Re: debugging segfaults in pythen PyQt (QWebview)

2011-03-04 Thread Marco Bizzarri
This applies to debugging a spinning Zope server, but I think you can adapt
the suggestions to your core dump:

http://www.upfrontsystems.co.za/Members/jean/zope-notes/debug-spinning-zope

Regards
Marco

On Thu, Mar 3, 2011 at 10:40 AM, Gelonida gelon...@gmail.com wrote:

 Hi,

 I have a QWebview application, which segfaults rather often,
 but not all the time.

 I assume it is some kind of race condition when loading a certain web
 page with quite some built in AJax.



 How can I debug it?

 The application crashes under Windows and under Linux.


 I enabled already core dumps and am able to

 start

 gdb python.exe core

 I guess the command bt
 will be able to give m a backtrace of  the C program


 Is there any way to obtain the related  backtrace of the python script?


 I'm at a complete loss of what I am doing wrong in my script and would
 hope to get at least some indication.


 --
 http://mail.python.org/mailman/listinfo/python-list




-- 
Marco Bizzarri
http://code.google.com/p/qt-asterisk/
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help me plsss...

2009-06-30 Thread Marco Bizzarri
Of course, you're sure that under

/data/oracle/product/10.2.0.3/lib


you can find

libclntsh.so.9.0

Regards
Marco



On Tue, Jun 30, 2009 at 1:45 PM, Harsha Reddy harsha.re...@db.com wrote:

 Hi All,

 Environment :-                 Solaris
 Python Version :-         ActivePython 2.4.3 Build 11 (ActiveState Software 
 Inc.) based on
                         Python 2.4.3 (#1, Apr  3 2006, 18:34:02) [C] on sunos5
 Oracle version :-         10.2.0.3

 Below is the library path

 echo $LD_LIBRARY_PATH
 /data/lgcmsp1/apps/dbus_3_0_8_14/vitria.3.1/SPARC_5.8/6.0/lib:/data/lgcmsp1/apps/dbus_3_0_8_14/SPARC_5.8/6.0/lib::/data/lgcmsp1/apps/dbus_3_0_8_14/SPARC_5.8/6.0/lib:/data/lgcmsp1/apps/dbus_3_0_8_14/vitria.3.1/SPARC_5.8/6.0/lib:/data/oracle/product/10.2.0.3/lib


 Issue :-

 We have been recently migrated from 9i to 10g database and also from AIX to 
 Solaris.

 When we were using 9i i can able to import cx_oracle library...

 But now iam in Solaris and 10g database and same when iam trying to do that 
 below is the error iam getting...

 newprd$ python
 ActivePython 2.4.3 Build 11 (ActiveState Software Inc.) based onPython 2.4.3 
 (#1, Apr  3 2006, 18:34:02) [C] on sunos5Type help, copyright, credits 
 or license for more information.

  import cx_Oracle
 Traceback (most recent call last):
   File stdin, line 1, in ?
 ImportError: ld.so.1: python: fatal: libclntsh.so.9.0: open failed: No such 
 file or directory

 Does it mean that cx_oracle library not there (or) if you see the error it's 
 trying to get 9i libraries fatal: libclntsh.so.9.0.



 PLs help meee ...
 Cheers,
 Harsha.

 FXPCA  GCMS  CLS SUPPORT
 Phone : +91-80-4187 3075
 FXPCA HOTLINE : +91-80-64522431 GCMS  CLS HOTLINE : +91-80-6450 8482
 
 P.S.: Please ensure all your FXPCA queries are CC'd to 
 fxpca_supp...@list.db.com  GCMS related queries are CC'd to 
 gcms_it_supp...@dmg UK  CLS related queries are CC'd to CLS_IT_SUPPORT to 
 get a quicker response in case of my absence
 

 --
 “This mail is transmitted to you on behalf of HCL Technologies
 Diese Post wird Ihnen im Namen der HCL Technologies übermittelt
 ---

 ---

 This e-mail may contain confidential and/or privileged information. If you 
 are not the intended recipient (or have received this e-mail in error) please 
 notify the sender immediately and delete this e-mail. Any unauthorized 
 copying, disclosure or distribution of the material in this e-mail is 
 strictly forbidden.

 Please refer to http://www.db.com/en/content/eu_disclosures.htm for 
 additional EU corporate and regulatory disclosures.

 --
 http://mail.python.org/mailman/listinfo/python-list




--
Marco Bizzarri
http://code.google.com/p/qt-asterisk/
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Decode a barcode ?

2009-06-24 Thread Marco Bizzarri
If you're looking for a library in python to find barcodes inside an image,
and then decoding it,  I'm afraid you're out of luck; as far as I can tell,
there is no such a library available.

In case you're looking for the theory on how to do that, I think this group
is not the best suited to post such a question :)

(( Despite the fact that many people could know the answer ))

regards
Marco

On Wed, Jun 24, 2009 at 3:06 PM, Stephane Wirtel steph...@openerp.comwrote:

 Hi all,

 I would like to know if there is a way to decode a barcode with a library ?

 Thank you so much,

 Stephane
 --
 Stephane Wirtel - As OpenERP is OpenSource, please feel free to
 contribute.
 Developper - Technical Lecturer OpenERP
 OpenERP - Tiny SPRL
 Chaussee de Namur, 40
 B-1367 Gerompont
 Tel: +32.81.81.37.00
 Web: http://www.tiny.be
 Web: http://www.openerp.com
 Planet: http://www.openerp.com/planet/
 Blog: http://stephane-wirtel-at-tiny.blogspot.com

 --
 http://mail.python.org/mailman/listinfo/python-list




-- 
Marco Bizzarri
http://code.google.com/p/qt-asterisk/
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python servlet for Java applet ?

2009-04-29 Thread Marco Bizzarri
On Wed, Apr 29, 2009 at 3:14 PM, Linuxguy123 linuxguy...@gmail.com wrote:

 How does one connect the servlet to the applet ?  Does anyone know of
 an example program that demonstrates a Python servlet with a Java
 applet ?

 Thanks !



Ok, let's make some basic questions:

1) do you know how to program an applet in order to invoke an URL on a server?

2) do you know how to program a server in order to answer to HTTP requests?

If the answer is *NO* in both cases, better if you take a look at this
topic in general (I'm sure you can google around a number of tutorials
on this) and then return here asking questions about what you're
unable to do in python.

Of course, these are my 2 cents.

Regards
Marco

-- 
Marco Bizzarri
http://sf.net/projects/qt-asterisk/
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: PyQt4 - widget signal trouble

2009-04-26 Thread Marco Bizzarri
On Sun, Apr 26, 2009 at 12:38 PM, Joacim Thomassen
joa...@net.homelinux.org wrote:
 Den Sat, 25 Apr 2009 23:47:57 +0200, skrev Marco Bizzarri:


 Hello Marco,

 python's fcntl() call the regular C fcntl() function and as stated in the
 manual pages for C fcntl:

 --- Snippet from fcntl man pages 

 File and directory change notification (dnotify)
       F_NOTIFY (long)
              (Linux  2.4 onwards) Provide notification when the
                      directory referred to by fd or any of the files that it
                      contains is changed.  The  events  to  be  notified  are
              specified in arg, which is a bit mask specified by ORing
                      together zero or more of the following bits:

              DN_MODIFY   A file was modified (write, pwrite, writev,
                                                       truncate, ftruncate).
 - End snippet of fcntl man pages ---

 The fact that my program actually trigger a signal as the monitored
 directoy's image.jpg file change confirm that this part of the code do
 work. I do get Change happened! as i manually do a cp another.jpg
 image.jpg, but this action is first seen after I close my application
 window. (I do not get Change happened! if I don't do my manual cp
 command. :-) )

 Personaly I believe this has something to do with the GUI/Qt4 part that I
 have not understood. Something about how a widget repaint itself or
 something in that direction.

 Best regards,
 Joacim
 --
 http://mail.python.org/mailman/listinfo/python-list



You're right: I've found the following answer googling:

http://mail.python.org/pipermail/python-list/2007-February/597617.html


indeed, addind a startTimer() to your code, makes it works ;).


Regards
Marco

-- 
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python not importing mysqldb

2009-04-25 Thread Marco Bizzarri
On Fri, Apr 24, 2009 at 10:04 PM, 83nini 83n...@gmail.com wrote:
 hi guys,

 i've been sweating the whole day trying to make python work with mysql
 but in vain!
 i'm doing the following:
 1. visiting http://sourceforge.net/projects/mysql-python
 2. dowloading mysql-python-test-1.2.3c1
 3. extracting the files to C:\Python26\Lib\site-packages
 4. writing import MySQLdb in the python prompt

 getting

 Traceback (most recent call last):
  File stdin, line 1, in module
  File C:\Python26\lib\site-packages\MySQLdb\__init__.py, line 19,
 in module

    import _mysql
 ImportError: No module named _mysql

 WHY Y
 why does it have to be so complicated what am i doing wrong for
 god's sake?



Suggestion: install python2.5 for windows, and then download this one:

http://sourceforge.net/project/downloading.php?group_id=22307filename=MySQL-python-1.2.2.win32-py2.5.exea=71602382

I'm sure you'll save yourself a lot of time.

Regards
Marco





-- 
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: DigitalSigner in Python

2009-04-25 Thread Marco Bizzarri
On Fri, Apr 24, 2009 at 7:57 AM, Good Z goodz...@yahoo.com wrote:
 Hello All,

 I need to digitally sign a document in python. Is there any equivalent
 directory in Python like the DigitalSigner we have in Java.

 Best Regards,
 Mike




Maybe you could take a look at M2Crypto?

http://chandlerproject.org/Projects/MeTooCrypto

Regards
Marco


-- 
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: authentication example with urllib.request

2009-04-25 Thread Marco Bizzarri
On Sat, Apr 25, 2009 at 8:09 AM, larryzhang zhangle2...@gmail.com wrote:
 Dear all,

 I am trying to download data from a website that requires
 authentication (maybe with cookies). Any suggestions on how i can do
 this with the urllib.request module in py3? Where can I can find some
 working examples? Thanks a lot.

 Larry
 --
 http://mail.python.org/mailman/listinfo/python-list



Hi, Larry.

Did you get a look at library documentation? If you take a look at
http://docs.python.org/3.0/library/urllib.request.html, FancyURLOpener
could do the job for you... (once you subclass it, and redefine the
promp_user_password method).

Regards
Marco



-- 
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: PyQt4 - widget signal trouble

2009-04-25 Thread Marco Bizzarri
On Fri, Apr 24, 2009 at 7:37 PM, Joacim Thomassen
joa...@net.homelinux.org wrote:
 Hello,

 I'm trying to get my first PyQt4 application to work as intended, but it
 seems I'm stuck and out of ideas for now.

 The program is a simple GUI showing an image. If the image on disk change
 my intension is that the displayed image in my application also change
 accordingly.

 What works: The filesystem change is detected and my program prints out
 Change happened!

 what is the problem: The image shown in the application is not changed.

 What am I doing wrong here? Any ideas and suggestions are appreciated.

 Best regards,
 Joacim Thomassen

 My program:
 #!/usr/bin/python
 
 familyframe.py

 Simple photo frame for the desktop

 Author: Joacim Thomassen, 4/2-2009
 License: AGPLv3+

 Last change: 24/2-2009
 

 from __future__ import division
 import sys
 from math import *
 from PyQt4.QtCore import *
 from PyQt4.QtGui import *

 import time
 import fcntl
 import os
 import signal

 fname = /home/joacim/.familyframe

 class Watcher(QObject):
        def handler(self, signum, frame):
                self.emit(SIGNAL(imageChange))
        def __init__(self, parent=None):
                super(Watcher, self).__init__()
                signal.signal(signal.SIGIO, self.handler)
                fd = os.open(fname, os.O_RDONLY)
                fcntl.fcntl(fd, fcntl.F_SETSIG, 0)
                fcntl.fcntl(fd, fcntl.F_NOTIFY, fcntl.DN_MODIFY |
 fcntl.DN_CREATE | fcntl.DN_MULTISHOT)

 class ImageWidget(QLabel):
        def __init__(self, parent=None):
                super(QLabel, self).__init__(parent)
                self.image = QImage(/home/joacim/.familyframe/image.jpg)
                self.setMinimumSize(200, 200)
                self.setAlignment(Qt.AlignCenter)
                self.setPixmap(QPixmap.fromImage(self.image))
        def reload(self):
                print Change happened!
                self.image.load(/home/joacim/.familyframe/image.jpg)
                self.setPixmap(QPixmap.fromImage(self.image))
                self.update()

 class CentralWidget(QWidget):
        def __init__(self, parent=None):
                super(QWidget, self).__init__(parent)
                self.imagewidget = ImageWidget()
                self.box = QHBoxLayout()
                self.box.addWidget(self.imagewidget)
                self.setLayout(self.box)
        def reload(self):
                self.imagewidget.reload()

 class MainWindow(QMainWindow):
        def __init__(self, w, parent=None):
                super(MainWindow, self).__init__(parent)
                self.centralwidget = CentralWidget()
                self.setWindowTitle(Family Frame)
                self.setCentralWidget(self.centralwidget)
                self.connect(w, SIGNAL(imageChange), self.updateUi)
                self.show()
        def updateUi(self):
                self.centralwidget.reload()

 if __name__ == __main__:
        app = QApplication(sys.argv)
        w = Watcher()
        main = MainWindow(w)
        app.exec_()
 --
 http://mail.python.org/mailman/listinfo/python-list


Ciao, Joacim.

Too much since I 'played' with low level calls, so I may be wrong. But
it seems to me you're opening the image and monitoring for changes the
directory. Hence the problem. If you read/write a file, I think the
directory does not result as modified (but you should experiment by
yourself).

Regards
Marco


-- 
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: return a value to shell script

2008-11-12 Thread Marco Bizzarri
On Wed, Nov 12, 2008 at 2:06 PM, devi thapa [EMAIL PROTECTED] wrote:
 Hi,

 I am executing a python script in a shell script.  The python script
 actually returns a value.
 So, can I get the return value in a shell script? If yes, then help me out.

 Regards,
 Devi
 --
 http://mail.python.org/mailman/listinfo/python-list


import sys

sys.exit(123)



-- 
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python barcode decoding

2008-10-28 Thread Marco Bizzarri
On Fri, Oct 24, 2008 at 6:05 PM, Robocop [EMAIL PROTECTED] wrote:
 Does anyone know of any decent (open source or commercial) python
 barcode recognition tools or libraries.  I need to read barcodes from
 pdfs or images, so it will involve some OCR algorithm.  I also only
 need to read the code 93 symbology, so it doesn't have to be very
 fancy.  The most important thing to me is that it outputs in some
 python friendly way, or ideally that it is written in python.  Any
 tips would be great!
 --
 http://mail.python.org/mailman/listinfo/python-list



If you don't mind using a commercial Java lib, use
http://www.tasman.co.uk/bars/readme.html. I'ts not exactly cheap, but
it works very well, and support is good.

The only suggestion I can give you is: stay away from mixed
OCR/Barcode recognition software; usually they are much slower.

Regards

-- 
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Unit Testing: a couple of questions

2008-10-28 Thread Marco Bizzarri
On Tue, Oct 28, 2008 at 3:56 PM, Emanuele D'Arrigo [EMAIL PROTECTED] wrote:
 Hi everybody,

 I'm just having a go with Unit Testing for the first time and my
 feeling about it in short is: Neat!

 I'm a bit worried about the time it's taking me to develop the tests
 but after only a day or so I'm already much faster than when I started
 with it and the code is already much improved in terms of robustness.
 A couple of philosophical questions have emerged in the process.

 1) Granularity
 Given a simple class

 class myClass():
def __init__(self, data):
__data = data;

def getData(self):
return __data

def setData(self, data):
 __data = data

 I've been wondering: where do I stop in terms of testing for things
 that could go wrong? In this case for example, it might be reasonable
 to expand the class to make sure it only receives integers and test
 accordingly, i.e.:

def setData(self, data):
try:
 data = int(data)
except ValueError:
raise ValueError(Argument received cannot be converted to
 integer:  + data)

 But would it be reasonable to test also for the assignment operators?
 After all, if, for some strange reason, there isn't enough memory,
 couldn't even __data = data potentially fail?

 2) Testing in isolation
 I'm not entirely clear on this point. I can see how I need to test
 each path of the program flow separately. But should a test -only-
 rely on the object being tested and mock ones in supporting roles?


IMHO, don't do that. Mocking everything and anything can become
incredibly complex. Wait to do it. As usual, experience plays a big
role on this; start mocking on what will make your test *simpler* and
easier to write and to understand, for you today and for you tomorrow
(and remember that you tomorrow is a different one from you today).

Before writing a mock, ask yourself: can I use a real object? The both
of you know the behaviour of the real object; you hadn't to think
about what some you yesterday wrote inside it.


 I.e. would this be wrong if SupportObject is not a mockup?

 def testObjectToBeTested _forReallyBadError(self):
supportObject = SupportObject()
objectToBeTested = ObjectToBeTested()
result =  objectToBeTested.addSupportObject(supportObject)
self.failIf(result != kSuccess, Support Object could not be
 added!)

 I can see how if the SupportObject class had a bug introduced in it,
 this test would fail even though it has nothing to do with the
 ObjectToBeTested class.

 However, creating mock objects can be quite an
 overhead (?). I'm wondering if there is a threshold, even a fuzzy one,
 under which it isn't worth doing and a test like the one above is
 good enough.



 What do you guys think?

 Manu
 --
 http://mail.python.org/mailman/listinfo/python-list


Creating mock objects in python can be quite easy; even more if you're
on a greenfield project, and not with some thousands or ten of
thousands of legacy code around. So, the burden is not that much. If
you end using more than a couple of mocks in one test, most probably
there is something wrong, and it would be better if you reconsider
your design.

Also, think if you really need mock object in your tests. Can't it be
easier to use a real object? Unless creating it is really complex,
and making it show the behaviour you want it to show is hard or
unclear, you can use it directly.

You wont' use a mock for a datetime object, am I right?

Moreover, don't fight your problem (integrating your objects) at the
wrong level (unit testing); you'll need integration tests, where you
use your *REAL* object end-to-end, maybe even talking with other
subsystems, in order to check that you are working for real. And
there,maybe, you could discover that your discipline failed and you
didn't changed the signature of the method of a mock object after you
changed it in the real one. It happens, so, put your tests in place to
catch this problem.

Regards
Marco

-- 
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: pyuno store OO object into blob

2008-10-12 Thread Marco Bizzarri
On Sun, Oct 12, 2008 at 1:41 PM, DarkBlue [EMAIL PROTECTED] wrote:
 Hello

 Python 2.5.1
 Qt 4.4.0
 PyQt 4.4.2
 OO 2.4.1
 Firebird 2.1

 I want to store an openoffice writer object into a blob field using
 the pyuno bridge. I read about the possibility of using streams ,
 but only see some old basic or java examples .

 The writer document has been created and stored into an odf file
 on disk. How to get it from there into the blob ?

 Thanks for any ideas.

 --
 http://mail.python.org/mailman/listinfo/python-list



I've little experience with firebird, and did this one only with
PostgreSQL; but once you get the odf file, can't you just write on a
temp file and read (and write) from that?

Regards
Marco


-- 
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Launching a subprocess without waiting around for the result?

2008-09-19 Thread Marco Bizzarri
On Fri, Sep 19, 2008 at 10:48 PM, Almar Klein [EMAIL PROTECTED] wrote:
 Ah, no, that's a different thing. If the parent exits, the child will
 also be killed I believe.

 Not if it's stuck in some endless loop...

 If you want to spawn a process and have it live on independent of the
 parent, you want to make the child process a daemon, detatching
 itself from the parent's environment. I don't recall how that's done
 immediately, but those are the terms to search for.

 I'm curious how this can be done, does anyone know this?

 Almar

 --
 http://mail.python.org/mailman/listinfo/python-list



First result in making a daemon in python with google:

http://mail.python.org/pipermail/python-list/2007-February/427692.html

(not tested)

Regards
Marco
-- 
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Zsi interoperability

2008-09-18 Thread Marco Bizzarri
On Thu, Sep 18, 2008 at 7:10 PM, Dieter Maurer [EMAIL PROTECTED] wrote:
 Marco Bizzarri [EMAIL PROTECTED] writes on Mon, 15 Sep 2008 20:26:27 
 +0200:
 On Mon, Sep 15, 2008 at 8:15 PM, Stefan Behnel [EMAIL PROTECTED] wrote:
  Mailing List SVR wrote:
  I have to implement a soap web services from wsdl, the server is
  developed using oracle, is zsi or some other python library for soap
  interoperable with oracle soa?
 
  No idea, but I'd definitely try soaplib before ZSI.
 
  Stefan

 I'm working on a project where I need to write a client for SOAP with
 Attachments; I can see ZSI does not support it

 The ZSI documentation (2.0) says that SOAP attachments are supported --
 but I never tried it.


 Dieter
 --
 http://mail.python.org/mailman/listinfo/python-list


That's right; but if you look at the code, it seems like it is able to
create a server which behaves in that way, but not to create a client
for it. But I'm still exploring...



-- 
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: recursion gotcha?

2008-09-14 Thread Marco Bizzarri
On Sun, Sep 14, 2008 at 10:01 AM, cnb [EMAIL PROTECTED] wrote:
 this recursive definition of sum thrumped me, is this some sort of
 gotcha or am I just braindead today?
 and yes i know this is easy a a for x in xs acc += x or just using the
 builtin.

 def suma(xs, acc=0):
if len(xs) == 0:
acc
else:
suma(xs[1:], acc+xs[0])

You're just missing the return statements?

def suma(xs, acc=0):
   if len(xs) == 0:
  return acc
   else:
  return suma(xs[1:], acc+xs[0])


Regards
Marco
-- 
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: recursion gotcha?

2008-09-14 Thread Marco Bizzarri
On Sun, Sep 14, 2008 at 10:08 AM, Marco Bizzarri
[EMAIL PROTECTED] wrote:
 On Sun, Sep 14, 2008 at 10:01 AM, cnb [EMAIL PROTECTED] wrote:
 this recursive definition of sum thrumped me, is this some sort of
 gotcha or am I just braindead today?
 and yes i know this is easy a a for x in xs acc += x or just using the
 builtin.

 def suma(xs, acc=0):
if len(xs) == 0:
acc
else:
suma(xs[1:], acc+xs[0])

 You're just missing the return statements?

 def suma(xs, acc=0):
   if len(xs) == 0:
  return acc
   else:
  return suma(xs[1:], acc+xs[0])



Besides: you can avoid the acc parameter:

def suma(xs):
if len(xs) == 0:
return 0
else:
return xs[0] + suma(xs[1:])

Regards
Marco


-- 
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Checking the boolean value of a collection

2008-09-13 Thread Marco Bizzarri
On Fri, Sep 12, 2008 at 6:07 PM, Bruno Desthuilliers
[EMAIL PROTECTED] wrote:
 Marco Bizzarri a écrit :
 (snip)

 I'm afraid this have another problem for me...


 [EMAIL PROTECTED]:/var/local/zope28/porting/Products/PAFlow$ python2.3
 Python 2.3.5 (#2, Oct 18 2006, 23:04:45)
 [GCC 4.1.2 20061015 (prerelease) (Debian 4.1.1-16.1)] on linux2
 Type help, copyright, credits or license for more information.

 def any(iterable): pass

 ...

 any(x for x in [1, 2, 3])

  File stdin, line 1
any(x for x in [1, 2, 3])
^
 SyntaxError: invalid syntax

 any([x for x in [1, 2, 3]])


 I mean, I'm afraid I can't use an expression like that without
 building a list... not at least in python2.3

 Err... a list being an iterable, you just need any([1, 2, 3]).

Ehm, yes, of course... I was trying just to show from a command line
what were my results.


 But this wont be enough to solve your real use case, indeed.


Yes, that's the point.



-- 
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Checking the boolean value of a collection

2008-09-13 Thread Marco Bizzarri
On Fri, Sep 12, 2008 at 4:09 PM, Diez B. Roggisch [EMAIL PROTECTED] wrote:


 You should also consider using PEP8 style naming.


 Diez


class FolderInUse:

def __init__(self, core):
self.core = core

def true_for(self, archivefolder):
return any([instance.forbid_to_close(archivefolder) for instance in
self.core.active_outgoing_registration_instances()])

Is this any better? The true_for name does not satisfy me a lot...
maybe because it is too similar to True. Anyway, I'm trying a good
naming so that code is readable, like:

specification = FolderInUse(core)

if specification.true_for(folder):
   ...

Any thought about this?

Regards
Marco


-- 
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


code style and readability [was: Re: Checking the boolean value of a collection]

2008-09-13 Thread Marco Bizzarri
On Sat, Sep 13, 2008 at 4:11 PM, Fredrik Lundh [EMAIL PROTECTED] wrote:
 Marco Bizzarri wrote:

 class FolderInUse:



def true_for(self, archivefolder):
return any([instance.forbid_to_close(archivefolder) for instance in
self.core.active_outgoing_registration_instances()])

 Is this any better? The true_for name does not satisfy me a lot...

 well, true_for is indeed pretty inscrutable, but I'm not sure that would
 be the first thing I'd complain about in that verbose mess...

verbose mess.

It is always frustrating when you do what you think is your best and
you read that.

Anyway: I'm here to learn, and, of course, part of it is to listen
those who've been there much longer than you.

So, thanks for your sincere evaluation, Fredrik :-).

 (when you pick method names, keep in mind that the reader will see the
 context, the instance, and the arguments at the same time as they see the
 name.  there's no need to use complete sentences; pick short short
 descriptive names instead.)

Maybe I'm looking at the wrong direction, right now. From the point of
view of the FolderInUse clients, they will do:

condition = FolderInUse(core)

condition.true_for(folder)

Is this too verbose? This is not a polemic statement, I'm really
asking your opionion.

The expression inside the true_for is indeed complex, and maybe I can
simplify it; however, I'm deeply convinced that

instance.forbid_to_close(folder)

has some good points on it; I mean, once I read this kind of code, I
can hope to understand it without looking at what forbid_to_close
does.


 /F


-- 
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Code example that will make a Skype connection?

2008-09-13 Thread Marco Bizzarri
On Sat, Sep 13, 2008 at 4:09 PM, Al Dykes [EMAIL PROTECTED] wrote:

 Can some post a Python code fragment that will to make a PC with Skpye
 installed to make a Skype call, given a valid phone # string.

 I'm not asking for code that handles the audio once the connection is
 made.



Maybe you can find this useful?


https://developer.skype.com/wiki/Skype4Py/examples/s4p_call_py


Regards
Marco

-- 
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Checking the boolean value of a collection

2008-09-12 Thread Marco Bizzarri
Hi all.

In many parts of my code I've the following schema of code:

def isInUseByOutgoingRegistrations(self, archivefolder):
for instance in self.findActiveOutgoingRegistrationInstances():
if instance.forbidToClose(archivefolder):
return True
return False

Before devising my own solution for this kind of problem, I wonder if
there is a common solution for the problem. I'm looking for a
python2.3 solution.

Regards
Marco

-- 
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Checking the boolean value of a collection

2008-09-12 Thread Marco Bizzarri
On Fri, Sep 12, 2008 at 4:09 PM, Diez B. Roggisch [EMAIL PROTECTED] wrote:
 Marco Bizzarri schrieb:

 Hi all.

 In many parts of my code I've the following schema of code:

def isInUseByOutgoingRegistrations(self, archivefolder):
for instance in self.findActiveOutgoingRegistrationInstances():
if instance.forbidToClose(archivefolder):
return True
return False

 Before devising my own solution for this kind of problem, I wonder if
 there is a common solution for the problem. I'm looking for a
 python2.3 solution.

 if any(instance.forbitToClose(archivefolder) for instance in
 self.findActiveOutgoingRegistrationInstances())

Can you clarify where I can find any? It seems to me I'm unable to find it...


 You should also consider using PEP8 style naming.


I knew that someone would have said that to me :-).

I'm doing that... slowly. I'm trying to fix naming conventions as I
had to work on my code...

 Diez
 --
 http://mail.python.org/mailman/listinfo/python-list




-- 
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Checking the boolean value of a collection

2008-09-12 Thread Marco Bizzarri
On Fri, Sep 12, 2008 at 4:44 PM, Diez B. Roggisch [EMAIL PROTECTED] wrote:
 if any(instance.forbitToClose(archivefolder) for instance in
 self.findActiveOutgoingRegistrationInstances())

 Can you clarify where I can find any? It seems to me I'm unable to find
 it...

 It's part of python2.5.

 If you don't have that, you can write it your own and stuff it into
 __builtins__:

 def any(iterable):
 ... for item in iterable:
 ... if item:
 ...  return True
 ... return False
 ...
 ... __builtins__.any = any


 You might also want to add all, the companion of any:


 def all(iterable):
 ... for item in iterable:
 ... if not item:
 ...  return False
 ... return True
 ...

 Diez
 --
 http://mail.python.org/mailman/listinfo/python-list


Thanks for the clarification, Diez! Indeed, I tried python2.3 and
python2.4, and of course not python2.5 ;)

I would like to make  this available to the whole project. I suspect I
could put it in the package __init__.py... in that way, the
__builtins__ namespace should have it... am I right?

-- 
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Checking the boolean value of a collection

2008-09-12 Thread Marco Bizzarri
On Fri, Sep 12, 2008 at 4:44 PM, Diez B. Roggisch [EMAIL PROTECTED] wrote:
 if any(instance.forbitToClose(archivefolder) for instance in
 self.findActiveOutgoingRegistrationInstances())

 Can you clarify where I can find any? It seems to me I'm unable to find
 it...

 It's part of python2.5.

 If you don't have that, you can write it your own and stuff it into
 __builtins__:

 def any(iterable):
 ... for item in iterable:
 ... if item:
 ...  return True
 ... return False
 ...
 ... __builtins__.any = any


 You might also want to add all, the companion of any:


 def all(iterable):
 ... for item in iterable:
 ... if not item:
 ...  return False
 ... return True
 ...

 Diez
 --
 http://mail.python.org/mailman/listinfo/python-list


I'm afraid this have another problem for me...


[EMAIL PROTECTED]:/var/local/zope28/porting/Products/PAFlow$ python2.3
Python 2.3.5 (#2, Oct 18 2006, 23:04:45)
[GCC 4.1.2 20061015 (prerelease) (Debian 4.1.1-16.1)] on linux2
Type help, copyright, credits or license for more information.
 def any(iterable): pass
...
 any(x for x in [1, 2, 3])
  File stdin, line 1
any(x for x in [1, 2, 3])
^
SyntaxError: invalid syntax


 any([x for x in [1, 2, 3]])


I mean, I'm afraid I can't use an expression like that without
building a list... not at least in python2.3

Regards
Marco

-- 
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python and Open Office

2008-09-11 Thread Marco Bizzarri
Greg, as an addition to what I already said to you, you can consider
taking a look at oood from ERP5 project

http://wiki.erp5.org/HowToUseOood

OOOd (openoffice.org daemon) runs openoffice behind the scene, and
allows you to interact with it via XML-RPC; it should be quite robust,
since it is actively mantained and used in a big software project.
And, also, it should be quite easy to extend in order to have your
custom functions run via XML-RPC.

Regards
Marco

-- 
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Adding further report options to unittest.py

2008-09-10 Thread Marco Bizzarri
Hi all.

I would like to change the way test reports are generated, in a Zope
environment.

I'm playing with TextTestReport, TextTestRunner. Since things are
getting to complicated, I'm afraid I'm following a non-pythonic way.

Specifically, I would like to have an output like:

package.subpackage.test_module.TestCase 0.1

where 0.1 is the time spent into doing the test.

In a previous attempt, I made the tests print the number of the test
executed, so that I would have the following output:

1 package.subpackage.test_module.TestCase

however, to do this, I had to put things in the following way:


class PAFlowTestRunner(TextTestRunner):
def _makeResult(self):
return PAFlowTextResult(self.stream, self.descriptions, self.verbosity)

class PAFlowTextResult(_TextTestResult):

def startTest(self, test):
self.stream.write(%s  % self.testsRun)
_TextTestResult.startTest(self, test)


now, of course, this is ugly, because I'm using _TextTestResult, which
I'm not supposed to know, and I'm changing behaviour by subclassing,
which is not exactly what I would like to do.

What is the pythonic way to accomplish this?

Marco
-- 
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Presenting calculation results

2008-09-10 Thread Marco Bizzarri
On Wed, Sep 10, 2008 at 6:46 PM, Vedran [EMAIL PROTECTED] wrote:
 Hello!

 I would like to present the results of the calculations on the web using
 Python and Apache. Currently I have java console applications that
 generate text files with results. Can somebody point me in the right
 direction from where to start?

 Thanks in advance!
 --
 http://mail.python.org/mailman/listinfo/python-list



http://www.modpython.org/

Regards
Marco
-- 
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Adding further report options to unittest.py

2008-09-10 Thread Marco Bizzarri
On Wed, Sep 10, 2008 at 3:25 PM, Diez B. Roggisch [EMAIL PROTECTED] wrote:
 Marco Bizzarri wrote:

 Hi all.

 I would like to change the way test reports are generated, in a Zope
 environment.


 Have you looked at nosetests? Nose is a test-discovery  running-framework
 based upon unittest-module (but you can also only test simple functions,
 very handy)

Nope; next time I will make a google search before posting ;)

 And it has a very powerful plugin-mechanism, that allows you to implement
 cleanly what you want.

 For each test, you get a start/end-method called in your plugin that you can
 use to gather the information you need, e.g. start/stop-times.


I gave it a look; it is nice and it seems powerful; I just wonder if I
need to put my hands on all my tests to do what I want to do... but
I'm sure this can be sorted in the documentation.


 For example, I've created an enhanced reporting plugin that lists all tests
 run (not only those failed or error'ed), and adding time-measuring per-test
 is on my list of todos.


Looks like there is a new tool I need to learn... ah, nice times when
all you needed was an hammer and a screwdriver... ;)


Thanks for the suggestion, Diez, I'll read it.


 Diez



-- 
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python and Open Office

2008-09-10 Thread Marco Bizzarri
On Wed, Sep 10, 2008 at 10:04 PM, Greg Lindstrom [EMAIL PROTECTED] wrote:
 Hello,

 I would like to create and manipulate Open Office documents using Python.  I
 have found then UNO Python page and odfpy modules which seem to be exactly
 what I need.  The odfpy manual is, to me, a confusing list of objects and
 methods (it's an impressive list!), but does not have much in the way of how
 to use them.  For example, I can open a spreadsheet and create new pages
 (there's a nice example near the back of the manual) but I can't figure out
 how to open an existing spreadsheet and list the names of the individual
 sheets (tabs).

 I have written an application that access Microsoft Excel and creates
 reports for work, but would like to create an Open Source version using Open
 Office and release it to the community (and maybe get a talk at PyCon :-).

 Is there someone here who can help me out, or is there an appropriate
 mailing list for me to join?

Ciao, Greg.

you should check with the openoffice.org mailing list; I think what
you are looking for is the api mailing list for openoffice; you could
try to get the OpenOffice.org developers guide and the SDK, and check
it (but it is not a little work)

Regards
Marco


 Thanks

 --greg

 --
 http://mail.python.org/mailman/listinfo/python-list




-- 
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: use str as variable name

2008-09-06 Thread Marco Bizzarri
On Fri, Sep 5, 2008 at 9:16 PM, Bruno Desthuilliers
[EMAIL PROTECTED] wrote:
 Marco Bizzarri a écrit :

 Just a question: generic functions are not meant in the sense of
 generic functions of CLOS, am I right?

 Nope. Just generic in the sense that they accept any object implementing a
 very minimal interface.

 If you want something like CLOS multimethods, you may be interested in
 Philip Eby's ruledispatch.


Even though I loved them when I used at university, I'm not looking
for them right now... but nice to know that they are available under
python :-)


-- 
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: use str as variable name

2008-09-06 Thread Marco Bizzarri
On Sat, Sep 6, 2008 at 7:52 AM, Fredrik Lundh [EMAIL PROTECTED] wrote:
 Marco Bizzarri wrote:

 (...as Bruno implies, setattr(), len() et al can be and should be viewed
 as
 generic functions.

 Just a question: generic functions are not meant in the sense of
 generic functions of CLOS, am I right?

 it's meant in exactly that sense: len(L) means of all len() implementations
 available to the runtime, execute the most specific code we have for the
 object L.


It is a generic functions like a CLOS one, as long as we remain to one
parameter.

I mean, there will be just one implemenatation of

foo(bar, man)

which the python interpretr can find; am I right?

-- 
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Understanding the pythonic way: why a.x = 1 is better than a.setX(1) ?

2008-09-05 Thread Marco Bizzarri
On Thu, Sep 4, 2008 at 7:15 PM, Timothy Grant [EMAIL PROTECTED] wrote:

 I think the most obvious solution to the problem is effective unit
 tests. If you type a.y =1 and have a test that asserts a.x == 1 then
 you would quite quickly discover that you made a typo.


 --
 Stand Fast,
 tjg. [Timothy Grant]


Right; that is one of the things I try to do to avoid this sort of problems.

-- 
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Core dumped while interacting with OpenOffice.org via pyuno

2008-09-05 Thread Marco Bizzarri
Hi all.

I'm experiencing a core dump while working in the following environment

- debain etch
- python2.3
- openoffice.org 2.4
- Zope 2.8.8

I was able to get a core dump, and the backtrace shows the following:

Core was generated by `python2.3 tests/testActs.py'.
Program terminated with signal 11, Segmentation fault.
#0  0xb6b5219c in ?? () from /usr/lib/openoffice/program/libuno_cppu.so.3
(gdb) bt
#0  0xb6b5219c in ?? () from /usr/lib/openoffice/program/libuno_cppu.so.3
#1  0xb6b547d3 in ?? () from /usr/lib/openoffice/program/libuno_cppu.so.3
#2  0xb6b531d2 in ?? () from /usr/lib/openoffice/program/libuno_cppu.so.3
#3  0xb6b53748 in uno_threadpool_enter () from
/usr/lib/openoffice/program/libuno_cppu.so.3
#4  0xb5c80c8c in ?? () from /usr/lib/openoffice/program/liburp_uno.so
#5  0xb5c7d1e8 in ?? () from /usr/lib/openoffice/program/liburp_uno.so
#6  0xb5c8710e in ?? () from /usr/lib/openoffice/program/liburp_uno.so
#7  0xb5c8727c in ?? () from /usr/lib/openoffice/program/liburp_uno.so
#8  0xb5c76a62 in ?? () from /usr/lib/openoffice/program/liburp_uno.so
#9  0xb68c76c7 in ?? () from /usr/lib/openoffice/program/libuno_sal.so.3
#10 0x08797840 in ?? ()
#11 0x0989b6e0 in ?? ()
#12 0x in ?? ()

Now, I can understand that the information I provided are not enough
to give me suggestions on solving this issue; so, I'm asking
suggesions on investigating the issue, namely:

- should I ask here or is it better if I ask on a openoffice forum?
- should I use a debug-enabled python in order to have more meaningful
backtraces?
- is there something else I should do in order to have more clues
(Read The Fine Manual (tm) is an acceptable answer)

Regards
Marco

-- 
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Core dumped while interacting with OpenOffice.org via pyuno

2008-09-05 Thread Marco Bizzarri
On Fri, Sep 5, 2008 at 3:50 PM, Maric Michaud [EMAIL PROTECTED] wrote:
 Le Friday 05 September 2008 15:04:22 Marco Bizzarri, vous avez écrit :
 Hi all.

 I'm experiencing a core dump while working in the following environment

 - debain etch
 - python2.3
 - openoffice.org 2.4
 - Zope 2.8.8

 I was able to get a core dump, and the backtrace shows the following:

 Core was generated by `python2.3 tests/testActs.py'.
 Program terminated with signal 11, Segmentation fault.
 #0  0xb6b5219c in ?? () from /usr/lib/openoffice/program/libuno_cppu.so.3
 ... lot of backtrace ...
 #9  0xb68c76c7 in ?? () from /usr/lib/openoffice/program/libuno_sal.so.3
 #10 0x08797840 in ?? ()
 #11 0x0989b6e0 in ?? ()
 #12 0x in ?? ()

 Now, I can understand that the information I provided are not enough
 to give me suggestions on solving this issue; so, I'm asking
 suggesions on investigating the issue, namely:

 - should I ask here or is it better if I ask on a openoffice forum?

 Yes.

Ok

 - should I use a debug-enabled python in order to have more meaningful
 backtraces?

 What you need is more a debug enabled version of pyuno libraries.

Ok; I will check with the openoffice guys, then.


 - is there something else I should do in order to have more clues
 (Read The Fine Manual (tm) is an acceptable answer)

 You can try to find which function call exactly provoke the exception, the
 simplest way is to trace execution flow with some print statments and using
 non forking zope instance (runzope -d if I remember well).


Ok; just for completeness, this is not a running zope application, it
is a ZopeTestCase which is causing me the trouble. And, as usual, it
does not cause it always :-)

Regards
Marco

-- 
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: use str as variable name

2008-09-05 Thread Marco Bizzarri
On Thu, Sep 4, 2008 at 10:47 AM, Fredrik Lundh [EMAIL PROTECTED] wrote:


 (...as Bruno implies, setattr(), len() et al can be and should be viewed as
 generic functions.

Just a question: generic functions are not meant in the sense of
generic functions of CLOS, am I right?

-- 
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: overwrite set behavior

2008-09-04 Thread Marco Bizzarri
Ciao, Michele:

On Thu, Sep 4, 2008 at 11:48 AM, Michele Petrazzo
[EMAIL PROTECTED] wrote:
 Hi all, I want to modify the method that set use for see if there is
 already an object inside its obj-list. Something like this:

 class foo: pass

 bar1 = foo()
 bar1.attr = 1

 bar2 = foo()
 bar2.attr = 1

 set( (bar1, bar2), key=lambda o: o.attr)

 and, of course, set has only one value.

 It's possible?

 Thanks,
 Michele
 --
 http://mail.python.org/mailman/listinfo/python-list


looking at the source, maybe you could create a subclass of Set
redefining the __contains__ method?

Regards
Marco


-- 
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: overwrite set behavior

2008-09-04 Thread Marco Bizzarri
On Thu, Sep 4, 2008 at 11:58 AM, Wojtek Walczak [EMAIL PROTECTED] wrote:
 On Thu, 04 Sep 2008 11:48:18 +0200, Michele Petrazzo wrote:
 Hi all, I want to modify the method that set use for see if there is
 already an object inside its obj-list. Something like this:
 ...
 It's possible?

 As far as I understand you, you need descriptors:
 http://users.rcn.com/python/download/Descriptor.htm


I know descriptors a litte, Wojtek, but didn't use them often; can you
elaborate a little more on your idea?

 --
 Regards,
 Wojtek Walczak,
 http://tosh.pl/gminick/
 --
 http://mail.python.org/mailman/listinfo/python-list



Saluti
Marco
-- 
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Coming from .NET and VB and C

2008-09-04 Thread Marco Bizzarri
On Thu, Sep 4, 2008 at 12:16 AM, Dennis Lee Bieber
[EMAIL PROTECTED] wrote:
 On Wed, 3 Sep 2008 09:52:06 -0700 (PDT), ToPostMustJoinGroup22
 [EMAIL PROTECTED] declaimed the following in
 comp.lang.python:

 have no preference with MySQL or SQL, stored procedures or ad-hoc
 queries.

Please note: MySQL is specific relational database management system
 (RDBMs), which uses a dialect of structured query language (SQL). SQL by
 itself is just a semi-standardized query language -- and can technically
 be used to access non-relational DBMS (if any such are still in use),
 though the query processor would be a pain to program (map a relational
 join into a hierarchical DBMS schema? ugh).

 SO, I'm interested in using my Google App space (free 500MB) to
 develop a quick database application.  Using Python.  I found Dive
 Into Python which I will be reading shortly.

So one question: what RDBMs are supported in that space?

The appearance is not an RDBMS, at least, maybe it is, but under the surface.

Looks more that you've persistent objects with a SQL-like language to
query them.

Regards
Marco


-- 
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Understanding the pythonic way: why a.x = 1 is better than a.setX(1) ?

2008-09-04 Thread Marco Bizzarri
Let's say I've a class a, where I can write:



-- 
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Understanding the pythonic way: why a.x = 1 is better than a.setX(1) ?

2008-09-04 Thread Marco Bizzarri
On Thu, Sep 4, 2008 at 1:00 PM, Diez B. Roggisch [EMAIL PROTECTED] wrote:
 Marco Bizzarri wrote:

 Let's say I've a class a, where I can write:

 Anticipating this obviously premature posting:

 http://dirtsimple.org/2004/12/python-is-not-java.html

 Diez
 --
 http://mail.python.org/mailman/listinfo/python-list


Ehi, Diez, that was fast :-) !

Thanks for the link, I saw it in the past days and I read it; and I
appreciated it a lot  (actually, it was a door to a new world in
Python, for me). But I'm asking something I feel is a little
different, as you can read in my message, once it is full.

Regards
Marco

-- 
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Understanding the pythonic way: why a.x = 1 is better than a.setX(1) ?

2008-09-04 Thread Marco Bizzarri
Sorry... pressed enter but really didn't want to.

As I said, let's say I have a class

class A:
def __init__(self):
 self.x = None



Python makes the decision to allow the developers to directly access
the attribute x,  so that they can directly write: a.x = 1, or
whatever; this has for me the unfortunate side effect that if I write,
for example a.y = 1, when I really wanted to write a.x = 1 no one
cares about it, and I'm unable to spot this error until later.

Of course, I know that while I'm fresh, I've a good knowledge of the
code, and anything else, I will be able to avoid such stupid errors;
however, I'm afraid of the times when I'm tired, when I have to put my
hands on the code of someone else, and so on.

Please, understand that I'm not stating that python is wrong... after
all, if it is wrong, I can move to a language like Java, which has a
different approach on it. I'm really very interested in reading past
discussion on it, if they are available.

Regards
Marco



On Thu, Sep 4, 2008 at 12:57 PM, Marco Bizzarri
[EMAIL PROTECTED] wrote:
 Let's say I've a class a, where I can write:



 --
 Marco Bizzarri
 http://notenotturne.blogspot.com/
 http://iliveinpisa.blogspot.com/




-- 
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Coming from .NET and VB and C

2008-09-04 Thread Marco Bizzarri
On Thu, Sep 4, 2008 at 1:23 PM, Bruno Desthuilliers
[EMAIL PROTECTED] wrote:

 The appearance is not an RDBMS, at least, maybe it is, but under the
 surface.

 Not AFAIK, cf:
 http://en.wikipedia.org/wiki/BigTable

 --
 http://mail.python.org/mailman/listinfo/python-list


Thanks for the pointer, Bruno... I wrote from my memory, but there is
some bank of it which need quick replace ;)


-- 
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: overwrite set behavior

2008-09-04 Thread Marco Bizzarri
On Thu, Sep 4, 2008 at 3:07 PM, Maric Michaud [EMAIL PROTECTED] wrote:
 Le Thursday 04 September 2008 14:31:23 Michele Petrazzo, vous avez écrit :
 Marco Bizzarri wrote:
  looking at the source, maybe you could create a subclass of Set
  redefining the __contains__ method?

 Made some tries, but __contains__ are never called


 No, __contains__ is only called  with in operator, not for internal hashing.
 Anyway this solution is bad, you'll need to compare the new element with all
 the set contain, which would result in a O(n) algorithm for adding elements
 to the set in place of the O(1) it use.


Thanks for the clarification, Maric; I take notices to watch source
more closely next time (( hopefully, before writing a wrong answer )).

Regards
Marco

 _

 Maric Michaud
 --
 http://mail.python.org/mailman/listinfo/python-list




-- 
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Understanding the pythonic way: why a.x = 1 is better than a.setX(1) ?

2008-09-04 Thread Marco Bizzarri
On Thu, Sep 4, 2008 at 1:19 PM, Diez B. Roggisch [EMAIL PROTECTED] wrote:


 What you are essentially asking is: why is python dynamic instead of static?


Most probably you're right. Maybe I will make a trip back to my
university books and take a look at them again :-)

Thanks
Marco

-- 
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Understanding the pythonic way: why a.x = 1 is better than a.setX(1) ?

2008-09-04 Thread Marco Bizzarri
On Thu, Sep 4, 2008 at 4:39 PM, Marco Bizzarri [EMAIL PROTECTED] wrote:

 Most probably you're right. Maybe I will make a trip back to my
 university books and take a look at them again :-)


Meant: you *are* right. Sorry.

Saluti
Marco

-- 
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Understanding the pythonic way: why a.x = 1 is better than a.setX(1) ?

2008-09-04 Thread Marco Bizzarri
On Thu, Sep 4, 2008 at 8:59 PM, Carl Banks [EMAIL PROTECTED] wrote:


 You can write code to guard against this if you want:

 class A:
legal = set([x])
def __setattr__(self,attr,val):
if attr not in self.legal:
raise AttributeError(A object has no attribute '%s' %
 attr)
self.__dict__[attr] = val
def __init__(self,x):
self.y = x


 I suspect most people who go into Python doing something like this
 soon abandon it when they see how rarely it actually catches anything.


 Carl Banks
 --
 http://mail.python.org/mailman/listinfo/python-list


marco_scracthing_his_head

Carl, I think I did not explained what I was asking the right way.

/marco_scracthing_his_head

I'm not asking: how can I do this sort of checks in Python: as I
stated before, if I want them, I will go for Java, or some other
language like that.

I understand that Python is a balance between different forces (like
any software object around the world) and I'm simply asking some
pointers to the discussion leading to this balance.

That's all.


-- 
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Using httplib to access servlets on tomcat server

2008-09-03 Thread Marco Bizzarri
On Wed, Sep 3, 2008 at 11:06 AM, jorma kala [EMAIL PROTECTED] wrote:
 Hi,

 I'm trying unsuccesfully to use the httplib library to execute servlets on a
 local tomcat server.

 If I type the following http adress on my browser
 http://localhost:8080/test/Serv1  the servlet works fine.
 But if I try to access it with the following python code:

conn = httplib.HTTPConnection(http://localhost:8080;)
conn.request(GET, /test/Serv1)
r1 = conn.getresponse()

 I get the following error:

 socket.gaierror: (11001, 'getaddrinfo failed')

 Do you know what I do wrong?
 Thank you very much.




localhost is not resolved to 127.0.0.1 on your machine.

Try changing it to http://127.0.0.1:8080

Regards
Marco


-- 
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python IDEs with F5 or hotkey shell interaction

2008-09-03 Thread Marco Bizzarri
On Tue, Sep 2, 2008 at 4:01 PM, mmm [EMAIL PROTECTED] wrote:

 I might look at
  Eclypse with pydev
  Jedit
 And these commercial/professional IDEs
  Wing
  Komodo IDE
  Zeus

 But before doing so I wanted to know form experienced users:

 ** How hard is it to configure any of the general editors/IDEs to run
 a Python shell using a hotkey (such as IDLEs F5) and whether any can
 be set up for full interactivity.

 I understand and appreciate  the difficulties to get full IDLE-like
 interactivity, but what comes closest?
 --
 http://mail.python.org/mailman/listinfo/python-list


I do not think I qualify for experienced users; I've used pydev for
many years, and I'm quite comfortable with it. It is an eclipse based
IDE, therefore you've some of its niceties and some of its drawbacks.

Regards
Marco

-- 
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Retrieving http headers from HTTPConnection object

2008-09-01 Thread Marco Bizzarri
On Mon, Sep 1, 2008 at 1:06 PM, jorma kala [EMAIL PROTECTED] wrote:
 Hi,

 when using  httplib for http requests, like for example:


conn = httplib.HTTPConnection(www.python.org)
conn.request(GET, /index.html)

 Is it possible to retrieve the complete http request in string form :


 GET /index.html HTTP/1.1
 Host: www.python.org
 User-Agent: ...
 Accept:   ...
 Accept-Language:
 Accept-Encoding:
 Accept-Charset:
 Keep-Alive:
 Connection:

 I mean does  the HTTPConnection object have a property that stores this ?
 or is it retrievable by some other form?

 Thanks a lot.
 --

Looking at the code of HTTPConnection, all that goes through the
_output message (including, therefore, the putheaders) are appended to
the self._buffer list.

Regards
Marco

-- 
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: How to print first(national) char from unicode string encoded in utf-8?

2008-09-01 Thread Marco Bizzarri
2008/9/1  [EMAIL PROTECTED]:
 Hi,

 I have a problem with unicode string in Pylons templates(Mako). I will
 print first char from my string encoded in UTF-8 and urllib.quote(),
 for example string 'Łukasz':

 ${urllib.unquote(c.user.firstName).encode('latin-1')[0:1]}

 and I received this information:

 type 'exceptions.UnicodeDecodeError': 'utf8' codec can't decode byte
 0xc5 in position 0: unexpected end of data

 When I change from [0:1] to [0:2] everything is ok. I think it is
 because of unicode and encoding utf-8(2 bytes).

 How to resolve this problem?

 Best regards
 --
 http://mail.python.org/mailman/listinfo/python-list


First: you're talking about utf8 encoding, but you've written latin1
encoding. Even though I do not know Mako templates, there should be no
problem in your snippet of code, if encoding is latin1, at least for
what I can understand.

Do not assume utf8 is a two byte encoding; utf8 is a variable length
encoding. Indeed,

'a' encoded as utf8 is 'a' (one byte)

'à' encode as utf8 is '\xc3\xa0' (two bytes).


Can you explain what you're trying to accomplish (rather than how
you're tryin to accomplish it) ?



Regards
Marco



-- 
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list

Re: How to print first(national) char from unicode string encoded in utf-8?

2008-09-01 Thread Marco Bizzarri
On Mon, Sep 1, 2008 at 3:25 PM,  [EMAIL PROTECTED] wrote:


 When I do ${urllib.unquote(c.user.firstName)} without encoding to
 latin-1 I got different chars than I will get: no Łukasz but Å ukasz
 --
 http://mail.python.org/mailman/listinfo/python-list

That's crazy. string.encode('latin1') gives you a latin1 encoded
string; latin1 is a single byte encoding, therefore taking the first
byte should be no problem.

Have you tried:

urlib.unquote(c.user.firstName)[0].encode('latin1') or

urlib.unquote(c.user.firstName)[0].encode('utf8')

I'm assuming here that the urlib.unquote(c.user.firstName) returns an
encodable string (which I'm absolutely not sure), but if it does, this
should take the first 'character'.

Regards
Marco
-- 
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: __stack_chk_fail_local

2008-08-30 Thread Marco Bizzarri
On Fri, Aug 29, 2008 at 7:53 PM, gianluca [EMAIL PROTECTED] wrote:
 hy list,
 I've built _libfoo.so and  libfoo.py library with swig and I've copied
 in /usr/lib/python2.5/lib-dynload/ but when import the module

import libfoo

 I've that message

 Traceback (most recent call last):
  File stdin, line 1, in module
 ImportError: /usr/lib/python2.5/lib-dynload/_libfoo.so: undefined
 symbol: __stack_chk_fail_local

 Could anybody help me?

 gianluca
 --
 http://mail.python.org/mailman/listinfo/python-list


Have you tried to use ldd against the _libfoo.so to check if it is
able to get all the libraries it needs?

Regards
Marco

-- 
Marco Bizzarri
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Advice on the style to use in imports

2008-08-30 Thread Marco Bizzarri
Hi all.

I read the PEP8 and the importing Python Modules article. However,
I'm still a little confused on what should the general rules for
importing modules.

I'm showing what I used in my current project, and will accept your
advices on how I should change them.

The style is consistently the following:

from package.subpackge.module import MyClass

Is this an accepted way to write imports? According to what I
understood in articles, I don't think so.

If I understand it correctly, it should be:

import module

and then use

module.MyClass

( in case of a flat module)

or

from package.subpackage import module

and then use

module.MyClass

(( for a package/subpackage structure ))

Thank you all for your attention

Regards
Marco

-- 
Marco Bizzarri
http://iliveinpisa.blogspot.com/
http://notenotturne.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: __stack_chk_fail_local

2008-08-30 Thread Marco Bizzarri
The ldd should point you to the library which is not loaded.

Maybe the library you need is not in one of the normal locations in
your Linux/Unix path.

Normally, the linker looks for library under /lib and /usr/lib, and
maybe other paths specified in /etc/ld.so.conf

If you know the library is installed in your system, you can force the
linker to look for it, either modifying your /etc/ld.so.conf (better
if you know what you're doing, however) or, just setting the
LD_LIBRARY_PATH variable:

export LD_LIBRARY_PATH=/some/non/standard/lib/dir/

python -c import foo

Another possibility, which you can check googling a little, is that
you've two different versions of the libarary around your system, and
that you're loading the wrong one (i.e., python is looking at the
wrong one)

again, setting the LD_LIBRARY_PATH should help

Regards
Marco

On Sat, Aug 30, 2008 at 2:33 PM, gianluca [EMAIL PROTECTED] wrote:
 On 30 Ago, 12:05, Marco Bizzarri [EMAIL PROTECTED] wrote:
 On Fri, Aug 29, 2008 at 7:53 PM, gianluca [EMAIL PROTECTED] wrote:
  hy list,
  I've built _libfoo.so and  libfoo.py library with swig and I've copied
  in /usr/lib/python2.5/lib-dynload/ but when import the module

 import libfoo

  I've that message

  Traceback (most recent call last):
   File stdin, line 1, in module
  ImportError: /usr/lib/python2.5/lib-dynload/_libfoo.so: undefined
  symbol: __stack_chk_fail_local

  Could anybody help me?

  gianluca
  --
 http://mail.python.org/mailman/listinfo/python-list

 Have you tried to use ldd against the _libfoo.so to check if it is
 able to get all the libraries it needs?

 Regards
 Marco

 --
 Marco Bizzarrihttp://iliveinpisa.blogspot.com/

 I've tried with ldd and the library aren't loaded. I don't use my *.i
 interface so is quite difficult modify it (realy, the libraru is
 supplied with make).

 Any suggests?
 gianluca
 --
 http://mail.python.org/mailman/listinfo/python-list




-- 
Marco Bizzarri
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: __stack_chk_fail_local

2008-08-30 Thread Marco Bizzarri
On Sat, Aug 30, 2008 at 3:03 PM, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 Thanks!
 I've resolved the problem with libraries but... I've still error with this 
 message:
 ImportError: ./_python_grass6.so: undefined symbol: __stack_chk_fail_local

 exuse me, I'm not a guru.

 Gianluca


I'm not a guru either, Gianluca ;)

I made a little search on Google; the first link is the following:

http://ubuntuforums.org/showthread.php?t=352642

can you apply the suggestion?

I think you should give a little more context on your problem, also,
because I think it has to do with your setup (not that you setup
something in the wrong way: just to have context).

Regards
Marco




-- 
Marco Bizzarri
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Advice on the style to use in imports

2008-08-30 Thread Marco Bizzarri
On Sat, Aug 30, 2008 at 2:20 PM, Fredrik Lundh [EMAIL PROTECTED] wrote:

 importing objects instead of the module (namespace) they live in can cause
 all sorts of aliasing and dependency issues.  avoid unless you know exactly
 what you're doing.

 /F


Thanks Fredrik; I understand that is the underlying message of your article.

I'm just confused because PEP8 seems to suggest that the from module
import Class style is acceptable; is there a big if you know what are
doing before, which I'm unable to see?

Regards
Marco


-- 
Marco Bizzarri
http://iliveinpisa.blogspot.com/
http://notenotturne.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Advice on the style to use in imports

2008-08-30 Thread Marco Bizzarri
Hi bearophile

On Sat, Aug 30, 2008 at 4:04 PM,  [EMAIL PROTECTED] wrote:



 from somemodule import somename

 is often acceptable IHMO, but there are some things to consider:
 - you and the person that reads your code have to remember where
 somename comes from. So you can do it for well known names like izip
 or imap, but if you import lots of names from lots of modules, things
 may become too much complex. So often it can be better to import just
 the modules, and use somemodule.somename.

Yes, that's true; but when I see that I need so many symbols from
another module, I take that as an hint that either my module is doing
too many things, and it should be splitted, or it is tightly coupled
to that module... actually, being forced to write all the imports in
that way was a tool into inspecting the dependencies in our project.

 - somemodule.somename is longer to write and to read, and if it's
 repeated many times it may worsen the program readability, making
 lines of code and expressions too much long and heavy. So you have to
 use your brain (this means that you may have to avoid standard
 solutions). Note that you can use a compromise, shortening the module
 name like this:
 import somemodule as sm
 Then you can use:
 sm.somename

it is not a problem to have special cases, as long as they are
special; I'm looking for more or less accepted solutions; of course
any project has some area where it is better to follow readability
over standards; I'm just trying to understand the standards, then I
will deviate from them.

I feel like I'm learning to drive: first I learn the rules, then I
learn the exceptions ;)

 - somemodule.somename requires an extra lookup, so in long tight loops

The slowdown was what in the first place made me import all the names
directly; but I'm not afraid too much from that, right now.


 (if you don't use Psyco) it slows down the code. This can be solved
 locally, assigning a local name into a function/method (or even in
 their argument list, but that's a hack to be used only once in a
 while):
 localname = somemodule.somename

 Bye,
 bearophile
 --
 http://mail.python.org/mailman/listinfo/python-list


Thanks again for sharing your thoughts with me, bearophile.


-- 
Marco Bizzarri
http://iliveinpisa.blogspot.com/
http://notenotturne.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Advice on the style to use in imports

2008-08-30 Thread Marco Bizzarri
On Sat, Aug 30, 2008 at 4:53 PM, Eric Wertman [EMAIL PROTECTED] wrote:
 I read the PEP8 and the importing Python Modules article. However,
 I'm still a little confused on what should the general rules for
 importing modules.

 I'm showing what I used in my current project, and will accept your
 advices on how I should change them.

 import module

 and then use

 module.MyClass

 ( in case of a flat module)

 or

 from package.subpackage import module

 and then use

 module.MyClass

 (( for a package/subpackage structure ))

 My opinion is that this is the preffered way, generally speaking.  Not
 only does it avoid namespace issues as effbot pointed out, but it also
 makes code easier to read later.  As examples, I tend to break those
 rules frequently with these :

 from pprint import pprint  # Because pprint.pprint is just redundant
 from lxml import etree # Actually I guess this doesn't break the rule.
 from datetime import datetime  # This might be a bad idea... I haven't
 had problems yet though.  datetime.datetime gets on my nerves though.

 just my .02

 Eric
 --
 http://mail.python.org/mailman/listinfo/python-list


Thanks Eric; your 02 cents are worthy for me ;)

Regards
Marco



-- 
Marco Bizzarri
http://iliveinpisa.blogspot.com/
http://notenotturne.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Writing to ms excel

2008-08-30 Thread Marco Bizzarri
On Sat, Aug 30, 2008 at 4:41 PM, Marin Brkic [EMAIL PROTECTED] wrote:
 Hello all,



 I'm trying to find a way to write data to excel cells (or to be more
 specific to an .xls file), let's say for the sake of argument, data
 readen from a file (although it will be calculated in the process).
 I've been searching, but couldn't find any examples which allows that.

Is it suitable for you to use a python program talking with a running
instance of openoffice? in that case, pyuno could help you.


-- 
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Counting Elements in an xml file

2008-08-30 Thread Marco Bizzarri
On Sat, Aug 30, 2008 at 7:37 PM, Ouray Viney [EMAIL PROTECTED] wrote:
 Hi All:

 I am looking at writing a python script that will let me parse a
 TestSuite xml file that contains n number of TestCases.

 My goal is to be able to count the TestCase elements base on a key
 value pair in the xml node.

 Example

 Testcase execute=true name=foobar

 I would like to be able to count the number of TestCases that contain
 the execute=true but not the ones that contain execute=false.

 I have review the python docs and various python ebooks.

 Does anyone have any experience with this sort of thing?  If so, could
 you suggest a good library and possibly some samples?

Isn't the SAX part of this howto

http://pyxml.sourceforge.net/topics/howto/xml-howto.html

enough for you to create your parser?


Regards
Marco

-- 
Marco Bizzarri
http://iliveinpisa.blogspot.com/
http://notenotturne.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: problem with packages and path

2008-08-28 Thread Marco Bizzarri
On Wed, Aug 27, 2008 at 6:44 PM, Daniel [EMAIL PROTECTED] wrote:
 Hello,

 I'm writing some unit tests for my python software which uses
 packages.  Here is the basic structure:

 mypackage
  __init__.py
  module1
__init__.py
mod1.py
  module2
__init__.py
mod2.py
  unittests
__init__.py
alltests.py
test1.py
test2.py

 within alltests.py I would expect to be able to import
 mypackage.unittests.test1.  In fact within PyScripter this works as
 expected.  However, when I execute the code from the command line, I
 get the following error:

 ImportError: No module named mypackage.unittests.test1


1) What is the command you're using to run the alltest.py module?

2) what is the result of:
   - python -c import mypackage
  - python -c import mypackage.unittests

Regards
Marco



-- 
Marco Bizzarri
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python and database unittests

2008-08-27 Thread Marco Bizzarri
On Wed, Aug 27, 2008 at 4:55 AM, alex23 [EMAIL PROTECTED] wrote:
 Daniel [EMAIL PROTECTED] wrote:
 Does anyone know about a module that acts as a database stub for
 python unittests?

 It's not database-specific, but the Mock module should help you here:

 http://python-mock.sourceforge.net/

 There's even an example on that page for mocking a database.
 --
 http://mail.python.org/mailman/listinfo/python-list




-- 
Marco Bizzarri
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python and database unittests

2008-08-27 Thread Marco Bizzarri
On Wed, Aug 27, 2008 at 4:55 AM, alex23 [EMAIL PROTECTED] wrote:
 Daniel [EMAIL PROTECTED] wrote:
 Does anyone know about a module that acts as a database stub for
 python unittests?

 It's not database-specific, but the Mock module should help you here:

 http://python-mock.sourceforge.net/

 There's even an example on that page for mocking a database.
 --
 http://mail.python.org/mailman/listinfo/python-list


I strongly disagree on using mocks for a database; checking sequences
of SQL statement is fragile, painful, and leads you to frustration
when the actual SQL and the generated SQL do not match.

Regards
Marco

-- 
Marco Bizzarri
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python and database unittests

2008-08-27 Thread Marco Bizzarri
On Tue, Aug 26, 2008 at 11:35 PM, Daniel [EMAIL PROTECTED] wrote:
 Hello,

 I'm writing an application that interacts with a database.  As I think
 about how to write the unittests, I want them to be able to run
 without actually having to access a live database.  The pattern that
 best describes this is here:

 http://martinfowler.com/eaaCatalog/serviceStub.html

 I have found http://qualitylabs.org/pdbseed/, which helps with
 unittests for a live database.  This isn't what I'm after.

 Does anyone know about a module that acts as a database stub for
 python unittests?

 Thanks,
 Daniel
 --
 http://mail.python.org/mailman/listinfo/python-list



I think you're pointing to the wrong direction, if you want to make a
servicestub; the service should encapsulate your access to the
database (or whatever external resource you want to access), and,
after that, it should be transparent for you, more or less.

Regards
Marco


-- 
Marco Bizzarri
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie needs help

2008-08-27 Thread Marco Bizzarri
On Tue, Aug 26, 2008 at 8:33 PM, frankrentef [EMAIL PROTECTED] wrote:


 Would the second file need something akin to...

 loginout.admin (ie,url,adminlogin)

Yes. Since you're importing the whole module.



-- 
Marco Bizzarri
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python and database unittests

2008-08-27 Thread Marco Bizzarri
On Wed, Aug 27, 2008 at 10:26 AM, Simon Brunning
[EMAIL PROTECTED] wrote:
 2008/8/27 Marco Bizzarri [EMAIL PROTECTED]:
 I strongly disagree on using mocks for a database; checking sequences
 of SQL statement is fragile, painful, and leads you to frustration
 when the actual SQL and the generated SQL do not match.

 Clearly you need integration tests as well as unit tests, but the unit
 tests ought to isolate the code under test, so stubbing out external
 dependencies is the norm.


I agree with you about stubbing external dependencies; I'm just
suggesting to stub the stuff a little further, so that you're not
exposed to actual SQL code.



Regards
Marco


 --
 Cheers,
 Simon B.
 [EMAIL PROTECTED]
 http://www.brunningonline.net/simon/blog/
 GTalk: simon.brunning | MSN: small_values | Yahoo: smallvalues | Twitter: 
 brunns
 --
 http://mail.python.org/mailman/listinfo/python-list






-- 
Marco Bizzarri
http://iliveinpisa.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list