ANN: wf2python alpha
Hi I'm working in a VB.NET/C# Windows Form to wxPython converter. It's alpha software right now and you can download the source code from http://nicolasrodriguez.blogspot.com. I really appreciate any comments, hints, bug report, etc. Best regards Niko -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
(wxPython) wx.ProgressDialog - how to cancel out of?
I'm trying to use wx.ProgressBar, and the cancel button is not responding. Here is a simple program that exhibits the problem: # import wx import time max = 10 app = wx.PySimpleApp() dlg = wx.ProgressDialog(Progress dialog example, variables to be shown here, maximum = max, style = wx.PD_CAN_ABORT | wx.PD_CAN_SKIP #| wx.PD_APP_MODAL | wx.PD_ELAPSED_TIME | wx.PD_ESTIMATED_TIME | wx.PD_REMAINING_TIME ) keepGoing = True skip = False count = 0 while keepGoing and count max: count += 1 wx.MilliSleep(1000) #time.sleep(1) newtext = (before) count: %s, keepGoing: %s, skip: %s % \ (count, keepGoing, skip) print newtext (keepGoing, skip) = dlg.Update(count, newtext) newtext = (after) count: %s, keepGoing: %s, skip: %s % \ (count, keepGoing, skip) print newtext dlg.Destroy() # The dialog looks right when this runs, but What's right: I get a progress bar; it includes Skip and Cancel buttons; it shows 10 seconds of progress, and updates once per second with the variables' values on each iteration. What's wrong is that I can't get clicking on the Skip or Cancel buttons to have any effect. Instead, as soon as the dialog displays, I get an hourglass, and it doesn't matter what I click on. Here's what the print statements display, consistently, regardless of what I try to click or whether I click nothing at all: I:\pythontest1.py (before) count: 1, keepGoing: True, skip: False (after) count: 1, keepGoing: True, skip: False (before) count: 2, keepGoing: True, skip: False (after) count: 2, keepGoing: True, skip: True (before) count: 3, keepGoing: True, skip: True (after) count: 3, keepGoing: True, skip: True (before) count: 4, keepGoing: True, skip: True (after) count: 4, keepGoing: True, skip: True (before) count: 5, keepGoing: True, skip: True (after) count: 5, keepGoing: True, skip: True (before) count: 6, keepGoing: True, skip: True (after) count: 6, keepGoing: True, skip: True (before) count: 7, keepGoing: True, skip: True (after) count: 7, keepGoing: True, skip: True (before) count: 8, keepGoing: True, skip: True (after) count: 8, keepGoing: True, skip: True (before) count: 9, keepGoing: True, skip: True (after) count: 9, keepGoing: True, skip: True (before) count: 10, keepGoing: True, skip: True (after) count: 10, keepGoing: True, skip: True Two oddities here: 1) As I read the docs, the keepGoing variable should be set to True, unless I click on Cancel, in which case it should be set to False (which would end the loop). That doesn't happen. This is really what I'm most concerned here with. 2) The variable skip: set to False on the first iteration, and then set to True on subsequent iterations? Note that this happens even if no buttons are selected. This is just a weirdness to me, and not my main concern, but I thought I'd mention it in case it's relevant. You can see some variations in the commented-out code that I tried; they did not help. Relevant software and releases: OS: Windows XP Home Edition, Version 2002, SP2 Python: ActivePython 2.5.0.0 wxPython: 2.8.1.1 (msw-unicode) Any help appreciated. -- http://mail.python.org/mailman/listinfo/python-list
Re: smtp debugging methods
Sean Nakasone [EMAIL PROTECTED] wrote: I'm having trouble with sending smtp mail. It's hanging after the smtplib.SMTP() line. It doesn't works from home but not from work. What's the best way to debug this? It's quite possible that your network at work has a firewall blocking these ports. Many employers allow outgoing connections only on ports 25, 80, and 443. -- Tim Roberts, [EMAIL PROTECTED] Providenza Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list
Re: regexp search on infinite string?
On Sep 15, 2:57 am, James Stroud [EMAIL PROTECTED] wrote: Paddy wrote: Lets say i have a generator running that generates successive characters of a 'string' From what I know, if I want to do a regexp search for a pattern of characters then I would have to 'freeze' the generator and pass the characters so far to re.search. It is expensive to create successive characters, but caching could be used for past characters. is it possible to wrap the generator in a class, possibly inheriting from string, that would allow the regexp searching of the string but without terminating the generator? In other words duck typing for the usual string object needed by re.search? - Paddy. re.search re.compile checks for str or unicode types explicitly, so you need to turn your data into one of those before using the module. buffer = [] while True: buffer.append(mygerator.next()) m = re.search(pattern, .join(buffer)) if m: process(m) buffer = [] James Thanks James. -- http://mail.python.org/mailman/listinfo/python-list
Re: Extended slicing and Ellipsis - where are they used?
On Sep 15, 12:29 am, James Stroud [EMAIL PROTECTED] wrote: Paddy wrote: And the ellipses ... ? ;) py class Bob(dict): ... def __getitem__(self, k, *args, **kwargs): ... if k is Ellipsis: ... return sorted(self.keys()) ... else: ... return dict.__getitem__(self, k, *args, **kwargs) ... def __setitem__(self, k, *args, **kwargs): ... if k is Ellipsis: ... raise KeyError, Can't make elliptical assignments. ... else: ... return dict.__setitem__(self, k, *args, **kwargs) ... py b = Bob(a=1, b=2, c=3, d=15.5) py b {'a': 1, 'b': 2, 'c': 3, 'd': 15.5} py for k in b[...]: print '%s == %s' % (k, b[k]) ... a == 1 b == 2 c == 3 d == 15.5 py b[...] = 2 Traceback (most recent call last): File ipython console, line 1, in module File ipython console, line 9, in __setitem__ type 'exceptions.KeyError': Can't make elliptical assignments. Thanks again James. -- http://mail.python.org/mailman/listinfo/python-list
Re: An ordered dictionary for the Python library?
Mark Summerfield schrieb: On 14 Sep, 21:23, James Stroud [EMAIL PROTECTED] wrote: Mark Summerfield wrote: I guess I'll have to rename my module (although unfortunately, my book has just gone into production and I have a (simpler) example of what I considered to be an ordered dict, so I will be adding to the terminology confusion). That notwithstanding, given that it is a sorteddict, how is the API? I must think the API good because I have been implementing, in parallel with this discussion, my own OrderedDict with a very similar API (this is part of a larger project where I recently found the need to have a well-implemented ordered dict). The only real omission I see is to allow instantiating a sorted dict with an optional cmp function--to allow the generalization of such features as case-independence, etc. I tend to create different orderings by munging the keys rather than by having optional cmp functions (as you'll see in the sorteddict.py docstring). I've now put sorteddict on PyPI (with docs tests): http://pypi.python.org/pypi/sorteddict The advantage of a passed cmp-function is that the context of usage hasn't to be aware of any change in semantics. Yet for better performance, the cmp-function might be a tad to slow, better use a key-function like for sorted/sort. Additionally, I'd change the parameter names of the keys()-method to start/end and make more clear if end is inclusive or not. The first/secondindex-names are pretty horrible IMHO, because the essentially enumerate parameters. Who wants to work with a method foo(arg1, arg2, arg3) ? :) Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Just bought Python in a Nutshell
Python in a nutshell also comes in a second edition: http://www.oreilly.com/catalog/pythonian2/index.html. Here, many of the new features in Python 2.5 are included. I haven't read through the first the edition, but I can honestly say that reading through the second edition has made me a better programmer, not just a better Python programmer. I only wish I'd read through it earlier, which would have saved me a lot of agony:) -Tor Erik -- http://mail.python.org/mailman/listinfo/python-list
Make money to share your videos
Goodtolove.com is sharing their 50% adsense revenue with you to post videos of anything. Just keep up logging in and start posting now to make money... -- http://mail.python.org/mailman/listinfo/python-list
c interfacing in 2.5
I used python extensive 3-5 years back. Coming back I find some changes. Trying to understand whats new and would appreciate any help/comments/pointers. Earlier there were basically two options: SWIG: convenient but inefficient Native (Extending/Embedding): an efficient way of getting a headache! (Boost being ignored because not using C++) Now it seems there are more possibilities: -- Sip seems to be more efficient than swig and easier than native but not well documented -- pyrex could be considered -- I know someone who uses pygtk to make wrappings But most interesting is ctype. I wonder if having ctype in the core language changes the ease of use of the native wrapping model and thereby makes sip/swig etc less necessary? Your views and/or experience appreciated. -- http://mail.python.org/mailman/listinfo/python-list
trim start and trailing space chars from string
Hi, is there something corresponding to the java String.trim() method, ie trim start and trailing space/tab chars from string? say convert asdf to asdf? Thnx -- http://mail.python.org/mailman/listinfo/python-list
Re: trim start and trailing space chars from string
On 15/09/2007, Konstantinos Pachopoulos [EMAIL PROTECTED] wrote: Hi, is there something corresponding to the java String.trim() method, ie trim start and trailing space/tab chars from string? say convert asdf to asdf? ' asdf '.strip() 'asdf' ' asdf '.rstrip() ' asdf' ' asdf '.lstrip() 'asdf ' -- http://mail.python.org/mailman/listinfo/python-list
Re: How to avoid overflow errors
Steven D'Aprano wrote: On Fri, 14 Sep 2007 18:19:45 -0700, James Stroud wrote: How do I subclass int and/or long so that my class also auto-converts only when needed? Use __new__. The disadvantage of that is that your example code requires me to duplicate my methods in the long version and the int version. It's easy enough to work around that (class factory function) but it just seems all rather untidy... The __new__ method is where you implement such decisions. There is no tidier way for one class auto-convert to another class, which is what you asked for (it says so right up there ^). So, if you don't like the answer, don't ask the question. Despite its unseemly appearance because of all the underscores, it is the natural way in python (to do what you have asked and not something which you didn't ask). The way to avoid duplicating methods (which is what you are asking for, no?) while still allowing your classes to maintain their identities is by using mixins: class MyModulatingMixin(object): def modulate(self, sum): if self.modulus is None: return self.__class__(sum) else: return self.__class__(sum % self.modulus) def __add__(self, other): sum = long.__add__(long(self), long(other)) return self.modulate(sum) def __mul__(self, other): sum = long.__mul__(long(self), long(other)) return self.modulate(sum) class MyLong(long): def __new__(cls, v, m=None): obj = long.__new__(cls, v) obj.modulus = m return obj class MyInt(int): def __new__(cls, v, m=None): try: obj = int.__new__(cls, v) obj.modulus = m except OverflowError: obj = MyLong(v, m) return obj for cls in MyLong, MyInt: cls.__bases__ = (MyModulatingMixin,) + cls.__bases__ py i = MyInt(51) py j = MyInt(40, 7) py k = MyLong(2, 13) py i + j 91 py j + k 0 py k + j 3L py i * k 102 py type(i * k) class '__main__.MyInt' py k * i 11L py type(k * i) class '__main__.MyLong' James -- http://mail.python.org/mailman/listinfo/python-list
Re: c interfacing in 2.5
Rustom Mody schrieb: I used python extensive 3-5 years back. Coming back I find some changes. Trying to understand whats new and would appreciate any help/comments/pointers. Earlier there were basically two options: SWIG: convenient but inefficient Native (Extending/Embedding): an efficient way of getting a headache! (Boost being ignored because not using C++) Now it seems there are more possibilities: -- Sip seems to be more efficient than swig and easier than native but not well documented -- pyrex could be considered -- I know someone who uses pygtk to make wrappings But most interesting is ctype. I wonder if having ctype in the core language changes the ease of use of the native wrapping model and thereby makes sip/swig etc less necessary? Your views and/or experience appreciated. ctypes is for C. Where it is great to use. If you need C++-wrapping, I recommend SIP. While the docs for SIP aren't overwhelming, I consider them accurate and complete. Best thing to do is to take a SIP-based project (most probably PyQt itself) and wheneever a question appears, rummage through it. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: trim start and trailing space chars from string
On Sep 15, 7:24 pm, Konstantinos Pachopoulos [EMAIL PROTECTED] wrote: Hi, is there something corresponding to the java String.trim() method, ie trim start and trailing space/tab chars from string? say convert asdf to asdf? http://docs.python.org/lib/string-methods.html -- http://mail.python.org/mailman/listinfo/python-list
Re: trim start and trailing space chars from string
s= abcdef s.strip() 'abcdef' s.rstrip() ' abcdef' s.lstrip() 'abcdef ' On 9/15/07, Konstantinos Pachopoulos [EMAIL PROTECTED] wrote: Hi, is there something corresponding to the java String.trim() method, ie trim start and trailing space/tab chars from string? say convert asdf to asdf? Thnx -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: reading xls file from python
On 15/09/2007 1:50 PM, Gabriel Genellina wrote: En Fri, 14 Sep 2007 18:56:34 -0300, [EMAIL PROTECTED] escribi�: I have installed python 2.5 for windows in my pc, I have a file xls say file.xls in c:/python25. How I can read this files from Python. Many thanks in advance. Try xlrd: http://www.python.org/pypi/xlrd In the interests of even-handedness: http://www.velocityreviews.com/forums/t352440-how-to-read-excel-files-in-python.html covers other possibilities. OT: A note for the OP: It is not a good idea to store your data files (example: file.xls) in the folder of some installed software (example: c:/python25). You may need to re-install the software and this may trash your data. Consider storing data files in folders whose names give some hint as to their contents. HTH, John -- http://mail.python.org/mailman/listinfo/python-list
Re: Just bought Python in a Nutshell
Used copies of computer books for out of date editions are always cheap. Python in a Nutshell (2nd ed) is a reference book with a frustratingly poor index--go figure. It also contains errors not posted in the errata. -- http://mail.python.org/mailman/listinfo/python-list
Re: regexp search on infinite string?
On Sep 15, 4:36 pm, Paddy [EMAIL PROTECTED] wrote: On Sep 15, 2:57 am, James Stroud [EMAIL PROTECTED] wrote: Paddy wrote: Lets say i have a generator running that generates successive characters of a 'string' From what I know, if I want to do a regexp search for a pattern of characters then I would have to 'freeze' the generator and pass the characters so far to re.search. It is expensive to create successive characters, but caching could be used for past characters. is it possible to wrap the generator in a class, possibly inheriting from string, that would allow the regexp searching of the string but without terminating the generator? In other words duck typing for the usual string object needed by re.search? - Paddy. re.search re.compile checks for str or unicode types explicitly, so you need to turn your data into one of those before using the module. Aaaarbejaysus. Since when? import array ba = array.array('c', 'A hollow voice says Plugh.') import re mobj = re.search('voi', ba) mobj _sre.SRE_Match object at 0x00B99598 mobj.span() (9, 12) buffer = [] while True: buffer.append(mygerator.next()) m = re.search(pattern, .join(buffer)) if m: process(m) buffer = [] James Thanks James. So: buffer = array.array('c') and flick the .join() etc etc HTH, John -- http://mail.python.org/mailman/listinfo/python-list
int('\x23') != 0x23 (a.k.a convert char to integer of its byte representation)
Hi, I am looking for the best way to convert a string of length 1 (= 1 character as string) to integer that has the same value as numeric representation of that character. Background: I am writing functions abstracting endianness, e.g. converting a string of length 4 to the appropriate integer value (e.g. '\x01\x00\x00\x00' = 2**24 for big endian memory, 2**0 for little endian memory). For this, I need to know the numeric value of each byte and sum them according to endianness. I thought that something like int('\x01') might work, provided the argument is string of length 1, but that throws an error: int('\x12') Traceback (most recent call last): File stdin, line 1, in ? ValueError: invalid literal for int(): The code I want to write looks like this: mem = '\x11\x22\x33\x44' factor = 1 sum = 0 for byte in mem: sum += int(byte) * factor factor *= 2**8 Could you please tell me how to achieve what I want in Python? (it would be straightforward in C) Thanks for any suggestions, Boris Dušek -- http://mail.python.org/mailman/listinfo/python-list
Re: Modul (%) in python not like in C?
J. Cliff Dyer wrote: Bryan Olson wrote: Scott David Daniels wrote: C, which was designed as a high level assembly language, does not tightly define the results of / and % for negative numbers. Instead it defines the result for positive over positive, and constrains the result for the others. Not true. Here it is again: When integers are divided, the result of the / operator is the algebraic quotient with any fractional part discarded.(87) If the quotient a/b is representable, the expression (a/b)*b + a%b shall equal a. [...] 87) This is often called ‘‘truncation toward zero’’. [International Standard ISO/IEC 9899:1999, Section 6.5.5 Multiplicative operators, Paragraph 6 and footnote 87] But C was around for a long time before the 1999 standard. C89, commonly called ANSI C, is still very commonly used in compilers, and KR C goes back to 1972. Is truncation toward 0 the standard for KR C as well? Looks like you have a good point there. I do not have a copy of the C89 standard, but do I have editions of HarbisonSteele that reflect the 1989 standard, and they confirm your suspicion that the results of the '/' and '%' operators on integer operants were not uniquely defined in cases where an operand could be negative. Describing the '/' operator: For integral operands,, if the mathematical quotient is is not an exact integer, then the result will be one of the integers closest to the mathematical quotient of the operands. Of those two integers, the one closer to 0 must be chosen if both operands are positive Furthermore: It is always true that (a/b)*b + a%b is equal to a if b is not 0 Quoted from: S. P. Harbison and G. L. Steele. /C: A Reference Manual, Third Edition/, Prentice Hall, 1991; Section 7.6.1, page 187. So Arnau Sanchez and Scott David Daniels were correct with respect to C89 and older standards, and many implementations have not yet adopted the 1999 standard that strictly defines the results of / and %. -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list
Re: int('\x23') != 0x23 (a.k.a convert char to integer of its byte representation)
On Sat, 15 Sep 2007 11:55:28 +, Boris Dušek wrote: I am looking for the best way to convert a string of length 1 (= 1 character as string) to integer that has the same value as numeric representation of that character. Background: I am writing functions abstracting endianness, e.g. converting a string of length 4 to the appropriate integer value (e.g. '\x01\x00\x00\x00' = 2**24 for big endian memory, 2**0 for little endian memory). For this, I need to know the numeric value of each byte and sum them according to endianness. So you are looking for the `struct` module in the standard library instead of doing this yourself. :-) If you insist on doing it yourself take a look at the built-in `ord()` function. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
Re: Https conversation - debug?
* Johny (Fri, 14 Sep 2007 12:51:22 -0700) Is there any good sniffer for https protocol? What's the connection to Python? How can be watched https conversation? ssldump. Note that in order to decrypt the traffic you need to have the server's private key. -- http://mail.python.org/mailman/listinfo/python-list
Re: int('\x23') != 0x23 (a.k.a convert char to integer of its byte representation)
On Sep 15, 1:59 pm, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: So you are looking for the `struct` module in the standard library instead of doing this yourself. :-) If you insist on doing it yourself take a look at the built-in `ord()` function. Thanks Marc, both things are exactly what I was looking for (I am a bit ashamed that I did not find the built-in ord :-) Boris -- http://mail.python.org/mailman/listinfo/python-list
how to join array of integers?
i think in Ruby, if you have an array (or list) of integers foo = [1, 2, 3] you can use foo.join(,) to join them into a string 1,2,3 in Python... is the method to use ,.join() ? but then it must take a list of strings... not integers... any fast method? -- http://mail.python.org/mailman/listinfo/python-list
Re: int('\x23') != 0x23 (a.k.a convert char to integer of its byte representation)
On Sep 15, 9:55 pm, Boris Dušek [EMAIL PROTECTED] wrote: Hi, I am looking for the best way to convert a string of length 1 (= 1 character as string) to integer that has the same value as numeric representation of that character. Background: I am writing functions abstracting endianness, e.g. converting a string of length 4 to the appropriate integer value (e.g. '\x01\x00\x00\x00' = 2**24 for big endian memory, 2**0 for little endian memory). For this, I need to know the numeric value of each byte and sum them according to endianness. I thought that something like int('\x01') might work, provided the argument is string of length 1, but that throws an error: int('\x12') Traceback (most recent call last): File stdin, line 1, in ? ValueError: invalid literal for int(): The code I want to write looks like this: mem = '\x11\x22\x33\x44' factor = 1 sum = 0 for byte in mem: sum += int(byte) * factor factor *= 2**8 Could you please tell me how to achieve what I want in Python? (it would be straightforward in C) 'BlackJack' has already sent you looking for the docs for ord() and the struct module but a few other clues seem necessary: 1. Don't think that something like int() might work, read the docs. 2. factor *= 2 **8?? Python compiles to bytecode; don't make it work any harder than it has to. factor is quite unnecessary. That loop needs exactly 1 statement: sum = (sum 8) + ord(byte) 3. Don't use sum as a variable name; it will shadow the sum() built- in function. 4. Read through the docs for *all* the built-in functions -- all kinds of interesting and useful gadgets to be found there. 5. In a dark corner there lives a strange beast called the array module: import array array.array('I', '\x01\x00\x00\x00')[0] 1L array.array('I', '\x00\x00\x00\x01')[0] 16777216L 2**24 16777216 HTH, John -- http://mail.python.org/mailman/listinfo/python-list
Re: how to join array of integers?
On Sat, 15 Sep 2007 12:36:02 +, Summercool wrote: i think in Ruby, if you have an array (or list) of integers foo = [1, 2, 3] you can use foo.join(,) to join them into a string 1,2,3 in Python... is the method to use ,.join() ? but then it must take a list of strings... not integers... any fast method? Convert them to strings before joining: In [145]: foo = [1, 2, 3] In [146]: ','.join(map(str, foo)) Out[146]: '1,2,3' Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
python 2.5 cElementTree entity troubles
Hi, this snippet, adapted from http://svn.effbot.org/public/tags/celementtree-1.0-20050126/selftest.py fails miserably with an unknown entity exception: from xml.etree.cElementTree import * ENTITY_XML = documententity;/document parser = XMLTreeBuilder() parser.entity[entity] = text print parser.entity parser.feed(ENTITY_XML) root = parser.close() Any suggestions on how to teach the built-in ET-parser entities? Python version is Python 2.5.1 (r251:54869, Apr 18 2007, 22:08:04) on OSX. Regards, Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: how to join array of integers?
print ''.join([str(i) for i in [1,2,3]]) On 9/15/07, Summercool [EMAIL PROTECTED] wrote: i think in Ruby, if you have an array (or list) of integers foo = [1, 2, 3] you can use foo.join(,) to join them into a string 1,2,3 in Python... is the method to use ,.join() ? but then it must take a list of strings... not integers... any fast method? -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: how to join array of integers?
On Sep 15, 10:36 pm, Summercool [EMAIL PROTECTED] wrote: i think in Ruby, if you have an array (or list) of integers foo = [1, 2, 3] you can use foo.join(,) to join them into a string 1,2,3 in Python... is the method to use ,.join() ? but then it must take a list of strings... not integers... any fast method? foo = [1,2,3] ,.join(str(x) for x in foo) '1,2,3' ,.join(map(str, foo)) '1,2,3' If you are going to write several such results to a file, consider using the csv module. HTH, John -- http://mail.python.org/mailman/listinfo/python-list
Re: regexp search on infinite string?
On Sep 14, 9:49 pm, Paddy [EMAIL PROTECTED] wrote: Lets say i have a generator running that generates successive characters of a 'string'From what I know, if I want to do a regexp search for a pattern of characters then I would have to 'freeze' the generator and pass the characters so far to re.search. It is expensive to create successive characters, but caching could be used for past characters. is it possible to wrap the generator in a class, possibly inheriting from string, that would allow the regexp searching of the string but without terminating the generator? In other words duck typing for the usual string object needed by re.search? - Paddy. There seems to be no way of breaking into the re library accessing characters from the string: class S(str): ... def __getitem__(self, *a): ... print getitem:,a ... return str.__getitem__(self, *a) ... def __get__(self, *a): ... print get:,a ... return str.__get__(self, *a) ... s = S('sdasd') m = re.search('as', s); m.span() (2, 4) m = sre.search('as', s); m.span() (2, 4) class A(array.array): ... def __getitem__(self, *a): ... print getitem:,a ... return str.__getitem__(self, *a) ... def __get__(self, *a): ... print get:,a ... return str.__get__(self, *a) ... s = A('c','sdasd') m = re.search('as', s); m.span() (2, 4) m = sre.search('as', s); m.span() (2, 4) - Paddy. -- http://mail.python.org/mailman/listinfo/python-list
Re: regexp search on infinite string?
On Sep 15, 10:56 pm, Paddy [EMAIL PROTECTED] wrote: On Sep 14, 9:49 pm, Paddy [EMAIL PROTECTED] wrote: Lets say i have a generator running that generates successive characters of a 'string'From what I know, if I want to do a regexp search for a pattern of characters then I would have to 'freeze' the generator and pass the characters so far to re.search. It is expensive to create successive characters, but caching could be used for past characters. is it possible to wrap the generator in a class, possibly inheriting from string, that would allow the regexp searching of the string but without terminating the generator? In other words duck typing for the usual string object needed by re.search? - Paddy. There seems to be no way of breaking into the re library accessing characters from the string: class S(str): ... def __getitem__(self, *a): ... print getitem:,a ... return str.__getitem__(self, *a) ... def __get__(self, *a): ... print get:,a ... return str.__get__(self, *a) ... s = S('sdasd') m = re.search('as', s); m.span() (2, 4) m = sre.search('as', s); m.span() (2, 4) class A(array.array): ... def __getitem__(self, *a): ... print getitem:,a ... return str.__getitem__(self, *a) ... def __get__(self, *a): ... print get:,a ... return str.__get__(self, *a) ... s = A('c','sdasd') m = re.search('as', s); m.span() (2, 4) m = sre.search('as', s); m.span() (2, 4) - Paddy. That would no doubt be because it either copies the input [we hope not] or more likely because it hands off the grunt work to a C module (_sre). Why do you want to break into it, anyway? -- http://mail.python.org/mailman/listinfo/python-list
Re: Python+Expect+Win32 = Not Possible?
In article [EMAIL PROTECTED], gamename [EMAIL PROTECTED] wrote: On Sep 13, 1:42 am, [EMAIL PROTECTED] wrote: On Sep 12, 9:27 pm, gamename [EMAIL PROTECTED] wrote: Hi, Is it still the case there is no practical Expect-like module for win32? I know that cygwin can support pexpect, but that isn't an option here --- I have to use a native win32 Python version. Are there alternatives, or is it simply not an option to replicate Expect on win32 with python? All I'm trying to do is start a couple processes, wait for each to say done on stdout and then quit (or timeout if something went wrong). TIA, -T I had planned on using telnet to do the same thing on windows. I don't think I ever proved it, but I'm pretty sure it will work. Thanks, Sean. The problem is that telnet is generally disabled on most hosts nowadays. . . . I'm plenty confused about who's saying what now. Yes, well-run modern hosts disable telnetd; I think the original description, though, was about use of telnet to connect to hardware devices which provide some simple TCP/IP (or serial-line?) service. Windows still builds in the telnet *client* ... ... which might well be superfluous. If these hardware devices (did I understand that part correctly?) are just simple network servers, and don't, for example, demand authentication, Python's socket library can be used directly (and even portably!), without involvement of Expect capabilities or an external telnet executable. -- http://mail.python.org/mailman/listinfo/python-list
Re: Rename multiple files using names in a text file
Le Fri, 14 Sep 2007 12:52:52 -0700, James Stroud a écrit: [...] Other than that your strip() is stripping off some whitespace that is part of the name, I really can't see the problem either, but did you try to add in the explicit path? E.g.: actually, the problem was in while i = len(list_jpg_strip) and i should have been while i len(list_jpg_strip). Antoher problem was the name of jpg's files used for testing. A naughty one was nammed file.jpg instead of file.jpg. So maube, as you saif, stripping is useless for list of jpg files. Thanks a lot. Rémi -- http://mail.python.org/mailman/listinfo/python-list
Re: Coming from Perl - SOLVED
I V wrote: On Thu, 13 Sep 2007 23:49:32 -0400, Amer Neely wrote: In trying to track down why this script would not run on my host, it has to come to light that Python is installed, however the Apache module is not. So, short story is - I was flogging a dead horse. Which Apache module? You don't need any special modules (just the regular CGI one) to use python in a CGI script. That is an interesting observation. It does run under my Apache + Win2K at home, with no special configuration by me. All I'm going on is what the techs told me. So, you think it may be something else? I've changed and even eliminated the end-of-line chars in my print statements. Another poster (Bryan Olson) has suggested a few things to try as well so I will try those. I don't have shell access though, so the best I can do is execute shell commands from a Perl script. -- Amer Neely w: www.webmechanic.softouch.on.ca/ Perl | MySQL programming for all data entry forms. Others make web sites. We make web sites work! -- http://mail.python.org/mailman/listinfo/python-list
Re: Coming from Perl
Bryan Olson wrote: Amer Neely wrote: This seems to indicate that maybe my host needs to configure Apache to run python scripts? But I didn't need to do anything with mine. Another possibility: If it works on Windows but not Unix, check the end-of-line characters. Windows ends each line with the two character sequence carriage-return + newline, which in Python is \r\n. Unix uses newline alone, \n. Most Unixies will choke on a #! line with a carriage return. The Python interpreter will accept source files with either end-of-line on either system, but of course you'll not get that far unless the operating system respects the shebang line. Maybe you already checked that. Hmmm...other possiblities... Do you have shell access? Can you executing it directly from the shell? Do you get a Python error, or some other? Did you: chmod ugo+rx yourscript Is Python in /usr/bin? What does which python say? Generally, most experts seem to prefer: #!/usr/bin/env python You might try changing the the extension of your script from .py to .cgi. Windows uses the .py to choose the executable, but Unix does not care; it used the shebang line. Hmmm. These are interesting suggestions. Especially in light of a new wrinkle pointed out by [IV]. That being the script runs fine under my Apache at home with no special modules loaded. I don't have shell access but I can run 'which python' from a Perl script, and I will try the different shebang line you suggested. Thanks for the suggestions. -- Amer Neely w: www.webmechanic.softouch.on.ca/ Perl | MySQL programming for all data entry forms. Others make web sites. We make web sites work! -- http://mail.python.org/mailman/listinfo/python-list
How to get headers in urllib2 response
Can anyone provide an example how to find out the return code and header from an urllib2 request? For example response = urllib2.urlopen('http://www.google.com').read().strip() provides data but I do not know if the return code was 200 or different. Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: how to join array of integers?
js escribió: On 9/15/07, Summercool [EMAIL PROTECTED] wrote: in Python... is the method to use ,.join() ? but then it must take a list of strings... not integers... any fast method? print ''.join([str(i) for i in [1,2,3]]) It's better to use generator comprehension instead of LC: ,.join(str(i) for i in [1, 2, 3]) Or, if you happen to like the itertools modules: from itertools import imap ,.join(imap(str, [1, 2, 3])) -- http://mail.python.org/mailman/listinfo/python-list
DDE error Poke Failed
Hi First of all I am a beginner with python and I am a bit fooling around to check wich possibilities I have. I'm trying to get some data to an internal developped application. Server: DDE Topic: SCSDDeServer Item: SendCustomerData Item data: value, value, value I got the following code import win32ui, dde server = dde.CreateServer() server.Create(test) conversation = dde.CreateConversation(server) conversation.ConnectTo(SCS,SCSDDeServer) conversation.Poke('SendCustomerData, S1234567,,') When I run this I get Traceback (most recent call last): File U:\python\scs.py, line 6, in module conversation.Poke('SendCustomerData, S1234567') error: Poke failed Am I doing anything wrong? Or is it possible that the SCS application only accepts pokes from a specific program? Regards Maarten -- http://mail.python.org/mailman/listinfo/python-list
Re: Can You Program?
On Sep 13, 3:37 am, [EMAIL PROTECTED] wrote: We are offering $2000 USD for the best website developed withwww.hatspin.com Are you up to it?? Hey, thanks for spamming our group. Perhaps you should try again after you learn proper HTML coding. Results from http://validator.w3.org/ : Failed validation, 26 Errors Really, really doubt that you are doing anything but trying to gather e-mails. My 12 year old has made better sites. Oh, and does jobslide.com know that you are linking to images on their site? I'll be mentioning that to them, just so you know. Please, put down the keyboard and step away from the computer.. -- http://mail.python.org/mailman/listinfo/python-list
Re: Coming from Perl
Bryan Olson wrote: Amer Neely wrote: This seems to indicate that maybe my host needs to configure Apache to run python scripts? But I didn't need to do anything with mine. Another possibility: If it works on Windows but not Unix, check the end-of-line characters. Windows ends each line with the two character sequence carriage-return + newline, which in Python is \r\n. Unix uses newline alone, \n. Most Unixies will choke on a #! line with a carriage return. The Python interpreter will accept source files with either end-of-line on either system, but of course you'll not get that far unless the operating system respects the shebang line. Maybe you already checked that. Hmmm...other possiblities... Do you have shell access? Can you executing it directly from the shell? Do you get a Python error, or some other? Did you: chmod ugo+rx yourscript Is Python in /usr/bin? What does which python say? Generally, most experts seem to prefer: #!/usr/bin/env python You might try changing the the extension of your script from .py to .cgi. Windows uses the .py to choose the executable, but Unix does not care; it used the shebang line. I tried `which python` and `whereis python` and got 0 back as a result. So it seems Python is not installed at all. -- Amer Neely w: www.webmechanic.softouch.on.ca/ Perl | MySQL programming for all data entry forms. Others make web sites. We make web sites work! -- http://mail.python.org/mailman/listinfo/python-list
Re: python 2.5 cElementTree entity troubles
Diez B. Roggisch wrote: Any suggestions on how to teach the built-in ET-parser entities? As you already do it in your code. http://effbot.org/elementtree/elementtree-xmlparser.htm#tag-ET.XMLParser.entity But I guess your version of cET is just too old. Stefan -- http://mail.python.org/mailman/listinfo/python-list
Re: Can You Program?
Hey, thanks for spamming our group. Perhaps you should try again after you learn proper HTML coding. Results from http://validator.w3.org/ : Failed validation, 26 Errors Really, really doubt that you are doing anything but trying to gather e-mails. My 12 year old has made better sites. Oh, and does jobslide.com know that you are linking to images on their site? I'll be mentioning that to them, just so you know. Please, put down the keyboard and step away from the computer.. And thanks to you, the spammer got another post containing his website, increasing page-rank. Well done! Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: extract text from log file using re
Hi to all, thanks for your help. The approach print '\r\n'.join([x.strip() for x in open('c:/flutest.txt') if 'e-0' in x]) works quite well :-) Greetings! Fabian Fabian Braennstroem schrieb am 09/13/2007 09:09 PM: Hi, I would like to delete a region on a log file which has this kind of structure: #--flutest 498 1.0086e-03 2.4608e-04 9.8589e-05 1.4908e-04 8.3956e-04 3.8560e-03 4.8384e-02 11:40:01 499 499 1.0086e-03 2.4608e-04 9.8589e-05 1.4908e-04 8.3956e-04 3.8560e-03 4.8384e-02 11:40:01 499 reversed flow in 1 faces on pressure-outlet 35. Writing /home/gcae504/SCR1/Solververgleich/Klimakruemmer_AK/CAD/Daimler/fluent-0500.cas... 5429199 mixed cells, zone 29, binary. 11187656 mixed interior faces, zone 30, binary. 20004 triangular wall faces, zone 31, binary. 1104 mixed velocity-inlet faces, zone 32, binary. 133638 triangular wall faces, zone 33, binary. 14529 triangular wall faces, zone 34, binary. 1350 mixed pressure-outlet faces, zone 35, binary. 11714 mixed wall faces, zone 36, binary. 1232141 nodes, binary. 1232141 node flags, binary. Done. Writing /home/gcae504/SCR1/Solververgleich/Klimakruemmer_AK/CAD/Daimler/fluent-0500.dat... Done. 500 1.0049e-03 2.4630e-04 9.8395e-05 1.4865e-04 8.3913e-04 3.8545e-03 1.3315e-01 11:14:10 500 reversed flow in 2 faces on pressure-outlet 35. 501 1.0086e-03 2.4608e-04 9.8589e-05 1.4908e-04 8.3956e-04 3.8560e-03 4.8384e-02 11:40:01 499 #-- I have a small script, which removes lines starting with '(re)versed', '(i)teration' and '(t)urbulent' and put the rest into an array: # -- plot residuals import re filename=flutest reversed_flow=re.compile('^\ re') turbulent_viscosity_ratio=re.compile('^\ tu') iteration=re.compile('^\ \ i') begin_of_res=re.compile('\ \ \ i') end_of_res=re.compile('^\ ad') begin_of_writing=re.compile('^\Writing') end_of_writing=re.compile('^\Done') end_number=0 begin_number=0 n = 0 for line in open(filename).readlines(): n = n + 1 if begin_of_res.match(line): begin_number=n+1 print Line Number (begin): + str(n) if end_of_res.match(line): end_number=n print Line Number (end): + str(n) if begin_of_writing.match(line): begin_w=n+1 print BeginWriting: + str(n) print HALLO if end_of_writing.match(line): end_w=n+1 print EndWriting: +str(n) if n end_number: end_number=n print Line Number (end): + str(end_number) n = 0 array = [] array_dummy = [] array_mapped = [] mapped = [] mappe = [] n = 0 for line in open(filename).readlines(): n = n + 1 if (begin_number = n) and (end_number n): #if (begin_w = n) and (end_w n): if not reversed_flow.match(line) and not iteration.match(line) and not turbulent_viscosity_ratio.match(line): m=(line.strip().split()) print m if len(m) 0: #print len(m) laenge_liste=len(m) #print len(m) mappe.append(m) #--end plot residuals- This works fine ; except for the region with the writing information: #-writing information - Writing /home/fb/fluent-0500.cas... 5429199 mixed cells, zone 29, binary. 11187656 mixed interior faces, zone 30, binary. 20004 triangular wall faces, zone 31, binary. 1104 mixed velocity-inlet faces, zone 32, binary. 133638 triangular wall faces, zone 33, binary. 14529 triangular wall faces, zone 34, binary. 1350 mixed pressure-outlet faces, zone 35, binary. 11714 mixed wall faces, zone 36, binary. 1232141 nodes, binary. 1232141 node flags, binary. Done. # ---end writing information --- Does anyone know, how I can this 'writing' stuff too? The matchingIt occurs a lot :-( Regards! Fabian -- http://mail.python.org/mailman/listinfo/python-list
Re: python 2.5 cElementTree entity troubles
Stefan Behnel schrieb: Diez B. Roggisch wrote: Any suggestions on how to teach the built-in ET-parser entities? As you already do it in your code. http://effbot.org/elementtree/elementtree-xmlparser.htm#tag-ET.XMLParser.entity But I guess your version of cET is just too old. Unfortunately, it's the python 2.5-build-in one.. :( Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get headers in urllib2 response
How about using httplib? http://docs.python.org/lib/httplib-examples.html HTTPResponse has getheaders() method, too. On 9/15/07, Johny [EMAIL PROTECTED] wrote: Can anyone provide an example how to find out the return code and header from an urllib2 request? For example response = urllib2.urlopen('http://www.google.com').read().strip() provides data but I do not know if the return code was 200 or different. Thanks -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: python 2.5 cElementTree entity troubles
Stefan Behnel wrote: Diez B. Roggisch wrote: Any suggestions on how to teach the built-in ET-parser entities? As you already do it in your code. http://effbot.org/elementtree/elementtree-xmlparser.htm#tag-ET.XMLParser.entity Hmmm, I never needed this, but the test doesn't work for me either (with ET 1.3, Python 2.5.1). ET's parser uses the generic expat callback for entities, but it doesn't seem to get called for entities on my side... Looks like something's broken there. Stefan -- http://mail.python.org/mailman/listinfo/python-list
Re: How to avoid overflow errors
On 9/15/07, Carl Banks [EMAIL PROTECTED] wrote: On Fri, 14 Sep 2007 22:59:13 -0300, Eduardo O. Padoan wrote: On 14 Sep 2007 18:08:00 -0700, Paul Rubin http://phr.cx@nospam.invalid wrote: Eduardo O. Padoan [EMAIL PROTECTED] writes: Not totally unrelated, but in Py3k, as it seems, overflows are really things of the past: Python 3.0a1 (py3k:58061, Sep 9 2007, 13:18:37) [GCC 4.1.3 20070831 (prerelease) (Ubuntu 4.1.2-16ubuntu1)] on linux2 Type help, copyright, credits or license for more information. class MyInt(int): ... pass ... import sys MyInt(sys.maxint) 2147483647 MyInt(sys.maxint+1) 2147483648 I'd be interested in knowing what happens in 3.0a1 with a = itertools.count(sys.maxint) print a.next() print a.next() print(next(a)) Traceback (most recent call last): File stdin, line 1, in module OverflowError: cannot count beyond PY_SSIZE_T_MAX Hum, you've got me there. it is the same as in 2.x. Maybe the message should be less crypt, at least - nothing that googling for PY_SSIZE_T_MAX cant help. This should demonstrate that OverflowError will not disappear entirely even in Python 3. No one is denying that by now :) Even if we were to get rid of all OverflowErrors resulting from integer operations in Python, there are going to be some C extensions--including some in the Python standard library--that will store 32-bit integers. Modules such as array and struct will still raise it, and probably other modules were a long integer sometimes doesn't make sense (socket, for instance). itertools.count() should work for arbitrary integers, though. Agreed. I was lookind at itertoolsmodule.c, and even for my very limited C knowlegment, it does not seem to be too hard. Anyway: http://bugs.python.org/issue1165 Carl Banks -- http://mail.python.org/mailman/listinfo/python-list -- http://www.advogato.org/person/eopadoan/ Bookmarks: http://del.icio.us/edcrypt -- http://mail.python.org/mailman/listinfo/python-list
Re: Extended slicing and Ellipsis - where are they used?
On Sep 13, 5:50 pm, James Stroud [EMAIL PROTECTED] wrote: Rodney Maxwell wrote: The following are apparently legal Python syntactically: L[1:3, 8:10] L[1, ..., 5:-2] But they don't seem to work on lists: l = [0,1,2,3] l[0:2,3] Traceback (most recent call last): File stdin, line 1, in module TypeError: list indices must be integers l[...] Traceback (most recent call last): File stdin, line 1, in module TypeError: list indices must be integers So where is this extended slicing used? AFAICT this syntax is not used in the standard library. However, the mega-beauty of it is that you can make use of it in your own classes: py class Bob(list): ... def __getitem__(self, i): ... try: ... return [list.__getitem__(self, j) for j in i] ... except TypeError: ... return list.__getitem__(self, i) ... py b = Bob(xrange(15, 30)) py b[3, 5, 7, 13] [18, 20, 22, 28] James Or b[0:3, 5, 9] [[15, 16, 17], 20, 24] which is what I was looking for in the first place. Thanks, Rodney -- http://mail.python.org/mailman/listinfo/python-list
Re: Extended slicing and Ellipsis - where are they used?
On Sep 13, 5:50 pm, James Stroud [EMAIL PROTECTED] wrote: Rodney Maxwell wrote: The following are apparently legal Python syntactically: L[1:3, 8:10] L[1, ..., 5:-2] But they don't seem to work on lists: l = [0,1,2,3] l[0:2,3] Traceback (most recent call last): File stdin, line 1, in module TypeError: list indices must be integers l[...] Traceback (most recent call last): File stdin, line 1, in module TypeError: list indices must be integers So where is this extended slicing used? AFAICT this syntax is not used in the standard library. However, the mega-beauty of it is that you can make use of it in your own classes: py class Bob(list): ... def __getitem__(self, i): ... try: ... return [list.__getitem__(self, j) for j in i] ... except TypeError: ... return list.__getitem__(self, i) ... py b = Bob(xrange(15, 30)) py b[3, 5, 7, 13] [18, 20, 22, 28] James Or b[0:3, 5, 9] [[15, 16, 17], 20, 24] which is what I was looking for in the first place. Thanks, Rodney -- http://mail.python.org/mailman/listinfo/python-list
Re: regexp search on infinite string?
On Sep 15, 2:07 pm, John Machin [EMAIL PROTECTED] wrote: On Sep 15, 10:56 pm, Paddy [EMAIL PROTECTED] wrote: On Sep 14, 9:49 pm, Paddy [EMAIL PROTECTED] wrote: Lets say i have a generator running that generates successive characters of a 'string'From what I know, if I want to do a regexp search for a pattern of characters then I would have to 'freeze' the generator and pass the characters so far to re.search. It is expensive to create successive characters, but caching could be used for past characters. is it possible to wrap the generator in a class, possibly inheriting from string, that would allow the regexp searching of the string but without terminating the generator? In other words duck typing for the usual string object needed by re.search? - Paddy. There seems to be no way of breaking into the re library accessing characters from the string: class S(str): ... def __getitem__(self, *a): ... print getitem:,a ... return str.__getitem__(self, *a) ... def __get__(self, *a): ... print get:,a ... return str.__get__(self, *a) ... s = S('sdasd') m = re.search('as', s); m.span() (2, 4) m = sre.search('as', s); m.span() (2, 4) class A(array.array): ... def __getitem__(self, *a): ... print getitem:,a ... return str.__getitem__(self, *a) ... def __get__(self, *a): ... print get:,a ... return str.__get__(self, *a) ... s = A('c','sdasd') m = re.search('as', s); m.span() (2, 4) m = sre.search('as', s); m.span() (2, 4) - Paddy. That would no doubt be because it either copies the input [we hope not] or more likely because it hands off the grunt work to a C module (_sre). Yes, it seems to need a buffer/string so probably access a contiguous area of memory from C. o Why do you want to break into it, anyway? A simulation generates stream of data that could be gigabytes from which I'd like to find interesting bits by doing a regexp search. I could use megabyte length sliding buffers, and probably will have to. - Paddy. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 3K or Python 2.9?
On Sep 14, 2007, at 11:54 PM, David Trudgett wrote: TheFlyingDutchman [EMAIL PROTECTED] writes: The confusing way about the current Python method when you first encounter it is why is self being passed in when you write the function but not when you call it. If the compiler is smart enough to know that a = MyClass() a.SomeFunction(12) SomeFunction() has a self implicitly added to the parameter list, it seems that it should be smart enough to know that a function defined in a class has a self implicitly added to the parameter list. Several languages use the object.method(args) form, which is syntactic sugar for method(object, other_args) which Ada, for instance, uses. Knowing this clears up half the confusion (the object /is/ passed as a parameter whichever syntax is used). The other half of the confusion is cleared up by considering that Python methods are ordinary functions that don't magically know in which class context they are executing: they must be told via the first parameter. Yes, that is really the crux of the issue, though. While the former may be syntactic sugar for the latter, once any syntactic sugar has become prevalent enough, it becomes the expected norm and the latter becomes clutter or, at best, awkward. It's something that really just takes a little use until you get to the point where you don't usually think of it but, every so often, the thought creeps in. I'm not complaining, just pointing out if you step out of this particular box, you'll realize that it really is a pointless one. Saying, because that's how Python does it may be the only valid reason, but that argument is about on par with a six year old's just because Erik Jones Software Developer | Emma® [EMAIL PROTECTED] 800.595.4401 or 615.292.5888 615.292.0777 (fax) Emma helps organizations everywhere communicate market in style. Visit us online at http://www.myemma.com -- http://mail.python.org/mailman/listinfo/python-list
Re: how to join array of integers?
On 2007-09-15, Arnau Sanchez [EMAIL PROTECTED] wrote: in Python... is the method to use ,.join() ? but then it must take a list of strings... not integers... any fast method? print ''.join([str(i) for i in [1,2,3]]) It's better to use generator comprehension instead of LC: ,.join(str(i) for i in [1, 2, 3]) Or, if you happen to like the itertools modules: from itertools import imap ,.join(imap(str, [1, 2, 3])) It's nice people have invented so many ways to spell the builting map ;) ,.join(map(str,[1,2,3])) '1,2,3' -- Grant Edwards grante Yow! Thousands of days of at civilians... have produced visi.coma... feeling for the aesthetic modules -- -- http://mail.python.org/mailman/listinfo/python-list
RFC-3986 or 2396 implementation in Python?
Hi list. Is there any module that is compatible with RFC-3986 or 2396, which is like Perl's URI module(http://search.cpan.org/~gaas/URI-1.35/URI.pm)? I like to normalize lots of URIs I've got in my database to make them all unique ones. Thank you in advance. -- http://mail.python.org/mailman/listinfo/python-list
Re: how to join array of integers?
On Sep 15, 2007, at 8:56 AM, Arnau Sanchez wrote: js escribió: On 9/15/07, Summercool [EMAIL PROTECTED] wrote: in Python... is the method to use ,.join() ? but then it must take a list of strings... not integers... any fast method? print ''.join([str(i) for i in [1,2,3]]) It's better to use generator comprehension instead of LC: ,.join(str(i) for i in [1, 2, 3]) Why is that? That entire expression must be evaluated to obtain the result, so what is the advantage of using a generator comprehension v. a list comprehension? -- http://mail.python.org/mailman/listinfo/python-list
Re: how to join array of integers?
On Sep 15, 2007, at 11:07 AM, Grant Edwards wrote: On 2007-09-15, Arnau Sanchez [EMAIL PROTECTED] wrote: in Python... is the method to use ,.join() ? but then it must take a list of strings... not integers... any fast method? print ''.join([str(i) for i in [1,2,3]]) It's better to use generator comprehension instead of LC: ,.join(str(i) for i in [1, 2, 3]) Or, if you happen to like the itertools modules: from itertools import imap ,.join(imap(str, [1, 2, 3])) It's nice people have invented so many ways to spell the builting map ;) ,.join(map(str,[1,2,3])) '1,2,3' IIRC, map's status as a builtin is going away. Erik Jones Software Developer | Emma® [EMAIL PROTECTED] 800.595.4401 or 615.292.5888 615.292.0777 (fax) Emma helps organizations everywhere communicate market in style. Visit us online at http://www.myemma.com -- http://mail.python.org/mailman/listinfo/python-list
Re: how to join array of integers?
On 2007-09-15, Erik Jones [EMAIL PROTECTED] wrote: print ''.join([str(i) for i in [1,2,3]]) It's better to use generator comprehension instead of LC: ,.join(str(i) for i in [1, 2, 3]) Why is that? That entire expression must be evaluated to obtain the result, so what is the advantage of using a generator comprehension v. a list comprehension? The generator avoids creating the intermediate list -- it generates the intermediate values on the fly. For short sequences it probably doesn't matter much. For a very long list it's probably noticable. -- Grant Edwards grante Yow! Mr and Mrs PED, can I at borrow 26.7% of the RAYON visi.comTEXTILE production of the INDONESIAN archipelago? -- http://mail.python.org/mailman/listinfo/python-list
Need a guitar?
Free guitars here!! http://freeguitars.blogspot.com/ -- http://mail.python.org/mailman/listinfo/python-list
find and remove \ character from string
Hi, i have the following string s and the following code, which doesn't successfully remove the \, but sucessfully removes the \\. s=Sad\\asd\asd newS= for i in s: ... if i!=\\: ... newS=newS+i ... newS 'Sadasd\x07sd' I have also read the following, but i do not understand the ...and the remaining characters have been mapped through the given translation table, which must be a string of length 256. Can some explain? *translate*(table[, deletechars]) Return a copy of the string where all characters occurring in the optional argument deletechars are removed, and the remaining characters have been mapped through the given translation table, which must be a string of length 256. For Unicode objects, the translate() method does not accept the optional deletechars argument. Instead, it returns a copy of the s where all characters have been mapped through the given translation table which must be a mapping of Unicode ordinals to Unicode ordinals, Unicode strings or |None|. Unmapped characters are left untouched. Characters mapped to |None| are deleted. Note, a more flexible approach is to create a custom character mapping codec using the codecs http://docs.python.org/lib/module-codecs.html module (see encodings.cp1251 for an example). -- http://mail.python.org/mailman/listinfo/python-list
Re: find and remove \ character from string
Konstantinos Pachopoulos wrote: i have the following string s and the following code, which doesn't successfully remove the \, but sucessfully removes the \\. s=Sad\\asd\asd newS= for i in s: ... if i!=\\: ... newS=newS+i I'm not quite sure what you're trying to achieve, but I'd use r\\a\\b\c.replace(, ) 'ab\\c' r\\a\\b\c.replace(\\, ) 'abc' Note that \\ in the source is unescaped to \ in the string. Use r\\ to prevent that. Stefan -- http://mail.python.org/mailman/listinfo/python-list
Re: how to join array of integers?
It's nice people have invented so many ways to spell the builting map ;) ,.join(map(str,[1,2,3])) '1,2,3' IIRC, map's status as a builtin is going away. Actually, py3k built-in map == itertools.imap map(str, []) itertools.imap object at 0xb7c7c9ec -- http://www.advogato.org/person/eopadoan/ Bookmarks: http://del.icio.us/edcrypt -- http://mail.python.org/mailman/listinfo/python-list
Re: c interfacing in 2.5
Diez B. Roggisch wrote: ctypes is for C. Where it is great to use. if you need simple wrappers then swig and ctypes are both good since they can generate it for you pyrex is also good for wrapping and for writing c extension code If you need C++-wrapping, I recommend SIP. i recommend py++ for wrapping c++ -- http://mail.python.org/mailman/listinfo/python-list
Re: how to join array of integers?
Grant Edwards ha escrito: Or, if you happen to like the itertools modules: from itertools import imap ,.join(imap(str, [1, 2, 3])) It's nice people have invented so many ways to spell the builting map ;) Did you wonder why the Python developers bother to implement imap if map was already there? ,.join(map(str,[1,2,3])) '1,2,3' Of course the result is the same, but map returns a list while itertools.imap returns an iterator. Fortunately, map will become lazy on Py3000: http://mail.python.org/pipermail/python-3000/2007-August/009207.html As you said, it won't be noticeable for short lists, but it's a good programming practice to use generators instead of lists (if you don't really need a list!) arnau -- http://mail.python.org/mailman/listinfo/python-list
World's most popular traveling destinations
http://world-traveling-destinations.blogspot.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: how to join array of integers?
Grant Edwards wrote: On 2007-09-15, Erik Jones [EMAIL PROTECTED] wrote: print ''.join([str(i) for i in [1,2,3]]) It's better to use generator comprehension instead of LC: ,.join(str(i) for i in [1, 2, 3]) Why is that? That entire expression must be evaluated to obtain the result, so what is the advantage of using a generator comprehension v. a list comprehension? The generator avoids creating the intermediate list -- it generates the intermediate values on the fly. For short sequences it probably doesn't matter much. For a very long list it's probably noticable. Not true. str.join() creates a list from the iterator if it is not already a list or a tuple. In Objects/stringobject.c, look at string_join(); it calls PySequence_Fast() on the argument. Looking in Objects/abstract.c, we see that PySequence_Fast() short-circuits lists and tuples but builds a full list from the iterable otherwise. map() seems to reliably be the fastest option, and list comprehensions seem to slightly edge out generator comprehensions if you do the timings. -- Robert Kern I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth. -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list
Latest software here!!!!!
http://freesoftwareupgrades.blogspot.com/ -- http://mail.python.org/mailman/listinfo/python-list
Python statements not forcing whitespace is messy?
Am I the only one that thinks that python statements should force whitespace before and after them? Right now this is not enforced and for an example these statements are valid printhello fooifbarelsefoobar for(x,y)in[(1,2),(3,4)]:print(x,y) [(y)for(x,y)in[(foo,2),(bar,4)]iffooin(x)] ...and so on. I know that writing code like this really shouldn't be done but wouldn't it be a good idea to enforce the use of whitespace around statements? (I wrote a short blog post about this here http://blog.buffis.com/?p=55 but thought I would post here as well to see what other developers think) - Björn Kempén -- http://mail.python.org/mailman/listinfo/python-list
Re: find and remove \ character from string
Konstantinos Pachopoulos wrote: Hi, i have the following string s and the following code, which doesn't successfully remove the \, but sucessfully removes the \\. s=Sad\\asd\asd newS= for i in s: ... if i!=\\: ... newS=newS+i ... newS 'Sadasd\x07sd' In actual fact there was just a single backslash in s to start with. If you read the documentation carefully at http://docs.python.org/ref/strings.html (though it's the language reference manual, and therefore not necessarily suitable reading for beginners) you will see that the \\ represents a single backslash character and \a represents an ASCII BEL character (whose decimal value is 7, and which the interpreter represents as the hexadecimal escape string \x07). So the characters in s were S a d \ a s d \x07 s d and you shoudl have seen len(s) == 10. As has already been mentioned, the shortest way to do what you want would be newS = s.replace(\\, ) I have also read the following, but i do not understand the ...and the remaining characters have been mapped through the given translation table, which must be a string of length 256. Can some explain? *translate*( table[, deletechars]) Return a copy of the string where all characters occurring in the optional argument deletechars are removed, and the remaining characters have been mapped through the given translation table, which must be a string of length 256. For Unicode objects, the translate() method does not accept the optional deletechars argument. Instead, it returns a copy of the s where all characters have been mapped through the given translation table which must be a mapping of Unicode ordinals to Unicode ordinals, Unicode strings or |None|. Unmapped characters are left untouched. Characters mapped to |None| are deleted. Note, a more flexible approach is to create a custom character mapping codec using the codecs http://docs.python.org/lib/module-codecs.html module (see encodings.cp1251 for an example). The translate() string method uses the numeric represetation of each character as an index into the translation table. So a null translation table can be constructed using t = .join(chr(i) for i in range(256)) t '\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\ x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !#$%\'()*+,-./0123456789:;=[EMAIL PROTECTED] DEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f\x80\x81\x82\x83 \x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97 \x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab \xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf \xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3 \xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7 \xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb \xfc\xfd\xfe\xff' (the above output will look a little screwy in the mail because of odd line wrapping). So hopefully you could then achieve the same effect (at vastly greater complexity than the first solution) using s=Sad\\asd\asd len(s) 10 newS = s.translate(t, \\) newS 'Sadasd\x07sd' You would probably only want to use that method if you were actually translating some of the characters at the same time. regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden Sorry, the dog ate my .sigline -- http://mail.python.org/mailman/listinfo/python-list
Re: (wxPython) wx.ProgressDialog - how to cancel out of?
On Sep 15, 12:57 am, Terry Carroll [EMAIL PROTECTED] wrote: I'm trying to use wx.ProgressBar, and the cancel button is not responding. Here is a simple program that exhibits the problem: # import wx import time max = 10 app = wx.PySimpleApp() dlg = wx.ProgressDialog(Progress dialog example, variables to be shown here, maximum = max, style = wx.PD_CAN_ABORT | wx.PD_CAN_SKIP #| wx.PD_APP_MODAL | wx.PD_ELAPSED_TIME | wx.PD_ESTIMATED_TIME | wx.PD_REMAINING_TIME ) keepGoing = True skip = False count = 0 while keepGoing and count max: count += 1 wx.MilliSleep(1000) #time.sleep(1) newtext = (before) count: %s, keepGoing: %s, skip: %s % \ (count, keepGoing, skip) print newtext (keepGoing, skip) = dlg.Update(count, newtext) newtext = (after) count: %s, keepGoing: %s, skip: %s % \ (count, keepGoing, skip) print newtext dlg.Destroy() # The dialog looks right when this runs, but What's right: I get a progress bar; it includes Skip and Cancel buttons; it shows 10 seconds of progress, and updates once per second with the variables' values on each iteration. What's wrong is that I can't get clicking on the Skip or Cancel buttons to have any effect. Instead, as soon as the dialog displays, I get an hourglass, and it doesn't matter what I click on. Here's what the print statements display, consistently, regardless of what I try to click or whether I click nothing at all: I:\pythontest1.py (before) count: 1, keepGoing: True, skip: False (after) count: 1, keepGoing: True, skip: False (before) count: 2, keepGoing: True, skip: False (after) count: 2, keepGoing: True, skip: True (before) count: 3, keepGoing: True, skip: True (after) count: 3, keepGoing: True, skip: True (before) count: 4, keepGoing: True, skip: True (after) count: 4, keepGoing: True, skip: True (before) count: 5, keepGoing: True, skip: True (after) count: 5, keepGoing: True, skip: True (before) count: 6, keepGoing: True, skip: True (after) count: 6, keepGoing: True, skip: True (before) count: 7, keepGoing: True, skip: True (after) count: 7, keepGoing: True, skip: True (before) count: 8, keepGoing: True, skip: True (after) count: 8, keepGoing: True, skip: True (before) count: 9, keepGoing: True, skip: True (after) count: 9, keepGoing: True, skip: True (before) count: 10, keepGoing: True, skip: True (after) count: 10, keepGoing: True, skip: True Two oddities here: 1) As I read the docs, the keepGoing variable should be set to True, unless I click on Cancel, in which case it should be set to False (which would end the loop). That doesn't happen. This is really what I'm most concerned here with. 2) The variable skip: set to False on the first iteration, and then set to True on subsequent iterations? Note that this happens even if no buttons are selected. This is just a weirdness to me, and not my main concern, but I thought I'd mention it in case it's relevant. You can see some variations in the commented-out code that I tried; they did not help. Relevant software and releases: OS: Windows XP Home Edition, Version 2002, SP2 Python: ActivePython 2.5.0.0 wxPython: 2.8.1.1 (msw-unicode) Any help appreciated. I'm not seeing the error either. The code looks very similar to the example in the demo. Maybe you can look at it and see the difference? The only thing I see is that the demo embeds the ProgressDialog into a Panel object. You should probably post this to the wxPython mailing group: http://wxpython.org/maillist.php Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: Python statements not forcing whitespace is messy?
buffi wrote: Am I the only one that thinks that python statements should force whitespace before and after them? Right now this is not enforced and for an example these statements are valid printhello fooifbarelsefoobar for(x,y)in[(1,2),(3,4)]:print(x,y) [(y)for(x,y)in[(foo,2),(bar,4)]iffooin(x)] ...and so on. I know that writing code like this really shouldn't be done but wouldn't it be a good idea to enforce the use of whitespace around statements? (I wrote a short blog post about this here http://blog.buffis.com/?p=55 but thought I would post here as well to see what other developers think) - Björn Kempén You may have a point--but on the other hand, this may be purposefully allowed help to recruit perl programmers. James -- http://mail.python.org/mailman/listinfo/python-list
calling locale.setlocale repeatedly
Hi, From http://www.pyzine.com/Issue008/Section_Articles/article_Encodings.html#guessing-the-encoding: The way to access the information about the normal encoding used on the current computer is through the locale module. Before using locale to retrieve the information you want, you need to call locale.setlocale(locale.LC_ALL, ''). Because of the sensitivity of the underlying C locale module on some platforms, this should only be done once. Why should the call locale.setlocale(locale.LC_ALL, '') only be made once? What exactly is the sensitivity of the underlying C locale module? Thanks, Michael -- http://mail.python.org/mailman/listinfo/python-list
Re: Python statements not forcing whitespace is messy?
buffi wrote: Am I the only one that thinks that python statements should force whitespace before and after them? Right now this is not enforced and for an example these statements are valid printhello fooifbarelsefoobar for(x,y)in[(1,2),(3,4)]:print(x,y) [(y)for(x,y)in[(foo,2),(bar,4)]iffooin(x)] ...and so on. On the other hand, this is just as bad: [ ( y ) for ( x , y ) in [ ( foo , 2 ) , ( bar , 4 ) ] if foo in ( x ) ] And I'd hate to have to remember all of the rules for what can go together and what can't, especially when it comes time to debug. No. I don't think it should be forced, but maybe put it in PEP8 or PEP3008. Also, the only thing I find thoroughly disagreeable in all of that mess, is the run-ins involving characters. The rest are at least clear at a glance what belongs where. Also, would you require the following? my_function (swallow='European') Because that is just an awful use of whitespace. Cheers, Cliff -- http://mail.python.org/mailman/listinfo/python-list
Re: Python statements not forcing whitespace is messy?
On 9/15/07, J. Cliff Dyer [EMAIL PROTECTED] wrote: And I'd hate to have to remember all of the rules for what can go together and what can't, especially when it comes time to debug. No. I don't think it should be forced, but maybe put it in PEP8 or PEP3008. It is: see Whitespace in Expressions and Statements in PEP 8. -- http://www.advogato.org/person/eopadoan/ Bookmarks: http://del.icio.us/edcrypt -- http://mail.python.org/mailman/listinfo/python-list
Re: find and remove \ character from string
On Sat, 15 Sep 2007 19:34:45 +0300, Konstantinos Pachopoulos wrote: Hi, i have the following string s and the following code, which doesn't successfully remove the \, but sucessfully removes the \\. There is no \\ in the string; there's one \ , which gets succesfully removed. s=Sad\\asd\asd When you write a string in the source code \\ gets changed to \ and \a gets changed to ASCII Bell (BEL) (that's what the docs say), which is a (non-printable) control code that is supposed to make the terminal beep. newS= for i in s: ... if i!=\\: Here, your test is true if i is not \ ... newS=newS+i ... newS 'Sadasd\x07sd' And here, you have a string containing no backslashes, but containing a character with ASCII code 7; it turns out that ASCII code 7 is the ASCII Bell, i.e., the character that you added to the string when you wrote '\a'. -- http://mail.python.org/mailman/listinfo/python-list
Re: Just bought Python in a Nutshell
Wow I just got it, and its nice doesn't even look used god damn. :D. On 9/14/07, Lamonte Harris [EMAIL PROTECTED] wrote: Lol, you bought it, dude theres not one left imho. When I bought it, it still said 1 More left Lol...mines should be her no less then a hour -.-... Taking SO LONG. On 9/14/07, Danyelle Gragsone [EMAIL PROTECTED] wrote: Luckily that site still had one left .. so i brought it :D. I can always use another good and CHEAP book. Danyelle -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Just bought Python in a Nutshell
awesome! I should see it in about 2 wks.. im poor. So I choose super snail mail. LN -- http://mail.python.org/mailman/listinfo/python-list
how could change backcolor of console?
Hi,everyone: I am a c programmer,and want using Python instead of C I can change backcolor using C,like this: textbackground(color); How can I do in Python? Best regards 点 击 此 处!免 费 试 玩 07 年 最 受 期 待 的 游 戏 大 作 ! -- http://mail.python.org/mailman/listinfo/python-list
problems using pythom tempfile module
Hello everyone, I'm trying to test the tempfile module with the following script, which basically creates a temporary file, fills the file with some test data and prints it. import tempfile t = tempfile.TemporaryFile() t.write(lalalala) t.flush() print t.read() Unfortunately, the print statement gives me an empty string. Can somebody tell me what I'm doing wrong ? regards Samir -- http://mail.python.org/mailman/listinfo/python-list
Re: Python statements not forcing whitespace is messy?
On Sep 15, 10:11 pm, J. Cliff Dyer [EMAIL PROTECTED] wrote: buffi wrote: Am I the only one that thinks that python statements should force whitespace before and after them? Right now this is not enforced and for an example these statements are valid printhello fooifbarelsefoobar for(x,y)in[(1,2),(3,4)]:print(x,y) [(y)for(x,y)in[(foo,2),(bar,4)]iffooin(x)] ...and so on. On the other hand, this is just as bad: [ ( y ) for ( x , y ) in [ ( foo , 2 ) , ( bar , 4 ) ] if foo in ( x ) ] And I'd hate to have to remember all of the rules for what can go together and what can't, especially when it comes time to debug. No. I don't think it should be forced, but maybe put it in PEP8 or PEP3008. Also, the only thing I find thoroughly disagreeable in all of that mess, is the run-ins involving characters. The rest are at least clear at a glance what belongs where. Also, would you require the following? my_function (swallow='European') Because that is just an awful use of whitespace. Cheers, Cliff I believe that having whitespace around the builtin statements, and having whitespace around everything is pretty different. There would be no downside whatsoever to enforcing this, except for backwards incompatibility (which is a rather huge downside but well... py3k is gonna break everything anyways). There obviously shouldnt be any limit to the maximum amount of whitespace used around statements (due to formatting and so on), but allowing stuff like printhello is just horrible. - Björn Kempén -- http://mail.python.org/mailman/listinfo/python-list
Re: how could change backcolor of console?
On Sep 15, 3:55 pm, [EMAIL PROTECTED] wrote: Hi,everyone: I am a c programmer,and want using Python instead of C I can change backcolor using C,like this: textbackground(color); How can I do in Python? Best regards 点 击 此 处!免 费 试 玩 07 年 最 受 期 待 的 游 戏 大 作 ! textbackground() is not part of the C programming language but rather a part of an rather old module for msdos. http://en.wikipedia.org/wiki/Conio.h If you want terminal colors in python you can use the curses module but I doubt that it will work in windows. http://docs.python.org/lib/module-curses.html -- http://mail.python.org/mailman/listinfo/python-list
Re: problems using pythom tempfile module
On Sep 15, 11:11 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hello everyone, I'm trying to test the tempfile module with the following script, which basically creates a temporary file, fills the file with some test data and prints it. import tempfile t = tempfile.TemporaryFile() t.write(lalalala) t.flush() print t.read() Unfortunately, the print statement gives me an empty string. Can somebody tell me what I'm doing wrong ? regards Samir Do a t.seek(0) before you do the read to rewind the file and then it should work. -- http://mail.python.org/mailman/listinfo/python-list
curses: x, y positioning
I can't see to get any y, x coordinates to work with curses. Here is an example: import curses def my_program(screen): while True: ch = screen.getch() if ch == ord(q): break if ch = 255: screen.addstr(30, 10, *%s* % chr(ch)) screen.refresh() curses.wrapper(my_program) Here is the result: Traceback (most recent call last): File 2pythontest.py, line 12, in ? curses.wrapper(my_program) File /Library/Frameworks/Python.framework/Versions/2.4//lib/ python2.4/curses/wrapper.py, line 44, in wrapper return func(stdscr, *args, **kwds) File 2pythontest.py, line 9, in my_program screen.addstr(30, 10, *%s* % chr(ch)) _curses.error: addstr() returned ERR -- http://mail.python.org/mailman/listinfo/python-list
Patent application
US patent application services: http://www.pinskylaw.ca/Practice/OntarioTorontoLawyers/business_patents.htm -- http://mail.python.org/mailman/listinfo/python-list
Re: Python statements not forcing whitespace is messy?
buffi wrote: On Sep 15, 10:11 pm, J. Cliff Dyer [EMAIL PROTECTED] wrote: buffi wrote: Am I the only one that thinks that python statements should force whitespace before and after them? Right now this is not enforced and for an example these statements are valid printhello fooifbarelsefoobar for(x,y)in[(1,2),(3,4)]:print(x,y) [(y)for(x,y)in[(foo,2),(bar,4)]iffooin(x)] ...and so on. On the other hand, this is just as bad: [ ( y ) for ( x , y ) in [ ( foo , 2 ) , ( bar , 4 ) ] if foo in ( x ) ] And I'd hate to have to remember all of the rules for what can go together and what can't, especially when it comes time to debug. No. I don't think it should be forced, but maybe put it in PEP8 or PEP3008. Also, the only thing I find thoroughly disagreeable in all of that mess, is the run-ins involving characters. The rest are at least clear at a glance what belongs where. Also, would you require the following? my_function (swallow='European') Because that is just an awful use of whitespace. Cheers, Cliff I believe that having whitespace around the builtin statements, and having whitespace around everything is pretty different. There would be no downside whatsoever to enforcing this, except for backwards incompatibility (which is a rather huge downside but well... py3k is gonna break everything anyways). There obviously shouldnt be any limit to the maximum amount of whitespace used around statements (due to formatting and so on), but allowing stuff like printhello is just horrible. If you don't like it then don't write it. I've been reading this group on and off for about ten years and I believe your email is the first to point out that this is possible. Clearly it isn't something that happens a lot, and I don't know why you have a bug up your ass about it, as the Americans say. The Python philosophy is to be permissive, and to expect individual users to write readable Python. Since they obviously do (one message in ten years providing a counter-example) I think you are wasting your time and energy on this. regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden Sorry, the dog ate my .sigline -- http://mail.python.org/mailman/listinfo/python-list
Needless copying in iterations?
Hello all, I was staring at a segment of code that looked like this today: for something in stuff[x:y]: whatever(something) and was wondering if the compiler really made a copy of the slice from stuff as the code seems to suggest, or does it find some way to produce an iterator without the need to make a copy (if stuff is a built-in sequence type)? Or would it be more efficient to do the more clumsy (in my opinion): for i in xrange(x, y): whatever(stuff[i]) James -- http://mail.python.org/mailman/listinfo/python-list
Re: Python statements not forcing whitespace is messy?
On Sep 15, 11:49 pm, Steve Holden [EMAIL PROTECTED] wrote: buffi wrote: On Sep 15, 10:11 pm, J. Cliff Dyer [EMAIL PROTECTED] wrote: buffi wrote: Am I the only one that thinks that python statements should force whitespace before and after them? Right now this is not enforced and for an example these statements are valid printhello fooifbarelsefoobar for(x,y)in[(1,2),(3,4)]:print(x,y) [(y)for(x,y)in[(foo,2),(bar,4)]iffooin(x)] ...and so on. On the other hand, this is just as bad: [ ( y ) for ( x , y ) in [ ( foo , 2 ) , ( bar , 4 ) ] if foo in ( x ) ] And I'd hate to have to remember all of the rules for what can go together and what can't, especially when it comes time to debug. No. I don't think it should be forced, but maybe put it in PEP8 or PEP3008. Also, the only thing I find thoroughly disagreeable in all of that mess, is the run-ins involving characters. The rest are at least clear at a glance what belongs where. Also, would you require the following? my_function (swallow='European') Because that is just an awful use of whitespace. Cheers, Cliff I believe that having whitespace around the builtin statements, and having whitespace around everything is pretty different. There would be no downside whatsoever to enforcing this, except for backwards incompatibility (which is a rather huge downside but well... py3k is gonna break everything anyways). There obviously shouldnt be any limit to the maximum amount of whitespace used around statements (due to formatting and so on), but allowing stuff like printhello is just horrible. If you don't like it then don't write it. I've been reading this group on and off for about ten years and I believe your email is the first to point out that this is possible. Clearly it isn't something that happens a lot, and I don't know why you have a bug up your ass about it, as the Americans say. The Python philosophy is to be permissive, and to expect individual users to write readable Python. Since they obviously do (one message in ten years providing a counter-example) I think you are wasting your time and energy on this. regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden Sorry, the dog ate my .sigline I actually found out about this myself while grading student labs. I myself didn't even know that you could write statements like this until then, but since some students does it that means that there should be other people out there as well that does it. And I can't say that I agree about The Python philosophy being permissive, and to expect individual users to write readable Python. Python enforces proper indentation which I think is a great idea since I'm used to reading horribly indented code by others. I would love to see this extended to enforce proper whitespacing for statements. There should be one-and preferably only one-obvious way to do it. is a phrase that is usually considered pythonic, and I think that it should also apply a bit when it comes to coding conventions. - Björn Kempén -- http://mail.python.org/mailman/listinfo/python-list
Re: Python statements not forcing whitespace is messy?
Steve Holden wrote: I don't know why you have a bug up your ass about it, as the Americans say. I think most Americans say wild hare up your ass. We do not, in fact, say wild hair up your ass. Many of us can testify that a hair up one's ass would be nothing terribly unusual and would go completely unnoticed under most circumstances. Also, some Americans erroneously say hair's breath, and others think they mean hare's breath (which might be tiny, but diffuses quickly to theoretically infinite volume). In reality, however, they mean hair's breadth--which is quite small indeed! For instance, a hair's breadth is far smaller than a hare's breath (even at the exact moment of respiration). James -- http://mail.python.org/mailman/listinfo/python-list
Re: Needless copying in iterations?
On Sep 15, 11:58 pm, James Stroud [EMAIL PROTECTED] wrote: Hello all, I was staring at a segment of code that looked like this today: for something in stuff[x:y]: whatever(something) and was wondering if the compiler really made a copy of the slice from stuff as the code seems to suggest, or does it find some way to produce an iterator without the need to make a copy (if stuff is a built-in sequence type)? Or would it be more efficient to do the more clumsy (in my opinion): for i in xrange(x, y): whatever(stuff[i]) James itertools.islice does what you want import itertools for something in itertools.islice(stuff, x, y): whatever(something) -- http://mail.python.org/mailman/listinfo/python-list
Re: problems using pythom tempfile module
On Sep 15, 5:24 pm, buffi [EMAIL PROTECTED] wrote: On Sep 15, 11:11 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hello everyone, I'm trying to test the tempfile module with the following script, which basically creates a temporary file, fills the file with some test data and prints it. import tempfile t = tempfile.TemporaryFile() t.write(lalalala) t.flush() print t.read() Unfortunately, the print statement gives me an empty string. Can somebody tell me what I'm doing wrong ? regards Samir Do a t.seek(0) before you do the read to rewind the file and then it should work. Ok, this really worked. Can you elaborate why I have to insert this statement? -- http://mail.python.org/mailman/listinfo/python-list
Re: Needless copying in iterations?
buffi wrote: On Sep 15, 11:58 pm, James Stroud [EMAIL PROTECTED] wrote: Hello all, I was staring at a segment of code that looked like this today: for something in stuff[x:y]: whatever(something) and was wondering if the compiler really made a copy of the slice from stuff as the code seems to suggest, or does it find some way to produce an iterator without the need to make a copy (if stuff is a built-in sequence type)? Or would it be more efficient to do the more clumsy (in my opinion): for i in xrange(x, y): whatever(stuff[i]) James itertools.islice does what you want import itertools for something in itertools.islice(stuff, x, y): whatever(something) Thanks buffi! So I guess the interpreter does no optimization in the latter? James -- http://mail.python.org/mailman/listinfo/python-list
Re: Needless copying in iterations?
On Sep 16, 12:20 am, James Stroud [EMAIL PROTECTED] wrote: buffi wrote: On Sep 15, 11:58 pm, James Stroud [EMAIL PROTECTED] wrote: Hello all, I was staring at a segment of code that looked like this today: for something in stuff[x:y]: whatever(something) and was wondering if the compiler really made a copy of the slice from stuff as the code seems to suggest, or does it find some way to produce an iterator without the need to make a copy (if stuff is a built-in sequence type)? Or would it be more efficient to do the more clumsy (in my opinion): for i in xrange(x, y): whatever(stuff[i]) James itertools.islice does what you want import itertools for something in itertools.islice(stuff, x, y): whatever(something) Thanks buffi! So I guess the interpreter does no optimization in the latter? James No, as far as I know it makes a new list out of the slice when you do it like for something in stuff[x:y] - Björn Kempén -- http://mail.python.org/mailman/listinfo/python-list
Re: Needless copying in iterations?
This is a case where its up to the type involved. For example, xrange() slices the way you want but range() does not. Maybe a type would return for slices a proxy object that got the value by index or maybe it knows that it makes more sense to give you a copy because changes during the iteration should not be reflected in the iteration. It would be really easy to make a generic slicer. On 9/15/07, James Stroud [EMAIL PROTECTED] wrote: Hello all, I was staring at a segment of code that looked like this today: for something in stuff[x:y]: whatever(something) and was wondering if the compiler really made a copy of the slice from stuff as the code seems to suggest, or does it find some way to produce an iterator without the need to make a copy (if stuff is a built-in sequence type)? Or would it be more efficient to do the more clumsy (in my opinion): for i in xrange(x, y): whatever(stuff[i]) James -- http://mail.python.org/mailman/listinfo/python-list -- Read my blog! I depend on your acceptance of my opinion! I am interesting! http://ironfroggy-code.blogspot.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: (wxPython) wx.ProgressDialog - how to cancel out of?
On Sep 14, 11:57 pm, Terry Carroll [EMAIL PROTECTED] wrote: I'm trying to use wx.ProgressBar, and the cancel button is not responding. Here is a simple program that exhibits the problem: # import wx import time max = 10 app = wx.PySimpleApp() dlg = wx.ProgressDialog(Progress dialog example, variables to be shown here, maximum = max, style = wx.PD_CAN_ABORT | wx.PD_CAN_SKIP #| wx.PD_APP_MODAL | wx.PD_ELAPSED_TIME | wx.PD_ESTIMATED_TIME | wx.PD_REMAINING_TIME ) keepGoing = True skip = False count = 0 while keepGoing and count max: count += 1 wx.MilliSleep(1000) #time.sleep(1) newtext = (before) count: %s, keepGoing: %s, skip: %s % \ (count, keepGoing, skip) print newtext (keepGoing, skip) = dlg.Update(count, newtext) newtext = (after) count: %s, keepGoing: %s, skip: %s % \ (count, keepGoing, skip) print newtext dlg.Destroy() # The dialog looks right when this runs, but What's right: I get a progress bar; it includes Skip and Cancel buttons; it shows 10 seconds of progress, and updates once per second with the variables' values on each iteration. What's wrong is that I can't get clicking on the Skip or Cancel buttons to have any effect. Instead, as soon as the dialog displays, I get an hourglass, and it doesn't matter what I click on. Here's what the print statements display, consistently, regardless of what I try to click or whether I click nothing at all: I:\pythontest1.py (before) count: 1, keepGoing: True, skip: False (after) count: 1, keepGoing: True, skip: False (before) count: 2, keepGoing: True, skip: False (after) count: 2, keepGoing: True, skip: True (before) count: 3, keepGoing: True, skip: True (after) count: 3, keepGoing: True, skip: True (before) count: 4, keepGoing: True, skip: True (after) count: 4, keepGoing: True, skip: True (before) count: 5, keepGoing: True, skip: True (after) count: 5, keepGoing: True, skip: True (before) count: 6, keepGoing: True, skip: True (after) count: 6, keepGoing: True, skip: True (before) count: 7, keepGoing: True, skip: True (after) count: 7, keepGoing: True, skip: True (before) count: 8, keepGoing: True, skip: True (after) count: 8, keepGoing: True, skip: True (before) count: 9, keepGoing: True, skip: True (after) count: 9, keepGoing: True, skip: True (before) count: 10, keepGoing: True, skip: True (after) count: 10, keepGoing: True, skip: True Two oddities here: 1) As I read the docs, the keepGoing variable should be set to True, unless I click on Cancel, in which case it should be set to False (which would end the loop). That doesn't happen. This is really what I'm most concerned here with. 2) The variable skip: set to False on the first iteration, and then set to True on subsequent iterations? Note that this happens even if no buttons are selected. This is just a weirdness to me, and not my main concern, but I thought I'd mention it in case it's relevant. You can see some variations in the commented-out code that I tried; they did not help. Relevant software and releases: OS: Windows XP Home Edition, Version 2002, SP2 Python: ActivePython 2.5.0.0 wxPython: 2.8.1.1 (msw-unicode) Any help appreciated. Supposedly a progress dialog does not work well on its own because events get screwed up when there isn't a main loop. Try this: import wx app = wx.PySimpleApp() win = wx.Frame(None, -1, Test Progress Dialog) button = wx.Button(win, -1, start download) def on_button_click(evt): max = 10 dialog = wx.ProgressDialog( Loading, progress:, max, style = wx.PD_CAN_ABORT |wx.PD_ELAPSED_TIME |wx.PD_ESTIMATED_TIME |wx.PD_REMAINING_TIME ) keep_going = True skip = False count = 0 while keep_going and (count max): count += 1 wx.MilliSleep(1000) (keep_going, skip) = dialog.Update(count) print skip dialog.Destroy() button.Bind(wx.EVT_BUTTON, on_button_click) win.Show() app.MainLoop() -- http://mail.python.org/mailman/listinfo/python-list
Re: Needless copying in iterations?
On Sep 16, 12:25 am, Calvin Spealman [EMAIL PROTECTED] wrote: This is a case where its up to the type involved. For example, xrange() slices the way you want but range() does not. Coul you explain this? As far as I know you can't slice a xrange - Björn Kempén -- http://mail.python.org/mailman/listinfo/python-list
Re: how to join array of integers?
On 2007-09-15, Robert Kern [EMAIL PROTECTED] wrote: Grant Edwards wrote: On 2007-09-15, Erik Jones [EMAIL PROTECTED] wrote: print ''.join([str(i) for i in [1,2,3]]) It's better to use generator comprehension instead of LC: ,.join(str(i) for i in [1, 2, 3]) Why is that? That entire expression must be evaluated to obtain the result, so what is the advantage of using a generator comprehension v. a list comprehension? The generator avoids creating the intermediate list -- it generates the intermediate values on the fly. For short sequences it probably doesn't matter much. For a very long list it's probably noticable. Not true. str.join() creates a list from the iterator if it is not already a list or a tuple. So the iterator avoids creating an intermediate list, but the join method goes ahead and does it anyway? In Objects/stringobject.c, look at string_join(); it calls PySequence_Fast() on the argument. Looking in Objects/abstract.c, we see that PySequence_Fast() short-circuits lists and tuples but builds a full list from the iterable otherwise. So what's the point of iterables if code is going to do stuff like that when it wants to iterate over a sequence? map() seems to reliably be the fastest option, Which is apparently going away in favor of the slower iterator approach? and list comprehensions seem to slightly edge out generator comprehensions if you do the timings. -- Grant Edwards grante Yow! Clear the at laundromat!! This visi.comwhirl-o-matic just had a nuclear meltdown!! -- http://mail.python.org/mailman/listinfo/python-list
Re: problems using pythom tempfile module
[EMAIL PROTECTED] wrote: On Sep 15, 5:24 pm, buffi [EMAIL PROTECTED] wrote: On Sep 15, 11:11 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hello everyone, I'm trying to test the tempfile module with the following script, which basically creates a temporary file, fills the file with some test data and prints it. import tempfile t = tempfile.TemporaryFile() t.write(lalalala) t.flush() print t.read() Unfortunately, the print statement gives me an empty string. Can somebody tell me what I'm doing wrong ? regards Samir Do a t.seek(0) before you do the read to rewind the file and then it should work. Ok, this really worked. Can you elaborate why I have to insert this statement? Each file has a current position. As you write a file the current position moves to stay just ahead of what's been written. So if you read it without resetting the current position (back to the beginning with seek(0)) you will get an immediate end of file (i.e. 0 bytes) returned. regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden Sorry, the dog ate my .sigline -- http://mail.python.org/mailman/listinfo/python-list
Re: problems using pythom tempfile module
Pretend that you have a number that is always pointing somewhere in your temporary file. It starts a 0. If you then write lalalala (8 characters) it will point after these at position 8, so that you can write more stuff after your previous text later by calling write. The read method reads all the data from the current position of the pointer to the end of the file. If you simply call it after writing, you wont get anything since you are already at the end of the file. Therefore you rewind the pointer back to the start by calling seek which takes the position in the file to go to... your_file.seek(0) returns you to the start of the file to read all of its data - Björn Kempén -- http://mail.python.org/mailman/listinfo/python-list
Re: (wxPython) wx.ProgressDialog - how to cancel out of?
Terry Carroll wrote: I'm trying to use wx.ProgressBar, and the cancel button is not responding. Here is a simple program that exhibits the problem: # import wx import time max = 10 app = wx.PySimpleApp() dlg = wx.ProgressDialog(Progress dialog example, variables to be shown here, maximum = max, style = wx.PD_CAN_ABORT | wx.PD_CAN_SKIP #| wx.PD_APP_MODAL | wx.PD_ELAPSED_TIME | wx.PD_ESTIMATED_TIME | wx.PD_REMAINING_TIME ) keepGoing = True skip = False count = 0 while keepGoing and count max: count += 1 wx.MilliSleep(1000) #time.sleep(1) newtext = (before) count: %s, keepGoing: %s, skip: %s % \ (count, keepGoing, skip) print newtext (keepGoing, skip) = dlg.Update(count, newtext) newtext = (after) count: %s, keepGoing: %s, skip: %s % \ (count, keepGoing, skip) print newtext dlg.Destroy() # The dialog looks right when this runs, but What's right: I get a progress bar; it includes Skip and Cancel buttons; it shows 10 seconds of progress, and updates once per second with the variables' values on each iteration. What's wrong is that I can't get clicking on the Skip or Cancel buttons to have any effect. Instead, as soon as the dialog displays, I get an hourglass, and it doesn't matter what I click on. Here's what the print statements display, consistently, regardless of what I try to click or whether I click nothing at all: I:\pythontest1.py (before) count: 1, keepGoing: True, skip: False (after) count: 1, keepGoing: True, skip: False (before) count: 2, keepGoing: True, skip: False (after) count: 2, keepGoing: True, skip: True (before) count: 3, keepGoing: True, skip: True (after) count: 3, keepGoing: True, skip: True (before) count: 4, keepGoing: True, skip: True (after) count: 4, keepGoing: True, skip: True (before) count: 5, keepGoing: True, skip: True (after) count: 5, keepGoing: True, skip: True (before) count: 6, keepGoing: True, skip: True (after) count: 6, keepGoing: True, skip: True (before) count: 7, keepGoing: True, skip: True (after) count: 7, keepGoing: True, skip: True (before) count: 8, keepGoing: True, skip: True (after) count: 8, keepGoing: True, skip: True (before) count: 9, keepGoing: True, skip: True (after) count: 9, keepGoing: True, skip: True (before) count: 10, keepGoing: True, skip: True (after) count: 10, keepGoing: True, skip: True Two oddities here: 1) As I read the docs, the keepGoing variable should be set to True, unless I click on Cancel, in which case it should be set to False (which would end the loop). That doesn't happen. This is really what I'm most concerned here with. 2) The variable skip: set to False on the first iteration, and then set to True on subsequent iterations? Note that this happens even if no buttons are selected. This is just a weirdness to me, and not my main concern, but I thought I'd mention it in case it's relevant. You can see some variations in the commented-out code that I tried; they did not help. Relevant software and releases: OS: Windows XP Home Edition, Version 2002, SP2 Python: ActivePython 2.5.0.0 wxPython: 2.8.1.1 (msw-unicode) Any help appreciated. Or, if you want the progress dialog to start when your app starts-- rather than after a user clicks on a button--you can use a short timer: import wx app = wx.PySimpleApp() win = wx.Frame(None, -1, Test Progress Dialog) timer = wx.Timer(win) #win.Bind(wx.EVT_TIMER, on_timer_expiry, timer) def on_timer_expiry(evt): max = 10 dialog = wx.ProgressDialog( Loading, progress:, max, style = wx.PD_CAN_ABORT |wx.PD_ELAPSED_TIME |wx.PD_ESTIMATED_TIME |wx.PD_REMAINING_TIME ) keep_going = True skip = False count = 0 while keep_going and (count max): count += 1 wx.MilliSleep(1000) (keep_going, skip) = dialog.Update(count) print skip dialog.Destroy() timer.Stop() win.Bind(wx.EVT_TIMER, on_timer_expiry, timer) timer.Start(1000) win.Show() app.MainLoop() -- http://mail.python.org/mailman/listinfo/python-list
Re: (wxPython) wx.ProgressDialog - how to cancel out of?
On Sep 14, 11:57 pm, Terry Carroll [EMAIL PROTECTED] wrote: I'm trying to use wx.ProgressBar, and the cancel button is not responding. Here is a simple program that exhibits the problem: # import wx import time max = 10 app = wx.PySimpleApp() dlg = wx.ProgressDialog(Progress dialog example, variables to be shown here, maximum = max, style = wx.PD_CAN_ABORT | wx.PD_CAN_SKIP #| wx.PD_APP_MODAL | wx.PD_ELAPSED_TIME | wx.PD_ESTIMATED_TIME | wx.PD_REMAINING_TIME ) keepGoing = True skip = False count = 0 while keepGoing and count max: count += 1 wx.MilliSleep(1000) #time.sleep(1) newtext = (before) count: %s, keepGoing: %s, skip: %s % \ (count, keepGoing, skip) print newtext (keepGoing, skip) = dlg.Update(count, newtext) newtext = (after) count: %s, keepGoing: %s, skip: %s % \ (count, keepGoing, skip) print newtext dlg.Destroy() # The dialog looks right when this runs, but What's right: I get a progress bar; it includes Skip and Cancel buttons; it shows 10 seconds of progress, and updates once per second with the variables' values on each iteration. What's wrong is that I can't get clicking on the Skip or Cancel buttons to have any effect. Instead, as soon as the dialog displays, I get an hourglass, and it doesn't matter what I click on. Here's what the print statements display, consistently, regardless of what I try to click or whether I click nothing at all: I:\pythontest1.py (before) count: 1, keepGoing: True, skip: False (after) count: 1, keepGoing: True, skip: False (before) count: 2, keepGoing: True, skip: False (after) count: 2, keepGoing: True, skip: True (before) count: 3, keepGoing: True, skip: True (after) count: 3, keepGoing: True, skip: True (before) count: 4, keepGoing: True, skip: True (after) count: 4, keepGoing: True, skip: True (before) count: 5, keepGoing: True, skip: True (after) count: 5, keepGoing: True, skip: True (before) count: 6, keepGoing: True, skip: True (after) count: 6, keepGoing: True, skip: True (before) count: 7, keepGoing: True, skip: True (after) count: 7, keepGoing: True, skip: True (before) count: 8, keepGoing: True, skip: True (after) count: 8, keepGoing: True, skip: True (before) count: 9, keepGoing: True, skip: True (after) count: 9, keepGoing: True, skip: True (before) count: 10, keepGoing: True, skip: True (after) count: 10, keepGoing: True, skip: True Two oddities here: 1) As I read the docs, the keepGoing variable should be set to True, unless I click on Cancel, in which case it should be set to False (which would end the loop). That doesn't happen. This is really what I'm most concerned here with. 2) The variable skip: set to False on the first iteration, and then set to True on subsequent iterations? Note that this happens even if no buttons are selected. This is just a weirdness to me, and not my main concern, but I thought I'd mention it in case it's relevant. You can see some variations in the commented-out code that I tried; they did not help. Relevant software and releases: OS: Windows XP Home Edition, Version 2002, SP2 Python: ActivePython 2.5.0.0 wxPython: 2.8.1.1 (msw-unicode) Any help appreciated. And here's a version that hides the frame and shows it only after the progress dialog has finished or been cancelled: import wx app = wx.PySimpleApp() win = wx.Frame(None, -1, Test Progress Dialog) timer = wx.Timer(win) #win.Bind(wx.EVT_TIMER, on_timer_expiry, timer) def on_timer_expiry(evt): max = 10 dialog = wx.ProgressDialog( Loading, progress:, max, style = wx.PD_CAN_ABORT |wx.PD_CAN_SKIP |wx.PD_ELAPSED_TIME |wx.PD_ESTIMATED_TIME |wx.PD_REMAINING_TIME ) keep_going = True skip = False count = 0 while keep_going and (count max): count += 1 wx.MilliSleep(1000) (keep_going, skip) = dialog.Update(count) print skip dialog.Destroy() timer.Stop() win.Show() # win.Bind(wx.EVT_TIMER, on_timer_expiry, timer) timer.Start(1000) #win.Show() app.MainLoop() -- http://mail.python.org/mailman/listinfo/python-list
Re: Python statements not forcing whitespace is messy?
On 16/09/2007 8:11 AM, James Stroud wrote: Steve Holden wrote: I don't know why you have a bug up your ass about it, as the Americans say. I think most Americans say wild hare up your ass. The essence of Steve's point appears to be that the OP has ridden into town to preach a misguided crusade against the heretofore-unknown non-spacing heretics. It also seems to be alleged that at some stage, the OP's donkey has been severely molested by some malevolent fauna; I am having difficulty understanding the connection between the two themes, and which is cause and which is effect. Enlightenment, please. -- http://mail.python.org/mailman/listinfo/python-list
Re: (wxPython) wx.ProgressDialog - how to cancel out of?
Terry Carroll wrote: 2) The variable skip: set to False on the first iteration, and then set to True on subsequent iterations? Note that this happens even if no buttons are selected. This is just a weirdness to me, and not my main concern, but I thought I'd mention it in case it's relevant. The docs say: wx.PD_CAN_SKIP This flag tells the dialog that it should have a Skip button which the user may press. If this happens, the next call to Update() will return True in the second component of its return value. What I'm seeing is: the second item in the tuple returned by Update() is False if the skip button wasn't clicked and it's True for one return value when the skip button was clicked, then the value reverts back to False when Update() returns the next time. -- http://mail.python.org/mailman/listinfo/python-list