[RELEASED] Python 3.1.1

2009-08-16 Thread Benjamin Peterson
On behalf of the Python development team, I'm happy to announce the first bugfix release of the Python 3.1 series, Python 3.1.1. This bug fix release fixes many normal bugs and several critical ones including potential data corruption in the io library. Python 3.1 focuses on the stabilization

Re: Pygresql, and query meta informations

2009-08-16 Thread Tim Roberts
durumdara durumd...@gmail.com wrote: Pygresql, DB-API. I search for a solution to get meta information about last query, because I must export these infos to Delphi. Delphi have TDataSet, and it have meta structure that must be defined before I create it. For char/varchar fields I must define

Re: Is it possible to use python to get True Full Duplex on a Serial port?

2009-08-16 Thread John Nagle
Hendrik van Rooyen wrote: On Saturday 15 August 2009 14:40:35 Michael Ströder wrote: Hendrik van Rooyen wrote: In the past, on this group, I have made statements that said that on Linux, the serial port handling somehow does not allow transmitting and receiving at the same time, and nobody

Re: Python 'for' loop is memory inefficient

2009-08-16 Thread Emmanuel Surleau
Dr. Phillip M. Feldman wrote: [snip] def is_prime(n): for j in range(2,n): if (n % j) == 0: return False return True It seems as though Python is actually expanding range(2,n) into a list of numbers, even though this is incredibly wasteful of memory. There should be

Re: for cycle with assigning index

2009-08-16 Thread dmitrey
Thanks all, especially Dennis for your detailed answer. left_arr_indexes is list of nonnegative integers, eg [0,0,0,1,1,4] IndDict is a dict like {0: [1,2], 3: [0,1], 10:[0,2,3]}, so that's why I don't use python list instead. The code is taken from OpenOpt framework that I develop. Currently I

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-16 Thread Hendrik van Rooyen
Steven D'Aprano st...@remove-this-c...e.com.au wrote: Now that I understand what the semantics of cout Hello world are, I don't have any problem with it either. It is a bit weird, Hello world cout would probably be better, but it's hardly the strangest design in any programming language,

my recursive function call is wrong?

2009-08-16 Thread Chang Min Jeon
I'm trying to write program to translate define macro in 'C'. And start_parse has return condition that list's length is 0. At this time return statement invoke start_parse() function. I can't understand do that. I'm using Python 2.6.2 in Windows XP import re import sys comment = ''' #if defined

Re: What happened to __cmp__() in Python 3.x?

2009-08-16 Thread Chris Rebert
On Sat, Aug 15, 2009 at 8:09 AM, Xavier Hocont...@xavierho.com wrote: Hey all, I've recently made my way to Python 3.1 and I'm not seeing __cmp__() in the documentation. Is there a substitution for this special method in 3.1, or do I really have to define all six rich comparison methods to

Re: What happened to __cmp__() in Python 3.x?

2009-08-16 Thread Chris Rebert
On Sat, Aug 15, 2009 at 1:06 PM, Mark Lawrencebreamore...@yahoo.co.uk wrote: Xavier Ho wrote: Hey all, I've recently made my way to Python 3.1 and I'm not seeing __cmp__() in the documentation. Is there a substitution for this special method in 3.1, or do I really have to define all six

Re: random.gauss vs. random.normalvariate

2009-08-16 Thread Chris Rebert
On Sat, Aug 15, 2009 at 10:18 PM, Paul Rubin http://phr...@nospam.invalid wrote: Dennis Lee Bieber wlfr...@ix.netcom.com writes:       No language can guard against independent access of a shared/global object by multiple threads... Erlang? On Sun, Aug 16, 2009 at 12:23 AM, John

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-16 Thread Steven D'Aprano
On Sun, 16 Aug 2009 09:24:36 +0200, Hendrik van Rooyen wrote: Steven D'Aprano st...@remove-this-c...e.com.au wrote: Now that I understand what the semantics of cout Hello world are, I don't have any problem with it either. It is a bit weird, Hello world cout would probably be better, but it's

Re: Python 'for' loop is memory inefficient

2009-08-16 Thread Steven D'Aprano
On Sun, 16 Aug 2009 08:30:54 +0200, Emmanuel Surleau wrote: [...] I will also observe that if you were to stop programming whatever language you are more familiar with in Python, and start programming Python in Python, you'll have an easier time of it. I don't see what's particularly

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-16 Thread Douglas Alan
On Aug 16, 4:22 am, Steven D'Aprano st...@remove-this- cybersource.com.au wrote: I don't like normal assignment. After nearly four decades of mathematics and programming, I'm used to it, but I don't think it is especially good. It confuses beginners to programming: they get one set of

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-16 Thread Erik Max Francis
Steven D'Aprano wrote: I don't like normal assignment. After nearly four decades of mathematics and programming, I'm used to it, but I don't think it is especially good. It confuses beginners to programming: they get one set of behaviour drilled into them in maths class, and then in

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-16 Thread Erik Max Francis
Douglas Alan wrote: Personally, my favorite is Lisp, which looks like (set! y (+ y 1)) For varying values of Lisp. `set!` is Scheme. -- Erik Max Francis m...@alcyone.com http://www.alcyone.com/max/ San Jose, CA, USA 37 18 N 121 57 W AIM/Y!M/Skype erikmaxfrancis Get there first

Re: ignored test cases in unittest

2009-08-16 Thread Duncan Booth
Ben Finney ben+pyt...@benfinney.id.au wrote: Terry terry.yin...@gmail.com writes: It seemed the to me that python unittest module does not support the counting of ignored test cases directly. Is there any ready solution for this? One solution I've seen involves: * a custom exception

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-16 Thread Douglas Alan
On Aug 16, 4:48 am, Erik Max Francis m...@alcyone.com wrote: Douglas Alan wrote: Personally, my favorite is Lisp, which looks like    (set! y (+ y 1)) For varying values of Lisp.  `set!` is Scheme. Yes, I'm well aware! There are probably as many different dialects of Lisp as all other

Re: What happened to __cmp__() in Python 3.x?

2009-08-16 Thread Xavier Ho
On Sun, Aug 16, 2009 at 7:38 PM, Mark Lawrence breamore...@yahoo.co.ukwrote: Blast, I posted the wrong flaming link, sorry everybody. No, don't be sorry. I found your link very informative, and while it's a little mixed, it could be useful. I'm really looking for a way to set up Python

Re: Splitting a string into substrings of equal size

2009-08-16 Thread Gregor Lingl
Mark Tolonen schrieb: Gregor Lingl gregor.li...@aon.at wrote in message news:4a87036a$0$2292$91cee...@newsreader02.highway.telekom.at... Emile van Sebille schrieb: On 8/14/2009 5:22 PM candide said... ... What is the pythonic way to do this ? I like list comps... jj =

Re: flatten a list of list

2009-08-16 Thread Chris Rebert
On Sun, Aug 16, 2009 at 5:47 AM, Terryterry.yin...@gmail.com wrote: Hi, Is there a simple way (the pythonic way) to flatten a list of list? rather than my current solution: new_list=[] for l in list_of_list:    new_list.extend(l) or, new_list=reduce(lambda x,y:x.extend(y),

flatten a list of list

2009-08-16 Thread Terry
Hi, Is there a simple way (the pythonic way) to flatten a list of list? rather than my current solution: new_list=[] for l in list_of_list: new_list.extend(l) or, new_list=reduce(lambda x,y:x.extend(y), list_of_list) br, Terry -- http://mail.python.org/mailman/listinfo/python-list

Re: What happened to __cmp__() in Python 3.x?

2009-08-16 Thread Mark Lawrence
Chris Rebert wrote: On Sat, Aug 15, 2009 at 1:06 PM, Mark Lawrencebreamore...@yahoo.co.uk wrote: Xavier Ho wrote: Hey all, I've recently made my way to Python 3.1 and I'm not seeing __cmp__() in the documentation. Is there a substitution for this special method in 3.1, or do I really have to

Re: ignored test cases in unittest

2009-08-16 Thread Terry
On Aug 16, 5:25 pm, Duncan Booth duncan.bo...@invalid.invalid wrote: Ben Finney ben+pyt...@benfinney.id.au wrote: Terry terry.yin...@gmail.com writes: It seemed the to me that python unittest module does not support the counting of ignored test cases directly. Is there any ready solution

Re: flatten a list of list

2009-08-16 Thread Michael Fötsch
Terry wrote: Is there a simple way (the pythonic way) to flatten a list of list? This is probably the shortest it can get: sum(list_of_lists, []) Kind Regards, M.F. -- http://mail.python.org/mailman/listinfo/python-list

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-16 Thread Steven D'Aprano
On Sun, 16 Aug 2009 01:41:41 -0700, Douglas Alan wrote: I like to be able to read everything from left to right, and Lisp does that more than any other programming language. I would definitely not like a language that obscures assignment by moving it over to the right side of lines. One

wxFormBuilder finally supports wxPython

2009-08-16 Thread sturlamolden
Version 3.1 of wxFormBuilder can generate wxPython code. I have previously used wxFormBuilder to generate XRC files for my wxPython projects. Though still in beta, this might be even better. :-) http://wxformbuilder.org/ -- http://mail.python.org/mailman/listinfo/python-list

Re: How to find out in which module an instance of a class is created?

2009-08-16 Thread Chris Rebert
On Sun, Aug 16, 2009 at 6:25 AM, Johannes Janssenm...@johannes-janssen.de wrote: Gabriel Genellina schrieb: The try/except around sys._getframe(1) is because that function is not mandatory/available on all Python implementations (that's the case for jython which doesn't provide it). Thanks,

Re: How to find out in which module an instance of a class is created?

2009-08-16 Thread Johannes Janssen
Gabriel Genellina schrieb: The try/except around sys._getframe(1) is because that function is not mandatory/available on all Python implementations (that's the case for jython which doesn't provide it). Thanks, shouldn't such information be part of the python documentation of sys._getframe()

Re: How to find out in which module an instance of a class is created?

2009-08-16 Thread Johannes Janssen
Chris Rebert schrieb: On Sun, Aug 16, 2009 at 6:25 AM, Johannes Janssenm...@johannes-janssen.de wrote: Gabriel Genellina schrieb: The try/except around sys._getframe(1) is because that function is not mandatory/available on all Python implementations (that's the case for jython which

Re: flatten a list of list

2009-08-16 Thread Steven D'Aprano
On Sun, 16 Aug 2009 05:55:48 -0400, Chris Rebert wrote: On Sun, Aug 16, 2009 at 5:47 AM, Terryterry.yin...@gmail.com wrote: Hi, Is there a simple way (the pythonic way) to flatten a list of list? rather than my current solution: new_list=[] for l in list_of_list:    new_list.extend(l)

Re: flatten a list of list

2009-08-16 Thread Chris Rebert
On Sun, Aug 16, 2009 at 6:49 AM, Steven D'Apranost...@remove-this-cybersource.com.au wrote: On Sun, 16 Aug 2009 05:55:48 -0400, Chris Rebert wrote: On Sun, Aug 16, 2009 at 5:47 AM, Terryterry.yin...@gmail.com wrote: Hi, Is there a simple way (the pythonic way) to flatten a list of list?

Re: flatten a list of list

2009-08-16 Thread Steven D'Aprano
On Sun, 16 Aug 2009 12:03:53 +0200, Michael Fötsch wrote: Terry wrote: Is there a simple way (the pythonic way) to flatten a list of list? This is probably the shortest it can get: sum(list_of_lists, []) That's also O(N**2). from timeit import Timer setup = L = [ ([None]*5000) for x

Re: Is it possible to use python to get True Full Duplex on a Serial port? - conclusions

2009-08-16 Thread Hendrik van Rooyen
On Sunday 16 August 2009 08:20:34 John Nagle wrote: Hendrik van Rooyen wrote: On Saturday 15 August 2009 14:40:35 Michael Ströder wrote: Hendrik van Rooyen wrote: In the past, on this group, I have made statements that said that on Linux, the serial port handling somehow does not allow

Re: Problem Regarding Handling of Unicode string

2009-08-16 Thread joy99
On Aug 11, 1:17 pm, John Machin sjmac...@lexicon.net wrote: On Aug 10, 9:26 pm, joy99 subhakolkata1...@gmail.com wrote: Dear Group, I am using Python26 on WindowsXP with service pack2. My GUI is IDLE. I am using Hindi resources and get nice output like: एक where I can use all the re

Re: flatten a list of list

2009-08-16 Thread Terry
On Aug 16, 6:59 pm, Chris Rebert c...@rebertia.com wrote: On Sun, Aug 16, 2009 at 6:49 AM, Steven D'Apranost...@remove-this-cybersource.com.au wrote: On Sun, 16 Aug 2009 05:55:48 -0400, Chris Rebert wrote: On Sun, Aug 16, 2009 at 5:47 AM, Terryterry.yin...@gmail.com wrote: Hi, Is

Re: flatten a list of list

2009-08-16 Thread Steven D'Aprano
On Sun, 16 Aug 2009 02:47:42 -0700, Terry wrote: Hi, Is there a simple way (the pythonic way) to flatten a list of list? rather than my current solution: new_list=[] for l in list_of_list: new_list.extend(l) I don't think that scales terribly well. In my testing, it performs about

Re: flatten a list of list

2009-08-16 Thread Steven D'Aprano
On Sun, 16 Aug 2009 06:59:52 -0400, Chris Rebert wrote: Surely that's going to be O(N**2)? The OP asked for simple, not best, most proper, or fastest. My comment was intended to mean that the code was marginally *simpler*, not faster. Fair enough, but he also asked for Pythonic, and while

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-16 Thread Hendrik van Rooyen
On Sunday 16 August 2009 12:18:11 Steven D'Aprano wrote: In any case, after half a century of left-from-right assignment, I think it's worth the experiment in a teaching language or three to try it the other way. The closest to this I know of is the family of languages derived from Apple's

Re: What happened to __cmp__() in Python 3.x?

2009-08-16 Thread Terry Reedy
Xavier Ho wrote: I'm really looking for a way to set up Python classes' natural ordering for sorting purposes. I believe __lt__ () is the only method (operator) used by both .sort and heap module. -- http://mail.python.org/mailman/listinfo/python-list

Re: flatten a list of list

2009-08-16 Thread Chris Rebert
On Sun, Aug 16, 2009 at 7:31 AM, Steven D'Apranost...@remove-this-cybersource.com.au wrote: On Sun, 16 Aug 2009 06:59:52 -0400, Chris Rebert wrote: Surely that's going to be O(N**2)? The OP asked for simple, not best, most proper, or fastest. My comment was intended to mean that the code was

Re: What happened to __cmp__() in Python 3.x?

2009-08-16 Thread Mark Lawrence
Chris Rebert wrote: On Sat, Aug 15, 2009 at 8:09 AM, Xavier Hocont...@xavierho.com wrote: Hey all, I've recently made my way to Python 3.1 and I'm not seeing __cmp__() in the documentation. Is there a substitution for this special method in 3.1, or do I really have to define all six rich

Re: What happened to __cmp__() in Python 3.x?

2009-08-16 Thread Xavier Ho
On Sun, Aug 16, 2009 at 9:49 PM, Mark Lawrence breamore...@yahoo.co.ukwrote: Unfortunately I don't think it's that easy, see. http://mail.python.org/pipermail/python-list/2008-November/688761.html The issue referenced is still open. This of course assumes that I've posted the correct link

platform-specific overrides of functions and class methods (expanding on imputils demo code)

2009-08-16 Thread lkcl
i've just had to put something together for pyjamas-desktop which may prove to be useful to other people, so i'm pointing people in its general direction, for archive purposes. the purpose behind the platform override system is to allow implementations of a common API, in python, to share the

Re: flatten a list of list

2009-08-16 Thread Bearophile
Chris Rebert: The OP asked for simple, not best, most proper, or fastest. My comment was intended to mean that the code was marginally *simpler*, not faster. Yep, the OP has asked for simple code. But often this is not the right way to solve this situation. A better way is to create (or copy)

Re: What happened to __cmp__() in Python 3.x?

2009-08-16 Thread Mark Lawrence
Xavier Ho wrote: On Sun, Aug 16, 2009 at 9:49 PM, Mark Lawrence breamore...@yahoo.co.ukwrote: Unfortunately I don't think it's that easy, see. http://mail.python.org/pipermail/python-list/2008-November/688761.html The issue referenced is still open. This of course assumes that I've posted the

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-16 Thread MRAB
Douglas Alan wrote: [snip] C++ also allows for reading from stdin like so: cin myVar; I think the direction of the arrows probably derives from languages like APL, which had notation something like so: myVar - 3 [] - myVar - was really a little arrow symbol (APL didn't use

Re: unittest

2009-08-16 Thread Mag Gam
John: Well, this is actually a script which wraps around another application. :-) My goal is when I introduce a new feature I don't want to break old stuff so instead of me testing manually I want to build a framework of tests. On Sat, Aug 15, 2009 at 11:37 PM, John Haggertybouncy...@gmail.com

Re: my recursive function call is wrong?

2009-08-16 Thread Kev Dwyer
On Sun, 16 Aug 2009 16:57:41 +0900, Chang Min Jeon wrote: Hello, You have placed recursive calls to the function in a number of different locations; when len(macro) becomes zero control will return to the calling function, but this calling function may have more code to execute, including

Re: Python 'for' loop is memory inefficient

2009-08-16 Thread Emmanuel Surleau
It's a particular unfair criticism because the critic (Ethan Furman) appears to have made a knee-jerk reaction. The some language in Python behaviour he's reacting to is the common idiom: for i in range(len(seq)): do_something_with(seq[i]) instead of the Python in Python idiom: for

Re: callable virtual method

2009-08-16 Thread Jean-Michel Pichavant
Scott David Daniels wrote: Jean-Michel Pichavant wrote: Steven D'Aprano wrote: On Fri, 14 Aug 2009 18:49:26 +0200, Jean-Michel Pichavant wrote: Sorry guys (means guys *and* gals :op ), I realized I've not been able to describe precisely what I want to do. I'd like the base class to be

Re: Is it possible to use python to get True Full Duplex on a Serial port?

2009-08-16 Thread Grant Edwards
On 2009-08-15, Hendrik van Rooyen hend...@microcorp.co.za wrote: On Saturday 15 August 2009 16:25:03 Grant Edwards wrote: Are you using python file operations open/read/write or OS file-descriptor operations os.open/os.read/os.write? The former - that seems to be the source of my trouble.

Re: callable virtual method

2009-08-16 Thread Christian Heimes
Jean-Michel Pichavant wrote: scott.dani...@acm.org That could do the trick, sparing me from writing additional code in each methods. Thanks. Why are you trying to reinvent the wheel? Python's abc module already takes care of these details. Christian --

Re: callable virtual method

2009-08-16 Thread Jean-Michel Pichavant
Christian Heimes wrote: Jean-Michel Pichavant wrote: talking about approaches: 1/ class Interface: def foo(self): if self.__class__.foo == Interface.foo: raise NotImplementedError 2/ class Interface: def foo(self): self._foo() def _foo(sef): raise

Re: callable virtual method

2009-08-16 Thread jean-michel Pichavant
Christian Heimes a écrit : Jean-Michel Pichavant wrote: scott.dani...@acm.org That could do the trick, sparing me from writing additional code in each methods. Thanks. Why are you trying to reinvent the wheel? Python's abc module already takes care of these details. Christian I'm working

Re: Surpressing Warnings

2009-08-16 Thread Victor Subervi
This is strange because I actually had if exists in my code: sqlKWDrop = 'DROP TABLE IF EXISTS ' + kwTable + ';' where kwTable, in the instance cited below, becomes judaism_128. What gives? Victor On Sun, Aug 9, 2009 at 7:57 PM, Dennis Lee Bieber wlfr...@ix.netcom.comwrote: On Sun, 9 Aug 2009

Re: Python 'for' loop is memory inefficient

2009-08-16 Thread Benjamin Kaplan
On Sun, Aug 16, 2009 at 2:30 AM, Emmanuel Surleau emmanuel.surl...@gmail.com wrote: I don't see what's particularly un-Pythonic with this code. Not using xrange() is a mistake, certainly, but it remains clear, easily understandable code which correctly demonstrates the naive algorithm for

Re: Xah's Edu Corner: The importance of syntax notations.

2009-08-16 Thread Peter Keller
In comp.lang.scheme Xah Lee xah...@gmail.com wrote: Xah's Edu Corner: The importance of syntax notations. http://www.stephenwolfram.com/publications/recent/mathml/mathml_abstract.html this article should teach the coding sophomorons and computer ?science? idiotic authors who harbor the

Re: my recursive function call is wrong?

2009-08-16 Thread Chang Min Jeon
Dear Kev Thank you very much. I got it.:) 2009/8/16 Kev Dwyer kevin.p.dw...@gmail.com On Sun, 16 Aug 2009 16:57:41 +0900, Chang Min Jeon wrote: Hello, You have placed recursive calls to the function in a number of different locations; when len(macro) becomes zero control will return to

Re: Python or ActionScript 3.0

2009-08-16 Thread paul
Jaseem schrieb: Hi, Is python similar to actionscript 3.0 Not really. Which is better to create a rich gui internet application? Is it AS 3.0 with flex or python with its GUI libs? Flex+AS3 definitely! (it's been designed for that, no surprise here) Is python in demand? Depends. It seems

Re: flatten a list of list

2009-08-16 Thread Scott David Daniels
Steven D'Aprano wrote: On Sun, 16 Aug 2009 02:47:42 -0700, Terry wrote: Is there a simple way (the pythonic way) to flatten a list of list? Chris' suggestion using itertools seems pretty good: from timeit import Timer setup = \\ ... L = [ [None]*5000 for _ in xrange(%d) ] ... from itertools

Re: What happened to __cmp__() in Python 3.x?

2009-08-16 Thread Raymond Hettinger
[Xavier Ho] I've recently made my way to Python 3.1 and I'm not seeing __cmp__() in the documentation. Is there a substitution for this special method in 3.1, or do I really have to define all six rich comparison methods to work it out? FWIW, there is a recipe for expanding the

Re: Python or ActionScript 3.0

2009-08-16 Thread Jaseem
On Aug 16, 9:30 pm, paul p...@subsignal.org wrote: Jaseem schrieb: Hi, Is python similar to actionscript 3.0 Not really. Which is better to create a rich gui internet application? Is it AS 3.0 with flex or python with its GUI libs? Flex+AS3 definitely! (it's been designed for that, no

Re: Splitting on '^' ?

2009-08-16 Thread kj
In ad212ad9-2cac-4a03-a25d-1d46dd527...@w41g2000yqb.googlegroups.com ru...@yahoo.com writes: On Aug 14, 2:23=A0pm, kj no.em...@please.post wrote: Sometimes I want to split a string into lines, preserving the end-of-line markers. =A0In Perl this is really easy to do, by splitting on the

Re: Komodo(!)

2009-08-16 Thread Lorenzo Bettini
Kee Nethery wrote: I've heard there is a nice add-on to Eclipse but Eclipse has even more setup variables than Wings and I've avoided it for that reason. Hi I've just started using python and since I've been an eclipse user for many years I tried http://pydev.sourceforge.net/ and I really

Re: flatten a list of list

2009-08-16 Thread Francesco Bochicchio
On Aug 16, 1:25 pm, Steven D'Aprano st...@remove-this- cybersource.com.au wrote: ... Chris' suggestion using itertools seems pretty good: from timeit import Timer setup = \\ ... L = [ [None]*5000 for _ in xrange(%d) ] ... from itertools import chain ...

Re: Python 2.6 still not giving memory back to the OS...

2009-08-16 Thread Martin v. Löwis
As far as releasing memory back to the OS is concerned, I have dim memories of *x systems where free() would return space to the OS if the block was large and it was next to the break point ... this effect could be what you are seeing. Today, there are two cases when malloc returns memory on

Re: flatten a list of list

2009-08-16 Thread Alan G Isaac
On 8/16/2009 5:47 AM Terry apparently wrote: Is there a simple way (the pythonic way) to flatten a list of list? rather than my current solution: new_list=[] for l in list_of_list: new_list.extend(l) new_list = list(xi for lst in list_of_list for xi in lst) hth, Alan Isaac --

Re: flatten a list of list

2009-08-16 Thread Paul Rubin
Terry terry.yin...@gmail.com writes: Is there a simple way (the pythonic way) to flatten a list of list? rather than my current solution: new_list=[] for l in list_of_list: new_list.extend(l) from itertools import chain new_list = list(chain(list_of_list)) --

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-16 Thread Douglas Alan
On Aug 16, 8:45 am, MRAB pyt...@mrabarnett.plus.com wrote: No, APL is strictly right-to-left.      - x means goto x. Writing to the console is:      [] - myVar Reading from the console is:      myVar - [] Ah, thanks for the correction. It's been 5,000 years since I used APL!

Re: Xah's Edu Corner: The importance of syntax notations.

2009-08-16 Thread w_a_x_man
On Aug 16, 11:05 am, Petey Keller psil...@merlin.cs.wisc.edu wrote: Compiler go through *great* pains Compiler work real hard. Compiler have heap big trouble. -- http://mail.python.org/mailman/listinfo/python-list

Re: problem with interface of operator.itemgetter

2009-08-16 Thread Simon Forman
On Thu, Aug 13, 2009 at 11:16 PM, dou dounirvana...@gmail.com wrote: I have a function to do some thing like LEFT JOIN in SQL, the function use the itemgetter to get the ON and SELECT parameters of the two table(list of list), the problem is that itemgetter may return a value or a tuple of

Re: Splitting on '^' ?

2009-08-16 Thread John Yeung
On Aug 16, 1:09 pm, kj no.em...@please.post wrote: And .splitlines seems to be able to handle all standard end-of-line markers without any special direction (which, ironically, strikes me as a *little* Perlish, somehow): It's Pythonic. Universal newline-handling for text has been a staple of

Re: Python 'for' loop is memory inefficient

2009-08-16 Thread bartc
Steven D'Aprano st...@remove-this-cybersource.com.au wrote in message news:02969972$0$20647$c3e8...@news.astraweb.com... On Fri, 14 Aug 2009 18:25:45 -0700, Dr. Phillip M. Feldman wrote: It seems as though Python is actually expanding range(2,n) into a list of numbers, even though this is

Re: Splitting on '^' ?

2009-08-16 Thread Stephen Hansen
And .splitlines seems to be able to handle all standard end-of-line markers without any special direction (which, ironically, strikes me as a *little* Perlish, somehow): spam\015\012ham\015eggs\012.splitlines(True) ['spam\r\n', 'ham\r', 'eggs\n'] ... actually working correctly and robustly

Re: random.gauss vs. random.normalvariate

2009-08-16 Thread Dave Angel
John Haggerty wrote: On Sat, Aug 15, 2009 at 7:23 PM, Dennis Lee Bieber wlfr...@ix.netcom.comwrote: On Sat, 15 Aug 2009 14:34:36 -0600, John Haggerty bouncy...@gmail.com declaimed the following in gmane.comp.python.general: What does the term thread safe mean exactly. I never had to

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-16 Thread Douglas Alan
On Aug 16, 6:18 am, Steven D'Aprano st...@remove-this- cybersource.com.au wrote: On Sun, 16 Aug 2009 01:41:41 -0700, Douglas Alan wrote: I would definitely not like a language that obscures assignment by moving it over to the right side of lines. One could argue that

Re: Xah's Edu Corner: The importance of syntax notations.

2009-08-16 Thread Peter Keller
In comp.lang.scheme w_a_x_man w_a_x_...@yahoo.com wrote: On Aug 16, 11:05?am, Petey Keller psil...@merlin.cs.wisc.edu wrote: Compiler go through *great* pains Compiler work real hard. Compiler have heap big trouble. That's a funny observation in the context of this thread--which I

Re: Python 'for' loop is memory inefficient

2009-08-16 Thread MRAB
bartc wrote: Steven D'Aprano st...@remove-this-cybersource.com.au wrote in message news:02969972$0$20647$c3e8...@news.astraweb.com... On Fri, 14 Aug 2009 18:25:45 -0700, Dr. Phillip M. Feldman wrote: It seems as though Python is actually expanding range(2,n) into a list of numbers, even

Re: Splitting a string into substrings of equal size

2009-08-16 Thread Simon Forman
On Aug 14, 8:22 pm, candide cand...@free.invalid wrote: Suppose you need to split a string into substrings of a given size (except possibly the last substring). I make the hypothesis the first slice is at the end of the string. A typical example is provided by formatting a decimal string with

XPath support?

2009-08-16 Thread kj
I'm looking for a XML parser that produces an object with full XPath support. What I've been using up to now, xml.etree.ElementTree, fails to support Xpath predicates, as in sp...@eggs='3']/ham. What I'm trying to do is to read-in a large XML string, and parse it into an object from which I

Re: XPath support?

2009-08-16 Thread Diez B. Roggisch
kj schrieb: I'm looking for a XML parser that produces an object with full XPath support. What I've been using up to now, xml.etree.ElementTree, fails to support Xpath predicates, as in sp...@eggs='3']/ham. What I'm trying to do is to read-in a large XML string, and parse it into an object

Re: XPath support?

2009-08-16 Thread Kev Dwyer
On Sun, 16 Aug 2009 20:29:15 +, kj wrote: I'm looking for a XML parser that produces an object with full XPath support. What I've been using up to now, xml.etree.ElementTree, fails to support Xpath predicates, as in sp...@eggs='3']/ham. What I'm trying to do is to read-in a large XML

Re: Python 'for' loop is memory inefficient

2009-08-16 Thread sturlamolden
On 16 Aug, 11:45, bartc ba...@freeuk.com wrote: A for-loop, for iterating over a simple sequence, should be one of the fastest things in the language. Anyone experienced with interpreted high-level languages knows this is not true. Not because iterating a sequence is expensive, but because the

Re: random.gauss vs. random.normalvariate

2009-08-16 Thread Paul Rubin
Dennis Lee Bieber wlfr...@ix.netcom.com writes: No language can guard against independent access of a shared/global object by multiple threads... http://en.wikipedia.org/wiki/Erlang_(programming_language) Like operating system processes (and unlike green threads and operating system

Re: Xah's Edu Corner: The importance of syntax notations.

2009-08-16 Thread toby
On Aug 16, 12:05 pm, Peter Keller psil...@merlin.cs.wisc.edu wrote: In comp.lang.scheme Xah Lee xah...@gmail.com wrote: Xah's Edu Corner: The importance of syntax notations. http://www.stephenwolfram.com/publications/recent/mathml/mathml_abstr... this article should teach the coding

Re: Xah's Edu Corner: The importance of syntax notations.

2009-08-16 Thread rjf
On Aug 16, 9:05 am, Peter Keller psil...@merlin.cs.wisc.edu wrote: In comp.lang.scheme Xah Lee xah...@gmail.com wrote: Xah's Edu Corner: The importance of syntax notations. http://www.stephenwolfram.com/publications/recent/mathml/mathml_abstr... this article should teach the coding

Re: Python 2.6 still not giving memory back to the OS...

2009-08-16 Thread ryles
On Aug 15, 7:55 am, Chris Withers ch...@simplistix.co.uk wrote: Hi All, I thought this was fixed back in Python 2.5, but I guess not? So, I'm playing in an interactive session:   from xlrd import open_workbook   b = open_workbook('some.xls',pickleable=0,formatting_info=1) At this point,

Re: Nltk with python

2009-08-16 Thread Aahz
In article 82c9f923-1098-4b7e-8f9d-9504c1a89...@12g2000pri.googlegroups.com, ArshaKrishna arshakrishnamt...@gmail.com wrote: How can I resolve scope ambiguity using nltk toolkit with python Question not clear, please provide more explanation -- Aahz (a...@pythoncraft.com) *

Re: redoing libgmail interface to smtplib blah?

2009-08-16 Thread Dave Angel
Dennis Lee Bieber wrote: On Sat, 15 Aug 2009 23:14:39 -0600, John Haggerty bouncy...@gmail.com declaimed the following in gmane.comp.python.general: I did detect one problem thus far File test.py, line 152 if len(args) == 1 and args[0] = -c: Should have been fine,

Re: zip codes

2009-08-16 Thread Shailen
Thanks Martin and Aahz. Anyone know if zip code information is copyrighted for the US? Anyone can look up zip codes on usps.gov (and other locations),so the information is readily available. I need zip codes for a handful of cities and could map those myself (or write a script to scrape them for

Re: Python 'for' loop is memory inefficient

2009-08-16 Thread sturlamolden
On 16 Aug, 14:57, Dennis Lee Bieber wlfr...@ix.netcom.com wrote:         Well, the alternative would be to have two keywords for looping: one for your simple incrementing integer loop, and another for a loop that operates over the elements of some collection type. A compiler could easily

Re: zip codes

2009-08-16 Thread Paul Rubin
Shailen shailen.t...@gmail.com writes: Thanks Martin and Aahz. Anyone know if zip code information is copyrighted for the US? Anyone can look up zip codes on usps.gov (and other locations),so the information is readily available. I need zip codes for a handful of cities and could map those

Re: zip codes

2009-08-16 Thread Paul Rubin
It was a long time ago, I don't remember specifics, and the contents are surely out of date by now, but I extracted a bunch of the TIGER geographic coordinates for zip codes here: http://www.nightsong.com/phr/chess/zipcodes.zip That file may have actually come from here:

Re: zip codes

2009-08-16 Thread Grant Edwards
On 2009-08-16, Shailen shailen.t...@gmail.com wrote: Thanks Martin and Aahz. Anyone know if zip code information is copyrighted for the US? You can't copyright information as such. Only concrete expressions of information. A particular publication containing zip code information can be

Re: Python 'for' loop is memory inefficient

2009-08-16 Thread Benjamin Kaplan
On Sun, Aug 16, 2009 at 6:35 PM, sturlamolden sturlamol...@yahoo.no wrote: A compiler could easily recognise a statement like   for i in range(n): as a simple integer loop. In fact, Cython is able to do this. but special cases aren't special enough to break the rules. --

Re: Python 'for' loop is memory inefficient

2009-08-16 Thread John Machin
On Aug 17, 8:35 am, sturlamolden sturlamol...@yahoo.no wrote: A compiler could easily recognise a statement like    for i in range(n): as a simple integer loop. In fact, Cython is able to do this. Extremely easy, once users relinquish the right to replace built-in range with their own

Re: Python 'for' loop is memory inefficient

2009-08-16 Thread exarkun
On 01:23 am, benjamin.kap...@case.edu wrote: On Sun, Aug 16, 2009 at 6:35 PM, sturlamolden sturlamol...@yahoo.no wrote: A compiler could easily recognise a statement like � for i in range(n): as a simple integer loop. In fact, Cython is able to do this. but special cases aren't special

Re: Python 'for' loop is memory inefficient

2009-08-16 Thread Paul Rubin
exar...@twistedmatrix.com writes: Although I think PyPy also recognizes this case and makes it as efficient as using xrange, and does so without breaking any rules. How can pypy possibly know that the user hasn't assigned some other value to range? --

Re: Python 'for' loop is memory inefficient

2009-08-16 Thread Carl Banks
On Aug 16, 6:28 pm, exar...@twistedmatrix.com wrote: On 01:23 am, benjamin.kap...@case.edu wrote: On Sun, Aug 16, 2009 at 6:35 PM, sturlamolden sturlamol...@yahoo.no wrote: A compiler could easily recognise a statement like   for i in range(n): as a simple integer loop. In fact, Cython

Re: Python 'for' loop is memory inefficient

2009-08-16 Thread Carl Banks
On Aug 16, 3:35 pm, sturlamolden sturlamol...@yahoo.no wrote: On 16 Aug, 14:57, Dennis Lee Bieber wlfr...@ix.netcom.com wrote:         Well, the alternative would be to have two keywords for looping: one for your simple incrementing integer loop, and another for a loop that operates over

  1   2   >