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

2010-01-31 Thread Aliaksandr Abushkevich
Maybe it is a good idea to use Disco (http://discoproject.org/) to process your data. Yours faithfully, Alexander Abushkevich On Sat, Jan 30, 2010 at 10:36 PM, marc magrans de abril wrote: > Dear colleagues, > > I was doing a small program to classify log files for a cluster of > PCs, I just w

pyjon: pythonic javascript interpreter

2010-01-31 Thread buzz
hi, Here is: http://code.google.com/p/pyjon/ Although the code is far from stable and completed, it's a good place to start play with. -- Evgen -- http://mail.python.org/mailman/listinfo/python-list

Re: unencountered error in FFT python

2010-01-31 Thread Mark Dickinson
On Jan 30, 8:20 pm, uche wrote: > Another issue: >     x[a], x[b] = x[(a)] + W[(n % N)] * x[(b)], x[(a)] - W[(n % N)] * x > [(b)] > TypeError: can't multiply sequence by non-int of type 'complex' With your original code, the elements of array2 are strings, and here Python is refusing to multiply

Re: unencountered error in FFT python

2010-01-31 Thread Mark Dickinson
On Jan 31, 10:02 am, Mark Dickinson wrote: > Python is refusing to multiply the string x[a] by the complex number W > [n % N]. Whoops, that should have been "x[b]", not "x[a]". Why is it that a post-submission proofread turns up errors so much more often than a pre-submission proofread? -- Mark

Re: PEP 3147 - new .pyc format

2010-01-31 Thread Martin v. Loewis
> Naming files using magic numbers is really beyond me. The fact that the > above needs comments to explain what's what already shows to me that > there's a problem with this naming scheme. What if for one reason or > another I want to delete all pyc files for Python 2.5? Where do I look > up the m

Re: PEP 3147 - new .pyc format

2010-01-31 Thread Martin v. Loewis
> True. You might also want to note that "Python 2.6 -U" appears to have a > different magic number from "Python 2.6" and "Python 2.6 -O". > > I don't know whether they always change for each new version. Here is a recent list of magic numbers: Python 2.6a0: 62151 (peephole optimizations a

Re: unencountered error in FFT python

2010-01-31 Thread Stefan Behnel
Mark Dickinson, 31.01.2010 11:07: > On Jan 31, 10:02 am, Mark Dickinson wrote: >> Python is refusing to multiply the string x[a] by the complex number W >> [n % N]. > > Whoops, that should have been "x[b]", not "x[a]". Why is it that a > post-submission proofread turns up errors so much more oft

Re: Python and Ruby

2010-01-31 Thread rantingrick
On Jan 30, 10:43 am, Nobody 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 most sense. Its to easy to m

Re: Python and Ruby

2010-01-31 Thread Steven D'Aprano
On Sun, 31 Jan 2010 03:01:51 -0800, rantingrick wrote: > On Jan 30, 10:43 am, Nobody 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 w

Re: Keyboard input

2010-01-31 Thread Mr.SpOOn
2010/1/29 Gabriel Genellina : > > That's strange. If you're using Linux, make sure you have the readline > package installed. I'm using Linux. Ubuntu. I checked on synaptic and I have readline-common. Do you mean something else? Anyway I tried running the program in the iPython shell and it works

create a string of variable lenght

2010-01-31 Thread Tracubik
Hi all, i want to print on linux console (terminal) a message like this one: error message of variable lenght to print the asterisks line i do this: def StringOfAsterisks(myString): asterisksString = "*" for i in range(1,

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, 6:35 AM > On Sun, 31 Jan 2010 03:01:51 -0800, > rantingrick wrote: > > > On Jan 30, 10:43 am, Nobody > wrote: > > > >> That's also

Re: create a string of variable lenght

2010-01-31 Thread Tim Chase
Tracubik wrote: error message of variable lenght to print the asterisks line i do this: def StringOfAsterisks(myString): asterisksString = "*" for i in range(1,len(myString): asterisksString += "*" print aster

Re: create a string of variable lenght

2010-01-31 Thread Peter Otten
Tracubik wrote: > Hi all, > > i want to print on linux console (terminal) a message like this one: > > > error message of variable lenght > > > to print the asterisks line i do this: > > def StringOfAsterisks(myString): > as

Re: create a string of variable lenght

2010-01-31 Thread Günther Dietrich
Tracubik wrote: >i want to print on linux console (terminal) a message like this one: > > >error message of variable lenght > > >to print the asterisks line i do this: > >def StringOfAsterisks(myString): >asterisksString = "*" >

Re: Unable to install numpy

2010-01-31 Thread vsoler
On Jan 18, 9:08 pm, Robert Kern wrote: > On 2010-01-18 14:02 PM, vsoler wrote: > > > Hi all, > > > I just download Numpy, and tried to install it using "numpy-1.4.0- > > win32-superpack-python2.6.exe" > > > I get an error:  "Python version 2.6 required, which was not found in > > the Registry" > >

Re: PEP 3147 - new .pyc format

2010-01-31 Thread Andrej Mitrovic
Leave magic to the witches of Perl. :) -- http://mail.python.org/mailman/listinfo/python-list

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

2010-01-31 Thread marc magrans de abril
>Find out which pattern is being used on the second iteration and then try it >on the first iteration. Is it just as slow? You were right, the second pattern was 1891 bytes but the first was just 142 :P I will need to put more thought than I expect in the "small script". -- http://mail.python.or

Re: PEP 3147 - new .pyc format

2010-01-31 Thread John Bokma
Steven D'Aprano writes: > On Sun, 31 Jan 2010 04:44:18 +0100, Alf P. Steinbach wrote: > >>> The relationship between byte code magic number and release version >>> number is not one-to-one. We could have, for the sake of the argument, >>> releases 3.2.3 through 3.5.0 (say) all having the same byt

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

2010-01-31 Thread skip
I have the pytz package but it doesn't know about non-standard timezone names like "CDT5" or "CST6". I can obviously infer that they are either five or six hours behind UTC. Are they constructed in some standard way so that I can assume that if a timezone name is not known to pytz I can assume t

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

2010-01-31 Thread Xavier Ho
This may not answer your question directly, but have you thought about ingoring the number at the end of these non-standard timezones? CDT is Central Daylight-saving Timezone, while CST is Central Standard Timezone. And you are correct they are -5 and -6 hours respectively. Does pytz know about CDT

How to set default encoding for print?

2010-01-31 Thread 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 PS: BTW, sys.setdefaultencoding

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

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

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

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

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

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

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()

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

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: 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: 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: 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 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: 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: 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: 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: 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 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: 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'\'

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  1   2   >