Re: The RAISE_VARARGS opcode in Python 3

2011-08-27 Thread Peter Otten
Arnaud Delobelle wrote: Here is an extract from the dis module doc [1] RAISE_VARARGS(argc) Raises an exception. argc indicates the number of parameters to the raise statement, ranging from 0 to 3. The handler will find the traceback as TOS2, the parameter as TOS1, and the exception as

comp.lang.python is a high-volume Usenet open (not moderated) newsgroup for general discussions and questions about Python. You can also access it as a ...

2011-08-27 Thread shenba valli
comp.lang.python · Discussions · + new post · About this group · Subscribe to this group. This is a Usenet group - learn more. View this group in the new Google ... http://123maza.com/65/purple505/ -- http://mail.python.org/mailman/listinfo/python-list

Re: The RAISE_VARARGS opcode in Python 3

2011-08-27 Thread Arnaud Delobelle
On 27 August 2011 07:49, Peter Otten __pete...@web.de wrote: Arnaud Delobelle wrote: Here is an extract from the dis module doc [1] RAISE_VARARGS(argc) Raises an exception. argc indicates the number of parameters to the raise statement, ranging from 0 to 3. The handler will find the

how to format long if conditions

2011-08-27 Thread Arnaud Delobelle
Hi all, I'm wondering what advice you have about formatting if statements with long conditions (I always format my code to 80 colums) Here's an example taken from something I'm writing at the moment and how I've formatted it: if (isinstance(left, PyCompare) and isinstance(right,

Re: how to format long if conditions

2011-08-27 Thread Steven D'Aprano
Arnaud Delobelle wrote: Hi all, I'm wondering what advice you have about formatting if statements with long conditions (I always format my code to 80 colums) Here's an example taken from something I'm writing at the moment and how I've formatted it: if (isinstance(left,

Re: how to format long if conditions

2011-08-27 Thread Hans Mulder
On 27/08/11 09:08:20, Arnaud Delobelle wrote: I'm wondering what advice you have about formatting if statements with long conditions (I always format my code to80 colums) Here's an example taken from something I'm writing at the moment and how I've formatted it: if (isinstance(left,

Re: Python IDE/Eclipse

2011-08-27 Thread UncleLaz
On Aug 26, 5:18 pm, Dave Boland dbola...@fastmail.fm wrote: I'm looking for a good IDE -- easy to setup, easy to use -- for Python.   Any suggestions? I use Eclipse for other projects and have no problem with using it for Python, except that I can't get PyDev to install.  It takes forever,

Re: how to format long if conditions

2011-08-27 Thread Steven D'Aprano
Hans Mulder wrote: [...] It may look ugly, but it's very clear where the condition part ends and the 'then' part begins. Immediately after the colon, surely? -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Catch and name an exception in Python 2.5 +

2011-08-27 Thread Thomas Jollans
On 27/08/11 05:45, Steven D'Aprano wrote: Thomas Jollans wrote: On 26/08/11 21:56, Steven D'Aprano wrote: Is there any way to catch an exception and bind it to a name which will work across all Python versions from 2.5 onwards? I'm pretty sure there isn't, but I thought I'd ask just in

Re: how to format long if conditions

2011-08-27 Thread Arnaud Delobelle
On 27 August 2011 08:24, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Arnaud Delobelle wrote: Hi all, I'm wondering what advice you have about formatting if statements with long conditions (I always format my code to 80 colums) Here's an example taken from something I'm

Re: how to format long if conditions

2011-08-27 Thread Hans Mulder
On 27/08/11 11:05:25, Steven D'Aprano wrote: Hans Mulder wrote: [...] It may look ugly, but it's very clear where the condition part ends and the 'then' part begins. Immediately after the colon, surely? On the next line, actually :-) The point is, that this layout makes it very clear that

Re: Run time default arguments

2011-08-27 Thread Carl Banks
On Thursday, August 25, 2011 1:54:35 PM UTC-7, ti...@thsu.org wrote: On Aug 25, 10:35 am, Arnaud Delobelle arn...@gmail.com wrote: You're close to the usual idiom: def doSomething(debug=None):     if debug is None:         debug = defaults['debug']     ... Note the use of 'is'

Re: how to format long if conditions

2011-08-27 Thread Ben Finney
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info writes: I believe that PEP 8 now Specifically the “Indentation” section contains:: When using a hanging indent the following considerations should be applied; there should be no arguments on the first line and further indentation

[ANN] Oktest 0.9.0 released - a new-style testing library

2011-08-27 Thread Makoto Kuwata
Hi, I released Oktest 0.9.0. http://pypi.python.org/pypi/Oktest/ http://packages.python.org/Oktest/ Oktest is a new-style testing library for Python. :: from oktest import ok, NG ok (x) 0 # same as assert_(x 0) ok (s) == 'foo'# same as assertEqual(s,

typing question

2011-08-27 Thread Jason Swails
Hello everyone, This is probably a basic question with an obvious answer, but I don't quite get why the type(foo).__name__ works differently for some class instances and not for others. If I have an underived class, any instance of that class is simply of type instance. If I include an explicit

Re: typing question

2011-08-27 Thread Chris Angelico
On Sat, Aug 27, 2011 at 11:42 PM, Jason Swails jason.swa...@gmail.com wrote: I can't explain this behavior (since doesn't every class inherit from object by default? And if so, there should be no difference between any of my class definitions). That is true in Python 3, but not in Python 2.

UnicodeEncodeError -- 'character maps to undefined'

2011-08-27 Thread J
Hi there, I'm attempting to print a dictionary entry of some twitter data to screen but every now and then I get the following error: (type 'exceptions.UnicodeEncodeError', UnicodeEncodeError('charmap', u'RT @ciaraluvsjb26: BIEBER FEVER \u2665', 32, 33, 'character maps to undefined'),

Re: UnicodeEncodeError -- 'character maps to undefined'

2011-08-27 Thread Steven D'Aprano
J wrote: Hi there, I'm attempting to print a dictionary entry of some twitter data to screen but every now and then I get the following error: (type 'exceptions.UnicodeEncodeError', UnicodeEncodeError('charmap', u'RT @ciaraluvsjb26: BIEBER FEVER \u2665', 32, 33, 'character maps to

Re: how to format long if conditions

2011-08-27 Thread Colin J. Williams
On 27-Aug-11 03:50 AM, Hans Mulder wrote: On 27/08/11 09:08:20, Arnaud Delobelle wrote: I'm wondering what advice you have about formatting if statements with long conditions (I always format my code to80 colums) Here's an example taken from something I'm writing at the moment and how I've

Re: how to format long if conditions

2011-08-27 Thread Hans Mulder
On 27/08/11 17:16:51, Colin J. Williams wrote: What about: cond= isinstance(left, PyCompare) and isinstance(right, PyCompare) and left.complist[-1] is right.complist[0] py_and= PyCompare(left.complist + right.complist[1:])if cond else: py_and = PyBooleanAnd(left, right) Colin

Re: how to format long if conditions

2011-08-27 Thread Roy Smith
In article mailman.457.1314428909.27778.python-l...@python.org, Arnaud Delobelle arno...@gmail.com wrote: Hi all, I'm wondering what advice you have about formatting if statements with long conditions (I always format my code to 80 colums) [...] if (isinstance(left, PyCompare) and

Re: is there any principle when writing python function

2011-08-27 Thread Roy Smith
Chris Angelico ros...@gmail.com wrote: the important considerations are not will it take two extra nanoseconds to execute but can my successor understand what the code's doing and will he, if he edits my code, have a reasonable expectation that he's not breaking stuff. These are always

Understanding .pth files

2011-08-27 Thread Josh English
I am developing a library for Python 2.7. I'm on Windows XP. I am also learning the proper way to do this (per PyPi) but not in a linear fashion: I've built a prototype for the library, created my setup script, and run the install to make sure I had that bit working properly. Now I'm

Re: is there any principle when writing python function

2011-08-27 Thread Chris Angelico
On Sun, Aug 28, 2011 at 2:41 AM, Roy Smith r...@panix.com wrote: Forget about your successor.  Will *you* be able to figure out what you did 6 months from now?  I can't tell you how many times I've looked at some piece of code, muttered, Who wrote this crap? and called up the checkin history

Re: Record seperator

2011-08-27 Thread greymaus
On 2011-08-26, D'Arcy J.M. Cain da...@druid.net wrote: On 26 Aug 2011 18:39:07 GMT greymaus greyma...@mail.com wrote: Is there an equivelent for the AWK RS in Python? as in RS='\n\n' will seperate a file at two blank line intervals open(file.txt).read().split(\n\n) Ta!.. bit

Understanding .pth in site-packages

2011-08-27 Thread Josh English
(This may be a shortened double post) I have a development version of a library in c:\dev\XmlDB\xmldb After testing the setup script I also have c:\python27\lib\site-packages\xmldb Now I'm continuing to develop it and simultaneously building an application with it. I thought I could plug into

Arrange files according to a text file

2011-08-27 Thread Ric
Hello, What would be the best way to accomplish this task? I have many files in separate directories, each file name contain a persons name but never in the same spot. I need to find that name which is listed in a large text file in the following format. Last name, comma and First name. The last

Re: Understanding .pth in site-packages

2011-08-27 Thread Philip Semanchuk
On Aug 27, 2011, at 12:56 PM, Josh English wrote: (This may be a shortened double post) I have a development version of a library in c:\dev\XmlDB\xmldb After testing the setup script I also have c:\python27\lib\site-packages\xmldb Now I'm continuing to develop it and simultaneously

Re: Arrange files according to a text file

2011-08-27 Thread MRAB
On 27/08/2011 18:03, r...@rdo.python.org wrote: Hello, What would be the best way to accomplish this task? I have many files in separate directories, each file name contain a persons name but never in the same spot. I need to find that name which is listed in a large text file in the following

Re: is there any principle when writing python function

2011-08-27 Thread Emile van Sebille
On 8/27/2011 9:41 AM Roy Smith said... Chris Angelicoros...@gmail.com wrote: the important considerations are not will it take two extra nanoseconds to execute but can my successor understand what the code's doing and will he, if he edits my code, have a reasonable expectation that he's not

Re: Record seperator

2011-08-27 Thread Steven D'Aprano
greymaus wrote: On 2011-08-26, D'Arcy J.M. Cain da...@druid.net wrote: On 26 Aug 2011 18:39:07 GMT greymaus greyma...@mail.com wrote: Is there an equivelent for the AWK RS in Python? as in RS='\n\n' will seperate a file at two blank line intervals open(file.txt).read().split(\n\n)

Re: is there any principle when writing python function

2011-08-27 Thread Chris Angelico
On Sun, Aug 28, 2011 at 3:27 AM, Emile van Sebille em...@fenx.com wrote: Code is first and foremost written to be executed. +1 QOTW. Yes, it'll be read, and most likely read several times, by humans, but ultimately its purpose is to be executed. And in the case of some code, the programmer

Re: Understanding .pth in site-packages

2011-08-27 Thread Peter Otten
Josh English wrote: I have a development version of a library in c:\dev\XmlDB\xmldb After testing the setup script I also have c:\python27\lib\site-packages\xmldb Now I'm continuing to develop it and simultaneously building an application with it. I thought I could plug into my

Re: typing question

2011-08-27 Thread Chris Rebert
On Sat, Aug 27, 2011 at 6:42 AM, Jason Swails jason.swa...@gmail.com wrote: Hello everyone, This is probably a basic question with an obvious answer, but I don't quite get why the type(foo).__name__ works differently for some class instances and not for others.  If I have an underived class,

Re: Record seperator

2011-08-27 Thread Roy Smith
In article 4e592852$0$29965$c3e8da3$54964...@news.astraweb.com, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: open(file.txt) # opens the file .read() # reads the contents of the file .split(\n\n)# splits the text on double-newlines. The biggest problem with

Re: Understanding .pth in site-packages

2011-08-27 Thread Josh English
Philip, Yes, the proper path should be c:\dev\XmlDB, which has the setup.py, xmldb subfolder, the docs subfolder, and example subfolder, and the other text files proscribed by the package development folder. I could only get it to work, though, by renaming the xmldb folder in the

Re: Arrange files according to a text file

2011-08-27 Thread Emile van Sebille
On 8/27/2011 10:03 AM r...@rdo.python.org said... Hello, What would be the best way to accomplish this task? I'd do something like: usernames = Adler, Jack Smith, John Smith, Sally Stone, Mark.split('\n') filenames = Smith, John - 02-15-75 - business files.doc Random Data - Adler Jack -

Re: Understanding .pth in site-packages

2011-08-27 Thread Philip Semanchuk
On Aug 27, 2011, at 1:57 PM, Josh English wrote: Philip, Yes, the proper path should be c:\dev\XmlDB, which has the setup.py, xmldb subfolder, the docs subfolder, and example subfolder, and the other text files proscribed by the package development folder. I could only get it to work,

Re: Record seperator

2011-08-27 Thread ChasBrown
On Aug 27, 10:45 am, Roy Smith r...@panix.com wrote: In article 4e592852$0$29965$c3e8da3$54964...@news.astraweb.com,  Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: open(file.txt)   # opens the file  .read()           # reads the contents of the file  .split(\n\n)    # splits

Re: Run time default arguments

2011-08-27 Thread Stephen Hansen
On 8/25/11 1:54 PM, t...@thsu.org wrote: On Aug 25, 10:35 am, Arnaud Delobelle arno...@gmail.com wrote: You're close to the usual idiom: def doSomething(debug=None): if debug is None: debug = defaults['debug'] ... Note the use of 'is' rather than '==' HTH Hmm, from

How can I solve a equation like solve a function containint expressions like sqrt(log(x) - 1) = 2 and exp((log(x) - 1.5)**2 - 3) = 5

2011-08-27 Thread Xiong Deng
HI, Hi, I am trying to solve an equation containing both exp, log, erfc, and they may be embedded into each otherBut sympy cannot handle this, as shown below: from sympy import solve, exp, log, pi from sympy.mpmath import * from sympy import Symbol x=Symbol('x') sigma = 4 mu = 1.5 solve(x *

Re: Understanding .pth in site-packages

2011-08-27 Thread OKB (not okblacke)
Josh English wrote: Philip, Yes, the proper path should be c:\dev\XmlDB, which has the setup.py, xmldb subfolder, the docs subfolder, and example subfolder, and the other text files proscribed by the package development folder. I could only get it to work, though, by renaming the xmldb

Re: Record seperator

2011-08-27 Thread Terry Reedy
On 8/27/2011 1:45 PM, Roy Smith wrote: In article4e592852$0$29965$c3e8da3$54964...@news.astraweb.com, Steven D'Apranosteve+comp.lang.pyt...@pearwood.info wrote: open(file.txt) # opens the file .read() # reads the contents of the file .split(\n\n)# splits the text on

Re: Record seperator

2011-08-27 Thread Chris Angelico
On Sun, Aug 28, 2011 at 6:03 AM, Terry Reedy tjre...@udel.edu wrote:      yield para # or ''.join(para), as desired Or possibly '\n'.join(para) if you want to keep the line breaks inside paragraphs. ChrisA -- http://mail.python.org/mailman/listinfo/python-list

Re: typing question

2011-08-27 Thread Terry Reedy
On 8/27/2011 9:42 AM, Jason Swails wrote: P.S. I'll note that my preferred behavior is how python3.2 actually operates Python core developers agree. This is one of the reasons for breaking a bit from 2.x to make Python 3. -- Terry Jan Reedy --

Re: Arrange files according to a text file

2011-08-27 Thread Ric
Hello Emile , Thank you for the code below as I have not encountered SequenceMatcher before and would have to take a look at it closer. My question would it work for a text file list of names about 25k lines and a directory with say 100 files inside? Thank you once again. On Sat, 27 Aug

Re: Understanding .pth in site-packages

2011-08-27 Thread Terry Reedy
On 8/27/2011 2:07 PM, Philip Semanchuk wrote: On Aug 27, 2011, at 1:57 PM, Josh English wrote: Philip, Yes, the proper path should be c:\dev\XmlDB, which has the setup.py, xmldb subfolder, the docs subfolder, and example subfolder, and the other text files proscribed by the package

Re: Understanding .pth in site-packages

2011-08-27 Thread Philip Semanchuk
On Aug 27, 2011, at 4:14 PM, Terry Reedy wrote: On 8/27/2011 2:07 PM, Philip Semanchuk wrote: On Aug 27, 2011, at 1:57 PM, Josh English wrote: Philip, Yes, the proper path should be c:\dev\XmlDB, which has the setup.py, xmldb subfolder, the docs subfolder, and example subfolder, and

Re: is there any principle when writing python function

2011-08-27 Thread Steven D'Aprano
Chris Angelico wrote: On Sun, Aug 28, 2011 at 3:27 AM, Emile van Sebille em...@fenx.com wrote: Code is first and foremost written to be executed. +1 QOTW. Yes, it'll be read, and most likely read several times, by humans, but ultimately its purpose is to be executed. You've never noticed

Re: is there any principle when writing python function

2011-08-27 Thread Chris Angelico
On Sun, Aug 28, 2011 at 6:27 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: You've never noticed the masses of code written in text books, blogs, web pages, discussion forums like this one, etc.? Real world code for production is usually messy and complicated and filled with

Re: Arrange files according to a text file

2011-08-27 Thread Emile van Sebille
On 8/27/2011 1:15 PM r...@rdo.python.org said... Hello Emile , Thank you for the code below as I have not encountered SequenceMatcher before and would have to take a look at it closer. My question would it work for a text file list of names about 25k lines and a directory with say 100 files

Re: Record seperator

2011-08-27 Thread Roy Smith
In article mailman.477.1314475482.27778.python-l...@python.org, Terry Reedy tjre...@udel.edu wrote: On 8/27/2011 1:45 PM, Roy Smith wrote: In article4e592852$0$29965$c3e8da3$54964...@news.astraweb.com, Steven D'Apranosteve+comp.lang.pyt...@pearwood.info wrote: open(file.txt) #

Re: is there any principle when writing python function

2011-08-27 Thread Roy Smith
In article 4e595334$0$3$c3e8da3$54964...@news.astraweb.com, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: and then there are languages with few, or no, design principles to speak of Oh, like PHP? -- http://mail.python.org/mailman/listinfo/python-list

Re: how to format long if conditions

2011-08-27 Thread Colin J. Williams
On 27-Aug-11 11:53 AM, Hans Mulder wrote: On 27/08/11 17:16:51, Colin J. Williams wrote: What about: cond= isinstance(left, PyCompare) and isinstance(right, PyCompare) and left.complist[-1] is right.complist[0] py_and= PyCompare(left.complist + right.complist[1:])if cond else: py_and =

Re: UnicodeEncodeError -- 'character maps to undefined'

2011-08-27 Thread Ben Finney
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info writes: s = u'BIEBER FEVER \u2665' print s # Printing Unicode is fine. BIEBER FEVER ♥ You're a cruel man. Why do you hate me? -- \ “If nature has made any one thing less susceptible than all | `\others of exclusive

Re: is there any principle when writing python function

2011-08-27 Thread Ben Finney
Emile van Sebille em...@fenx.com writes: Code is first and foremost written to be executed. −1 QotW. I disagree, and have a counter-aphorism: “Programs must be written for people to read, and only incidentally for machines to execute.” —Abelson Sussman, _Structure and

Re: is there any principle when writing python function

2011-08-27 Thread Emile van Sebille
On 8/27/2011 2:57 PM Ben Finney said... Emile van Sebilleem...@fenx.com writes: Code is first and foremost written to be executed. “Programs must be written for people to read, and only incidentally for machines to execute.” —Abelson Sussman, _Structure and

Re: Understanding .pth in site-packages

2011-08-27 Thread Josh English
I have .egg files in my system path. The Egg file created by my setup script doesn't include anything but the introductory text. If I open other eggs I see the zipped data, but not for my own files. Is having a zipped egg file any faster than a regular package? or does it just prevent people

Re: Understanding .pth in site-packages

2011-08-27 Thread Josh English
When I run: os.listdir('c:\Python27\lib\site-packages') I get the contents in order, so the folders come before .pth files (as nothing comes before something.) I would guess Python is using os.listdir. Why wouldn't it? -- http://mail.python.org/mailman/listinfo/python-list

Re: Understanding .pth in site-packages

2011-08-27 Thread Josh English
OKB, The setup.py script created the egg, but not the .pth file. I created that myself. Thank you for clarifying about how .pth works. I know redirect imports was the wrong phrase, but it worked in my head at the time. It appears, at least on my system, that Python will find site-packages/foo

Re: is there any principle when writing python function

2011-08-27 Thread rantingrick
On Aug 27, 5:21 pm, Emile van Sebille em...@fenx.com wrote: On 8/27/2011 2:57 PM Ben Finney said... Emile van Sebilleem...@fenx.com  writes: Code is first and foremost written to be executed.      “Programs must be written for people to read, and only incidentally for      machines to

Re: is there any principle when writing python function

2011-08-27 Thread Roy Smith
In article mailman.489.1314483681.27778.python-l...@python.org, Emile van Sebille em...@fenx.com wrote: code that doesn't execute will need to be read to be understood, and to be fixed so that it does run. That is certainly true, but it's not the whole story. Even code that works perfectly

Re: Arrange files according to a text file

2011-08-27 Thread Ric
Thank you so much. The code worked perfectly. This is what I tried using Emile code. The only time when it picked wrong name from the list was when the file was named like this. Data Mark Stone.doc How can I fix this? Hope I am not asking too much? import os from difflib import

Re: is there any principle when writing python function

2011-08-27 Thread Stephen Hansen
On 8/27/11 3:21 PM, Emile van Sebille wrote: On 8/27/2011 2:57 PM Ben Finney said... Emile van Sebilleem...@fenx.com writes: Code is first and foremost written to be executed. “Programs must be written for people to read, and only incidentally for machines to execute.”

Re: Arrange files according to a text file

2011-08-27 Thread Stephen Hansen
On 8/27/11 11:06 AM, Emile van Sebille wrote: from difflib import SequenceMatcher as SM def ignore(x): return x in ' ,.' for filename in filenames: ratios = [SM(ignore,filename,username).ratio() for username in usernames] best = max(ratios) owner =

Re: Understanding .pth in site-packages

2011-08-27 Thread Stephen Hansen
On 8/27/11 3:41 PM, Josh English wrote: I have .egg files in my system path. The Egg file created by my setup script doesn't include anything but the introductory text. If I open other eggs I see the zipped data, but not for my own files. Sounds like your setup.py isn't actually including

Re: Arrange files according to a text file

2011-08-27 Thread MRAB
On 28/08/2011 00:18, r...@rdo.python.org wrote: Thank you so much. The code worked perfectly. This is what I tried using Emile code. The only time when it picked wrong name from the list was when the file was named like this. Data Mark Stone.doc How can I fix this? Hope I am not asking too

Re: Arrange files according to a text file

2011-08-27 Thread Ric
On Sun, 28 Aug 2011 00:48:20 +0100, MRAB pyt...@mrabarnett.plus.com wrote: On 28/08/2011 00:18, r...@rdo.python.org wrote: Thank you so much. The code worked perfectly. This is what I tried using Emile code. The only time when it picked wrong name from the list was when the file was named

packaging a python application

2011-08-27 Thread suresh
Hi I created a python application which consists of multiple python files and a configuration file. I am not sure, how can I distribute it. I read distutils2 documentation and a few blogs on python packaging. But I still have the following questions. 1. My package has a configuration file

Re: Record seperator

2011-08-27 Thread Terry Reedy
On 8/27/2011 5:07 PM, Roy Smith wrote: In articlemailman.477.1314475482.27778.python-l...@python.org, Terry Reedytjre...@udel.edu wrote: On 8/27/2011 1:45 PM, Roy Smith wrote: In article4e592852$0$29965$c3e8da3$54964...@news.astraweb.com, Steven

Re: Arrange files according to a text file

2011-08-27 Thread Emile van Sebille
On 8/27/2011 4:18 PM r...@rdo.python.org said... Thank you so much. The code worked perfectly. This is what I tried using Emile code. The only time when it picked wrong name from the list was when the file was named like this. Data Mark Stone.doc How can I fix this? Hope I am not asking too

Re: Record seperator

2011-08-27 Thread Dan Stromberg
http://stromberg.dnsalias.org/svn/bufsock/trunk does it. $ cat double-file daemon:x:1:1:daemon:/usr/sbin:/bin/sh bin:x:2:2:bin:/bin:/bin/sh sys:x:3:3:sys:/dev:/bin/sh sync:x:4:65534:sync:/bin:/bin/sync games:x:5:60:games:/usr/games:/bin/sh man:x:6:12:man:/var/cache/man:/bin/sh

Custom dict to prevent keys from being overridden

2011-08-27 Thread Julien
Hi, With a simple dict, the following happens: d = { ... 'a': 1, ... 'b': 2, ... 'a': 3 ... } d {'a': 3, 'b': 2} ... i.e. the value for the 'a' key gets overridden. What I'd like to achieve is: d = { ... 'a': 1, ... 'b': 2, ... 'a': 3 ... } Error: The key 'a' already exists.

Re: Custom dict to prevent keys from being overridden

2011-08-27 Thread Steven D'Aprano
Julien wrote: What I'd like to achieve is: d = { ... 'a': 1, ... 'b': 2, ... 'a': 3 ... } Error: The key 'a' already exists. Is that possible, and if so, how? Not if the requirements including using built-in dicts { }. But if you are happy enough to use a custom class, like

Re: Understanding .pth in site-packages

2011-08-27 Thread Philip Semanchuk
On Aug 27, 2011, at 6:49 PM, Josh English wrote: When I run: os.listdir('c:\Python27\lib\site-packages') I get the contents in order, so the folders come before .pth files (as nothing comes before something.) That's one definition of in order. =) I would guess Python is using

Why do closures do this?

2011-08-27 Thread John O'Hagan
Somewhat apropos of the recent function principle thread, I was recently surprised by this: funcs=[] for n in range(3): def f(): return n funcs.append(f) [i() for i in funcs] The last expression, IMO surprisingly, is [2,2,2], not [0,1,2]. Google tells me I'm not the only one

Re: Why do closures do this?

2011-08-27 Thread Terry Reedy
On 8/27/2011 11:45 PM, John O'Hagan wrote: Somewhat apropos of the recent function principle thread, I was recently surprised by this: funcs=[] for n in range(3): def f(): return n funcs.append(f) The last expression, IMO surprisingly, is [2,2,2], not [0,1,2]. Google

Re: is there any principle when writing python function

2011-08-27 Thread harrismh777
smith jack wrote: i have heard that function invocation in python is expensive, but make lots of functions are a good design habit in many other languages, so is there any principle when writing python function? for example, how many lines should form a function? Once Abraham Lincoln was asked

Re: Why do closures do this?

2011-08-27 Thread John O'Hagan
On Sun, 28 Aug 2011 00:19:07 -0400 Terry Reedy tjre...@udel.edu wrote: On 8/27/2011 11:45 PM, John O'Hagan wrote: Somewhat apropos of the recent function principle thread, I was recently surprised by this: funcs=[] for n in range(3): def f(): return n

Re: Understanding .pth in site-packages

2011-08-27 Thread OKB (not okblacke)
Josh English wrote: OKB, The setup.py script created the egg, but not the .pth file. I created that myself. Thank you for clarifying about how .pth works. I know redirect imports was the wrong phrase, but it worked in my head at the time. It appears, at least on my system, that Python

Re: Arrange files according to a text file

2011-08-27 Thread Ric
No, it turned out to be my mistake. Your code was correct and I appreciate it very much. Thank you again On Sat, 27 Aug 2011 18:10:07 -0700, Emile van Sebille em...@fenx.com wrote: On 8/27/2011 4:18 PM r...@rdo.python.org said... Thank you so much. The code worked perfectly. This is what I

[issue12768] docstrings for the threading module

2011-08-27 Thread Graeme Cross
Graeme Cross gjcr...@gmail.com added the comment: I will check that the patch works with 3.2; if not, I'll redo the patch for 3.2. I will also incorporate the review changes from Ezio and Eric. -- ___ Python tracker rep...@bugs.python.org

[issue12833] raw_input misbehaves when readline is imported

2011-08-27 Thread Nadeem Vawda
Nadeem Vawda nadeem.va...@gmail.com added the comment: Reproduced on 3.3 head. Looking at the documentation of the C readline library, it needs to know the length of the prompt in order to display properly, so this seems to be an acknowledged limitation of the underlying library rather than a

[issue12833] raw_input misbehaves when readline is imported

2011-08-27 Thread Idan Kamara
Idan Kamara idank...@gmail.com added the comment: You're right, as this little C program verifies: #include stdio.h #include stdlib.h #include readline/readline.h int main() { printf(foo ); char* buf = readline(); free(buf); return 0; } Passing ' ' seems to be a suitable

[issue12802] Windows error code 267 should be mapped to ENOTDIR, not EINVAL

2011-08-27 Thread Amaury Forgeot d'Arc
Amaury Forgeot d'Arc amaur...@gmail.com added the comment: Unfortunately, it won't work. _dosmaperr() is not exported by msvcrt.dll, it is only available when you link against the static version of the C runtime. -- ___ Python tracker

[issue12729] Python lib re cannot handle Unicode properly due to narrow/wide bug

2011-08-27 Thread Tom Christiansen
Tom Christiansen tchr...@perl.com added the comment: Guido van Rossum rep...@bugs.python.org wrote on Sat, 27 Aug 2011 03:26:21 -: To me, making (default) iteration deviate from indexing is anathema. So long is there's a way to interate through a string some other way that by code

[issue12847] crash with negative PUT in pickle

2011-08-27 Thread Antoine Pitrou
New submission from Antoine Pitrou pit...@free.fr: This doesn't happen on 2.x cPickle, where PUT keys are simply treated as strings. import pickle, pickletools s = b'Va\np-1\n.' pickletools.dis(s) 0: VUNICODE'a' 3: pPUT-1 7: .STOP highest protocol among

[issue12847] crash with negative PUT in pickle

2011-08-27 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: Same with LONG_BINPUT on a 32-bit build: s = b'\x80\x03X\x01\x00\x00\x00ar\xff\xff\xff\xff.' pickletools.dis(s) 0: \x80 PROTO 3 2: XBINUNICODE 'a' 8: rLONG_BINPUT -1 13: .STOP highest protocol among opcodes = 2

[issue11564] pickle not 64-bit ready

2011-08-27 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: Here is a new patch against 3.2. I can't say it works for sure, but it should be much better. It also adds a couple more tests. There seems to be a separate issue where pure-Python pickle.py considers 32-bit lengths signed where the C impl

[issue12848] pickle.py treats 32bit lengths as signed, but _pickle.c as unsigned

2011-08-27 Thread Antoine Pitrou
New submission from Antoine Pitrou pit...@free.fr: In several opcodes (BINBYTES, BINUNICODE... what else?), _pickle.c happily accepts 32-bit lengths of more than 2**31, while pickle.py uses marshal's i typecode which means signed... and therefore fails reading the data. Apparently, pickle.py

[issue12835] Missing SSLSocket.sendmsg() wrapper allows programs to send unencrypted data by mistake

2011-08-27 Thread Roundup Robot
Roundup Robot devn...@psf.upfronthosting.co.za added the comment: New changeset b06f011a3529 by Nick Coghlan in branch 'default': Fix #12835: prevent use of the unencrypted sendmsg/recvmsg APIs on SSL wrapped sockets (Patch by David Watson) http://hg.python.org/cpython/rev/b06f011a3529

[issue12835] Missing SSLSocket.sendmsg() wrapper allows programs to send unencrypted data by mistake

2011-08-27 Thread Nick Coghlan
Changes by Nick Coghlan ncogh...@gmail.com: -- resolution: - fixed stage: - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12835 ___

[issue9923] mailcap module may not work on non-POSIX platforms if MAILCAPS env variable is set

2011-08-27 Thread Roundup Robot
Roundup Robot devn...@psf.upfronthosting.co.za added the comment: New changeset 7b83d2c1aad9 by Nick Coghlan in branch 'default': Fix #9923: mailcap now uses the OS path separator for the MAILCAP envvar. Not backported, since it could break cases where people worked around the old

[issue12174] Multiprocessing logging levels unclear

2011-08-27 Thread Vinay Sajip
Vinay Sajip vinay_sa...@yahoo.co.uk added the comment: Although the reference docs don't list the numeric values of logging levels, this happened during reorganising of the docs. The table has moved to the HOWTO: http://docs.python.org/howto/logging.html#logging-levels That said, I don't

[issue9923] mailcap module may not work on non-POSIX platforms if MAILCAPS env variable is set

2011-08-27 Thread Nick Coghlan
Nick Coghlan ncogh...@gmail.com added the comment: As noted in the commit message, I didn't backport this, since it didn't seem worth risking breaking even the unlikely case that someone actually *was* using the MAILCAP environment variable on Windows. -- resolution: - fixed stage:

[issue12802] Windows error code 267 should be mapped to ENOTDIR, not EINVAL

2011-08-27 Thread Vlad Riscutia
Vlad Riscutia riscutiav...@gmail.com added the comment: Oh, got it. Interesting. Then should I just add a comment somewhere or should we resolve this as Won't Fix? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12802

[issue12802] Windows error code 267 should be mapped to ENOTDIR, not EINVAL

2011-08-27 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: We could add a special case to generrmap.c (but how can I compile and execute this file? it doesn't seem to be part of the project files). -- ___ Python tracker rep...@bugs.python.org

[issue12736] Request for python casemapping functions to use full not simple casemaps per Unicode's recommendation

2011-08-27 Thread Tom Christiansen
Tom Christiansen tchr...@perl.com added the comment: Guido van Rossum rep...@bugs.python.org wrote on Fri, 26 Aug 2011 21:11:24 -: Would this also affect .islower() and friends? SHORT VERSION: (7 lines) I don't believe so, but the relationship between lower() and islower()

[issue10015] Creating a multiprocess.pool.ThreadPool from a child thread blows up.

2011-08-27 Thread Vinay Sajip
Changes by Vinay Sajip vinay_sa...@yahoo.co.uk: -- title: Creating a multiproccess.pool.ThreadPool from a child thread blows up. - Creating a multiprocess.pool.ThreadPool from a child thread blows up. ___ Python tracker rep...@bugs.python.org

[issue12802] Windows error code 267 should be mapped to ENOTDIR, not EINVAL

2011-08-27 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: Ok, apparently I can use errmap.mak, except that I get the following error: Z:\default\PCnmake errmap.mak Microsoft (R) Program Maintenance Utility Version 9.00.21022.08 Copyright (C) Microsoft Corporation. All rights reserved. cl

  1   2   >