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

2009-08-16 Thread Hendrik van Rooyen
>"Steven D'Aprano" 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, and it's probably

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 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 rich comparison methods to work it out?

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 Lawrence 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 ri

Re: random.gauss vs. random.normalvariate

2009-08-16 Thread Chris Rebert
> On Sat, Aug 15, 2009 at 10:18 PM, Paul Rubin > wrote: >> >> Dennis Lee Bieber 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 Hagger

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" 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

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 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 clas

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 programming

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 && [email protected] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 18 N 121 57 W && AIM/Y!M/Skype erikmaxfrancis Get there

Re: ignored test cases in unittest

2009-08-16 Thread Duncan Booth
Ben Finney wrote: > Terry 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 class, ‘TestSkipped’ > > * raisin

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 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 programmi

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 wrote: > > 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 classes' natural ordering

Re: Splitting a string into substrings of equal size

2009-08-16 Thread Gregor Lingl
Mark Tolonen schrieb: "Gregor Lingl" wrote in message news:[email protected]... 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 = '1234567890123456789' >>> ",".

Re: flatten a list of list

2009-08-16 Thread Chris Rebert
On Sun, Aug 16, 2009 at 5:47 AM, 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) > > or, > > new_list=reduce(lambda x,y:x.extend(y), list_of_list) #only ma

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 Lawrence 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 rich com

Re: ignored test cases in unittest

2009-08-16 Thread Terry
On Aug 16, 5:25 pm, Duncan Booth wrote: > Ben Finney wrote: > > Terry 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 cust

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. On

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 Janssen 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, shouldn't suc

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 Janssen 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).

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, 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) >> >> or

Re: flatten a list of list

2009-08-16 Thread Chris Rebert
On Sun, Aug 16, 2009 at 6:49 AM, Steven D'Aprano wrote: > On Sun, 16 Aug 2009 05:55:48 -0400, Chris Rebert wrote: >> On Sun, Aug 16, 2009 at 5:47 AM, Terry wrote: >>> Hi, >>> >>> Is there a simple way (the pythonic way) to flatten a list of list? >>> rather than my current solution: >>> >>> new_lis

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

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 doe

Re: Problem Regarding Handling of Unicode string

2009-08-16 Thread joy99
On Aug 11, 1:17 pm, John Machin wrote: > On Aug 10, 9:26 pm, joy99 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 functions and other functions witho

Re: flatten a list of list

2009-08-16 Thread Terry
On Aug 16, 6:59 pm, Chris Rebert wrote: > On Sun, Aug 16, 2009 at 6:49 AM, Steven > > > > > > D'Aprano wrote: > > On Sun, 16 Aug 2009 05:55:48 -0400, Chris Rebert wrote: > >> On Sun, Aug 16, 2009 at 5:47 AM, Terry wrote: > >>> Hi, > > >>> Is there a simple way (the pythonic way) to flatten a list

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

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 Pythoni

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'Aprano 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 marginally *simpler

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 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 rich comparison methods to wor

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 wrote: > > 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 this time! > I'm no

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 majo

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

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 wrote: 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 this time!

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 us

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 Haggerty wrote: > This is an

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 fur

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" i

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 virtu

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 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. > > I have now wri

Re: callable virtual method

2009-08-16 Thread Christian Heimes
Jean-Michel Pichavant wrote: [email protected] 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 -- http://mail.python.org/mailman/listinf

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 No

Re: callable virtual method

2009-08-16 Thread jean-michel Pichavant
Christian Heimes a écrit : Jean-Michel Pichavant wrote: [email protected] 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 w

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 wrote: > On Sun, 9 Aug 2009 15:21:43 -0500,

Re: Python 'for' loop is memory inefficient

2009-08-16 Thread Benjamin Kaplan
On Sun, Aug 16, 2009 at 2:30 AM, Emmanuel Surleau 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 detecting whether n is a >

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

2009-08-16 Thread Peter Keller
In comp.lang.scheme Xah Lee 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 notion that

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 > 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 func

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 itertoo

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 c

Re: Python or ActionScript 3.0

2009-08-16 Thread Jaseem
On Aug 16, 9:30 pm, paul 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 surp

Re: Splitting on '^' ?

2009-08-16 Thread kj
In [email protected] writes: >On Aug 14, 2:23=A0pm, kj 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 beginning-of-line anchor: >> >> =A0 @lines =3D split /^/, $string; >> >> But I can't

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 e

Re: flatten a list of list

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

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 mem

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 -- h

Re: flatten a list of list

2009-08-16 Thread Paul Rubin
Terry 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)) -- http://mail.python.org/mailman/listinfo/py

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 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! |>ouglas -- ht

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 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 dou 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 > values, because

Re: Splitting on '^' ?

2009-08-16 Thread John Yeung
On Aug 16, 1:09 pm, kj 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 Python for as

Re: Python 'for' loop is memory inefficient

2009-08-16 Thread bartc
"Steven D'Aprano" wrote in message news:[email protected]... 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 incredibly wasteful of memory. There

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

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 wrote: On Sat, 15 Aug 2009 14:34:36 -0600, John Haggerty declaimed the following in gmane.comp.python.general: What does the term "thread safe" mean exactly. I never had to program with "threads" be

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 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 left-assigned-from-right assignment obscures the > mo

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

2009-08-16 Thread Peter Keller
In comp.lang.scheme w_a_x_man wrote: > On Aug 16, 11:05?am, Petey Keller 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 appreciate, since syntax really is the cornersto

Re: Python 'for' loop is memory inefficient

2009-08-16 Thread MRAB
bartc wrote: "Steven D'Aprano" wrote in message news:[email protected]... 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 incredibly wasteful of

Re: Splitting a string into substrings of equal size

2009-08-16 Thread Simon Forman
On Aug 14, 8:22 pm, candide 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 thousands > separ

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 c

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 fr

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

Re: Python 'for' loop is memory inefficient

2009-08-16 Thread sturlamolden
On 16 Aug, 11:45, "bartc" 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 interpreter

Re: random.gauss vs. random.normalvariate

2009-08-16 Thread Paul Rubin
Dennis Lee Bieber 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 threads) t

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

2009-08-16 Thread toby
On Aug 16, 12:05 pm, Peter Keller wrote: > In comp.lang.scheme Xah Lee 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 sophomorons and computer > > ?scienc

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

2009-08-16 Thread rjf
On Aug 16, 9:05 am, Peter Keller wrote: > In comp.lang.scheme Xah Lee 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 sophomorons and computer > > ?science

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 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, top sho

Re: Nltk with python

2009-08-16 Thread Aahz
In article <[email protected]>, ArshaKrishna wrote: > >How can I resolve scope ambiguity using nltk toolkit with python Question not clear, please provide more explanation -- Aahz ([email protected]) <*> http://www.pythoncraft.

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 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, unless my memory of s

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 me

Re: Python 'for' loop is memory inefficient

2009-08-16 Thread sturlamolden
On 16 Aug, 14:57, Dennis Lee Bieber 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 recognise a statement

Re: zip codes

2009-08-16 Thread Paul Rubin
Shailen 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 myself (or write a > s

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: http://www

Re: zip codes

2009-08-16 Thread Grant Edwards
On 2009-08-16, Shailen 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 copyrighted. The underl

Re: Python 'for' loop is memory inefficient

2009-08-16 Thread Benjamin Kaplan
On Sun, Aug 16, 2009 at 6:35 PM, sturlamolden 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. -- http://mail.python.org/mailman/lis

Re: Python 'for' loop is memory inefficient

2009-08-16 Thread John Machin
On Aug 17, 8:35 am, sturlamolden 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 concoctions ... -- htt

Re: Python 'for' loop is memory inefficient

2009-08-16 Thread exarkun
On 01:23 am, [email protected] wrote: On Sun, Aug 16, 2009 at 6:35 PM, sturlamolden 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 Paul Rubin
[email protected] 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"? -- http://mail.python.org/mailman/listinfo

Re: Python 'for' loop is memory inefficient

2009-08-16 Thread Carl Banks
On Aug 16, 6:28 pm, [email protected] wrote: > On 01:23 am, [email protected] wrote: > > >On Sun, Aug 16, 2009 at 6:35 PM, sturlamolden > >wrote: > > >>A compiler could easily recognise a statement like > > >>  for i in range(n): > > >>as a simple integer loop. In fact, Cython is ab

Re: Python 'for' loop is memory inefficient

2009-08-16 Thread Carl Banks
On Aug 16, 3:35 pm, sturlamolden wrote: > On 16 Aug, 14:57, Dennis Lee Bieber 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 ty

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

2009-08-16 Thread Nobody
On Sun, 16 Aug 2009 05:05:01 +, Steven D'Aprano 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, Placing the stream on the LHS allows the main forms

[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 and

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

2009-08-16 Thread Jon Harrop
w_a_x_man wrote: > On Aug 16, 11:05 am, Petey Keller wrote: >> Compiler go through *great* pains > > Compiler work real hard. > Compiler have heap big trouble. ROTFL. :-) -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/?u -- http://mail.python.org/mailman/listin

Re: Python 'for' loop is memory inefficient

2009-08-16 Thread Nobody
On Sun, 16 Aug 2009 11:41:21 -0400, Benjamin Kaplan wrote: > It's not that the code is bad, but too many people coming from Java > and C keep thinking of for loops like they're using Java or C and > therefore that "for i in range(a,b)" is identical to "for(int i = a; i > < b; i++)". It's not and,

Re: Social problems of Python doc [was Re: Python docs disappointing]

2009-08-16 Thread Xah Lee
Thanks Raymond. I've been out of python community for a couple of years. I've saved your messages and will study it later when next time i work in python. Possibly today and will reply in some of your points. But just wanted to say thanks for improving python. Also, sometimes ago out of the blue

  1   2   >