Re: splitting numpy array unevenly

2012-09-19 Thread Hans Mulder
On 18/09/12 16:02:02, Wanderer wrote: On Monday, September 17, 2012 7:43:06 PM UTC-4, Martin De Kauwe wrote: On Tuesday, September 18, 2012 8:31:09 AM UTC+10, Wanderer wrote: I need to divide a 512x512 image array with the first horizontal and vertical division 49 pixels in. Then every 59

Re: using text file to get ip address from hostname

2012-09-19 Thread Dan Katorza
בתאריך יום ראשון, 16 בספטמבר 2012 01:43:31 UTC+3, מאת Dan Katorza: בתאריך יום רביעי, 12 בספטמבר 2012 17:24:50 UTC+3, מאת Dan Katorza: hello , i'm new to Python and i searched the web and could not find an answer for my issue. i need to get an ip

Re: 'indent'ing Python in windows bat

2012-09-19 Thread Hans Mulder
On 18/09/12 05:01:14, Ian Kelly wrote: On Mon, Sep 17, 2012 at 7:08 PM, David Smith dav...@invtools.com wrote: How do I indent if I have something like: if (sR=='Cope'): sys.exit(1) elif (sR=='Perform') sys.exit(2) else sys.exit(3) How about: if sR == 'Cope': sys.exit(1) elif sR ==

Re: using text file to get ip address from hostname

2012-09-19 Thread Chris Angelico
On Wed, Sep 19, 2012 at 5:41 PM, Dan Katorza dkato...@gmail.com wrote: Hello again, I have another question and i hope you will understand me.. Is there any option where you can set the program to go back to lets say the top of the code? I mean if the program finished the operation and i

Re: using text file to get ip address from hostname

2012-09-19 Thread Dan Katorza
בתאריך יום רביעי, 19 בספטמבר 2012 11:14:29 UTC+3, מאת Chris Angelico: On Wed, Sep 19, 2012 at 5:41 PM, Dan Katorza dkato...@gmail.com wrote: Hello again, I have another question and i hope you will understand me.. Is there any option where you can set the program to go back to

Re: using text file to get ip address from hostname

2012-09-19 Thread Chris Angelico
On Wed, Sep 19, 2012 at 6:50 PM, Dan Katorza dkato...@gmail.com wrote: i know about the while loop , but forgive me i just don't have a clue how to use it for this situation. You've already used one. What you need to do is surround your entire code with the loop, so that as soon as it gets to

Re: using text file to get ip address from hostname

2012-09-19 Thread Dan Katorza
בתאריך יום רביעי, 19 בספטמבר 2012 11:50:56 UTC+3, מאת Dan Katorza: בתאריך יום רביעי, 19 בספטמבר 2012 11:14:29 UTC+3, מאת Chris Angelico: On Wed, Sep 19, 2012 at 5:41 PM, Dan Katorza dkato...@gmail.com wrote: Hello again, I have another question and i hope you

Re: 'indent'ing Python in windows bat

2012-09-19 Thread Thomas Rachel
Am 18.09.2012 15:03 schrieb David Smith: I COULD break down each batch file and write dozens of mini python scripts to be called. I already have a few, too. Efficiency? Speed is bad, but these are bat files, after all. The cost of trying to work with a multitude of small files is high, though,

Using dict as object

2012-09-19 Thread Pierre Tardy
One thing that is cooler with java-script than in python is that dictionaries and objects are the same thing. It allows browsing of complex hierarchical data syntactically easy. For manipulating complex jsonable data, one will always prefer writing: buildrequest.properties.myprop rather than

Re: subprocess call is not waiting.

2012-09-19 Thread andrea crotti
2012/9/18 Dennis Lee Bieber wlfr...@ix.netcom.com: Unless you have a really massive result set from that ls, that command probably ran so fast that it is blocked waiting for someone to read the PIPE. I tried also with ls -lR / and that definitively takes a while to run, when I do

A little morning puzzle

2012-09-19 Thread Neal Becker
I have a list of dictionaries. They all have the same keys. I want to find the set of keys where all the dictionaries have the same values. Suggestions? -- http://mail.python.org/mailman/listinfo/python-list

Re: A little morning puzzle

2012-09-19 Thread Peter Otten
Neal Becker wrote: I have a list of dictionaries. They all have the same keys. I want to find the set of keys where all the dictionaries have the same values. Suggestions? items = [ ... {1:2, 2:2}, ... {1:1, 2:2}, ... ] first = items[0].items() [key for key, value in first if

Re: A little morning puzzle

2012-09-19 Thread Jussi Piitulainen
Neal Becker writes: I have a list of dictionaries. They all have the same keys. I want to find the set of keys where all the dictionaries have the same values. Suggestions? Literally-ish: { key for key, val in ds[0].items() if all(val == d[key] for d in ds) } --

Re: Using dict as object

2012-09-19 Thread Dave Angel
On 09/19/2012 06:24 AM, Pierre Tardy wrote: One thing that is cooler with java-script than in python is that dictionaries and objects are the same thing. It allows browsing of complex hierarchical data syntactically easy. You probably need some different terminology, since a dictionary is

Re: A little morning puzzle

2012-09-19 Thread Dwight Hutto
I have a list of dictionaries. They all have the same keys. I want to find the set of keys where all the dictionaries have the same values. Suggestions? Here is my solution: a = {} a['dict'] = 1 b = {} b['dict'] = 2 c = {} c['dict'] = 1 d = {} d['dict'] = 3 e = {} e['dict'] = 1 x =

Re: A little morning puzzle

2012-09-19 Thread Peter Otten
Dwight Hutto wrote: I have a list of dictionaries. They all have the same keys. I want to find the set of keys where all the dictionaries have the same values. Suggestions? Here is my solution: a = {} a['dict'] = 1 b = {} b['dict'] = 2 c = {} c['dict'] = 1 d = {}

Re: A little morning puzzle

2012-09-19 Thread Antoon Pardon
On 19-09-12 13:17, Neal Becker wrote: I have a list of dictionaries. They all have the same keys. I want to find the set of keys where all the dictionaries have the same values. Suggestions? common_items = reduce(opereator.__and__, [set(dct.iteritems()) for dct in lst]) common_keys =

Re: Re: 'indent'ing Python in windows bat

2012-09-19 Thread David Smith
On 2012-09-19 05:22, Thomas Rachel wrote: Am 18.09.2012 15:03 schrieb David Smith: I COULD break down each batch file and write dozens of mini python scripts to be called. I already have a few, too. Efficiency? Speed is bad, but these are bat files, after all. The cost of trying to work with a

Re: A little morning puzzle

2012-09-19 Thread Dwight Hutto
On Wed, Sep 19, 2012 at 8:01 AM, Dwight Hutto dwightdhu...@gmail.com wrote: I have a list of dictionaries. They all have the same keys. I want to find the set of keys where all the dictionaries have the same values. Suggestions? This one is better: a = {} a['dict'] = 1 b = {} b['dict']

Re: using text file to get ip address from hostname

2012-09-19 Thread Dan Katorza
בתאריך יום רביעי, 19 בספטמבר 2012 12:11:04 UTC+3, מאת Dan Katorza: בתאריך יום רביעי, 19 בספטמבר 2012 11:50:56 UTC+3, מאת Dan Katorza: בתאריך יום רביעי, 19 בספטמבר 2012 11:14:29 UTC+3, מאת Chris Angelico: On Wed, Sep 19, 2012 at 5:41 PM, Dan Katorza dkato...@gmail.com wrote:

Re: Decorators not worth the effort

2012-09-19 Thread Jean-Michel Pichavant
- Original Message - Jean-Michel Pichavant jeanmic...@sequans.com writes: - Original Message - Jean-Michel Pichavant wrote: [snip] One minor note, the style of decorator you are using loses the docstring (at least) of the original function. I would add the

Re: subprocess call is not waiting.

2012-09-19 Thread Hans Mulder
On 19/09/12 12:26:30, andrea crotti wrote: 2012/9/18 Dennis Lee Bieber wlfr...@ix.netcom.com: Unless you have a really massive result set from that ls, that command probably ran so fast that it is blocked waiting for someone to read the PIPE. I tried also with ls -lR / and that

Re: Using dict as object

2012-09-19 Thread Oscar Benjamin
On 2012-09-19, Dave Angel d...@davea.name wrote: On 09/19/2012 06:24 AM, Pierre Tardy wrote: All implementation I tried are much slower than a pure native dict access. Each implementation have bench results in commit comment. All of them are 20+x slower than plain dict! Assuming you're

Re: Using dict as object

2012-09-19 Thread Thomas Rachel
Am 19.09.2012 12:24 schrieb Pierre Tardy: One thing that is cooler with java-script than in python is that dictionaries and objects are the same thing. It allows browsing of complex hierarchical data syntactically easy. For manipulating complex jsonable data, one will always prefer writing:

sum works in sequences (Python 3)

2012-09-19 Thread Franck Ditter
Hello, I wonder why sum does not work on the string sequence in Python 3 : sum((8,5,9,3)) 25 sum([5,8,3,9,2]) 27 sum('rtarze') TypeError: unsupported operand type(s) for +: 'int' and 'str' I naively thought that sum('abc') would expand to 'a'+'b'+'c' And the error message is somewhat

Re: sum works in sequences (Python 3)

2012-09-19 Thread Joel Goldstick
On Wed, Sep 19, 2012 at 10:41 AM, Franck Ditter fra...@ditter.org wrote: Hello, I wonder why sum does not work on the string sequence in Python 3 : sum((8,5,9,3)) 25 sum([5,8,3,9,2]) 27 sum('rtarze') TypeError: unsupported operand type(s) for +: 'int' and 'str' I naively thought that

Re: sum works in sequences (Python 3)

2012-09-19 Thread Neil Cerutti
On 2012-09-19, Franck Ditter fra...@ditter.org wrote: Hello, I wonder why sum does not work on the string sequence in Python 3 : sum((8,5,9,3)) 25 sum([5,8,3,9,2]) 27 sum('rtarze') TypeError: unsupported operand type(s) for +: 'int' and 'str' I naively thought that sum('abc') would

Re: sum works in sequences (Python 3)

2012-09-19 Thread Ian Kelly
On Wed, Sep 19, 2012 at 8:41 AM, Franck Ditter fra...@ditter.org wrote: Hello, I wonder why sum does not work on the string sequence in Python 3 : sum((8,5,9,3)) 25 sum([5,8,3,9,2]) 27 sum('rtarze') TypeError: unsupported operand type(s) for +: 'int' and 'str' I naively thought that

Re: sum works in sequences (Python 3)

2012-09-19 Thread Neil Cerutti
On 2012-09-19, Ian Kelly ian.g.ke...@gmail.com wrote: It notes in the doc string that it does not work on strings: sum(...) sum(sequence[, start]) - value Returns the sum of a sequence of numbers (NOT strings) plus the value of parameter 'start' (which defaults to 0). When

Re: sum works in sequences (Python 3)

2012-09-19 Thread Alister
On Wed, 19 Sep 2012 16:41:20 +0200, Franck Ditter wrote: Hello, I wonder why sum does not work on the string sequence in Python 3 : sum((8,5,9,3)) 25 sum([5,8,3,9,2]) 27 sum('rtarze') TypeError: unsupported operand type(s) for +: 'int' and 'str' I naively thought that sum('abc')

Re: A little morning puzzle

2012-09-19 Thread Ian Kelly
On Wed, Sep 19, 2012 at 6:13 AM, Antoon Pardon antoon.par...@rece.vub.ac.be wrote: On 19-09-12 13:17, Neal Becker wrote: I have a list of dictionaries. They all have the same keys. I want to find the set of keys where all the dictionaries have the same values. Suggestions? common_items =

Re: sum works in sequences (Python 3)

2012-09-19 Thread Ian Kelly
On Wed, Sep 19, 2012 at 9:06 AM, Neil Cerutti ne...@norwich.edu wrote: Are iterables and sequences different enough to warrant posting a bug report? The glossary is specific about the definitions of both, so I would say yes. http://docs.python.org/dev/glossary.html#term-iterable

Re: sum works in sequences (Python 3)

2012-09-19 Thread Steve Howell
On Sep 19, 8:06 am, Neil Cerutti ne...@norwich.edu wrote: On 2012-09-19, Ian Kelly ian.g.ke...@gmail.com wrote: It notes in the doc string that it does not work on strings: sum(...)     sum(sequence[, start]) - value     Returns the sum of a sequence of numbers (NOT strings) plus    

Re: subprocess call is not waiting.

2012-09-19 Thread Gene Heskett
On Wednesday 19 September 2012 11:56:44 Hans Mulder did opine: On 19/09/12 12:26:30, andrea crotti wrote: 2012/9/18 Dennis Lee Bieber wlfr...@ix.netcom.com: Unless you have a really massive result set from that ls, that command probably ran so fast that it is blocked

Re: sum works in sequences (Python 3)

2012-09-19 Thread Steven D'Aprano
On Wed, 19 Sep 2012 09:03:03 -0600, Ian Kelly wrote: I think this restriction is mainly for efficiency. sum(['a', 'b', 'c', 'd', 'e']) would be the equivalent of 'a' + 'b' + 'c' + 'd' + 'e', which is an inefficient way to add together strings. It might not be obvious to some people why

Re: Using dict as object

2012-09-19 Thread Pierre Tardy
This has been proposed and discussed and even implemented many times on this list and others. I can find this question on SO http://stackoverflow.com/questions/4984647/accessing-dict-keys-like-an-attribute-in-python which is basically answered with this solution class AttributeDict(dict):

Re: sum works in sequences (Python 3)

2012-09-19 Thread Steven D'Aprano
On Wed, 19 Sep 2012 15:07:04 +, Alister wrote: Summation is a mathematical function that works on numbers Concatenation is the process of appending 1 string to another although they are not related to each other they do share the same operator(+) which is the cause of confusion.

Re: subprocess call is not waiting.

2012-09-19 Thread andrea crotti
2012/9/19 Hans Mulder han...@xs4all.nl: Yes: using top is an observation problem. Top, as the name suggests, shows only the most active processes. Sure but ls -lR / is a very active process if you try to run it.. Anyway as written below I don't need this anymore. It's quite possible that

Re: Python presentations

2012-09-19 Thread andrea crotti
2012/9/19 Trent Nelson tr...@snakebite.org: FWIW, I gave a presentation on decorators to the New York Python User Group back in 2008. Relevant blog post: http://blogs.onresolve.com/?p=48 There's a link to the PowerPoint presentation I used in the first paragraph.

Re: subprocess call is not waiting.

2012-09-19 Thread Benjamin Kaplan
On Sep 19, 2012 9:37 AM, andrea crotti andrea.crott...@gmail.com wrote: Well there is a process which has to do two things, monitor periodically some external conditions (filesystem / db), and launch a process that can take very long time. So I can't put a wait anywhere, or I'll stop

Re: A little morning puzzle

2012-09-19 Thread Paul Rubin
Neal Becker ndbeck...@gmail.com writes: I have a list of dictionaries. They all have the same keys. I want to find the set of keys where all the dictionaries have the same values. Suggestions? Untested, and uses a few more comparisons than necessary: # ds = [dict1, dict2 ... ] d0 =

How to get the list of all my open file(descriptor)s and locks?

2012-09-19 Thread Ismael Farfán
Hello list From man 2 EXECVE By default, file descriptors remain open across an execve() And from man 2 FCNTL Record locks are... preserved across an execve(2). So the question: * If I execve a python script (from C), how can I retrieve the list of files, and optionally the list of locks, from

Re: subprocess call is not waiting.

2012-09-19 Thread Hans Mulder
On 19/09/12 18:34:58, andrea crotti wrote: 2012/9/19 Hans Mulder han...@xs4all.nl: Yes: using top is an observation problem. Top, as the name suggests, shows only the most active processes. Sure but ls -lR / is a very active process if you try to run it.. Not necessarily: It's quite

Re: 'indent'ing Python in windows bat

2012-09-19 Thread Albert Hopkins
On Tue, 2012-09-18 at 22:12 -0600, Jason Friedman wrote: I'm converting windows bat files little by little to Python 3 as I find time and learn Python. The most efficient method for some lines is to call Python like: python -c import sys; sys.exit(3) How do I indent if I have something

Re: 'indent'ing Python in windows bat

2012-09-19 Thread Terry Reedy
On 9/19/2012 8:27 AM, David Smith wrote: but not: print('hi');if 1: print('hi') Chokes on the 'if'. On the surface, this is not consistent. Yes it is. ; can only be followed by simple statements. The keyword for compound statememts must be the first non-indent token on a line. That is why

Re: using text file to get ip address from hostname

2012-09-19 Thread Dave Angel
On 09/19/2012 08:28 AM, Dan Katorza wrote: בתאריך יום רביעי, 19 בספטמבר 2012 12:11:04 UTC+3, מאת Dan Katorza: SNIP hi, ll like found a solution, it's not quite like Chris advised but it works. Not at all like Chris advised. But it also doesn't help you understand programming. Two concepts

Re: 'indent'ing Python in windows bat

2012-09-19 Thread Hans Mulder
On 19/09/12 19:51:44, Albert Hopkins wrote: On Tue, 2012-09-18 at 22:12 -0600, Jason Friedman wrote: I'm converting windows bat files little by little to Python 3 as I find time and learn Python. The most efficient method for some lines is to call Python like: python -c import sys;

using uwsgi to get flask going

2012-09-19 Thread Littlefield, Tyler
Hello all: This is my first shot with UWSGI and Python on Nginx, and I'm getting kind of confused. My uwsgi init script looks like: #!/bin/sh #/etc/init.d/uwsgi ### BEGIN INIT INFO # Provides: uwsgi # Required-Start: $all # Required-Stop: $all # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 ###

Re: sum works in sequences (Python 3)

2012-09-19 Thread Ian Kelly
On Wed, Sep 19, 2012 at 9:37 AM, Steve Howell showel...@yahoo.com wrote: Sequences are iterables, so I'd say the docs are technically correct, but maybe I'm misunderstanding what you would be trying to clarify. The doc string suggests that the argument to sum() must be a sequence, when in fact

Re: sum works in sequences (Python 3)

2012-09-19 Thread Steve Howell
On Sep 19, 11:34 am, Ian Kelly ian.g.ke...@gmail.com wrote: On Wed, Sep 19, 2012 at 9:37 AM, Steve Howell showel...@yahoo.com wrote: Sequences are iterables, so I'd say the docs are technically correct, but maybe I'm misunderstanding what you would be trying to clarify. The doc string

Re: sum works in sequences (Python 3)

2012-09-19 Thread Terry Reedy
On 9/19/2012 11:07 AM, Alister wrote: Summation is a mathematical function that works on numbers Concatenation is the process of appending 1 string to another although they are not related to each other they do share the same operator(+) which is the cause of confusion. If one represents

Re: How to send email programmatically from a gmail email a/c when port 587(smtp) is blocked

2012-09-19 Thread ashish
Folks, I asked the same query on the python tutor mailing list. The responses i received are here : http://thread.gmane.org/gmane.comp.python.tutor/77601 Mark, There is nothing wrong in asking a query on multiple forums. Poeple on the tutor list, may not be part of comp.lang.python

Re: Python presentations

2012-09-19 Thread 88888 Dihedral
andrea crotti於 2012年9月20日星期四UTC+8上午12時42分50秒寫道: 2012/9/19 Trent Nelson tr...@snakebite.org: FWIW, I gave a presentation on decorators to the New York Python User Group back in 2008. Relevant blog post: http://blogs.onresolve.com/?p=48 There's a

Passing arguments to executing, a python script on a remote machine from a python script on local machine

2012-09-19 Thread ashish
Hi PyTutor Folks Here is my situation 1. I have two machines. Lets call them local remote. Both run ubuntu both have python installed 2. I have a python script, local.py, running on local which needs to pass arguments ( 3/4 string arguments, containing whitespaces like spaces, etc ) to a

Passing arguments to executing, a python script on a remote machine from a python script on local machine (using ssh ?)

2012-09-19 Thread ashish
Hi c.l.p folks Here is my situation 1. I have two machines. Lets call them 'local' 'remote'. Both run ubuntu both have python installed 2. I have a python script, local.py, running on 'local' which needs to pass arguments ( 3/4 string arguments, containing whitespaces like spaces, etc ) to

Re: Re: 'indent'ing Python in windows bat

2012-09-19 Thread David Smith
On 2012-09-19 14:18, Terry Reedy wrote: stating correctly that it works for exec(). My mistake. I fancied you were talking shell, not python. I now see that Python 3 has exec() as a built-in. python -c exec('print(\hi\)\nif 0:\n print(\hi\)\nelif 1:\n print(\hi2\)') worked right off the

Re: Passing arguments to executing, a python script on a remote machine from a python script on local machine (using ssh ?)

2012-09-19 Thread Ismael Farfán
2012/9/19 ashish ashish.mak...@gmail.com: Hi c.l.p folks Here is my situation 1. I have two machines. Lets call them 'local' 'remote'. Both run ubuntu both have python installed 2. I have a python script, local.py, running on 'local' which needs to pass arguments ( 3/4 string

Re: How to get the list of all my open file(descriptor)s and locks?

2012-09-19 Thread Ismael Farfán
2012/9/19 Ismael Farfán sulfur...@gmail.com: Hello list From man 2 EXECVE By default, file descriptors remain open across an execve() And from man 2 FCNTL Record locks are... preserved across an execve(2). So the question: * If I execve a python script (from C), how can I retrieve the

Re: How to get the list of all my open file(descriptor)s and locks?

2012-09-19 Thread Ian Kelly
On Wed, Sep 19, 2012 at 11:34 AM, Ismael Farfán sulfur...@gmail.com wrote: So the question: * If I execve a python script (from C), how can I retrieve the list of files, and optionally the list of locks, from within the execve(d) python process so that I can use them? Some more info: I'm

Re: How to get the list of all my open file(descriptor)s and locks?

2012-09-19 Thread Ian Kelly
On Wed, Sep 19, 2012 at 2:36 PM, Ismael Farfán sulfur...@gmail.com wrote: It seems like I can use os.fstat to find out if a fd exists and also get it's type and mode (I'm getting some pipes too : ) Sure, because files and pipes both use the file descriptor abstraction. If your process does any

Re: How to get the list of all my open file(descriptor)s and locks?

2012-09-19 Thread Ismael Farfán
2012/9/19 Ian Kelly ian.g.ke...@gmail.com: On Wed, Sep 19, 2012 at 2:36 PM, Ismael Farfán sulfur...@gmail.com wrote: It seems like I can use os.fstat to find out if a fd exists and also get it's type and mode (I'm getting some pipes too : ) Sure, because files and pipes both use the file

Re: sum works in sequences (Python 3)

2012-09-19 Thread Hans Mulder
On 19/09/12 17:07:04, Alister wrote: On Wed, 19 Sep 2012 16:41:20 +0200, Franck Ditter wrote: Hello, I wonder why sum does not work on the string sequence in Python 3 : sum((8,5,9,3)) 25 sum([5,8,3,9,2]) 27 sum('rtarze') TypeError: unsupported operand type(s) for +: 'int' and 'str' I

Re: Using dict as object

2012-09-19 Thread Oscar Benjamin
On 2012-09-19, Pierre Tardy tar...@gmail.com wrote: --===1362296571== Content-Type: multipart/alternative; boundary=bcaec554d3229e814204ca105e50 --bcaec554d3229e814204ca105e50 Content-Type: text/plain; charset=ISO-8859-1 This has been proposed and discussed and even

Re: How to get the list of all my open file(descriptor)s and locks?

2012-09-19 Thread Christian Heimes
Am 19.09.2012 19:34, schrieb Ismael Farfán: Hello list From man 2 EXECVE By default, file descriptors remain open across an execve() And from man 2 FCNTL Record locks are... preserved across an execve(2). So the question: * If I execve a python script (from C), how can I retrieve the

Installing Pip onto a mac os x system

2012-09-19 Thread John Mordecai Dildy
Does anyone know how to install Pip onto a mac os x ver 10.7.4? Ive tried easy_instal pip but it brings up this message (but it doesn't help with my problem): error: can't create or remove files in install directory The following error occurred while trying to add or remove files in the

Re: Installing Pip onto a mac os x system

2012-09-19 Thread Benjamin Kaplan
On Sep 19, 2012 6:37 PM, John Mordecai Dildy jdild...@gmail.com wrote: Does anyone know how to install Pip onto a mac os x ver 10.7.4? Ive tried easy_instal pip but it brings up this message (but it doesn't help with my problem): error: can't create or remove files in install directory The

Re: How to get the list of all my open file(descriptor)s and locks?

2012-09-19 Thread Chris Angelico
On Thu, Sep 20, 2012 at 7:09 AM, Ian Kelly ian.g.ke...@gmail.com wrote: You could do: os.listdir(/proc/%d/fd % os.getpid()) This should work on Linux, AIX, and Solaris, but obviously not on Windows. I'm not sure how cross-platform it is, but at least on Linux, you can use /proc/self as an

Re: Programming Issues

2012-09-19 Thread Jason Friedman
Ask the user for the amount of change expressed in cents. Your program must compute and display the number of half-dollars, quarters, dimes, nickels, and pennies to be returned. Return as many half-dollars as possible, then quarters, dimes, nickels, and pennies, in that order. Your program

Re: Passing arguments to executing, a python script on a remote machine from a python script on local machine (using ssh ?)

2012-09-19 Thread Tim Roberts
ashish ashish.mak...@gmail.com wrote: Here is my situation 1. I have two machines. Lets call them 'local' 'remote'. Both run ubuntu both have python installed 2. I have a python script, local.py, running on 'local' which needs to pass arguments ( 3/4 string arguments, containing whitespaces

Re: How to get the list of all my open file(descriptor)s and locks?

2012-09-19 Thread Ismael Farfán
2012/9/19 Christian Heimes christ...@python.org: So the question: * If I execve a python script (from C), how can I retrieve the list of files, and optionally the list of locks, from within the execve(d) python process so that I can use them? Have a look at psutil:

Re: Passing arguments to executing, a python script on a remote machine from a python script on local machine

2012-09-19 Thread Steven D'Aprano
On Wed, 19 Sep 2012 12:46:33 -0700, ashish wrote: Hi PyTutor Folks Here is my situation 1. I have two machines. Lets call them local remote. Both run ubuntu both have python installed 2. I have a python script, local.py, running on local which needs to pass arguments ( 3/4 string

Re: Passing arguments to executing, a python script on a remote machine from a python script on local machine

2012-09-19 Thread Chris Angelico
On Thu, Sep 20, 2012 at 2:27 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Wed, 19 Sep 2012 12:46:33 -0700, ashish wrote: 2. I have a python script, local.py, running on local which needs to pass arguments ( 3/4 string arguments, containing whitespaces like spaces, etc )

Re: using text file to get ip address from hostname

2012-09-19 Thread Dan Katorza
בתאריך יום רביעי, 19 בספטמבר 2012 15:28:23 UTC+3, מאת Dan Katorza: בתאריך יום רביעי, 19 בספטמבר 2012 12:11:04 UTC+3, מאת Dan Katorza: בתאריך יום רביעי, 19 בספטמבר 2012 11:50:56 UTC+3, מאת Dan Katorza: בתאריך יום רביעי, 19 בספטמבר 2012 11:14:29 UTC+3, מאת Chris Angelico:

[issue15896] Sporadic EINVAL in nonblocking pipe os.read when forked child fails on Mac OS

2012-09-19 Thread Ronald Oussoren
Ronald Oussoren added the comment: The workaround should not be implemented in os.read because it is a very thin wrapper around the system call and should stay that way. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15896

[issue15967] Slaves don't seem to clean up their /tmp mess if a step fails.

2012-09-19 Thread Chris Jerdonek
Chris Jerdonek added the comment: Personally I think the best solution is to have the test framework allocate a single test directory This is partially done. See here: http://hg.python.org/cpython/file/19c74cadea95/Lib/test/regrtest.py#l1810 # Run the tests in a context manager that

[issue15896] Sporadic EINVAL in nonblocking pipe os.read when forked child fails on Mac OS

2012-09-19 Thread Vitaly
Vitaly added the comment: The workaround should not be implemented in os.read because it is a very thin wrapper around the system call and should stay that way. Although this issue was initially filed as Sporadic EINVAL in nonblocking pipe os.read when forked child fails on Mac OS, the

[issue15896] Sporadic EINVAL in nonblocking pipe os.read when forked child fails on Mac OS

2012-09-19 Thread Ronald Oussoren
Ronald Oussoren added the comment: How can you work around it in os.read, without knowing anything about what the file descriptor represents? Just triggering on getting on EINVAL error when calling read might trigger other problems and might even be a valid result for some file descriptors

[issue14783] Make int() and str() docstrings correct

2012-09-19 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: +.. function:: int(number=0) First argument is named x. int(number=42) Traceback (most recent call last): File stdin, line 1, in module TypeError: 'number' is an invalid keyword argument for this function int(x=42) 42 + int(string,

[issue6471] errno and strerror attributes incorrectly set on socket errors wrapped by urllib

2012-09-19 Thread Ezio Melotti
Ezio Melotti added the comment: I seem to remember writing code that fished the wrapped error out using one of those attributrs... That would be err.reason: from urllib.request import urlopen try: urlopen('http://www.pythonfoobarbaz.org') except Exception as exc: print('err:', err)

[issue6471] errno and strerror attributes incorrectly set on socket errors wrapped by urllib

2012-09-19 Thread Chris Jerdonek
Changes by Chris Jerdonek chris.jerdo...@gmail.com: -- nosy: +cjerdonek ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6471 ___ ___

[issue14783] Make int() and str() docstrings correct

2012-09-19 Thread Ezio Melotti
Ezio Melotti added the comment: First argument is named x. Sometimes the doc uses better names to improve clarity when the argument is not supposed to be called as keyword arg. Here can be not only string, but bytes or bytearray. The same applies here. string is also used in the error

[issue11454] email.message import time

2012-09-19 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: If I change the regex to _has_surrogates = re.compile('[\udc80-\udcff]').search, the tests still pass but there's no improvement on startup time (note: the previous regex was matching all the surrogates in this range too, however I'm not sure how well

[issue11454] email.message import time

2012-09-19 Thread Ezio Melotti
Ezio Melotti added the comment: What about _has_surrogates = re.compile('[^\udc80-\udcff]*\Z').match ? The runtime is a bit slower than re.compile('[\udc80-\udcff]').search, but otherwise it's faster than all the other alternatives. I haven't checked the startup-time, but I suspect it won't

[issue11454] email.message import time

2012-09-19 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I haven't checked the startup-time, but I suspect it won't be better -- maybe even worse. I suppose it will be much better. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11454

[issue11454] email.message import time

2012-09-19 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Startup-time: $ ./python -m timeit -s 'import re' 're.compile(([^\ud800-\udbff]|\A)[\udc00-\udfff]([^\udc00-\udfff]|\Z)).search; re.purge()' 100 loops, best of 3: 4.16 msec per loop $ ./python -m timeit -s 'import re' 're.purge()'

[issue11664] Add patch method to unittest.TestCase

2012-09-19 Thread Michael Foord
Michael Foord added the comment: It maybe that patch.object is a more natural interface to the small sample of people commenting here, in which case great - that's what it's there for. However in common usage patch is used around two orders of magnitude more. I've seen large codebases with

[issue15946] Windows 8 x64 - IO-Error

2012-09-19 Thread Martin v . Löwis
Martin v. Löwis added the comment: I think it should be possible to add a wait=False parameter to rmtree which makes it block until the directory is gone away. This could be similar to the test.support feature added in #15496. For compatibility, such a flag should default to False, and users

[issue11454] email.message import time

2012-09-19 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Faster set-version: $ ./python -m timeit -s 'h=lambda s, hn=set(map(chr, range(0xDC80, 0xDD00))).isdisjoint: not hn(s); s = A*1000' 'h(s)' 1 loops, best of 3: 43.8 usec per loop -- ___ Python tracker

[issue15276] unicode format does not really work in Python 2.x

2012-09-19 Thread Martin v . Löwis
Martin v. Löwis added the comment: What do you think? [Even though I wasn't asked] I think we may need to close the issue as won't fix. Depending on the exact change propsosed, it may be that the return type for existing operations might change, which shouldn't be done in a bug fix release.

[issue15964] SyntaxError in asdl when building 2.7 with system Python 3

2012-09-19 Thread Martin v . Löwis
Martin v. Löwis added the comment: The case that python is a Python 3 binary is not a supported installation (see PEP 394). asdl_c.py works on both 2.x and 3.x unmodified in the 3.x branch, however, backporting this to 2.7 would be a new feature (support for building on systems where python

[issue15966] concurrent.futures: Executor.submit keyword arguments may not be called 'fn' (or 'self')

2012-09-19 Thread Mark Dickinson
Mark Dickinson added the comment: Ah, I added the wrong Brian to the nosy. Sorry, Brian C. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15966 ___

[issue15971] Sporadic failure in test_dump_tracebacks_later_file (test_faulthandler)

2012-09-19 Thread STINNER Victor
STINNER Victor added the comment: Code of the failing test: import faulthandler import time def func(timeout, repeat, cancel, file, loops): for loop in range(loops): faulthandler.dump_tracebacks_later(timeout, repeat=repeat, file=file) if cancel:

[issue6471] errno and strerror attributes incorrectly set on socket errors wrapped by urllib

2012-09-19 Thread R. David Murray
R. David Murray added the comment: Ah, of course. I should have reread the whole issue :) The backward compatibility is the big concern here. Regardless of what we do about that, we should at least fix this in 3.4. -- ___ Python tracker

[issue15415] Add temp_dir() and change_cwd() to test.support

2012-09-19 Thread Brett Cannon
Changes by Brett Cannon br...@python.org: -- nosy: +brett.cannon ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15415 ___ ___ Python-bugs-list

[issue11664] Add patch method to unittest.TestCase

2012-09-19 Thread Éric Araujo
Éric Araujo added the comment: A data point: at work I follow Pyramid testing guidelines which tell you not to import code under test at module level, but in your test functions, so that if you have an error your tests do start and you see the error under the test method. This means that I

[issue15972] wrong error message for os.path.getsize

2012-09-19 Thread John Taylor
New submission from John Taylor: import os.path a = [ r'c:\Windows\notepad.exe' ] print( os.path.getsize(a) ) Under Python 3.2.3, this error message is returned: File c:\python32\lib\genericpath.py, line 49, in getsize return os.stat(filename).st_size TypeError: Can't convert 'list'

[issue15972] wrong error message for os.path.getsize

2012-09-19 Thread Christian Heimes
Christian Heimes added the comment: Linux: os.stat([]) Traceback (most recent call last): File stdin, line 1, in module FileNotFoundError: [Errno 2] No such file or directory: '' [60996 refs] os.stat([None]) Traceback (most recent call last): File stdin, line 1, in module TypeError: an

[issue15964] SyntaxError in asdl when building 2.7 with system Python 3

2012-09-19 Thread Chris Jerdonek
Chris Jerdonek added the comment: The case that python is a Python 3 binary is not a supported installation Just to clarify, in the original scenario, python did not refer to anything. From the original comment: $ python No such file or directory (python2 and python3 did refer to the

[issue15964] SyntaxError in asdl when building 2.7 with system Python 3

2012-09-19 Thread Christian Heimes
Christian Heimes added the comment: $ make touch make: *** No rule to make target `touch'. Stop. Martin meant: touch Include/Python-ast.h Python/Python-ast.c -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15964

[issue15964] SyntaxError in asdl when building 2.7 with system Python 3

2012-09-19 Thread Chris Jerdonek
Chris Jerdonek added the comment: Yes, that works. Rather than closing this as won't fix, however, I would suggest that we document the workaround in the devguide. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15964

  1   2   >