Re: python reading file memory cost

2011-08-01 Thread Chris Rebert
On Mon, Aug 1, 2011 at 8:22 PM, Tony Zhang wrote: > Thanks! > > Actually, I used .readline() to parse file line by line, because I need > to find out the start position to extract data into list, and the end > point to pause extracting, then repeat until the end of file. > My file to read is forma

Re: Spam

2011-08-01 Thread Chris Angelico
On Tue, Aug 2, 2011 at 4:58 AM, Ghodmode wrote: > I hope it's clear that reading an email doesn't constitute visiting all of > the sites linked in the email and therefore doesn't improve Google page > ranks or provide any other tracking information.  Also note that the > original email didn't have

Re: python reading file memory cost

2011-08-01 Thread Dan Stromberg
You could try forcing a garbage collection... On Mon, Aug 1, 2011 at 8:22 PM, Tony Zhang wrote: > Thanks! > > Actually, I used .readline() to parse file line by line, because I need > to find out the start position to extract data into list, and the end > point to pause extracting, then repeat u

Map-based module imports with import hook

2011-08-01 Thread mpj
Hi, I've experience working at companies where, because of the network set up, having a long PYTHONPATH and searching it is quite a heavy task and can slow down the start up of the interpreter when there are lots of imports. As a proof of concept I wanted to look at a map-based approach. The theo

Re: Spam

2011-08-01 Thread Ghodmode
On Tue, Aug 2, 2011 at 3:17 AM, harrismh777 wrote: > Steven D'Aprano wrote: > >> I've noticed that python-list gets significantly more spam than the >>> > other lists I subscribe to. There's an example below. >>> >> Thanks for that! I missed it the first time, so it is very helpful for you >> t

Re: python reading file memory cost

2011-08-01 Thread Tony Zhang
Thanks! Actually, I used .readline() to parse file line by line, because I need to find out the start position to extract data into list, and the end point to pause extracting, then repeat until the end of file. My file to read is formatted like this: blabla...useless useless... /sign/ data

Re: test systems

2011-08-01 Thread James Matthews
Wow, why don't you find some cloud providers and write bootstrap programs. James On Mon, Aug 1, 2011 at 6:35 PM, Dan Stromberg wrote: > > I've been testing my Python code on these using virtualbox and/or physical > machines (but mostly virtualbox): > > CentOS 6.0 > Debian > DragonflyBSD > Fedor

Re: test systems

2011-08-01 Thread Chris Angelico
On Mon, Aug 1, 2011 at 11:42 PM, Ethan Furman wrote: > Howdy, > > I'm going to setup a few linux systems for testing (probably three) as well > as the three FreeBSD, OpenBSD, and (possibly) NetBsd.  Oh, and Windows.  ;) > > Any recommendations on which linuces to pick? Others have made recommenda

RE: Convert '165.0' to int

2011-08-01 Thread Prasad, Ramit
-Original Message- From: python-list-bounces+ramit.prasad=jpmchase@python.org [mailto:python-list-bounces+ramit.prasad=jpmchase@python.org] On Behalf Of Gregory Ewing Sent: Sunday, July 24, 2011 7:05 PM To: python-list@python.org Subject: Re: Convert '165.0' to int Frank Millman

RE: Convert '165.0' to int

2011-08-01 Thread Prasad, Ramit
-Original Message- From: python-list-bounces+ramit.prasad=jpmchase@python.org [mailto:python-list-bounces+ramit.prasad=jpmchase@python.org] On Behalf Of Frank Millman Sent: Monday, July 25, 2011 12:51 AM To: python-list@python.org Subject: Re: Convert '165.0' to int On Jul 25, 2:

Re: test systems

2011-08-01 Thread Thomas Jollans
On 02/08/11 00:42, Ethan Furman wrote: > Howdy, > > I'm going to setup a few linux systems for testing (probably three) as > well as the three FreeBSD, OpenBSD, and (possibly) NetBsd. Oh, and > Windows. ;) > > Any recommendations on which linuces to pick? I would say that the Debian vs Red Hat

Re: os.path.dirname(sys.argv[0]) always returns nothing

2011-08-01 Thread Gregory Ewing
Thijs Engels wrote: argv[0] returns the name of the current file (string), but no path information if I recall correct. It's the path that was used to specify the script by whatever launched it, so it could be either absolute or relative to the current directory. -- Greg -- http://mail.python

Re: Hostmonster : Installing MySQLdb at a specific location

2011-08-01 Thread Tim Johnson
* Tim Johnson [110731 11:47]: > I don't want to discourage any further input, but I'm looking at > https://my.hostmonster.com/cgi/help/000531?step=000531 > regarding installing django and I think the instructions can be > extrapolated for MySQLdb. I will report what happens... I received a l

Re: test systems

2011-08-01 Thread Steven D'Aprano
Ethan Furman wrote: > Howdy, > > I'm going to setup a few linux systems for testing (probably three) as > well as the three FreeBSD, OpenBSD, and (possibly) NetBsd. Oh, and > Windows. ;) > > Any recommendations on which linuces to pick? What are you testing? Is this for buildbots? Are you tes

Re: test systems

2011-08-01 Thread Alister Ware
On Mon, 01 Aug 2011 15:42:19 -0700, Ethan Furman wrote: > Howdy, > > I'm going to setup a few linux systems for testing (probably three) as > well as the three FreeBSD, OpenBSD, and (possibly) NetBsd. Oh, and > Windows. ;) > > Any recommendations on which linuces to pick? > > ~Ethan~ I would

Re: test systems

2011-08-01 Thread Dan Stromberg
I've been testing my Python code on these using virtualbox and/or physical machines (but mostly virtualbox): CentOS 6.0 Debian DragonflyBSD Fedora 15 FreeBSD Haiku R1 alpha 3 Linux Mint Minix OpenIndiana openSUSE Sabayon Scientific Linux 6 Slackware Solaris Express Ubuntu Windows 7 Sadly, I don't

test systems

2011-08-01 Thread Ethan Furman
Howdy, I'm going to setup a few linux systems for testing (probably three) as well as the three FreeBSD, OpenBSD, and (possibly) NetBsd. Oh, and Windows. ;) Any recommendations on which linuces to pick? ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: where the function has problem? n = 900 is OK , but n = 1000 is ERROR

2011-08-01 Thread Steven D'Aprano
Billy Mays wrote: > I have fixed the problem for you: > > > def fibo(n): > phi = (1+5**.5)/2; iphi = 1-phi; > return (phi**n - iphi**n) / (5**.5) Does your definition of "fixed" mean "gives wrong results for n >= 4 "? >>> fibo(4) == 3 False -- Steven -- http://mail.python.org/

Re: Spam

2011-08-01 Thread harrismh777
Steven D'Aprano wrote: I've noticed that python-list gets significantly more spam than the > other lists I subscribe to. There's an example below. Thanks for that! I missed it the first time, so it is very helpful for you to forward it. It's especially helpful that you included all the spammer

Re: os.path.dirname(sys.argv[0]) always returns nothing

2011-08-01 Thread Chris Angelico
On Mon, Aug 1, 2011 at 6:55 PM, Thijs Engels wrote: > argv[0] returns the name of the current file (string), but no path > information if I recall correct. It will give path information if you're invoking a script from another directory. Under some circumstances it might happen to give an absolut

Re: os.path.dirname(sys.argv[0]) always returns nothing

2011-08-01 Thread John Gordon
In <9797b629-3fba-4b90-920f-e42668359...@a12g2000vbf.googlegroups.com> happykid writes: > I want to use this function to get the directory path of the running > script, but it always returns empty string. Can anyone help me solve > this? Thank you. What is the value of sys.argv[0]? You're supp

Re: os.path.dirname(sys.argv[0]) always returns nothing

2011-08-01 Thread Benjamin Kaplan
On Mon, Aug 1, 2011 at 1:38 PM, happykid wrote: > I want to use this function to get the directory path of the running > script, but it always returns empty string. Can anyone help me solve > this? Thank you. > -- > sys.argv[0] is the name of the script you called. If you call "python spam.py",

Re: os.path.dirname(sys.argv[0]) always returns nothing

2011-08-01 Thread Thijs Engels
On Mon, 01 Aug 2011 10:38 -0700, "happykid" wrote: > I want to use this function to get the directory path of the running > script, but it always returns empty string. Can anyone help me solve > this? Thank you. > -- > http://mail.python.org/mailman/listinfo/python-list I think this is what you

Re: os.path.dirname(sys.argv[0]) always returns nothing

2011-08-01 Thread Chris Angelico
On Mon, Aug 1, 2011 at 6:38 PM, happykid wrote: > I want to use this function to get the directory path of the running > script, but it always returns empty string. Can anyone help me solve > this? Thank you. As long as you haven't changed directory since startup, you should be able to use os.pat

Re: What's in a name?

2011-08-01 Thread Andrew Berg
Hmm How about Rainbow Video Encoder Wrapper (Rainbow View for short - RView is taken, possibly multiple times)? I added an arbitrary word to a generic name, and the result doesn't seem to be taken by anything software-related. It wraps more than just video encoders (in fact, x264 will likely be

Re: Complex sort on big files

2011-08-01 Thread Peter Otten
aliman wrote: > Apologies I'm sure this has been asked many times, but I'm trying to > figure out the most efficient way to do a complex sort on very large > files. > > I've read the recipe at [1] and understand that the way to sort a > large file is to break it into chunks, sort each chunk and w

Re: Complex sort on big files

2011-08-01 Thread Dan Stromberg
Python 2.x, or Python 3.x? What are the types of your sort keys? If you're on 3.x and the key you need reversed is numeric, you can negate the key. If you're on 2.x, you can use an object with a __cmp__ method to compare objects however you require. You probably should timsort the chunks (which

Re: python reading file memory cost

2011-08-01 Thread Dan Stromberg
A code snippet would work wonders in making sure you've communicated what you really need, or at least what you have now. But if you read the data into one big string, that'll be much more efficient than if you read it as a list of integers or even as a list of lines. Processing the data one chun

Notifications when process is killed

2011-08-01 Thread Andrea Di Mario
Thanks Thomas, it is what i'm looking for. Regards -- Andrea Di Mario -- http://mail.python.org/mailman/listinfo/python-list

Complex sort on big files

2011-08-01 Thread aliman
Hi all, Apologies I'm sure this has been asked many times, but I'm trying to figure out the most efficient way to do a complex sort on very large files. I've read the recipe at [1] and understand that the way to sort a large file is to break it into chunks, sort each chunk and write sorted chunks

Re: python reading file memory cost

2011-08-01 Thread Thomas Jollans
On 01/08/11 17:05, Tong Zhang wrote: > Hello, everyone! > > > > I am trying to read a little big txt file (~1 GB) by python2.7, what I > want to do is to read these data into a array, meanwhile, I monitor the > memory cost, I found that it cost more than 6 GB RAM! So I have two > questions: >

Re: PEP 8 and extraneous whitespace

2011-08-01 Thread Thomas 'PointedEars' Lahn
OKB (not okblacke) wrote: > Thomas 'PointedEars' Lahn wrote: >> Automatic word-wrap, where available, really is not a solution; it >> is a bad workaround to a problem caused by the original author of >> the source code that can be easily avoided by them taking more care >> while coding. > >

python reading file memory cost

2011-08-01 Thread Tong Zhang
Hello, everyone! I am trying to read a little big txt file (~1 GB) by python2.7, what I want to do is to read these data into a array, meanwhile, I monitor the memory cost, I found that it cost more than 6 GB RAM! So I have two questions: 1: How to estimate memory cost before exec python scrip

Re: where the function has problem? n = 900 is OK , but n = 1000 is ERROR

2011-08-01 Thread Thomas Rachel
Am 01.08.2011 11:11 schrieb jc: except: print "EXCEPT: " + str(n) If you catch all exceptions here, it is clear that you only get this. Why don't you do except Exception, e: print "EXCEPT: " + str(n), e ? Then you could at least ask "why do I get a unsupported operand typ

Re: where the function has problem? n = 900 is OK , but n = 1000 is ERROR

2011-08-01 Thread Billy Mays
On 08/01/2011 05:11 AM, jc wrote: # Get Fibonacci Value #Fibonacci(N) = Fibonacci(N-1) + Fibonacci(N-2) # # n = 900 is OK # n = 1000 is ERROR , Why # # What Wrong? # I have fixed the problem for you: def fibo(n): phi = (1+5**.5)/2; iphi = 1-phi; return (phi**n - iphi**n) / (5**.5)

Re: [ANN] IPython 0.11 is officially out

2011-08-01 Thread Thorsten Kampe
* Fernando Perez (Sun, 31 Jul 2011 17:26:50 + (UTC)) > on behalf of the IPython development team, I'm thrilled to announce, > after more than two years of development work, the official release of > IPython 0.11. > > This release brings a long list of improvements and new features > (along wit

Re: how to solve it?

2011-08-01 Thread Michael Poeltl
* 守株待兔 <1248283...@qq.com> [2011-08-01 06:22]: > from matplotlib.matlab import * > Traceback (most recent call last): > File "", line 1, in > ImportError: No module named matlab is this what you were looking for? >>> from matplotlib.pylab import * cheers Michael -- Michael Poeltl Computationa

Re: Question

2011-08-01 Thread mark ferguson
Peter - well caught! I've been wondering how that line could have arisen when running a script through the interpreter from the command line! Pasting it into Idle gives exactly that output. It was the leading $ that threw me, I took it as the shell prompt. I think that Camilo was actually typing i

Re: Spam

2011-08-01 Thread Matty Sarro
I agree, the Bollywood spam sucks. There's not even any boobies! On Aug 1, 2011 4:16 AM, "Steven D'Aprano" < steve+comp.lang.pyt...@pearwood.info> wrote: > Ghodmode wrote: > >> I've noticed that python-list gets significantly more spam than the >> other lists I subscribe to. There's an example belo

How add/change password for RSA priv key using PyCrypto

2011-08-01 Thread k2
Hi, maybe somebody be able to help me. I'm using PyCrypto to generate a pair of RSA keys. The public key and private key. I try to add a password to the private key, and I do not know how to do it. This is a piece of my code. #encoding:utf-8 from Crypto.PublicKey import RSA pass_alice='ala' priv

Re: where the function has problem? n = 900 is OK , but n = 1000 is ERROR

2011-08-01 Thread Ulrich Eckhardt
Steven D'Aprano wrote: > jc wrote: >> n = 900 >> cache = range(0 , n + 1 , 1) >> for i in cache: >> cache[i] = -1 > > This is a waste of time. Better to write: > > cache = [-1]*900 Since he's computing the Fibonacci number of n, and n is 900, he needs cache = [-1] * (n + 1)

Re: where the function has problem? n = 900 is OK , but n = 1000 is ERROR

2011-08-01 Thread Dave Angel
On 01/-10/-28163 02:59 PM, jc wrote: # Get Fibonacci Value #Fibonacci(N) = Fibonacci(N-1) + Fibonacci(N-2) # # n = 900 is OK # n = 1000 is ERROR , Why # # What Wrong? # cache = [] def fibo( n ): try: if cache[n] != -1: return cache[n] else:

Re: how to solve it?

2011-08-01 Thread Michael Poeltl
* 守株待兔 <1248283...@qq.com> [2011-08-01 06:22]: > from matplotlib.matlab import * > Traceback (most recent call last): > File "", line 1, in > ImportError: No module named matlab does this work? >>> import matplotlib next check 'gallery' at http://matplotlib.sourceforge.net/index.html choose t

Re: Notifications when process is killed

2011-08-01 Thread Thomas Jollans
On 01/08/11 11:56, Andrea Di Mario wrote: > Hi, i've created a twisted server application and i want that the > server send me a message when someone stops or kills the process. > I want to override reactor.stop(), but do this way send me message > when the process is stopped by a system kill? > Co

Notifications when process is killed

2011-08-01 Thread Andrea Di Mario
Hi, i've created a twisted server application and i want that the server send me a message when someone stops or kills the process. I want to override reactor.stop(), but do this way send me message when the process is stopped by a system kill? Could you suggest me if there's a way to do this? Tha

Re: where the function has problem? n = 900 is OK , but n = 1000 is ERROR

2011-08-01 Thread Gennadiy Zlobin
The maximum depth of the Python interpreter stack is limited to 1000 calls by default. You can get it by import sys; sys.getrecursionlimit() and set a new value to sys.setrecursionlimit(new_value) - Gennadiy On Mon, Aug 1, 2011 at 4:11 PM, jc wrote: > # Get Fibonacci Value > #Fibonacci(N

Re: where the function has problem? n = 900 is OK , but n = 1000 is ERROR

2011-08-01 Thread Steven D'Aprano
jc wrote: > # Get Fibonacci Value > #Fibonacci(N) = Fibonacci(N-1) + Fibonacci(N-2) > # > # n = 900 is OK > # n = 1000 is ERROR , Why How should we know? Please tell us what the error is, don't expect us to guess. [...] > if __name__ == '__main__': > # This n = 900 is OK > # But n = 1000 is

where the function has problem? n = 900 is OK , but n = 1000 is ERROR

2011-08-01 Thread jc
# Get Fibonacci Value #Fibonacci(N) = Fibonacci(N-1) + Fibonacci(N-2) # # n = 900 is OK # n = 1000 is ERROR , Why # # What Wrong? # cache = [] def fibo( n ): try: if cache[n] != -1: return cache[n] else: if 0 == n: r = 0

Re: Question

2011-08-01 Thread Peter Otten
Camilo Andres Roca Duarte wrote: > My name is Camilo Roca, I'm a student and recently installed the 2.7.2 > Python version. The problem is that anytime I try to run a script from the > Python Shell it returns an error message. I am new using python so I am > not sure what to do since what I'm typi

Re: Question

2011-08-01 Thread Steven D'Aprano
Camilo Andres Roca Duarte wrote: > Hello > My name is Camilo Roca, I'm a student and recently installed the 2.7.2 > Python version. The problem is that anytime I try to run a script from the > Python Shell it returns an error message. I am new using python so I am > not sure what to do since what

Re: Question

2011-08-01 Thread Andrew Berg
On 2011.07.30 06:38 PM, Camilo Andres Roca Duarte wrote: > $ python myfunctions.py > SyntaxError: invalid syntax It helps to include the full traceback. If we don't know the code that caused the error, it's pretty hard to say what went wrong, especially with an exception as broad as SyntaxError. It

Re: Question

2011-08-01 Thread Chris Angelico
On Sun, Jul 31, 2011 at 12:38 AM, Camilo Andres Roca Duarte wrote: > $ python myfunctions.py > SyntaxError: invalid syntax > This is an error from Python, so it probably means something is wrong in your .py file. Check the contents of the file with 'cat myfunctions.py'. Is the first line the one

Code War at PyCon Au 2011

2011-08-01 Thread Ryan Kelly
A huge hit at PyCon-Au last year, Code War is back! Eight teams, onstage knockout rounds of short programming bouts, loud crowd...mildly impressive prizes. Any language allowed, no holds bared. Think of it like cage fighting for coders. Originally based on an idea from the book PeopleWare,

Question

2011-08-01 Thread Camilo Andres Roca Duarte
Hello My name is Camilo Roca, I'm a student and recently installed the 2.7.2 Python version. The problem is that anytime I try to run a script from the Python Shell it returns an error message. I am new using python so I am not sure what to do since what I'm typing in the shell is in a Begginers

Re: PyWart: os.path needs immediate attention!

2011-08-01 Thread Teemu Likonen
* 2011-07-30T10:57:29+10:00 * Steven D'Aprano wrote: > Teemu Likonen wrote: >> Pathnames and the separator for pathname components should be >> abstracted away, to a pathname object. > > Been there, done that, floundered on the inability of people to work > out the details. > > http://www.python.o

Re: Spam

2011-08-01 Thread Steven D'Aprano
Ghodmode wrote: > I've noticed that python-list gets significantly more spam than the > other lists I subscribe to. There's an example below. Thanks for that! I missed it the first time, so it is very helpful for you to forward it. It's especially helpful that you included all the spammer's URLs