Re: Object serialization: transfer from a to b (non-implemented code on b)

2010-04-16 Thread Gabriel Rossetti
Andreas Löscher wrote: import types import marshal def a(): pass ... s=marshal.dumps(a.__code__) f=types.FunctionType(marshal.loads(s), {}) f What version of python do you have? If I try your code above I get : >>> import type

Re: Object serialization: transfer from a to b (non-implemented code on b)

2010-04-15 Thread Gabriel Rossetti
Andreas Löscher wrote: Am Mittwoch, den 14.04.2010, 11:33 +0200 schrieb Gabriel Rossetti: Paul Rubin wrote: Gabriel Rossetti writes: I am trying to serialize a function, class, etc and transfer it You mean the actual code? You have to use marshal rather than

Re: Object serialization: transfer from a to b (non-implemented code on b)

2010-04-14 Thread Gabriel Rossetti
Andreas Löscher wrote: Am Mittwoch, den 14.04.2010, 11:33 +0200 schrieb Gabriel Rossetti: Paul Rubin wrote: Gabriel Rossetti writes: I am trying to serialize a function, class, etc and transfer it You mean the actual code? You have to use marshal rather than

Re: Object serialization: transfer from a to b (non-implemented code on b)

2010-04-14 Thread Gabriel Rossetti
Paul Rubin wrote: Gabriel Rossetti writes: I am trying to serialize a function, class, etc and transfer it You mean the actual code? You have to use marshal rather than pickle, the Python versions have to be the same at both ends, and you better have some kind of authenticated

Object serialization: transfer from a to b (non-implemented code on b)

2010-04-14 Thread Gabriel Rossetti
Hello everyone, I am trying to serialize a function, class, etc and transfer it, have it unserialized and used. The thing is that this code is not defined on the receiving side and thus it does not work. I tried the following tests: Terminal A: >>> import pickle >>> def test(): pass ... >>>

Re: Anything like "Effective Java" for Python?

2010-03-12 Thread Gabriel Rossetti
kj wrote: Subject line pretty much says it all: is there a book like "Effective Java" for Python. I.e. a book that assumes that readers are experienced programmers that already know the basics of the language, and want to focus on more advanced programming issues? ~K Effective Java is a g

Re: Any Swisses here?

2010-01-26 Thread Gabriel Rossetti
n00m wrote: Congrats! Your choice -- to ban building of muslim mosques -- is the only choice to save our civililazation. This yellow plague (incl. Chinese etc) must be eliminated from our Planet, They are very cunning critters, they can play on strings of compassion, but its riffraffs. What do yo

regex help

2009-12-16 Thread Gabriel Rossetti
Hello everyone, I'm going nuts with some regex, could someone please show me what I'm doing wrong? I have an XMPP msg : 123 456 ... the node may be absent or empty (), the node may be absent. I'd like to grab everything exept the

platform module problem when frozen?

2009-12-16 Thread Gabriel Rossetti
Hello everyone, I am having problems with the platform module when being run from a frozen program (py2exe). It imports it fine, but it gives me the following error : 'module' object does not contain attribute 'platform' when I do this : platform.platfom() Does platform have a problem with

Re: UnboundLocalError: local variable '_[1]' referenced before assignment

2009-12-09 Thread Gabriel Rossetti
Dave Angel wrote: Gabriel Rossetti wrote: Hello everyone, I get this error on python 2.6.1 on mac os x 10.6 : UnboundLocalError: local variable '_[1]' referenced before assignment here's the code that raises this: params = [ self.__formatData(paramProcFunc, query, p)

no SPA in poplib?

2009-12-09 Thread Gabriel Rossetti
Hello, I couldn't find SPA in poplib, does anyone know of an alternative implementation? Thanks, Gabriel -- Arimaz SA Ingénieur en Informatique Av. du 24 Janvier 11 Ateliers de la Ville de Renens, Atelier 5 1020 Renens, Switzerland www.arimaz.com www.mydeskfriend.com Mob: +41-(0)79-539-0069 T

UnboundLocalError: local variable '_[1]' referenced before assignment

2009-12-09 Thread Gabriel Rossetti
Hello everyone, I get this error on python 2.6.1 on mac os x 10.6 : UnboundLocalError: local variable '_[1]' referenced before assignment here's the code that raises this: params = [ self.__formatData(paramProcFunc, query, p) for p in params ] what I don't get is that it worked on mac os x 10

shelve, segfault and bsddb.db.DBPageNotFoundError: (-30987, 'DB_PAGE_NOTFOUND: Requested page not found')

2009-10-14 Thread Gabriel Rossetti
Hello everyone, I get the following error with the shelve module (python 2.5.2) sometimes : >>> s = shelve.open("save.dat", writeback=True) >>> s Traceback (most recent call last): File "", line 1, in File "/usr/lib/python2.5/UserDict.py", line 167, in __repr__ return repr(dict(self.iterit

on package import, have it conditionally import a subpackage

2009-09-19 Thread Gabriel Rossetti
Hello everyone, I'd like to ba able to import a package and have it's __init__ conditionally import a subpackage. Suppose that you have this structure : mybase/ mybase/__init__.py mybase/mypkg mybase/mypkg/__init__.py mybase/mypkg/module0.py mybase/mypkg/type1 mybase/mypkg/type1/__init__.py my

Windows binaries of python in debug mode

2009-09-07 Thread Gabriel Rossetti
Hello everyone, I am looking for a version of python 2.5.x compiled for windows in debug mode, but I can't find this, does anyone have a link or have a version that he/she can send me? Thank you, Gabriel -- http://mail.python.org/mailman/listinfo/python-list

socket bug or not?

2009-08-19 Thread Gabriel Rossetti
Hello everyone, I found what was not working in my code (see Twisted mailing list topics "self.socket.accept() in doRead() in tcp.py has (11, 'Resource temporarily unavailable') error", "Twisted, PushProducer, Words & big msgs, any limit?" and Python mailing list topic "socket.send : (11, 'Re

Re: socket.send : (11, 'Resource temporarily unavailable')

2009-08-14 Thread Gabriel Rossetti
Gabriel Rossetti wrote: Hello everyone, I get a (11, 'Resource temporarily unavailable') error when I try to send a file using a socket. Is there s size limit? I tried sending a smaller file and ii poses no problem. Am I doing something wrong? Here is the code: def sendMessage(

socket.send : (11, 'Resource temporarily unavailable')

2009-08-14 Thread Gabriel Rossetti
Hello everyone, I get a (11, 'Resource temporarily unavailable') error when I try to send a file using a socket. Is there s size limit? I tried sending a smaller file and ii poses no problem. Am I doing something wrong? Here is the code: def sendMessage(host, port, msg): if isinstance(ms

Re: no return value for threading.Condition.wait(timeout)?

2009-07-17 Thread Gabriel Rossetti
Piet van Oostrum wrote: Gabriel Rossetti (GR) wrote: GR> I have a 1-1 relation, I have a thread reading msgs from a network socket GR> and a method waiting for an answer to arrive (see my thread GR> "Threading.Condition problem"). I would like to be able t

Re: no return value for threading.Condition.wait(timeout)?

2009-07-16 Thread Gabriel Rossetti
Piet van Oostrum wrote: Gabriel Rossetti (GR) wrote: GR> Hello everyone, GR> I am using threading.Condition.wait(timeout) and was surprised to see that GR> there is no return value nor an exception when wait() is used w/ a timeout. GR> How am I supposed to kn

Re: no return value for threading.Condition.wait(timeout)?

2009-07-16 Thread Gabriel Rossetti
Maxim Khitrov wrote: On Thu, Jul 16, 2009 at 5:00 PM, Carl Banks wrote: On Jul 16, 8:12 am, Gabriel Rossetti wrote: Hello everyone, I am using threading.Condition.wait(timeout) and was surprised to see that there is no return value nor an exception when wait() is used w/ a timeout

no return value for threading.Condition.wait(timeout)?

2009-07-16 Thread Gabriel Rossetti
Hello everyone, I am using threading.Condition.wait(timeout) and was surprised to see that there is no return value nor an exception when wait() is used w/ a timeout. How am I supposed to know if it was notified or if it timed out? cheers, Gabriel -- http://mail.python.org/mailman/listinfo/py

Re: Threading.Condition problem

2009-07-13 Thread Gabriel Rossetti
Piet van Oostrum wrote: Gabriel Rossetti (GR) wrote: GR> Sorry if this appears twice, I sent it once with an attachment and it never GR> arrived so maybe the attachment is posing problems. I inlined the code this GR> time (at the bottom), thank you, GR

Re: Blocking XMPP API?

2009-07-13 Thread Gabriel Rossetti
Lawrence D'Oliveiro wrote: In message , Gabriel Rossetti wrote: I am looking for blocking XMPP API. I'm wanting to make a webservice that uses XMPP, but all the XMPP libs I find are non-blocking (i.e. w/ callbacks). So why not have the caller sleep or something until the c

Threading.Condition problem

2009-07-10 Thread Gabriel Rossetti
Sorry if this appears twice, I sent it once with an attachment and it never arrived so maybe the attachment is posing problems. I inlined the code this time (at the bottom), thank you, Gabriel ## Original message Hello everyone, I wrote a

Re: Threading.Condition problem

2009-07-10 Thread Gabriel Rossetti
The previous msg w/ attached code is the wrong code, please use the code attached to this msg, thank you and sorry for this. Gabriel Gabriel Rossetti wrote: Hello everyone, I wrote a small example that listens for xmpp msgs in a thread. The main program calls a function that blocks (using

Threading.Condition problem

2009-07-10 Thread Gabriel Rossetti
Hello everyone, I wrote a small example that listens for xmpp msgs in a thread. The main program calls a function that blocks (using Condition.wait) until a msg has been received and then returns the msg. When a msg arrives, it is put in a variable in the thread's object, it then calls the not

Blocking XMPP API?

2009-07-09 Thread Gabriel Rossetti
Hello everyone, I am looking for blocking XMPP API. I'm wanting to make a webservice that uses XMPP, but all the XMPP libs I find are non-blocking (i.e. w/ callbacks). I'd like to be able to do something like : cl = Client("t...@domain.com/res01", "password",) msg = "any ideas? Using Java I h

Re: sqlite3, OperationalError: no such column, shouldn't that ne a ProgrammingError?

2009-06-17 Thread Gabriel Rossetti
John Machin wrote: On Jun 17, 1:41 am, Gabriel Rossetti wrote: Hello everyone, I get an OperationalError with sqlite3 if I put the wrong column name, but shouldn't that be a ProgrammingError instead? I read PEP 249 and it says : [snip] and to me it sounds more like a progra

sqlite3, OperationalError: no such column, shouldn't that ne a ProgrammingError?

2009-06-16 Thread Gabriel Rossetti
Hello everyone, I get an OperationalError with sqlite3 if I put the wrong column name, but shouldn't that be a ProgrammingError instead? I read PEP 249 and it says : "OperationalError Exception raised for errors that are related to the database's operat

Re: DB-API execute params, am I missing something?

2009-05-28 Thread Gabriel Rossetti
Paul Boddie wrote: On 26 Mai, 13:46, Gabriel Rossetti wrote: def getParams(curs): curs.execute("select * from param where id=%d", 1001) First of all, you should use the database module's parameter style, which is probably "%s" - something I've thou

Re: DB-API execute params, am I missing something?

2009-05-28 Thread Gabriel Rossetti
Diez B. Roggisch wrote: Gabriel Rossetti wrote: Hello everyone, I am trying to use dbapi with mysql and I get this error: Traceback (most recent call last): File "", line 1, in File "", line 2, in getUnitParams File "/var/lib/python-support/python2.5/MySQ

DB-API execute params, am I missing something?

2009-05-26 Thread Gabriel Rossetti
Hello everyone, I am trying to use dbapi with mysql and I get this error: Traceback (most recent call last): File "", line 1, in File "", line 2, in getUnitParams File "/var/lib/python-support/python2.5/MySQLdb/cursors.py", line 151, in execute query = query % db.literal(args) TypeError:

Re: UDP reading on multiple sockets

2009-05-19 Thread Gabriel Rossetti
thomas.vo...@likeabird.de wrote: On 17 Mai, 04:22, Grant Edwards wrote: On 2009-05-17, Thomas Vogel wrote: I'm currently have the problem that I try to read UDP messages from multiple sockets in parallel. So let's say I get UDP packets from the same IP on the ports 2000, 2001, 2002,.

Re: Dynamically declared shared constant/variable imported twice problem

2009-05-01 Thread Gabriel Rossetti
Peter Otten wrote: Gabriel Rossetti wrote: I have three modules A, B, C; A declares this globally : UpdateEvent, UPDATE_EVENT_ID = wx.lib.newevent.NewEvent() Then they import stuff from each other: - A imports a constant from module B (in "__main__") - A imports a clas

Dynamically declared shared constant/variable imported twice problem

2009-05-01 Thread Gabriel Rossetti
Hello everyone, I have three modules A, B, C; A declares this globally : UpdateEvent, UPDATE_EVENT_ID = wx.lib.newevent.NewEvent() Then they import stuff from each other: - A imports a constant from module B (in "__main__") - A imports a class and some constants from module C - B imports a c

Re: [Py2exe-users] installer for py2exe files?

2009-04-22 Thread Gabriel Rossetti
Gabriel Rossetti wrote: Hello everyone, I am wanting to create an installer for my project. I first use py2exe to create win32 executables and then would like to have an easy to use (for the end user) installer. I would need the installer to launch a script (a python script also turned into

py2exe with BeautifulSoup and simplejson error

2009-04-22 Thread Gabriel Rossetti
Hello everyone, I am tryng to use py2exe with BeautifulSoup and simplejson. I have already successfully used it with storm and twisted, but for some reason py2exe does not find neither BeautifulSoup nor simplejson. I did do something different when installing those packages, I used easy_install a

installer for py2exe files?

2009-04-22 Thread Gabriel Rossetti
Hello everyone, I am wanting to create an installer for my project. I first use py2exe to create win32 executables and then would like to have an easy to use (for the end user) installer. I would need the installer to launch a script (a python script also turned into an exec) after the install

Re: Beautiful soup : why does "string" not give me the string?

2009-04-01 Thread Gabriel Rossetti
Jeremiah Dodds wrote: On Wed, Apr 1, 2009 at 8:25 AM, Gabriel Rossetti mailto:gabriel.rosse...@arimaz.com>> wrote: Hello everyone, I am using beautiful soup to parse some HTML and I came across something strange. Here is an illustration: >>> soup

Re: BeautifulSoup : why does "string" not give me the string?

2009-04-01 Thread Gabriel Rossetti
Gabriel Rossetti wrote: Hello everyone, I am using BeautifulSoup to parse some HTML and I came across something strange. Here is an illustration: soup = BeautifulSoup(u'hello ça boume hello ça boume soup.find("div", "text") hello ça boume soup.find("div&q

BeautifulSoup : why does "string" not give me the string?

2009-04-01 Thread Gabriel Rossetti
Hello everyone, I am using BeautifulSoup to parse some HTML and I came across something strange. Here is an illustration: soup = BeautifulSoup(u'hello ça boume hello ça boume soup.find("div", "text") hello ça boume soup.find("div", "text").string soup.find("div", "text").next u'hello \xe7a

Beautiful soup : why does "string" not give me the string?

2009-04-01 Thread Gabriel Rossetti
Hello everyone, I am using beautiful soup to parse some HTML and I came across something strange. Here is an illustration: >>> soup = BeautifulSoup(u'hello ça boume>> soup hello ça boume >>> soup.find("div", "text") hello ça boume >>> soup.find("div", "text").string >>> soup.find("div", "text"

Re: urllib2 problem, data param not working? : DISREGARD

2009-04-01 Thread Gabriel Rossetti
Gabriel Rossetti wrote: Hello everyone, I am having a problem with urllib2, when I do this : post = urllib.urlencode(post) request = urllib2.Request(url, post) response = urllib2.urlopen(request) or this : post = urllib.urlencode(post) response = urllib2.urlopen(url, post) or

Re: regex negative lookbehind assertion not working correctly?

2009-03-31 Thread Gabriel Rossetti
MRAB wrote: Gabriel Rossetti wrote: Hello everyone, I am trying to write a regex pattern to match an ID in a URL only if it is not a given ID. Here's an example, the ID not to match is "14522XXX98", if my URL is "/profile.php?id=14522XXX99" I want it to match and

urllib2 problem, data param not working?

2009-03-31 Thread Gabriel Rossetti
Hello everyone, I am having a problem with urllib2, when I do this : post = urllib.urlencode(post) request = urllib2.Request(url, post) response = urllib2.urlopen(request) or this : post = urllib.urlencode(post) response = urllib2.urlopen(url, post) or this : post = urllib.

regex negative lookbehind assertion not working correctly?

2009-03-31 Thread Gabriel Rossetti
Hello everyone, I am trying to write a regex pattern to match an ID in a URL only if it is not a given ID. Here's an example, the ID not to match is "14522XXX98", if my URL is "/profile.php?id=14522XXX99" I want it to match and if it's "/profile.php?id=14522XXX98" I want it not to. I tried th

Re: shared lib from python code?

2009-02-24 Thread Gabriel Rossetti
Duncan Booth wrote: Gabriel Rossetti wrote: Ok, maybe I mis-stated my problem (or mis-understood your answers).. I don' t want to share code as in have multiple processes access a variable and have the same value, like it is done in threads, what I want is to not have n copies o

Re: shared lib from python code?

2009-02-24 Thread Gabriel Rossetti
andrew cooke wrote: Gabriel Rossetti wrote: Ok, maybe I mis-stated my problem (or mis-understood your answers).. I don' t want to share code as in have multiple processes access a variable and have the same value, like it is done in threads, what I want is to not have n copies of the

Re: shared lib from python code?

2009-02-23 Thread Gabriel Rossetti
Gabriel Rossetti wrote: Hello everyone, I would like to know if it is possible to turn python code into a shared lib? I have several processes that use the same base code, and it seems like every process loads the "shared" code into memory. I would like it to be loaded once and sh

shared lib from python code?

2009-02-23 Thread Gabriel Rossetti
Hello everyone, I would like to know if it is possible to turn python code into a shared lib? I have several processes that use the same base code, and it seems like every process loads the "shared" code into memory. I would like it to be loaded once and shared, like a .so in linux or a .dll i

Re: Python/environment problem with char encoding/decoding

2009-02-18 Thread Gabriel Rossetti
Peter Otten wrote: Gabriel Rossetti wrote: Hello everyone, I originally posted this on the Twisted mailing list, but now it seams to be a more general python/environment problem. If I run the attached example in Eclipse, it works, if I run it from a terminal, it doesn't, I get : $ p

Python/environment problem with char encoding/decoding

2009-02-18 Thread Gabriel Rossetti
Hello everyone, I originally posted this on the Twisted mailing list, but now it seams to be a more general python/environment problem. If I run the attached example in Eclipse, it works, if I run it from a terminal, it doesn't, I get : $ python xml_parser_test.py Traceback (most recent cal

poplib

2009-02-10 Thread Gabriel Rossetti
Hello, I am using poplib and I noticed that calls to top() don't return the msg info (2nd index in the returned list, e.g. email.top(1,0)[1]) in the same order, by that I mean the date could be email.top(1,0)[1][2] or email.top(1,0)[1][5], etc. Is there a reason for that other than that may b

Re: Python package Management GUI - New Project on Sourceforge

2009-02-01 Thread Gabriel Rossetti
James Mills wrote: On Mon, Feb 2, 2009 at 2:57 PM, David Lyon wrote: To be truly cross platform, consider using the Tcl/Tk toolkit rather tahn wxWindows. Why ? Because Tcl/TK is packaged and provided along with most Python distributions. I agree with your point.. The problem is that

Re: memory leak?

2008-12-10 Thread Gabriel Rossetti
Gabriel Rossetti wrote: Terry Reedy wrote: Gabriel Rossetti wrote: I ran these tests on linux 2.6 (ubuntu 8.04) using python 2.5.2. Have you tried the much newer 2.6? 2.5.3 will be out soon with some bug fixes. Thanks for the reply Terry, I just tried the pyserial example with python

Re: memory leak?

2008-12-10 Thread Gabriel Rossetti
Terry Reedy wrote: Gabriel Rossetti wrote: I ran these tests on linux 2.6 (ubuntu 8.04) using python 2.5.2. Have you tried the much newer 2.6? 2.5.3 will be out soon with some bug fixes. Thanks for the reply Terry, I just tried the pyserial example with python 2.6 and it still has the

memory leak?

2008-12-09 Thread Gabriel Rossetti
I have been debugging a distributed application for about 2 days that has a memory leak. My app is a Twisted app, so I thought that maybe it was on the twisted side, I finally isolated it to no being a Twisted problem but a Python problem. The problem comes from the code that uses wxPython and

Re: crossplatform standalone python apps

2008-10-22 Thread Gabriel Rossetti
Martin v. Löwis wrote: I like to create a cross-platform standalone python application, like Mac OS *.app dirs. The idea is to distribute a zip file containing everything (the python interpreter and all) so that a user just unzips it and runs it. I don't think this can possibly work. If t

crossplatform standalone python apps

2008-10-16 Thread Gabriel Rossetti
Hello everyone, I like to create a cross-platform standalone python application, like Mac OS *.app dirs. The idea is to distribute a zip file containing everything (the python interpreter and all) so that a user just unzips it and runs it. Has anyone ever done anything like that? I searched g

Re: book recommendation for Python newbie?

2008-10-10 Thread Gabriel Rossetti
Joe Strout wrote: I'm trying to (gently) convince my business partner that we should be adding Python to our core toolset. He's never used it before, apart from poking around in the tutorial a bit at my urging. But he's got a birthday coming up, and I'd like to get him a book that will help h

time

2008-10-07 Thread Gabriel Rossetti
Hello everyone! I trying to work with time and I a bit confused... If I look at my clock, it's 16:59 (4:59pm), if I type "date" in a terminal, it says the same thing. I'm wanting to write a simple NTP-type server/client (it's not NTP at all actually, but does the same thing). The idea is that

Re: python freeze help

2008-09-23 Thread Gabriel Rossetti
Mike Driscoll wrote: On Sep 23, 5:01 am, Gabriel Rossetti <[EMAIL PROTECTED]> wrote: Hello everyone, I'm trying to use python's freeze utility but I'm running into problems. I called it like this : python /usr/share/doc/python2.5/examples/Tools/freeze/freeze.py ~/Docu

python freeze help

2008-09-23 Thread Gabriel Rossetti
Hello everyone, I'm trying to use python's freeze utility but I'm running into problems. I called it like this : python /usr/share/doc/python2.5/examples/Tools/freeze/freeze.py ~/Documents/Code/Python/src/jester/service.py -m jester then I did : make then I tried to run it : ./service and

os.ChDir() not thread-safe; was : Is tempfile.mkdtemp() thread-safe?

2008-08-29 Thread Gabriel Rossetti
Gabriel Rossetti wrote: Hello, I'm using tempfile.mkdtemp() in a multithreading program and I've been having problems with it. Sometimes it tells me the file I'm trying to access (in the directory created with tempfile.mkdtemp()) doesn't exist. I suspect that tempfile.m

dynamically adding some of one module's functions to another

2008-08-26 Thread Gabriel Rossetti
Hello everyone, I'm trying to import some modules into another's namespace (network_utils) network_utils.py: import utils import constants as main_const from services import constants as srv_const from plugins import constants as plg_const # # Import all the message creation functions # f = di

Re: Is tempfile.mkdtemp() thread-safe?

2008-08-22 Thread Gabriel Rossetti
Dennis Lee Bieber wrote: On Thu, 21 Aug 2008 13:22:33 +0200, Gabriel Rossetti <[EMAIL PROTECTED]> declaimed the following in comp.lang.python: have a solution? I have to create unique and temp. directories to use an external program that creates a temp. file with the same name every

Re: Is tempfile.mkdtemp() thread-safe?

2008-08-22 Thread Gabriel Rossetti
Dennis Lee Bieber wrote: On Thu, 21 Aug 2008 13:22:33 +0200, Gabriel Rossetti <[EMAIL PROTECTED]> declaimed the following in comp.lang.python: have a solution? I have to create unique and temp. directories to use an external program that creates a temp. file with the same name every

Re: getattr() on nested functions?

2008-08-21 Thread Gabriel Rossetti
Bruno Desthuilliers wrote: Gabriel Rossetti a écrit : Terry Reedy wrote: (snip) Unlike the class approach, this requires recreating the constant functions and dict with each call to _test. Quick to write but a bit 'dirty', in my opinion. Another standard idiom is to set up the

Is tempfile.mkdtemp() thread-safe?

2008-08-21 Thread Gabriel Rossetti
Hello, I'm using tempfile.mkdtemp() in a multithreading program and I've been having problems with it. Sometimes it tells me the file I'm trying to access (in the directory created with tempfile.mkdtemp()) doesn't exist. I suspect that tempfile.mkdtemp() returns the same directory to differen

Re: getattr() on nested functions?

2008-08-21 Thread Gabriel Rossetti
Terry Reedy wrote: Gabriel Rossetti wrote: Bruno Desthuilliers wrote: Gabriel Rossetti a écrit : I thought that since functions are objects, that I could obtain it's nested functions. Well, there's probably a very hackish way, but it's not worth the pain. What Brun

Re: getattr() on nested functions?

2008-08-20 Thread Gabriel Rossetti
Bruno Desthuilliers wrote: Gabriel Rossetti a écrit : Hello, I can't get getattr() to return nested functions, Of course. Nested functions are not attributes of their container function. Ok I tried this : >>> def toto(): ... def titi(): ... pass ...

Re: getattr() on nested functions?

2008-08-20 Thread Gabriel Rossetti
Gabriel Genellina wrote: En Wed, 20 Aug 2008 05:34:38 -0300, Gabriel Rossetti <[EMAIL PROTECTED]> escribi�: I can't get getattr() to return nested functions, I tried this : >>> def toto(): ... def titi(): ... pass ... f = getattr(toto, "t

getattr() on nested functions?

2008-08-20 Thread Gabriel Rossetti
Hello, I can't get getattr() to return nested functions, I tried this : >>> def toto(): ... def titi(): ... pass ... f = getattr(toto, "titi") ... print str(f) ... >>> toto() Traceback (most recent call last): File "", line 1, in File "", line 4, in toto AttributeError

Re: Do I need "self" and "other"?

2008-06-28 Thread Gabriel Rossetti
Kurda Yon wrote: Hi, I found one example which defines the addition of two vectors as a method of a class. It looks like that: class Vector: def __add__(self, other): data = [] for j in range(len(self.data)): data.append(self.data[j] + other.data[j]) return Vector(data) In

Re: h2py.py bug?

2008-06-12 Thread Gabriel Rossetti
Gabriel Genellina wrote: En Wed, 11 Jun 2008 04:21:03 -0300, Gabriel Rossetti <[EMAIL PROTECTED]> escribió: Gabriel Genellina wrote: En Tue, 10 Jun 2008 09:44:13 -0300, Gabriel Rossetti <[EMAIL PROTECTED]> escribió: I wanted to use the h2py.py script (Tools/scripts/h2py.py) an

Re: ClassName.attribute vs self.__class__.attribute

2008-06-12 Thread Gabriel Rossetti
Duncan Booth wrote: Mike Orr <[EMAIL PROTECTED]> wrote: That's a misunderstanding of classes vs instances. If you have an instance of MyClass(Superclass), there is one instance but several classes. The instance is of MyClass; there is no instance of Superclass. 'self' has a .__class__ att

Re: ClassName.attribute vs self.__class__.attribute

2008-06-11 Thread Gabriel Rossetti
Bruno Desthuilliers wrote: Gabriel Rossetti a écrit : Larry Bates wrote: Gabriel Rossetti wrote: Hello everyone, I had read somewhere that it is preferred to use self.__class__.attribute over ClassName.attribute to access class (aka static) attributes. I had done this and it seamed to work

Re: ClassName.attribute vs self.__class__.attribute

2008-06-11 Thread Gabriel Rossetti
Mike Orr wrote: On Jun 5, 8:40 am, Gabriel Rossetti <[EMAIL PROTECTED]> wrote: Hello everyone, I had read somewhere that it is preferred to use self.__class__.attribute over ClassName.attribute to access class (aka static) attributes. I had done this and it seamed to work, u

Re: h2py.py bug?

2008-06-11 Thread Gabriel Rossetti
Gabriel Genellina wrote: En Tue, 10 Jun 2008 09:44:13 -0300, Gabriel Rossetti <[EMAIL PROTECTED]> escribió: I wanted to use the h2py.py script (Tools/scripts/h2py.py) and it didn't like char litterals : Skipping: PC_ERROR = ord() where my *.h file contained : #define PC_E

h2py.py bug?

2008-06-10 Thread Gabriel Rossetti
Hello everyone, I wanted to use the h2py.py script (Tools/scripts/h2py.py) and it didn't like char litterals : Skipping: PC_ERROR = ord() where my *.h file contained : #define PC_ERROR '0' I searched the web and found a post with the same error : http://mail.python.org/pipermail/python-lis

Re: ClassName.attribute vs self.__class__.attribute

2008-06-06 Thread Gabriel Rossetti
Larry Bates wrote: Gabriel Rossetti wrote: Hello everyone, I had read somewhere that it is preferred to use self.__class__.attribute over ClassName.attribute to access class (aka static) attributes. I had done this and it seamed to work, until I subclassed a class using this technique and

ClassName.attribute vs self.__class__.attribute

2008-06-05 Thread Gabriel Rossetti
Hello everyone, I had read somewhere that it is preferred to use self.__class__.attribute over ClassName.attribute to access class (aka static) attributes. I had done this and it seamed to work, until I subclassed a class using this technique and from there on things started screwing up. I fi

Re: why does the following with Queue, q.put('\x02', True) not put it in the queue?

2008-04-25 Thread Gabriel Rossetti
Arimaz SA Av. du 24 Janvier 11 Ateliers de la Ville de Renens, Atelier 5 1020 Renens, Switzerland www.mydeskfriend.com Mob: +41-(0)79-539-0069 Tel: +41-(0)21-566-7343 sturlamolden wrote: On Apr 25, 4:38 pm, Gabriel Rossetti <[EMAIL PROTECTED]> wrote: Hello, I'm having some t

why does the following with Queue, q.put('\x02', True) not put it in the queue?

2008-04-25 Thread Gabriel Rossetti
Hello, I'm having some trouble with the Queue class, for some reason, if I do this (ch == ) : q = Queue.Queue(0) repr(ch) q.put(ch, True) len(q.queue) where the output is : '\x02' 0 why isn't the character/string being put it in the queue? Thank you, Gabriel -- http://mail.python.org/mail

Re: Destructor?

2008-04-08 Thread Gabriel Rossetti
Matt Nordhoff wrote: > Matt Nordhoff wrote: > >> Gabriel Rossetti wrote: >> >>> Hello everyone, >>> >>> we are writing an application that needs some cleanup to be done if the >>> application is quit, normally (normal termination) o

Destructor?

2008-04-08 Thread Gabriel Rossetti
Hello everyone, we are writing an application that needs some cleanup to be done if the application is quit, normally (normal termination) or by a signal like SIGINT or SIGTERM. I know that the __del__ method exists, but unless I'm mistaken there is no guarantee as of when it will be called, an

Re: Python in High School

2008-04-02 Thread Gabriel Rossetti
sprad wrote: > I'm a high school computer teacher, and I'm starting a series of > programming courses next year (disguised as "game development" classes > to capture more interest). The first year will be a gentle > introduction to programming, leading to two more years of advanced > topics. > > I

Re: Partial Function Application and implicit self problem

2008-03-27 Thread Gabriel Rossetti
Bruno Desthuilliers wrote: > Gabriel Rossetti a écrit : >> Hello, >> >> I am using Partial Function Application in a class and I've come up >> with a problem, when the method is called it tries to pass "self" to >> the curried/partial functi

Re: Partial Function Application and implicit self problem

2008-03-27 Thread Gabriel Rossetti
Diez B. Roggisch wrote: > Gabriel Rossetti schrieb: > >> Hello, >> >> I am using Partial Function Application in a class and I've come up with >> a problem, when the method is called it tries to pass "self" to the >> curried/partial

Re: Partial Function Application and implicit self problem

2008-03-27 Thread Gabriel Rossetti
Gabriel Rossetti wrote: > Hello, > > I am using Partial Function Application in a class and I've come up with > a problem, when the method is called it tries to pass "self" to the > curried/partial function, but this should be the first argument in > reality,

Partial Function Application and implicit self problem

2008-03-27 Thread Gabriel Rossetti
Hello, I am using Partial Function Application in a class and I've come up with a problem, when the method is called it tries to pass "self" to the curried/partial function, but this should be the first argument in reality, but since the function is curried, then the self gets passed as the se

Re: Strange loop behavior

2008-03-26 Thread Gabriel Rossetti
Arnaud Delobelle wrote: > On Mar 26, 8:35 am, Gabriel Rossetti > <[EMAIL PROTECTED]> wrote: > >> Hello, >> >> I wrote a program that reads data from a file and puts it in a string, >> the problem is that it loops infinitely and that's not wanted, her

Re: Strange loop behavior

2008-03-26 Thread Gabriel Rossetti
Gabriel Rossetti wrote: > Hello, > > I wrote a program that reads data from a file and puts it in a string, > the problem is that it loops infinitely and that's not wanted, here is > the code : > > d = repr(f.read(DEFAULT_BUFFER_SIZE)) > while d != &

Strange loop behavior

2008-03-26 Thread Gabriel Rossetti
Hello, I wrote a program that reads data from a file and puts it in a string, the problem is that it loops infinitely and that's not wanted, here is the code : d = repr(f.read(DEFAULT_BUFFER_SIZE)) while d != "": file_str.write(d) d = repr(f.read(DEFAULT_BUFFER_SIZE)) I

Re: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/205183 idiom

2008-03-18 Thread Gabriel Rossetti
Carsten Haese wrote: > On Tue, 2008-03-18 at 09:06 +0100, Gabriel Rossetti wrote: > >> Hello, >> >> I am reading core python python programming and it talks about using the >> idiom >> described on >> http://aspn.activestate.com/ASPN/Cookbook/Pyt

Re: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/205183 idiom

2008-03-18 Thread Gabriel Rossetti
Carsten Haese wrote: > On Tue, 2008-03-18 at 09:06 +0100, Gabriel Rossetti wrote: > >> Hello, >> >> I am reading core python python programming and it talks about using the >> idiom >> described on >> http://aspn.activestate.com/ASPN/Cookbook/Pyt

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/205183 idiom

2008-03-18 Thread Gabriel Rossetti
Hello, I am reading core python python programming and it talks about using the idiom described on http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/205183 . I'm using python 2.5.1 and if I try : class MyClass(object): def __init__(self): self._foo = "foo" self._bar =

Re: execute python script question

2008-03-11 Thread Gabriel Rossetti
Michael Wieher wrote: > stupid question: you have myPackage somewhere on sys.path? > > I mean, module1.py only knows it lives in a directory, it doesn't know > anything about anything above it. > > > > 2008/3/10, Gabriel Rossetti <[EMAIL PROTECTED] > <mai

Re: execute python script question

2008-03-11 Thread Gabriel Rossetti
Sam wrote: > Hello, > > I may misunderstand your problem, but it may be related to the > execution environment, especially the PYTHONPATH variable. Have a look > at the following log: > > [EMAIL PROTECTED]:/$ pwd > / > [EMAIL PROTECTED]:/$ cat -n /tmp/test_import.py > 1 class A(object): >

  1   2   >