Re: Guido rethinking removal of cmp from sort method

2011-03-28 Thread Dan Stromberg
On Mon, Mar 28, 2011 at 6:58 PM, Paul Rubin wrote: > DSU is a clever and useful design pattern, but comparison > sorting is what all the sorting textbooks are written about. > Actually, even though I wrote one program that could almost benefit from cmp sorting that might have trouble with key so

Re: Directly Executable Files in Python

2011-03-28 Thread Benjamin Kaplan
On Tue, Mar 29, 2011 at 12:16 AM, harrismh777 wrote: > Chris Rebert wrote: >> >> Yes. py2exe is a tool which generates such Windows executables: >> http://www.py2exe.org/ > > Interesting... but it can't possibly be creating .exe files (compiling)... I > don't buy it... it has to be reproducing the

Re: Directly Executable Files in Python

2011-03-28 Thread harrismh777
Chris Rebert wrote: Yes. py2exe is a tool which generates such Windows executables: http://www.py2exe.org/ Interesting... but it can't possibly be creating .exe files (compiling)... I don't buy it... it has to be reproducing the byte code interpreter in the code segment and the byte code in t

Re: Directly Executable Files in Python

2011-03-28 Thread Chris Rebert
On Mon, Mar 28, 2011 at 8:37 PM, Jordan Meyer wrote: > Is it possible to make a directly executable (such as .exe on Windows) file > from scripts written in Python? So as to prevent the end-user from having to > download an interpreter to run the program. Yes. py2exe is a tool which generates s

Directly Executable Files in Python

2011-03-28 Thread Jordan Meyer
Is it possible to make a directly executable (such as .exe on Windows) file from scripts written in Python? So as to prevent the end-user from having to download an interpreter to run the program. -- http://mail.python.org/mailman/listinfo/python-list

Re: Guido rethinking removal of cmp from sort method

2011-03-28 Thread Paul Rubin
Steven D'Aprano writes: > There are lots of problems that Python is not well-suited for. > It is not well-suited for writing the driver to a graphics card. > It is not well-suited to calculating pi to a trillion decimal places. >... But sorting moderate amounts of data on complicated criteria is

PIL in Apache in Fedora 14

2011-03-28 Thread Sandipan
Python 2.7 Fedora 14 import Image fails in CGI script due to https://bugzilla.redhat.com/show_bug.cgi?id=582009 How do I make it work? I have searched the web for days and can't figure out how to apply the many patches discussed. Thanks. Sandipan -- http://mail.python.org/mailman/listinfo/python-

Re: Embedding Python: estimate size of dict/list

2011-03-28 Thread Michael Hunter
On Mon, Mar 28, 2011 at 4:18 PM, Chris Angelico wrote: [...] > Obviously I could use PyObject_Str() and PyString_Size() to get a > decent figure, but that seems like overkill. > > What I'm hoping for is some simple function that zips through a > complex object and sums its approximate memory usage

Re: Embedding Python: estimate size of dict/list

2011-03-28 Thread Chris Angelico
On Tue, Mar 29, 2011 at 12:03 PM, Jerry Hill wrote: > On Mon, Mar 28, 2011 at 8:26 PM, Chris Angelico wrote: >> Based on the docs and http://code.activestate.com/recipes/577504/ I >> understand that to be non-recursive. I'm guessing then that there >> isn't a recursive version, and that it's best

Re: Guido rethinking removal of cmp from sort method

2011-03-28 Thread Raymond Hettinger
On Mar 28, 8:43 am, Steven D'Aprano wrote: > Thank you for spending the time to get some hard data, but I can't > replicate your results since you haven't shown your code. Rather than > attempt to guess what you did and duplicate it, I instead came up with my > own timing measurements. Results are

Re: Embedding Python: estimate size of dict/list

2011-03-28 Thread Jerry Hill
On Mon, Mar 28, 2011 at 8:26 PM, Chris Angelico wrote: > Based on the docs and http://code.activestate.com/recipes/577504/ I > understand that to be non-recursive. I'm guessing then that there > isn't a recursive version, and that it's best to recurse myself? Yes, you're right. I completely miss

Re: Python problem

2011-03-28 Thread John Parker
Dear all, This is the solution that I came up with to deal with handling the file of scores. Thank you all for your feedback! John # define calc average function def calcAve(mylist): total = 0 count = 0 for i in range (0, len(mylist)): # count scores for even number items in in

Re: embedding interactive python interpreter

2011-03-28 Thread Mark Hammond
On 28/03/2011 2:06 PM, Eric Frederich wrote: I'm not sure that I know how to run this function in such a way that it gives me an interactive session. I passed in stdin as the first parameter and NULL as the second and I'd get seg faults when running exit() or even imnport sys. I don't want to pa

[no subject]

2011-03-28 Thread Kylin25mail
-- http://mail.python.org/mailman/listinfo/python-list

Re: Embedding Python: estimate size of dict/list

2011-03-28 Thread Chris Angelico
On Tue, Mar 29, 2011 at 10:56 AM, Jerry Hill wrote: > For python 2.6 and later, sys.getsizeof() will probably do what you > want.  It relies on objects implementing a __sizeof__() method, so > third-party objects may or may not support this, but since you're > looking at dicts and lists, you shoul

Re: Embedding Python: estimate size of dict/list

2011-03-28 Thread Jerry Hill
On Mon, Mar 28, 2011 at 7:18 PM, Chris Angelico wrote: > I have an application that embeds Python to allow third-party > scripting. The Python code returns data to the application in the form > of a list or dictionary, and I'd like to have a quick check on the > size of the outputted object before

Embedding Python: estimate size of dict/list

2011-03-28 Thread Chris Angelico
Hi! New to the list, apologies if I'm in breach of protocol. I have an application that embeds Python to allow third-party scripting. The Python code returns data to the application in the form of a list or dictionary, and I'd like to have a quick check on the size of the outputted object before m

Re: Python problem

2011-03-28 Thread John Parker
Ethan, Thanks for pointing that out. I commented that code out and then ran it. It created the list of names. Now, I just need to figure out how to get the scores into the list called scores. It would appear that this is done with a nested for loop. Thanks, John On 3/28/11 12:02 PM, "Etha

Re: Guido rethinking removal of cmp from sort method

2011-03-28 Thread Fons Adriaensen
On Mon, Mar 28, 2011 at 11:06:20AM +0200, Antoon Pardon wrote: > Asking for *real-world* uses is just how the python community smothers > requests. It's quite a common strategy, I've seen it used in many contexts. Which doesn't make it any more acceptable of course. > Should someone come with

Re: Python problem

2011-03-28 Thread Rhodri James
On Mon, 28 Mar 2011 22:38:29 +0100, John Parker wrote: infile = open("scores.txt", "r") lines = infile.readlines() infile.close() tokens = lines.split(",") names = [] scores = [] [snippety snip] error: Traceback (most recent call last): File "Score_8.py", line 38, in tokens = lines.s

Re: Python problem

2011-03-28 Thread Peter Pearson
On Mon, 28 Mar 2011 11:38:29 -1000, John Parker wrote: [snip] > I have written the following code so far but get an error. > > infile = open("scores.txt", "r") > lines = infile.readlines() > infile.close() > tokens = lines.split(",") [snip] > error: > Traceback (most recent call last): > File

Re: Python problem

2011-03-28 Thread Ethan Furman
John Parker wrote: I have written the following code so far but get an error. infile = open("scores.txt", "r") lines = infile.readlines() infile.close() tokens = lines.split(",") [snip] error: Traceback (most recent call last): File "Score_8.py", line 38, in tokens = lines.split(",")

Re: Python problem

2011-03-28 Thread Ian Kelly
On Mon, Mar 28, 2011 at 3:38 PM, John Parker wrote: > error: > Traceback (most recent call last): >  File "Score_8.py", line 38, in >    tokens = lines.split(",") > AttributeError: 'list' object has no attribute 'split' > > So, what am I doing wrong? 'lines' is a list of strings. 'split' is a st

Python problem

2011-03-28 Thread John Parker
Hi All, I'm trying to figure out a problem in which I have a file named scores.txt that contains the following information. Jane Doe,87,92,97,33 John Doe,78,91,84,25 Bill Gates,91,88,89,56 Bruce Perens,88,92,84,99 I'm wanting to read the file and create two lists: names and scores. I also wa

Re: Why aren't copy and deepcopy in __builtins__?

2011-03-28 Thread Steven D'Aprano
On Mon, 28 Mar 2011 10:30:03 -0700, John Ladasky wrote: > On Mar 28, 2:25 am, Andrea Crotti wrote: >> John Ladasky writes: I almost never use them >> either, maybe also in many cases you could avoid using them... >> When for example you use them? > > To take one example: neural network programm

RE: Writing to a file

2011-03-28 Thread jyoung79
I appreciate you all taking the time to answer my question. These were the types of things I was needing to hear. Sorry for any confusion I may have caused by using a relative file path with the '~'… I was typing from memory and didn't think about it beforehand. Eryksun, thank you for the in

threading.Semaphore (quite long)

2011-03-28 Thread Thomas Rachel
[posted in de.clp in German] Hello, I want to implement an alternative concept to worker threads processing a job queue. The alternative consists of threads being the jobs themselves and thus running only this one job. The job threads are started after a Semaphore's acquire() "giving the OK"

Re: [pyplot] using f1=figure(1)

2011-03-28 Thread Giacomo Boffi
Blockheads Oi Oi writes: > I don't know why but this works fine. > f1=figure(1) > plot(sin(linspace(0,10)),figure=f1) > f2=figure(2) > plot(cos(linspace(0,10)),figure=f2) > show() it works as well (with a proper t...) plot(sin(t);figure(2);plot(cos(t));show() because that's the way it is advis

Re: Why aren't copy and deepcopy in __builtins__?

2011-03-28 Thread Ethan Furman
John Ladasky wrote: On Mar 28, 2:25 am, Andrea Crotti wrote: I noticed some time ago in a program that needed speed that deepcopy in particular is incredibly slow, but I guess is normal since it has to copy every bit of the data structure. That may be, but when it already takes several second

Re: how to create a virtual printer

2011-03-28 Thread Michel Claveau - MVP
Hi! On windows, install a "Generic" printer, on "FILE:" port. @-salutations -- Michel Claveau -- http://mail.python.org/mailman/listinfo/python-list

Re: Why aren't copy and deepcopy in __builtins__?

2011-03-28 Thread Ian Kelly
On Mon, Mar 28, 2011 at 4:55 AM, Dave Angel wrote: > I'd expect it to be very slow.  I presume it not only has to visit and > duplicate every bit of the data structure, but also has to detect loops, and > avoid infinite loops recreating them. > > This loop detection is probably an n-squared algori

Re: Why aren't copy and deepcopy in __builtins__?

2011-03-28 Thread John Ladasky
On Mar 28, 2:25 am, Andrea Crotti wrote: > John Ladasky writes: > I almost never use them either, maybe also in many cases you could avoid > using them... > When for example you use them? To take one example: neural network programming. I construct a network object (which is quite complex), tes

Re: ValueError: insecure pickle string

2011-03-28 Thread pradeepbpin
> For new data: an alternative is to open the file in binary mode for both > reading and writing on all platforms. This will also allow you to switch to > the more efficient binary pickle protocols. Writing and reading the pickled file in binary mode seems to be working. Thank you. -- http://ma

Re: [pyplot] using f1=figure(1)

2011-03-28 Thread Blockheads Oi Oi
On 28/03/2011 17:04, Giacomo Boffi wrote: i executed the following interactions and i remained disappointed $ python Python 2.6.6 (r266:84292, Dec 27 2010, 00:02:40) [GCC 4.4.5] on linux2 Type "help", "copyright", "credits" or "license" for more information. from pylab import * f1=figure(1) f2=

Re: ValueError: insecure pickle string

2011-03-28 Thread Steven D'Aprano
On Mon, 28 Mar 2011 08:53:35 -0700, pradeepbpin wrote: > I am encountering 'Value Error: insecure string pickle' when trying to > execute the script on Ubuntu. The same script and the pickled file works > without any problem in Windows. For working in Ubuntu I just copied both > the script file an

Re: ValueError: insecure pickle string

2011-03-28 Thread Peter Otten
pradeepbpin wrote: > I am encountering 'Value Error: insecure string pickle' when trying to > execute the script on Ubuntu. The same script and the pickled file > works without any problem in Windows. For working in Ubuntu I just > copied both the script file and pickled file from Windows. > > >

[pyplot] using f1=figure(1)

2011-03-28 Thread Giacomo Boffi
i executed the following interactions and i remained disappointed $ python Python 2.6.6 (r266:84292, Dec 27 2010, 00:02:40) [GCC 4.4.5] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from pylab import * >>> f1=figure(1) >>> f2=figure(2) >>> f1 >>> f2 >>> pl

ValueError: insecure pickle string

2011-03-28 Thread pradeepbpin
I am encountering 'Value Error: insecure string pickle' when trying to execute the script on Ubuntu. The same script and the pickled file works without any problem in Windows. For working in Ubuntu I just copied both the script file and pickled file from Windows. How can I get out of this error?

Re: Guido rethinking removal of cmp from sort method

2011-03-28 Thread Steven D'Aprano
On Mon, 28 Mar 2011 14:39:04 +0200, Antoon Pardon wrote: > I tried to sort lists of 1 elemens. Each element a tuple two items > that was to be sorted first according to the first item in ascending > order, then according to the second item in descending order. This was > done on python 2.6 so

Re: Guido rethinking removal of cmp from sort method

2011-03-28 Thread Duncan Booth
Antoon Pardon wrote: > I tried to sort lists of 1 elemens. Each element a tuple two items > that was to be sorted first according to the first item in ascending > order, then according to the second item in descending order. This was > done on python 2.6 so I had to write my own cmp_to_key fu

Re: Free Software University - Python Certificate - In reply to Noah Hall

2011-03-28 Thread Lloyd Hardy
1) Perhaps Noah Hall is not my real name, nor the name I used to sign up. ;) 2) Perhaps I have multiple email addresses. 3) Regardless, it is still offers little, IMO ;) 4) As you have been for quite some time, yet little seems to change. 5) Most interesting. Dear [Python List Member of Unkno

SQLObject 1.0.0

2011-03-28 Thread Oleg Broytman
Hello! I'm really happy to announce SQLObject version 1.0.0! What is SQLObject = SQLObject is an object-relational mapper. Your database tables are described as classes, and rows are instances of those classes. SQLObject is meant to be easy to use and quick to get started with

Re: Guido rethinking removal of cmp from sort method

2011-03-28 Thread Antoon Pardon
On Fri, Mar 25, 2011 at 10:06:59PM +, Steven D'Aprano wrote: > On Fri, 25 Mar 2011 10:21:35 +0100, Antoon Pardon wrote: > > > On Thu, Mar 24, 2011 at 11:49:53PM +, Steven D'Aprano wrote: > >> On Thu, 24 Mar 2011 17:47:05 +0100, Antoon Pardon wrote: > >> > >> > However since that seems to

Re: Non-deterministic output

2011-03-28 Thread Peter Otten
Esben Nielsen wrote: > Hi, > > We are making a prototype program in Python. I discovered the output was > non-deterministic, i.e. I rerun the program on the same input files and > get different output files. We do not use any random calls, nor > threading. > > One of us thought it could be set a

Re: Non-deterministic output

2011-03-28 Thread Tim Wintle
On Mon, 2011-03-28 at 12:42 +0200, Esben Nielsen wrote: > We are making a prototype program in Python. I discovered the output was > non-deterministic, i.e. I rerun the program on the same input files and > get different output files. We do not use any random calls, nor > threading. > > One of us

Re: how to create a virtual printer

2011-03-28 Thread Adam Tauno Williams
On Mon, 2011-03-28 at 04:12 -0700, kalop...@gmail.com wrote: > Hi, > > Does anybody know how to create a virtual > printer with python (on both windows and linux)? I don't. Not on Windows anyway. There is no single mechanism that will work for both. On LINUX this is trivial - define a printer

Re: Non-deterministic output

2011-03-28 Thread Laurent Claessens
One of us thought it could be set and dictionaries not always yielding the same results. I, however, would think that given the exact same operations, a set/dictionary would always yield the same results. Am I correct? Or could different runs of the same program yield different results due to, s

Re: Guido rethinking removal of cmp from sort method

2011-03-28 Thread Steven D'Aprano
On Mon, 28 Mar 2011 11:06:20 +0200, Antoon Pardon wrote: > On Fri, Mar 25, 2011 at 10:40:03PM +, Steven D'Aprano wrote: >> On Fri, 25 Mar 2011 13:56:23 +0100, Antoon Pardon wrote: >> >> > Look we are provided with the cmp_to_key function. If something >> > doesn't work with that function or p

Non-deterministic output

2011-03-28 Thread Esben Nielsen
Hi, We are making a prototype program in Python. I discovered the output was non-deterministic, i.e. I rerun the program on the same input files and get different output files. We do not use any random calls, nor threading. One of us thought it could be set and dictionaries not always yielding th

how to create a virtual printer

2011-03-28 Thread kalop...@gmail.com
Hi, Does anybody know how to create a virtual printer with python (on both windows and linux)? thnx. D. -- http://mail.python.org/mailman/listinfo/python-list

Re: Why aren't copy and deepcopy in __builtins__?

2011-03-28 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Andrea Crotti wrote: John Ladasky writes: Simple question. I use these functions much more frequently than many others which are included in __builtins__. I don't know if my programming needs are atypical, but my experience has led me to wonder why I have to import

Re: Why aren't copy and deepcopy in __builtins__?

2011-03-28 Thread Andrea Crotti
John Ladasky writes: > Simple question. I use these functions much more frequently than many > others which are included in __builtins__. I don't know if my > programming needs are atypical, but my experience has led me to wonder > why I have to import these functions. I almost never use them

Re: Guido rethinking removal of cmp from sort method

2011-03-28 Thread Antoon Pardon
On Fri, Mar 25, 2011 at 10:40:03PM +, Steven D'Aprano wrote: > On Fri, 25 Mar 2011 13:56:23 +0100, Antoon Pardon wrote: > > > Look we are provided with the cmp_to_key function. If something doesn't > > work with that function or performs realy bad with that function, it > > means either the fu

Re: best python games?

2011-03-28 Thread Paul Rudin
alex23 writes: > Paul Rudin wrote: >> Apparently Eve Online is (stackless) python. > > I've dropped a ridiculous number of hours into EVE this year alone but > I'd be very hesitant to ever mention "best" in relation to its > coding :) > > It uses way too much floating point incorrectly, the in-g

Re: best python games?

2011-03-28 Thread Ian Kelly
On Sun, Mar 27, 2011 at 10:17 PM, alex23 wrote: > Civ 4 used it for most of the gameplay and interface, I believe, > wrapping more performant libraries for the graphics & audio. For Civ 5, however, they have switched to Lua -- I think primarily for speed reasons. -- http://mail.python.org/mailma