Re: Problem with keyboard up/down arrows in Python 2.4 interpreter

2011-03-24 Thread Julien
On Mar 22, 5:37 pm, Benjamin Kaplan wrote: > On Tue, Mar 22, 2011 at 2:27 AM, Julien wrote: > > Hi, > > > I'm having problems when typing the up/down arrows in the Python 2.4 > > interpreter (exact version: Python 2.4.6 (#1, Mar  3 2011, 15:45:53) > > [GCC 4.2.1 (Apple Inc. build 5664)] on darwin

Re: functools.partial doesn't work without using named parameter

2011-03-24 Thread Paddy
P.S: Python 3.2! -- http://mail.python.org/mailman/listinfo/python-list

functools.partial doesn't work without using named parameter

2011-03-24 Thread Paddy
Hi, I just found the following oddity where for function fsf1 I am forced to use a named parameter for correct evaluation and was wondering why it doesn't work, yet the example from the docs of wrapping int to create basetwo doesn't need this? The example: >>> from functools import partial >>>

Re: Guido rethinking removal of cmp from sort method

2011-03-24 Thread Stefan Behnel
Steven D'Aprano, 25.03.2011 06:46: On Thu, 24 Mar 2011 18:32:11 -0700, Carl Banks wrote: It's probably the least justified builtin other than pow. I don't know about that. Correctly, efficiently and *quickly* implementing the three-argument version of pow is exactly the sort of thing that sho

Re: Guido rethinking removal of cmp from sort method

2011-03-24 Thread Paul Rubin
Steven D'Aprano writes: > I don't know about that. Correctly, efficiently and *quickly* > implementing the three-argument version of pow is exactly the sort of > thing that should be in the built-ins, or at least the standard library. There is also math.pow which works slightly differently from

ConfigParser.NoSectionError: No section: 'locations'

2011-03-24 Thread Şansal Birbaş
Hi, I created successfully an .exe file for my python code. As a .py file, it works like a charm. But when I try to run it from the exe version, I get error as follows: Traceback (most recent call last): File "CreateAS.pyw", line 14, in File "pulp\__init__.pyc", line 33, in

Re: Guido rethinking removal of cmp from sort method

2011-03-24 Thread Steven D'Aprano
On Thu, 24 Mar 2011 18:32:11 -0700, Carl Banks wrote: > It's probably the least justified builtin other than pow. I don't know about that. Correctly, efficiently and *quickly* implementing the three-argument version of pow is exactly the sort of thing that should be in the built-ins, or at leas

Re: dynamic assigments

2011-03-24 Thread Steven D'Aprano
On Thu, 24 Mar 2011 17:26:34 -0500, Chris Rebert wrote: > On Thu, Mar 24, 2011 at 1:39 PM, Seldon wrote: >> Hi, I have a question about generating variable assignments >> dynamically. > > This can frequently be a code smell. Is there any time when it's not a code smell? A code smell is somethin

Re: dynamic assigments

2011-03-24 Thread Steven D'Aprano
On Thu, 24 Mar 2011 19:51:08 -0700, scattered wrote: > On Mar 24, 7:18 pm, Steven D'Aprano +comp.lang.pyt...@pearwood.info> wrote: >> On Thu, 24 Mar 2011 14:39:34 -0700, scattered wrote: >> > Could try: >> >> my_list = [("x", 7), ("y", 8)] >> for pair in my_list: exec(pair[0] + " = " +

Re: why memoizing is faster

2011-03-24 Thread Terry Reedy
On 3/24/2011 8:26 PM, Fons Adriaensen wrote: On Thu, Mar 24, 2011 at 08:12:22PM -0400, Terry Reedy wrote: The irony of this is that memoizing 'recursive' functions with a decorator depends on the fact the Python does not have truly recursive functions. A function cannot call itself directly.

Understanding the Pystone measurement

2011-03-24 Thread tleeuwenb...@gmail.com
Hi there, Is there a good writeup of what the pystone measurement actually means? I'm working on benchmarking of some Python code at work, and I'm interested in how Pystone might be relevant to me. I've tried googling, but I can't find any introductory / definitional descriptions of what this modu

Re: dynamic assigments

2011-03-24 Thread Tim Leslie
On 25 March 2011 13:51, scattered wrote: > Here is another possibility: you are using Python *interactively* in > solving cryptograms (as a matter of fact - I was doing exactly this > yesterday in trying to solve some Playfair ciphers). You have a > ciphertext that is a stream of letters in the ra

Re: dynamic assigments

2011-03-24 Thread scattered
On Mar 24, 10:51 pm, scattered wrote: [snip] > I can easily imagine other > situations in which a user might want to create a large number of > bindings for interactive use. Maybe as a teacher (I'm a math teacher) > you have written a student-class which contains things like methods to > comput

Re: dynamic assigments

2011-03-24 Thread Jason Swails
On Thu, Mar 24, 2011 at 4:05 PM, Steven D'Aprano < steve+comp.lang.pyt...@pearwood.info> wrote: > On Thu, 24 Mar 2011 19:39:21 +0100, Seldon wrote: > > > Hi, I have a question about generating variable assignments dynamically. > [...] > > Now, I would like to use data contained in this list to dyn

Re: dynamic assigments

2011-03-24 Thread scattered
On Mar 24, 7:18 pm, Steven D'Aprano wrote: > On Thu, 24 Mar 2011 14:39:34 -0700, scattered wrote: > > Could try: > > my_list = [("x", 7), ("y", 8)] > for pair in my_list: exec(pair[0] + " = " + str(pair[1])) > x,y > (7,8) > > Please don't ever do such a thing. The world has eno

Re: Guido rethinking removal of cmp from sort method

2011-03-24 Thread Carl Banks
On Mar 24, 5:37 pm, "Martin v. Loewis" wrote: > > The cmp argument doesn't depend in any way on an object's __cmp__ > > method, so getting rid of __cmp__ wasn't any good readon to also get > > rid of the cmp argument > > So what do you think about the cmp() builtin? Should have stayed, > or was it

Re: Guido rethinking removal of cmp from sort method

2011-03-24 Thread Martin v. Loewis
> The cmp argument doesn't depend in any way on an object's __cmp__ > method, so getting rid of __cmp__ wasn't any good readon to also get > rid of the cmp argument So what do you think about the cmp() builtin? Should have stayed, or was it ok to remove it? If it should have stayed: how should it

Re: Guido rethinking removal of cmp from sort method

2011-03-24 Thread MRAB
On 24/03/2011 23:49, Steven D'Aprano wrote: On Thu, 24 Mar 2011 17:47:05 +0100, Antoon Pardon wrote: However since that seems to be a problem for you I will be more detailed. The original poster didn't ask for cases in which cmp was necessary, he asked for cases in which not using cmp was cumbe

Re: why memoizing is faster

2011-03-24 Thread Fons Adriaensen
On Thu, Mar 24, 2011 at 08:12:22PM -0400, Terry Reedy wrote: > The irony of this is that memoizing 'recursive' functions with a > decorator depends on the fact the Python does not have truly recursive > functions. A function cannot call itself directly. I wonder what exactly is meant by that

Re: why memoizing is faster

2011-03-24 Thread Terry Reedy
On 3/24/2011 9:48 AM, Andrea Crotti wrote: I was showing a nice memoize decorator to a friend using the classic fibonacci problem. --8<---cut here---start->8--- def memoize(f, cache={}): def g(*args, **kwargs): # first must create a key to

Callback mysteries

2011-03-24 Thread Fons Adriaensen
Hello all, I wonder if someone could explain some of the following. (Python 3.2) I have a class which has a method called 'callback()'. An instance of this class calls a C extension which then calls back into Python. In all cases below, two arguments are passed to the C code and end up in PyO

Re: why memoizing is faster

2011-03-24 Thread Terry Reedy
On 3/24/2011 9:48 AM, Andrea Crotti wrote: def fib_iter(n): ls = {0: 1, 1:1} Storing a linear array in a dict is a bit bizarre for i in range(2, n+1): ls[i] = ls[i-1] + ls[i-2] return ls[max(ls)] So is using max(keys) to find the highest index, which you

Re: Guido rethinking removal of cmp from sort method

2011-03-24 Thread Steven D'Aprano
On Thu, 24 Mar 2011 17:47:05 +0100, Antoon Pardon wrote: > However since that seems to be a problem for you I will be more > detailed. The original poster didn't ask for cases in which cmp was > necessary, he asked for cases in which not using cmp was cumbersome. I'm the original poster, and that

Re: dynamic assigments

2011-03-24 Thread Steven D'Aprano
On Thu, 24 Mar 2011 14:39:34 -0700, scattered wrote: > Could try: > my_list = [("x", 7), ("y", 8)] for pair in my_list: exec(pair[0] + " = " + str(pair[1])) x,y (7,8) Please don't ever do such a thing. The world has enough buggy software vulnerable to code injection attacks

Re: dynamic assigments

2011-03-24 Thread Steven D'Aprano
On Thu, 24 Mar 2011 19:39:21 +0100, Seldon wrote: > Hi, I have a question about generating variable assignments dynamically. [...] > Now, I would like to use data contained in this list to dynamically > generate assignments of the form "var1 = value1", ecc where var1 is an > identifier equal (as a

Re: dynamic assigments

2011-03-24 Thread Chris Rebert
On Thu, Mar 24, 2011 at 1:39 PM, Seldon wrote: > Hi, I have a question about generating variable assignments dynamically. This can frequently be a code smell. > I have a list of 2-tuples like this > > ( > (var1, value1), > (var2, value2), > .. , > ) > > where var1, var2, ecc. are strings and val

Re: dynamic assigments

2011-03-24 Thread scattered
On Mar 24, 2:39 pm, Seldon wrote: > Hi, I have a question about generating variable assignments dynamically. > > I have a list of 2-tuples like this > > ( > (var1, value1), > (var2, value2), > .. , > ) > > where var1, var2, ecc. are strings and value1, value2 are generic objects. > > Now, I would

Re: Convert ctypes 16 bit c_short array to a 32 bit numpy array

2011-03-24 Thread Wanderer
On Mar 24, 3:14 pm, Wanderer wrote: > I'm using ctypes to have a dll fill a buffer with 16 bit data. I then > want to convert this data to a numpy array. The code snippet below > converts the data from 16 bit to 32 bit, but two 16 bit numbers are > concatenated to make a 32 bit number and half the

Convert ctypes 16 bit c_short array to a 32 bit numpy array

2011-03-24 Thread Wanderer
I'm using ctypes to have a dll fill a buffer with 16 bit data. I then want to convert this data to a numpy array. The code snippet below converts the data from 16 bit to 32 bit, but two 16 bit numbers are concatenated to make a 32 bit number and half the array is zero. Buffer = (c_short *

Re: dynamic assigments

2011-03-24 Thread Jean-Michel Pichavant
Seldon wrote: Hi, I have a question about generating variable assignments dynamically. I have a list of 2-tuples like this ( (var1, value1), (var2, value2), .. , ) where var1, var2, ecc. are strings and value1, value2 are generic objects. Now, I would like to use data contained in this list

dynamic assigments

2011-03-24 Thread Seldon
Hi, I have a question about generating variable assignments dynamically. I have a list of 2-tuples like this ( (var1, value1), (var2, value2), .. , ) where var1, var2, ecc. are strings and value1, value2 are generic objects. Now, I would like to use data contained in this list to dynamically

About gmon.out for profiling

2011-03-24 Thread Baskaran Sankaran
Hi, I have two questions regarding the profiling. My python version automatically generates gmon.out for every script that I run and so I guess that it must have been compiled with the appropriate option. Firstly, it is not clear to me how I can use this. I've used python with -cprofile switch an

Re: autoscale y to current xrange in view - matplotlib

2011-03-24 Thread Blockheads Oi Oi
On 23/03/2011 18:17, urban_gibbon wrote: [snip] You're likely to get answers on the matplotlib users mailing list https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- http://mail.python.org/mailman/listinfo/python-list

Re: Guido rethinking removal of cmp from sort method

2011-03-24 Thread Ian Kelly
On Thu, Mar 24, 2011 at 10:47 AM, Antoon Pardon wrote: >> That's not what you wrote before.  You wrote "I can't do the sort in >> multiple steps."  I was just responding to what you wrote. > > That is because I tend to assume some intelligence with those I > communicate with, so that I don't need

Re: Guido rethinking removal of cmp from sort method

2011-03-24 Thread Antoon Pardon
On Thu, Mar 24, 2011 at 09:06:44AM -0600, Ian Kelly wrote: > On Thu, Mar 24, 2011 at 3:23 AM, Antoon Pardon > wrote: > > Sure I can do that. I can do lots of things like writing a CMP class > > that I will use as a key and where I can implement the logic for > > comparing the original objects, whi

Re: Instant File I/O

2011-03-24 Thread Jordan Meyer
That did the trick! Thanks! -- http://mail.python.org/mailman/listinfo/python-list

Re: os.stat bug?

2011-03-24 Thread Laszlo Nagy
It's the OS kernel. If it was Python or the C library, sending SIGKILL would result in immediate termination. Is the disk interface operating in PIO mode? A slow disk shouldn't cause 100% CPU consumption; the OS would just get on with something else (or just idle) while waiting for data to beco

Re: Guido rethinking removal of cmp from sort method

2011-03-24 Thread Ian Kelly
On Thu, Mar 24, 2011 at 3:23 AM, Antoon Pardon wrote: > Sure I can do that. I can do lots of things like writing a CMP class > that I will use as a key and where I can implement the logic for > comparing the original objects, which I otherwise would have put in a > cmp function. I thought this was

Re: Guido rethinking removal of cmp from sort method

2011-03-24 Thread Mel
Carl Banks wrote: > On Mar 23, 1:38 pm, Paul Rubin wrote: >> Well, I thought it was also to get rid of 3-way cmp in general, in favor >> of rich comparison. > > Supporting both __cmp__ and rich comparison methods of a class does > add a lot of complexity. The cmp argument of sort doesn't. > > Th

No more Python support in NetBeans 7.0

2011-03-24 Thread Kees Bakker
Hi, Sad news (for me, at least), in the upcoming version 7.0 of NetBeans there will be no Python plugin anymore. I have been using NetBeans for Python development for a while now and I was very happy with it. See this archive for details: http://netbeans.org/projects/www/lists/nbpython-dev/archi

Re: why memoizing is faster

2011-03-24 Thread Stefan Behnel
Andrea Crotti, 24.03.2011 14:48: I was showing a nice memoize decorator to a friend using the classic fibonacci problem. --8<---cut here---start->8--- def memoize(f, cache={}): def g(*args, **kwargs): # first must create a key to store the

why memoizing is faster

2011-03-24 Thread Andrea Crotti
I was showing a nice memoize decorator to a friend using the classic fibonacci problem. --8<---cut here---start->8--- def memoize(f, cache={}): def g(*args, **kwargs): # first must create a key to store the arguments called # it's for

Re: "in house" pypi?

2011-03-24 Thread Miki Tebeka
> The easiest solution is to use a plain file system. Make a directory per > project, and put all distributions of the project into the directory. > Then have Apache serve the parent directory, with DirectoryIndex turned > on. Great, thanks! -- http://mail.python.org/mailman/listinfo/python-list

Re: Threading with Socket Server

2011-03-24 Thread baloan
If you don't mind to use the coroutine library eventlet you can implement a single threaded solution. See example below. For your use case you need to change controller to load the shelve every eventlet.sleep(n) seconds. Regards, Andreas # eventlet single thread demo """ prc_publish.eventlet Pr

Re: "in house" pypi?

2011-03-24 Thread Christian Heimes
Am 24.03.2011 12:49, schrieb Billy Earney: > Another possible solution, would be to use urlimport > http://pypi.python.org/pypi/urlimport/ > if the packages are 100% python (no > c, etc), you could create a single repository, serve that via a web server, > an

Re: "in house" pypi?

2011-03-24 Thread Billy Earney
Another possible solution, would be to use urlimport http://pypi.python.org/pypi/urlimport/ if the packages are 100% python (no c, etc), you could create a single repository, serve that via a web server, and users could easy import modules without even instal

Re: "in house" pypi?

2011-03-24 Thread Christian Heimes
Am 24.03.2011 04:19, schrieb Miki Tebeka: > Greetings, > > My company want to distribute Python packages internally. We would like > something like an internal PyPi where people can upload and easy_install from > packages. > > Is there such a ready made solution? > I'd like something as simple

Re: Guido rethinking removal of cmp from sort method

2011-03-24 Thread Antoon Pardon
On Wed, Mar 23, 2011 at 05:51:07PM +0100, Stefan Behnel wrote: > >> > >>You can use a stable sort in two steps for that. > > > >Which isn't helpfull if where you decide how they have to be sorted is > >not the place where they are actually sorted. > > > >I have a class that is a priority queue. Ele

Re: Guido rethinking removal of cmp from sort method

2011-03-24 Thread Antoon Pardon
On Wed, Mar 23, 2011 at 10:40:11AM -0600, Ian Kelly wrote: > On Wed, Mar 23, 2011 at 9:14 AM, Antoon Pardon > wrote: > > Which isn't helpfull if where you decide how they have to be sorted is > > not the place where they are actually sorted. > > > > I have a class that is a priority queue. Element

Re: Special logging module needed

2011-03-24 Thread Laszlo Nagy
2011.03.23. 19:33 keltezéssel, Dan Stromberg írta: On Wed, Mar 23, 2011 at 7:37 AM, Laszlo Nagy > wrote: I was also thinking about storing data in a gdbm database. One file for each month storing at most 100 log messages for every key value. Then one fi

Re: Guido rethinking removal of cmp from sort method

2011-03-24 Thread Paul Rubin
Dennis Lee Bieber writes: > The first half of the problem description -- "Elements are added at > random" seems more suited to an in-place insertion sort method. This is precisely what a priority queue is for. Insertions take O(log n) time and there's very little space overhead in heapq'

Re: Instant File I/O

2011-03-24 Thread Charles
"jam1991" wrote in message news:c0c76bc4-8923-4a46-9c36-6e1a0375f...@l11g2000yqb.googlegroups.com... [snip] > they sign into the program with; however, this information doesn't > appear in the file until after the program has closed. This poses a > problem for retrieving the up-to-date statistic

Re: "in house" pypi?

2011-03-24 Thread John Nagle
On 3/23/2011 8:19 PM, Miki Tebeka wrote: Greetings, My company want to distribute Python packages internally. We would like something like an internal PyPi where people can upload and easy_install from packages. Is there such a ready made solution? I'd like something as simple as possible, with