Re: float("nan") in set or as key

2011-06-03 Thread Ethan Furman
Steven D'Aprano wrote: NANs are not necessarily errors, they're hardly silent, and if you don't want NANs, the standard mandates that there be a way to turn them off. So how does one turn them off in standard Python? ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: how to avoid leading white spaces

2011-06-03 Thread Chris Angelico
On Sat, Jun 4, 2011 at 12:30 PM, Roy Smith wrote: > Another nice thing about regexes (as compared to string methods) is that > they're both portable and serializable.  You can use the same regex in > Perl, Python, Ruby, PHP, etc.  You can transmit them over a network > connection to a cooperating

Re: how to avoid leading white spaces

2011-06-03 Thread Steven D'Aprano
On Fri, 03 Jun 2011 22:30:59 -0400, Roy Smith wrote: > In article <4de992d7$0$29996$c3e8da3$54964...@news.astraweb.com>, > Steven D'Aprano wrote: > >> Of course, if you include both case-sensitive and insensitive tests in >> the same calculation, that's a good candidate for a regex... or at >>

Re: how to avoid leading white spaces

2011-06-03 Thread Steven D'Aprano
On Sat, 04 Jun 2011 03:24:50 +0100, MRAB wrote: > [snip] > Some regex implementations support scoped case sensitivity. :-) Yes, you should link to your regex library :) Have you considered the suggested Perl 6 syntax? Much of it looks good to me. > I have at times thought that it would be use

Re: float("nan") in set or as key

2011-06-03 Thread Steven D'Aprano
On Fri, 03 Jun 2011 13:27:00 -0700, Carl Banks wrote: > On Wednesday, June 1, 2011 5:53:26 PM UTC-7, Steven D'Aprano wrote: [...] >> On the contrary, it blows it out of the water and stomps its corpse >> into a stain on the ground. > > Really? I am claiming that, even if everyone and their mothe

Re: how to avoid leading white spaces

2011-06-03 Thread Roy Smith
In article <4de992d7$0$29996$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > Of course, if you include both case-sensitive and insensitive tests in > the same calculation, that's a good candidate for a regex... or at least > it would be if regexes supported that :) Of course the

Re: how to avoid leading white spaces

2011-06-03 Thread MRAB
On 04/06/2011 03:05, Steven D'Aprano wrote: On Fri, 03 Jun 2011 12:29:52 -0700, ru...@yahoo.com wrote: I often find myself changing, for example, a startwith() to a RE when I realize that the input can contain mixed case Why wouldn't you just normalise the case? Because some of the text may

Re: float("nan") in set or as key

2011-06-03 Thread Steven D'Aprano
On Sat, 04 Jun 2011 12:14:03 +1200, Gregory Ewing wrote: > Steven D'Aprano wrote: >> Fair point. Call it an extension of the Kronecker Delta to the reals >> then. > > That's called the Dirac delta function, and it's a bit different Yes, I'm familiar with the Dirac delta. As you say, it's not re

Re: how to avoid leading white spaces

2011-06-03 Thread Steven D'Aprano
On Fri, 03 Jun 2011 12:29:52 -0700, ru...@yahoo.com wrote: >>> I often find myself changing, for example, a startwith() to a RE when >>> I realize that the input can contain mixed case >> >> Why wouldn't you just normalise the case? > > Because some of the text may be case-sensitive. Perhaps you

Re: how to avoid leading white spaces

2011-06-03 Thread Gregory Ewing
Chris Torek wrote: Python might be penalized by its use of Unicode here, since a Boyer-Moore table for a full 16-bit Unicode string would need 65536 entries But is there any need for the Boyer-Moore algorithm to operate on characters? Seems to me you could just as well chop the UTF-16 up into

Re: Something is rotten in Denmark...

2011-06-03 Thread Gregory Ewing
Alain Ketterlin wrote: You must be kidding. Like many others, you seem to think that Scheme is a typical functional language, which it is not. I never said that Scheme is a functional language -- I'd be the first to acknowledge that it's not. I do know what real functional languages are like.

Re: except KeyError, everywhere

2011-06-03 Thread Ben Finney
Ben Finney writes: > It's best to implement Memoize as a Python decorator in one place > http://wiki.python.org/moin/PythonDecoratorLibrary#Memoize>. Michele Simionato discusses a better implementation of a Memoize decorator in the documentation for his useful ‘decorator’ library http://micheles

ANN: python-ldap 2.4.0

2011-06-03 Thread Michael Ströder
Find a new release of python-ldap: http://pypi.python.org/pypi/python-ldap/2.4.0 python-ldap provides an object-oriented API to access LDAP directory servers from Python programs. It mainly wraps the OpenLDAP 2.x libs for that purpose. Additionally it contains modules for other LDAP-related st

Released: Python 2.6.7

2011-06-03 Thread Barry Warsaw
Hello Pythoneers and Pythonistas, I'm happy to announce the final release of Python 2.6.7. Python 2.6 is in security-fix only mode. This means that general bug maintenance has ended, and only critical security issues are being fixed. We will support Python 2.6 in security-fix only mode until Oct

Re: float("nan") in set or as key

2011-06-03 Thread Gregory Ewing
Steven D'Aprano wrote: Fair point. Call it an extension of the Kronecker Delta to the reals then. That's called the Dirac delta function, and it's a bit different -- instead of a value of 1, it has an infinitely high spike of zero width at the origin, whose integral is 1. (Which means it's not

Re: except KeyError, everywhere

2011-06-03 Thread Ben Finney
Wilbert Berendsen writes: > I find myself all over the place associating objects with each other using > dicts as caches: > > something like this: > > _cache = {} > > def get_something(obj): > """Returns the frobnicate-plugin for the specified object.""" > try: > return _cache[ob

Re: except KeyError, everywhere

2011-06-03 Thread Nobody
On Fri, 03 Jun 2011 22:08:16 +0200, Wilbert Berendsen wrote: > I find myself all over the place associating objects with each other using > dicts as caches: > Are there other peoply using things like this? Is there a solution like > this in the standard lib that I'm overlooking? The general con

Re: float("nan") in set or as key

2011-06-03 Thread Chris Angelico
On Sat, Jun 4, 2011 at 9:29 AM, Nobody wrote: > Floats are supposed to approximate reals. They're also a Python > data type, and should make some effort to fit in with the rest of > the language. > That's what I thought a week ago. But that's not really true. Floats are supposed to hold non-integ

Re: float("nan") in set or as key

2011-06-03 Thread Nobody
On Fri, 03 Jun 2011 14:52:39 +, Grant Edwards wrote: >> It's arguable that NaN itself simply shouldn't exist in Python; if >> the FPU ever generates a NaN, Python should raise an exception at >> that point. > > Sorry, I just don't "get" that argument. I depend on compliance with > IEEE-754,

Re: Best way to compute length of arbitrary dimension vector?

2011-06-03 Thread Robert Kern
On 6/3/11 4:53 PM, Gabriel wrote: The dimension is arbitrary, though, so: length = reduce(math.hypot, self._coords, 0) Thanks, I was going to ask Algis that same question. But still, is this solution really faster or better than the one using list comprehension and the expression 'x*x'? I

Re: how to avoid leading white spaces

2011-06-03 Thread MRAB
On 03/06/2011 23:11, Ethan Furman wrote: Chris Torek wrote: On 2011-06-03, ru...@yahoo.com wrote: [prefers] re.split ('[ ,]', source) This is probably not what you want in dealing with human-created text: >>> re.split('[ ,]', 'foo bar, spam,maps') ['foo', '', 'bar', '', 'spam', 'maps'] I

Re: Unescaping formatted Terminal text

2011-06-03 Thread Gnarlodious
Thanks, it looks like the appropriate incantation is: import pydoc pydoc.html.docmodule(sys.modules[__name__]) -- Gnarlie -- http://mail.python.org/mailman/listinfo/python-list

Re: Best way to compute length of arbitrary dimension vector?

2011-06-03 Thread Ian Kelly
On Fri, Jun 3, 2011 at 3:53 PM, Gabriel wrote: > But still, is this solution really faster or better than the one using > list comprehension and the expression 'x*x'? No, not really. >c:\python32\python -m timeit -s "coords = list(range(100))" -s "from math >import hypot" -s "from functools imp

Re: how to avoid leading white spaces

2011-06-03 Thread Ethan Furman
Chris Torek wrote: On 2011-06-03, ru...@yahoo.com wrote: [prefers] re.split ('[ ,]', source) This is probably not what you want in dealing with human-created text: >>> re.split('[ ,]', 'foo bar, spam,maps') ['foo', '', 'bar', '', 'spam', 'maps'] I think you've got a typo in th

Re: Best way to compute length of arbitrary dimension vector?

2011-06-03 Thread Gabriel
> The dimension is arbitrary, though, so: > > length = reduce(math.hypot, self._coords, 0) > Thanks, I was going to ask Algis that same question. But still, is this solution really faster or better than the one using list comprehension and the expression 'x*x'? It seems to me that the above sol

Re: how to avoid leading white spaces

2011-06-03 Thread Chris Torek
>On 2011-06-03, ru...@yahoo.com wrote: [prefers] >> re.split ('[ ,]', source) This is probably not what you want in dealing with human-created text: >>> re.split('[ ,]', 'foo bar, spam,maps') ['foo', '', 'bar', '', 'spam', 'maps'] Instead, you probably want "a comma followed by zero

Re: A simple way to print few line stuck to the same position

2011-06-03 Thread Hans Mulder
On 3/06/11 13:00:22, TheSaint wrote: I'd like to show 4~6 line of report and refreshing periodically all of them, avoiding to scroll down. example: this count 50 Second time 90 following line 110 another line xxx The lines should remain on their position and update their data. The quick and

Re: how to avoid leading white spaces

2011-06-03 Thread Neil Cerutti
On 2011-06-03, ru...@yahoo.com wrote: >>> or that I have to treat commas as well as spaces as >>> delimiters. >> >> source.replace(",", " ").split(" ") > > Uhgg. create a whole new string just so you can split it on one > rather than two characters? Sorry, but I find > > re.split ('[ ,]', sou

Re: Something is rotten in Denmark...

2011-06-03 Thread harrismh777
Alain Ketterlin wrote: The reason why we have the kind of lambdas we have in python (and scheme, and javascript, etc.) is just that it is way easier to implement. That's all I've said. And people have gotten used to it, without ever realizing they are using something completely different from wha

Determine attributes of calling method

2011-06-03 Thread Joe
Hello, I'm trying to implement a way to restrict method usage based on the caller's attributes. In the following example I'd like to execute the server method "bar" only if the caller's method has a "blue" value for it's color attribute. The current output is: blue red bar bar I'd like it to b

Re: Bloom Filter in 22 lines of Python (updated)

2011-06-03 Thread Dan Stromberg
FWIW, I took what I believe to have been the 2nd generation of this code, and put some of my own spin on it - mostly making it pass pylint, changing the __init__ arguments to be a little more intuitive (to me), and expanding the tests a bit. It's at http://stromberg.dnsalias.org/svn/bloom-filter/t

Re: float("nan") in set or as key

2011-06-03 Thread Chris Angelico
On Sat, Jun 4, 2011 at 6:27 AM, Carl Banks wrote: > Really?  I am claiming that, even if everyone and their mother thought > exceptions were the best thing ever, NaN would have been added to IEEE anyway > because most hardware didn't support exceptions.  Therefore the fact that NaN > is in IEEE

Re: float("nan") in set or as key

2011-06-03 Thread Carl Banks
On Wednesday, June 1, 2011 5:53:26 PM UTC-7, Steven D'Aprano wrote: > On Tue, 31 May 2011 19:45:01 -0700, Carl Banks wrote: > > > On Sunday, May 29, 2011 8:59:49 PM UTC-7, Steven D'Aprano wrote: > >> On Sun, 29 May 2011 17:55:22 -0700, Carl Banks wrote: > >> > >> > Floating point arithmetic evolv

Bloom Filter in 22 lines of Python (updated)

2011-06-03 Thread Raymond Hettinger
Thanks for all the feedback on the earlier post. I've updated the recipe to use a cleaner API, simpler code, more easily subclassable, and with optional optimizations for better cache utilization and speed: http://code.activestate.com/recipes/577684-bloom-filter/ Raymond -

except KeyError, everywhere

2011-06-03 Thread Wilbert Berendsen
Hi, I find myself all over the place associating objects with each other using dicts as caches: something like this: _cache = {} def get_something(obj): """Returns the frobnicate-plugin for the specified object.""" try: return _cache[obj] except KeyError: res = _cac

Re: Standard Deviation One-liner

2011-06-03 Thread Raymond Hettinger
On Jun 3, 10:55 am, Billy Mays wrote: > I'm trying to shorten a one-liner I have for calculating the standard > deviation of a list of numbers.  I have something so far, but I was > wondering if it could be made any shorter (without imports). > > Here's my function: > > a=lambda d:(sum((x-1.*sum(d

Re: how to avoid leading white spaces

2011-06-03 Thread ru...@yahoo.com
On 06/03/2011 08:25 AM, Steven D'Aprano wrote: > On Fri, 03 Jun 2011 05:51:18 -0700, ru...@yahoo.com wrote: > >> On 06/02/2011 07:21 AM, Neil Cerutti wrote: > >>> > Python's str methods, when they're sufficent, are usually more >>> > efficient. >> >> Unfortunately, except for the very simplest case

Re: Standard Deviation One-liner

2011-06-03 Thread Alain Ketterlin
Alain Ketterlin writes: > aux = lambda s1,s2,n: (s2 - s1*s1/n)/(n-1) > sv = lambda d: aux(sum(d),sum(x*x for x in d),len(d)) Err, sorry, the final square root is missing. -- Alain. -- http://mail.python.org/mailman/listinfo/python-list

Re: Passing array from java to python

2011-06-03 Thread Marco Nawijn
On Jun 2, 11:54 am, loial wrote: > I need to pass some sort of array or hashmap from Java and read the > data in a python script (which will be called by the java class). Is > there any neater way  to do this other than just passing strings? I recently had to deal with the same problem, some bi-d

Re: Standard Deviation One-liner

2011-06-03 Thread Alain Ketterlin
Billy Mays writes: > I'm trying to shorten a one-liner I have for calculating the standard > deviation of a list of numbers. I have something so far, but I was > wondering if it could be made any shorter (without imports). > a=lambda d:(sum((x-1.*sum(d)/len(d))**2 for x in d)/(1.*(len(d)-1)))**

Standard Deviation One-liner

2011-06-03 Thread Billy Mays
I'm trying to shorten a one-liner I have for calculating the standard deviation of a list of numbers. I have something so far, but I was wondering if it could be made any shorter (without imports). Here's my function: a=lambda d:(sum((x-1.*sum(d)/len(d))**2 for x in d)/(1.*(len(d)-1)))**.5

Re: float("nan") in set or as key

2011-06-03 Thread Chris Torek
>On 2011-06-02, Nobody wrote: >> (I note that Python actually raises an exception for "0.0/0.0"). In article Grant Edwards wrote: >IMHO, that's a bug. IEEE-754 states explicit that 0.0/0.0 is NaN. >Pythons claims it implements IEEE-754. Python got it wrong. Indeed -- or at least, inconsiste

Re: Something is rotten in Denmark...

2011-06-03 Thread Ian Kelly
On Fri, Jun 3, 2011 at 2:30 AM, Thomas Rachel wrote: > So there should be a way to replace the closure of a function with a > snapshot of it at a certain time. If there was an internal function with > access to the readonly attribute func_closure and with the capability of > changing or creating a

Re: feedparser hanging after I/O error

2011-06-03 Thread John Nagle
On 6/2/2011 4:40 AM, xDog Walker wrote: On Wednesday 2011 June 01 10:34, John Nagle wrote: I have a program which uses "feedparser". It occasionally hangs when the network connection has been lost, and remains hung after the network connection is restored. My solution is to download the feed

Re: BadValueError: Property title is required

2011-06-03 Thread Casey Dwyer
On May 31, 1:21 am, "michal.bulla" wrote: > Hello, > > I'm trying to create simple method to create category. I set the model > category: > > class Category(db.Model): >   title = db.StringProperty(required=True) >   clashes_count = db.IntegerProperty(default=0) > > And the class New Category as w

Re: Newby Python help needed with functions

2011-06-03 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Cathy James wrote: I need a jolt here with my python excercise, please somebody!! How can I make my functions work correctly? I tried below but I get the following error: if f_dict[capitalize]: KeyError: Code below: def capitalize (s): """capitalize accepts a

Re: Newby Python help needed with functions

2011-06-03 Thread Jonathan Gardner
On Fri, Jun 3, 2011 at 7:42 AM, Cathy James wrote: > I need a jolt here with my python excercise, please somebody!! How can I > make my functions work correctly? I tried below but I get the following > error: > > if f_dict[capitalize]: > > KeyError: > This error is because the function capitaliz

Re: Newby Python help needed with functions

2011-06-03 Thread Tim Chase
On 06/03/2011 09:42 AM, Cathy James wrote: I need a jolt here with my python excercise, please somebody!! How can I make my functions work correctly? I tried below but I get the following error: if f_dict[capitalize]: KeyError: def capitalize (s): Here you define the variable "capitalize" as

Re: Unescaping formatted Terminal text

2011-06-03 Thread Peter Otten
Gnarlodious wrote: > This may be happening because I am using Python 3.2 which includes > "curses" to format output. When running: > > pydoc.render_doc(sys.modules[__name__]) > > in Terminal I see FUNCTIONS > > when the same output goes to HTTP I see FFUUNNCCTTIIOONNSS What you are se

Re: how to avoid leading white spaces

2011-06-03 Thread ru...@yahoo.com
On 06/03/2011 07:17 AM, Neil Cerutti wrote: > On 2011-06-03, ru...@yahoo.com wrote: >> The other tradeoff, applying both to Perl and Python is with >> maintenance. As mentioned above, even when today's >> requirements can be solved with some code involving several >> string functions, indexes, an

Re: Newby Python help needed with functions

2011-06-03 Thread Andrew Berg
On 2011.06.03 09:42 AM, Cathy James wrote: > I need a jolt here with my python excercise, please somebody!! How can > I make my functions work correctly? I tried below but I get the > following error: > > if f_dict[capitalize]: > > KeyError: > ... > > def capitalize (s): > """capitalize accep

Re: how to avoid leading white spaces

2011-06-03 Thread D'Arcy J.M. Cain
On 03 Jun 2011 14:25:53 GMT Steven D'Aprano wrote: > source.replace(",", " ").split(" ") I would do; source.replace(",", " ").split() > [steve@sylar ~]$ python -m timeit -s "source = 'a b c,d,e,f,g h i j k'" What if the string is 'a b c, d, e,f,g h i j k'? >>> source.replace(",", " ").spli

Re: float("nan") in set or as key

2011-06-03 Thread Grant Edwards
On 2011-06-02, Nobody wrote: > On Thu, 02 Jun 2011 09:54:30 +, Steven D'Aprano wrote: > >>> Exceptions allow you to write more natural code by ignoring the >>> awkward cases. E.g. writing "x * y + z" rather than first determining >>> whether "x * y" is even defined then using a conditional. >>

Newby Python help needed with functions

2011-06-03 Thread Cathy James
I need a jolt here with my python excercise, please somebody!! How can I make my functions work correctly? I tried below but I get the following error: if f_dict[capitalize]: KeyError: Code below: def capitalize (s): """capitalize accepts a string parameter and applies the capitalize() m

Re: how to avoid leading white spaces

2011-06-03 Thread Steven D'Aprano
On Fri, 03 Jun 2011 05:51:18 -0700, ru...@yahoo.com wrote: > On 06/02/2011 07:21 AM, Neil Cerutti wrote: >> > Python's str methods, when they're sufficent, are usually more >> > efficient. > > Unfortunately, except for the very simplest cases, they are often not > sufficient. Maybe so, but the

Unescaping formatted Terminal text

2011-06-03 Thread Gnarlodious
This may be happening because I am using Python 3.2 which includes "curses" to format output. When running: pydoc.render_doc(sys.modules[__name__]) in Terminal I see FUNCTIONS when the same output goes to HTTP I see FFUUNNCCTTIIOONNSS Is there an easy way to strip ANSI escaped characte

Re: how to avoid leading white spaces

2011-06-03 Thread Nobody
On Fri, 03 Jun 2011 02:58:24 +, Chris Torek wrote: > Python might be penalized by its use of Unicode here, since a > Boyer-Moore table for a full 16-bit Unicode string would need > 65536 entries (one per possible ord() value). However, if the > string being sought is all single-byte values, a

Re: how to avoid leading white spaces

2011-06-03 Thread Neil Cerutti
On 2011-06-03, ru...@yahoo.com wrote: > The other tradeoff, applying both to Perl and Python is with > maintenance. As mentioned above, even when today's > requirements can be solved with some code involving several > string functions, indexes, and conditionals, when those > requirements change,

Re: how to avoid leading white spaces

2011-06-03 Thread Nobody
On Fri, 03 Jun 2011 04:30:46 +, Chris Torek wrote: >>I'm not sure what you mean by "full 16-bit Unicode string"? Isn't >>unicode inherently 32 bit? > > Well, not exactly. As I understand it, Python is normally built > with a 16-bit "unicode character" type though It's normally 32-bit on p

Re: Something is rotten in Denmark...

2011-06-03 Thread Nobody
On Fri, 03 Jun 2011 11:43:54 +1200, Gregory Ewing wrote: >> But going against generally accepted semantics should at least >> be clearly indicated. Lambda is one of the oldest computing abstraction, >> and they are at the core of any functional programming language. > > Yes, and Python's lambdas

Re: how to avoid leading white spaces

2011-06-03 Thread ru...@yahoo.com
On 06/02/2011 07:21 AM, Neil Cerutti wrote: > > On 2011-06-01, ru...@yahoo.com wrote: >> >> For some odd reason (perhaps because they are used a lot in >> >> Perl), this groups seems to have a great aversion to regular >> >> expressions. Too bad because this is a typical problem where >> >> their

Re: A simple way to print few line stuck to the same position

2011-06-03 Thread Steven D'Aprano
On Fri, 03 Jun 2011 19:00:22 +0800, TheSaint wrote: > Steven D'Aprano wrote: > >> def spinner(): >> chars = '|/-\\' > > Not exactly. > I'd like to show 4~6 line of report and refreshing periodically all of > them, avoiding to scroll down. You have to use the curses module for that. -- Steve

Re: How to import data from MySQL db into excel sheet -- Very Urgent

2011-06-03 Thread Kushal Kumaran
On Fri, Jun 3, 2011 at 5:52 PM, hisan wrote: > Task i need to achieve here is: > I need to write a python script which fetches all the data from the > MySQL database and dumps into an excel sheet. since i was not able to > dump the data into excel sheet i used CSV file which looks similar to > exc

Re: How to import data from MySQL db into excel sheet -- Very Urgent

2011-06-03 Thread hisan
Task i need to achieve here is: I need to write a python script which fetches all the data from the MySQL database and dumps into an excel sheet. since i was not able to dump the data into excel sheet i used CSV file which looks similar to excel sheet. on dumping the data into CSV file i came know

Re: Why is this so much faster?

2011-06-03 Thread Tim Delaney
On 3 June 2011 19:05, Thomas Jollans wrote: > On Friday 03 June 2011, it occurred to Tim Delaney to exclaim: > > > Probably the biggest savings are list creating and jumping between C- and > > > Python-functions during the map call. The lambda is a Python function, > > > which are notoriously sl

Re: Something is rotten in Denmark...

2011-06-03 Thread Jussi Piitulainen
Alain Ketterlin writes: > Gregory Ewing writes: > > > Alain Ketterlin wrote: > >> But going against generally accepted semantics should at least be > >> clearly indicated. Lambda is one of the oldest computing > >> abstraction, and they are at the core of any functional > >> programming language.

Re: A simple way to print few line stuck to the same position

2011-06-03 Thread TheSaint
Steven D'Aprano wrote: > def spinner(): > chars = '|/-\\' Not exactly. I'd like to show 4~6 line of report and refreshing periodically all of them, avoiding to scroll down. example: this count 50 Second time 90 following line 110 another line xxx The lines should remain on their position and u

Re: Something is rotten in Denmark...

2011-06-03 Thread Alain Ketterlin
Gregory Ewing writes: > Alain Ketterlin wrote: >> But going against generally accepted semantics should at least >> be clearly indicated. Lambda is one of the oldest computing abstraction, >> and they are at the core of any functional programming language. > > Yes, and Python's lambdas behave exa

Re: Multiprocessing.connection magic

2011-06-03 Thread Chris Angelico
On Fri, Jun 3, 2011 at 6:50 PM, Steven D'Aprano wrote: > On Fri, 03 Jun 2011 18:26:47 +1000, Chris Angelico wrote: > >> Just how many Chrises are there on this list? I have a pet theory that >> there's a greater-than-usual correlation between geeks and the name >> "Chris", and the Python list has

Re: datetime.datetime and mysql different after python2.3

2011-06-03 Thread Thomas Rachel
Am 01.06.2011 20:42 schrieb Tobiah: I'm grabbing two fields from a MySQLdb connection. One is a date type, and one is a time type. So I put the values in two variables and print them: import datetime date, time = get_fields() # for example print str(type(date)), str((type(time))) print str(date

Re: Why is this so much faster?

2011-06-03 Thread Thomas Jollans
On Friday 03 June 2011, it occurred to Tim Delaney to exclaim: > Probably the biggest savings are list creating and jumping between C- and > Python-functions during the map call. The lambda is a Python function, > which are notoriously slow to use from within map() in comparison to > keeping it all

Distutils beginner question - windows

2011-06-03 Thread Seb S
Hi all, Just a quick question , I have a simple script I want to convert into a windows installer and give to some friends. I had a look at http://docs.python.org/distutils/introduction.html and wrote this setup script: #!/usr/bin/env python from distutils.core import setup setup(name="C:

Re: Multiprocessing.connection magic

2011-06-03 Thread Steven D'Aprano
On Fri, 03 Jun 2011 18:26:47 +1000, Chris Angelico wrote: > Just how many Chrises are there on this list? I have a pet theory that > there's a greater-than-usual correlation between geeks and the name > "Chris", and the Python list has provided a number of supporting > instances. My theory is tha

Re: Multiprocessing.connection magic

2011-06-03 Thread Chris Angelico
On Fri, Jun 3, 2011 at 6:10 PM, Thomas Rachel wrote: > Kids, don't try this at home nor on your external server. > Aye... you would be in a pickle. (Yes, he really did make a pun that bad. Feel free to throw rotten tomatoes.) Chris Angelico -- http://mail.python.org/mailman/listinfo/python-lis

Re: how to avoid leading white spaces

2011-06-03 Thread Thorsten Kampe
* Roy Smith (Thu, 02 Jun 2011 21:57:16 -0400) > In article <94ph22frh...@mid.individual.net>, > Neil Cerutti wrote: > > On 2011-06-01, ru...@yahoo.com wrote: > > > For some odd reason (perhaps because they are used a lot in > > > Perl), this groups seems to have a great aversion to regular > > >

Re: Something is rotten in Denmark...

2011-06-03 Thread Thomas Rachel
Am 03.06.2011 01:43 schrieb Gregory Ewing: It's not the lambda that's different from other languages, it's the for-loop. In languages that encourage a functional style of programming, the moral equivalent of a for-loop is usually some construct that results in a new binding of the control variab

Re: Multiprocessing.connection magic

2011-06-03 Thread Chris Angelico
On Fri, Jun 3, 2011 at 6:03 PM, Thomas Rachel wrote: > Am 03.06.2011 08:28 schrieb Claudiu Popa: >> >> Hello guys, >>       While  working  at a dispatcher using >>   multiprocessing.connection.Listener  module  I've stumbled upon some >>   sort    of  magic  trick  that  amazed  me. How is this p

Re: Multiprocessing.connection magic

2011-06-03 Thread Thomas Rachel
Am 03.06.2011 08:59 schrieb Chris Angelico: I don't know how effective the pickling of functions actually is. Someone else will doubtless be able to fill that in. Trying to do so, I get (with several protocol versions): >>> import pickle >>> pickle.dumps(pickle.dumps) 'cpickle\ndumps\np0\n.'

Re: Multiprocessing.connection magic

2011-06-03 Thread Thomas Rachel
Am 03.06.2011 08:28 schrieb Claudiu Popa: Hello guys, While working at a dispatcher using multiprocessing.connection.Listener module I've stumbled upon some sortof magic trick that amazed me. How is this possible and what does multiprocessing library doing in backg

Re: Why is this so much faster?

2011-06-03 Thread Ian Kelly
On Thu, Jun 2, 2011 at 7:28 PM, Keir Rice wrote: > Ian, I was basing my code off Fredrik Lundh post on comparing images. > http://effbot.org/zone/pil-comparing-images.htm Ah, now I get what it's doing. Thanks! -- http://mail.python.org/mailman/listinfo/python-list

Re: Updated now can't scroll uparrow

2011-06-03 Thread Ned Deily
In article <730fedb4-a3ad-46df-ad66-2376d0af4...@p13g2000yqh.googlegroups.com>, Gnarlodious wrote: > After copious headscratching I took Ned's advice and went for 3.2 > which includes built-in interactive arrow key support. To any Mac OSX > readers, save yourself the trouble and don't even try P

Re: Why is this so much faster?

2011-06-03 Thread Peter Otten
Keir Rice wrote: > Ian, I was basing my code off Fredrik Lundh post on comparing images. > http://effbot.org/zone/pil-comparing-images.htm > return math.sqrt(sum([h*i*i for i,h in enumerate(histogram)]) / > self.Area()) > > Ran at the same speed as my 'fast' version and without the square bracke

Re: Multiprocessing.connection magic

2011-06-03 Thread Chris Angelico
On Fri, Jun 3, 2011 at 5:03 PM, Chris Torek wrote: > The real magic is in the unpickler, which has figured out how to > access shutil.copy without importing shutil into the global namespace: So from this I gather that it doesn't actually pickle the code, just the name. Seems a little odd, but tha

Re: Multiprocessing.connection magic

2011-06-03 Thread Chris Torek
In article Claudiu Popa wrote: >Hello guys, > While working at a dispatcher using > multiprocessing.connection.Listener module I've stumbled upon some > sortof magic trick that amazed me. How is this possible and > what does multiprocessing library doing in background for

Re: Multiprocessing.connection magic

2011-06-03 Thread Chris Angelico
On Fri, Jun 3, 2011 at 4:28 PM, Claudiu Popa wrote: > Hello guys, >      While  working  at a dispatcher using >  multiprocessing.connection.Listener  module  I've stumbled upon some >  sort    of  magic  trick  that  amazed  me. How is this possible and >  what  does  multiprocessing  library doi