Re: Python and Ruby

2010-01-31 Thread Paul Rubin
Chris Rebert writes: > get_popular_name would have the type: IO () -> IO String I don't know if it makes the explanation any clearer, but I think that isn't quite right. The Python version would have type String -> IO String. The parameterless Haskell version would just be an I/O action, with

Re: Python and Ruby

2010-01-31 Thread Steven D'Aprano
On Sun, 31 Jan 2010 22:43:56 -0800, alex23 wrote: > Steven D'Aprano wrote: >> You're using that term wrong. It looks to me that you don't actually >> know what a straw man argument is. A straw man argument is when >> somebody responds to a deliberately weakened or invalid argument as if >> it had

Re: Python and Ruby

2010-01-31 Thread Chris Rebert
On Sun, Jan 31, 2010 at 10:05 PM, Steven D'Aprano wrote: > On Sun, 31 Jan 2010 20:22:36 -0800, Paul Rubin wrote: >> Terry Reedy writes: >>> Three of you gave essentially identical answers, but I still do not see >>> how given something like >>> >>> def f(): return 1 >>> >>> I differentiate betwee

Re: Python and Ruby

2010-01-31 Thread alex23
Steven D'Aprano wrote: > You're using that term wrong. It looks to me that you don't actually know > what a straw man argument is. A straw man argument is when somebody > responds to a deliberately weakened or invalid argument as if it had been > made by their opponent. Jeez, Steve, you're beginn

Re: Python and Ruby

2010-01-31 Thread Steven D'Aprano
On Sun, 31 Jan 2010 21:30:15 -0600, John Bokma wrote: > While braces might be considered redundant they are not when for one > reason or another formatting is lost or done incorrectly. I've heard this argument before, and I don't buy it. Why should we expect the editor to co

Re: Python and Ruby

2010-01-31 Thread Paul Rubin
Steven D'Aprano writes: > How would Haskell coders write it? Something like this? > > def get_popular_name(url): > data = fetch url > names = parse data > name = choose name 1 > return name The syntax and types would be different, but ok, something like that. > name = get_popular

Re: Python and Ruby

2010-01-31 Thread Steven D'Aprano
On Sun, 31 Jan 2010 18:53:16 -0600, John Bokma wrote: > You don't have to buy my argument, I am not selling it. It's a figure of speech. You are making an argument others have made before, and I don't accept the validity of the argument. -- Steven -- http://mail.python.org/mailman/listinfo/p

Re: A performance issue when using default value

2010-01-31 Thread Steven D'Aprano
On Sun, 31 Jan 2010 20:58:50 -0800, keakon wrote: > I've found strange performance issue when using default value, the test > code is list below: > > from timeit import Timer > > def f(x): > y = x > y.append(1) > return y > > def g(x=[]): > y = [] > y.append(1) > return y > > def h

Re: Python and Ruby

2010-01-31 Thread Steven D'Aprano
On Sun, 31 Jan 2010 20:22:36 -0800, Paul Rubin wrote: > Terry Reedy writes: >> Three of you gave essentially identical answers, but I still do not see >> how given something like >> >> def f(): return 1 >> >> I differentiate between 'function object at address xxx' and 'int 1' >> objects. > > In

Re: A performance issue when using default value

2010-01-31 Thread alex23
keakon wrote: > The default value is mutable, and can be reused by all each call. > So each call it will append 1 to the default value, that's very > different than C++. Being different from C++ is one of the many reasons some of us choose Python ;) This tends to bite most newcomers, so it's men

Re: A performance issue when using default value

2010-01-31 Thread keakon
On 2月1日, 下午1时20分, alex23 wrote: > alex23 wrote: > > keakon wrote: > > > def h2(x=[]): > > > y = x > > > y.append(1) > > > return y + [] > > > Are you aware that 'y = x' _doesn't_ make a copy of [], that it > > actually points to the same list as x? > > Sorry, I meant to suggest trying the

Re: A performance issue when using default value

2010-01-31 Thread alex23
alex23 wrote: > keakon wrote: > > def h2(x=[]): > >   y = x > >   y.append(1) > >   return y + [] > > Are you aware that 'y = x' _doesn't_ make a copy of [], that it > actually points to the same list as x? Sorry, I meant to suggest trying the following instead: def h2(x=None): if x is None:

Re: A performance issue when using default value

2010-01-31 Thread Chris Rebert
On Sun, Jan 31, 2010 at 8:58 PM, keakon wrote: > I've found strange performance issue when using default value, the > test code is list below: > > from timeit import Timer > > def f(x): >  y = x >  y.append(1) >  return y > > def g(x=[]): >  y = [] >  y.append(1) >  return y > > def h(x=[]): >  y

Re: A performance issue when using default value

2010-01-31 Thread alex23
keakon wrote: > def h2(x=[]): >   y = x >   y.append(1) >   return y + [] > h2() is about 42 times slower than h2([]), but h() is a litter faster > than h([]). Are you aware that 'y = x' _doesn't_ make a copy of [], that it actually points to the same list as x? My guess is that the slowdown yo

A performance issue when using default value

2010-01-31 Thread keakon
I've found strange performance issue when using default value, the test code is list below: from timeit import Timer def f(x): y = x y.append(1) return y def g(x=[]): y = [] y.append(1) return y def h(x=[]): y = x y.append(1) return y def f2(x): y = x y.append(1) return

Re: [Edu-sig] odd drawing problem with turtle.py

2010-01-31 Thread kirby urner
On Sun, Jan 31, 2010 at 8:07 PM, Vern Ceder wrote: > kirby urner wrote: >> >> I don't see where you've defined a Turtle class to instantiate sir. > > The Turtle class is part of the turtle library, so that's not an issue. > Hey, good point Vern, not firing on all cylinders over here. So I just c

Re: odd drawing problem with turtle.py

2010-01-31 Thread Alf P. Steinbach
* John Posner: > I'm on Python 2.5, but using the updated turtle.py Version 1.0.1 - 24. 9. 2009. > The following script draws 5 circles, which it is supposed to, but then > doesn't draw the second turtle which is supposed to simply move forward. > Any ideas? Try commenting out this stateme

Re: Python and Ruby

2010-01-31 Thread Paul Rubin
Terry Reedy writes: > Three of you gave essentially identical answers, but I still do not > see how given something like > > def f(): return 1 > > I differentiate between 'function object at address xxx' and 'int 1' > objects. In the languages they are talking about, there is no such thing as a f

Re: odd drawing problem with turtle.py

2010-01-31 Thread John Posner
> I'm on Python 2.5, but using the updated turtle.py Version 1.0.1 - 24. 9. 2009. > The following script draws 5 circles, which it is supposed to, but then > doesn't draw the second turtle which is supposed to simply move forward. > Any ideas? Try commenting out this statement: self.turtle.t

Re: Python and Ruby

2010-01-31 Thread Terry Reedy
On 1/31/2010 7:25 PM, Steven D'Aprano wrote: On Sun, 31 Jan 2010 15:40:36 -0800, Chris Rebert wrote: On Sun, Jan 31, 2010 at 2:36 PM, Steven D'Aprano wrote: On Sun, 31 Jan 2010 04:28:41 -0800, Ed Keith wrote: In most functional languages you just name a function to access it and you do it A

Re: Python and Ruby

2010-01-31 Thread John Bokma
Steven D'Aprano writes: > On Sun, 31 Jan 2010 18:47:42 -0600, John Bokma wrote: > >> Steven D'Aprano writes: >> >>> On Sun, 31 Jan 2010 14:47:08 -0600, John Bokma wrote: >>> An editor can correct the indenting of the braces example but can't with this one. if x:

Re: whassup? builtins? python3000? Naah can't be right?

2010-01-31 Thread Terry Reedy
On 1/31/2010 4:17 PM, _wolf wrote: but why does ``__builtins__`` change its meaning depending on whether this is the scope of the ‘script’ (i.e. the module whose name was present, when calling ``python foobar.py``) or whether this is the scope of a secondary module (imported or executed, directl

Re: Python distutils build problems with MinGW

2010-01-31 Thread Andrej Mitrovic
On Feb 1, 2:59 am, Andrej Mitrovic wrote: > Hi, > > I've made a similar post on the Cython mailing list, however I think > this is more python-specific. I'm having trouble setting up distutils > to use MinGW instead of Visual Studio when building a module. Even tho > I've just uninstalled VS, and

Re: recv_into(bytearray) complains about a "pinned buffer"

2010-01-31 Thread Martin v. Loewis
> In Python 2.6 I can't socket.recv_into(a byte array instance). I get a > TypeError which complains about a "pinned buffer". I have only an > inkling of what that means. A pinned buffer is one that cannot move in memory, even if another thread tries to behind your back. Typically, resizable conta

Python distutils build problems with MinGW

2010-01-31 Thread Andrej Mitrovic
Hi, I've made a similar post on the Cython mailing list, however I think this is more python-specific. I'm having trouble setting up distutils to use MinGW instead of Visual Studio when building a module. Even tho I've just uninstalled VS, and cleared out any leftover VS environment variables, dis

Re: [Edu-sig] odd drawing problem with turtle.py

2010-01-31 Thread kirby urner
I don't see where you've defined a Turtle class to instantiate sir. Perhaps rename Circle to Turtle and rewrite the circle-drawing expression as: > c=Turtle(randint(-350,350),randint(-250,250),10,"red") You are making progress with a wrapper class for the Standard Library turtle. That's a w

Re: recv_into(bytearray) complains about a "pinned buffer"

2010-01-31 Thread Andrew Dalke
On Feb 1, 1:04 am, Antoine Pitrou wrote: > The problem is that socket.recv_into() in 2.6 doesn't recognize the new > buffer API which is needed to accept bytearray objects. > (it does in 3.1, because the old buffer API doesn't exist anymore there) That's about what I thought it was, but I don't k

Re: Python and Ruby

2010-01-31 Thread Steven D'Aprano
On Sun, 31 Jan 2010 18:47:42 -0600, John Bokma wrote: > Steven D'Aprano writes: > >> On Sun, 31 Jan 2010 14:47:08 -0600, John Bokma wrote: >> >>> An editor can correct the indenting of the braces example but can't >>> with this one. >>> >>> if x: >>> if y: >>> foo() >>> else:

Re: Python and Ruby

2010-01-31 Thread Chris Rebert
On Sun, Jan 31, 2010 at 5:22 PM, Steven D'Aprano wrote: > On Sun, 31 Jan 2010 16:50:50 -0800, Chris Rebert wrote: > How do you call a function of no arguments? It's not really a function in that case, it's just a named constant. (Recall that functions don't/can't have side-effec

Re: Python and Ruby

2010-01-31 Thread Ed Keith
--- On Sun, 1/31/10, Steven D'Aprano wrote: > From: Steven D'Aprano > Subject: Re: Python and Ruby > To: python-list@python.org > Date: Sunday, January 31, 2010, 8:22 PM > On Sun, 31 Jan 2010 16:50:50 -0800, > Chris Rebert wrote: > > How do you call a function of no > arguments? > >>> > >

Re: Python and Ruby

2010-01-31 Thread Steven D'Aprano
On Sun, 31 Jan 2010 16:50:50 -0800, Chris Rebert wrote: How do you call a function of no arguments? >>> >>> It's not really a function in that case, it's just a named constant. >>> (Recall that functions don't/can't have side-effects.) >> >> > time.time(), random.random() >> (1264983502.7

Re: gmtime

2010-01-31 Thread pograph
On Jan 31, 4:01 pm, gazza wrote: > On Jan 31, 3:27 pm, gazza wrote: > > > Hi, > > > I am trying to discover how to obtain the correct time of say CST/ > > America and EST/America in python? > > > Any help on this would be appreciated. > > > Thanks, > > Garyc > > I found some information. Someone

Re: Python and Ruby

2010-01-31 Thread John Bokma
Steven D'Aprano writes: > On Sun, 31 Jan 2010 14:47:08 -0600, John Bokma wrote: > >> An editor can correct the indenting of the braces example but can't with >> this one. >> >> if x: >> if y: >> foo() >> else: >> bar() >> >> While braces might be considered redundant th

Re: create a string of variable lenght

2010-01-31 Thread Benjamin Kaplan
On Sun, Jan 31, 2010 at 5:12 PM, Tracubik wrote: > Il Sun, 31 Jan 2010 13:46:16 +0100, Günther Dietrich ha > scritto: > >> Maybe you might solve this if you decode your string to unicode. >> Example: >> >> |>>> euro = "€" >> |>>> len(euro) >> |3 >> |>>> u_euro = euro.decode('utf_8') >> |>>> len(u_

Re: Python and Ruby

2010-01-31 Thread Chris Rebert
On Sun, Jan 31, 2010 at 4:25 PM, Steven D'Aprano wrote: > On Sun, 31 Jan 2010 15:40:36 -0800, Chris Rebert wrote: >> On Sun, Jan 31, 2010 at 2:36 PM, Steven D'Aprano >> wrote: >>> On Sun, 31 Jan 2010 04:28:41 -0800, Ed Keith wrote: In most functional languages you just name a function to acc

Re: Python and Ruby

2010-01-31 Thread John Bokma
Steven D'Aprano writes: > On Sun, 31 Jan 2010 14:47:08 -0600, John Bokma wrote: > >> An editor can correct the indenting of the braces example but can't with >> this one. >> >> if x: >> if y: >> foo() >> else: >> bar() >> >> While braces might be considered redundant th

Re: Python and Ruby

2010-01-31 Thread Steven D'Aprano
On Sun, 31 Jan 2010 15:40:36 -0800, Chris Rebert wrote: > On Sun, Jan 31, 2010 at 2:36 PM, Steven D'Aprano > wrote: >> On Sun, 31 Jan 2010 04:28:41 -0800, Ed Keith wrote: >>> In most functional languages you just name a function to access it and >>> you do it ALL the time. >>> >>> for example, in

odd drawing problem with turtle.py

2010-01-31 Thread Brian Blais
I'm on Python 2.5, but using the updated turtle.py Version 1.0.1 - 24. 9. 2009. The following script draws 5 circles, which it is supposed to, but then doesn't draw the second turtle which is supposed to simply move forward. Any ideas? from turtle import * from numpy.random import randint

Re: Python and Ruby

2010-01-31 Thread Ed Keith
--- On Sun, 1/31/10, Steven D'Aprano wrote: > From: Steven D'Aprano > Subject: Re: Python and Ruby > To: python-list@python.org > Date: Sunday, January 31, 2010, 5:36 PM > On Sun, 31 Jan 2010 04:28:41 -0800, > Ed Keith wrote: > > > In most functional languages you just name a function > to acc

Re: iglob performance no better than glob

2010-01-31 Thread Kyp
On Jan 31, 2:44 pm, Peter Otten <__pete...@web.de> wrote: > Kyp wrote: > > I have a dir with a large # of files that I need to perform operations > > on, but only needing to access a subset of the files, i.e. the first > > 100 files. > > > Using glob is very slow, so I ran across iglob, which retur

Re: iglob performance no better than glob

2010-01-31 Thread Kyp
On Jan 31, 1:06 pm, John Bokma wrote: > Kyp writes: > > Is there a way to get the first X # of files from a dir with lots of > > files, that does not take a long time to run? > > Assuming Linux: what does time > >  ls thedir | head > > give? > > with thedir the name of the actual dir about 3 seco

Re: Python and Ruby

2010-01-31 Thread Arnaud Delobelle
Steven D'Aprano writes: > On Sun, 31 Jan 2010 04:28:41 -0800, Ed Keith wrote: > >> In most functional languages you just name a function to access it and >> you do it ALL the time. >> >> for example, in if you have a function 'f' which takes two parameters to >> call the function and get the res

Re: recv_into(bytearray) complains about a "pinned buffer"

2010-01-31 Thread Antoine Pitrou
Hello Andrew, > I don't even know what a "pinned buffer" means, and searching python.org > isn't helpful. > > Using a bytearray in Python 3.1.1 *does* work: > [...] Agreed, the error message is cryptic. The problem is that socket.recv_into() in 2.6 doesn't recognize the new buffer API which is

Re: gmtime

2010-01-31 Thread gazza
On Jan 31, 3:27 pm, gazza wrote: > Hi, > > I am trying to discover how to obtain the correct time of say CST/ > America and EST/America in python? > > Any help on this would be appreciated. > > Thanks, > Garyc I found some information. Someone suggested I use the pytz library? Cheers, Garyc --

Re: Python and Ruby

2010-01-31 Thread Chris Rebert
On Sun, Jan 31, 2010 at 2:36 PM, Steven D'Aprano wrote: > On Sun, 31 Jan 2010 04:28:41 -0800, Ed Keith wrote: >> In most functional languages you just name a function to access it and >> you do it ALL the time. >> >> for example, in if you have a function 'f' which takes two parameters to >> call

Re: ftp.storlines error

2010-01-31 Thread Mik0b0
On Feb 1, 12:19 am, Chris Rebert wrote: > On Sun, Jan 31, 2010 at 2:07 PM, Mik0b0 wrote: > > Good day/night/etc. > > I am rather a newb in Python (learning Python 3). I am trying to > > create a small script for FTP file uploads  on my home network. The > > script looks like this: > > > from ftpl

Re: create a string of variable lenght

2010-01-31 Thread MRAB
Tracubik wrote: Il Sun, 31 Jan 2010 13:46:16 +0100, Günther Dietrich ha scritto: Maybe you might solve this if you decode your string to unicode. Example: |>>> euro = "€" |>>> len(euro) |3 |>>> u_euro = euro.decode('utf_8') |>>> len(u_euro) |1 Adapt the encoding ('utf_8' in my example) to wha

Re: Keyboard input

2010-01-31 Thread Steven D'Aprano
On Sun, 31 Jan 2010 14:10:34 -0800, Dennis Lee Bieber wrote: > On Sun, 31 Jan 2010 11:51:46 +, "Mr.SpOOn" > declaimed the following in gmane.comp.python.general: > >> 2010/1/29 Gabriel Genellina : >> > >> > That's strange. If you're using Linux, make sure you have the >> > readline package i

Re: PEP 3147 - new .pyc format

2010-01-31 Thread Steven D'Aprano
On Sun, 31 Jan 2010 14:10:34 -0800, Dennis Lee Bieber wrote: > Ugh... That would mean that for an application using, say 20 > files, > one now has 20 subdirectories for what, in a lot of cases, will contain > just one file each (and since I doubt older Python's will be modified to > support

Re: Slow down while creating a big list and iterating over it

2010-01-31 Thread MRAB
marc magrans de abril wrote: Hi! ...I have found a good enough solution, although it only works if the number of patterns (clusters) is not very big: def classify(f): THERESHOLD=0.1 patterns={} for l in enumerate(f): found = False for p,c in patterns.items():

Re: Python and Ruby

2010-01-31 Thread Steven D'Aprano
On Sun, 31 Jan 2010 14:47:08 -0600, John Bokma wrote: > An editor can correct the indenting of the braces example but can't with > this one. > > if x: > if y: > foo() > else: > bar() > > While braces might be considered redundant they are not when for one > reason or ano

Re: PEP 3147 - new .pyc format

2010-01-31 Thread Steven D'Aprano
On Sun, 31 Jan 2010 09:06:18 -0600, John Bokma wrote: > Based on the magic numbers I've seen so far it looks like that not an > option. They increment with every minor change. They increment with every *incompatible* change to the marshal format, not every change to the compiler. > So to me, a

Re: Python and Ruby

2010-01-31 Thread Steven D'Aprano
On Sun, 31 Jan 2010 04:28:41 -0800, Ed Keith wrote: > In most functional languages you just name a function to access it and > you do it ALL the time. > > for example, in if you have a function 'f' which takes two parameters to > call the function and get the result you use: > > f 2 3 > > If y

Re: Can't get sys.stdin.readlines() to work

2010-01-31 Thread tinnews
Richard Thomas wrote: > On Jan 31, 6:15 pm, tinn...@isbd.co.uk wrote: > > I'm trying to read some data from standard input, what I'm actually > > trying to do is process some date pasted in using the mouse cut and > > paste on a Linux box (xubuntu 9.10) in a terminal window. > > > > First attempts

recv_into(bytearray) complains about a "pinned buffer"

2010-01-31 Thread Andrew Dalke
In Python 2.6 I can't socket.recv_into(a byte array instance). I get a TypeError which complains about a "pinned buffer". I have only an inkling of what that means. Since an array.array("b") works there, and since it works in Python 3.1.1, and since I thought the point of a bytearray was to make th

Re: ftp.storlines error

2010-01-31 Thread Chris Rebert
On Sun, Jan 31, 2010 at 2:07 PM, Mik0b0 wrote: > Good day/night/etc. > I am rather a newb in Python (learning Python 3). I am trying to > create a small script for FTP file uploads  on my home network. The > script looks like this: > > from ftplib import FTP > ftp=FTP('10.0.0.1') > ftp.login('mike

Re: create a string of variable lenght

2010-01-31 Thread Tracubik
Il Sun, 31 Jan 2010 13:46:16 +0100, Günther Dietrich ha scritto: > Maybe you might solve this if you decode your string to unicode. > Example: > > |>>> euro = "€" > |>>> len(euro) > |3 > |>>> u_euro = euro.decode('utf_8') > |>>> len(u_euro) > |1 > > Adapt the encoding ('utf_8' in my example) to

ftp.storlines error

2010-01-31 Thread Mik0b0
Good day/night/etc. I am rather a newb in Python (learning Python 3). I am trying to create a small script for FTP file uploads on my home network. The script looks like this: from ftplib import FTP ftp=FTP('10.0.0.1') ftp.login('mike','*') directory='/var/www/blabla/' ftp.cwd(directory) ftp.

Re: What's the Scoop on \\ for Paths? (Win)

2010-01-31 Thread Nobody
On Sun, 31 Jan 2010 13:41:55 -0600, Tim Chase wrote: > The previous absolute-path fails in cmd.exe for a variety of apps because > the "/" is treated as a parameter/switch to the various programs. > Fortunately, the Python path-handling sub-system is smart enough to do the > right thing, even whe

Re: PEP 3147 - new .pyc format

2010-01-31 Thread Benjamin Peterson
Sean DiZazzo gmail.com> writes: > Does "magic" really need to be used? Why not just use the revision > number? Because magic is easier and otherwise CPython developers would have to rebuild their pycs everytime their working copy was updated. -- http://mail.python.org/mailman/listinfo/python-

Re: iglob performance no better than glob

2010-01-31 Thread Benjamin Peterson
Kyp stsci.edu> writes: > So the iglob was faster, but accessing the first file took about the > same time as glob.glob. That would be because glob is implemented in terms of iglob. -- http://mail.python.org/mailman/listinfo/python-list

Re: OT: Instant Messenger Clients

2010-01-31 Thread Adam Tauno Williams
On Sun, 2010-01-31 at 13:15 -0800, Victor Subervi wrote: > Hi; > I need to record my IM conversations. I'm using Gmal's IM client and I > can't figure out how to do it, nor do I find any help googling it. Is > it possible with Gmail? If so, how? If not, is there a good IM client > that will allow m

whassup? builtins? python3000? Naah can't be right?

2010-01-31 Thread _wolf
dear pythoneers, i would be very gladly accept any commentaries about what this sentence, gleaned from http://celabs.com/python-3.1/reference/executionmodel.html, is meant to mean, or why gods have decided this is the way to go. i anticipate this guy named Kay Schluehr will have a say on that, or

OT: Instant Messenger Clients

2010-01-31 Thread Victor Subervi
Hi; I need to record my IM conversations. I'm using Gmal's IM client and I can't figure out how to do it, nor do I find any help googling it. Is it possible with Gmail? If so, how? If not, is there a good IM client that will allow me to do this? TIA, beno -- The Logos has come to bear http://logo

Re: Utility to screenscrape sites using javascript ?

2010-01-31 Thread Nobody
On Sat, 30 Jan 2010 11:28:47 -0800, KB wrote: >> > I have a service I subscribe to that uses javascript to stream news. > >> There's a Python interface to SpiderMonkey (Mozilla's JavaScript >> interpreter): >> >> http://pypi.python.org/pypi/python-spidermonkey > > Thanks! I don't see a documenta

Re: Why this error message

2010-01-31 Thread Ryan Kelly
On Sun, 2010-01-31 at 15:25 -0500, Ray Holt wrote: > Why am I getting the error that test is not defined. Thanks, Ray > class SpecialFile: > def __init__(self, fileName): > self.__file = open(fileName, 'W') > self.__file.write('* Start Special File *\n\n') > def wri

Re: Python and Ruby

2010-01-31 Thread John Bokma
Nobody writes: > Configurable tab stops in a text editor is one of those "features" that > differentiates a "coder" from a software engineer. A coder implements it > because it's easy to implement, without giving a moment's thought to the > wider context (such as: how to communicate the non-stand

Re: Python and Ruby

2010-01-31 Thread Nobody
On Sun, 31 Jan 2010 03:01:51 -0800, rantingrick wrote: >> That's also true for most functional languages, e.g. Haskell and ML, as >> well as e.g. Tcl and most shells. Why require "f(x)" or "(f x)" if "f x" >> will suffice? > > yuck! wrapping the arg list with parenthesis (python way) makes the mo

ANN: blist 1.1.1 - now with sortedlist, sortedset, and sorteddict

2010-01-31 Thread Daniel Stutzbach
blist 1.1.1 is now available: http://pypi.python.org/pypi/blist/ What is blist? -- The blist is a drop-in replacement for the Python list the provides better performance when modifying large lists. Python's built-in list is a dynamically-sized array; to insert or removal an

Re: What's the Scoop on \\ for Paths? (Win)

2010-01-31 Thread Alf P. Steinbach
* Tim Chase: Alf P. Steinbach wrote: that you cannot write e.g. "c:\windows\system32", but must write something like "c:\\windows\\system32" (try to print that string), or, since Windows handles forward slashes as well, you can write "c:/windows/system32" :-). Forward slashes work for some rel

Why this error message

2010-01-31 Thread Ray Holt
Why am I getting the error that test is not defined. Thanks, Ray class SpecialFile: def __init__(self, fileName): self.__file = open(fileName, 'W') self.__file.write('* Start Special File *\n\n') def write(self, str): self.__file.write(str) def writeline

Re: Python and Ruby

2010-01-31 Thread Nobody
On Sat, 30 Jan 2010 16:58:34 +, tanix wrote: >>I'm not familiar with Ruby, but most languages are cleaner than Python >>once you get beyond the "10-minute introduction" stage. > > I'd have to agree. The only ones that beat Python in that department are > Javascript and PHP. Plus CSS and HTML

Re: Slow down while creating a big list and iterating over it

2010-01-31 Thread marc magrans de abril
Hi! ...I have found a good enough solution, although it only works if the number of patterns (clusters) is not very big: def classify(f): THERESHOLD=0.1 patterns={} for l in enumerate(f): found = False for p,c in patterns.items(): if dist(l,p) < THERESHOLD:

Re: PEP 3147 - new .pyc format

2010-01-31 Thread Sean DiZazzo
> Here is a recent list of magic numbers: > >        Python 2.6a0: 62151 (peephole optimizations and STORE_MAP opcode) >        Python 2.6a1: 62161 (WITH_CLEANUP optimization) >        Python 2.7a0: 62171 (optimize list comprehensions/change LIST_APPEND) >        Python 2.7a0: 62181 (optimize cond

Re: What's the Scoop on \\ for Paths? (Win)

2010-01-31 Thread MRAB
W. eWatson wrote: Steve Holden wrote: You need to read up on string literals is all. "\\" is simply the literal representation of a string containing a single backslash. This comes about because string literals are allowed to contain special "escape sequences" which are introduced by a backslas

HTML Parser which allows low-keyed local changes?

2010-01-31 Thread Robert
I tried lxml, but after walking and making changes in the element tree, I'm forced to do a full serialization of the whole document (etree.tostring(tree)) - which destroys the "human edited" format of the original HTML code. makes it rather unreadable. is there an existing HTML parser which su

Re: What's the Scoop on \\ for Paths? (Win)

2010-01-31 Thread Tim Chase
W. eWatson wrote: What am I missing here? Looks OK to me. >>> abc.replace(r'\',r'z') SyntaxError: invalid syntax A raw string can't end in a single backslash (something that occasionally annoys me, but I've learned to deal with it). >>> s=r'\' File "", line 1 s=r'\'

Re: What's the Scoop on \\ for Paths? (Win)

2010-01-31 Thread Steve Holden
W. eWatson wrote: > Steve Holden wrote: > >> You need to read up on string literals is all. "\\" is simply the >> literal representation of a string containing a single backslash. This >> comes about because string literals are allowed to contain special >> "escape sequences" which are introduced

Re: iglob performance no better than glob

2010-01-31 Thread Peter Otten
Kyp wrote: > I have a dir with a large # of files that I need to perform operations > on, but only needing to access a subset of the files, i.e. the first > 100 files. > > Using glob is very slow, so I ran across iglob, which returns an > iterator, which seemed just like what I wanted. I could it

Re: What's the Scoop on \\ for Paths? (Win)

2010-01-31 Thread W. eWatson
Steve Holden wrote: You need to read up on string literals is all. "\\" is simply the literal representation of a string containing a single backslash. This comes about because string literals are allowed to contain special "escape sequences" which are introduced by a backslash; since this gives

Re: What's the Scoop on \\ for Paths? (Win)

2010-01-31 Thread Tim Chase
Alf P. Steinbach wrote: that you cannot write e.g. "c:\windows\system32", but must write something like "c:\\windows\\system32" (try to print that string), or, since Windows handles forward slashes as well, you can write "c:/windows/system32" :-). Forward slashes work for some relative paths fo

Re: How to pass Chinese characters as command-line arguments?

2010-01-31 Thread kj
In <7slr5ife6...@mid.uni-berlin.de> "Diez B. Roggisch" writes: >Am 31.01.10 16:52, schrieb kj: >> I want to pass Chinese characters as command-line arguments to a >> Python script. My terminal has no problem displaying these >> characters, and passing them to the script, but I can't get Python

Re: Can't get sys.stdin.readlines() to work

2010-01-31 Thread Grant Edwards
On 2010-01-31, Steve Holden wrote: > tinn...@isbd.co.uk wrote: >> I'm trying to read some data from standard input, what I'm actually >> trying to do is process some date pasted in using the mouse cut and >> paste on a Linux box (xubuntu 9.10) in a terminal window. >> >> First attempts failed so

Re: What's the Scoop on \\ for Paths? (Win)

2010-01-31 Thread W. eWatson
Alf P. Steinbach wrote: * W. eWatson: I'm sure that \\ is used in some way for paths in Win Python, but I have not found anything after quite a search. I even have a six page pdf on a file tutorial. Nothing. Two books. Nothing. When I try to open a file along do I need, for example, "Events\\

Re: Can't get sys.stdin.readlines() to work

2010-01-31 Thread Steve Holden
tinn...@isbd.co.uk wrote: > I'm trying to read some data from standard input, what I'm actually > trying to do is process some date pasted in using the mouse cut and > paste on a Linux box (xubuntu 9.10) in a terminal window. > > First attempts failed so I'm now trying the trivial:- > > impor

Re: Can't get sys.stdin.readlines() to work

2010-01-31 Thread Richard Thomas
On Jan 31, 6:15 pm, tinn...@isbd.co.uk wrote: > I'm trying to read some data from standard input, what I'm actually > trying to do is process some date pasted in using the mouse cut and > paste on a Linux box (xubuntu 9.10) in a terminal window. > > First attempts failed so I'm now trying the trivi

Re: What's the Scoop on \\ for Paths? (Win)

2010-01-31 Thread Steve Holden
W. eWatson wrote: > I'm sure that \\ is used in some way for paths in Win Python, but I have > not found anything after quite a search. I even have a six page pdf on a > file tutorial. Nothing. Two books. Nothing. When I try to open a file > along do I need, for example, "Events\\record\\year\\toda

Re: What's the Scoop on \\ for Paths? (Win)

2010-01-31 Thread Alf P. Steinbach
* W. eWatson: I'm sure that \\ is used in some way for paths in Win Python, but I have not found anything after quite a search. I even have a six page pdf on a file tutorial. Nothing. Two books. Nothing. When I try to open a file along do I need, for example, "Events\\record\\year\\today"? Are

Can't get sys.stdin.readlines() to work

2010-01-31 Thread tinnews
I'm trying to read some data from standard input, what I'm actually trying to do is process some date pasted in using the mouse cut and paste on a Linux box (xubuntu 9.10) in a terminal window. First attempts failed so I'm now trying the trivial:- import sys data = sys.stdin.readlines()

What's the Scoop on \\ for Paths? (Win)

2010-01-31 Thread W. eWatson
I'm sure that \\ is used in some way for paths in Win Python, but I have not found anything after quite a search. I even have a six page pdf on a file tutorial. Nothing. Two books. Nothing. When I try to open a file along do I need, for example, "Events\\record\\year\\today"? Are paths like, ".

Re: iglob performance no better than glob

2010-01-31 Thread John Bokma
Kyp writes: > Is there a way to get the first X # of files from a dir with lots of > files, that does not take a long time to run? Assuming Linux: what does time ls thedir | head give? with thedir the name of the actual dir Also how many is many files? -- John Bokma

Re: iglob performance no better than glob

2010-01-31 Thread Skip Montanaro
> So the iglob was faster, but accessing the first file took about the > same time as glob.glob. I'll wager most of the time required to access the first file is due to filesystem overhead, not any inherent limitation in Python. Skip Montanaro -- http://mail.python.org/mailman/listinfo/python-

Re: How to get UTC offset for non-standard time zone names?

2010-01-31 Thread Skip Montanaro
> Would it hurt if you put in some extra information? > http://www.timeanddate.com/library/abbreviations/timezones/ In theory, no. At work we still use the ancient Rogue Wave C++ libraries in a number of applications. It has hard-coded timezone info so when the US changed the start and end of da

Re: How to pass Chinese characters as command-line arguments?

2010-01-31 Thread Diez B. Roggisch
Am 31.01.10 16:52, schrieb kj: I want to pass Chinese characters as command-line arguments to a Python script. My terminal has no problem displaying these characters, and passing them to the script, but I can't get Python to understand them properly. E.g. if I pass one such character to the sim

Re: How to get UTC offset for non-standard time zone names?

2010-01-31 Thread Xavier Ho
Would it hurt if you put in some extra information? http://www.timeanddate.com/library/abbreviations/timezones/ HTH, -Xav P.S: You, sir, have an awesome first name. On Mon, Feb 1, 2010 at 1:57 AM, Skip Montanaro wrote: > > Does pytz know about CDT and CST? > > Nope... > > Skip > > > -- > htt

Re: How to set default encoding for print?

2010-01-31 Thread kj
In <7slndhfno...@mid.uni-berlin.de> "Diez B. Roggisch" writes: >Am 31.01.10 16:38, schrieb kj: >> It gets tedious to have to append .encode('utf-8') to all my unicode >> strings when I print them, as in: >> >> print foobar.encode('utf-8') >> >> I want to tell python to apply this encoding a

iglob performance no better than glob

2010-01-31 Thread Kyp
I have a dir with a large # of files that I need to perform operations on, but only needing to access a subset of the files, i.e. the first 100 files. Using glob is very slow, so I ran across iglob, which returns an iterator, which seemed just like what I wanted. I could iterate over the files tha

Re: How to get UTC offset for non-standard time zone names?

2010-01-31 Thread Skip Montanaro
> Does pytz know about CDT and CST? Nope... Skip -- http://mail.python.org/mailman/listinfo/python-list

Re: How to set default encoding for print?

2010-01-31 Thread Diez B. Roggisch
Am 31.01.10 16:38, schrieb kj: It gets tedious to have to append .encode('utf-8') to all my unicode strings when I print them, as in: print foobar.encode('utf-8') I want to tell python to apply this encoding automatically to anything argument passed to print. How can I do this? TIA! K

How to pass Chinese characters as command-line arguments?

2010-01-31 Thread kj
I want to pass Chinese characters as command-line arguments to a Python script. My terminal has no problem displaying these characters, and passing them to the script, but I can't get Python to understand them properly. E.g. if I pass one such character to the simple script import sys print sy

  1   2   >