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

2011-05-29 Thread Steven D'Aprano
On Mon, 30 May 2011 04:15:11 +, Steven D'Aprano wrote: > On Mon, 30 May 2011 11:14:58 +1000, Chris Angelico wrote: > >> So, apart from float("nan"), are there actually any places where real >> production code has to handle NaN? I was unable to get a nan by any of >> the above methods, except

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

2011-05-29 Thread Steven D'Aprano
On Mon, 30 May 2011 04:29:19 +, Chris Torek wrote: > In article <4de31635$0$29990$c3e8da3$54964...@news.astraweb.com>, Steven > D'Aprano wrote: >>That's also completely wrong. The correct way to test for a NAN is with >>the IEEE-mandated function isnan(). The NAN != NAN trick is exactly >>th

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

2011-05-29 Thread Chris Torek
In article I wrote, in part: >_inf = float("inf") >def isinf(x): >return x == _inf >del _inf Oops, take out the del, or otherwise fix the obvious problem, e.g., perhaps: def isinf(x): return x == isinf._inf isinf._inf = float("inf") (Of course, if something l

[ANN] PyYAML-3.10: YAML parser and emitter for Python

2011-05-29 Thread Kirill Simonov
Announcing PyYAML-3.10 A new bug fix release of PyYAML is now available: http://pyyaml.org/wiki/PyYAML Changes === * Do not try to build LibYAML bindings on platforms other than CPython (Thank to olt(at)bogosoft(dot)com). * Clear cy

Re: 3.1.4 release candidate 1

2011-05-29 Thread Raymond Hettinger
On May 29, 3:44 pm, Benjamin Peterson wrote: > On behalf of the Python development team, I'm happy as a swallow to announce a > release candidate for the fourth bugfix release for the Python 3.1 > series, Python > 3.1.4. The Pi release of Python :-) Raymond P.S. For the most part, if you have

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

2011-05-29 Thread Raymond Hettinger
On May 28, 4:41 pm, MRAB wrote: > Here's a curiosity. float("nan") can occur multiple times in a set or as > a key in a dict: Which is by design. NaNs intentionally have multiple possible instances (some implementations even include distinct payload values). Sets and dicts intentionally recogni

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

2011-05-29 Thread Chris Torek
In article <4de31635$0$29990$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: >That's also completely wrong. The correct way to test for a NAN is with >the IEEE-mandated function isnan(). The NAN != NAN trick is exactly that, >a trick, used by programmers when their language or compi

Re: Class decorators might also be super too

2011-05-29 Thread Raymond Hettinger
On May 28, 11:33 pm, Michele Simionato wrote: > He is basically showing that using mixins for implementing logging is not > such a good idea, i.e. you can get the same effect in a better way by making > use of other Python features. I argued the same thing many times in the past. > I even wrote

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

2011-05-29 Thread John Nagle
On 5/29/2011 9:15 PM, Steven D'Aprano wrote: On Mon, 30 May 2011 11:14:58 +1000, Chris Angelico wrote: So, apart from float("nan"), are there actually any places where real production code has to handle NaN? Yes. I used to write dynamic simulation engines. There were situations that prod

Re: scope of function parameters

2011-05-29 Thread Steven D'Aprano
On Mon, 30 May 2011 11:31:33 +1000, Ben Finney wrote: > Steven D'Aprano writes: > >> http://mail.python.org/pipermail/tutor/2010-December/080505.html >> >> >> Constructive criticism welcome. > > Informative, but it “buries the lead” as our friends in the press corps > would say. Thank you, tha

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

2011-05-29 Thread Steven D'Aprano
On Mon, 30 May 2011 12:53:59 +1000, Chris Angelico wrote: > Okay, here's a question. The Python 'float' value - is it meant to be "a > Python representation of an IEEE double-precision floating point value", Yes. > or "a Python representation of a real number"? No. Floats are not real numbers

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

2011-05-29 Thread Steven D'Aprano
On Mon, 30 May 2011 11:14:58 +1000, Chris Angelico wrote: > So, apart from float("nan"), are there actually any places where real > production code has to handle NaN? I was unable to get a nan by any of > the above methods, except for operations involving inf; for instance, > float("inf")-float("i

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

2011-05-29 Thread Steven D'Aprano
On Sun, 29 May 2011 17:55:22 -0700, Carl Banks wrote: > Floating point arithmetic evolved more or less on languages like Fortran > where things like exceptions were unheard of, I'm afraid that you are completely mistaken. Fortran IV had support for floating point traps, which are "things like

Re: Error: child process close a socket inherited from parent

2011-05-29 Thread narke
On 2011-05-29, Chris Torek wrote: > In article > narke wrote: >>As illustrated in the following simple sample: >> >>import sys >>import os >>import socket >> >>class Server: >>def __init__(self): >>self._listen_sock = None >> >>def _talk_to_client(self, conn, addr): >>te

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

2011-05-29 Thread rusi
On May 30, 7:53 am, Chris Angelico wrote: > On Mon, May 30, 2011 at 12:17 PM, Carl Banks wrote: > > If I were designing a new floating-point standard for hardware, I would > > consider getting rid of NaN.  However, with the floating point standard > > that exists, that almost all floating point

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

2011-05-29 Thread Chris Angelico
On Mon, May 30, 2011 at 12:17 PM, Carl Banks wrote: > If I were designing a new floating-point standard for hardware, I would > consider getting rid of NaN.  However, with the floating point standard that > exists, that almost all floating point hardware mostly conforms to, there are > certain

Re: scope of function parameters

2011-05-29 Thread Chris Angelico
On Mon, May 30, 2011 at 12:08 PM, Ben Finney wrote: > Chris Angelico writes: > >> Of course, there's a significant difference between a mailing list >> post and a detailed and well copyedited article. Quite frequently I'll >> ramble on list, in a way quite inappropriate to a publication that >> w

Re: Alternatives to PythonPath

2011-05-29 Thread rusi
On May 30, 2:49 am, ray wrote: > I am using Win7 on a tightly locked down desktop. > > Is there an alternative to using PythonPath? > > What are the trade-offs? > > Thanks, > ray Externally: 1. PYTHONPATH 2. .pth files http://bob.pythonmac.org/archives/2005/02/06/using-pth-files-for-python-devel

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

2011-05-29 Thread Carl Banks
On Sunday, May 29, 2011 6:14:58 PM UTC-7, Chris Angelico wrote: > On Mon, May 30, 2011 at 10:55 AM, Carl Banks > wrote: > > If exceptions had commonly existed in that environment there's no chance > > they would have chosen that behavior; comparison against NaN (or any > > operation with NaN) w

Re: scope of function parameters

2011-05-29 Thread Ben Finney
Chris Angelico writes: > Of course, there's a significant difference between a mailing list > post and a detailed and well copyedited article. Quite frequently I'll > ramble on list, in a way quite inappropriate to a publication that > would be linked to as a "hey guys, here's how it is" page. Di

Re: portable way of sending notifying a process

2011-05-29 Thread Chris Angelico
On Mon, May 30, 2011 at 11:44 AM, Chris Torek wrote: >>What would be a light weight portable way, that one process can tell >>another to do something? >> >>The main requirement would be to have no CPU impact while waiting (thus >>no polling) > > Your best bet here is probably to use sockets.  Both

Re: scope of function parameters

2011-05-29 Thread Chris Angelico
On Mon, May 30, 2011 at 11:31 AM, Ben Finney wrote: >  http://www.computerworld.com/s/article/print/93903/I_m_OK_The_Bull_Is_Dead> I agree with the gist of that. My take on this is: When I'm talking to my boss, I always assume that the phone will ring ten seconds into my explanation. Ten seconds

Re: portable way of sending notifying a process

2011-05-29 Thread Chris Torek
In article <4de183e7$0$26108$426a7...@news.free.fr> News123 wrote: >I'm looking for a portable way (windows XP / Windows Vista and Linux ) >to send a signal from any python script to another one >(one signa would be enough) This turns out to be pretty hard to do reliably-and-securely even *witho

Re: scope of function parameters

2011-05-29 Thread Ben Finney
Steven D'Aprano writes: > http://mail.python.org/pipermail/tutor/2010-December/080505.html > > > Constructive criticism welcome. Informative, but it “buries the lead” as our friends in the press corps would say. Instead you should write as though you have no idea where the reader will stop rea

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

2011-05-29 Thread Chris Angelico
On Mon, May 30, 2011 at 10:55 AM, Carl Banks wrote: > If exceptions had commonly existed in that environment there's no chance they > would have chosen that behavior; comparison against NaN (or any operation > with NaN) would have signaled a floating point exception.  That is the > correct way

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

2011-05-29 Thread Carl Banks
On Sunday, May 29, 2011 7:41:13 AM UTC-7, Grant Edwards wrote: > It treats them as identical (not sure if that's the right word). The > implementation is checking for ( A is B or A == B ). Presumably, the > assumpting being that all objects are equal to themselves. That > assumption is not true

Re: How to catch a line with Popen

2011-05-29 Thread Chris Torek
In article TheSaint wrote: >Chris Rebert wrote: >I just suppose to elaborate the latest line, as soon it's written on the >pipe, and print some result on the screen. >Imaging something like > > p= Popen(['ping','-c40','www.google.com'], stdout=PIPE) > for line in p.stdout: > print(str(line)

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

2011-05-29 Thread Carl Banks
On Sunday, May 29, 2011 4:31:19 PM UTC-7, Steven D'Aprano wrote: > On Sun, 29 May 2011 22:19:49 +0100, Nobody wrote: > > > On Sun, 29 May 2011 10:29:28 +, Steven D'Aprano wrote: > > > >>> The correct answer to "nan == nan" is to raise an exception, > >>> because > >>> you have asked a

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

2011-05-29 Thread Chris Torek
Incidentally, note: $ python ... >>> nan = float("nan") >>> nan nan >>> nan is nan True >>> nan == nan False In article <4de1e3e7$0$2195$742ec...@news.sonic.net> John Nagle wrote: >The correct answer to "nan == nan" is to raise an exception, because >you

Re: scope of function parameters

2011-05-29 Thread Steven D'Aprano
On Sun, 29 May 2011 04:30:52 -0400, Henry Olders wrote: > I just spent a considerable amount of time and effort debugging a > program. The made-up code snippet below illustrates the problem I > encountered: [...] > Are there others who feel as I do that a function parameter should > always be loca

Re: Error: child process close a socket inherited from parent

2011-05-29 Thread Chris Torek
In article narke wrote: >As illustrated in the following simple sample: > >import sys >import os >import socket > >class Server: >def __init__(self): >self._listen_sock = None > >def _talk_to_client(self, conn, addr): >text = 'The brown fox jumps over the lazy dog.\n' >

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

2011-05-29 Thread Steven D'Aprano
On Sun, 29 May 2011 22:19:49 +0100, Nobody wrote: > On Sun, 29 May 2011 10:29:28 +, Steven D'Aprano wrote: > >>> The correct answer to "nan == nan" is to raise an exception, >>> because >>> you have asked a question for which the answer is nether True nor >>> False. >> >> Wrong. > >

Re: Beginner needs advice

2011-05-29 Thread Chris Angelico
On Mon, May 30, 2011 at 9:00 AM, rantingrick wrote: > Python 2.x and Pythin 3.x are two different dialects just like Humans > (Python 3.x) and Chimpanzees (Python 2.x) are similar (compatible) but > very different versions of talking apes (languages). Sure humans > (Python 3.x) and chimps (Python

Re: Beginner needs advice

2011-05-29 Thread rantingrick
On May 29, 2:28 pm, Jason Tackaberry wrote: > On 11-05-29 04:06 AM, Ian Kelly wrote: > > > I realize you are now asserting that compatibility is a boolean > > condition, and that "totally incompatible" is a redundant phrase that > > you tossed out as a joke. > > As a casual lurker reading this thr

Re: English Idiom in Unix: Directory Recursively

2011-05-29 Thread rantingrick
On May 29, 4:46 pm, Chris Angelico wrote: > On Mon, May 30, 2011 at 7:38 AM, rantingrick wrote: > > Yes but understanding of this sort is very general ESPECIALLY in the > > case of destroying data! > > > What are the limits of the recursion? What forces can act on the > > recursion to stop it? If

[RELEASE] Python 2.7.2 release candidate 1

2011-05-29 Thread Benjamin Peterson
On behalf of the Python development team, I'm happy to announce the immediate availability of Python 2.7.2 release candidate 1. 2.7.2 is the second in bugfix release for the Python 2.7 series. 2.7 is the last major verison of the 2.x line and will be receiving bug fixes while new feature developme

[RELEASE] 3.1.4 release candidate 1

2011-05-29 Thread Benjamin Peterson
On behalf of the Python development team, I'm happy as a swallow to announce a release candidate for the fourth bugfix release for the Python 3.1 series, Python 3.1.4. 3.1.4 will the last bug fix release in the 3.1 series before 3.1. After 3.1.4, 3.1 will be in security-only fix mode. The Python

Re: Alternatives to PythonPath

2011-05-29 Thread Irmen de Jong
On 29-5-2011 23:49, ray wrote: > I am using Win7 on a tightly locked down desktop. > > Is there an alternative to using PythonPath? > What do you mean by "using PythonPath"? What doesn't work that you want to have an alternative for? Irmen -- http://mail.python.org/mailman/listinfo/python-list

Re: How to Use Setuptools, Alternatives?

2011-05-29 Thread Irmen de Jong
On 29-5-2011 23:41, ray wrote: > I have Python 2.7 on Win7 Pro on a tightly locked down desktop. I > would like to install Networkx from an egg. From what I have read, > Setuptools can be used for this. What does 'tightly locked down' mean? > I don't know how to install Setuptools. The exe wi

Re: scope of function parameters

2011-05-29 Thread Terry Reedy
On 5/29/2011 4:19 PM, Henry Olders wrote: From my perspective, a function parameter should be considered as having been assigned (although the exact assignment will not be known until runtime), and as an assigned variable, it should be considered local. That is exactly the case for Python func

Re: Beginner needs advice

2011-05-29 Thread rantingrick
On May 28, 9:33 pm, harrismh777 wrote: > Steven D'Aprano wrote: > > A straw man is not when somebody points out holes in your argument, or > > unwanted implications that you didn't realise were there. It is when > > somebody makes claims on your behalf that you did not make to discredit > > you, n

Alternatives to PythonPath

2011-05-29 Thread ray
I am using Win7 on a tightly locked down desktop. Is there an alternative to using PythonPath? What are the trade-offs? Thanks, ray -- http://mail.python.org/mailman/listinfo/python-list

Re: scope of function parameters

2011-05-29 Thread Christopher Head
On Sun, 29 May 2011 16:19:11 -0400 Henry Olders wrote: > > def fnc2(c): > > c = c[:] > >c[1] = 'having' > >return c > > Thank you, Wolfgang. That certainly works, but to me it is still a > workaround to deal with the consequence of a particular decision. > From my per

Re: English Idiom in Unix: Directory Recursively

2011-05-29 Thread Chris Angelico
On Mon, May 30, 2011 at 7:38 AM, rantingrick wrote: > Yes but understanding of this sort is very general ESPECIALLY in the > case of destroying data! > > What are the limits of the recursion? What forces can act on the > recursion to stop it? If (for example) I know that a "while loop" will > cont

Re: scope of function parameters

2011-05-29 Thread Ben Finney
Peter Pearson writes: > Python works in terms of objects having names, and one > object can have many names. Or no names. So it's less accurate (though better than talking of “variables”) to speak of Python objects “having names”. > The names b and c aren't boxes that hold things, they are -- i

How to Use Setuptools, Alternatives?

2011-05-29 Thread ray
I have Python 2.7 on Win7 Pro on a tightly locked down desktop. I would like to install Networkx from an egg. From what I have read, Setuptools can be used for this. I don't know how to install Setuptools. The exe will not work. On execution, it reports that the Python version is not included

Re: English Idiom in Unix: Directory Recursively

2011-05-29 Thread rantingrick
On May 26, 6:12 am, Chris Angelico wrote: > I just conducted a rapid poll of a non-technical userbase. > > (Okay, I just asked my sister who happens to be sitting here. But > she's nontechnical.) > > She explained "recursive" as "it repeats until it can't go any > further". I think that's a fair,

Re: English Idiom in Unix: Directory Recursively

2011-05-29 Thread rantingrick
On May 26, 6:12 am, Chris Angelico wrote: > I just conducted a rapid poll of a non-technical userbase. > > (Okay, I just asked my sister who happens to be sitting here. But > she's nontechnical.) > > She explained "recursive" as "it repeats until it can't go any > further". I think that's a fair,

Re: English Idiom in Unix: Directory Recursively

2011-05-29 Thread Chris Angelico
On Mon, May 30, 2011 at 6:58 AM, rantingrick wrote: > Yes "Gas Pedal"... that clears up all the confusion . > However i would have thought if the vehicle had a "decelerator petal" > it would at least sport a complimentary "accelerator petal". You know > the whole "equal and opposite thing"? Call

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

2011-05-29 Thread Nobody
On Sun, 29 May 2011 10:29:28 +, Steven D'Aprano wrote: >> The correct answer to "nan == nan" is to raise an exception, because >> you have asked a question for which the answer is nether True nor False. > > Wrong. That's overstating it. There's a good argument to be made for raising an e

Re: English Idiom in Unix: Directory Recursively

2011-05-29 Thread rantingrick
On May 24, 7:40 pm, Chris Angelico wrote: > On Wed, May 25, 2011 at 8:06 AM, Rikishi42 wrote: > > On 2011-05-24, Steven D'Aprano wrote: > >> I wonder whether physicists insist that cars should have a "go faster > >> pedal" because ordinary people don't need to understand Newton's Laws of > >> M

Re: English Idiom in Unix: Directory Recursively

2011-05-29 Thread rantingrick
On May 24, 7:40 pm, Chris Angelico wrote: > On Wed, May 25, 2011 at 8:06 AM, Rikishi42 wrote: > > On 2011-05-24, Steven D'Aprano wrote: > >> I wonder whether physicists insist that cars should have a "go faster > >> pedal" because ordinary people don't need to understand Newton's Laws of > >> M

Re: English Idiom in Unix: Directory Recursively

2011-05-29 Thread rantingrick
On May 24, 5:06 pm, Rikishi42 wrote: > On 2011-05-24, Steven D'Aprano wrote: > > I wonder whether physicists insist that cars should have a "go faster > > pedal" because ordinary people don't need to understand Newton's Laws of > > Motion in order to drive cars? > > Gas pedal. Pedal was allraedy

Re: English Idiom in Unix: Directory Recursively

2011-05-29 Thread rantingrick
On May 20, 1:55 am, Steven D'Aprano wrote: > Trust me on this, if the audience of Carry On films could understand > recursion, anyone can! Well we could also say that this pathetic display of metal masturbation is recursive also. -- http://mail.python.org/mailman/listinfo/python-list

Re: English Idiom in Unix: Directory Recursively

2011-05-29 Thread rantingrick
On May 18, 3:00 pm, Xah Lee wrote: > In the emacs case: “Recursive delete of xx? (y or n) ”, what could it > possibly mean by the word “recursive” there? Like, it might delete the > directory but not delete all files in it? Actually i think this case is more for "scare factor" than anything. As

Re: English Idiom in Unix: Directory Recursively

2011-05-29 Thread rantingrick
On May 18, 12:59 pm, s...@sig.for.address (Victor Eijkhout) wrote: > Harrison Hill wrote: > > No need - I have the Dictionary definition of recursion here: > > > Recursion: (N). See recursion. > > If you tell a joke, you have to tell it right. Jeez, speaking of bad colloquialisms... """if you'

Re: English Idiom in Unix: Directory Recursively

2011-05-29 Thread rantingrick
On May 18, 12:59 pm, s...@sig.for.address (Victor Eijkhout) wrote: > Harrison Hill wrote: > > No need - I have the Dictionary definition of recursion here: > > > Recursion: (N). See recursion. > > If you tell a joke, you have to tell it right. Jeez, speaking of bad colloquialisms... """if you'

Re: scope of function parameters

2011-05-29 Thread Terry Reedy
On 5/29/2011 7:59 AM, Mel wrote: Henry Olders wrote: I just spent a considerable amount of time and effort debugging a program. The made-up code snippet below illustrates the problem I encountered: def main(): a = ['a list','with','three elements'] print a print fnc1(a) print a def fnc1(b): r

Re: English Idiom in Unix: Directory Recursively

2011-05-29 Thread rantingrick
On May 18, 7:19 am, Peter Moylan wrote: > It's interesting to note that the definitions of 'recursive' to be found > in Wikipedia and Wiktionary have very little in common with the > definitions to be found in the dictionaries covered by Onelook.  No > wonder experts in different areas have troub

Re: scope of function parameters

2011-05-29 Thread Henry Olders
Henry On 2011-05-29, at 5:47 , Wolfgang Rohdewald wrote: > On Sonntag 29 Mai 2011, Henry Olders wrote: >> It seems that in Python, a variable inside a function is >> global unless it's assigned. > > no, they are local > >> I would have thought that a function parameter would >> automaticall

Re: Beginner needs advice

2011-05-29 Thread Jason Tackaberry
On 11-05-29 04:06 AM, Ian Kelly wrote: > I realize you are now asserting that compatibility is a boolean > condition, and that "totally incompatible" is a redundant phrase that > you tossed out as a joke. As a casual lurker reading this thread, I believe he is equating "completely incompatible" wi

Re: scope of function parameters

2011-05-29 Thread Chris Angelico
On Mon, May 30, 2011 at 4:53 AM, Steven D'Aprano wrote: > UnboundLocalError is a subclass of NameError, so it will still be caught > by try...except NameError. > > If you're crazy enough to be catching NameError :) Ah okay. So it is still NameError, it just doesn't look like one. > While Unbound

Re: scope of function parameters

2011-05-29 Thread Ian Kelly
On Sun, May 29, 2011 at 12:38 PM, Chris Angelico wrote: > I thought it basically functioned top-down. You get a different error > on the print line if there's a "bar = 42" *after* it. This could make > debugging quite confusing. > > Guess it's just one of the consequences of eschewing variable > d

Re: Weird problem matching with REs

2011-05-29 Thread Thomas 'PointedEars' Lahn
Andrew Berg wrote: > On 2011.05.29 10:19 AM, Roy Smith wrote: >> Named after the governor of Tarsus IV? > Judging by the graphic at http://kodos.sourceforge.net/help/kodos.html , > it's named after the Simpsons character. I don't think that's a coincidence; both are from other planets and both

Re: scope of function parameters

2011-05-29 Thread Steven D'Aprano
On Mon, 30 May 2011 04:38:26 +1000, Chris Angelico wrote: > On Mon, May 30, 2011 at 4:01 AM, Chris Rebert wrote: >> def foo(): >>    print bar >>    bar = 42 >> >> foo() >> >> ===> >> Traceback (most recent call last): >>  File "", line 1, in >>  File "", line 2, in foo >> UnboundLocalError: loc

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

2011-05-29 Thread Steven D'Aprano
On Sun, 29 May 2011 20:05:07 +0200, Christian Heimes wrote: > Am 29.05.2011 19:44, schrieb MRAB: >> Would there be any advantage to making NaN a singleton? I'm thinking >> that it could make checking for it cheaper in the implementation of >> sets and dicts. Or making NaN unhashable? > > It can't

Re: scope of function parameters

2011-05-29 Thread Chris Angelico
On Mon, May 30, 2011 at 4:01 AM, Chris Rebert wrote: > def foo(): >    print bar >    bar = 42 > > foo() > > ===> > Traceback (most recent call last): >  File "", line 1, in >  File "", line 2, in foo > UnboundLocalError: local variable 'bar' referenced before assignment Wow I thought it basica

Re: scope of function parameters

2011-05-29 Thread Steven D'Aprano
On Mon, 30 May 2011 03:53:24 +1000, Chris Angelico wrote: > On Sun, May 29, 2011 at 10:47 PM, Steven D'Aprano > wrote: >> If a name is assigned to anywhere in the function, treat it as a local, >> and look it up in the local namespace. If not found, raise >> UnboundLocalError. >> >> > Wait wha? I

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

2011-05-29 Thread Steven D'Aprano
On Sun, 29 May 2011 18:44:08 +0100, MRAB wrote: > Would there be any advantage to making NaN a singleton? Absolutely not. That would be a step backwards. NANs can carry payload (a code indicating what sort of NAN it represents -- log(-1) and 1/INF are not the same). So although Python currently

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

2011-05-29 Thread Christian Heimes
Am 29.05.2011 19:44, schrieb MRAB: > Would there be any advantage to making NaN a singleton? I'm thinking > that it could make checking for it cheaper in the implementation of > sets and dicts. Or making NaN unhashable? It can't be a singleton, because IEEE 754 specifies millions of millions of di

Re: scope of function parameters

2011-05-29 Thread Chris Rebert
On Sun, May 29, 2011 at 10:53 AM, Chris Angelico wrote: > On Sun, May 29, 2011 at 10:47 PM, Steven D'Aprano > wrote: >> If a name is assigned to anywhere in the function, treat it as a local, >> and look it up in the local namespace. If not found, raise >> UnboundLocalError. >> > > Wait wha? I've

Re: Weird problem matching with REs

2011-05-29 Thread Chris Angelico
On Mon, May 30, 2011 at 2:16 AM, Andrew Berg wrote: >> Also, be sure to >> use a raw string when composing REs, so you don't run into backslash >> issues. > How would I do that when grabbing strings from a config file (via the > configparser module)? Or rather, if I have a predefined variable > co

Re: scope of function parameters

2011-05-29 Thread Chris Angelico
On Sun, May 29, 2011 at 10:47 PM, Steven D'Aprano wrote: > If a name is assigned to anywhere in the function, treat it as a local, > and look it up in the local namespace. If not found, raise > UnboundLocalError. > Wait wha? I've never seen this... wouldn't it just create it in the local namespac

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

2011-05-29 Thread Chris Angelico
On Mon, May 30, 2011 at 3:44 AM, MRAB wrote: > Would there be any advantage to making NaN a singleton? I'm thinking > that it could make checking for it cheaper in the implementation of > sets and dicts. Or making NaN unhashable? Doesn't matter. It still wouldn't be equal to itself, even though i

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

2011-05-29 Thread MRAB
On 29/05/2011 15:41, Grant Edwards wrote: On 2011-05-29, Wolfgang Rohdewald wrote: On Sonntag 29 Mai 2011, Tim Delaney wrote: There's a second part the mystery - sets and dictionaries (and I think lists) assume that identify implies equality (hence the second result). This was recently discuss

Re: The worth of comments

2011-05-29 Thread Alister Ware
On Sun, 29 May 2011 12:47:52 +1200, Gregory Ewing wrote: > Irmen de Jong wrote: > >> I don't see how that is opposed to what Grant was saying. It's that >> these 'contracts' tend to change and that people forget or are too lazy >> to update the comments to reflect those changes. > > However, I c

Re: scope of function parameters

2011-05-29 Thread Peter Pearson
On Sun, 29 May 2011 04:30:52 -0400, Henry Olders wrote: [snip] > def main(): > a = ['a list','with','three elements'] > print a > print fnc1(a) > print a > > def fnc1(b): > return fnc2(b) > > def fnc2(c): > c[1] = 'having' > return c > > This is the

Re: Weird problem matching with REs

2011-05-29 Thread John S
On May 29, 12:16 pm, Andrew Berg wrote: > > I've been meaning to learn how to use parenthesis groups. > > Also, be sure to > > use a raw string when composing REs, so you don't run into backslash > > issues. > > How would I do that when grabbing strings from a config file (via the > configparser m

Re: Weird problem matching with REs

2011-05-29 Thread Andrew Berg
On 2011.05.29 10:48 AM, John S wrote: > Dots don't match end-of-line-for-your-current-OS is how I think of > it. IMO, the docs should say the dot matches any character except a line feed ('\n'), since that is more accurate. > True, malformed > HTML can throw you off, but they can also throw a parse

Re: Weird problem matching with REs

2011-05-29 Thread John S
On May 29, 10:35 am, Andrew Berg wrote: > On 2011.05.29 09:18 AM, Steven D'Aprano wrote:> >> What makes you think it > shouldn't match? > > > > AFAIK, dots aren't supposed to match carriage returns or any other > > > whitespace characters. > > I got things mixed up there (was thinking whitespace

Re: The worth of comments

2011-05-29 Thread Roy Smith
In article , Grant Edwards wrote: > On 2011-05-29, Gregory Ewing wrote: > > Ben Finney wrote: > > > >> You omit the common third possibility: *both* the comment and the code > >> are wrong. > > > > In that case, the correct response is to fix both of them. :-) > > Only as a last resort. IMO, t

Re: Weird problem matching with REs

2011-05-29 Thread Andrew Berg
On 2011.05.29 10:19 AM, Roy Smith wrote: > Named after the governor of Tarsus IV? Judging by the graphic at http://kodos.sourceforge.net/help/kodos.html , it's named after the Simpsons character. -- http://mail.python.org/mailman/listinfo/python-list

Re: Weird problem matching with REs

2011-05-29 Thread Roy Smith
In article , Andrew Berg wrote: > Kodos is written in Python and uses Python's regex engine. In fact, it > is specifically intended to debug Python regexes. Named after the governor of Tarsus IV? -- http://mail.python.org/mailman/listinfo/python-list

Re: The worth of comments

2011-05-29 Thread Grant Edwards
On 2011-05-29, Gregory Ewing wrote: > Ben Finney wrote: > >> You omit the common third possibility: *both* the comment and the code >> are wrong. > > In that case, the correct response is to fix both of them. :-) Only as a last resort. IMO, the best option is to fix the code so it's purpose and o

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

2011-05-29 Thread Grant Edwards
On 2011-05-29, Wolfgang Rohdewald wrote: > On Sonntag 29 Mai 2011, Tim Delaney wrote: >> There's a second part the mystery - sets and dictionaries (and >> I think lists) assume that identify implies equality (hence >> the second result). This was recently discussed on >> python-dev, and the decisi

Re: Weird problem matching with REs

2011-05-29 Thread Andrew Berg
On 2011.05.29 09:18 AM, Steven D'Aprano wrote: > >> What makes you think it shouldn't match? > > > > AFAIK, dots aren't supposed to match carriage returns or any other > > whitespace characters. > > They won't match *newlines* \n unless you pass the DOTALL flag, but they > do match whitespace: >

Re: Weird problem matching with REs

2011-05-29 Thread Steven D'Aprano
On Sun, 29 May 2011 08:41:16 -0500, Andrew Berg wrote: > On 2011.05.29 08:09 AM, Steven D'Aprano wrote: [...] > Kodos is written in Python and uses Python's regex engine. In fact, it > is specifically intended to debug Python regexes. Fair enough. >> Secondly, you probably should use a proper HT

Re: How to catch a line with Popen

2011-05-29 Thread TheSaint
TheSaint wrote: > I just suppose to elaborate the latest line, as soon it's written on the > pipe, and print some result on the screen. I think some info is also here: http://alexandredeverteuil.blogspot.com/ -- goto /dev/null -- http://mail.python.org/mailman/listinfo/python-list

Re: Beginner needs advice

2011-05-29 Thread Steven D'Aprano
On Sat, 28 May 2011 21:02:47 -0500, harrismh777 wrote: > Minor, yes, until you need to make something work--- only to be > frustrated to find that a detail that was not expected has risen to bite > a sensitive place... :) Just like when migrating from Python 2.3 to 2.6. And 1.5 and 2.0

Re: Error: child process close a socket inherited from parent

2011-05-29 Thread narke
On 2011-05-29, narke wrote: > Hi, > > As illustrated in the following simple sample: > > import sys > import os > import socket > > class Server: > def __init__(self): > self._listen_sock = None > > def _talk_to_client(self, conn, addr): > text = 'The brown fox jumps over t

Re: How to catch a line with Popen

2011-05-29 Thread TheSaint
Chris Rebert wrote: > What do you mean by "on-the-fly" in this context I just suppose to elaborate the latest line, as soon it's written on the pipe, and print some result on the screen. Imaging something like p= Popen(['ping','-c40','www.google.com'], stdout=PIPE) for line in p.stdout:

Re: Weird problem matching with REs

2011-05-29 Thread Andrew Berg
On 2011.05.29 08:09 AM, Steven D'Aprano wrote: > On Sun, 29 May 2011 06:45:30 -0500, Andrew Berg wrote: > > > I have an RE that should work (it even works in Kodos [1], but not in my > > code), but it keeps failing to match characters after a newline. > > Not all regexes are the same. Different reg

Re: Weird problem matching with REs

2011-05-29 Thread Andrew Berg
On 2011.05.29 08:00 AM, Ben Finney wrote: > You are aware that most text-emitting processes on Windows, and Internet > text protocols like the HTTP standard, use the two-character “CR LF” > sequence (U+000C U+000A) for terminating lines? Yes, but I was not having trouble with just '\n' before, and

Re: Weird problem matching with REs

2011-05-29 Thread Steven D'Aprano
On Sun, 29 May 2011 06:45:30 -0500, Andrew Berg wrote: > I have an RE that should work (it even works in Kodos [1], but not in my > code), but it keeps failing to match characters after a newline. Not all regexes are the same. Different regex engines accept different symbols, and sometimes behav

Re: Weird problem matching with REs

2011-05-29 Thread Ben Finney
Ben Finney writes: > the two-character “CR LF” sequence (U+000C U+000A) > http://en.wikipedia.org/wiki/Newline> As detailed in that Wikipedia article, the characters are of course U+000D U+000A. -- \ “You say “Carmina”, and I say “Burana”, You say “Fortuna”, and | `\I say “cant

Re: Weird problem matching with REs

2011-05-29 Thread Ben Finney
Andrew Berg writes: > I was able to make a regex that matches in my code, but it shouldn't: > http://x264.nl/x264/64bit/8bit_depth/revision.\n{1,3}[0-9]{4}.\n{1,3}/x264.\n{1,3}.\n{1,3}.exe > I have to add a dot before each "\n". There is no character not > accounted for before those newlines, but

Re: scope of function parameters

2011-05-29 Thread Steven D'Aprano
On Sun, 29 May 2011 11:47:26 +0200, Wolfgang Rohdewald wrote: > On Sonntag 29 Mai 2011, Henry Olders wrote: >> It seems that in Python, a variable inside a function is global unless >> it's assigned. > > no, they are local I'm afraid you are incorrect. Names inside a function are global unless

Re: scope of function parameters

2011-05-29 Thread Mel
Henry Olders wrote: > I just spent a considerable amount of time and effort debugging a program. > The made-up code snippet below illustrates the problem I encountered: > > def main(): > a = ['a list','with','three elements'] > print a > print fnc1(a) > print a > > def fnc1(b): > return fnc2(b)

Weird problem matching with REs

2011-05-29 Thread Andrew Berg
I have an RE that should work (it even works in Kodos [1], but not in my code), but it keeps failing to match characters after a newline. I'm writing a little program that scans the webpage of an arbitrary application and gets the newest version advertised on the page. test3.py: > # -*- coding:

Re: Class decorators might also be super too

2011-05-29 Thread Vinay Sajip
On May 29, 7:33 am, Michele Simionato wrote: > He is basically showing that using mixins for implementingloggingis not such > a good idea, I don't think he was particularly advocating implementing logging this way, but rather just using logging for illustrative purposes. Regards, Vinay Sajip -

  1   2   >