Re: caseless dictionary howto ?

2007-06-19 Thread Gabriel Genellina
to get the intended behavior: > ... def __setitem__(self, key, value): > ... self._dict[key.lower()] = value > ... if key.lower() not in self._original_keys: > ... self._original_keys[key.lower()] = key -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Reference current module?

2007-06-19 Thread Gabriel Genellina
simpler and does not assume additional requirements (like __name__ still being the same, or the module still available for importing). -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: How can I know the name of "caller"

2007-06-19 Thread Gabriel Genellina
tack fast enough? > Considering that I'd have to use inspect.stack inside a 'while' > statement looping different times, I wouldn't slow down my application. A faster way is to use sys._getframe(1).f_code.co_name But it doesn't feel good for production code... can't you find a different approach? -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Q: listsort and dictsort - official equivalents?

2007-06-19 Thread Gabriel Genellina
e, the input must be read completely before sorted() can output anything. Suppose the minimum element is at the end - until you read it, you can't output the very first sorted element. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Help With Better Design

2007-06-19 Thread Gabriel Genellina
leave it off light.TurnOn() light.TurnOn()# an attempt to turn it on again assert light.state == ON # some more tests light = LightBulb(ON) assert light.state == ON # should test both initial states light = LightBulb(0) # what should happen here? light.TurnOn() assert light.state == ON # oops! light.TurnOff() assert light.state == OFF # oops! This has many advantages: you can write the tests carefully once and run many times later, and detect breakages; you can't take a "likely" answer for a "true" answer; etc. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: poplib.retr doens't flag message as read

2007-06-20 Thread Gabriel Genellina
En Wed, 20 Jun 2007 06:42:15 -0300, EuGeNe Van den Bulke <[EMAIL PROTECTED]> escribió: > Gabriel Genellina wrote: >> The POP protocol has no concept of "read" or "unread" messages; the LIST >> command simply shows all existing messages. >

Re: caseless dictionary howto ?

2007-06-20 Thread Gabriel Genellina
ing[0] is not. >> > I think you might be right, > but for a one-time/one-programmer program, > I think the documentation will be good enough. The best way would be to mix both things, using a NamedTuple (available on Python 2.6 or from http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/500261) -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: How to hide a program?

2007-06-20 Thread Gabriel Genellina
window. > > I forgot to mention that i have created a Windows executable of the > script. How did you create it? Using py2exe? Use windows=your_program.py instead of console=... in your setup script. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: subprocess.popen question

2007-06-20 Thread Gabriel Genellina
ter split the arguments beforehand: cmd = ["gawk", "-f", "altertime.awk", "-v", "time_offset=4", "-v", "outfile=testdat.sco", "i1.sco"] Now, what do you want to do with the output? Printing it line by line? output = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0] lines = output.splitlines() for line in lines: print line -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: python25_d.lib

2007-06-20 Thread Gabriel Genellina
nd a "debug" build; the debug build generates python25_d.dll (and .lib). You will need to compile the debug build of Python yourself (or use the release build). -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: need help with re module

2007-06-20 Thread Gabriel Genellina
ifulSoup py> chaine = """helloworldok""" py> soup = BeautifulSoup(chaine) py> soup.findAll(text=True) [u'hello', u'world', u'ok'] Get it from <http://www.crummy.com/software/BeautifulSoup/> -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: need help with re module

2007-06-20 Thread Gabriel Genellina
En Wed, 20 Jun 2007 17:24:27 -0300, John Salerno <[EMAIL PROTECTED]> escribió: > Gabriel Genellina wrote: > >> py> from BeautifulSoup import BeautifulSoup >> py> chaine = """helloworldok""" >> py> soup = BeautifulSoup(chaine)

Re: need help with re module

2007-06-20 Thread Gabriel Genellina
En Wed, 20 Jun 2007 17:56:30 -0300, David Wahler <[EMAIL PROTECTED]> escribió: > On 6/20/07, Gabriel Genellina <[EMAIL PROTECTED]> wrote: >> En Wed, 20 Jun 2007 13:58:34 -0300, linuxprog <[EMAIL PROTECTED]> >> escribió: >> >> > i have that stri

Re: subprocess.popen question

2007-06-20 Thread Gabriel Genellina
En Wed, 20 Jun 2007 20:02:52 -0300, [EMAIL PROTECTED] <[EMAIL PROTECTED]> escribió: > On Jun 20, 1:46 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> > wrote: >> >> cmd = ["gawk", "-f", "altertime.awk", "-v", "tim

Re: The Modernization of Emacs

2007-06-20 Thread Gabriel Genellina
The Year Award? -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: subprocess.popen question

2007-06-20 Thread Gabriel Genellina
En Wed, 20 Jun 2007 22:28:06 -0300, [EMAIL PROTECTED] <[EMAIL PROTECTED]> escribió: > On Jun 20, 7:50 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> > wrote: >> En Wed, 20 Jun 2007 20:02:52 -0300, [EMAIL PROTECTED] >> <[EMAIL PROTECTED]> escribi

Re: string formatter %x and a class instance with __int__ or __long__ cannot handle long

2007-06-20 Thread Gabriel Genellina
eturned a long type value in the Example2. The "%08x" allows > either int or long in the Example1, however it accepts int only > in the Example2. Is this a bug or expected? It is a bug, at least for me, and I have half of a patch addressing it. As a workaround, convert explicitely to long before formatting. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Can python access windows clipboard

2007-06-21 Thread Gabriel Genellina
ge py> from win32clipboard import * py> OpenClipboard() py> EmptyClipboard() py> SetClipboardText("Hello from Python!") 11272196 py> CloseClipboard() Ctrl-v: Hello from Python! -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Internationalised email subjects

2007-06-21 Thread Gabriel Genellina
uot;cp850")) 'LATIN SMALL LETTER A WITH ACUTE' The first attempt shows the wrong name, so my console *cannot* be using latin-1. With cp850 I got the right results, so it *might* be cp850 (it may also be another encoding that happens to match this single character). Furth

Re: Split file into several and reformat

2007-06-21 Thread Gabriel Genellina
some_file.readline() - The expression: "x" in line, tests if line contains any "x" - You will find the string methods useful: http://docs.python.org/lib/string-methods.html In particular: find, split, strip, partition look promising in this case. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: unable to execute to a python script

2007-06-21 Thread Gabriel Genellina
ws the right one. Rename or delete your rpm.py > I dont know what path I should set the PYTHONHOME PYTHONPATH .etc.. > variables Usually, nothing. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: import mysteries

2007-06-21 Thread Gabriel Genellina
se (not the full path). The script changes the current directory (os.chdir) after doing other imports and initialization. From now on, importing a module from the original directory doesn't work anymore. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: variable sub in a list- how to

2007-06-21 Thread Gabriel Genellina
ar?) I think you should start by reading some introductory texts, like the Python Tutorial <http://docs.python.org/tut/> or Dive Into Python <http://www.diveintopython.org/>, to learn how things are done in Python. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: How to Encode Parameters into an HTML Parsing Script

2007-06-21 Thread Gabriel Genellina
er':42} py> print urlencode(data) signedin=true&another=42 Do not use the data argument to urlopen. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: why __repr__ affected after __getattr__ overloaded?

2007-06-21 Thread Gabriel Genellina
; except KeyError: print "Now creating:",attr_name > self.__dict__[attr_name] = 'inexistent' > return self.__dict__[attr_name] -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: subprocess.popen question

2007-06-21 Thread Gabriel Genellina
I get all the > options to use with it but the minute I try to use the options with it > I have problems. I have done it with batch files but then I would > have to write out a batch file and then run the batch file. seems > like more work than I should have to do to use options with a command > line program.. I have done this in other cases with os.startfile and > other cases and would like to fix it. Ok, but please check *what* are the arguments to Popen. If cmd is a *list* as shown on the first quoted line on this message, you should call subprocess.Popen(cmd, ...) as shown on the third line on this message, but your traceback shows that you are using Popen([cmd], ...) Can you see the difference? -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: why __repr__ affected after __getattr__ overloaded?

2007-06-22 Thread Gabriel Genellina
27;t create "fake" attributes for things like __bases__ by example, and dir(), vars(), repr() etc. work as expected. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: why __repr__ affected after __getattr__ overloaded?

2007-06-22 Thread Gabriel Genellina
n action; tries to find a __str__ method and fails; tries to find a __repr__ instead and fails; then uses the default representation. See <http://docs.python.org/ref/customization.html#l2h-179> -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Retrieving a stacktrace from an exception object / forwarding an exception

2007-06-22 Thread Gabriel Genellina
the exception with a stacktrace showing > my_func() > --- > > Any idea if and how this can be done? - see the traceback module <http://docs.python.org/lib/module-traceback.html> - use a bare raise (not raise e); this reraises the active exception without changing its context. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: string formatter %x and a class instance with __int__ cannot handle long

2007-06-22 Thread Gabriel Genellina
ong but are not longs themselves; I've modified that function, but PyUnicode_Format has a similar problem, that's "the other half". Maybe this weekend I'll clean those things and submit the patch. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Internationalised email subjects

2007-06-22 Thread Gabriel Genellina
thon2.2/email/Header.py", line 272, in append > ustr = unicode(s, incodec, errors) > LookupError: unknown encoding: gb2312 ) It appears that you don't have the gb2312 codec - maybe it was not available with your rather old Python version (2.2). Upgrading to a newer version may help. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: subprocess.popen question

2007-06-22 Thread Gabriel Genellina
of line charecter in > the output?? Try print repr(your_data) to see exactly what you got. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: EMBEDDING > Run Python & Run C Function

2007-06-22 Thread Gabriel Genellina
ou can use ctypes: http://www.python.org/doc/lib/module-ctypes.html -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Collections of non-arbitrary objects ?

2007-06-22 Thread Gabriel Genellina
, to become a builtin type. Look for some recent posts about a RestrictedList. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: newbie question about unicode

2007-06-22 Thread Gabriel Genellina
but consider this (assuming your terminal uses utf-8): py> u1 = u'' py> s1 = u1.encode('utf-8') py> py> s2 = '' py> u2 = s2.decode('utf-8') py> py> type(u1), type(u2) (, ) py> u1==u2 True py> type(s1), type(s2) (, ) py> s1==s2 True -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: need help with re module

2007-06-22 Thread Gabriel Genellina
! By the way, I'm looking for a different sound. I have an Ibanez but I think the Jackson is far better for thrash metal, the Jackson Kelly Pro series KE3 sounds good, and it's a classic. Maybe as a self-gift for my birthday next month. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Python changing keywords name

2007-06-23 Thread Gabriel Genellina
aise': 'lanzar', 'return': 'retornar', 'try': 'intentar', 'while': 'mientras', 'with': 'con', 'yield': 'producir', } # reverse dict trans_es2en = dict((v,k) for (k,v) in trans_en2es.items()) def translate_tokens(source, tdict): for tok_num, tok_val, _, _, _ in tokenize.generate_tokens(source.readline): if tok_num==token.NAME: tok_val = tdict.get(tok_val, tok_val) yield tok_num, tok_val code_en = tokenize.untokenize(translate_tokens(StringIO(code_es), trans_es2en)) print code_en code_es2= tokenize.untokenize(translate_tokens(StringIO(code_en), trans_en2es)) print code_es2 --- end code --- -- Gabriel Genellina PS: Asking just once is enough. -- http://mail.python.org/mailman/listinfo/python-list

Re: Help needed to solve this "NameError"

2007-06-24 Thread Gabriel Genellina
quot;hi there!" line. All other lines should be at the left margin. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: socket on cygwin python

2007-06-24 Thread Gabriel Genellina
on/release/flavor you want. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

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

2007-06-25 Thread Gabriel Genellina
QOTW: "[R]edundant/useless/misleading/poor code is worse than wrong." - Michele Simionato http://groups.google.com/group/comp.lang.python/msg/74adbb471826a245 "Unit tests are not a magic wand that discover every problem that a program could possibly have." - Paul Rubin http://groups.googl

Re: listing all property variables of a class instance

2007-06-25 Thread Gabriel Genellina
stance(v, property): >>> print k, v.__doc__ >>> >> >> The only way I could get this to work was to change the way the >> properties were defined/initalized: > > That's because you iterate over the instance's `__dict__` and not over &g

Re: New Thread- Supporting Multiline values in ConfigParser

2007-06-25 Thread Gabriel Genellina
header and it's not a new option and there is a current section and option; those two last conditions same as the previous version). But you'll have to experiment - I've not tested it. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Collections of non-arbitrary objects ?

2007-06-25 Thread Gabriel Genellina
t an explicit assignment. After I > assigned a to b, I never did another "b =" yet b changed anyway > because I changed a. I am not saying there is anything wrong with > this, I'm just explaining what I meant. I think you should benefit reading this short article: http://effbo

Re: regular expressions eliminating filenames of type foo.thumbnail.jpg

2007-06-25 Thread Gabriel Genellina
for picture in [ p for p in os.listdir(dir) if >> os.path.isfile(os.path.join( >> dir,p)) and filenameRx.match(p) if 'thumbnail' not in p]: >> file, ext = os.path.splitext(picture) -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Python changing keywords name

2007-06-26 Thread Gabriel Genellina
En Tue, 26 Jun 2007 13:11:50 -0300, Sion Arrowsmith <[EMAIL PROTECTED]> escribió: > Gabriel Genellina <[EMAIL PROTECTED]> wrote: >> (I hope nobody will abuse this technique... Y perd=F3n a los >> hispanoparlantes por lo horrible de la traducci=F3n). > > Ah, I

Re: [Bulk] RE: Python changing the keywords name

2007-06-26 Thread Gabriel Genellina
tok_val = tdict.get(tok_val, tok_val) yield tok_num, tok_val text = """ koristi os # koristi as import ispisi "Bok kaj ima" # ispisi as print """ print tokenize.untokenize(translate_tokens(StringIO(text),trans_hr2en)) --- end code --- And I get this output: import os # koristi as import print "Bok kaj ima"# ispisi as print Hope this helps, -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Converting Diff Output to XML?

2007-06-26 Thread Gabriel Genellina
b module http://docs.python.org/lib/module-difflib.html) and generate the xml file based on the resulting opcodes. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: urllib interpretation of URL with ".."

2007-06-26 Thread Gabriel Genellina
vel. I'd say it's an annoyance, not a bug. Write your own urljoin function with your exact desired behavior - since all "meaningful" .. and . should have been already processed by urljoin, a simple url = url.replace("/../","/").replace("/./","/") may be enough. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Unbound Local error --???

2007-06-26 Thread Gabriel Genellina
.. x = a + 1 ... >>> g() Traceback (most recent call last): File "", line 1, in ? File "", line 2, in g NameError: global name 'a' is not defined This time, "a" is not local, and not found in the global namespace either. The message tells you that it was looking for a global variable, and could not find it. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Re: Padding en

2007-06-26 Thread Gabriel Genellina
rstrip("=") > except: > #For older versions > import os > return base64.encodestring(m.digest())\ >.replace(os.linesep,"").rstrip("=") [Aparte del except, que deberia atrapar sólo AttributeError]. encod

Re: Can Readlines() go to next line after a Tab

2007-06-26 Thread Gabriel Genellina
ery usage of readlines() slows the process. It has to read the entire file into memory. I'd use something like this instead: for line in def_file: tabpos = line.find("\t") if tabpos>0: # >= if an empty keyword is allowed keyword = line[:tabpos] ... -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: guidance needed: best practice for script packaging

2007-06-26 Thread Gabriel Genellina
an > answer, you > are asking the question in an unhelpful way. If my question is still > unclear, I > would appreciate any leads on how to clarify it. I read your previous post, but since I didn't feel that I had a "good" answer I didn't reply the first

Re: p & br using ElementTree?

2007-06-26 Thread Gabriel Genellina
t; p[0].text py> p[0].tail '2000-01-01' See <http://effbot.org/zone/element-infoset.htm> about infosets and the "mixed content" simplified model. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: New Thread- Supporting Multiline values in ConfigParser

2007-06-26 Thread Gabriel Genellina
En Wed, 27 Jun 2007 01:35:27 -0300, O.R.Senthil Kumaran <[EMAIL PROTECTED]> escribió: > * Gabriel Genellina <[EMAIL PROTECTED]> [2007-06-25 22:26:47]: > >> And how would you detect a multiline value? >> Because it is not a section nor looks like a new option? >

Re: How to destroy a Frame with condition

2007-06-26 Thread Gabriel Genellina
me.destroy() This will call the destroy() method of iframe, only when iframe is not the None object itself. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: String formatting for complex writing systems

2007-06-27 Thread Gabriel Genellina
; is usually wider than an "i" or "l" letter. You could use a reporting library or program (like ReportLab, generating PDF files), but perhaps the simplest approach is to generate an HTML page containing a table, and display and print it using your favorite browser. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: XML from SQL result

2007-06-27 Thread Gabriel Genellina
it's not a problem when returned data is "flat", not > hierarchical. However, that's not the case. Uhm - ElementTree is designed precisely for a hierarchical structure (a "tree" :) ) -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: equality & comparison by default (was Re: Too many 'self' in python.That's a big flaw in this language.)

2007-06-28 Thread Gabriel Genellina
dictionary keys without much coding. This must always be true: (a==b) => (hash(a)==hash(b)), and the documentation for __hash__ and __cmp__ warns about the requisites (but __eq__ and the other rich-comparison methods are lacking the warning). -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: win32event.WaitForInputIdle() returns too soon

2007-06-28 Thread Gabriel Genellina
s immediately, with no wait." A typical Python script is a console application. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Threads Dying?

2007-06-28 Thread Gabriel Genellina
or some condition (an Event object, a special object placed on a Queue, even a global variable in the simplest case) and exit when the condition is met. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Unbound Local error --???

2007-07-04 Thread Gabriel Genellina
e names like the same thing. That is, all names are just that... names - pointing to objects. -- Gabriel Genellina Softlab SRL __ Todo sobre la Copa América. Mantenete actualizado con las últimas noticias sobre esta competencia en Yaho

Re: connecting to serial port + python

2007-07-04 Thread Gabriel Genellina
onn1.write(str(cmd)) Don't you have to send after each command? "\n" >th = connect_serial(conn1) >list1.append(th) >th.start() You can't have four threads all reading the same serial port. The device sends its responses sequentially anyway. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: PyRun_String using my module in a def

2007-07-05 Thread Gabriel Genellina
ict) (in C code). > I tried PyObject *rstring = PyRun_String( cmd, Py_file_input, > dlfl_dict, dlfl_dict ); > This worked, but has the side effect of not allowing other commands > like "execfile" The idea is to copy all items from dlfl_dict into main_dict, and use main_di

Re: Problem with building extension in Python

2007-07-05 Thread Gabriel Genellina
y you got a previous error, making link to fail. Try to correct *that* error. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: (EMBEDDING) Can't get python error message

2007-07-05 Thread Gabriel Genellina
can't. From http://docs.python.org/api/veryhigh.html: "If there was an error, there is no way to get the exception information." Use another function instead, like PyRun_StringFlags() -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Htmllib help

2007-07-05 Thread Gabriel Genellina
r.HTMLParser, so I'd ask why do you use a writer in the first place?) -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: having problems in changing directories doing ftp in python

2007-07-09 Thread Gabriel Genellina
change the directory to ted > 3.try to go back by changing the directory to "var/www/html" in which > I get an error saying it does not exist. If your server file system is case sensitive (likely if it's a linux/unix server), VAR/WWW/HTML is not the same thing as var

Re: Htmllib help

2007-07-09 Thread Gabriel Genellina
y. Look at the HTMLParser module too; depending on your needs, it may be easier to use. > -- Original message ------ > From: "Gabriel Genellina" <[EMAIL PROTECTED]> >> En Thu, 05 Jul 2007 20:23:08 -0300, <[EMAIL PROTECTED]> escribió:

Re: Is there a way to program a robot with python (ex, an electric motor, control it's speed, etc)

2007-07-09 Thread Gabriel Genellina
cordingly. Picasso: a Python-controlled robot for doing paintings http://youtube.com/watch?v=PsbKq5Kysj0 -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Portable general timestamp format, not 2038-limited

2007-07-09 Thread Gabriel Genellina
d by common horse carts at the time. (Some people goes beyond that and say it was the same width as used in the Roman empire but this may be just a practical coincidence, no causality being involved). -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: The file executing

2007-07-09 Thread Gabriel Genellina
program because __file__ may contain a relative path (and will give a wrong result after changing the current directory). -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Broken MUA interactions (was: Restarting a Python Application)

2007-07-09 Thread Gabriel Genellina
list support, thats fine. But > it's hardly incorrect to configure it with the reply-to set to the > list, either. No, it's not correct to modify Reply-To. Some reasons: http://www.unicom.com/pw/reply-to-harmful.html -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: TypeError: can't multiply sequence to non-int

2007-07-09 Thread Gabriel Genellina
quot;abc" * 5 (gives "abcabcabcabcabc") [1,2,3] * 8 (gives a list with 24 numbers) (4,"z") * 2 (gives (4,"z",4,"z")) -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: execute script in certain directory

2007-07-09 Thread Gabriel Genellina
.abspath(__file__)) # when opening the file f = open(os.path.join(dat_path, "filename.dat")) -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: execute script in certain directory

2007-07-09 Thread Gabriel Genellina
you mean. The short answer is: don't place standalone scripts inside a package; see this thread: http://groups.google.com/group/comp.lang.python/browse_thread/thread/c44c769a72ca69fa/ -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Error when trying to write unicode xml to zipfile

2007-07-09 Thread Gabriel Genellina
estr('content.xml', content.toxml().encode('utf-8')) In general, when working with unicode, it's best to decode bytes into unicode as early as possible (when reading input), process only unicode inside the program, and encode into bytes at the last step (when writing

Re: Portable general timestamp format, not 2038-limited

2007-07-10 Thread Gabriel Genellina
ard but not as wide as the original GWR. Now most of the passenger lines are defunct and cargo lines trend to use narrow gauge = 1000mm so the proportion may be much smaller now. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: path backslash escaping trouble

2007-07-10 Thread Gabriel Genellina
ctly 3 characters, the second being a single backslash. The \ is the escape character; to include an actual \ inside a string, you have to double it. Another way is to use raw string literals (supressing escape processing): r"a\\b" contains four characters. See section 3.1.2 in the P

Re: Transfer folders to ftp

2007-07-10 Thread Gabriel Genellina
ogram, but i want to make this in python. Good luck! -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Parsing Help

2007-07-10 Thread Gabriel Genellina
if value[:2]=="0x": return int(value, 16) else: return int(value) Using lxml <http://codespeak.net/lxml/> you could use XPath notation to simplify the navigation a little. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: serializing datetime object

2007-07-10 Thread Gabriel Genellina
En Tue, 10 Jul 2007 13:13:54 -0300, [EMAIL PROTECTED] <[EMAIL PROTECTED]> escribió: > I want to serialize datetime.datetime.now() object . I could convert it > to > string but how do I get a datetime object back from the string? > Any suggestions? Use the pickle mo

Re: SafeConfigParser can set unsafe values

2007-07-10 Thread Gabriel Genellina
really. If all % were escaped automatically, there is no way to write a templatized value. Maybe SafeConfigParser.set should grow an escape argument, controlling whether one wants the value escaped or not. For compatibility reasons should default to False, for usability reasons should default to True. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: storing pickles in sql data base

2007-07-10 Thread Gabriel Genellina
olumns might be converted or reencoded in some way, binary data should never be modified in any way. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: 2**2**2**2**2 wrong? Bug?

2007-07-11 Thread Gabriel Genellina
to the problem "Which is the largest number that can be written with only 3 digits?" Some people stop at 999, others try 99**9 and 9**99, and the winner is 9**9**9, or: | 9 | 9 | 9 Sorry, couldn't resist. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: binascii.unhexlify ... not clear about usage, and output

2007-07-11 Thread Gabriel Genellina
En Wed, 11 Jul 2007 17:34:04 -0300, [EMAIL PROTECTED] <[EMAIL PROTECTED]> escribió: > If only there was a built-in base 2 conversion. No builtin, but you can find uncountable versions if you search this group, or the Python cookbook, or the entire web... -- Gabriel Genellina

Re: atexit, sys.exit, sys.exitfunc, reaching end of source code

2007-07-12 Thread Gabriel Genellina
mExit: py> help(sys) Help on built-in module sys: [...] excepthook -- called to handle any uncaught exception other than SystemExit Unfortunately help(sys.excepthook) does not provide the same information, neither the docs for the sys module. (Should be corrected...) -- Gabr

Re: 2**2**2**2**2 wrong? Bug?

2007-07-12 Thread Gabriel Genellina
En Thu, 12 Jul 2007 07:30:05 -0300, Nick Craig-Wood <[EMAIL PROTECTED]> escribió: > Gabriel Genellina <[EMAIL PROTECTED]> wrote: >> En Wed, 11 Jul 2007 16:39:17 -0300, Paul McGuire <[EMAIL PROTECTED]> >> escribió: >> >> > As was >> > po

Re: storing pickles in sql data base

2007-07-12 Thread Gabriel Genellina
s. You have to write and read the "text" >> files in binary mode or they break if taken across platform boundaries >> because of the different line endings in Linux and Windows for instance. >> > > It's fine as long as you use universal line endings mode.

Re: 2**2**2**2**2 wrong? Bug?

2007-07-12 Thread Gabriel Genellina
En Thu, 12 Jul 2007 09:30:34 -0300, Ben Finney <[EMAIL PROTECTED]> escribió: > "Gabriel Genellina" <[EMAIL PROTECTED]> writes: > >> "Which is the largest number that can be written with only 3 >> digits?" Some people stop at 999, others

Re: MaildirMessage

2007-07-12 Thread Gabriel Genellina
to use the sequence protocol, starting at 0; that is, tries to get msg[0]. Message objects support the mapping protocol, and msg[0] tries to find a *header* 0, converting the name 0 to lowercase, and fails miserably. Try with: for msg in mbox: print msg or read the MaildirMessage (and Message) docs to see the ways you can handle it. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: diferent answers with isalpha()

2007-07-12 Thread Gabriel Genellina
ot;LATIN SMALL LETTER A WITH ACUTE"; if not, Python thinks your terminal uses a different encoding than the actual one. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: inspite of proper package structure, no module named xyz error.

2007-07-12 Thread Gabriel Genellina
27;m not convinced this is absolutely the right way to do things, but at least it's less bug prone. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Understanding python functions - Instant Python tutorial

2007-07-12 Thread Gabriel Genellina
ts contents and properties. Modifying an object is not the same as rebinding its name: x = [1,2,3] y = x x[1] = 4 print x # [1, 4, 3] print y # [1, 4, 3] x = [1,2,3] y = x x = [1,4,3] print x # [1, 4, 3] print y # [1, 2, 3] You can test is two names refer to the same object using the is operator: x is y. You will get True in the first case and False in the second case. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Circular import problem

2007-07-12 Thread Gabriel Genellina
have to assume that the error is being generated by some other > modules loading in the grooves.py stuff ... but really have no idea. > > Is there anything I can do to trace though this and get it working > properly? See http://effbot.org/zone/import-confusion.htm Try to move the circular references later in the code (maybe inside a function, when it is required), or much better, refactor it so there is no circularity. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Getting values out of a CSV

2007-07-12 Thread Gabriel Genellina
ist(csv.reader(open('some.csv', 'rb'))) -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Understanding python functions - Instant Python tutorial

2007-07-13 Thread Gabriel Genellina
ntinue learning Python. I think you will like it in the near future. But for someone coming from the microcontroller world, used to think closely in terms of the implementation, this may be a big paradigm shift. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: MaildirMessage

2007-07-13 Thread Gabriel Genellina
message should mean iterating over its headers... Anyway, if you want to iterate over all the message headers, the simplest way is using msg.keys() -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: permission denied in shutil.copyfile

2007-07-13 Thread Gabriel Genellina
7; 3) shutil.copyfile copies ONE FILE at a time. 4) use glob.glob to find the desired set of files to be copied; and perhaps you'll find copy2 more convenient. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Getting values out of a CSV

2007-07-13 Thread Gabriel Genellina
40.7 msec per loop (Generating less values shows larger differences - anyway they're not terrific) So, as always, one should measure in each specific case if optimization is worth the pain - and if csv files are involved I'd say the critical points are elsewhere, not on how one creates the list of rows. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Function parameter type safety?

2007-07-13 Thread Gabriel Genellina
Directorio de C:\TEMP 14/07/2007 00:13 4 output.bin 1 archivos 4 bytes 0 dirs 18.806.763.520 bytes libres "strings" are "strings of bytes" in Python. (If you are mostly concerned with characters, use unicode objects). -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

<    3   4   5   6   7   8   9   10   11   12   >