Re: except KeyError, everywhere
En Fri, 03 Jun 2011 21:02:56 -0300, Nobody escribió: On Fri, 03 Jun 2011 22:08:16 +0200, Wilbert Berendsen wrote: I find myself all over the place associating objects with each other using dicts as caches: The general concept is called "memoization". There isn't an implementation in the standard library Yes, there is, in Python 3.2: http://docs.python.org/py3k/library/functools.html#functools.lru_cache -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: GIL in alternative implementations
En Sat, 28 May 2011 14:05:16 -0300, Steven D'Aprano escribió: On Sat, 28 May 2011 09:39:08 -0700, John Nagle wrote: Python allows patching code while the code is executing. Can you give an example of what you mean by this? If I have a function: def f(a, b): c = a + b d = c*3 return "hello world"*d how would I patch this function while it is executing? I think John Nagle was thinking about rebinding names: def f(self, a, b): while b>0: b = g(b) c = a + b d = self.h(c*3) return "hello world"*d both g and self.h may change its meaning from one iteration to the next, so a complete name lookup is required at each iteration. This is very useful sometimes, but affects performance a lot. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Print Window on IDLE
En Mon, 06 Jun 2011 14:48:26 -0300, Steve Oldner escribió: Seems to work using 2.7 but not 3.2. On 3.2 it just closes all my python sessions. Is this a bug? Can someone point me to a "How To" on using a local printer in windows? It's a bug. Starting IDLE from the command line, one can actually see the error: Exception in Tkinter callback Traceback (most recent call last): File "D:\apps\python32\lib\tkinter\__init__.py", line 1399, in __call__ return self.func(*args) File "D:\apps\python32\lib\idlelib\IOBinding.py", line 453, in print_window command = idleConf.GetOption('main','General','print-command-win') File "D:\apps\python32\lib\idlelib\configHandler.py", line 245, in GetOption type=type, raw=raw) File "D:\apps\python32\lib\idlelib\configHandler.py", line 54, in Get return self.get(section, option, raw=raw) File "D:\apps\python32\lib\configparser.py", line 789, in get d) File "D:\apps\python32\lib\configparser.py", line 391, in before_get self._interpolate_some(parser, option, L, value, section, defaults, 1) File "D:\apps\python32\lib\configparser.py", line 440, in _interpolate_some "found: %r" % (rest,)) configparser.InterpolationSyntaxError: '%' must be followed by '%' or '(', found : '%s' IDLE is attempting to read an entry from its configuration file, but fails because of a syntax error in the file (it's an error for a ConfigParser entry, %s should be %%s). The same entry was fine for earlier IDLE versions. As a workaround, you may edit the offending lines in your configuration file. Go to the idlelib directory; if you don't know where it is, just open idle or Python command line and execute: py> import idlelib py> idlelib.__file__ 'D:\\apps\\python32\\lib\\idlelib\\__init__.py' In the same directory you'll find config-main.def; open it, and replace these lines in the [General] section: print-command-posix=lpr %%s print-command-win=start /min notepad /p %%s (%s should become %%s). Tested on Windows, but Linux should have the same problem and temporary solution. You may need to roll this change back when the code is corrected. Reported as http://bugs.python.org/issue12274 -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: sys.tracebacklimit not working in Python 3.2?
En Fri, 27 May 2011 17:38:50 -0300, Thorsten Kampe escribió: sys.tracebacklimit = 0 The 3.2 documentation says "When set to 0 or less, all traceback information is suppressed and only the exception type and value are printed". Bug? Yes; reported at http://bugs.python.org/issue12276 -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Function call arguments in stack trace?
En Tue, 07 Jun 2011 15:09:54 -0300, Dun Peal escribió: In a stack trace, is it possible to somehow get the arguments with which each function was called? So for example, if function `foo` in module `bar` was called with arguments `(1, [2])` when it raised an exception, then instead of: Traceback (most recent call last): File "bar.py", line 123, in foo build_rpms() The stack trace would read: Traceback (most recent call last): File "bar.py", line 123, in foo(1, [2]) build_rpms() This would save a lot of debugging time! The cgitb module does exactly that; some third-party modules offer similar functionality, but I don't remember any names. Despite its name, cgitb works with any script. Given this test script: # begin test_traceback.py import cgitb cgitb.enable(format="text") spam = [] def a(x, y): "This is function a" z = x+y return b(z) def b(z, n=3): """This is function b. Its docstring is longer.""" if n!=3: just(to_consume_space) w = c(foo=z*n) return w def c(foo=0, bar=1): "This is function c" baz = foo+bar spam.somenamethatdoesnotexist(foo+bar) anotherglobal("thatdoesnotexisteither") a(10, 20) # end test_traceback.py the output is: AttributeError Python 3.2: d:\apps\Python32\python.exe Tue Jun 7 23:36:36 2011 A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred. D:\TEMP\test_traceback.py in () 27 baz = foo+bar 28 spam.somenamethatdoesnotexist(foo+bar) 29 anotherglobal("thatdoesnotexisteither") 30 31 a(10, 20) a = D:\TEMP\test_traceback.py in a(x=10, y=20) 7 "This is function a" 8 z = x+y 9 return b(z) 10 11 global b = z = 30 D:\TEMP\test_traceback.py in b(z=30, n=3) 18 just(to_consume_space) 19 20 w = c(foo=z*n) 21 22 return w w undefined global c = foo undefined z = 30 n = 3 D:\TEMP\test_traceback.py in c(foo=90, bar=1) 26 "This is function c" 27 baz = foo+bar 28 spam.somenamethatdoesnotexist(foo+bar) 29 anotherglobal("thatdoesnotexisteither") 30 global spam = [] spam.somenamethatdoesnotexist undefined foo = 90 bar = 1 AttributeError: 'list' object has no attribute 'somenamethatdoesnotexist' [... exception attributes ...] [... original traceback ...] -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Problems Compiling Python 2.6.7 for Win7
En Wed, 08 Jun 2011 12:28:56 -0300, Jay Osako escribió: I have been trying to get PyODBC to work with Python 2.6 (the latest version it is known to be compatible with) and Django, but have run into a problem which, according to the information I've got elsewhere, probably stems from a DLL incompatibility - apparently, [...] The first of these problems is, of course, tracking down a copy of VC+ + 2008 Express. While one would think that this would be the simplest solution, Microsfot themselves no longer provide the installer for this, and I'm not sure I'd trust most of the other sources claiming to provide it. Doesn't http://www.microsoft.com/express/Downloads/#2008-Visual-CPP work for you? I didn't try past the initial download prompt, but it seems to be the right version. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: help on QUICKFIX
En Fri, 10 Jun 2011 04:13:05 -0300, prakash jp escribió: I am using quickfix, would like to start with that ..\quickfix-1.13.3\quickfix\examples\executor\python\executor.py asks for a configuration file how should it look like. This one? http://www.quickfixengine.org/ I see a forum and a mailing list - I think you'll get more help there. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Unsupported operand type(s) for +: 'float' and 'tuple'
En Fri, 10 Jun 2011 07:30:28 -0300, Francesc Segura escribió: Hello all, I'm new to this and I'm having problems on summing two values at python. I get the following error: Traceback (most recent call last): File "C:\edge-bc (2).py", line 168, in if (costGG <= cost + T0): TypeError: unsupported operand type(s) for +: 'float' and 'tuple' I see Tim Chase already told you about this error. Let me make a few comments about the rest. try: import matplotlib.pyplot as plt except: raise I guess the above try/except was left from some earlier debugging attempt - such an except clause is useless, just omit it. T0 = 0.5 RO = 0.99 Perhaps those names make sense in your problem at hand, but usually I try to use more meaningful ones. 0 and O look very similar in some fonts. for i in range(len(edges)): total = 0 cost = 0 factor = 1 liedges = list(edges[i]) linode1 = list(liedges[0]) linode2 = list(liedges[1]) list(something) creates a new list out of the elements from `something`. You're just iterating here, so there is no need to duplicate those lists. In addition, Python is not C: the `for` statement iterates over a collection, you don't have to iterate over the indices and dereference each item: for liedges in edges: linode1 = liedges[0] linode2 = liedges[1] distance = (((linode2[0]-linode1[0])%N)^2)+(((linode2[1]- linode1[1])%N)^2) That doesn't evaluate what you think it does. ^ is the "bitwise xor" operator, and I bet you want **, the "power" operator. total = total + cost return(total) return is not a function but a statement; those () are unnecesary and confusing. And I think you want to initialize total=0 *before* entering the loop; also, initializing cost and factor is unnecesary. def costGeasy(G): bc = NX.edge_betweenness_centrality(G,normalized=True) total = 0 for i in range(len(bc)): total=total+bc.values()[i] return (total) bc = NX.edge_betweenness_centrality(G,normalized=True) values = bc.values() total = sum(values) return total ==> return sum(bc.values()) pos={} for i in range(NODES): pos[nod[i]]=(nod[i][0]/(N*1.0),nod[i][1]/(N*1.0)) In Python version 2.x, 1/3 evals to 0, but that's a mistake; it is fixed in the 3.x version. If you put this line at the top of your script: from __future__ import division then 1/3 returns 0.... When you actually want integer division, use //, like 1//3 So we can rewrite the above as: from __future__ import division ... for node in nod: pos[node] = (node[0] / N, node[1] / N) Another way, not relying on true division: divisor = float(N) for node in nod: pos[node] = (node[0] / divisor, node[1] / divisor) or even: pos = dict((node, (node[0] / divisor, node[1] / divisor)) for node in nod) for y in range(NK): for x in range(ITERATIONS): cost = costG(G) if (cost < (best_cost)): best_graph = G best_cost = cost GG = G Again, I think this doesn't do what you think it does. GG = G means "let's use the name GG for the object currently known as G". GG is not a "copy" of G, just a different name for the very same object. Later operations like GG.remove_edge(...) modify the object - and you'll see the changes in G, and in best_graph, because those names all refer to the same object. I think you'll benefit from reading this: http://effbot.org/zone/python-objects.htm a = random.randint(0,NODES-1) b = random.randint(0,NODES-1) adj=G.adjacency_list() while ((nod[b] in adj[a]) or (b == a)): a = random.randint(0,NODES-1) b = random.randint(0,NODES-1) GG.add_edge(nod[a],nod[b]) As above, I'd avoid using indexes, take two random nodes using random.sample instead, and avoid adjacency_list(): while True: a, b = random.sample(nod, 2) if b not in G[a]: break GG.add_edge(a, b) (mmm, I'm unsure of the adjacency test, I've used networkx some time ago but I don't have it available right now) -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Unsupported operand type(s) for +: 'float' and 'tuple'
En Fri, 10 Jun 2011 07:30:28 -0300, Francesc Segura escribió: Hello all, I'm new to this and I'm having problems on summing two values at python. I get the following error: Traceback (most recent call last): File "C:\edge-bc (2).py", line 168, in if (costGG <= cost + T0): TypeError: unsupported operand type(s) for +: 'float' and 'tuple' I see Tim Chase already told you about this error. Let me make a few comments about the rest. try: import matplotlib.pyplot as plt except: raise I guess the above try/except was left from some earlier debugging attempt - such an except clause is useless, just omit it. T0 = 0.5 RO = 0.99 Perhaps those names make sense in your problem at hand, but usually I try to use more meaningful ones. 0 and O look very similar in some fonts. for i in range(len(edges)): total = 0 cost = 0 factor = 1 liedges = list(edges[i]) linode1 = list(liedges[0]) linode2 = list(liedges[1]) list(something) creates a new list out of the elements from `something`. You're just iterating here, so there is no need to duplicate those lists. In addition, Python is not C: the `for` statement iterates over a collection, you don't have to iterate over the indices and dereference each item: for liedges in edges: linode1 = liedges[0] linode2 = liedges[1] distance = (((linode2[0]-linode1[0])%N)^2)+(((linode2[1]- linode1[1])%N)^2) That doesn't evaluate what you think it does. ^ is the "bitwise xor" operator, and I bet you want **, the "power" operator. total = total + cost return(total) return is not a function but a statement; those () are unnecesary and confusing. And I think you want to initialize total=0 *before* entering the loop; also, initializing cost and factor is unnecesary. def costGeasy(G): bc = NX.edge_betweenness_centrality(G,normalized=True) total = 0 for i in range(len(bc)): total=total+bc.values()[i] return (total) bc = NX.edge_betweenness_centrality(G,normalized=True) values = bc.values() total = sum(values) return total ==> return sum(bc.values()) pos={} for i in range(NODES): pos[nod[i]]=(nod[i][0]/(N*1.0),nod[i][1]/(N*1.0)) In Python version 2.x, 1/3 evals to 0, but that's a mistake; it is fixed in the 3.x version. If you put this line at the top of your script: from __future__ import division then 1/3 returns 0.... When you actually want integer division, use //, like 1//3 So we can rewrite the above as: from __future__ import division ... for node in nod: pos[node] = (node[0] / N, node[1] / N) Another way, not relying on true division: divisor = float(N) for node in nod: pos[node] = (node[0] / divisor, node[1] / divisor) or even: pos = dict((node, (node[0] / divisor, node[1] / divisor)) for node in nod) for y in range(NK): for x in range(ITERATIONS): cost = costG(G) if (cost < (best_cost)): best_graph = G best_cost = cost GG = G Again, I think this doesn't do what you think it does. GG = G means "let's use the name GG for the object currently known as G". GG is not a "copy" of G, just a different name for the very same object. Later operations like GG.remove_edge(...) modify the object - and you'll see the changes in G, and in best_graph, because those names all refer to the same object. I think you'll benefit from reading this: http://effbot.org/zone/python-objects.htm a = random.randint(0,NODES-1) b = random.randint(0,NODES-1) adj=G.adjacency_list() while ((nod[b] in adj[a]) or (b == a)): a = random.randint(0,NODES-1) b = random.randint(0,NODES-1) GG.add_edge(nod[a],nod[b]) As above, I'd avoid using indexes, take two random nodes using random.sample instead, and avoid adjacency_list(): while True: a, b = random.sample(nod, 2) if b not in G[a]: break GG.add_edge(a, b) (mmm, I'm unsure of the adjacency test, I've used networkx some time ago but I don't have it available right now) -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 2.7.2 for Windows reports version as 2.7.0?
En Sun, 19 Jun 2011 12:35:38 -0300, escribió: The version info comes from the DLL - I wonder if the DLL being found is somehow old? Make sure: >>> import sys >>> win32api.GetModuleFileName(sys.dllhandle) Is the DLL you expect. After uninstalling and reinstalling for the current user only (vs. all users), Python now reports the correct version number. And running your code above confirms that the proper DLL is being loaded (c:\Python27\Python27.dll). My original version of Python 2.7.0 was installed for all users and when I ran the 2.7.2 MSI I chose to install for all users as well. After running the 2.7.2 MSI, my Python exe's had the correct timestamps, but I failed to check the python27.dll timestamp to see if this file was out-of-date. I wonder if changing my install method to current user forced the installation of the updated python27.dll? And perhaps the default 2.7.2 installation in all users mode (when one is updating an existing 2.7 installation) doesn't update the Python27.dll under some conditions? In a "for all users" install, python27.dll goes into c:\windows\system32, not c:\python27 Maybe you installed 2.7.0 twice, "for all users" and also "for current user only", and both in the same directory (c:\python27). That could explain the old .dll in the install directory; the new one goes into system32, but the old one takes precedence. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: search through this list's email archives
En Thu, 23 Jun 2011 13:11:32 -0300, Cathy James escribió: I looked through this forum's archives, but I can't find a way to search for a topic through the archive. Am I missing something? Gmane provides a search capability also: http://blog.gmane.org/gmane.comp.python.general -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: search through this list's email archives
En Fri, 24 Jun 2011 11:33:23 -0300, Grant Edwards escribió: On 2011-06-24, Gabriel Genellina wrote: En Thu, 23 Jun 2011 13:11:32 -0300, Cathy James escribi?: I looked through this forum's archives, but I can't find a way to search for a topic through the archive. Am I missing something? Gmane provides a search capability also: http://blog.gmane.org/gmane.comp.python.general FWIW, I've found the Gmane search feature to be very unreliable. It often overlooks a lot of matching articles for no apparent reason. It seems no single provider is perfect. Google searching capability is quite good, but for some reason, many posts are missing, often the initial post head of a thread. The "Python-URL" summaries usually include a Google Groups url, but sometimes I have to link to Gmane, velocityreviews.com or even to the list archives at python.org because of that problem. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: from module import * using __import__?
En Sat, 02 Jul 2011 16:52:11 -0300, Dan Stromberg escribió: Is there a decent way of running "from import *"? Perhaps using __import__? Does it mean using the copy module or adding an element to globals() somehow? Yes, I think I do have a good use for this: importing either pure python or cython versions of a module into a single namespace that can provide the same interface (transparent to the caller), whether C extension modules are viable in the current interpreter or not. So you have a stub module that provides one or the other, depending on availability and suitability. See pickle.py in Python 3 as an example: the slow (pure Python) code resides in pickle.py; the fast (C code) in _pickle.so (on Windows, a built-in module). Near the end of pickle.py, there is a line "from _pickle import *" which, if successful, overrides (replaces) any previous definitions; if not, the ImportError is trapped and the previously defined Python code remains valid. Unlike the 2.x series, where you should decide to "import cPickle" or "import pickle" (or attempt both, cathcing the ImportError), here you only have to "import pickle" in your code; if the fast module is present, it is automatically loaded and used; else, the slow but compatible version is used. You don't even have to know that an alternative implementation exists. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Execute a method in a file in an egg
En Tue, 23 Aug 2011 13:14:06 -0300, RVince escribió: Is there a way to do this from the command line? Thanks. Something like this? python -c "import the.module;the.module.someclass().method(arguments)" -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Calling Script from Command line not working
En Mon, 29 Aug 2011 07:40:06 -0300, Sathish S escribió: We created a DLL using cygwin and have written a class based python module for the same. We have created a sample script for the class based python module, that creates an object of the class and calls various methods in the class. This Test script works fine while I run it from IDLE. However when I run it from command prompt it either hangs or just returns without executing the functions. When it returns I do not get a error trace. When I tried to findout where exactly the issue is happening. the issue occurs when I try to call the *cygwin_dll_init* method of the cygwin1.dll . This cygwin1.dll is actualy a dependency to the DLL we have built. So we have to load this DLL and call this *cygwin_dll_init* method before loading my DLL. cyg = cdll.LoadLibrary("cygwin1.dll") cyg.cygwin_dll_init() #hangs or returns here mydll=cdll.LoadLibrary("my.dll") mydll.func1() I'm trying to understand what exactly is the difference, when we call it IDLE and when we call it from command prompt using the python command. I will have to get the script working from command prompt as well. A few comments: * why do you initialize cygwin1.dll in Python? If it's a dependency of my.dll, it might be better to load and initialize it there. * for this function prototype: void cygwin_dll_init(void); you should declare it using: cyg = cdll.LoadLibrary("cygwin1.dll") cyg.restype = None cyg.cygwin_dll_init() #hangs or returns here ... Anyway, I don't see why a console application would fail but not inside IDLE. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Handling 2.7 and 3.0 Versions of Dict
En Wed, 31 Aug 2011 22:28:09 -0300, Travis Parks escribió: On Aug 31, 7:37 pm, Gregory Ewing wrote: Ian Kelly wrote: > if sys.version_info < (3,): > getDictValues = dict.itervalues > else: > getDictValues = dict.values > (which is basically what the OP was doing in the first place). My problem was that I didn't understand the scoping rules. It is still strange to me that the getValues variable is still in scope outside the if/else branches. Those if/else are at global scope. An 'if' statement does not introduce a new scope; so getDictValues, despite being "indented", is defined at global scope, and may be used anywhere in the module. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Help required accessing dictionary
En Wed, 31 Aug 2011 22:46:54 -0300, escribió: I need to access the dictionary of the script that I am running through my vc++ application by embedding python. I am linking to python dynamically. I want to obtain the dictionary of the script and access the variables declared in the script. However, with the PyObject * that I get from the dictionary, I am not able to find the type of the object. The reason being that GetProcAddress to PyInt_Check returns a NULL. The same thing with PyFloat_Check and so on. I think this is because they are macros and not exported functions. What can be done to be able to perform these checks without statically linking to the pyhon lib ? Just include python.h PyInt_Check is completely implemented as a macro, it doesn't call any function. /* from intobject.h */ #define PyInt_Check(op) \ PyType_FastSubclass((op)->ob_type, Py_TPFLAGS_INT_SUBCLASS) /* from object.h */ #define PyType_FastSubclass(t,f) PyType_HasFeature(t,f) #define PyType_HasFeature(t,f) (((t)->tp_flags & (f)) != 0) -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Invoking profile from command line prevent my sys.path modification
En Thu, 01 Sep 2011 07:51:43 -0300, Yaşar Arabacı escribió: I am new to profile module, so I am sorry if this is an absolute beginner question. In order to my code to run, I need to add a directory to sys.path. When I invole python -m profile myfile.py, my code won't work, saying that the thing that is supposed to be in path, isn't. Code works fine without profiling. Profiling works if I write it into the file, but I don't prefer doing that, if that is possible. You may set the PYTHONPATH environment variable, just for the profiling session. http://docs.python.org/install/index.html#modifying-python-s-search-path -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Handling 2.7 and 3.0 Versions of Dict
En Fri, 02 Sep 2011 13:53:37 -0300, Travis Parks escribió: On Sep 2, 12:36 pm, "Gabriel Genellina" wrote: En Wed, 31 Aug 2011 22:28:09 -0300, Travis Parks escribi : > On Aug 31, 7:37 pm, Gregory Ewing wrote: >> Ian Kelly wrote: >> > if sys.version_info < (3,): >> > getDictValues = dict.itervalues >> > else: >> > getDictValues = dict.values >> > (which is basically what the OP was doing in the first place). > My problem was that I didn't understand the scoping rules. It is still > strange to me that the getValues variable is still in scope outside > the if/else branches. Those if/else are at global scope. An 'if' statement does not introduce a new scope; so getDictValues, despite being "indented", is defined at global scope, and may be used anywhere in the module. Does that mean the rules would be different inside a function? Yes: a function body *does* create a new scope, as well as the class statement. See http://docs.python.org/reference/executionmodel.html -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: puzzle about file Object.readlines()
On 19 mar, 16:05, Dave Angel wrote: > On 01/-10/-28163 02:59 PM, MRAB wrote: > > On 19/03/2011 13:15, 林桦 wrote: > >> i use python 2.5. os is window 7. > >> the puzzle is :python don't read the leave text when meet character: > >> chr(26) > >> the code is: > >> /fileObject=open('d:\\temp\\1.txt','w') > >> fileObject.write('22\r\n') > >> fileObject.write(chr(26)+'\r\n') > >> fileObject.write('33') > >> fileObject.close() > >> fileObject=open('d:\\temp\\1.txt','r') > >> i=0 > >> for line in fileObject: > >> i+=1 > >> print str(i)+'**'+line > >> fileObject.close()/ > > >> the output only print: > >> />>> > >> 1**22/ > > >> but can't print next line text:/'33'' 。who tell me why? > >> / > > > chr(26) can sometimes be used in text files to indicate the end of the text. > > > In Microsoft Windows it dates from MS-DOS, which borrowed from CP/M, an > > operating > > system which stored the file size as the number of 128-byte records. > > chr(26) was used to > > indicate where the text ended in the last record. > > On Win a ctrl-z is end of file. So if you want to read beyond the end > of a text file, you have to pretend it's binary. Open it with "rb" > instead of "r" Using mode "rU" may be more convenient, because it still translates \r \n into \n but disregards chr(26) as a special marker. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: How to build and upload eggs to pypi?
On 21 mar, 08:53, morphex wrote: > Hi, > > I have a couple of project which are on PyPi, and now I'd like to > update some of them. Is there a good howto somewhere, showing how to > add new versions (instead of updating one that's already there) etc? There is a tutorial: http://wiki.python.org/moin/CheeseShopTutorial To add a new version, simply increment the version number, and then "python setup.py upload" should be enough. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: PYTHONPATH
En Fri, 15 Apr 2011 05:33:18 -0300, Algis Kabaila escribió: An elementary question that is bugging me, regarding sys.path values.sys.path can be altered easily, but the changes last for the current session only. I would like the changes to stay for several sessions. Is PYTHONPATH a system variable that sets the path for several sessions and if so, where in the system is it? Do I need to create one for setting python path for several sessions? PYTHONPATH is an environment variable, you set it the same way as any other, the details depend on the operating system/shell you're currently using. But - why do you think you need to set PYTHONPATH? Don't do that. Use the standard places to put your library modules and packages, like site-packages (where third-party libraries are installed by default). From Python 2.6+ the search path includes per-user directories like ~/.local/lib/python2.6/site-packages and %APPDATA%\Python\Python26\site-packages (see PEP370 [1] for details) so you don't even have to mess with the Python installation directories. [1] http://www.python.org/dev/peps/pep-0370/ -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: argparse parser stores lists instead of strings
En Thu, 28 Apr 2011 04:24:46 -0300, Andrew Berg escribió: I've set up groups of arguments for a script I'm writing, and any time I give an argument a value, it gets stored as a list instead of a string, even if I explicitly tell it to store a string. Arguments declared with other types (e.g. float, int) and default values are stored as expected. For example: vidin_args=parser.add_argument_group('Video Input Options', 'Various options that control how the video file is demuxed/decoded.') vidin_args.add_argument('-m', dest='vmode', nargs=1, type=str, metavar='video_mode', choices=['ntsc', 'pal', 'film', 'ivtc'], default='ntsc', help='Valid values are "ntsc", "pal", "film" and "ivtc".') ...more arguments... opts=parser.parse_args() If I assign a value on the command line (e.g. -m pal), opts.vmode is a list, otherwise it's a string. This is pretty bad since I can't know whether to get opts.vmode or opts.vmode[0] later in the script. I could loop through all the options and convert each option to a string, but that's not really something I want to do, especially if I start adding more options. That's because of nargs=1. From the argparse documentation: [1] Note that nargs=1 produces a list of one item. This is different from the default, in which the item is produced by itself. So, just remove nargs=1 from add_argument() [1] http://docs.python.org/py3k/library/argparse.html#nargs -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Access violation reading 0x00000010
En Thu, 28 Apr 2011 03:35:48 -0300, yuan zheng escribió: Sorry , the path is just an example. This is not the question I think. Because there is lots of api in libcommon-0.dll, and there is no fault when invoking other api, such as libcommon.SIM_start().. It's just fault when invoking this api -> SIM_init(). So I wanna which situation would lead to this error: -- WindowsError: exception: access violation reading 0x0010 -- On Thu, Apr 28, 2011 at 4:01 PM, yuan zheng wrote: > > libcommon = CDLL("c:\libcommon-0.dll", RTLD_GLOBAL) > > libcommon.SIM_init() -> This is the invoking. It's hard to guess, but if you get an access violation just from those two lines of code, I'd say the problem is inside SIM_init() itself. It may be attempting to dereference a NULL pointer: accessing a field inside a struct, or calling a virtual function from a NULL object... Also, make sure CDLL is the right choice; it implies a prototype like this: int cdecl SIM_INIT(void); -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: How to upload a file
En Wed, 27 Apr 2011 11:14:54 -0300, Torsten Bronger escribió: Hallöchen! I'm skimming through the various recipies for uploading a file via HTTP. Unfortunately, all of them are awkward but also rather old. (See for example http://stackoverflow.com/questions/68477/send-file-using-post-from-a-python-script) In my module, I do my HTTP request like this: opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookielib.CookieJar())) opener.open(url, urllib.urlencode(data, doseq=True)) Well, and now I'd also like to include a file upload to the POST data. The solution should use urllib2, otherwise I'd have to change most of my existing code. If you now say "Torsten, unfortunately it *is* so complicated" I'll jump through the hoops, but I'd love to hear that with Python 2.6.5 there's an easier way. ;-) This particular battery isn't included (yet - see http://bugs.python.org/issue3244) but this little library may help: https://bitbucket.org/chrisatlee/poster -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Testing tools classification
En Sat, 07 May 2011 02:21:02 -0300, rusi escribió: There is this nice page of testing tools taxonomy: http://pycheesecake.org/wiki/PythonTestingToolsTaxonomy But it does not list staf: http://staf.sourceforge.net/index.php. The good thing about wikis is, you can add it yourself. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: This it is the code of tmb_import.py (to matter of .tmb to blender) I need tmb_exporter.py (to export of blender to .tmb) Thanks.
En Tue, 10 May 2011 15:51:03 -0300, Jean Carlos Páez Ramírez escribió: The attached file is script of blender fact in python that .tmb serves to concern archives (secondly attached file), unloadings to blender and uses Por lo que pude entender, tu problema es bastante específico de Blender, así que tal vez te convenga preguntar en un foro como: http://www.g-blender.org/ (específicamente dedicado a Blender 3D en español) También está la comunidad de Python Argentina: http://python.org.ar/pyar/ (busca la lista de correo) Suerte! -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: NewBie Doubt in Python Thread Programming
En Wed, 11 May 2011 03:57:13 -0300, vijay swaminathan escribió: Hi All, I'm new bie to thread programming and I need some assistance in understanding few concepts ... I have a very simple program which runs a thread and prints a string. import threading class MyThread(threading.Thread): def __init__(self, parent = None): threading.Thread.__init__(self) def run(self): print 'Hello World' def main(): for i in range(10): MyThread_Object = MyThread() print 'Object id is : ' , id(MyThread_Object) print 'Staring thread --> ' , MyThread_Object.getName() MyThread_Object.start() count = threading.activeCount() print 'The active thread count is: ' , count if __name__ == '__main__': main() When I run this, I could see 10 thread being called. But when I print the active thread count it is only 2. Need some understanding on the following. 1. How the total active thread is 2? Because most of them have already finished by then. Your run() method executes quite fast. Make it take more time (maybe by adding time.sleep(1)) and you'll see 10 active threads. 2. how do I stop a thread? does it get automatically stopped after execution ? You don't; a trhread runs until the run() method exits. After that, the OS thread finishes. The Python object (a threading.Thread instance) is still alive (until the last reference to it disappears, as any other object). 3. Am I totally wrong in understanding the concepts. I don't know... 4. what is the difference between active_count() and activeCount() since both seem to give the same result. Nothing. active_count is the preferred Python spelling per PEP8; activeCount is the original Java spelling. 5. is there a way to find out if the thread is still active or dead? Yes, use is_alive() -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Peculiar Behaviour of __builtins__
En Thu, 12 May 2011 20:29:57 -0300, Aman Nijhawan escribió: I was trying to call the builtin function min by using getattr(__builtins__,'min') This works at the interpretter prompt However when I called it inside a module that was imported by another module it fails and gives an attribute error __builtins__ (note the final 's') is an implementation detail. You want the __builtin__ (no 's') module, renamed 'builtin' in Python 3.x py> import __builtin__ py> builtin_min = __builtin__.min py> builtin_min([8,2,5]) 2 See http://docs.python.org/library/__builtin__.html Note: using getattr with a literal name is not so useful. Better to use dot notation. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Peculiar Behaviour of __builtins__
En Thu, 12 May 2011 22:59:24 -0300, Gabriel Genellina escribió: En Thu, 12 May 2011 20:29:57 -0300, Aman Nijhawan escribió: I was trying to call the builtin function min by using getattr(__builtins__,'min') This works at the interpretter prompt However when I called it inside a module that was imported by another module it fails and gives an attribute error __builtins__ (note the final 's') is an implementation detail. You want the __builtin__ (no 's') module, renamed 'builtin' in Python 3.x Should read "...renamed 'builtins' in Python 3.x, just to add to the confusion." :) -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Import on case insensitive filesystem
En Fri, 13 May 2011 15:43:23 -0300, Mitchell Hashimoto escribió: I'm developing an app which runs Python on a filesystem which is not case sensitive (Mac OS X), but is mounted as an NFS drive on a remote machine. This causes errors because of the import being case sensitive but accessing an FS which is case insensitive. Short of copying the entire directory tree over to another filesystem, is there anything I can do to flag Python to act as though it were on a case sensitive FS? Try creating an environment variable PYTHONCASEOK with any value. See http://www.python.org/dev/peps/pep-0235/ for details. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: turn monitor off and on
En Sat, 14 May 2011 03:08:44 -0300, Astan Chee escribió: I'm trying to turn off my monitor, pause and then turn it on again. I'm doing this in python 2.6 and windows xp. Here is my script so far (that doesn't work): def turnOnMonitor(): SC_MONITORPOWER = 0xF170 win32gui.SendMessage(win32con.HWND_BROADCAST, win32con.WM_SYSCOMMAND, SC_MONITORPOWER, -1) For some reason, the script doesn't turn the monitor back on. What am I doing wrong here or are there any other alternative? Your script worked fine for me, 2.6 and XP also. Perhaps your monitor device driver is buggy or does not implement the required functionality. Mine is from Philips. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Datetime.timedelta
En Tue, 17 May 2011 07:44:08 -0300, Tsolmon Narantsogt escribió: I'm using datetime.timedelta and i have a problem delta = 1 day, 2:30:00 hours = delta.days * 8 how to add 8 + 2:30:00 Just operate with it as it were a number. The timedelta class implements all "sane" mathematical operations. py> from datetime import * py> def timedelta_from_dhms(days=0, hours=0, mins=0, secs=0): ... return timedelta(days, hours*3600 + mins*60 + secs) ... py> delta = timedelta_from_dhms(1, 2, 30) py> delta datetime.timedelta(1, 9000) py> hours = delta.days * 8 py> delta + hours Traceback (most recent call last): File "", line 1, in TypeError: unsupported operand type(s) for +: 'datetime.timedelta' and 'int' py> hours = timedelta_from_dhms(0, delta.days * 8) py> hours datetime.timedelta(0, 28800) py> delta + hours datetime.timedelta(1, 37800) py> def dhms_from_timedelta(td): ... return td.days, td.seconds // 3600, (td.seconds % 3600) // 60, td.seconds % 60 ... py> dhms_from_timedelta(delta + hours) (1, 10, 30, 0) -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: FW: help please
En Tue, 17 May 2011 06:43:51 -0300, hamed azarkeshb escribió: hi dearinwant to useautomation with catiaby python,but i dont know,how do we can creat catsafearrayvariant in python?please help me.i need urhelp by one example.thank u forany thing There are two sides when you want to use automation with Python: * learn how to do automation by itself, how COM works, how to invoke a COM server from Python. This is mostly application-independent. A good resource is "Python Programming in Win32" book by Mark Hammond. Chapter 5 "Introduction to COM" is exactly what you need, and is available for preview in Google Books: http://books.google.com.ar/books?id=fzUCGtyg0MMC&lpg=PA65&pg=PA65#v=onepage&f=false * learn how to use the actual objects exposed by the desired application. Usually, documentation is available for VBA or other languages, but can be easily translated into Python terms. So I'd say you first read the book, then search the documentation about CATSafeArrayVariant and see how to create it, and then translate that into Python. Feel free to post any problem you encounter, a better place would be the python-win32 list: http://mail.python.org/mailman/listinfo/python-win32 Good luck! -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: cPickle -> invalid signature
En Tue, 17 May 2011 08:41:41 -0300, Neal Becker escribió: What does it mean when cPickle.load says: RuntimeError: invalid signature Is binary format not portable? Are you sure that's the actual error message? I cannot find such message anywhere in the sources. The pickle format is quite portable, even cross-version. As a generic answer, make sure you open the file in binary mode, both when writing and reading. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: FW: help please
En Tue, 17 May 2011 16:48:29 -0300, Albert Hopkins escribió: On Tue, 2011-05-17 at 10:18 -0600, Littlefield, Tyler wrote: Not to be pedantic or anything, and I may not be able to help regardless, but it looks like your space key is fixed, and I don't really care to pick through and try to play hangman with your message. I actually, at first glance, thought it was spam, ignored it, and was wondering why people were replying to it :| I can't remember exactly in which release 'perfect English skills' were added to Python runtime requirements, could you please refresh my memory? -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: cPickle -> invalid signature
En Tue, 17 May 2011 15:26:53 -0300, Neal Becker escribió: Gabriel Genellina wrote: En Tue, 17 May 2011 08:41:41 -0300, Neal Becker escribió: What does it mean when cPickle.load says: RuntimeError: invalid signature Is binary format not portable? Are you sure that's the actual error message? I cannot find such message anywhere in the sources. The pickle format is quite portable, even cross-version. As a generic answer, make sure you open the file in binary mode, both when writing and reading. Yes, that's the message. Part of what is pickled is a numpy array. I am writing on a 32-bit linux system and reading on a 64-bit system. Reading on the 64-bit system is no problem. Maybe the message comes from numpy's unpickling? Maybe, at least 'invalid signature' makes sense in Numpy. In that case, a better place to ask would be a numpy specific list, see http://www.scipy.org/Mailing_Lists -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: cPickle -> invalid signature
En Tue, 17 May 2011 15:26:53 -0300, Neal Becker escribió: Gabriel Genellina wrote: En Tue, 17 May 2011 08:41:41 -0300, Neal Becker escribió: What does it mean when cPickle.load says: RuntimeError: invalid signature Is binary format not portable? Are you sure that's the actual error message? I cannot find such message anywhere in the sources. The pickle format is quite portable, even cross-version. As a generic answer, make sure you open the file in binary mode, both when writing and reading. Yes, that's the message. Part of what is pickled is a numpy array. I am writing on a 32-bit linux system and reading on a 64-bit system. Reading on the 64-bit system is no problem. Maybe the message comes from numpy's unpickling? Maybe, at least 'invalid signature' makes sense in Numpy. In that case, a better place to ask would be a numpy specific list, see http://www.scipy.org/Mailing_Lists -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Multiple file select with tkFileDialog passes back 'decorated' strings (sometimes)
En Mon, 23 May 2011 10:00:53 -0300, Alex van der Spek escribió: I switched from Mark Hammonds pywin32 extensions for file choosers as the multiselect there seems to crash on me when selecting more than a few dozen. Using Tk now. Works well but the resulting string passed back seems to 'decorated' when the files are on local disk and not decorated when retrieved over a USB interface from an external disk? I do this: From local disk I get back: '{file1.bin} {file2.bin}' From external disk I get back: 'file1.bin file2.bin' I can handle/parse both, not an issue but it raises the question: Are these the only two possibilities? Is it the same across platforms (I use Python 2.7 on Win Vista)? An old bug. See http://bugs.python.org/issue5712 for a workaround. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Hotshoting recursive function
En Sun, 22 May 2011 10:42:08 -0300, Selvam escribió: I am using hotshot module to profile my python function. I used the details from ( http://code.activestate.com/recipes/576656-quick-python-profiling-with-hotshot/ ). The function I profile is a recursive one and I am getting the following error, "ProfilerError: profiler already active" I guess this is due to the recursive call to the profiling function. I would like to get some suggestions. The recursive call inside your function should call the undecorated function, not the decorated function again. Decorator syntax is not convenient anymore. Using the same names as in the recipe example: # a recursive function def my_slow_function(n): ... return my_slow_function(n-1) my_profiled_slow_function = hotshotit(my_slow_function) my_profiled_slow_function(n) This works, in the sense that it does not raise ProfileError anymore. Interpreting profile data is up to you... -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: pexpect: TIMEOUT no longer clears child.before
En Thu, 19 May 2011 08:29:21 -0300, Adrian Casey escribió: The behaviour of pexpect has changed between version 2.1 and 2.3. In version 2.1, the following code would result in child.before being cleared -: >>>child.expect(pexpect.TIMEOUT,1) In version 2.3, this is no longer the case. No matter how many times the above code is run, child.before continues to hold the output from previous commands. It is important to be able to clear the contents of child.before between each command. What is the correct way to do this in version 2.3? Try contacting the author: www.noah.org -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Best way to compute length of arbitrary dimension vector?
En Mon, 30 May 2011 06:46:01 -0300, Peter Otten <__pete...@web.de> escribió: Gabriel wrote: Well, the subject says it almost all: I'd like to write a small Vector class for arbitrary-dimensional vectors. class Vector(object): ... def __init__(self, *coords): ... self._coords = coords ... def __abs__(self): ... return math.sqrt(sum(x*x for x in self._coords)) ... import math abs(Vector(1,1)) 1.4142135623730951 abs(Vector(3,4)) 5.0 Using math.fsum instead of sum may improve accuracy, specially when len(coords)≫2 py> import math py> py> def f1(*args): ... return math.sqrt(sum(x*x for x in args)) ... py> def f2(*args): ... return math.sqrt(math.fsum(x*x for x in args)) ... py> pi=math.pi py> args=[pi]*16 py> abs(f1(*args)/4 - pi) 4.4408920985006262e-16 py> abs(f2(*args)/4 - pi) 0.0 -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Alternatives to PythonPath
En Sun, 29 May 2011 18:49:28 -0300, ray escribió: I am using Win7 on a tightly locked down desktop. Is there an alternative to using PythonPath? What are the trade-offs? Usually there is no need to define the PYTHONPATH variable; I never use it. There is a per-user site-packages directory (2.6 and up), on Windows it is located at %APPDATA%\Python\PythonXX\site-packages. Every user gets its own %APPDATA% directory, with read and write permissions. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Pickle to source code
Hello I want to convert from pickle format to python source code. That is, given an existing pickle, I want to produce a textual representation which, when evaluated, yields the original object (as if I had unpickled the pickle). I know of some transformations pickle/xml (Zope comes with one such tool, gnosis xml is another) so I believe I could build something based on them. But I dont want to reinvent the wheel, I wonder if anyone knows of a library which could do what I want? Thanks, Gabriel Genellina Softlab SRL -- http://mail.python.org/mailman/listinfo/python-list
Re: Pickle to source code
Benjamin Niemann ha escrito: > Gabriel Genellina wrote: > > > I want to convert from pickle format to python source code. That is, > > given an existing pickle, I want to produce a textual representation > > which, when evaluated, yields the original object (as if I had > > If all objects correctly implement the __repr__ method (true for built-in > stuff like list, dict, set...): > Just unpickle it and call repr() on the resulting object. Unfortunately I need a more general approach... Gabriel Genellina Softlab SRL -- http://mail.python.org/mailman/listinfo/python-list
Re: Pickle to source code
Maksim Kasimov ha escrito: > As far i know, in pickle-file there are only attributes values of a pickled > object, but not an object itself. > > It is possible to unpickle object only if you have the sourse of the class > that object you have pickled. > So, if you have class code and attribute values of the class instance, there > is no problem to produce a textual representation of the object. Isn't it? Yes, but I need it for many different objects, some of them written by other people. Please see my next post for clarification. Gabriel Genellina Softlab SRL -- http://mail.python.org/mailman/listinfo/python-list
Re: Pickle to source code
> I want to convert from pickle format to python source code. That is, > given an existing pickle, I want to produce a textual representation > which, when evaluated, yields the original object (as if I had > unpickled the pickle). > I know of some transformations pickle/xml (Zope comes with one such > tool, gnosis xml is another) so I believe I could build something based > on them. > But I dont want to reinvent the wheel, I wonder if anyone knows of a > library which could do what I want? An example to make things clear: class MyClass: def __init__(self,a,b): self.a=a self.b=b def foo(self): self.done=1 # construct an instance and work with it obj = MyClass(1,2) obj.foo() # save into file pickle.dump(obj,file('test.dat','wb')) Then, later, another day, using another process, I read the file and want to print a block of python code equivalent to the pickle saved in the file. That is, I want to *generate* a block of code like this: xxx = new.instance(MyClass) xxx.a = 1 xxx.b = 2 xxx.done = 1 Or perhaps: xxx = new.instance(MyClass, {'a':1,'b':2,'done':1}) In other words, I need a *string* which, being sent to eval(), would return the original object state saved in the pickle. As has been pointed, repr() would do that for simple types. But I need a more general solution. The real case is a bit more complicated because there may be references to other objects, involving the persistent_id mechanism of pickles, but I think it should not be too difficult. In this example, if xxx.z points to another external instance for which persistent_id returns '1234', would suffice to output another line like: xxx.z = external_reference('1234') I hope its more clear now. Thanks, Gabriel Genellina Softlab SRL -- http://mail.python.org/mailman/listinfo/python-list
Re: Pickle to source code
Jean-Paul Calderone ha escrito: > >In other words, I need a *string* which, being sent to eval(), would > >return the original object state saved in the pickle. > > You may find twisted.persisted.aot of some use. Here is an example: > > AOT is unmaintained in Twisted, and may not support some newer features of > Python (eg, datetime or deque instances). If this seems useful, you may want > to contribute patches to bring it up to the full level of functionality you > need. Oh, thanks. I have some problems installing the package but I hope it will be useful. If any changes are needed I'll report them. Gabriel Genellina Softlab SRL -- http://mail.python.org/mailman/listinfo/python-list
Re: Pickle to source code
Olivier Dormond ha escrito: > > xxx = new.instance(MyClass, {'a':1,'b':2,'done':1}) > > > > In other words, I need a *string* which, being sent to eval(), would > > return the original object state saved in the pickle. > > Doesn't pickle.loads just do what you need ? e.g.: > > >>> pickled = file('test.dat', 'rb').read() > >>> obj = eval('pickle.loads(%r)'%pickled) > >>> obj > <__main__.MyClass instance at 0xb7bfb76c> > >>> obj.a, obj.b, obj.done > (1, 2, 1) Er... Touché :) - What year did World War II finish? - Same year the Potsdam Conference was held. - When was that? - The year World War II finished. I should have stated that I need an *explicit* string... Gabriel Genellina Softlab SRL -- http://mail.python.org/mailman/listinfo/python-list
Re: Error 'module' object has no attribute "_extension_registry" when cPickle is imported from an installed Python 2.7.1
En Tue, 27 Sep 2011 06:08:54 -0300, Wong Wah Meng-R32813 escribió: Hello all, I encounter this issue whereby I am not able to load cPickle module into the python I newly built. There is no issue when I load it right from the folder where the python executable and libpython2.7.so is built. However, it gives me this error when I load the same module using the installed files (python and all its modules, shared library from default /use/local folder that contains bin, lib, include sub-folders) from "make install" command. Does anyone know why? Here is the error:- $ python Python 2.7.1 (r271:86832, Sep 27 2011, 15:19:26) [C] on hp-ux11 Type "help", "copyright", "credits" or "license" for more information. import cPickle Traceback (most recent call last): File "", line 1, in AttributeError: 'module' object has no attribute '_extension_registry' Looking at cPickle.c, it imports the copy_reg module and then looks for its "_extension_registry" attribute. Maybe your copy_reg.py is broken, or you have another copy_reg.py hiding the standard one. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: syntactic sugar for def?
En Wed, 28 Sep 2011 18:51:00 -0300, Chris Kaynor escribió: On Wed, Sep 28, 2011 at 2:37 PM, Arnaud Delobelle wrote: On 28 September 2011 22:26, Ethan Furman wrote: I remember that 'class' is sugar for type(). I don't remember if 'def' is sugar for something besides lambda. Any clues for me? Heck, I'll even be grateful for outright answers! It's not really sugar. But I think you mean something like this: class A: pass ... type(A) type is type(A) True So the closest you get for functions will be: def f(): pass ... type(f) Try help(type(f)) to see how to use it to create a function object. The problem is that you need to provide a code object, and the easiest way to create a code object is to use a def statement :) I would say compile isn't too much harder to use: c = compile('a = 123', 'test', 'exec') d = {} f = types.FunctionType(c, d, 'test') f() print d {'a': 123} Although it appears you get all of the variables defined as global apparently (try "f = types.FunctionType(c, globals(), 'test')" instead). I know no way of compiling a function body alone. Suppose you have this function: def foo(x): print x y = 2*x return y py> compile(" print x\n y = 2*x\n return y", "", "exec") Traceback (most recent call last): File "", line 1, in File "", line 1 print x ^ IndentationError: unexpected indent py> compile("print x\ny = 2*x\nreturn y", "", "exec") Traceback (most recent call last): File "", line 1, in File "", line 3 SyntaxError: 'return' outside function If you include the 'def' statement in the source string, the resulting code object does not represent the function itself, but a "module" defining it: py> f = FunctionType(compile("def foo(x):\n print x\n y = 2*x\n return y\n", ... "", "exec"), globals(), "foo") py> f(3) Traceback (most recent call last): File "", line 1, in TypeError: () takes no arguments (1 given) py> dis.dis(f) 1 0 LOAD_CONST 0 (file "", line 1>) 3 MAKE_FUNCTION0 6 STORE_NAME 0 (foo) 9 LOAD_CONST 1 (None) 12 RETURN_VALUE To get at the actual function code, one should use f.func_code.co_consts[0]; this would be the 'code' parameter for types.FunctionType. Very complicated, really; nothing can beat the 'def' statement for defining a function ;) -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Installing Python 2.6.7 on Windows
En Wed, 28 Sep 2011 21:10:38 -0300, Nobody escribió: On Wed, 28 Sep 2011 15:21:25 -0700, Ned Deily wrote: No, it was a deliberate decision. After a release is in security-fix mode only, we don't build Windows or Mac OS X installers for them. But you continue to offer the installers for the unfixed version. As well as all the previous ones back to Python 1.x I can think of several alternatives: * Upgrade to Python 2.7, the current stable and maintained release. * Compile Python 2.6.7 yourself. For the 32 bits version, you may use Microsoft Visual C++ 2008 Express Edition (free/gratis); see PCbuild\readme.txt for details. Obtain the required dependencies using Tools\buildbot\external.bat. It compiles cleanly out of the box. * Obtain the compiled binary somewhere else. Considering that 2.6.7 is just a security patch, I'm not sure if running a precompiled binary from untrusted sources is any better than sticking with the official, previous version. I've built the binaries, in case you're interested. * Compare both source trees and look at their differences. Most of them are in Python modules that you can just drop over an existing 2.6.6 install. Only two C modules have changed, and require rebuilding python26.dll: timemodule.c r87648: Issue #8013: Fixed time.asctime segfault when OS's asctime fails unicodedata.c http://bugs.python.org/issue10254 If you think you're not affected by these, just ignore 2.6.7 (or apply only the .py changes) -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Change import order with *.pth files
En Sun, 02 Oct 2011 18:29:24 -0300, Andrea Gavana escribió: Let's say I am using a package called "blah", and this package is already installed on site-packages (and I need it to be there) with a name "blah-1.2-win". In the site-packages folder, there is a pth file called "blah.pth" which contains this line: blah-1.2-win To redirect Python to the correct folder when I type "import blah". Anyway, now I am developing another version of this package and it's called "blah-2.0-win", and it sits on my computer into a different folder (not on site-packages, on an entire different drive in reality). How can I tell Python *not* to use the version inside site-packages but to use the other one in my development folder (without touching the pth file in site-packages, of course)? From Python 2.6 on, there is a per user site-packages directory, which is searched before the global one. See: http://docs.python.org/whatsnew/2.6.html#pep-370-per-user-site-packages-directory You could put your developing version on that directory. In Python 2.5 and earlier, if you have to PREPEND a directory to sys.path, you may set the PYTHONPATH environment variable, or edit the site.py standard module. This may be fine in your development environment, but I would never do that in production. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: BaseHTTPServer ThreadMixIn not working
En Mon, 03 Oct 2011 12:03:18 -0300, amit escribió: I am really stuck in a very simple problem and wanted to know if you could take some time to check it out - My code is simple. Using BaseHTTPServer and ThreadInMix I want to run a python script (Script1.py) for every request made simultaneously. [...] If I open multiple tabs/pages in Chrome/Firefox/IE and give URL: http://localhost:8080, the pages wait for previous page? This does not imply threading? Any help? Thanks Your code is fine, and Python behaves correctly. The browser is queuing all similar requests when it sees they all refer to the same URI. Had the first response contained an Expires: header in the future, there would be no need to ask again for the same object; the ETag: and Last-Modified: headers may play a role too. So, only after the first response is completely read, Chrome/Firefox/IE sees it is invalid and knows she cannot re-use the received body and has to issue the second request and waits again and ... Try with different URLs for each request: http://localhost:8080/a http://localhost:8080/b http://localhost:8080/c and you'll see they all are processed in parallel. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Is exec() also not used in python 2.7.1 anymore?
En Tue, 04 Oct 2011 07:32:41 -0300, Wong Wah Meng-R32813 escribió: Haha... yeah I reviewed the code, it is supposed to exposed some remote methods locally (RMI proxy usage). However, I am not sure why what it does is merely a pass. I commented out this code and haven't seen any negative implication. I will look into this again if I am convinced the next error I see is due to I commented out this code. exec('def %s(self, *args, **kw): pass'%methodStrName) In case you convince yourself that defining this dynamic but empty function is really needed, you can avoid exec this way: def some_function(...) ... # instead of exec('def ...' % methodStrName) def empty_function(self, *args, **kw): pass empty_function.func_name = methodStrName ... # presumably methodStrName is referred somehow in # the remaining code block, or perhaps locals(); # modify accordingly -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: database connection
En Fri, 07 Oct 2011 02:18:04 -0300, masood shaik escribió: can u please tell me how we can connect to database without changing the permission of db file using sqlite3 The OS user who executes the Python script must have read (and write, usually) access to the database file - *any* OS user who can read the database file can connect to it. sqlite does not have internal users, and does not implement GRANT/REVOKE statements. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: How to inspect slot wrappers arguments in Python?
En Sat, 01 Oct 2011 12:13:45 -0300, julian bilcke escribió: I would like to get the list of parameters I need to initialize an AST node. I'm trying to use the `inspect` module, however it seems I can't use it on a built-in (native?) class, or else I misunderstood. [...] >>> import inspect >>> import ast >>> inspect.getargspec(ast.If.__init__) Traceback (most recent call last): File "", line 1, in File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/inspect.py", line 813, in getargspec raise TypeError('{!r} is not a Python function'.format(func)) TypeError: is not a Python function I am wondering if there is another way to get these parameters automatically? (ie. without compiling myself a dict) I'm afraid there is no way; this kind of introspection does not work for functions written in C. The function itself usually has a generic signature resembling (*args, **kw), and its parameters are usually unpacked calling a suitable variant of PyArg_ParseXXX. The information about the number and type of expected arguments is encoded in its 'format' parameter, and is not stored anywhere. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: sending ftp file list to mail???
En Fri, 07 Oct 2011 03:23:57 -0300, selahattin ay escribió: hi all. I want to get my ftp list and send the list to my mail adress... my codes are And your problem is...? -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: sending ftp file list to mail???
En Fri, 07 Oct 2011 03:23:57 -0300, selahattin ay escribió: hi all. I want to get my ftp list and send the list to my mail adress... my codes are baglanti = FTP("ftp.guncelyorum.org") baglanti.login("**", "***") print baglanti.dir() posta = MIMEMultipart() def posta_olustur(): posta['Subject']=konu posta['From']=gmail_kullanici posta['To']=kime posta.attach(MIMEText(baglanti.retrlines("LIST"))) <-- what can I do for here Ah, I didn't notice that part. MIMEText expects a string. retrlines, by default, outputs to stdout, isn't very useful. Try this: def posta_olustur(): ... lines = [] baglanti.retrlines("LIST", lines.append) text = '\n'.join(lines) posta.attach(MIMEText(text)) -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: socket.getsockname is returning junk!!
En Wed, 05 Oct 2011 08:56:08 -0300, Wong Wah Meng-R32813 escribió: I am migrating my application from python 1.5.2 to 2.7.1. One of the existing code breaks. The getsockname method from socket object somehow returns me with some number which I deem as junk, rather than the listening port as I would have expected in the older python. Has anyone seen the same thing or is it due to my python is built with some corrupted library or something? $ python Python 2.7.1 (r271:86832, Oct 5 2011, 18:34:15) [C] on hp-ux11 Type "help", "copyright", "credits" or "license" for more information. import socket sock = socket.socket( socket.AF_INET, socket.SOCK_STREAM ) sock.setsockopt( socket.SOL_SOCKET, socket.SO_REUSEADDR, 1 ) sock.setsockopt( socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1 ) sock.setsockopt( socket.IPPROTO_TCP, 1, 1 ) server_address=('zmy02hp3', 1) sock.bind(server_address) sock.getsockname() (0, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') In python 1.5.2 server_address=('zmy02aix04', 1) sock.bind(server_address) sock.getsockname() ('10.228.51.41', 1) I'd say it's a problem with the _socket module; did the unit tests flag anything when you built Python? On Windows, Python 2.7.1: server_address=('lepton', 1) sock.bind(server_address) sock.getsockname() ('127.0.0.1', 1) -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Deleting files on a shared server
En Fri, 07 Oct 2011 04:45:32 -0300, Tim Golden escribió: On 07/10/2011 02:14, Josh English wrote: To delete the files, I am using os.unlink. One lock file refuses to disappear, even though I have code at both application startup and shutdown (on the OnInit and OnExit methods to the wxPython Application object) that hunts down .lock files and deletes them. Assuming that your code paths succeed and that the unlink actually happens, it is possible for files to continue to exist after they have been successfully deleted. This happens if another process has opened them with share-delete mode; typically this will be a virus checker or a process like the TortoiseSVN cache (or its counterparts for other VCS). The file won't actually disappear until the last handle on it is released. In such cases the openfiles command [1] is very useful for detecting who is holding the file open. [1] http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/openfiles.mspx -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: why msvcrt.printf show the first char only?
On 12 oct, 08:50, Nobody wrote: > On Wed, 12 Oct 2011 04:18:25 -0700, install...@189.cn wrote: > > from ctypes import * > > msvcrt = cdll.msvcrt > > message_string = "Hello world!\n" > > print(msvcrt.printf("Testing: %s", message_string)) > > > when running in eclipse, the result is: > > 1 > > T > > > when running in IDLE, then result is: > > 1 > > > why is that? > > Odd. I get 22 when running from IDLE. > > Also, when using the console, it actually prints the text. I suspect that > stdout gets block-buffered when using an IDE. I can't see any way to get a > reference to stdout, so you can't fflush() it. Launch IDLE from the command line and you'll see the text output. To the OP: I bet your Eclipse runs Python 2.x and IDLE is 3.x. In Python 3.x, "Test..." is a Unicode string, internally represented using two bytes per character. (In contrast, in Python 2.x, "Test..." is a byte string, and u"Test..." is unicode). All ASCII characters have a 0 as their second byte in its internal representation. printf expects a byte string, and stops as soon as it sees the '\0' following the 'T' in 'Testing'. Either use wprintf("Testing..."), or encode the Unicode object into a byte string before calling: printf("Testing...".encode(sys.stdout.encoding)), or tell ctypes about the right parameter type: printf = msvcrt.printf printf.argtypes = [c_char_p] printf("Testing\n") -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Fast recursive generators?
En Fri, 28 Oct 2011 15:10:14 -0300, Michael McGlothlin escribió: I'm trying to generate a list of values where each value is dependent on the previous value in the list and this bit of code needs to be repeatedly so I'd like it to be fast. It doesn't seem that comprehensions will work as each pass needs to take the result of the previous pass as it's argument. map() doesn't seem likely. filter() or reduce() seem workable but not very clean. Is there a good way to do this? About the best I can get is this: l = [ func ( start ) ] f = lambda a: func ( l[-1] ) or a filter ( f, range ( big_number, -1, -1 ) ) I guess I'm looking for something more like: l = do ( lambda a: func ( a ), big_number, start ) What about a generator function? def my_generator(): prev = 1 yield prev while True: this = 2*prev yield this prev = this print list(itertools.islice(my_generator(), 10)) -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: When I use Python under Windows. I found some file handles are not closed,
En Mon, 31 Oct 2011 12:57:15 -0300, 罗勇刚(Yonggang Luo) escribió: How did detecting where those handlers are created to tracing it and close it. Mainly because I was using C binding library(subvertpy) and file is not closed. A better place to ask is python-list@python.org Please include the Python version you're using. Also, a small, complete, runnable code example showing the problem would be very valuable. Usually, in building such example, you may well find out where your problem is. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
threading IOError
Hi I'm using Python 2.4.2 on Windows 98 SE. In a program with several threads, sometimes (I cant determine exactly when or why) one thread dies with the following traceback: 12/13/05 02:17:47 (WatchDog ) Unhandled thread exception Traceback (most recent call last): File "E:\prog\pop3\TaskScheduler.py", line 60, in run self.finished.wait(self.interval) File "C:\Apps\Python\Lib\threading.py", line 348, in wait self.__cond.wait(timeout) File "C:\Apps\Python\Lib\threading.py", line 218, in wait remaining = endtime - _time() IOError: [Errno 2] No such file or directory The error appears to be inside the time module, and I can't explain the IOError there. Maybe this crash is related too: sometimes, the full program crashes with an Invalid Page Fault with the following info: PYTHONW provocó un error de página no válida en el módulo PYTHON24.DLL de 016f:1e0ab51f. Registros: EAX=1e19d1af CS=016f EIP=1e0ab51f EFLGS=00010206 EBX=00841f80 SS=0177 ESP=0071e6ec EBP= ECX=73962000 DS=0177 ESI=1e06a1b0 FS=1a07 EDX=1e19d1b0 ES=0177 EDI=0000 GS= Any ideas? Gabriel Genellina Softlab SRL -- http://mail.python.org/mailman/listinfo/python-list
Re: threading IOError
Andrew MacIntyre ha escrito: > Gabriel Genellina wrote: > > File "C:\Apps\Python\Lib\threading.py", line 218, in wait > > remaining = endtime - _time() > > IOError: [Errno 2] No such file or directory > > > > The error appears to be inside the time module, and I can't explain the > > IOError there. > > > > Maybe this crash is related too: sometimes, the full program crashes > > with an Invalid Page Fault with the following info: > Quite some time ago I saw the same sort of issue - inexplicable > exceptions from apparently benign code. > > Tim Peters prognosticated that there was a bug in an extension module, > and indeed that proved to be the case (a 3rd party extension, which > fortunately I had source for and was able to build). > > I doubt that any of Python's standard extension modules will be involved > (as they are generally mature and widely used and tested) but you should > look at the source for any others looking for unhandled error returns. > Typically, errno is set but the failure return from the routine setting > errno is ignored or not properly handled. > > What then happens is the next time an exception gets propagated through > Python's internals, the errno value gets picked up and is used to > identify the exception (incorrectly). > > The invalid page fault may well be because a garbage pointer is handed > to a routine, possibly as a consequence of the mishandled error return. Oh, thanks, at least this gives me a starting point to investigate. But I can´t discard the standard modules; this is an (almost) clean python install. The download rate has became extremely low and maybe all of this is related to the recent upgrade to Python 2.4.2... (Maybe Win98+many threads+sockets is not a well tested combination) Thanks, Gabriel Genellina Softlab SRL -- http://mail.python.org/mailman/listinfo/python-list
Design Patterns in Python
Hello Most authors talk about Java/C++, and describe patterns used as a workaround to their static class model; the dynamic nature of Python allows for trivial implementations in some cases. I've seen some design patterns examples on the ActiveState site, and some discussions some time ago on this list. But does anyone know of a complete discussion/analysis of patterns in Python? Books, articles, web pages... Unfortunately the pattern-SIG is now defunct... Gabriel Genellina Softlab SRL __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
Re: Design Patterns in Python
At Saturday 5/8/2006 22:22, Alex Martelli wrote: > But does anyone know of a complete discussion/analysis of patterns in > Python? Books, articles, web pages... Thanks to all of you for your pointers on this subject! Gabriel Genellina Softlab SRL __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
Re: python - HTML processing - need tips
At Monday 7/8/2006 20:58, wipit wrote: I need to process a HTML form in python. I'm using urllib2 and HTMLParser to handle the html. There are several steps I need to take to get to the specific page on the relevant site the first of which is to log in with a username/password. The html code that processes the login consists of 2 edit boxes (for User ID and Password) and a Submit button which uses ASP.net client side validation as follows (formatted for clarity): Another approach would be using HTTPDebugger <http://www.softx.org/debugger.html> to see exactly what gets submitted, and then build a compatible Request. On many sites you don't even need to *get* the login page -nor parse it-, just posting the right Request is enough to log in successfully. Gabriel Genellina '@'.join(('gagsl-py','.'.join(('yahoo','com','ar' __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
Re: Accessing Yahoo Mail withtout POP
At Tuesday 8/8/2006 12:39, Dieter Deyke wrote: > Is there a way to access yahoo mail via its web interface? If so, can > someone give some pointers? www.freepops.org Very generic almost-anything-to-pop3, but it's not written in Python, uses LUA instead. Gabriel Genellina Softlab SRL __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
Re: newb question: file searching
At Tuesday 8/8/2006 17:55, [EMAIL PROTECTED] wrote: I must ask, in the interest of learning, what is [file for file in files if file.endswith(extension)] actually doing? I know that 'file' is a type, but what's with the set up and the brackets and all? Can someone run down the syntax for me on that? Note: "file" is really a bad name here; rebinding builtins is never a good idea. But unfortunately names like "file", "dir", "dict" are very handy when you need a dummy variable like this, so people tend to use them. This has exactly the same meaning: [x for x in files if x.endswith(extension)] I still need to know how I can dynamically get the name of the directory that my script is in. os.path.dirname(os.path.abspath(sys.modules[__name__].__file__)) Also, how can I get it to add the full path of the file to "images" instead of just the file name. See, when I go to use a particular image name later on, it won't do me much good if I don't have the path to it. Look at os.path.join() Gabriel Genellina Softlab SRL __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
Re: newb question: file searching
At Tuesday 8/8/2006 21:11, [EMAIL PROTECTED] wrote: Here's my code: def getFileList(): import os imageList = [] for dirpath, dirnames, filenames in os.walk(os.getcwd()): for filename in filenames: for dirname in dirnames: if not dirname.startswith('.'): if filename.lower().endswith('.jpg') and not filename.startswith('.'): imageList.append(os.path.join(dirpath, filename)) return imageList I've adapted it around all the much appreciated suggestions. However, I'm running into two very peculiar logical errors. First, I'm getting repeated entries. That's no good. One image, one entry in the list. That's because of the double iteration. dirnames and filenames are two distinct, complementary, lists. (If a directory entry is a directory it goes into dirnames; if it's a file it goes into filenames). So you have to process them one after another. def getFileList(): import os imageList = [] for dirpath, dirnames, filenames in os.walk(os.getcwd()): for filename in filenames: if filename.lower().endswith('.jpg') and not filename.startswith('.'): imageList.append(os.path.join(dirpath, filename)) for i in reversed(range(len(dirnames))): if dirnames[i].startswith('.'): del dirnames[i] return imageList reversed() because you need to modify dirnames in-place, so it's better to process the list backwards. Gabriel Genellina Softlab SRL __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
Re: os.path.normpath
At Wednesday 9/8/2006 15:45, [EMAIL PROTECTED] wrote: I am using a windows box and passing a string like "../foo/../foo2" to normpath which then returns "..\\foo2". But if this string is going into a webpage link it should really be "../foo". You could just .replace('\\','/') on the resulting string. Or use the urlparse module. Is there any way to tell os.path.normpath to act like we are an a unix style box? The fact than '/' is used as a path separator both on unix and on HTTP URLs should be considered as a mere coincidence (in fact it isn't...) URLs dont necesarily point to a real file on a real file system (Zope is an example). Gabriel Genellina Softlab SRL __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
Re: Nested function scope problem
At Wednesday 9/8/2006 16:15, [EMAIL PROTECTED] wrote: I agree with the previous comments that this approach is "bad form". But if you absolutely *must* modify an enclosing function's variables with an inner function, all you need to do is remember that a Python function is an object too, so it can be assigned attributes. ;-) def outer(): outer.x = 1 print outer.x def inner(): outer.x = 2 inner() print outer.x I see two problems: - Concurrency: two or more threads executing the same function, writing to this "global" - Can't be used (easily) on methods On the original question, I would inherit from list: > def addTok(): > if len(tok) > 0: > ls.append(tok) > tok = '' > > class mylist(list) def addTok(self, tok): if len(tok)>0: self.append(tok) tok = '' return tok ls = mylist() and use: tok = ls.addTok(tok) whenever the original code says addTok(tok) Gabriel Genellina Softlab SRL __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
Re: Two Classes In Two Files
At Wednesday 9/8/2006 16:24, [EMAIL PROTECTED] wrote: I just started working with Python and ran into an annoyance. Is there a way to avoid having to use the "from xxx import yyy" syntax from files in the same directory? I'm sure it's been asked a million times, but I can't seem to find the answer. [...] When I run the Two.py file, I get the expected output but I'd like to eliminate the from line in two.py. Embody the Zen of Python: http://www.python.org/dev/peps/pep-0020/ Gabriel Genellina Softlab SRL __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
Re: loop until keypress (Windows XP)
At Thursday 10/8/2006 02:19, placid wrote: chr = sys.stdin.read(1) while chr != "q": """ keep printing text """ chr = sys.stdin.read(1) but again this blocks too. is there a way to do this, wait for user input but dont block? I could use a thread that just does the previous code block but i already have three Thread classes, its just getting too complex with threads! If your script only needs to be run on Windows -as the subject suggests- you can use the msvcrt module: from msvcrt import kbhit,getch stop = False while not stop: print "Hello world!" if kbhit(): stop = getch()=='q' kbhit() is used to detect when a keypress is waiting, so the next getch() will not block. Gabriel Genellina Softlab SRL __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
Re: state of SOAP and python?
At Thursday 10/8/2006 03:38, Mark Harrison wrote: So I'm investigating doing some SOAP work... Any concensus on what the best python libraries are for doing this? Too bad, xmlrpc is choking on our long longs. :-( Just thinking, if you have control over the two ends, and dont need real interoperability, maybe just extending to support long integers could be easier... I remember extending once to support NaN's, moving to SOAP was too much effort for that application. Gabriel Genellina Softlab SRL __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
Re: Escape sequences (colour) and padding with "%8s"%
At Thursday 10/8/2006 07:04, Anton81 wrote: For example: print '%8s' % '\x1b[34mTEST\x1b[0m' doesn't not indent 'TEST' whereas print '%8s' % TEST' works. If you insist on building the codes yourself instead of using the standard curses library... print '\x1b[34m%8s\x1b[0m' % 'TEST' Gabriel Genellina Softlab SRL __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
RE: seaching a list...
At Thursday 10/8/2006 21:54, bruce wrote: the issue i'm having is that i'm going to have to compare multiple rows of information to the information in the db. so essentially i'd have to do a hit to the db, for each row of information i want to compare if i did it your way... (which was what i had thought about) the issue of doing the string/list compare/search is that i can get everything from the db with one call... i can then iterate through memory for each of my row information that i'm searching to see if it exists in the db... memory searches should be faster than the network overhead, and the associated multiple db calls... should... are you sure? How many rows on the database? how many rows to compare? network overhead? Do some timing/performance tests to evaluate that. Things aren't always as you expect. Gabriel Genellina Softlab SRL __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
Re: Tab delimited file
At Friday 11/8/2006 11:41, Colin Wildsmith wrote: >I am making a gui for the purpose that I can >change the values in a list of different >criteria which is found in a text file, such as: > >Name(tab)rating(tab)breast size(tab)occurrences > > > > >However as far as I know Python does not allow >you to easily change a specific line in a text >file. You have to place the whole file to >memory, change what you need to and then write >the file back after deleting the previous information. Yes. If the lines are not all fixed-length, this is true in general for any language, not only Python. > Assuming this is true, how do i find where the > tabs are in the file so that I can distinguish between the different criteria? >Assuming this is not true, does anyone suggest another way to do it? Look at the csv module: http://docs.python.org/lib/module-csv.html Gabriel Genellina Softlab SRL __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
Re: seeking the "Hello World" of Packages
At Friday 11/8/2006 14:48, Bell, Kevin wrote: I'm trying to get an idea of how packages work and I've read about it in the Py Tutorial and Nutshell, but I'm still craving a concrete example that I can poke through. Does anyone have a really basic package that does very little that I could look at? What I've gathered thus far is that a package is simply a directory, say C:\MyPackage, that would contain __init__.py which tells Python to be aware of all the other modules in C:\MyPackage. Am I correct? C:\MyPackage\ \__init__.py \justPrintHelloWorld.py \multiply5By10.py Would I expect the following behavior?: >>>import MyPackage >>>MyPackage.justPrintHelloWorld "Hello World" >>>MyPackage.multiply5by10 50 Not exactly. Assuming your __init__.py is empty, MyPackage.justPrintHelloWorld references that *module*. If you have a function called "printHelloWorld" there, you could call it this way from another unrelated module: import MyPackage MyPackage.justPrintHelloWorld.printHelloWorld() or from MyPackage import justPrintHelloWorld justPrintHelloWorld.printHelloWorld() or from MyPackage.justPrintHelloWorld import printHelloWorld printHelloWorld() But sometimes, either by convenience or to hide implementation details, you put something into the package's namespace: <<<__init__.py>>> from justPrintHelloWorld import printHelloWorld Then you could use: import MyPackage MyPackage.printHelloWorld() Note: In order to be able to import MyPackage, the directory MyPackage must be a subdir of anything listed on sys.path. It's unlikely that C:\MyPackage would work. Try using python\lib\site-packages instead. Read the Tutorial, section Modules, for more information. Gabriel Genellina Softlab SRL __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
Re: Learning Python
At Friday 11/8/2006 18:04, Dr. Pastor wrote: Attempting to learn Python; I constructed the module listed below. I would like to make it shorter, faster, more "Python like". (Windows XP, Pro.) Many thanks for any advice! ... #--- # Name:SendMoreMoney.py # Purpose: A solution to the SEND+MORE=MONEY puzzle. # # Author: Dr. Pastor # # Copyright: (c) Dr. Pastor 2006 #--- #!/usr/bin/env python This line is not used on Windows, but if you want to include it, must be the very first line on the script. # # The solution for the puzzle of #SEND # +MORE # - # MONEY # def perm(items, n=None): if n is None: n = len(items) for i in range(len(items)): v = items[i:i+1] I would use v = [items[i]] but that's a matter of taste... if n == 1: yield v else: rest = items[:i] + items[i+1:] for p in perm(rest, n-1): yield v + p def comb(items, n=None): if n is None: n = len(items) for i in range(len(items)): v = items[i:i+1] Same as above. if n == 1: yield v else: rest = items[i+1:] for c in comb(rest, n-1): yield v + c # # S E N D M O R Y # ['0','1','2','3','4','5','6','7','8','9'] # print print "Selections of 8 items from 10 then the permutation of them." print b=0 for s in comb([0,1,2,3,4,5,6,7,8,9],8): for a in perm(s,None): if (a[4]*1000+a[5]*100+a[2]*10+a[1])*10+a[7] == \ (a[0]+a[4])*1000+(a[1]+a[5])*100+(a[2]+a[6])*10+(a[3]+a[1]): Backslash as continuation is a bit problematic (add an empty space after it and it's broken...) so it's better to add an open parens; continuation is implicit until the last parens is closed: if (a[4]*1+a[5]*1000+a[2]*100+a[1]*10+a[7] == (a[0]+a[4])*1000+(a[1]+a[5])*100+(a[2]+a[6])*10+(a[3]+a[1])): If speed is not the most important thing, you could assign names to the 8 items: S, E, N, D, M, O, R, Y = a if poly(10, M,O,N,E,Y) == poly(10, S,E,N,D) + poly(10, M,O,R,E): which is infinitely more legible (and a bit compact, too). (poly is left as an exercise: def poly(x, *args): ) And a,b,s are too short names... Gabriel Genellina Softlab SRL __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie Python SQL
At Monday 14/8/2006 16:54, len wrote: Could someone recommend a tutoral, book, white paper, etc. I am trying to write a python program which takes a CSV file and through SQL insert update my SQL files. The SQL files contain a parent file with multiply child and grandchildren plus various files for doing validation. I am using the mxODBC module for access to the SQL files. I have, through the IDLE connected done some simple queries and some testing of insert. I believe I am past the initial stage on the SQL stuff but just can't get to the next level. I have picked up several python book, but all take a very introductory approach. Any recommendation would be appreciated. I think you need an SQL/database course rather than a Python one. Gabriel Genellina Softlab SRL __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
Re: looking for a simple way to load a program from another python program..
At Sunday 13/8/2006 16:51, [EMAIL PROTECTED] wrote: I was looking for a simple way to load a simple python program from another python program. I tried os.system(cabel) The file name is cabel.py a csound instrument editor.. NameError: global name 'cabel' is not defined Have you tried os.system("cabel.py") Gabriel Genellina Softlab SRL __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
Re: sending mailing list with smtplib
At Monday 14/8/2006 10:22, 3KWA wrote: # ... but the actual message sending in a loop to send one email each (didn't work) Specify "didn't work" at least... see http://www.catb.org/~esr/faqs/smart-questions.html Gabriel Genellina Softlab SRL __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
Re: why the method get() of python Queue is hang on there?
At Monday 14/8/2006 12:35, zxo102 wrote: Thanks for your guys. I got it. I thought Queue can be used anywhere in the code and the second b.get() would return a "None". You can use a list as a generic queue, with append (== push) and pop(0) Gabriel Genellina Softlab SRL __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
Re: OT: p-gal website
At Monday 14/8/2006 18:45, John Bokma wrote: > Even Firefox developers will tell you to avoid this. Develop for > standards compliant browsers (including Firefox) by testing against > the standards. Neither your HTML or CSS pass validation, both due to > minor, easy-to-fix issues. If you actually read those "standards" you will know that the documents itself are called Recommendations or Working drafts. Why someone recommends to follow documentation but isn't even able to name them as they are named in the documentation itself is beyond me. Uh? They are "true" and "real" international standards. Do you know what ISO is? HTML 4.01 is ISO/IEC 15445; see https://www.cs.tcd.ie/15445/15445.html Gabriel Genellina Softlab SRL __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
Re: Python for arcgis
At Thursday 17/8/2006 00:25, subramanian2003 wrote: From where can I get the python tutorial for arcgis customisation?. Tried google? Gabriel Genellina Softlab SRL __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
Re: Py2Exe and sys.argv : The Lost Arguments
At Thursday 17/8/2006 16:42, Thomas W wrote: Is it impossible to compile a script using py2exe and pass selected items in Explorer to my script? It works fine when called on the command line so it might be something related to Explorer but I'm completly lost. Yes, it is related to Explorer -some misbehaving context menu extension-. See <http://groups.google.com/group/microsoft.public.windowsxp.basics/browse_frm/thread/5d7a111f31fa7901> But, maybe next time, you could try and exclude all other variables (wxWindows, py2exe...) to keep things simple... Gabriel Genellina Softlab SRL __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
Re: Http client to POST using multipart/form-data
At Friday 18/8/2006 03:06, Bruno Dilly wrote: I'm implementing a http client to POST using multipart/form-data. It uses urllib2 module, and files are uploaded correctly. But I need to know how much has been uploaded at a given moment, to inform the user the proportion of the file already uploaded. See httplib.HTTPConnection._send_request; after sending the headers: if body: self.send(body) You should inherit from HTTPConnection and provide your feedback there - that depends on your application. Then, inherit from urllib2.HTTPHandler, and override http_open to use your custom HTTPConnection. Pass your custom HTTPHandler to build_opener and it will use it. Gabriel Genellina Softlab SRL __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
Re: efficient memoize decorator?
At Friday 18/8/2006 17:14, [EMAIL PROTECTED] wrote: sorry memoize is http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496879 This implementation uses cPickle to generate a key from the supplied function arguments, which is very slow and defeats the purpose of memoizing. In your example -function with no keyword arguments- use the much simpler implementation from <http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/325205> NOT the original recipe but the comment by Chris Spencer titled "A working example". Gabriel Genellina Softlab SRL __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
Re: Search or compai problem
At Saturday 19/8/2006 01:16, [EMAIL PROTECTED] wrote: it is really lstusers (it is an L not a # 1), Some of the output from print lstUsers has the output of None. I and trying to filter the None out of the list. I come from a perl background and this is how I do thing in perl None is a unique object used as "nothing" or "no value". Try reading the Python tutorial, it's easy and you will learn a lot of things. Gabriel Genellina Softlab SRL __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
Re: Documenting a package with Pydoc
At Friday 18/8/2006 11:45, Rob Cowie wrote: Pydoc seems to be capable of writing documentation for all modules within a package by simply pointing it to the package on the command line... pydoc -w Certainly, the method writedocs() appears to descend into a directory and create docs for each importable object. Perhaps I'm doing something wrong but when I do this, pydoc reports that no Python documentation can be found for each of the contents of the package. Of course, if I point pydoc directly to the modules, it succeeds. Am I doing something wrong? That appears to be a bug. In pydoc.writedocs, when iterating over the package directory contents, it uses inspect.getmodulename(path). That returns the bare filename (without path nor extension) (is it ok???), and later the resolve() function can't load the module because it lacks package information. For simple cases this patch may work: In writedocs, add the following line at the beginning: if pkgpath=='' and ispackage(dir): pkgpath = os.path.basename(dir) + '.' This works for top level packages located at sys.path, but not for packages located elsewhere. By example, I can generate now the docs for pychart: python c:\apps\python\lib\pydoc.py -w c:\apps\python\lib\site-packages\pychart Gabriel Genellina Softlab SRL __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
Re: efficient memoize decorator?
At Saturday 19/8/2006 07:58, [EMAIL PROTECTED] wrote: am i correct in thinking that psyco will just not accelerate, rather than break code it cannot deal with? that has been a pretty standard import on all my programs Don't optimize what doesn't deserve optimization... That's a pretty standard mantra. Gabriel Genellina Softlab SRL __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
Re: efficient memoize decorator?
At Saturday 19/8/2006 07:56, [EMAIL PROTECTED] wrote: does not seem to work for standalone functions, this is a method decorator only then? Traceback (most recent call last): File "prob14memoize.py", line 94, in ? length = col(i,1) File "prob14memoize.py", line 49, in __call__ object = self.cache[args] = self.fn(self.instance, *args) AttributeError: 'Memoize' object has no attribute 'instance' For a standalone function, you should remove __del__ and self.instance, but I haven't tried it... Gabriel Genellina Softlab SRL __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
Re: Small Troll on notation of variables over time
At Saturday 19/8/2006 07:49, Hendrik van Rooyen wrote: Now how about introducing an index that works over time, such that s{0} (the default so as to not break any existing code) implies the current object bound to the name s, with s{1} being the previous one, and so on... Doing that *always* for *all* names would be ridiculous - objects would never get garbage collected, by example. And 99.% of programs don't need that behavior at all. So just implement that for your use case - if you have any! Gabriel Genellina Softlab SRL __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
Re: Search or compai problem
At Saturday 19/8/2006 23:43, [EMAIL PROTECTED] wrote: > >it is really lstusers (it is an L not a # 1), Some of the output from > >print lstUsers has the output of None. I and trying to filter the None > >out of the list. I come from a perl background and this is how I do > >thing in perl > > None is a unique object used as "nothing" or "no value". > Try reading the Python tutorial, it's easy and you will learn a lot of things. Thanks, I did not know that. Then I should look for a null value? Yes; I don't know where your items come from, but usually None is used to represent an empty/null value. It's not the same as "". Gabriel Genellina Softlab SRL __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
Re: Need advice on how to improve this function
At Monday 21/8/2006 12:03, Larry Bates wrote: > I wrote a function that converts a tuple of tuples into html. For > example: > I'd like to know ways to make it better (more efficient, able to deal > with enormous-size arguments, etc). How would I write this as a > generator? Before you put too much work into this you might want to take a look at HTMLgen: http://www.python.net/crew/friedrich/HTMLgen/html/main.html Another very good library is <http://dustman.net/andy/python/HyperText> (Don't be afraid of the date - it's just that HTML standards haven't changed very much lately :) ) Gabriel Genellina Softlab SRL __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
Re: how do you get the name of a dictionary?
At Tuesday 22/8/2006 13:34, jojoba wrote: i don't want to do anything sophisticated with this, i am really only looking for a TITLE for my dictionary when i throw it in a tree editor that i have built. And i do realize that its not possible now. I am just pressing a point here. Sorry to ruffle everyone's feathers, but this is a fairly curious problem. It's no problem at all: do you need a TITLE for your dictionary? Add a "title" attribute and you're done. Do you want a class? Inherit from dict and add your title attribute there. That's pretty standard OO, and there is no need to modify the Python language... Gabriel Genellina Softlab SRL p4.vert.ukl.yahoo.com uncompressed Tue Aug 22 17:27:05 GMT 2006 __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
Re: Job Jar
At Tuesday 22/8/2006 15:47, D wrote: Thanks, Fredrik - but could I adapt them so that, instead of using them for bug tracking (don't need version control, etc.), they're just used for keeping track of simple tasks? Roundup <http://roundup.sourceforge.net/> is generic enough to be used for almost anything... It has nothing to do with version control. Gabriel Genellina Softlab SRL p5.vert.ukl.yahoo.com uncompressed Tue Aug 22 18:27:05 GMT 2006 __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list