Re: Multiline lamba implementation in python.

2007-06-12 Thread Gabriel Genellina
th* statements inside. bin = lambda x:((x&8 and '*' or '_') + (x&4 and '*' or '_') + (x&2 and '*' or '_') + (x&1 and '*' or '_')) -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Focus to be removed

2007-06-13 Thread Gabriel Genellina
nything to do with Python. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: In C extension .pyd, sizeof INT64 = 4?

2007-06-13 Thread Gabriel Genellina
and apparently > incorrectly. How did you define it? It is defined in basetsd.h, included by winnt.h; the OP should not redefine it, and that also explains why I could compile my test program without any problem. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Build EXE on Mac OsX 10.4

2007-06-13 Thread Gabriel Genellina
true. gcc on linux can generate a Windows EXE, and using: python setup.py bdist_wininst, you can generate a complete binary installer for Windows. I'm not sure if this can be done on a Mac too. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: one-time initialization of class members

2007-06-13 Thread Gabriel Genellina
ng dataset: Params for AnotherChildClass py> c3 = ChildClass1() py> print Base.dataset None py> print ChildClass1.dataset ['Params for ChildClass1'] py> print AnotherChildClass.dataset ['Params for AnotherChildClass'] py> print c1.dataset ['Params for ChildClass1'] py> print c3.dataset ['Params for ChildClass1'] py> print c1.dataset is c3.dataset True py> -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Method much slower than function?

2007-06-13 Thread Gabriel Genellina
nge would be to use a local variable s, and assign self.s = s only at the end. This should make both methods almost identical in performance. In addition, += is rather inefficient for strings; the usual idiom is using ''.join(items) And since you have Python 2.5, you can use the

Re: How can I capture all exceptions especially when os.system() fail? Thanks

2007-06-13 Thread Gabriel Genellina
127 This is a list of more-or-less standard exit codes: http://www.faqs.org/docs/abs/HTML/exitcodes.html -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: save class

2007-06-13 Thread Gabriel Genellina
ink that it would be a standard thing to do. This would try to save the *class* definition, which is usually not required because they reside on your source files. If this is actually what you really want to do, try to explain us exactly why do you think so. Chances are that there is another solution for this. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: save class

2007-06-13 Thread Gabriel Genellina
En Wed, 13 Jun 2007 23:11:22 -0300, nik <[EMAIL PROTECTED]> escribió: > On Jun 13, 6:48 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> > wrote: >> En Wed, 13 Jun 2007 22:20:16 -0300, nik <[EMAIL PROTECTED]> escribió: >> >> > I would like

Re: Method much slower than function?

2007-06-13 Thread Gabriel Genellina
En Thu, 14 Jun 2007 01:39:29 -0300, [EMAIL PROTECTED] <[EMAIL PROTECTED]> escribió: > Gabriel Genellina wrote: >> In addition, += is rather inefficient for strings; the usual idiom is >> using ''.join(items) > > Ehh. Python 2.5 (and probably some earli

Re: How to save python codes in files?

2007-06-13 Thread Gabriel Genellina
, numbers, comments, etc. Other programs combine an editor + debugger + code autocompletion + other nice features (they're called IDEs, in general). I hope this is of some help. You should read the OS documentation for more info on how to edit a file and such things. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Is there any way to catch expections when call python method in C++

2007-06-14 Thread Gabriel Genellina
> will > also PyObject_GetAttrString and PyEval_CallObject do. For an example on how to do this, see "Extending and Embedding the Python Interpreter" <http://docs.python.org/ext/intro.html> specially section 1.2 -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Method much slower than function?

2007-06-14 Thread Gabriel Genellina
En Thu, 14 Jun 2007 05:54:25 -0300, Francesco Guerrieri <[EMAIL PROTECTED]> escribió: > On 6/14/07, Peter Otten <[EMAIL PROTECTED]> wrote: >> Gabriel Genellina wrote: >> > ... >> > py> print timeit.Timer("f2()", "from __main__ im

Re: Moving items from list to list

2007-06-14 Thread Gabriel Genellina
;a=range(100);b=range(1000)" "b.append(a[-1 ]);a=a[:-1]" 10 loops, best of 3: 107 msec per loop c:\temp>call python -m timeit -s "a=range(100);b=range(1000)" "b.append(a[0] );a=a[1:]" 10 loops, best of 3: 110 msec per loop -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: save class

2007-06-14 Thread Gabriel Genellina
En Thu, 14 Jun 2007 16:05:14 -0300, nik <[EMAIL PROTECTED]> escribió: > On Jun 13, 10:04 pm, Josiah Carlson <[EMAIL PROTECTED]> > wrote: >> Gabriel Genellina wrote: >> > En Wed, 13 Jun 2007 23:11:22 -0300, nik <[EMAIL PROTECTED]> escribió: >> >

Re: Failing on string exceptions in 2.4

2007-06-14 Thread Gabriel Genellina
d I've gotten a weird compiler error about the constructor > for SomeClass. I'd prefer it just to fail there and not let > me raise an exception that isn't subclassed beneath > Exception. The compiler won't complain here - you will have to inspect the code (or use a tool like pylint or pychecker). The easy fix is just inherit from Exception. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Problems with regular expressions

2007-06-14 Thread Gabriel Genellina
uot;) <_sre.SRE_Match object at 0x00ACB1E0> py> re.search('^(taskid|bugid):\\d+',"asdfa fa taskid:1234") py> re.search('^(taskid|bugid):\\d+'," taskid:1234") py> re.search('^(taskid|bugid):\\d+',"taskid:123adfa asfa lkjljlj&quo

Re: poking around a running program

2007-06-14 Thread Gabriel Genellina
n, modifying the code between runs > based on what happens in a given run. That may be hard to do. For global functions, reload() may help, but if you have many created instances, modifying and reloading the module that contains the class definition won't automatically alter the existing instances. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: inverting a dictionary of lists

2007-06-14 Thread Gabriel Genellina
py> result {1: ['a'], 2: ['a', 'b'], 3: ['c', 'b']} py> You may use collections.defaultdict too - search some recent posts. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Re printing on same line.

2007-06-15 Thread Gabriel Genellina
e any other print statement ruining the output? -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Inserting breakpoints ...

2007-06-16 Thread Gabriel Genellina
ll to a debug routine, > called JSM(linenr), which performs task like wait, update user feedback, > etc. > This works, but doesn't give a nice output > > for xxx in xrange ( 16 * hardware_column ): > JSM(78) > Write_LCD_2Bytes ( write_text , 0 )

Re: Is there a way to hook into module destruction?

2007-06-16 Thread Gabriel Genellina
En Sat, 16 Jun 2007 17:16:10 -0300, Neal Becker <[EMAIL PROTECTED]> escribió: > Code at global scope in a module is run at module construction (init). > Is > it possible to hook into module destruction (unloading)? No exactly, but you could try the atexit module. -- Ga

Re: Windows XMLRPC Service

2007-06-18 Thread Gabriel Genellina
socket timeout to a reasonable value (you'll have to wait that time before exiting). Also, a ThreadingTCPServer may be better if you expect more than a request at a time. If you search past messages you may find other ways. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: PyRun_String with Py_single_input to stdout?

2007-06-18 Thread Gabriel Genellina
ing because it uses printf to stdout, not cout. > > Anyone know how I can get the string so I can print it in a text box. From your description this should be working... try posting some more code showing how you call PyRun_String and how you process the result... -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: fetching text from the screen

2007-06-18 Thread Gabriel Genellina
efull with it. On Windows, I'd try first using WindowFromPoint to get a window handle, and the sending it a WM_GETTEXT message. This should work for all windowed controls that contain text of some kind. I'd use your generic approach when this doesn't work. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: avoid script running twice

2007-06-18 Thread Gabriel Genellina
27;) > >>> f.close() > >>> g.close() > >>> open('lock.txt').read() > 'ho' The same happens on Windows. A file *can* be opened with exclusive access, but this is not exposed thru the open() function in Python; one should use the CreateFile Win32 API function with adequate flags. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: getting the size of an object

2007-06-18 Thread Gabriel Genellina
. The total memory for the three objects is a few bytes more than 1MB. For arbitrary objects, a rough estimate may be its pickle size: len(dumps(x)) == 108 len(dumps(y)) == 108 len(dumps(z)) == 116 -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: HTMLParser.HTMLParseError: EOF in middle of construct

2007-06-18 Thread Gabriel Genellina
at line 1173, > column 1 > > at line 1173 of test file is perfectly normal . That page is not valid HTML - http://validator.w3.org/ finds 726 errors in it. HTMLParser expects valid HTML - try a different tool, like BeautifulSoup, which is specially designed to handle malformed pages.

Re: sizeof() in python

2007-06-18 Thread Gabriel Genellina
UDP. Thank you in advance guys. So you don't need the size of arbitrary data, only the size of your packets. Assuming you use strings (perhaps built using struct.pack) just use len(a_string). -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

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

2007-06-19 Thread Gabriel Genellina
QOTW: "Regarding a Java programmer moving to Python, a lot of the mindset change is about the abundant use of built in data types of Python. So a Java programmer, when confronted with a problem, should think 'how can I solve this using lists, dicts and tuples?' (and perhaps also my new favourite,

Re: Windows XMLRPC Service

2007-06-19 Thread Gabriel Genellina
modify the socket instance. Just add this method to your AsyncServer: def server_activate(self): SimpleXMLRPCServer.server_activate(self) self.socket.settimeout(15) # for 15 secs -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

Re: Windows XMLRPC Service

2007-06-19 Thread Gabriel Genellina
do you see it is 2? >> py> import win32event >> py> win32event.WAIT_TIMEOUT >> 258 > > I meant here that *if* I set the WAIT_TIMEOUT to 2, then I see that > behavior. Ah, ok! I should have stated clearly that WAIT_TIMEOUT is a Windows predefined constant, no

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

2007-06-19 Thread Gabriel Genellina
ke IMAP, if the server supports it. You could delete messages after successful retrieval, using the DELE command. Only after a successful QUIT command will the server actually delete them. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list

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

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