Re: Py 3: How to switch application to Unicode strings?

2010-01-19 Thread Mark Tolonen
"Gnarlodious" wrote in message news:646ab38b-0710-4d31-b9e1-8a6ee7bfa...@21g2000yqj.googlegroups.com... Well, Python 3 is supposed to be all Unicode by default. I shouldn't even need to say # coding:UTF-8 Yes, in Python 3, an absence of a 'coding' line assumes UTF-8. And, the file is saved

Re: Performance of lists vs. list comprehensions

2010-01-19 Thread Stefan Behnel
Steven D'Aprano, 20.01.2010 07:12: > On Wed, 20 Jan 2010 05:25:22 +0100, Alf P. Steinbach wrote: >> That is a good argument for not doing the expanding buffer thing. >> But such buffers may be generally present anyway, resulting from >> optimization of "+". > > As near as I can determine, the CPyt

Best way to convert sequence of bytes to long integer

2010-01-19 Thread Steven D'Aprano
I have a byte string (Python 2.x string), e.g.: s = "g%$f yg\n1\05" assert len(s) == 10 I wish to convert it to a long integer, treating it as base-256. Currently I'm using: def makelong(s): n = 0 for c in s: n *= 256 n += ord(c) return n which gives: >>> makelong

Re: What is a list compression in Python?

2010-01-19 Thread Stephen Hansen
On Tue, Jan 19, 2010 at 11:32 PM, Stephen Hansen wrote: > > I really don't think you can call comprehensions as mere syntactic sugar, > Err, I misspoke. I don't really think you can call comprehensions mere syntactic sugar /for map and filter/. It IS mere syntactic sugar for a "for loop". But

Re: What is a list compression in Python?

2010-01-19 Thread Stephen Hansen
On Tue, Jan 19, 2010 at 10:39 PM, Rainer Grimm wrote: > Hallo, > you can also look at list comprehension as syntactic sugar for the > functions map and filter. The two functions from the functional world > can be expressed in a comprehensive way with list comprehension. > >>> [x**2 for x in range

Re: Py 3: How to switch application to Unicode strings?

2010-01-19 Thread Arnaud Delobelle
Gnarlodious writes: > Well, Python 3 is supposed to be all Unicode by default. I shouldn't > even need to say > # coding:UTF-8 > > And, the file is saved as Unicode. > When a filed is saved, shouldn't it be in a specific encoding? I don't see how you can save your file 'as unicode'. You should

Re: setattr() oddness

2010-01-19 Thread Dieter Maurer
Steven D'Aprano writes on 18 Jan 2010 06:47:59 GMT: > On Mon, 18 Jan 2010 07:25:58 +0100, Dieter Maurer wrote: > > > Lie Ryan writes on Sat, 16 Jan 2010 19:37:29 +1100: > >> On 01/16/10 10:10, Sean DiZazzo wrote: > >> > Interesting. I can understand the "would take time" argument, but I > >> >

Re: What is a list compression in Python?

2010-01-19 Thread Rainer Grimm
Hallo, you can also look at list comprehension as syntactic sugar for the functions map and filter. The two functions from the functional world can be expressed in a comprehensive way with list comprehension. >>> [x**2 for x in range(10) ] == map ( lambda x: x*x, range(10)) True >>> [ x for x in ra

Re: Performance of lists vs. list comprehensions

2010-01-19 Thread Steven D'Aprano
On Wed, 20 Jan 2010 05:25:22 +0100, Alf P. Steinbach wrote: > * Steven D'Aprano: >> On Tue, 19 Jan 2010 16:20:42 -0500, Gerald Britton wrote: >> >>> That's surprising. I wouldn't implement it that way at all. I'd use a >>> dynamically-expanding buffer as I suggested. That way you get a >>> sing

Re: Python IDE for MacOS-X

2010-01-19 Thread Tim Arnold
"Jean Guillaume Pyraksos" wrote in message news:wissme-9248e1.08090319012...@news.free.fr... > What's the best one to use with beginners ? > Something with integrated syntax editor, browser of doc... > Thanks, > >JG eclipse + pydev works well for me. --Tim Arnold -- http://mail.python.org

Re: Py 3: How to switch application to Unicode strings?

2010-01-19 Thread Stephen Hansen
On Tue, Jan 19, 2010 at 8:16 PM, Gnarlodious wrote: > Well, Python 3 is supposed to be all Unicode by default. I shouldn't > even need to say > # coding:UTF-8 > > And, the file is saved as Unicode. > > There are many mentions of this error found by Google, but none seen > to clearly say what the

Re: Performance of lists vs. list comprehensions

2010-01-19 Thread Alf P. Steinbach
* Steven D'Aprano: On Tue, 19 Jan 2010 16:20:42 -0500, Gerald Britton wrote: That's surprising. I wouldn't implement it that way at all. I'd use a dynamically-expanding buffer as I suggested. That way you get a single pass and don't have to calculate anything before you begin. In the best ca

Re: Py 3: How to switch application to Unicode strings?

2010-01-19 Thread Gnarlodious
Well, Python 3 is supposed to be all Unicode by default. I shouldn't even need to say # coding:UTF-8 And, the file is saved as Unicode. There are many mentions of this error found by Google, but none seen to clearly say what the problem is or how to fix it. FYI, the problem line says: cursor.ex

Re: Py 3: How to switch application to Unicode strings?

2010-01-19 Thread Mark Tolonen
"Stephen Hansen" wrote in message news:7a9c25c21001191156j46a7fdadt58b728477b85e...@mail.gmail.com... On Tue, Jan 19, 2010 at 7:50 AM, Gnarlodious wrote: I am using Python 3, getting an error from SQLite: sqlite3.ProgrammingError: You must not use 8-bit bytestrings unless you use a text_f

Re: Performance of lists vs. list comprehensions

2010-01-19 Thread Steven D'Aprano
On Tue, 19 Jan 2010 16:20:42 -0500, Gerald Britton wrote: > That's surprising. I wouldn't implement it that way at all. I'd use a > dynamically-expanding buffer as I suggested. That way you get a single > pass and don't have to calculate anything before you begin. In the best > case, you'd use

Re: Performance of lists vs. list comprehensions

2010-01-19 Thread Steven D'Aprano
On Tue, 19 Jan 2010 11:26:43 -0500, Gerald Britton wrote: > Interestingly, I scaled it up to a million list items with more or less > the same results. A million items is not a lot of data. Depending on the size of each object, that might be as little as 4 MB of data: >>> L = ['' for _ in xrang

Pydev 1.5.4 Released

2010-01-19 Thread Fabio Zadrozny
Hi All, Pydev 1.5.4 has been released Details on Pydev: http://pydev.org Details on its development: http://pydev.blogspot.com Release Highlights: --- * Actions: o Go to matching bracket (Ctrl + Shift + P) o Copy the qualified name of the current context

Re: thread return code

2010-01-19 Thread Peter
On Jan 19, 9:25 pm, "Alf P. Steinbach" wrote: > * Rajat: > > > Hi, > > > I'm using threading module in Python 2.6.4. I'm using thread's join() > > method. > > > On the new thread I'm running a function which returns a code at the > > end. Is there a way I access that code in the parent thread afte

Re: can i examine the svn rev used to build a python 3 executable?

2010-01-19 Thread Martin v. Loewis
> never mind. just discovered that while "python3 -V" won't do it, > executing it gives me: > > $ python3 > Python 3.2a0 (py3k:77609, Jan 19 2010, 04:10:16) > ... > > and it's that 77609 rev number i was after. If you want that in a command line fashion, do python -c 'import sys;print(sys.su

Re: Performance of lists vs. list comprehensions

2010-01-19 Thread Arnaud Delobelle
Gerald Britton writes: > That's surprising. I wouldn't implement it that way at all. I'd use a > dynamically-expanding buffer as I suggested. That way you get a > single pass and don't have to calculate anything before you begin. In > the best case, you'd use half the memory (the result just f

Re: Performance of lists vs. list comprehensions

2010-01-19 Thread Raymond Hettinger
[Wolfram Hinderer] > Yes, list building from a generator expression *is* expensive. And > join has to do it, because it has to iterate twice over the iterable > passed in: once for calculating the memory needed for the joined > string, and once more to actually do the join (this is implementation >

Re: Updating an OptionMenu every time the text file it reads from is updated (Tkinter)

2010-01-19 Thread Dr. Benjamin David Clarke
On Jan 19, 7:00 am, Peter Otten <__pete...@web.de> wrote: > Dr. Benjamin David Clarke wrote: > > > I currently have a program that reads in values for an OptionMenu from > > a text file. I also have an option to add a line to that text file > > which corresponds to a new value for that OptionMenu.

Re: Recommended "new" way for config files

2010-01-19 Thread Jonathan Gardner
On Jan 8, 2:54 pm, Ben Finney wrote: > Chris Rebert writes: > > JSON is one option:http://docs.python.org/library/json.html > > YAML http://en.wikipedia.org/wiki/YAML> is another contender. > Compared to JSON, it is yet to gain as much mind-share, but even more > human-friendly and no less expres

Re: Performance of lists vs. list comprehensions

2010-01-19 Thread Gerald Britton
That's surprising. I wouldn't implement it that way at all. I'd use a dynamically-expanding buffer as I suggested. That way you get a single pass and don't have to calculate anything before you begin. In the best case, you'd use half the memory (the result just fits in the buffer after its last

Re: integer and string compare, is that correct?

2010-01-19 Thread Aahz
In article , Peter Otten <__pete...@web.de> wrote: > >The use cases for an order that works across types like int and str are >weak to non-existent. Implementing it was considered a mistake and has >been fixed in Python 3: That is not precisely correct from my POV. The primary use case for order

Re: Performance of lists vs. list comprehensions

2010-01-19 Thread Wolfram Hinderer
On 19 Jan., 21:06, Gerald Britton wrote: > [snip] > > > > > Yes, list building from a generator expression *is* expensive. And > > join has to do it, because it has to iterate twice over the iterable > > passed in: once for calculating the memory needed for the joined > > string, and once more to

Re: Performance of lists vs. list comprehensions

2010-01-19 Thread Arnaud Delobelle
Gerald Britton writes: > [snip] > >> >> Yes, list building from a generator expression *is* expensive. And >> join has to do it, because it has to iterate twice over the iterable >> passed in: once for calculating the memory needed for the joined >> string, and once more to actually do the join (

Re: enhancing 'list'

2010-01-19 Thread Steve Holden
samwyse wrote: > On Jan 18, 1:56 am, Terry Reedy wrote: >> On 1/17/2010 5:37 PM, samwyse wrote: >> >> >> >> >> >>> Consider this a wish list. I know I'm unlikely to get any of these in >>> time for for my birthday, but still I felt the need to toss it out and >>> see what happens. >>> Lately, I'v

Re: Performance of lists vs. list comprehensions

2010-01-19 Thread Gerald Britton
[snip] > > Yes, list building from a generator expression *is* expensive. And > join has to do it, because it has to iterate twice over the iterable > passed in: once for calculating the memory needed for the joined > string, and once more to actually do the join (this is implementation > dependen

Re: Py 3: How to switch application to Unicode strings?

2010-01-19 Thread Stephen Hansen
On Tue, Jan 19, 2010 at 7:50 AM, Gnarlodious wrote: > I am using Python 3, getting an error from SQLite: > > sqlite3.ProgrammingError: You must not use 8-bit bytestrings unless > you use a text_factory that can interpret 8-bit bytestrings (like > text_factory = str). It is highly recommended that

Re: Performance of lists vs. list comprehensions

2010-01-19 Thread Wolfram Hinderer
On 19 Jan., 16:30, Gerald Britton wrote: > >>> Timer("' '.join([x for x in l])", 'l = map(str,range(10))').timeit() > > 2.9967339038848877 > > >>> Timer("' '.join(x for x in l)", 'l = map(str,range(10))').timeit() > > 7.2045478820800781 [...] > 2. Why should the "pure" list comprehension be slow

Re: Py 3: Terminal script can't find relative path

2010-01-19 Thread Gnarlodious
OK I guess that is normal, I fixed it with this: path=os.path.dirname(__file__)+"/Data/" -- Gnarlie -- http://mail.python.org/mailman/listinfo/python-list

Re: Python IDE for MacOS-X

2010-01-19 Thread Chris Colbert
On Tue, Jan 19, 2010 at 2:09 AM, Jean Guillaume Pyraksos wrote: > What's the best one to use with beginners ? > Something with integrated syntax editor, browser of doc... > Thanks, > >JG > -- > http://mail.python.org/mailman/listinfo/python-list > I whole-heartedly recommend WingIDE. It's co

Re: Python IDE for MacOS-X

2010-01-19 Thread Günther Dietrich
Jean Guillaume Pyraksos wrote: >What's the best one to use with beginners ? >Something with integrated syntax editor, browser of doc... >Thanks, I started with 'EasyEclipse for Python', but soon changed to Eclipse with PyDev, MercurialEclipse and AnyEditTools plugins installed manually. I can

Re: substitution

2010-01-19 Thread Wyrmskull
Nvm, my bad, I misunderstood the split instruction. No difference :) --- Wyrmskull P.S Sorry about the P.M., I misclicked on a GUI -- http://mail.python.org/mailman/listinfo/python-list

Re: substitution

2010-01-19 Thread Wyrmskull
Cleaned. You can remove the 'else's if you want, because 'return' breaks the instruction flow. Should also work with other sequence types. def mySubst(reps,seq): if reps: a,b,c = string.partition(reps[0][0]) if b: return mySubst(reps,a) + reps[0][

Re: substitution

2010-01-19 Thread Peter Otten
Wyrmskull wrote: > Peter Otten wrote: >> def replace_many(s, pairs): >> if len(pairs): >> a, b = pairs[0] >> rest = pairs[1:] >> return b.join(replace_many(t, rest) for t in s.split(a)) >> else: >> return s > Proves wrong, this way x -> y -> z. > You call

Re: substitution

2010-01-19 Thread Wyrmskull
Peter Otten wrote: def replace_many(s, pairs): if len(pairs): a, b = pairs[0] rest = pairs[1:] return b.join(replace_many(t, rest) for t in s.split(a)) else: return s - Proves wrong, this way x -> y -> z. You call replace_many again on the c

Re: Iterate over group names in a regex match?

2010-01-19 Thread MRAB
Brian D wrote: Here's a simple named group matching pattern: s = "1,2,3" p = re.compile(r"(?P\d),(?P\d),(?P\d)") m = re.match(p, s) m <_sre.SRE_Match object at 0x011BE610> print m.groups() ('1', '2', '3') Is it possible to call the group names, so that I can iterate over them? The result I

Re: Iterate over group names in a regex match?

2010-01-19 Thread Brian D
On Jan 19, 11:51 am, Brian D wrote: > On Jan 19, 11:28 am, Peter Otten <__pete...@web.de> wrote: > > > > > Brian D wrote: > > > Here's a simple named group matching pattern: > > > s = "1,2,3" > > p = re.compile(r"(?P\d),(?P\d),(?P\d)") > > m = re.match(p, s) > > m > > > <_sre.S

Re: Iterate over group names in a regex match?

2010-01-19 Thread Brian D
On Jan 19, 11:28 am, Peter Otten <__pete...@web.de> wrote: > Brian D wrote: > > Here's a simple named group matching pattern: > > s = "1,2,3" > p = re.compile(r"(?P\d),(?P\d),(?P\d)") > m = re.match(p, s) > m > > <_sre.SRE_Match object at 0x011BE610> > print m.groups() > >

Re: how to sort two dimensional array ??

2010-01-19 Thread Stephen Hansen
On Tue, Jan 19, 2010 at 9:00 AM, Robert Somerville < rsomervi...@sjgeophysics.com> wrote: > Hi; > Hi, why did you post this three times? > i am having trouble trying to sort the rows of a 2 dimensional array by the > values in the first column .. does anybody know how or have an example of > ho

Re: how to sort two dimensional array ??

2010-01-19 Thread Robert Kern
On 2010-01-19 11:00 AM, Robert Somerville wrote: Hi; i am having trouble trying to sort the rows of a 2 dimensional array by the values in the first column .. does anybody know how or have an example of how to do this ??? while leaving the remain columns remain relative to the leading column Yo

[ANN] Python-es mailing list changes home

2010-01-19 Thread Chema Cortes
=== Python-es mailing list changes home === Due to technical problems with the site that usually ran the Python-es mailing list (Python list for the Spanish speaking community), we are setting up a new one under the python.org umbrella. Hence, the new list will become (the old one was ). Please

Re: Iterate over group names in a regex match?

2010-01-19 Thread Peter Otten
Brian D wrote: > Here's a simple named group matching pattern: > s = "1,2,3" p = re.compile(r"(?P\d),(?P\d),(?P\d)") m = re.match(p, s) m > <_sre.SRE_Match object at 0x011BE610> print m.groups() > ('1', '2', '3') > > Is it possible to call the group names, so that I can

Re: use of super

2010-01-19 Thread harryos
thanks Simon..I should have checked it -- http://mail.python.org/mailman/listinfo/python-list

Re: Iterate over group names in a regex match?

2010-01-19 Thread Alf P. Steinbach
* Brian D: Here's a simple named group matching pattern: s = "1,2,3" p = re.compile(r"(?P\d),(?P\d),(?P\d)") m = re.match(p, s) m <_sre.SRE_Match object at 0x011BE610> print m.groups() ('1', '2', '3') Is it possible to call the group names, so that I can iterate over them? The result I'm l

Re: Iterate over group names in a regex match?

2010-01-19 Thread djc
Brian D wrote: > Here's a simple named group matching pattern: > s = "1,2,3" p = re.compile(r"(?P\d),(?P\d),(?P\d)") m = re.match(p, s) m > <_sre.SRE_Match object at 0x011BE610> print m.groups() > ('1', '2', '3') > > Is it possible to call the group names, so that I can i

Re: Create list/dict from string

2010-01-19 Thread Simon Brunning
2010/1/19 Peter Otten <__pete...@web.de>: > Both eval() and json.loads() will do. eval() is dangerous as it allows the > user to run arbitrary python code. Something like might be worth a look too. -- Cheers, Simon B. -- http://mail.python.org/mailm

Re: Create list/dict from string

2010-01-19 Thread Gerald Britton
Can't you just use the dict() built-in function like this: dict({"action_name": "action_1", "val": "asdf"}) Of course if the list is not properly formed, this will fail. But I guess you have thought of that already. On Tue, Jan 19, 2010 at 11:33 AM, SoxFan44 wrote: > I was wondering if there w

Re: Python IDE for MacOS-X

2010-01-19 Thread Phlip
On Jan 18, 11:09 pm, Jean Guillaume Pyraksos wrote: > What's the best one to use with beginners ? > Something with integrated syntax editor, browser of doc... > Thanks, Before this message goes stale, there's TextMate (which I have too much experience with to consider redeemable in any way)...

Iterate over group names in a regex match?

2010-01-19 Thread Brian D
Here's a simple named group matching pattern: >>> s = "1,2,3" >>> p = re.compile(r"(?P\d),(?P\d),(?P\d)") >>> m = re.match(p, s) >>> m <_sre.SRE_Match object at 0x011BE610> >>> print m.groups() ('1', '2', '3') Is it possible to call the group names, so that I can iterate over them? The result I'

how to sort two dimensional array ??

2010-01-19 Thread Robert Somerville
Hi; i am having trouble trying to sort the rows of a 2 dimensional array by the values in the first column .. does anybody know how or have an example of how to do this ??? while leaving the remain columns remain relative to the leading column from numpy import * a=array( [ [4, 4, 3], [4, 5,

Re: Is HTML report of tests run using PyUnit (unittest) possible?

2010-01-19 Thread Phlip
On Jan 19, 3:16 am, fossist wrote: > I am using PyUnit (unittest module) for loading test cases from our > modules and executing them. Is it possible to export the test results > as HTML report? Currently the results appear as text on standard > output while the tests execute. But is there someth

Re: Create list/dict from string

2010-01-19 Thread Peter Otten
SoxFan44 wrote: > I was wondering if there was a way to create a list (which in this > case would contain several dicts) based on a string passed in by the > user. Security is not an issue. Basically I want to be able to have > the user pass in using optparse: > --actions=[{"action_name": "actio

Re: use of super

2010-01-19 Thread Simon Brunning
2010/1/19 harryos : > I was going thru the weblog appln in practical django book by > bennet .I came across this > > class Entry(Model): >        def save(self): >                dosomething() >                super(Entry,self).save() > > I couldn't make out why Entry and self are passed as argumen

how to sort two dimensional array ??

2010-01-19 Thread robert somerville
Hi; i am having trouble trying to sort the rows of a 2 dimensional array by the values in the first column .. does anybody know how or have an example of how to do this ??? while leaving the remain columns remain relative to the leading column from numpy import * a=array( [ [4, 4, 3], [4, 5, 2],

how to sort two dimensional array

2010-01-19 Thread robert somerville
Hi; i am having trouble trying to sort the rows of a 2 dimensional array by the values in the first column .. does anybody know how or have an example of how to do this ??? while leaving the remain columns remain relative to the leading column from numpy import * a=array( [ [4, 4, 3], [4, 5, 2],

Re: Arrrrgh! Another module broken

2010-01-19 Thread nn
On Jan 18, 11:37 am, Grant Edwards wrote: > On 2010-01-18, Jive Dadson wrote: > > > I just found another module that broke when I went to 2.6.  Gnuplot. > > Apparently one of its routines has a parameter named "with."  That used > > to be okay, and now it's not. > > I remember seeing depreicated

Create list/dict from string

2010-01-19 Thread SoxFan44
I was wondering if there was a way to create a list (which in this case would contain several dicts) based on a string passed in by the user. Security is not an issue. Basically I want to be able to have the user pass in using optparse: --actions=[{"action_name": "action_1", "val": "asdf", "val2"

Re: multiprocessing problems

2010-01-19 Thread DoxaLogos
On Jan 19, 10:26 am, Adam Tauno Williams wrote: > > I decided to play around with the multiprocessing module, and I'm > > having some strange side effects that I can't explain.  It makes me > > wonder if I'm just overlooking something obvious or not.  Basically, I > > have a script parses through

can i examine the svn rev used to build a python 3 executable?

2010-01-19 Thread Robert P. J. Day
i'm currently checking out python3 from the svn repo, configuring, building and installing under /usr/local/bin on my fedora 12 system, all good. i'm curious, though -- is there a query i can make of that executable that would tell me what svn rev it was built from? i'm guessing not, but i t

Re: multiprocessing problems

2010-01-19 Thread Adam Tauno Williams
> I decided to play around with the multiprocessing module, and I'm > having some strange side effects that I can't explain. It makes me > wonder if I'm just overlooking something obvious or not. Basically, I > have a script parses through a lot of files doing search and replace > on key strings

Re: Performance of lists vs. list comprehensions

2010-01-19 Thread Gerald Britton
Interestingly, I scaled it up to a million list items with more or less the same results. It's helpful to see that your results are different. That leads me to suspect that mine are somehow related to my own environment. Still I think the key is the overhead in calling next() for each item in th

use of super

2010-01-19 Thread harryos
hi I was going thru the weblog appln in practical django book by bennet .I came across this class Entry(Model): def save(self): dosomething() super(Entry,self).save() I couldn't make out why Entry and self are passed as arguments to super ().Can someone ple

Re: can i examine the svn rev used to build a python 3 executable?

2010-01-19 Thread Robert P. J. Day
On Tue, 19 Jan 2010, Robert P. J. Day wrote: > i'm currently checking out python3 from the svn repo, configuring, > building and installing under /usr/local/bin on my fedora 12 system, > all good. > > i'm curious, though -- is there a query i can make of that > executable that would tell me wh

Closing a Curses Window???

2010-01-19 Thread Adam Tauno Williams
I'm uses the curses module of Python to create a TUI. I can create windows, and subwindows, but I can't find anything on deleting or disposing of a a subwindow. How do I get rid of a subwindow? --

Re: Py 3: Terminal script can't find relative path

2010-01-19 Thread nn
On Jan 19, 8:03 am, Gnarlodious wrote: > On Jan 18, 4:21 pm, John Bokma wrote: > > > Gnarlodious writes: > > > I am running a script in a browser that finds the file in subfolder > > > Data: > > > > Content=Plist('Data/Content.plist') > > > > However, running the same script in Terminal errors:

multiprocessing problems

2010-01-19 Thread DoxaLogos
Hi, I decided to play around with the multiprocessing module, and I'm having some strange side effects that I can't explain. It makes me wonder if I'm just overlooking something obvious or not. Basically, I have a script parses through a lot of files doing search and replace on key strings insid

Re: Performance of lists vs. list comprehensions

2010-01-19 Thread Stephen Hansen
On Tue, Jan 19, 2010 at 7:30 AM, Gerald Britton wrote: [snip] > mystring = '\n'.join( line for line in lines if depending on line> ) > Note, this is not a list comprehension, but a generator comprehension. A list comprehension is used to build, in one sweep, a list and return it. A generator c

Re: Performance of lists vs. list comprehensions

2010-01-19 Thread Gerald Britton
Thanks! Good explanation. On Tue, Jan 19, 2010 at 10:57 AM, Alf P. Steinbach wrote: > * Gerald Britton: >> >> Yesterday I stumbled across some old code in a project I was working >> on.  It does something like this: >> >> mystring = '\n'.join( [ line for line in lines if > depending on line> ] )

Re: Performance of lists vs. list comprehensions

2010-01-19 Thread Alf P. Steinbach
* Gerald Britton: Yesterday I stumbled across some old code in a project I was working on. It does something like this: mystring = '\n'.join( [ line for line in lines if ] ) where "lines" is a simple list of strings. I realized that the code had been written before you could put a list compr

Py 3: How to switch application to Unicode strings?

2010-01-19 Thread Gnarlodious
I am using Python 3, getting an error from SQLite: sqlite3.ProgrammingError: You must not use 8-bit bytestrings unless you use a text_factory that can interpret 8-bit bytestrings (like text_factory = str). It is highly recommended that you instead just switch your application to Unicode strings.

python gui ide under linux..like visual studio ;) ?

2010-01-19 Thread ryniek90
Il 18/01/2010 21:59, Mike Driscoll ha scritto: > On Jan 18, 8:32 am, ted wrote: >> Hi at all... >> Can someone please give me some advice, about a good IDE with control >> GUI under Linux ? >> >> Actually i know QT Creator by Nokia which i can use with Python (but i >> don't k

Performance of lists vs. list comprehensions

2010-01-19 Thread Gerald Britton
Yesterday I stumbled across some old code in a project I was working on. It does something like this: mystring = '\n'.join( [ line for line in lines if ] ) where "lines" is a simple list of strings. I realized that the code had been written before you could put a list comprehension as an argum

Re: Py 3: Terminal script can't find relative path

2010-01-19 Thread Gnarlodious
On Jan 18, 4:21 pm, John Bokma wrote: > Gnarlodious writes: > > I am running a script in a browser that finds the file in subfolder > > Data: > > > Content=Plist('Data/Content.plist') > > > However, running the same script in Terminal errors: > > > IOError: [Errno 2] No such file or directory: 'D

Re: using super

2010-01-19 Thread Jean-Michel Pichavant
Gabriel Genellina wrote: I see. Then is there a reason why return super(Subclass, self).parrot() would be prefered over the "classic" return Base.parrot(self) ? Or is it just a matter of preference ? For a longer explanation, see: James Knight: Python's Super Considered Harmful http://fuhm

Re: python replace/sub/wildcard/regex issue

2010-01-19 Thread dippim
On Jan 18, 11:04 pm, tom wrote: > hi... > > trying to figure out how to solve what should be an easy python/regex/ > wildcard/replace issue. > > i've tried a number of different approaches.. so i must be missing > something... > > my initial sample text are: > > Soo ChoiLONGEDITBOX">Apryl Berney >

Re: [ANN] Data Plotting Library DISLIN 10.0

2010-01-19 Thread superpollo
Helmut Michels ha scritto: Dear Pytnon users, I am pleased to announce version 10.0 of the data plotting software DISLIN. why dont you make it free software (i mean. GPL'ed) bye -- http://mail.python.org/mailman/listinfo/python-list

Re: Updating an OptionMenu every time the text file it reads from is updated (Tkinter)

2010-01-19 Thread Peter Otten
Dr. Benjamin David Clarke wrote: > I currently have a program that reads in values for an OptionMenu from > a text file. I also have an option to add a line to that text file > which corresponds to a new value for that OptionMenu. How can I make > that OptionMenu update its values based on that te

Re: Generic Python Benchmark suite?

2010-01-19 Thread Antoine Pitrou
Le Mon, 18 Jan 2010 21:05:26 -0800, Anand Vaidya a écrit : > @Antoine, Terry, > > Thanks for the suggestions. > > I will investigate those. I just ran the pybench, doesn't run on 3.x, > 2to3 fails. You just have to use the pybench version that is bundled with 3.x (in the Tools directory). --

Re: Inheriting methods but over-riding docstrings

2010-01-19 Thread Michele Simionato
On Jan 16, 6:55 pm, Steven D'Aprano wrote: > I have a series of subclasses that inherit methods from a base class, but > I'd like them to have their own individual docstrings. The following is not tested more than you see and will not work for builtin methods, but it should work in the common cas

Is HTML report of tests run using PyUnit (unittest) possible?

2010-01-19 Thread fossist
I am using PyUnit (unittest module) for loading test cases from our modules and executing them. Is it possible to export the test results as HTML report? Currently the results appear as text on standard output while the tests execute. But is there something out of the box available in PyUnit to mak

[ANN] Data Plotting Library DISLIN 10.0

2010-01-19 Thread Helmut Michels
Dear Pytnon users, I am pleased to announce version 10.0 of the data plotting software DISLIN. DISLIN is a high-level and easy to use plotting library for displaying data as curves, bar graphs, pie charts, 3D-colour plots, surfaces, contours and maps. Several output formats are supported such as

Re: Updating an OptionMenu every time the text file it reads from is updated (Tkinter)

2010-01-19 Thread Alf P. Steinbach
* Dr. Benjamin David Clarke: I currently have a program that reads in values for an OptionMenu from a text file. I also have an option to add a line to that text file which corresponds to a new value for that OptionMenu. How can I make that OptionMenu update its values based on that text file wit

what test runner should I use?

2010-01-19 Thread Chris Withers
Hi All, I'm wondering what test runner I should use. Here's my list of requirements: - cross platform (I develop for and on Windows, Linux and Mac) - should not prevent tests from running with other test runners (so no plugins/layers/etc that only work with one specific test runner) - sho

Re: thread return code

2010-01-19 Thread Alf P. Steinbach
* Rajat: Hi, I'm using threading module in Python 2.6.4. I'm using thread's join() method. On the new thread I'm running a function which returns a code at the end. Is there a way I access that code in the parent thread after thread finishes? Simply, does join() could get me that code? join()

Re: python gui ide under linux..like visual studio ;) ?

2010-01-19 Thread ted
Il 18/01/2010 21:59, Mike Driscoll ha scritto: > On Jan 18, 8:32 am, ted wrote: >> Hi at all... >> Can someone please give me some advice, about a good IDE with control >> GUI under Linux ? >> >> Actually i know QT Creator by Nokia which i can use with Python (but i >> don't know how). >> >> And,

thread return code

2010-01-19 Thread Rajat
Hi, I'm using threading module in Python 2.6.4. I'm using thread's join() method. On the new thread I'm running a function which returns a code at the end. Is there a way I access that code in the parent thread after thread finishes? Simply, does join() could get me that code? Regards, Rajat --

Re: searching and storing large quantities of xml!

2010-01-19 Thread Stefan Behnel
dads, 18.01.2010 22:39: > There was one thing that I forgot about - when ElementTree fails to > parse due to an element not being closed why doesn't it close the file > like object. Because it didn't open it? Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: syntax

2010-01-19 Thread Gib Bogle
Looks like homework. -- http://mail.python.org/mailman/listinfo/python-list

Re: basic Class in Python

2010-01-19 Thread Richard Brodie
"bartc" wrote in message news:xl_4n.28001$ym4.5...@text.news.virginmedia.com... > Any particular reason why two, and not one (or three)? In some fonts it's > difficult to > tell how many as they run together. It follows the C convention for reserved identifers. -- http://mail.python.org/

Re: Generic Python Benchmark suite?

2010-01-19 Thread M.-A. Lemburg
Anand Vaidya wrote: > Is there a generic python benchmark suite in active development? I am > looking forward to comparing some code on various python > implementations (primarily CPython 2.x, CPython 3.x, UnladenSwallow, > Psyco). > > I am happy with something that gives me a relative number eg: