Re: print()

2009-10-18 Thread Gabriel Genellina
(BTW, why 03.02f? The output will always have at least 4 chars, so 03 doesn't mean anything... Maybe you want {0:06.2f} (three places before the decimal point, two after it, filled with 0's on the left)?) -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: slicing return iter?

2009-10-18 Thread Gabriel Genellina
'] py> list(myslice(lst, -5, None, None)) # as in lst[-5:] ['v', 'w', 'x', 'y', 'z'] py>py> list(myslice(lst, None, None, -1)) # as in lst[::-1] ['z', 'y', 'x', 'w', 'v', 'u', 't', 's', ..., 'a'] Slice objects are not-so-well known, and are documented here: http://docs.python.org/reference/datamodel.html#types -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Spawning Cmd Window via Subprocess

2009-10-18 Thread Gabriel Genellina
ess only supports a few fields). You can find the structure definition in the Microsoft documentation: http://msdn.microsoft.com/en-us/library/ms686285(VS.85).aspx -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: SimpleXMLRPCServer clobbering sys.stderr? (2.5.2)

2009-10-17 Thread Gabriel Genellina
te it for me? XMLRPCServer doesn't reassign or alter sys.stderr, just uses it in the log_message method. I'd look in some other place... -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: zipfile extracting png files corrupt

2009-10-16 Thread Gabriel Genellina
ept a tendency to shrten vrble nmes :) ) -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: print()

2009-10-16 Thread Gabriel Genellina
quot;) hello Presumably he's using Python 3: Python 3.1.1 (r311:74483, Aug 17 2009, 17:02:12) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. p3> import sys p3> sys.stdout.write("hello") hello5 See http://bugs.python.org/issue6345 -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: struct curiosity

2009-10-16 Thread Gabriel Genellina
#x27;llh0l' specifies two pad bytes at the end, assuming longs are aligned on 4-byte boundaries. This only works when native size and alignment are in effect; standard size and alignment does not enforce any alignment.""" py> calcsize("BB") 11 py> calcsize("BB0h") 12 -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: struct curiosity

2009-10-16 Thread Gabriel Genellina
#x27;llh0l' specifies two pad bytes at the end, assuming longs are aligned on 4-byte boundaries. This only works when native size and alignment are in effect; standard size and alignment does not enforce any alignment.""" py> calcsize("BB") 11 py> calcsize("BB0h") 12 -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Load a list subset with pickle?

2009-10-15 Thread Gabriel Genellina
En Thu, 15 Oct 2009 16:28:11 -0300, Peng Yu escribió: On Thu, Oct 15, 2009 at 12:01 PM, Gabriel Genellina wrote: En Thu, 15 Oct 2009 13:05:18 -0300, Peng Yu escribió: How do I determine if I have loaded all the elements? I use the following code. I'm wondering if there is any b

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

2009-10-15 Thread Gabriel Genellina
QOTW: "It is however, much like the framework in question, best kept private and not made public." - Ed Singleton, on a "perfectly healthful and acceptable" practice ... left unnamed here http://groups.google.com/group/comp.lang.python/msg/987b1a7a4b9 01f3f Looking for a sane way of

Re: set using alternative hash function?

2009-10-15 Thread Gabriel Genellina
En Thu, 15 Oct 2009 13:24:18 -0300, Rami Chowdhury escribió: On Thu, 15 Oct 2009 09:11:00 -0700, Austin Bingham wrote: On Thu, Oct 15, 2009 at 5:15 PM, Gabriel Genellina wrote: En Thu, 15 Oct 2009 11:42:20 -0300, Austin Bingham escribió: I think you didn't understand corr

Re: Load a list subset with pickle?

2009-10-15 Thread Gabriel Genellina
ist.output/serialize_list.pkl', 'wb') for e in alist: pickle.dump(e, output) output.close() input=open('serialize_list.output/serialize_list.pkl', 'rb') try: while 1: e = pickle.load(input) print e except EOFError: pass Pickle the list length before

Re: Load a list subset with pickle?

2009-10-15 Thread Gabriel Genellina
ist.output/serialize_list.pkl', 'wb') for e in alist: pickle.dump(e, output) output.close() input=open('serialize_list.output/serialize_list.pkl', 'rb') try: while 1: e = pickle.load(input) print e except EOFError: pass Pickle the list length before

Re: set using alternative hash function?

2009-10-15 Thread Gabriel Genellina
unny_key_extractor(o), o) for o in objs) If you feel so inclined, you could implement the MutableSet ABC based on this and have a full featured set implementation. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: HTMLgen???

2009-10-15 Thread Gabriel Genellina
ne instead of generating HTML by code). Used to be at http://dustman.net/andy/python/HyperText but no more :( There is a trimmed down version here: http://www.astro.umass.edu/~dpopowich/python/mpservlets/ (see _HTML.py inside the tutorial) -- Gabriel Genellina -- http://mail.python.o

Re: unicode-to-ascii: replace with space, not "?"

2009-10-14 Thread Gabriel Genellina
c", replace_spc_error_handler) print u"¡añá membuí!".encode("ascii", "replace_spc") print "¡añá membuí!".decode("ascii", "replace_spc") -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Python XMLRPC question

2009-10-14 Thread Gabriel Genellina
ing server to shut down" server.shutdown() if sys.argv[1]=="server": server() elif sys.argv[1]=="client": client() === end xmlrpcshutdown.py === C:\TEMP>start python xmlrpcshutdown.py server C:\TEMP>python xmlrpcshutdown.py client Connecting to XML-RPC server on

Re: Python and USB

2009-10-14 Thread Gabriel Genellina
your app), that depends on the OS and desktop you're using. On Windows I think there's a library named pyhook or similar. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: MUD Game Programmming - Python Modules in C++

2009-10-14 Thread Gabriel Genellina
En Wed, 14 Oct 2009 05:19:06 -0300, Ulrich Eckhardt escribió: Gabriel Genellina wrote: #ifdef _DEBUG #undef _DEBUG #include #define _DEBUG #else #include #endif [...to keep Python from linking against non-existant debug libraries.] No, don't do that. Just compile your applicati

Re: python along or bash combined with python (for manipulating files)

2009-10-13 Thread Gabriel Genellina
anced): http://www.dabeaz.com/generators/ -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: XML-RPC(using SimpleXMLRPCServer) slow on the first call

2009-10-13 Thread Gabriel Genellina
twork: DNS resolution, IPv6 (Windows XP has some timeout issues with IPv6 enabled). -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: threading module, call thread.interrupt_main()

2009-10-13 Thread Gabriel Genellina
En Thu, 08 Oct 2009 14:18:48 -0300, Gabriel Genellina escribió: En Thu, 08 Oct 2009 00:33:04 -0300, §äŽmŠÛ€vªº...@€ù€Ñ escribió: I try to call thread.interrupt_main() function in my child thread's run method which is inherit threading.Thread class. But it didn&#

Re: MUD Game Programmming - Python Modules in C++

2009-10-13 Thread Gabriel Genellina
. It's been suggested that I replace the first part of my C++ code with the following, and then try to compile in release mode: #ifdef _DEBUG #undef _DEBUG #include #define _DEBUG #else #include #endif No, don't do that. Just compile your application in release mode. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: MUD Game Programmming - Python Modules in C++

2009-10-13 Thread Gabriel Genellina
. It's been suggested that I replace the first part of my C++ code with the following, and then try to compile in release mode: #ifdef _DEBUG #undef _DEBUG #include #define _DEBUG #else #include #endif No, don't do that. Just compile your application in release mode. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: organizing your scripts, with plenty of re-use

2009-10-13 Thread Gabriel Genellina
rg/dev/peps/pep-0370/ -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: problem with running os.path.walk()

2009-10-13 Thread Gabriel Genellina
I have problem with it then let me know and if is possible please fix it up . Because all files in your c:\windows\system directory are older than one month? os.walk is simpler to use; stats.st_mtime is less "magical" than stats[8]; and I'd use os.path.join(dirname, filename) inst

Re: Python XMLRPC question

2009-10-13 Thread Gabriel Genellina
ctor. I think it's easier to pass logRequests=False when creating the server. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: organizing your scripts, with plenty of re-use

2009-10-13 Thread Gabriel Genellina
En Tue, 13 Oct 2009 13:28:05 -0300, Buck escribió: On Oct 12, 3:34 pm, "Gabriel Genellina" wrote: Quoting Steven D'Aprano   (changing names slightly): """You would benefit greatly from separating the interface from the backend. You should arrange matters so tha

Re: speed up linecache.getline()

2009-10-13 Thread Gabriel Genellina
your help!! If all the lines in the file have exactly the same length, you may seek to the specific line and read it at once. Otherwise I'm afraid you have to read all the previous n-1 lines to get to line n, and that's what makes it slow. -- Gabriel Genellina -- http://mail.

Re: setting variables in the local namespace

2009-10-13 Thread Gabriel Genellina
ess, or attribute-like access: class namespace:pass ns = namespace() ns.order = . setattr(ns, variablename, ..) ns.area = ns.height * ns.width --- ns = {} ns['order'] = ... ns[variablename] = ... ns['area'] = ns['height'] * ns['width'] Or, s

Re: [OT] organizing your scripts, with plenty of re-use

2009-10-13 Thread Gabriel Genellina
ubdirectory would make the disk tree completely flat as seen by the application. I think this functionality was removed by the time Windows 95 came out because it was very dangerous. It was extremely easy to open (or even remove!) the wrong file. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: deepcopy of class inherited from Thread

2009-10-12 Thread Gabriel Genellina
to pass additional info for each run. Creating OS threads is somewhat expensive so usually is more efficient to create them once and keep feeding them with work to be done. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: pickle's backward compatibility

2009-10-12 Thread Gabriel Genellina
t if I serialize (using pickle) an object of a class defined in python library, will it be successfully read in later version of python? As JPC said: no guarantees. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: pickle's backward compatibility

2009-10-12 Thread Gabriel Genellina
t if I serialize (using pickle) an object of a class defined in python library, will it be successfully read in later version of python? As JPC said: no guarantees. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: organizing your scripts, with plenty of re-use

2009-10-12 Thread Gabriel Genellina
ues with boilerplate are several. [...] As pointed out before, all this boilerplate code is actually unnecesary. Just import the module you want from its package, and you're done (usually). -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: getting equal behavior for scripts and modules ?

2009-10-12 Thread Gabriel Genellina
En Sun, 11 Oct 2009 18:07:30 -0300, Stef Mientki escribió: Gabriel Genellina wrote: En Sun, 11 Oct 2009 14:50:31 -0300, Stef Mientki escribió: Now I finally (after 2 years) knowing there's a difference between modules and scripts, I want to guarantee that I always get the

Re: getting equal behavior for scripts and modules ?

2009-10-12 Thread Gabriel Genellina
En Sun, 11 Oct 2009 18:07:30 -0300, Stef Mientki escribió: Gabriel Genellina wrote: En Sun, 11 Oct 2009 14:50:31 -0300, Stef Mientki escribió: Now I finally (after 2 years) knowing there's a difference between modules and scripts, I want to guarantee that I always get the

Re: organizing your scripts, with plenty of re-use

2009-10-12 Thread Gabriel Genellina
En Mon, 12 Oct 2009 15:24:34 -0300, Buck escribió: On Oct 10, 9:44 am, "Gabriel Genellina" wrote: The good thing is that, if the backend package is properly installed   somewhere in the Python path ... it still works with no modifications. I'd like to get to zero-installat

Re: organizing your scripts, with plenty of re-use

2009-10-12 Thread Gabriel Genellina
En Mon, 12 Oct 2009 15:24:34 -0300, Buck escribió: On Oct 10, 9:44 am, "Gabriel Genellina" wrote: The good thing is that, if the backend package is properly installed   somewhere in the Python path ... it still works with no modifications. I'd like to get to zero-installat

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

2009-10-12 Thread Gabriel Genellina
== d2.xyz == 456 assert hasattr(d2, 'xyz') d2['abc'] = 789 assert d2.abc == d2['abc'] == 789 d2.abc = 123 assert d2.abc == d2['abc'] == 123 del d2.abc assert not hasattr(d2, 'abc') assert 'abc' not in d2 del d2['xyz'] assert not hasattr(d2, 'xyz') assert 'xyz' not in d2 d4 = loads(dumps(d2)) assert d2 == d4 assert isinstance(d4, type(d2)) (plus all the expected behavior from dict itself: clear, get, update...) -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: The rap against "while True:" loops

2009-10-11 Thread Gabriel Genellina
plest loop case, with the test at the start. A loop with the test at the end, on the other hand, is slightly harder to prove correct (but not much). As an example, Ada has a general loop construct like this: loop ... exit when some_condition; ... end loop; and LOTS of work has been done in proving correctness of Ada programs, so having the test at the start/middle/end of the loop is not an obstacle for formal verification. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: The rap against "while True:" loops

2009-10-11 Thread Gabriel Genellina
licated tests and/or duplicated code and/or artificial boolean variables added. Some algorithms are *naturally* expressed as a loop with the condition in the middle. Forcing the condition to always happen at the start requires artificial steps that complicate unnecesarily the code. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: getting equal behavior for scripts and modules ?

2009-10-11 Thread Gabriel Genellina
hat. You can avoid the temptation by naming your scripts with another extension (or no extension at all). I found 2 solutions to realize the above. [...] Too much hassle and magic for what should be a non-issue. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: The rap against "while True:" loops

2009-10-11 Thread Gabriel Genellina
hile condition:" loop, the condition is right at the while statement. In a "while True:" loop, you have to look for the condition elsewhere (likely, an "if" statement preceding a "break"). -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: organizing your scripts, with plenty of re-use

2009-10-10 Thread Gabriel Genellina
/usr/bin/python from backend import animals animals.main() That's all. No need to set PYTHONPATH, nor alter sys.path, nor install the whole tree in a specific place. The good thing is that, if the backend package is properly installed somewhere in the Python path, and the anima

Re: organizing your scripts, with plenty of re-use

2009-10-10 Thread Gabriel Genellina
/usr/bin/python from backend import animals animals.main() That's all. No need to set PYTHONPATH, nor alter sys.path, nor install the whole tree in a specific place. The good thing is that, if the backend package is properly installed somewhere in the Python path, and the anima

Re: easy install

2009-10-09 Thread Gabriel Genellina
the compileall module). Code objects (stored in the .pyc files) carry their source file name with them. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Plotting multiple datasets with gnuplot

2009-10-09 Thread Gabriel Genellina
instead: data = [] ... # Populate data ... plots = [] for dataSet in data: plots.append(dataSet) g.plot(plots) g.plot(*plots) should work; it's like calling g.plot(plots[0], plots[1], plots[2]...) See http://docs.python.org/reference/expressions.html#calls for the gory details. --

Re: datetime.datetime. or datetime. ?

2009-10-08 Thread Gabriel Genellina
hen changed import and cut the first datetime occurance which looks good but breaks next sync with other. Just make sure to replace *all* occurrences of "datetime.datetime" to "datetime", etc. Should be easy to do. I don't know what you mean "breaks next sync with other". -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: threading module, call thread.interrupt_main()

2009-10-08 Thread Gabriel Genellina
://bugs.python.org but I can't locate the issue right now. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: threading module, call thread.interrupt_main()

2009-10-08 Thread Gabriel Genellina
://bugs.python.org but I can't locate the issue right now. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem Displaying Pics

2009-10-08 Thread Gabriel Genellina
?) After fixing the database, you can omit the unnecesary base64 encoding; anyway I'd add a Content-Length header to avoid that spurious \n at the end. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Question about RADIXCHAR on Win32

2009-10-07 Thread Gabriel Genellina
ndows too: py> import locale py> locale.localeconv()['decimal_point'] '.' py> locale.setlocale(locale.LC_ALL, '') 'Spanish_Argentina.1252' py> locale.localeconv()['decimal_point'] ',' -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem Displaying Pics

2009-10-07 Thread Gabriel Genellina
En Wed, 07 Oct 2009 12:00:13 -0300, Victor Subervi escribió: > print '''Content-Type: image/jpeg > > ''' > print > print content On Wed, Oct 7, 2009 at 9:51 AM, Gabriel Genellina wrote: > That's still wrong. The output should be: > &g

Re: Problem Displaying Pics

2009-10-07 Thread Gabriel Genellina
ntent-Type: image/jpeg - a blank line (no more!) - the actual image data A Content-Type of text/html is just *wrong* for an image... -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Re: unittest.TestCase and functools.partial don't seem to mix

2009-10-07 Thread Gabriel Genellina
En Tue, 06 Oct 2009 18:01:34 -0300, Joel Smith escribió: Gabriel Genellina wrote: Note that you don't *have* to use partial in this case, as you're building the suite yourself. Just create the TestCase instances manually: suite = unittest.TestSuite([ TestGenericWind

Re: Problem with subprocess module on Windows with open file in append mode

2009-10-06 Thread Gabriel Genellina
En Tue, 06 Oct 2009 11:24:23 -0300, MRAB escribió: Gabriel Genellina wrote: En Sat, 03 Oct 2009 21:53:12 -0300, Andrew Savige escribió: When I run this little test program on Linux: import subprocess subprocess.call(["python","-V"], stderr=open("log.tmp&qu

Re: unittest.TestCase and functools.partial don't seem to mix

2009-10-06 Thread Gabriel Genellina
=100, color=color) def test_brown(self): return self._testit('brown') # provide desired parameters def test_blue(self): return self._testit('blue') unittest.main() should still work with this TestCase as written, without a custom Suite/Loader. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: organizing your scripts, with plenty of re-use

2009-10-06 Thread Gabriel Genellina
0 [1]). So there is no need to set the PYTHONPATH variable, nor alter the standard site-packages directory, nor play tricks with sys.path - just install the modules/packages inside the user site directory (or any other directory named in a .pth file found there). [1] http://www.python.org/

Re: unicode issue

2009-10-06 Thread Gabriel Genellina
uot;" for key, value in _MAP.iteritems(): name = name.replace(key, value) return name import unicodedata def downcode(name): return unicodedata.normalize("NFD", name)\ .encode("ascii", "ignore")\ .decode("asci

Re: Problem with subprocess module on Windows with open file in append mode

2009-10-05 Thread Gabriel Genellina
beginning or the end of the file.""" The Linux implementation choose to move the file pointer to the end in such cases, the Windows one choose to always keep it at the start. Both are correct according to the specification above. Python 2.X just inherits that behavior from C. I

Re: Module inspect Bug

2009-10-05 Thread Gabriel Genellina
milar construct but always returns True/False, I've submitted a bug+patch: http://bugs.python.org/issue7069 -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: SQLite or files?

2009-10-05 Thread Gabriel Genellina
at powers that be are going to deprecate it. If you want the convenience of shelve without the limitations of dbm, you can do: """Implementation of Python shelves using SQLite.""" See also http://bugs.python.org/issue3783 "dbm.sqlite proof of concept" -- Gab

Re: How to refer to class name and function name in a python program?

2009-10-05 Thread Gabriel Genellina
s/pep-0318/ [2] http://www.artima.com/weblogs/viewpost.jsp?thread=240808 [3] http://pypi.python.org/pypi/decorator -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: ARP code

2009-10-05 Thread Gabriel Genellina
, it's usually better to directly ask the author. class dissect: def __init__(self,pkt,offset): [...] You posted only a class definition - how do you *use* it? -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: ARP code

2009-10-05 Thread Gabriel Genellina
, it's usually better to directly ask the author. class dissect: def __init__(self,pkt,offset): [...] You posted only a class definition - how do you *use* it? -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: a questions about thread-safety of boolean variables

2009-10-05 Thread Gabriel Genellina
only get the old one or the new one, but not something weird instead (because a different thread changed the value while this thread was trying to read it). See http://effbot.org/zone/thread-synchronization.htm -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Conversion of npyscreen module to python 3 -- help!

2009-10-05 Thread Gabriel Genellina
ectories, try to keep the minimum code that still reproduces the problem. You may solve it yourself in the process. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: conflict between various library to process EXIF data

2009-10-05 Thread Gabriel Genellina
no longer possible to read the EXIF header with EXIF.py. Furthermore imghdr does not even recognize it as a JPEG anymore. [...] maybe pyexiv2 is doing something "wrong" that might cause other problems later on. It seems so - don't be so shy and report the problem to the author

Re: mktime, how to handle dates before 01-01-1970 ?

2009-10-05 Thread Gabriel Genellina
ibrary) or would it be better to handle all dates in the Delphi format (number of days since 1-1-1900 py> birthdate.toordinal() 698912 (number of days since 1 AD, approximately) -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Python-URL! - weekly Python news and links (Sep 26)

2009-09-26 Thread Gabriel Genellina
QOTW: "Forget ethical. We can do his homework for him, we can perhaps pass exams for him, maybe graduate for him, and then with our luck, he'll get a job in our office and we get to do his work for him." - Mel http://groups.google.com/group/comp.lang.python/msg/8f7c1fa393c23476

Re: raise errors

2009-09-26 Thread Gabriel Genellina
File "test638580.py", line 5, in foo2 undefinedname() and that means that foo2 tried to call undefinedname. NameError: global name 'undefinedname' is not defined And that's the actual error. Do you want it to be more nicely formatted? Do you want to includ

Re: super() and multiple inheritance failure

2009-09-25 Thread Gabriel Genellina
all, it's a dispatcher; you may use a dictionary to map each alternative to the function to be invoked. If it only depends on the type of the argument, there is a hidden gem in pkgutil (simplegeneric) that can help you. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Format string with single quotes in it

2009-09-25 Thread Gabriel Genellina
e 1, in ValueError: unsupported format character ' ' (0xa) at index 5 So, look in your file for lines ending in % -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Finding application data after install - a solution?

2009-09-25 Thread Gabriel Genellina
.conf', ['foo.conf.sample']), If --install-data is used, one has to edit the /etc/foo.conf file by hand. I understand you want this step to be automatic, and I admit it would be great, but none of my users complained until now (not that there are so many...!) -- Gabriel Genellina -- http://mai

Re: setting up dynamic descriptors in Python

2009-09-25 Thread Gabriel Genellina
e desired descriptor) and set it as the instance __class__ attribute. (This was discussed some time ago, try searching the list archives. Uh, I found this: http://groups.google.com/group/comp.lang.python/t/bfc093464dd6ba9/ but you should be able to find other threads) -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Read header and data from a binary file [LONG]

2009-09-25 Thread Gabriel Genellina
k SDA_), would it possible with struct?, any help ? The chunk module (http://docs.python.org/library/chunk.html) is designed to work with such file format. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Finding application data after install - a solution?

2009-09-24 Thread Gabriel Genellina
lucky (or perhaps my users are "geek" enough to know how to edit a config file, or dumb enough to never change the system settings...) -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Finding application data after install - a solution?

2009-09-24 Thread Gabriel Genellina
: http://www.python.org/community/sigs/current/distutils-sig/ -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: on package import, have it conditionally import a subpackage

2009-09-21 Thread Gabriel Genellina
ort module1, module2 elif type_ == 'type2': from .type2 import module1, module2 else: raise ValueError, 'unknown type: %s' % type_ A more generic version: def setType(type_): global module1, module2 t = __import__(type_, globals(), locals(), ['module1','module2'], 1) module1 = t.module1 module2 = t.module2 -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Non-deprecated equivalent of rfc822.AddressList

2009-09-21 Thread Gabriel Genellina
nt to rfc822.AddressList in the email module, which I want to use to parse a _list_ of addresses: [...] Is there some non-deprecated method I can use to parse an RFC 2822 address list? No takers? Should I file a bug? Seems so... -- Gabriel Genellina -- http://mail.python.org/mailman/lis

Re: Finding application data after install - a solution?

2009-09-21 Thread Gabriel Genellina
atch your code so it works with their file system hierarchy. * it does not work inside eggs * it is ugly ;-) Isn't pkgutil.get_data() what you're looking for? I'm not sure it covers all your use cases though. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: How to change string or number passed as argument?

2009-09-21 Thread Gabriel Genellina
u're still returning ONE object - a tuple. But since packing and unpacking of values is done automatically, you may consider it as returning multiple values at the same time). -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: An assessment of the Unicode standard

2009-09-21 Thread Gabriel Genellina
c names could be expressed. [1] Colerus, Egmont. Historia de la Matemática. De Pitágoras a Hilbert. Bs. As, Ediciones Progreso y Cultura, 1943 [2] BTW, the very name 'algebra' comes from a book of Abu Ja'far Muhammad ibn Musa Al-Khwarizmi, "al-jabr w'al-muqabala". An

Re: Creating a local variable scope.

2009-09-18 Thread Gabriel Genellina
nded to be used very locally, delete those after use. Why bother? Unless they're big objects and you want to ensure they get deleted as soon as possible. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: detmining name during an assignment

2009-09-18 Thread Gabriel Genellina
which the script is run. One may use the Scene class above as the globlal scope when executing the script: scene = Scene() code = "cube1 = Cube(); print cube1.name" exec code in Scene (well, not exactly, Scene should inherit from dict and override __setitem__ instead, but you get th

Re: class initialization problem

2009-09-17 Thread Gabriel Genellina
g day of coding. This is addicting. Does anybody know of a good Coders Anonymous group, i think i may have an addiction. 16 hours of strait coding with 4hrs sleep last night and only stopping for one meal (lunch) still have not ate dinner yet! Gheez! ;) Remember, there is a whole world out the

Re: SQLite or files?

2009-09-17 Thread Gabriel Genellina
round. So, I wouldn't worry about that. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Python-URL! - weekly Python news and links (Sep 17)

2009-09-17 Thread Gabriel Genellina
QOTW: "Python the language doesn't try to satisfy all tastes in language design equally." - Guido van Rossum Is it really necesary to explicitely close open files? http://groups.google.com/group/comp.lang.python/t/d794d426a5bef2c1/ Tips for using Unicode text (specia

Re: Python C/API Problem

2009-09-17 Thread Gabriel Genellina
if i type 'python prova.pyc'? No; the filename you pass in is just to set the co_filename attribute of code objects, and such things. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Compiler.ast helper function "literal_eval" in python 2.4

2009-09-17 Thread Gabriel Genellina
expr) raise ValueError('malformed string') return _convert(node_or_string) py> print literal_eval("(1, [-2.,'3',4j], {-5:None, u'6':True})") (1, [-2.0, '3', 4j], {-5: None, u'6': True}) -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: How to check something is in a list with rich-comparison objects?

2009-09-15 Thread Gabriel Genellina
En Wed, 16 Sep 2009 03:36:32 -0300, Jason escribió: On Sep 16, 2:39 am, "Gabriel Genellina" wrote: Looks like a bug in pysvn. Some class (whatever pysvn.wc_notify_action.status_completed is) is not well written. When compared against something unknown, it should return NotI

Re: VTK install

2009-09-15 Thread Gabriel Genellina
ons. Your VTK path starts with a space, and that confuses the path manipulations. I solved the problem by editing PYTHONPATH in the registry. Definitely a trap for Windows users. If you set the VTK path to an absolute path, this should not happen. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: KeyBoard interrupt and Redirection operator

2009-09-15 Thread Gabriel Genellina
ate program mesage to the console without writing it to the file. You're redirecting stdout, but stderr still goes to the console. print >>sys.stderr, "This message appears on the console" -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Why use "locals()"

2009-09-15 Thread Gabriel Genellina
([object]) -> dictionary Without arguments, equivalent to locals(). With an argument, equivalent to object.__dict__. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: How to check something is in a list with rich-comparison objects?

2009-09-15 Thread Gabriel Genellina
t): ... foo = 1 ... # ... def __eq__(self, other): ... if not isinstance(other, GoodBoy): ... return NotImplemented ... return self.foo==other.foo ... py> "hello" in [GoodBoy(), "hello"] True -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Remove empty strings from list

2009-09-14 Thread Gabriel Genellina
list=filter(None, list) which is the fastest variant AFAIK. (Of course, it's even better to use the right split() call so there is no empty strings to filter out in the first place) -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: myparentclass.__subclasses__() not working for me

2009-09-14 Thread Gabriel Genellina
Any ideas? Don't run the first module as a program itself. When it's run as a program, it's known as '__main__'; when someone executes 'import plugin' *another* copy is imported under the name 'plugin'. So your plugin classes inherit from plugin.Plugin but you're printing __main__.Plugin subclasses. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: numpy NaN, not surviving pickle/unpickle?

2009-09-14 Thread Gabriel Genellina
e read some time ago, that simply caching 0.0 reduced appreciably the memory usage of a Zope application. (Note that Zope relies on pickling and unpickling objects all the time, so even if two objects started as the "same" zero, they may become different at a later time.)

Re: Distributing Python environment

2009-09-14 Thread Gabriel Genellina
earch path (sys.path); whatever is found first, wins. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

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