Re: list to table

2009-11-05 Thread Gabriel Genellina
gh? It goes to some detail describing, e.g., what a.x = 1 means. The next section explains what a.x += 1 means in terms of the former case. I did find discussion (end of §6.2 of the language reference) of the case where the target is an attibute reference, with this example: class A: x = 3# class variable a = A() a.x += 1 # writes a.x as 4 leaving A.x as 3 Do you want to discuss this example? -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: distutils.core.setup --install-script option in Python 2.6 ?

2009-11-05 Thread Gabriel Genellina
. Do you mean this option? http://docs.python.org/distutils/builtdist.html#the-postinstallation-script Probably the distutils SIG is a better place to ask: http://www.python.org/community/sigs/current/distutils-sig/ -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Looking for portable what to determine directory where extensions are installed?

2009-11-05 Thread Gabriel Genellina
., lib or lib64) to resolve this issue: https://www.cca-forum.org/bugs/babel/issue670 The distutils SIG is probably a better place to ask: http://www.python.org/community/sigs/current/distutils-sig/ -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Tkinter callback arguments

2009-11-04 Thread Gabriel Genellina
En Wed, 04 Nov 2009 04:50:42 -0300, Alf P. Steinbach escribió: * Gabriel Genellina: I don't understand either. R1 and R2 have *different* semantics. Assume that they have the very exact same semantics -- like two TV sets that look the same and work the same except when you ope

Re: Tkinter callback arguments

2009-11-03 Thread Gabriel Genellina
nted as a simple attribute, a computed property, or an esoteric class attribute following the descriptor protocol. If all a property does is to store and retrieve its value as an instance attribute, yes, it just adds overhead. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: import from a string

2009-11-03 Thread Gabriel Genellina
En Wed, 04 Nov 2009 02:45:23 -0300, iu2 escribió: On Nov 4, 3:10 am, "Gabriel Genellina" wrote: txt = """ def foo(x): print 'x=', x def bar(x): return x + x """ py> namespace = {} py> exec txt in namespace py> namespa

Re: how to create nested classes dynamically

2009-11-03 Thread Gabriel Genellina
... class CC(object): class AA(object): def __init__(self, ...): self.bb = BB() self.cc = CC() Then, you can write: aa = AA() print aa.bb.bb1 aa.bb.bb2 = '10' print aa.bb.bb2 [1] http://dirtsimple.org/2004/12/python-is-not-java.html -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: unittest & setup

2009-11-03 Thread Gabriel Genellina
with createFoo(parameters). For new-style classes, you may override the __new__ method instead. Perhaps I didn't understand your problem correctly because this is unrelated to unit testing... -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: continuous return?

2009-11-03 Thread Gabriel Genellina
stand your scenario, but since you say you have several threads, a common way to communicate between them is to use a Queue object. Let the receiver thread put() lines into the queue, and the processing thread get() them and do some work. -- Gabriel Genellina -- http://mail.python.org/mailma

Re: elementtree XML() unicode

2009-11-03 Thread Gabriel Genellina
tp://bugs.python.org/ applies to documentation too. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Cast into custom type

2009-11-03 Thread Gabriel Genellina
quot;""My second plugin. I don't know what is this for, but it works.""" --- end one.py --- Plugin is the base class; all plugins must inherit from it. PluginMgr scans the plugin directory, executes all modules it finds there (be careful...), and looks for Plug

Re: elementtree XML() unicode

2009-11-03 Thread Gabriel Genellina
.XML with the bytes before decoding, or reencode the received xml text in UTF-8 (since this is the declared encoding). -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: import bug

2009-11-03 Thread Gabriel Genellina
the module is searched along sys.path). The only way to import a local file "re.py" is using "from .re import something"; the leading dot means it's a relative import ("relative" means that the module is searched in a single directory: the current package d

Re: import from a string

2009-11-03 Thread Gabriel Genellina
bal variables (none in this example). The global names that the code creates become entries in the dictionary. (foo and bar; __builtins__ is an implementation detail of CPython). You may supply separate globals and locals dictionaries. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Help resolve a syntax error on 'as' keyword (python 2.5)

2009-11-03 Thread Gabriel Genellina
27;s new?" document for Python 3.0 - but right now, they will just confuse you. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Python-URL! - weekly Python news and links (Nov 3)

2009-11-03 Thread Gabriel Genellina
QOTW: "I consider "import *" the first error to be fixed ..." - Robert Kern, author of PyFlakes, a potential replacement for Pylint and Pychecker, on his personal style http://groups.google.com/group/comp.lang.python/msg/5bf77b21b3b0caf2 Python 2.6.4 is out; it fixes some small b

Re: Cast into custom type

2009-11-03 Thread Gabriel Genellina
nstance as first argument (got PluginMount instance instead) Python uses "late binding", even more than Java. A reference like obj.foo(...) searches for "foo" along obj's attributes at runtime. Please post some code showing your issue, and don't forget to tell us what is y

Re: About one class/function per module

2009-11-02 Thread Gabriel Genellina
rt, although bzr seems to be the most robust, specially in non trivial cases. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: __eq__() inconvenience when subclassing set

2009-11-02 Thread Gabriel Genellina
En Mon, 02 Nov 2009 22:05:42 -0300, Jess Austin escribió: On Nov 1, 1:13 am, "Gabriel Genellina" wrote: Looks like in 3.1 this can be done with bytes+str and viceversa, even if bytes and str don't have a common ancestor (other than object; basestring doesn't exi

Re: read Zipfile

2009-11-02 Thread Gabriel Genellina
zipfile.html#zipfile.ZipFile.open Hope my contents do make sense. Yes, it was clear to me. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: stdin in embedded python

2009-11-01 Thread Gabriel Genellina
En Sun, 01 Nov 2009 23:13:10 -0300, Dave Angel escribió: Gabriel Genellina wrote: En Sun, 01 Nov 2009 13:34:44 -0300, KillSwitch escribió: On Nov 1, 5:34 am, Dave Angel wrote: KillSwitch wrote: > I have a C++ program, with a GUI, into which I have embedded python. I > hav

Re: About one class/function per module

2009-11-01 Thread Gabriel Genellina
ollow PEP8 conventions, module names are all in lowercase, and class names use TitleCase. This helps avoid confusion. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: import bug

2009-11-01 Thread Gabriel Genellina
En Sun, 01 Nov 2009 19:51:04 -0300, Steven D'Aprano escribió: On Sun, 01 Nov 2009 17:34:19 -0300, Gabriel Genellina wrote: En Sun, 01 Nov 2009 02:54:15 -0300, Steven D'Aprano escribió: Shadowing a standard library module is no different. But that's what namespaces

Re: import bug

2009-11-01 Thread Gabriel Genellina
En Sun, 01 Nov 2009 19:01:42 -0300, MRAB escribió: Gabriel Genellina wrote: One way to avoid name clashes would be to put the entire standard library under a package; a program that wants the standard re module would write "import std.re" instead of "import re", or some

Re: stdin in embedded python

2009-11-01 Thread Gabriel Genellina
builtin__ py> __builtin__.raw_input = my_raw_input py> py> raw_input("What's your name?") 'Gabriel' -- Gabriel Genellina<>-- http://mail.python.org/mailman/listinfo/python-list

Re: import bug

2009-11-01 Thread Gabriel Genellina
En Sun, 01 Nov 2009 02:54:15 -0300, Steven D'Aprano escribió: On Sun, 01 Nov 2009 01:38:16 -0300, Gabriel Genellina wrote: Incorrect. Simplicity of implementation and API is a virtue, in and of itself. The existing module machinery is quite simple to understand, use and maintain.

Re: __eq__() inconvenience when subclassing set

2009-11-01 Thread Gabriel Genellina
En Fri, 30 Oct 2009 17:55:27 -0300, Jess Austin escribió: On Oct 29, 10:41 pm, "Gabriel Genellina" wrote: We know the last test fails because the == logic fails to recognize mySet (on the right side) as a "more specialized" object than frozenset (on the left si

Re: import bug

2009-10-31 Thread Gabriel Genellina
lse: script_path = '' if script_path in sys.path: sys.path.remove(script_path) sys.path.append(script_path) (I'd want to put such code in sitecustomize.py, but sys.argv doesnt't exist yet at the time sitecustomize.py is executed) -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Problems in merge.py when building the Python MSI installer

2009-10-31 Thread Gabriel Genellina
se errors are important or not. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: How can module determine its own path?

2009-10-30 Thread Gabriel Genellina
execfile, __file__ doesn't exists. Remember that execfile just executes the file contents, it does not create a new module nor interacts with the module management. "modules launched with execfile" has no meaning. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: How to avoid certain directories when using os.walk?

2009-10-30 Thread Gabriel Genellina
e problem I had with my deletion script a while back. I'd say the problem is ill-defined in that case. You have to decide what to do with those non-empty directories that are non-empty because you explicitely skipped some subdirectories... -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Unicode again ... default codec ...

2009-10-30 Thread Gabriel Genellina
En Fri, 30 Oct 2009 13:40:14 -0300, zooko escribió: On Oct 20, 9:50 pm, "Gabriel Genellina" wrote: DON'T do that. Really. Changing the default encoding is a horrible, horrible hack and causes a lot of problems. I'm not convinced. I've read all of the posts and w

Re: Python 2.6 Global Variables

2009-10-29 Thread Gabriel Genellina
re once you realize the name '__main__' isn't special. Replace __main__ with foo, or config, or whatever, and you get the same results. Ok, there is a catch: a file with that name must exist, at least an empty one... You're just importing the same module from two pla

Re: __eq__() inconvenience when subclassing set

2009-10-29 Thread Gabriel Genellina
require modifying tp_richcompare of set/frozenset objects, so it is aware of subclasses on the right side. Currently, frozenset() == mySet() effectively ignores the fact that mySet is a subclass of set. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: ftpilb.FTP.stor...() freeze mystery

2009-10-29 Thread Gabriel Genellina
En Thu, 29 Oct 2009 13:18:30 -0300, Anthra Norell escribió: Gabriel Genellina wrote: En Wed, 28 Oct 2009 08:05:22 -0300, Anthra Norell escribió: Gabriel Genellina wrote: En Tue, 27 Oct 2009 07:53:36 -0300, Anthra Norell escribió: I am trying to upload a bunch of web pages to a hosting

Re: Bug(s) in Python 3.1.1 Windows installation

2009-10-28 Thread Gabriel Genellina
es. tkinter is a package, not a module. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Feedback wanted on programming introduction (Python in Windows)

2009-10-28 Thread Gabriel Genellina
nto python" book). The biggest thing not included in the python.org distribution is the pywin32 package and related stuff (like the PythonWin editor). Maybe in the past the gap between both distributions were larger, but now, the official Python build is perfecty suitable for Windows users

Re: Bug(s) in Python 3.1.1 Windows installation

2009-10-28 Thread Gabriel Genellina
;s not the 3.1.1 installer that forgot to clean up, but files from a previous 2.x installation. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Bug(s) in Python 3.1.1 Windows installation

2009-10-28 Thread Gabriel Genellina
people wanting to install this). The best place to report bugs is http://bugs.python.org/ -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: ftpilb.FTP.stor...() freeze mystery

2009-10-28 Thread Gabriel Genellina
En Wed, 28 Oct 2009 08:05:22 -0300, Anthra Norell escribió: Gabriel Genellina wrote: En Tue, 27 Oct 2009 07:53:36 -0300, Anthra Norell escribió: I am trying to upload a bunch of web pages to a hosting service.[...] I wrote a loop that iterates through the file names and calls either of

Re: a simple unicode question

2009-10-28 Thread Gabriel Genellina
and Character Sets (No Excuses!)", by Joel Spolsky. http://www.joelonsoftware.com/articles/Unicode.html -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: calling server side function

2009-10-28 Thread Gabriel Genellina
alizing in xml instead of pickling. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: how to get os.system () call to cooperate on Windows

2009-10-27 Thread Gabriel Genellina
En Tue, 27 Oct 2009 23:04:47 -0300, Steven D'Aprano escribió: On Tue, 27 Oct 2009 21:48:36 -0300, Gabriel Genellina wrote: En Tue, 27 Oct 2009 10:55:09 -0300, TerryP escribió: On Oct 26, 10:00 am, Anthra Norell wrote: How can one copy files on the OS level? from ctypes import w

Re: Form Parsing resouces

2009-10-27 Thread Gabriel Genellina
}, "Enter Name ", {"tagtype":"input","type":"text","size":"40","name":"firstname"} {"tagtype":"/form"}] FYI: I have looked at ClientForm. It appears that ClientForm enables the reading of a

Re: Problem embedding Python.

2009-10-27 Thread Gabriel Genellina
En Tue, 27 Oct 2009 06:36:18 -0300, Brandon Keown escribió: On Oct 27, 2:47 am, "Gabriel Genellina" wrote: You didn't test for the fopen result; are you sure "test.py" exists in the current directory at the time you run it? Ok, so I assumed that the file, i

Re: how to get os.system () call to cooperate on Windows

2009-10-27 Thread Gabriel Genellina
A CopyFile("d:\\temp\\old.txt", "d:\\temp\\new.txt", True) -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: ftpilb.FTP.stor...() freeze mystery

2009-10-27 Thread Gabriel Genellina
;t infer any problem. Certainly uploading files with ftplib worked fine last time I tried. Try to remove all unnecesary lines from your script, making it as small as possible but still showing your problem, and post it here. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: ftpilb.FTP.stor...() freeze mystery

2009-10-27 Thread Gabriel Genellina
y problem. Certainly uploading files with ftplib worked fine last time I tried. Try to remove all unnecesary lines from your script, making it as small as possible but still showing your problem, and post it here. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Embedded python on systems without python installed

2009-10-27 Thread Gabriel Genellina
ubdirectory (at least os.py; it is used by the initialization code to determine the standard library location). Or nothing. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: how to modify row content of file in python?

2009-10-27 Thread Gabriel Genellina
from STDIN and writes to STDOUT. Some versions of sed provide the -i option to edit files in place (makes backup if extension supplied) You could program a similar behaviour in Python using the re module. There is the fileinput module: http://docs.python.org/library/fileinput.html -- Gabriel Gen

Re: Is there a command that returns the number of substrings in a string?

2009-10-27 Thread Gabriel Genellina
nt of occurences, but their positions too). I've seen a couple implementations for Python; if they're *actually* faster is to be determined... -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem embedding Python.

2009-10-27 Thread Gabriel Genellina
least put a few printf. You didn't test for the fopen result; are you sure "test.py" exists in the current directory at the time you run it? -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: How to know locals of script without running it

2009-10-26 Thread Gabriel Genellina
En Mon, 26 Oct 2009 14:06:22 -0300, Nadav Chernin escribió: Is there a way to know locals of the script without running it? I don't quite understand the question, could you explain it? A concrete example would help. -- Gabriel Genellina -- http://mail.python.org/mailman/lis

Re: why python cache the string > 256?

2009-10-26 Thread Gabriel Genellina
hon 3672 6187126696 5338484252 5596082 55 4252 python 3672 6187126680 5338484228 698891 2 55 4228 Note the 'VM' and 'Priv' columns (virtual address space and private bytes, respectively). -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: python web service or Apache?

2009-10-26 Thread Gabriel Genellina
eb service" is a program that exposes some sort of API that can be accessed thru a web interfase, mostly intended to be used by other programs, not humans. Web services usually are built on top of HTTP as the transport layer, so they run behind Apache or other web server. Python is

Re: quit button

2009-10-26 Thread Gabriel Genellina
it).pack() mainloop() If you run the code from inside IDLE, you'll have to add this line at the end: root.destroy() as explained here: http://www.effbot.org/tkinterbook/tkinter-hello-again.htm -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem with urllib2.urlopen() opening a local file

2009-10-26 Thread Gabriel Genellina
ly meaningful if the server is running Windows, ok? -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Python-URL! - weekly Python news and links (Oct 25)

2009-10-25 Thread Gabriel Genellina
QOTW: "It was intended to be understood, not copied." - Dave Angel comments on a characteristic of didactic examples http://groups.google.com/group/comp.lang.python/msg/61e2d60d08f1c630 Altering the default character encoding (sys.setdefaultencoding) is never a good idea:

Re: Socket logic problem

2009-10-25 Thread Gabriel Genellina
pleXMLRPCServer (plus either ThreadingMixIn or ForkingMixIn) is easy enough. Are sockets actually the best way to do this? If so, how to set it up to do what I want? If not, what other approaches could I try? See the wiki page on distributed systems: http://wiki.python.org/moin/Distribute

Re: multiprocessing deadlock

2009-10-24 Thread Gabriel Genellina
En Sat, 24 Oct 2009 02:48:38 -0300, Brian Quinlan escribió: On 24 Oct 2009, at 14:10, Gabriel Genellina wrote: En Thu, 22 Oct 2009 23:18:32 -0300, Brian Quinlan escribió: I don't like a few things in the code: I'm actually not looking for workarounds. I want to know if

Re: Copying a ZipExtFile

2009-10-23 Thread Gabriel Genellina
:\Python26\lib\shutil.py", line 27, in copyfileobj buf = fsrc.read(length) File "C:\Python26\lib\zipfile.py", line 594, in read bytes = self.fileobj.read(bytesToRead) TypeError: integer argument expected, got 'long' Try adding a length parameter to the c

Re: AttributeError: 'SSLSocket' object has no attribute 'producer_fifo'

2009-10-23 Thread Gabriel Genellina
core.py", line 399, in __getattr__ return getattr(self.socket, attr) AttributeError: 'SSLSocket' object has no attribute 'out_buffer' Someone please throw some light on this! How do you manage asyncore's map? It should contain dispatcher objects -- looks l

Re: PAMIE and beautifulsoup problem

2009-10-23 Thread Gabriel Genellina
exception? Please post the complete exception traceback. from BeautifulSoup import BeautifulSoup Import cPAMIE url = 'http://www.cnn.com' ie = cPAMIE.PAMIE(url) bs = BeautifulSoup(ie.pageText()) Also, don't re-type the code. Copy and paste it, directly from the program that faile

Re: PySerial

2009-10-23 Thread Gabriel Genellina
En Fri, 23 Oct 2009 20:56:21 -0300, Ronn Ross escribió: I have tried setting the baud rate with no success. Also I'm using port #2 because I"m using a usb to serial cable. Note that Serial(2) is known as COM3 in Windows, is it ok? -- Gabriel Genellina -- http://mail.python.o

Re: multiprocessing deadlock

2009-10-23 Thread Gabriel Genellina
I don't know if fixing those things will fix your problem, but at least the code will look neater... -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: python pyodbc - connect error

2009-10-23 Thread Gabriel Genellina
En Thu, 22 Oct 2009 22:33:52 -0300, Threader Slash escribió: Hi again.. I have done the same test using pyodbc, but to MySQL ODBC driver. It works fine for MySQL. The problem still remains to Lotus Notes. Any other hints please? http://www.connectionstrings.com -- Gabriel Genellina

Re: Terminating python script easily

2009-10-22 Thread Gabriel Genellina
st generic 'except' clause should be, normally: try: ... except Exception: ... -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Terminating python script easily

2009-10-22 Thread Gabriel Genellina
ic 'except' clause should be, normally: try: ... except Exception: ... -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Unloading a module

2009-10-22 Thread Gabriel Genellina
es, and one in the m list. Once you remove them (with del, as in your example), the module object itself is destroyed, yes. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: a splitting headache

2009-10-22 Thread Gabriel Genellina
convert to 3.1. I for one, never had a copy of Python 1.3. Those relics from the past has been removed in Python 3.x (in both code and documentation). Also, all notes like 'New in version 1.x' or 'New in version 2.x' have been removed too. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: a simple unicode question

2009-10-22 Thread Gabriel Genellina
En Thu, 22 Oct 2009 17:08:21 -0300, escribió: On 10/22/2009 03:23 AM, Gabriel Genellina wrote: En Wed, 21 Oct 2009 15:14:32 -0300, escribió: On Oct 21, 4:59 am, Bruno Desthuilliers wrote: beSTEfar a écrit : (snip) > When parsing strings, use Regular Expressions. And now you have _t

Re: buggy popup

2009-10-22 Thread Gabriel Genellina
then, click on OKAY button. Is there a python way of automating the above procedure? I'm very happy using pywinauto for those tasks. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Unicode again ... default codec ...

2009-10-22 Thread Gabriel Genellina
En Thu, 22 Oct 2009 05:25:16 -0300, Lele Gaifax escribió: "Gabriel Genellina" writes: En Wed, 21 Oct 2009 06:24:55 -0300, Lele Gaifax escribió: "Gabriel Genellina" writes: nosetest should do nothing special. You should configure the environment so Python *know

Re: a simple unicode question

2009-10-22 Thread Gabriel Genellina
otes, any attribute ordering, empty tags, arbitrary whitespace... If you don't, you are not reading XML (or HTML), only a specific file format that resembles XML but actually isn't. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: subprocess executing shell

2009-10-22 Thread Gabriel Genellina
))) p.wait() Since the shell is executing in the child process anyway, is the only difference when using shell=True is that environment variables can be expanded in the command to be executed? Note that in this case, "the child process" is rsh on the local system. Popen has no contr

Re: unittest wart/bug for assertNotEqual

2009-10-22 Thread Gabriel Genellina
ertMultiLineEqual use != instead of ==, and some assertion messages use the wrong terminology) -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: equivalent to globals(), locals() for nonlocal variables?

2009-10-21 Thread Gabriel Genellina
riables in outer nested scopes? Not that I know of - and as someone pointed out recently, vars() should include those variables instead of simply returning locals(). -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: which "dictionary with attribute-style access"?

2009-10-21 Thread Gabriel Genellina
ue'}) py> d.items() [('name', 'value')] py> d = AttrDict({'items': [1,2,3]}) py> d.items() Traceback (most recent call last): File "", line 1, in TypeError: 'list' object is not callable (I should have included a test case for

Re: mysql select some sort of caching

2009-10-21 Thread Gabriel Genellina
En Wed, 21 Oct 2009 22:24:49 -0300, David Sfiligoi escribió: On Wed, 21 Oct 2009 00:45:21 -0300, Gabriel Genellina wrote: If you want to keep the cursor open, you must commit the (implicit) current transaction, even if it only contains selects (a rollback would work too). Alternatively

Re: Unicode again ... default codec ...

2009-10-21 Thread Gabriel Genellina
En Wed, 21 Oct 2009 06:24:55 -0300, Lele Gaifax escribió: "Gabriel Genellina" writes: DON'T do that. Really. Changing the default encoding is a horrible, horrible hack and causes a lot of problems. ... More reasons: http://tarekziade.wordpress.com/2008/01/08/syssetdefaulte

Re: Unicode again ... default codec ...

2009-10-20 Thread Gabriel Genellina
using *your* default encoding. - what if another library/package/application wants to set a different default encoding? - the default encoding for Python>=3.0 is now 'utf-8' instead of 'ascii' More reasons: http://tarekziade.wordpress.com/2008/01/08/syssetdefaultencoding-is-evil/ See also this recent thread in python-dev: http://comments.gmane.org/gmane.comp.python.devel/106134 -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: InteractiveConsole executed in another thread.

2009-10-20 Thread Gabriel Genellina
op, I presume. I'd use a separate process for the console, sending back and forth input and output to the original process. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: mysql select some sort of caching

2009-10-20 Thread Gabriel Genellina
er the transaction isolation level below "repeatable reads". Note that in other scenarios, ensuring that the same query returns the same results is a Good Thing. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Struct on on x86_64 mac os x

2009-10-20 Thread Gabriel Genellina
bytes ('x') to the struct definition in Python to match those offsets (and probably use '=' for standard sizes). -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Inconsistent raw_input behavior after Ctrl-C

2009-10-20 Thread Gabriel Genellina
raw_input raises EOFError, and KeyboardInterrupt is raised a line or two later. I could not reproduce it with XP so it may be an issue with Windows 7 only. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Why does passing tuple as arg WITHOUT scattering work?

2009-10-20 Thread Gabriel Genellina
27;s correct, would the first version still work in practice regardless of Python / Tkinter implementation? I'd use the "modern" interface, that is, keyword arguments (instead of an explicit dictionary). Although the documentation warns against the "old" way, the fact is that Tkinter has changed very little in years, and the cnf parameter is still there in version 3.1 -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: pyserial ser.write('string') TypeError in OS X

2009-10-20 Thread Gabriel Genellina
uot;abc" unicode text. With Python 3.x, "abc" is unicode (spelled just `str` now) and b"abc" denotes the `bytes` type (the old str). bytearray is a mutable variant of the bytes type. Read the "What's new" document for the 3.0 release: http://ww

Re: SimpleXMLRPCServer clobbering sys.stderr? (2.5.2)

2009-10-20 Thread Gabriel Genellina
you redirect it from the command line (or your main program redirects it by code or does something strange with those handles) -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: File not closed on exception

2009-10-20 Thread Gabriel Genellina
En Tue, 20 Oct 2009 04:47:02 -0300, arve.knud...@gmail.com escribió: On 20 Okt, 09:40, "Gabriel Genellina" wrote: En Tue, 20 Oct 2009 03:23:49 -0300, arve.knud...@gmail.com escribió: > I agree, but like I said, I've been told that this (implicit closing > of files)

Re: File not closed on exception

2009-10-20 Thread Gabriel Genellina
En Tue, 20 Oct 2009 03:23:49 -0300, arve.knud...@gmail.com escribió: On Oct 19, 5:56 pm, "Gabriel Genellina" wrote: En Mon, 19 Oct 2009 09:45:49 -0200, arve.knud...@gmail.com   escribió: > I thought that file objects were supposed to be garbage-collected and > automatic

Re: Is __mul__ sufficient for operator '*'?

2009-10-19 Thread Gabriel Genellina
En Tue, 20 Oct 2009 00:59:12 -0300, Mick Krippendorf escribió: Gabriel Genellina schrieb: __special__ methods are searched in the type, not in the instance directly. x*y looks for type(x).__mul__ (among other things) So I thought too, but: class meta(type): def __mul__(*args

Re: Is __mul__ sufficient for operator '*'?

2009-10-19 Thread Gabriel Genellina
for type(x).__mul__ (among other things) -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: smtplib upload progress

2009-10-19 Thread Gabriel Genellina
s dirty as yours, one has to duplicate the original code. I don't know how often the need arises or how useful would this be to others, but you could submit a patch to http://bugs.python.org/ -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: elementtree examples

2009-10-19 Thread Gabriel Genellina
selftest.py module in the source package for elementtree (available from www.effbot.org) does provide quite a few examples using doctest. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: restriction on sum: intentional bug?

2009-10-19 Thread Gabriel Genellina
avior than throwing an exception. Just for completeness, and in case anyone would like to try this O(n²) process, sum(x) may be rewritten as: x = ["a","b","c",Something()] print reduce(operator.add, x) which does exactly the same thing, with the same quadratic b

Re: File not closed on exception

2009-10-19 Thread Gabriel Genellina
tmp", "w") as f: # do something with the file raise Exception This way the file is closed when leaving the with statement (either normally or because of an exception). And, if the file doesn't exist or access is denied, the open() call doesn't success either. In any case, it never remains open. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: smtplib send mail dns resolve problem

2009-10-19 Thread Gabriel Genellina
tever address gethostbyname returns. If you want load balancing among the 5 addresses above, you'll have to do it yourself: host = random.choice(list_of_addresses) If you don't want to hardcode the addresses, there are a few libraries that perform DNS queries in PyPI. -- Ga

Re: slicing return iter?

2009-10-18 Thread Gabriel Genellina
:1] == ''.join(myslice(s, -5, -2, 1)) True But not always: py> s[10:-1:1]==''.join(myslice(s, 10, -1, 1)) False py> s[-10:25:1]==''.join(myslice(s, -10, 25, 1)) False You have to take the sequence length into account before computing the range, not after. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: How about adding slice notation to iterators/generators?

2009-10-18 Thread Gabriel Genellina
to remember to never reuse my_iter again, as my example above shows. Or keep track of the past items so you can adjust the indices. But anyway you can't retrieve those past items, unless you maintain them all in a list and take the memory penalty. Or just use islice when needed - only s

Re: More & More Fun w/ Pics & MySQL

2009-10-18 Thread Gabriel Genellina
now it doesn't want to work again. What gives? I think you'll benefit from using *any* sort of source versioning (cvs, svn, mercurial...) This way you can go back in time to the moment when things were working fine, and see what changed since then. -- Gabriel Genellina --

<    1   2   3   4   5   6   7   8   9   10   >