Help with loading file into an array

2013-05-05 Thread peter berrett
Hi all

I am trying to build a program that can find comets in a series of astronomical 
images. I have already written functions to find the comet in a series of 
images, the data of which is stored in embedded lists.

The area I am having difficulty with is take a standard gif file (1024 x 1024) 
and reading it into an array or embedded lists.

In a nutshell here is an example of what I want to do

Let's say I have a gif file called 20130428__c2_1024.gif in a folder called 
c:\comets

I want to read the data from that gif file taking the red data (excluding the 
green and blue data) and store that in an array called Image[][] which is a 
nested array length 1024 with a list in each item of 1024 length (ie 1024 x 
1024)

Could someone please provide a piece of code to do the above so I can then go 
on to modify it to pick up different files from different folders? In 
particular I am keen to seen how you read in the data and also how you change 
the directory from which you are reading the image.

For the record this is not for homework but is a pet project of mine. I have 
already written a version of the program in Justbasic but python is faster. I 
am also interested in readers views as to which is the simplest and best way to 
achieve what I am trying to do.


Thanks Peter
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help with loading file into an array

2013-05-05 Thread Fábio Santos
Using a nested array should waste a lot of memory. I think you should use
PIL to load and read the image.


 I want to read the data from that gif file taking the red data (excluding
the green and blue data) and store that in an array called Image[][] which
is a nested array length 1024 with a list in each item of 1024 length (ie
1024 x 1024)

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help with loading file into an array

2013-05-05 Thread Colin J. Williams

On 05/05/2013 3:43 AM, Fábio Santos wrote:

Using a nested array should waste a lot of memory. I think you should
use PIL to load and read the image.

 
  I want to read the data from that gif file taking the red data
(excluding the green and blue data) and store that in an array called
Image[][] which is a nested array length 1024 with a list in each item
of 1024 length (ie 1024 x 1024)
 


Fabio,

Have you considered numpy?

Colin W.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Help with loading file into an array

2013-05-05 Thread Jens Thoms Toerring
peter berrett pwberr...@gmail.com wrote:
 I am trying to build a program that can find comets in a series of
 astronomical images. I have already written functions to find the comet in a
 series of images, the data of which is stored in embedded lists.

 The area I am having difficulty with is take a standard gif file (1024 x
 1024) and reading it into an array or embedded lists.

 In a nutshell here is an example of what I want to do

 Let's say I have a gif file called 20130428__c2_1024.gif in a folder
 called c:\comets

 I want to read the data from that gif file taking the red data (excluding
 the green and blue data) and store that in an array called Image[][] which
 is a nested array length 1024 with a list in each item of 1024 length (ie
 1024 x 1024)

 Could someone please provide a piece of code to do the above so I can then
 go on to modify it to pick up different files from different folders? In
 particular I am keen to seen how you read in the data and also how you
 change the directory from which you are reading the image. 

the following should do the trick using, as Fábio already
suggested, the Python Image Library (PIL):

8-
#!/ur/bin/env python

import Image

im = Image.open( 'c:/comets/20130428__c2_1024.gif' )
w, h = im.size
red_arr = [ ]
for y in range( h ) :
red_line = [ ]
for x in range( w ) :
red_line.append( im.getpixel( ( x, y ) )[ 0 ] )
red_arr.append( red_line )
8-

For obvious reasons I couldn't use 'Image' as the name of the list
of lists, so it's 'red_arr' instead. This is probably not the fas-
test solution, but it's simple and hopefully will get you started.

Concerning reading other files: here I may not understand your
problem since it looks rather trivial to me by simply passing
the open() method of 'Image' the name of a file in a different
directory.
 Regards, Jens
-- 
  \   Jens Thoms Toerring  ___  j...@toerring.de
   \__  http://toerring.de
-- 
http://mail.python.org/mailman/listinfo/python-list


Python not starting

2013-05-05 Thread rama29065
I was using python from over an year and half.Suddenly from yesterday i'm 
unable to run it.
The error is as follows
Traceback (most recent call last):
  File C:\Python27\lib\site.py, line 563, in module
main()
  File C:\Python27\lib\site.py, line 546, in main
known_paths = addsitepackages(known_paths)
  File C:\Python27\lib\site.py, line 324, in addsitepackages
if os.path.isdir(sitedir):
  File C:\Python27\lib\genericpath.py, line 44, in isdir
return stat.S_ISDIR(st.st_mode)
AttributeError: 'module' object has no attribute 'S_ISDIR'
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python not starting

2013-05-05 Thread Roy Smith
In article 9ace60b8-a07d-41bc-ac9f-507f6c61f...@googlegroups.com,
 rama29...@gmail.com wrote:

 I was using python from over an year and half.Suddenly from yesterday i'm 
 unable to run it.
 The error is as follows
 Traceback (most recent call last):
   File C:\Python27\lib\site.py, line 563, in module
 main()
   File C:\Python27\lib\site.py, line 546, in main
 known_paths = addsitepackages(known_paths)
   File C:\Python27\lib\site.py, line 324, in addsitepackages
 if os.path.isdir(sitedir):
   File C:\Python27\lib\genericpath.py, line 44, in isdir
 return stat.S_ISDIR(st.st_mode)
 AttributeError: 'module' object has no attribute 'S_ISDIR'

Just a wild guess, but did you happen to create a module of your own 
named stat, which is getting imported instead of the one from the 
library?

Try doing:

 print stat.__file__

and see what it says.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python not starting

2013-05-05 Thread DRJ Reddy
On Sunday, May 5, 2013 7:21:59 PM UTC+5:30, Roy Smith wrote:
 In article 9ace60b8-a07d-41bc-ac9f-507f6c61f...@googlegroups.com,
 
  rama29...@gmail.com wrote:
 
 
 
  I was using python from over an year and half.Suddenly from yesterday i'm 
 
  unable to run it.
 
  The error is as follows
 
  Traceback (most recent call last):
 
File C:\Python27\lib\site.py, line 563, in module
 
  main()
 
File C:\Python27\lib\site.py, line 546, in main
 
  known_paths = addsitepackages(known_paths)
 
File C:\Python27\lib\site.py, line 324, in addsitepackages
 
  if os.path.isdir(sitedir):
 
File C:\Python27\lib\genericpath.py, line 44, in isdir
 
  return stat.S_ISDIR(st.st_mode)
 
  AttributeError: 'module' object has no attribute 'S_ISDIR'
 
 
 
 Just a wild guess, but did you happen to create a module of your own 
 
 named stat, which is getting imported instead of the one from the 
 
 library?
 
 
 
 Try doing:
 
 
 
  print stat.__file__
 
 
 
 and see what it says.

Even from command prompt i can't start python.The error is coming up.Python in 
Windows7 box.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python not starting

2013-05-05 Thread Roy Smith
 On Sunday, May 5, 2013 7:21:59 PM UTC+5:30, Roy Smith wrote:
  In article 9ace60b8-a07d-41bc-ac9f-507f6c61f...@googlegroups.com,

  Just a wild guess, but did you happen to create a module of your own 
  named stat, which is getting imported instead of the one from the 
  library?

In article c7c26e78-b786-4205-9ffa-5eb290064...@googlegroups.com,
 DRJ Reddy rama29...@gmail.com wrote:
 Even from command prompt i can't start python.The error is coming up.Python 
 in Windows7 box.

I don't know Windows, but my guess is still that it's finding some other 
file called stat.py before it's finding the system library one.  Try 
doing a file system search for all files named stat.py and see what 
you find.  On unix, I would do find / -name stat.py.  I assume there's 
something similar on Windows.

The other thing I would try is tracing the python process as it starts 
up.  On unix, I would do something like strace -e trace=file python 
and see if it's finding a stat.py in some unexpected place.  Again, I 
can only assume there's something similar on Windows.

Oh, and please don't post with Google Groups.  It double-spaces 
everything and makes your message really difficult to read.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python not starting

2013-05-05 Thread Mark Lawrence

On 05/05/2013 15:00, DRJ Reddy wrote:

On Sunday, May 5, 2013 7:21:59 PM UTC+5:30, Roy Smith wrote:

In article 9ace60b8-a07d-41bc-ac9f-507f6c61f...@googlegroups.com,

  rama29...@gmail.com wrote:


I was using python from over an year and half.Suddenly from yesterday i'm
unable to run it.
The error is as follows



Traceback (most recent call last):
   File C:\Python27\lib\site.py, line 563, in module
 main()
   File C:\Python27\lib\site.py, line 546, in main
 known_paths = addsitepackages(known_paths)
   File C:\Python27\lib\site.py, line 324, in addsitepackages
 if os.path.isdir(sitedir):
   File C:\Python27\lib\genericpath.py, line 44, in isdir
 return stat.S_ISDIR(st.st_mode)
AttributeError: 'module' object has no attribute 'S_ISDIR'


Just a wild guess, but did you happen to create a module of your own
named stat, which is getting imported instead of the one from the
library?

Try doing:

print stat.__file__


and see what it says.


Even from command prompt i can't start python.The error is coming up.Python in 
Windows7 box.



Place the call to print stat.__file__ in the file genericpath.py 
immediately before the line that gives the attribute error.


Would you also be kind enough to read and use the guidance given in the 
link in my signature.  My eyesight is bad enough without parsing double 
spaced stuff courtesy of google groups, thanks.


--
If you're using GoogleCrap™ please read this 
http://wiki.python.org/moin/GoogleGroupsPython.


Mark Lawrence

--
http://mail.python.org/mailman/listinfo/python-list


Re: Python not starting

2013-05-05 Thread DRJ Reddy
On Sunday, May 5, 2013 7:46:48 PM UTC+5:30, Roy Smith wrote:
  On Sunday, May 5, 2013 7:21:59 PM UTC+5:30, Roy Smith wrote:
 
   In article 9ace60b8-a07d-41bc-ac9f-507f6c61f...@googlegroups.com,
 
 
 
   Just a wild guess, but did you happen to create a module of your own 
 
   named stat, which is getting imported instead of the one from the 
 
   library?
 
 
 
 In article c7c26e78-b786-4205-9ffa-5eb290064...@googlegroups.com,
 
  DRJ Reddy rama29...@gmail.com wrote:
 
  Even from command prompt i can't start python.The error is coming up.Python 
 
  in Windows7 box.
 
 
 
 I don't know Windows, but my guess is still that it's finding some other 
 
 file called stat.py before it's finding the system library one.  Try 
 
 doing a file system search for all files named stat.py and see what 
 
 you find.  On unix, I would do find / -name stat.py.  I assume there's 
 
 something similar on Windows.
 
 
 
 The other thing I would try is tracing the python process as it starts 
 
 up.  On unix, I would do something like strace -e trace=file python 
 
 and see if it's finding a stat.py in some unexpected place.  Again, I 
 
 can only assume there's something similar on Windows.
 
 
 
 Oh, and please don't post with Google Groups.  It double-spaces 
 
 everything and makes your message really difficult to read.

I found a stat.py in python27/idlelib i haven't created one.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python not starting

2013-05-05 Thread DRJ Reddy
On Sunday, May 5, 2013 7:56:58 PM UTC+5:30, Mark Lawrence wrote:
 On 05/05/2013 15:00, DRJ Reddy wrote:
 
  On Sunday, May 5, 2013 7:21:59 PM UTC+5:30, Roy Smith wrote:
 
  In article 9ace60b8-a07d-41bc-ac9f-507f6c61f...@googlegroups.com,
 
 
 
rama29...@gmail.com wrote:
 
 
 
  I was using python from over an year and half.Suddenly from yesterday i'm
 
  unable to run it.
 
  The error is as follows
 
 
 
  Traceback (most recent call last):
 
 File C:\Python27\lib\site.py, line 563, in module
 
   main()
 
 File C:\Python27\lib\site.py, line 546, in main
 
   known_paths = addsitepackages(known_paths)
 
 File C:\Python27\lib\site.py, line 324, in addsitepackages
 
   if os.path.isdir(sitedir):
 
 File C:\Python27\lib\genericpath.py, line 44, in isdir
 
   return stat.S_ISDIR(st.st_mode)
 
  AttributeError: 'module' object has no attribute 'S_ISDIR'
 
 
 
  Just a wild guess, but did you happen to create a module of your own
 
  named stat, which is getting imported instead of the one from the
 
  library?
 
 
 
  Try doing:
 
  print stat.__file__
 
 
 
  and see what it says.
 
 
 
  Even from command prompt i can't start python.The error is coming up.Python 
  in Windows7 box.
 
 
 
 
 
 Place the call to print stat.__file__ in the file genericpath.py 
 
 immediately before the line that gives the attribute error.
 
 
 
 Would you also be kind enough to read and use the guidance given in the 
 
 link in my signature.  My eyesight is bad enough without parsing double 
 
 spaced stuff courtesy of google groups, thanks.
 
 
 
 -- 
 
 If you're using GoogleCrap� please read this 
 
 http://wiki.python.org/moin/GoogleGroupsPython.
 
 
 
 Mark Lawrence

Sorry for double spaced stuff,how can i get rid of it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python not starting

2013-05-05 Thread Chris Angelico
On Mon, May 6, 2013 at 12:16 AM, Roy Smith r...@panix.com wrote:
 In article c7c26e78-b786-4205-9ffa-5eb290064...@googlegroups.com,
  DRJ Reddy rama29...@gmail.com wrote:
 Even from command prompt i can't start python.The error is coming up.Python
 in Windows7 box.

 I don't know Windows, but my guess is still that it's finding some other
 file called stat.py before it's finding the system library one.  Try
 doing a file system search for all files named stat.py and see what
 you find.  On unix, I would do find / -name stat.py.  I assume there's
 something similar on Windows.

Or alternatively, disable site.py by invoking python -S, and then
manually import stat and see what its file is.

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python not starting

2013-05-05 Thread DRJ Reddy
On Sunday, May 5, 2013 8:30:59 PM UTC+5:30, Chris Angelico wrote:
 On Mon, May 6, 2013 at 12:16 AM, Roy Smith r...@panix.com wrote:
 
  In article c7c26e78-b786-4205-9ffa-5eb290064...@googlegroups.com,
 
   DRJ Reddy rama29...@gmail.com wrote:
 
  Even from command prompt i can't start python.The error is coming up.Python
 
  in Windows7 box.
 
 
 
  I don't know Windows, but my guess is still that it's finding some other
 
  file called stat.py before it's finding the system library one.  Try
 
  doing a file system search for all files named stat.py and see what
 
  you find.  On unix, I would do find / -name stat.py.  I assume there's
 
  something similar on Windows.
 
 
 
 Or alternatively, disable site.py by invoking python -S, and then
 
 manually import stat and see what its file is.
 
 
 
 ChrisA

Thanks all of you,i have done it,by disabling,but what is the permanent 
solution.How can i start python idle 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python not starting

2013-05-05 Thread Chris Angelico
On Mon, May 6, 2013 at 1:11 AM, DRJ Reddy rama29...@gmail.com wrote:
 On Sunday, May 5, 2013 8:30:59 PM UTC+5:30, Chris Angelico wrote:
 On Mon, May 6, 2013 at 12:16 AM, Roy Smith r...@panix.com wrote:

  In article c7c26e78-b786-4205-9ffa-5eb290064...@googlegroups.com,

   DRJ Reddy rama29...@gmail.com wrote:

  Even from command prompt i can't start python.The error is coming 
  up.Python

  in Windows7 box.

 

  I don't know Windows, but my guess is still that it's finding some other

  file called stat.py before it's finding the system library one.  Try

  doing a file system search for all files named stat.py and see what

  you find.  On unix, I would do find / -name stat.py.  I assume there's

  something similar on Windows.



 Or alternatively, disable site.py by invoking python -S, and then

 manually import stat and see what its file is.



 ChrisA

 Thanks all of you,i have done it,by disabling,but what is the permanent 
 solution.How can i start python idle

Here's the steps:

1) Start Python with the -S option. You have apparently figured this
part out. This should give you a working interactive Python.

2) Type:
import stat
stat.__file__

3) See what the file is that was named there. If you created it, you
now know the problem.

4) Read Mark Lawrence's signature.

This post adds nothing to what has already been said; it's just
coalescing the previously-given advice into exact steps.

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


How to avoid PEP8 'imported but unused'

2013-05-05 Thread Adam Jiang
I am new to python. Now, I am woring on an application within Django
framework. When I checked my code with pep8 and pyflakes, some warning
messages show up-'Foobar imported but unused'. Obviously, it indicates
that some modules are imprted to current module but never get
references. However, it seems the message is wrong in this case:

# file: urls.py
urlpattens = patterns(
'',
url('^signup/$', 'signup')
}

# file: register.py
def signup(request):
return ...

# file: views.py
import signup from register

The warning message is shown in file views.py. It seems to me that the
code is okay because Django requires all functions serve as 'view' is
typically go into views.py. 'import' is about get 'signup' function
into module 'views.py'. Or, I am totally wrong? Is there a proper way
to avoid this warnning?

Best regards,
/Adam
-- 
http://mail.python.org/mailman/listinfo/python-list


learning python

2013-05-05 Thread leonardo selmi
hi guys

i need to find a good book to learn python with exercises and solutions, any 
suggestions?

thanks!

best regards

leonardo-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to avoid PEP8 'imported but unused'

2013-05-05 Thread Fábio Santos
I usually do this on pyflakes:

import whatever
assert whatever  # silence pyflakes

Pyflakes and pep8 have no way of knowing django will import and use your
module, or whether you are just importing a module for the side effects, so
they issue a warning anyway. Assert'ing counts as using the module, so it
counts as an used import.

On 5 May 2013 17:05, Adam Jiang jiang.a...@gmail.com wrote:

 I am new to python. Now, I am woring on an application within Django
 framework. When I checked my code with pep8 and pyflakes, some warning
 messages show up-'Foobar imported but unused'. Obviously, it indicates
 that some modules are imprted to current module but never get
 references. However, it seems the message is wrong in this case:

 # file: urls.py
 urlpattens = patterns(
 '',
 url('^signup/$', 'signup')
 }

 # file: register.py
 def signup(request):
 return ...

 # file: views.py
 import signup from register

 The warning message is shown in file views.py. It seems to me that the
 code is okay because Django requires all functions serve as 'view' is
 typically go into views.py. 'import' is about get 'signup' function
 into module 'views.py'. Or, I am totally wrong? Is there a proper way
 to avoid this warnning?

 Best regards,
 /Adam
 --
 http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to avoid PEP8 'imported but unused'

2013-05-05 Thread MRAB

On 05/05/2013 17:00, Adam Jiang wrote:

I am new to python. Now, I am woring on an application within Django
framework. When I checked my code with pep8 and pyflakes, some warning
messages show up-'Foobar imported but unused'. Obviously, it indicates
that some modules are imprted to current module but never get
references. However, it seems the message is wrong in this case:

# file: urls.py
urlpattens = patterns(
 '',
 url('^signup/$', 'signup')
}

# file: register.py
def signup(request):
 return ...

# file: views.py
import signup from register

The warning message is shown in file views.py. It seems to me that the
code is okay because Django requires all functions serve as 'view' is
typically go into views.py. 'import' is about get 'signup' function
into module 'views.py'. Or, I am totally wrong? Is there a proper way
to avoid this warnning?


It's not:

import signup from register

(that's an error) but:

from register import signup

After fixing that, does it still show the warning?

--
http://mail.python.org/mailman/listinfo/python-list


Re: Python not starting

2013-05-05 Thread DRJ Reddy
Chris i have seen stat.__file__. It gives me 'C:\\Python27\\lib\\stat.pyc'. 
What should i do now.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: learning python

2013-05-05 Thread DRJ Reddy
A byte of python with learning python by Mark Lutz is a good combination.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to avoid PEP8 'imported but unused'

2013-05-05 Thread Peter Otten
Adam Jiang wrote:

 I am new to python. Now, I am woring on an application within Django
 framework. When I checked my code with pep8 and pyflakes, some warning
 messages show up-'Foobar imported but unused'. Obviously, it indicates
 that some modules are imprted to current module but never get
 references. However, it seems the message is wrong in this case:
 
 # file: urls.py
 urlpattens = patterns(
 '',
 url('^signup/$', 'signup')
 }
 
 # file: register.py
 def signup(request):
 return ...
 
 # file: views.py
 import signup from register
 
 The warning message is shown in file views.py. It seems to me that the
 code is okay because Django requires all functions serve as 'view' is
 typically go into views.py. 'import' is about get 'signup' function
 into module 'views.py'. Or, I am totally wrong? Is there a proper way
 to avoid this warnning?

pylint has a way to suppress such warnings with a comment like

from signup import register # pylint:disable=W0611

but personally I find the magic comment more annoying than the false 
warning...

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to avoid PEP8 'imported but unused'

2013-05-05 Thread Adam Jiang
Thanks. It works very well.

One more question. In this particular case it seems 'assert' should be
safe as a workaround, doesn't it?  'assert' will check if the symbol
is imported and not NULL. Is there side effect if I just applied this
rule as a generic one.

/Adam
On Sun, May 05, 2013 at 05:18:40PM +0100, Fábio Santos wrote:
 I usually do this on pyflakes:
 
 import whatever
 assert whatever  # silence pyflakes
 
 Pyflakes and pep8 have no way of knowing django will import and use your
 module, or whether you are just importing a module for the side effects, so
 they issue a warning anyway. Assert'ing counts as using the module, so it
 counts as an used import.
 
 On 5 May 2013 17:05, Adam Jiang jiang.a...@gmail.com wrote:
 
  I am new to python. Now, I am woring on an application within Django
  framework. When I checked my code with pep8 and pyflakes, some warning
  messages show up-'Foobar imported but unused'. Obviously, it indicates
  that some modules are imprted to current module but never get
  references. However, it seems the message is wrong in this case:
 
  # file: urls.py
  urlpattens = patterns(
      '',
      url('^signup/$', 'signup')
  }
 
  # file: register.py
  def signup(request):
      return ...
 
  # file: views.py
  import signup from register
 
  The warning message is shown in file views.py. It seems to me that the
  code is okay because Django requires all functions serve as 'view' is
  typically go into views.py. 'import' is about get 'signup' function
  into module 'views.py'. Or, I am totally wrong? Is there a proper way
  to avoid this warnning?
 
  Best regards,
  /Adam
  --
  http://mail.python.org/mailman/listinfo/python-list
 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Python-Help] learning python

2013-05-05 Thread Eric Brunson

On 05/05/2013 10:08 AM, leonardo selmi wrote:

hi guys

i need to find a good book to learn python with exercises and 
solutions, any suggestions?


thanks!



Leonardo,

There are several good online tutorials available, many listed here:  
http://wiki.python.org/moin/BeginnersGuide


There is also the Python Tutorial written by the creator of Python 
here:  http://docs.python.org/2/tutorial/index.html


If you want a hands on approach with exercises, try Learn Python the 
Hard Way:  http://learnpythonthehardway.org/


If you already have a background in programming I find Dive Into Python 
to be an excellent introduction: http://www.diveintopython.net/ as well 
as Think Python: How to Think Like a Computer Scientist: 
http://www.greenteapress.com/thinkpython/html/


If you want something you can hold in your hand and has paper pages, I 
can recommend Learning Python by Mark Lutz: 
http://shop.oreilly.com/product/9780596158071.do followed by The Python 
Cookbook, by Alex Martelli and David Ascher: 
http://shop.oreilly.com/product/9780596001674.do


The Massachusetts Institute of Technology uses Python to teach their 
introduction to programming course which is available online (free) 
here: 
http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-00sc-introduction-to-computer-science-and-programming-spring-2011/index.htm


I hope that helps.

Sincerely,
e.


-- 
http://mail.python.org/mailman/listinfo/python-list


Why do Perl programmers make more money than Python programmers

2013-05-05 Thread Ignoramus16992
According to CIO.com, Python programmers make only $83,000 per year,
while Perl programmers make $93,000 per year. 

http://www.cio.com/slideshow/detail/97819?source=ifwartcio#slide10
http://www.cio.com/slideshow/detail/97819?source=ifwartcio#slide11

I would like to know, what explains the discrepancy. 

Thank you!

i
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why do Perl programmers make more money than Python programmers

2013-05-05 Thread Stephan Vladimir Bugaj
Most likely more legacy Perl code in mission critical systems

S

Sent from my pocket UNIVAC.

On May 5, 2013, at 10:11 AM, Ignoramus16992 
ignoramus16992@NOSPAM.16992.invalid wrote:

 According to CIO.com, Python programmers make only $83,000 per year,
 while Perl programmers make $93,000 per year. 
 
 http://www.cio.com/slideshow/detail/97819?source=ifwartcio#slide10
 http://www.cio.com/slideshow/detail/97819?source=ifwartcio#slide11
 
 I would like to know, what explains the discrepancy. 
 
 Thank you!
 
 i
 -- 
 http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why do Perl programmers make more money than Python programmers

2013-05-05 Thread Fábio Santos
I wouldn't touch perl code with a ten foot pole.

On the other hand, python is pleasing to the eye and easy to write,
read and modify.

This means that you can easily be replaced with someone else who also
knows python, so your company doesn't care much about paying you well
and keeping you there.

On Sun, May 5, 2013 at 6:11 PM, Ignoramus16992
ignoramus16992@nospam.16992.invalid wrote:
 According to CIO.com, Python programmers make only $83,000 per year,
 while Perl programmers make $93,000 per year.

 http://www.cio.com/slideshow/detail/97819?source=ifwartcio#slide10
 http://www.cio.com/slideshow/detail/97819?source=ifwartcio#slide11

 I would like to know, what explains the discrepancy.

 Thank you!

 i
 --
 http://mail.python.org/mailman/listinfo/python-list



-- 
Fábio Santos
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to avoid PEP8 'imported but unused'

2013-05-05 Thread Fábio Santos
That assert will never fail. If the symbol is not imported, the import
statement raises ImportError. And actually assert makes sure that
the value is not false-ish, not None/Null. And AFAIK a module object
is *always* true.

 One more question. In this particular case it seems 'assert' should be
 safe as a workaround, doesn't it?  'assert' will check if the symbol
 is imported and not NULL. Is there side effect if I just applied this
 rule as a generic one.


--
Fábio Santos
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why do Perl programmers make more money than Python programmers

2013-05-05 Thread Stephan Vladimir Bugaj
And seniority combined with annual cost of living raises, due to Perl being in 
use longer

S

Sent from my pocket UNIVAC.

On May 5, 2013, at 10:11 AM, Ignoramus16992 
ignoramus16992@NOSPAM.16992.invalid wrote:

 According to CIO.com, Python programmers make only $83,000 per year,
 while Perl programmers make $93,000 per year. 
 
 http://www.cio.com/slideshow/detail/97819?source=ifwartcio#slide10
 http://www.cio.com/slideshow/detail/97819?source=ifwartcio#slide11
 
 I would like to know, what explains the discrepancy. 
 
 Thank you!
 
 i
 -- 
 http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why do Perl programmers make more money than Python programmers

2013-05-05 Thread Chris Angelico
On Mon, May 6, 2013 at 3:11 AM, Ignoramus16992
ignoramus16992@nospam.16992.invalid wrote:
 According to CIO.com, Python programmers make only $83,000 per year,
 while Perl programmers make $93,000 per year.

 http://www.cio.com/slideshow/detail/97819?source=ifwartcio#slide10
 http://www.cio.com/slideshow/detail/97819?source=ifwartcio#slide11

 I would like to know, what explains the discrepancy.

 Thank you!

Once, I was young and foolish too, and an ignoramus, just like you. [1]

There's a big problem with comparing statistical averages without any
indication of their spread. Suppose these are the salaries involved:

Perl = [15000, 3, 8, 10, 143000, 19]
Python = [15000, 3, 8, 10, 19]

That is, the guy who's making 143K a year didn't mention that he's
using Python. Voila! Your averages differ, yet statistically, there's
not a lot of difference. The best way to know how useful the averages
are is to look at the distribution, eg look at the difference between
the highest and lowest values, or the standard deviation of the
sample, or something of that sort. Without that, there's no way of
knowing whether a 10K difference is at all significant. I would posit
that, among salaries, it's meaningless.

ChrisA

[1] I don't know if you're trolling or not, so I'll give a serious
response. But I'm going to start with a quote from Emerald Isle.
http://diamond.boisestate.edu/gas/sullivan/emerald_isle/web_opera/ei14.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why do Perl programmers make more money than Python programmers

2013-05-05 Thread rusi
On May 5, 10:11 pm, Ignoramus16992 ignoramus16...@NOSPAM.
16992.invalid wrote:
 According to CIO.com, Python programmers make only $83,000 per year,
 while Perl programmers make $93,000 per year.

 http://www.cio.com/slideshow/detail/97819?source=ifwartcio#slide10http://www.cio.com/slideshow/detail/97819?source=ifwartcio#slide11

 I would like to know, what explains the discrepancy.

 Thank you!

 i

I expect Cobol programmers earn more than either
Its called supply and demand
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python not starting

2013-05-05 Thread Roy Smith
In article 9d2513ed-2738-4b6f-92af-82c1faa54...@googlegroups.com,
 DRJ Reddy rama29...@gmail.com wrote:

  If you're using GoogleCrap� please read this 
  
  http://wiki.python.org/moin/GoogleGroupsPython.
  
  
  
  Mark Lawrence
 
 Sorry for double spaced stuff,how can i get rid of it.

I don't mean to be disrespectful, but did you actually read the page you 
were asked to read?  It says, about halfway down the page, You should 
remove the excess quoted blank lines before posting. There are several 
way to do this., and then goes on to describe three different ways.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why do Perl programmers make more money than Python programmers

2013-05-05 Thread Fábio Santos
 Most likely more legacy Perl code in mission critical systems

Which is unfair because when Python is ever surpassed by an even
better language/technology then we get paid more to work Python and
not move the industry forward by moving to the new technology and
hacking on it.

--
Fábio Santos
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why do Perl programmers make more money than Python programmers

2013-05-05 Thread Roy Smith
In article zrodnzu2u6sydxvmnz2dnuvz_v2dn...@giganews.com,
 Ignoramus16992 ignoramus16992@NOSPAM.16992.invalid wrote:

 According to CIO.com, Python programmers make only $83,000 per year,
 while Perl programmers make $93,000 per year. 

It's amazing the depths to which people are willing to sink for an extra 
$10k per year.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Python-Help] learning python

2013-05-05 Thread leonardo selmi
thanks!



Il giorno 05/mag/2013, alle ore 18:58, Eric Brunson brun...@brunson.com ha 
scritto:

 On 05/05/2013 10:08 AM, leonardo selmi wrote:
 hi guys
 
 i need to find a good book to learn python with exercises and solutions, any 
 suggestions?
 
 thanks!
 
 
 Leonardo,
 
 There are several good online tutorials available, many listed here:  
 http://wiki.python.org/moin/BeginnersGuide
 
 There is also the Python Tutorial written by the creator of Python here:  
 http://docs.python.org/2/tutorial/index.html
 
 If you want a hands on approach with exercises, try Learn Python the Hard 
 Way:  http://learnpythonthehardway.org/
 
 If you already have a background in programming I find Dive Into Python to be 
 an excellent introduction:  http://www.diveintopython.net/ as well as Think 
 Python: How to Think Like a Computer Scientist:  
 http://www.greenteapress.com/thinkpython/html/
 
 If you want something you can hold in your hand and has paper pages, I can 
 recommend Learning Python by Mark Lutz:  
 http://shop.oreilly.com/product/9780596158071.do followed by The Python 
 Cookbook, by Alex Martelli and David Ascher:  
 http://shop.oreilly.com/product/9780596001674.do
 
 The Massachusetts Institute of Technology uses Python to teach their 
 introduction to programming course which is available online (free) here:  
 http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-00sc-introduction-to-computer-science-and-programming-spring-2011/index.htm
 
 I hope that helps.
 
 Sincerely,
 e.
 
 

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python not starting

2013-05-05 Thread DRJ Reddy
I did read and understood that while replying if  is there we will get a blank 
line unnecessarily.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why do Perl programmers make more money than Python programmers

2013-05-05 Thread Mark Lawrence

On 05/05/2013 18:35, rusi wrote:

On May 5, 10:11 pm, Ignoramus16992 ignoramus16...@NOSPAM.
16992.invalid wrote:

According to CIO.com, Python programmers make only $83,000 per year,
while Perl programmers make $93,000 per year.

http://www.cio.com/slideshow/detail/97819?source=ifwartcio#slide10http://www.cio.com/slideshow/detail/97819?source=ifwartcio#slide11

I would like to know, what explains the discrepancy.

Thank you!

i


I expect Cobol programmers earn more than either
Its called supply and demand



They might get paid more, whether or not they earn it is an entirely 
different question.


--
If you're using GoogleCrap™ please read this 
http://wiki.python.org/moin/GoogleGroupsPython.


Mark Lawrence

--
http://mail.python.org/mailman/listinfo/python-list


Re: Python not starting

2013-05-05 Thread Steven D'Aprano
On Sun, 05 May 2013 06:43:25 -0700, rama29065 wrote:

 I was using python from over an year and half.Suddenly from yesterday
 i'm unable to run it. 

Well, the obvious question is, what did you do yesterday to change your 
system? Did you install any new packages? Run a Windows update? Delete 
some stuff? Something changed. What was it?


 The error is as follows

 Traceback (most recent call last):
   File C:\Python27\lib\site.py, line 563, in module
 main()
   File C:\Python27\lib\site.py, line 546, in main
 known_paths = addsitepackages(known_paths)
   File C:\Python27\lib\site.py, line 324, in addsitepackages
 if os.path.isdir(sitedir):
   File C:\Python27\lib\genericpath.py, line 44, in isdir
 return stat.S_ISDIR(st.st_mode)
 AttributeError: 'module' object has no attribute 'S_ISDIR'


This is a Python error, so Python is definitely starting. It's starting, 
hitting an error, and then failing with an exception.

Interestingly, the error is in os.path.isdir. The os module should be 
importing the ntpath module. The ntpath module tries to import _isdir 
from the nt module, and if that fails, falls back on genericpath.isdir. 
Which is what fails. So you have two problems:

- why is your nt module missing?

- why does genericpath.isdir fail?


Try running Python from the command line with the -S switch:


python -S


(you might need to use /S on Windows instead, I'm not sure.) Note that 
this is uppercase S, not lowercase. -S will disable the import of site.py 
module, which hopefully will then give you a prompt so you can run this:


import nt
print nt.__file__


which hopefully will show you have created a file called nt.py which is 
interfering with the actual nt file needed by Python. Get rid of that, 
and you should be right.



-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why do Perl programmers make more money than Python programmers

2013-05-05 Thread Steven D'Aprano
On Sun, 05 May 2013 12:11:11 -0500, Ignoramus16992 wrote:

 According to CIO.com, Python programmers make only $83,000 per year,
 while Perl programmers make $93,000 per year.
 
 http://www.cio.com/slideshow/detail/97819?source=ifwartcio#slide10
 http://www.cio.com/slideshow/detail/97819?source=ifwartcio#slide11
 
 I would like to know, what explains the discrepancy.

Perl is much harder to use, so the average Perl programmer burns out 
after a few years and takes up a less stressful career, like going 
undercover in the Russian mob or the Taliban. So only the most dedicated, 
brilliant and extreme programmers last long enough to become a Perl 
expert, and consequently can demand higher pay, while any idiot can learn 
to program Python, as I have.

Also, Perl programmers are an unprincipled, devious bunch, always looking 
for an opportunity to blackmail their employers into paying them extra. 
Python programmers are a decent, law-abiding people with a strong moral 
code who would never stoop to the sort of things that Perl coders are 
proud of doing.



-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why do Perl programmers make more money than Python programmers

2013-05-05 Thread Steven D'Aprano
On Sun, 05 May 2013 13:58:51 -0400, Roy Smith wrote:

 In article zrodnzu2u6sydxvmnz2dnuvz_v2dn...@giganews.com,
  Ignoramus16992 ignoramus16992@NOSPAM.16992.invalid wrote:
 
 According to CIO.com, Python programmers make only $83,000 per year,
 while Perl programmers make $93,000 per year.
 
 It's amazing the depths to which people are willing to sink for an extra
 $10k per year.

Right now, I'd consider learning PHP for an extra $100 a month. Or 
peddling my arse down at the docks for twenty cents a time, which will be 
less embarrassing and much less painful.


-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why do Perl programmers make more money than Python programmers

2013-05-05 Thread Jens Thoms Toerring
In comp.lang.python Steven D'Aprano steve+comp.lang.pyt...@pearwood.info 
wrote:
 On Sun, 05 May 2013 12:11:11 -0500, Ignoramus16992 wrote:

  According to CIO.com, Python programmers make only $83,000 per year,
  while Perl programmers make $93,000 per year.
  
  http://www.cio.com/slideshow/detail/97819?source=ifwartcio#slide10
  http://www.cio.com/slideshow/detail/97819?source=ifwartcio#slide11
  
  I would like to know, what explains the discrepancy.

 Perl is much harder to use, so the average Perl programmer burns out 
 after a few years and takes up a less stressful career, like going 
 undercover in the Russian mob or the Taliban. So only the most dedicated, 
 brilliant and extreme programmers last long enough to become a Perl 
 expert, and consequently can demand higher pay, while any idiot can learn 
 to program Python, as I have.

 Also, Perl programmers are an unprincipled, devious bunch, always looking 
 for an opportunity to blackmail their employers into paying them extra. 
 Python programmers are a decent, law-abiding people with a strong moral 
 code who would never stoop to the sort of things that Perl coders are 
 proud of doing.

Now you got me badly worried, using both Perl and Python (and
other, unspeakable languages, but not VB I promise!) Will I
end up as a Python hacker for the mob or worse - or is there
a chance of redemption (perhaps after a few years in Guanta-
namo bay)? And should I, while it lasts, get the Perl or the
Python salary, or the mean or both combined? Got to consider
that when applying for my next job!

 Regards, Jens
-- 
  \   Jens Thoms Toerring  ___  j...@toerring.de
   \__  http://toerring.de
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why do Perl programmers make more money than Python programmers

2013-05-05 Thread Petite Abeille

On May 5, 2013, at 9:13 PM, Steven D'Aprano 
steve+comp.lang.pyt...@pearwood.info wrote:

 On Sun, 05 May 2013 13:58:51 -0400, Roy Smith wrote:
 
 In article zrodnzu2u6sydxvmnz2dnuvz_v2dn...@giganews.com,
 Ignoramus16992 ignoramus16992@NOSPAM.16992.invalid wrote:
 
 According to CIO.com, Python programmers make only $83,000 per year,
 while Perl programmers make $93,000 per year.
 
 It's amazing the depths to which people are willing to sink for an extra
 $10k per year.
 
 Right now, I'd consider learning PHP for an extra $100 a month. Or 
 peddling my arse down at the docks for twenty cents a time, which will be 
 less embarrassing and much less painful.

I, for one, I'm glad to let the Pythonistas take the high road, while other, 
more, err, pragmatic types, take the dough. ching ching.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why do Perl programmers make more money than Python programmers

2013-05-05 Thread Rainer Weikusat
j...@toerring.de (Jens Thoms Toerring) writes:
 In comp.lang.python Steven D'Aprano steve+comp.lang.pyt...@pearwood.info 
 wrote:
 On Sun, 05 May 2013 12:11:11 -0500, Ignoramus16992 wrote:

  According to CIO.com, Python programmers make only $83,000 per year,
  while Perl programmers make $93,000 per year.
  
  http://www.cio.com/slideshow/detail/97819?source=ifwartcio#slide10
  http://www.cio.com/slideshow/detail/97819?source=ifwartcio#slide11
  
  I would like to know, what explains the discrepancy.

 Perl is much harder to use, so the average Perl programmer burns out 
 after a few years and takes up a less stressful career, like going 
 undercover in the Russian mob or the Taliban. So only the most dedicated, 
 brilliant and extreme programmers last long enough to become a Perl 
 expert, and consequently can demand higher pay, while any idiot can learn 
 to program Python, as I have.

 Also, Perl programmers are an unprincipled, devious bunch, always looking 
 for an opportunity to blackmail their employers into paying them extra. 
 Python programmers are a decent, law-abiding people with a strong moral 
 code who would never stoop to the sort of things that Perl coders are 
 proud of doing.

 Now you got me badly worried, using both Perl and Python (and
 other, unspeakable languages, but not VB I promise!) Will I
 end up as a Python hacker for the mob or worse

https://en.wikipedia.org/wiki/Strange_Case_of_Dr_Jekyll_and_Mr_Hyde

[SCNR]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why do Perl programmers make more money than Python programmers

2013-05-05 Thread Roy Smith
In article 5186af75$0$29997$c3e8da3$54964...@news.astraweb.com,
 Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote:
 
 Right now, I'd consider learning PHP for an extra $100 a month. Or 
 peddling my arse down at the docks for twenty cents a time, which will be 
 less embarrassing and much less painful.

Having spent the better part of a year doing one of those activities, 
I'm inclined to agree.

There *are* programming languages worse than PHP.  Have you ever tried 
britescript?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why do Perl programmers make more money than Python programmers

2013-05-05 Thread Paul Rubin
Ignoramus16992 ignoramus16992@NOSPAM.16992.invalid writes:
 I would like to know, what explains the discrepancy. 

I see New York listed as a location for Perl but not for Python.  That
implies: 1) some general skew because of the very high cost of living in
NY (even compared to San Francisco or Silicon Valley); 2) further skew
because a good chuck of the NY programming jobs are in the financial
sector, which shovels money around with heavy farm equipment (but is
reportedly otherwise unpleasant to work in).  Wall Street has done very
well in the past few years, and some of that shows up as bonuses for the
involved parties.

I remember seeing a ridiculously high figure listed for Haskell, and
then realized the reason for it was similar to the above.  Most Haskell
programmers I know can't actually get Haskell jobs.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why do Perl programmers make more money than Python programmers

2013-05-05 Thread Paul Rubin
Paul Rubin no.email@nospam.invalid writes:
 I see New York listed as a location for Perl but not for Python.

Whaat?  It's there for Python, though in the #3 position rather than #2.
I must have flipped through the slides too fast.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why do Perl programmers make more money than Python programmers

2013-05-05 Thread Jens Thoms Toerring
In comp.lang.python Rainer Weikusat rweiku...@mssgmbh.com wrote:
 j...@toerring.de (Jens Thoms Toerring) writes:
  In comp.lang.python Steven D'Aprano steve+comp.lang.pyt...@pearwood.info 
  wrote:
  On Sun, 05 May 2013 12:11:11 -0500, Ignoramus16992 wrote:
 
   According to CIO.com, Python programmers make only $83,000 per year,
   while Perl programmers make $93,000 per year.
   
   http://www.cio.com/slideshow/detail/97819?source=ifwartcio#slide10
   http://www.cio.com/slideshow/detail/97819?source=ifwartcio#slide11
   
   I would like to know, what explains the discrepancy.
 
  Perl is much harder to use, so the average Perl programmer burns out 
  after a few years and takes up a less stressful career, like going 
  undercover in the Russian mob or the Taliban. So only the most dedicated, 
  brilliant and extreme programmers last long enough to become a Perl 
  expert, and consequently can demand higher pay, while any idiot can learn 
  to program Python, as I have.
 
  Also, Perl programmers are an unprincipled, devious bunch, always looking 
  for an opportunity to blackmail their employers into paying them extra. 
  Python programmers are a decent, law-abiding people with a strong moral 
  code who would never stoop to the sort of things that Perl coders are 
  proud of doing.
 
  Now you got me badly worried, using both Perl and Python (and
  other, unspeakable languages, but not VB I promise!) Will I
  end up as a Python hacker for the mob or worse

 https://en.wikipedia.org/wiki/Strange_Case_of_Dr_Jekyll_and_Mr_Hyde

 [SCNR]

Well, that didn't have a happy ending:-( Should have listened to
my parents when they told me again and again Never use Perl, just
say no!. Seems I'm doomed - what's the proper way to apply for a
job with the mob?

-- 
  \   Jens Thoms Toerring  ___  j...@toerring.de
   \__  http://toerring.de
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why do Perl programmers make more money than Python programmers

2013-05-05 Thread 88888 Dihedral
Steven D'Aprano於 2013年5月6日星期一UTC+8上午3時10分47秒寫道:
 On Sun, 05 May 2013 12:11:11 -0500, Ignoramus16992 wrote:
 
 
 
  According to CIO.com, Python programmers make only $83,000 per year,
 
  while Perl programmers make $93,000 per year.
 
  
 
  http://www.cio.com/slideshow/detail/97819?source=ifwartcio#slide10
 
  http://www.cio.com/slideshow/detail/97819?source=ifwartcio#slide11
 
  
 
  I would like to know, what explains the discrepancy.
 
 
 
 Perl is much harder to use, so the average Perl programmer burns out 
 
 after a few years and takes up a less stressful career, like going 
 
 undercover in the Russian mob or the Taliban. So only the most dedicated, 
 
 brilliant and extreme programmers last long enough to become a Perl 
 
 expert, and consequently can demand higher pay, while any idiot can learn 
 
 to program Python, as I have.
 
 
 
 Also, Perl programmers are an unprincipled, devious bunch, always looking 
 
 for an opportunity to blackmail their employers into paying them extra. 
 
 Python programmers are a decent, law-abiding people with a strong moral 
 
 code who would never stoop to the sort of things that Perl coders are 
 
 proud of doing.
 
 
 
 
 
 
 
 -- 
 
 Steven


Some bosses just like the 1 to 5 liners  of the Perl style 
in some cryptic forms from villain Perl programmers.

I did see the same tricks in the Lisp or C/C++ before
but with extremely long fat source codes in tens of 
thousands of lines that could also pleased some managers 
or bosses.





-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why do Perl programmers make more money than Python programmers

2013-05-05 Thread Roy Smith
In article auo1hgfmri...@mid.uni-berlin.de,
 j...@toerring.de (Jens Thoms Toerring) wrote:

 Well, that didn't have a happy ending:-( Should have listened to
 my parents when they told me again and again Never use Perl, just
 say no!. Seems I'm doomed - what's the proper way to apply for a
 job with the mob?

I don't think you apply.  If they want you, they'll find you.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why do Perl programmers make more money than Python programmers

2013-05-05 Thread Jens Thoms Toerring
In comp.lang.python Roy Smith r...@panix.com wrote:
 In article auo1hgfmri...@mid.uni-berlin.de,
  j...@toerring.de (Jens Thoms Toerring) wrote:

  Well, that didn't have a happy ending:-( Should have listened to
  my parents when they told me again and again Never use Perl, just
  say no!. Seems I'm doomed - what's the proper way to apply for a
  job with the mob?

 I don't think you apply.  If they want you, they'll find you.

I see, that's what's called headhuntering, isn't it?

-- 
  \   Jens Thoms Toerring  ___  j...@toerring.de
   \__  http://toerring.de
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why do Perl programmers make more money than Python programmers

2013-05-05 Thread Roy Smith
In article mailman.1310.1367789840.3114.python-l...@python.org,
 Dennis Lee Bieber wlfr...@ix.netcom.com wrote:

 On Sun, 05 May 2013 17:07:41 -0400, Roy Smith r...@panix.com declaimed
 the following in gmane.comp.python.general:
 
  In article 5186af75$0$29997$c3e8da3$54964...@news.astraweb.com,
   Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote:
   
   Right now, I'd consider learning PHP for an extra $100 a month. Or 
   peddling my arse down at the docks for twenty cents a time, which will be 
   less embarrassing and much less painful.
  
  Having spent the better part of a year doing one of those activities, 
  I'm inclined to agree.
  
  There *are* programming languages worse than PHP.  Have you ever tried 
  britescript?
 
   Is that a toothpaste, kitchen cleaner, or device for doing gold-leaf
 illuminated manuscripts? G

It is a programming language.  It is what Roku apps are written in.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python not starting

2013-05-05 Thread Andrew Berg
On 2013.05.05 13:55, Steven D'Aprano wrote:
 (you might need to use /S on Windows instead, I'm not sure.)
That is only a convention among Microsoft's CLI utilities. Very few others 
follow it (even for programs written specifically for Windows),
and it is certainly not a necessity on Windows.
-- 
CPython 3.3.1 | Windows NT 6.2.9200 / FreeBSD 9.1
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why do Perl programmers make more money than Python programmers

2013-05-05 Thread Chris Angelico
On Mon, May 6, 2013 at 7:09 AM, Rainer Weikusat rweiku...@mssgmbh.com wrote:
 j...@toerring.de (Jens Thoms Toerring) writes:
 Now you got me badly worried, using both Perl and Python (and
 other, unspeakable languages, but not VB I promise!) Will I
 end up as a Python hacker for the mob or worse

 https://en.wikipedia.org/wiki/Strange_Case_of_Dr_Jekyll_and_Mr_Hyde

Ah, that would be me. Every night, I work on open source projects
written in good languages; but four days a week from 9:00 till 5:00 my
other nature takes over, and there is a struggle between the forces of
Good and Evil. The Evil side is strong, but even there the Good side
is not completely unheard; there are occasional times when I fight off
the PHP influence. (I'm still confident that we will eventually move
off PHP altogether. My boss reckons it'll never happen, but I can be
patient...)

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python not starting

2013-05-05 Thread Chris Angelico
On Mon, May 6, 2013 at 4:15 AM, DRJ Reddy rama29...@gmail.com wrote:
 I did read and understood that while replying if  is there we will get a 
 blank line unnecessarily.

If you read that page, you'll know that it does NOT advocate the total
elimination of quoted text, which is what you've now done. Please
don't. Your posts now lack any form of context.

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why do Perl programmers make more money than Python programmers

2013-05-05 Thread Ignoramus16992
On 2013-05-05, Paul Rubin no.email@nospam.invalid wrote:
 Paul Rubin no.email@nospam.invalid writes:
 I see New York listed as a location for Perl but not for Python.

 Whaat?  It's there for Python, though in the #3 position rather than #2.
 I must have flipped through the slides too fast.

My website algebra.com is written in perl, it is now #1,198 in the US
rankings, based on Quantcast.  I could not be happier with
maintainability and robustness features of perl. 

i
going undercover for the russian mob next week
-- 
http://mail.python.org/mailman/listinfo/python-list


(Learner-here) Lists + Functions = headache

2013-05-05 Thread Bradley Wright
Hey guys and gals doing this tutorial(codecademy) and needed a bit help from 
the experienced.

I'm writing a function that takes a list(one they supply during runtime)
here's what my function is supposed to do

1. for each instance of the string fizz make a count
2. Finally return that count

here's my code:

def fizz_cout(x):
count = 0
for item in x:
while item == fizz:
count += 1
return count

Please remember that i am a eager beginner, where am i going wrong?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: (Learner-here) Lists + Functions = headache

2013-05-05 Thread alex23
On May 6, 10:59 am, Bradley Wright bradley.wright@gmail.com
wrote:
 def fizz_cout(x):
     count = 0
     for item in x:
         while item == fizz:
             count += 1
             return count

 Please remember that i am a eager beginner, where am i going wrong?

There are several problems with your code:

     for item in x:
         while item == fizz:
             count += 1

The `for` takes an item out of the list `x`. If that item is the
string 'fizz', it increments count. As it's a `while` loop, it will
continue to increment for as long as `item` is 'fizz'. Since the while
loop doesn't look up another list item, it will remain as 'fizz' until
the end of time. Well, it would except for your second bug:

         while item == fizz:
             count += 1
             return count

The very first time it encounters a list item that is 'fizz', it adds
one to `count`, then exits the function passing back `count`.

You want to move the return to _outside_ the for loop, and you want to
change your `while` condition to an `if` instead.


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: (Learner-here) Lists + Functions = headache

2013-05-05 Thread Bradley Wright
On Sunday, May 5, 2013 9:21:33 PM UTC-4, alex23 wrote:
 On May 6, 10:59 am, Bradley Wright bradley.wright@gmail.com
 
 wrote:
 
  def fizz_cout(x):
 
      count = 0
 
      for item in x:
 
          while item == fizz:
 
              count += 1
 
              return count
 
 
 
  Please remember that i am a eager beginner, where am i going wrong?
 
 
 
 There are several problems with your code:
 
 
 
      for item in x:
 
          while item == fizz:
 
              count += 1
 
 
 
 The `for` takes an item out of the list `x`. If that item is the
 
 string 'fizz', it increments count. As it's a `while` loop, it will
 
 continue to increment for as long as `item` is 'fizz'. Since the while
 
 loop doesn't look up another list item, it will remain as 'fizz' until
 
 the end of time. Well, it would except for your second bug:
 
 
 
          while item == fizz:
 
              count += 1
 
              return count
 
 
 
 The very first time it encounters a list item that is 'fizz', it adds
 
 one to `count`, then exits the function passing back `count`.
 
 
 
 You want to move the return to _outside_ the for loop, and you want to
 
 change your `while` condition to an `if` instead.

Thank you Alex - much appreciated, about to implement right now!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: (Learner-here) Lists + Functions = headache

2013-05-05 Thread Terry Jan Reedy

On 5/5/2013 8:59 PM, Bradley Wright wrote:

Hey guys and gals doing this tutorial(codecademy) and needed a bit help from 
the experienced.

I'm writing a function that takes a list(one they supply during runtime)
here's what my function is supposed to do


Do they supply an example so you can test both your comprehension and 
code? I think most specs given in natural language need such.



1. for each instance of the string fizz make a count
2. Finally return that count


Did you create an example problem to test your code? If not, do so.
Did you run your function with example data? If not, do so.


here's my code:

def fizz_cout(x):
 count = 0
 for item in x:
 while item == fizz:
 count += 1
 return count


Here is  hint as to some of what needs to be improved: this function 
will return either 1 or None. You should have discovered that by testings.


--
Terry Jan Reedy


--
http://mail.python.org/mailman/listinfo/python-list


Re: (Learner-here) Lists + Functions = headache

2013-05-05 Thread Steven D'Aprano
On Sun, 05 May 2013 17:59:15 -0700, Bradley Wright wrote:

 Hey guys and gals doing this tutorial(codecademy) and needed a bit help
 from the experienced.
 
 I'm writing a function that takes a list(one they supply during runtime)
 here's what my function is supposed to do
 
 1. for each instance of the string fizz make a count 
 2. Finally return that count
 
 here's my code:
 
 def fizz_cout(x):
 count = 0
 for item in x:
 while item == fizz:
 count += 1
 return count
 
 Please remember that i am a eager beginner, where am i going wrong?

Lots of places, sorry. The first thing you're doing is hoping that we 
will guess what error you are getting. In this case, it so happens that 
we can, but that will not always be the case. You should always give us 
the code (which you have done), the data it is running on, the expected 
result, and the actual result. Within reason: don't bombard us with 
10,000 lines of code and 3MB of data.

Now, moving on to your function: try walking through it yourself in your 
head. You start off by defining a value, then start iterating over each 
value in x, one at a time.


count = 0
for item in x:

Suppose x = [buzz, fizz, buzz, fizz]. Then you should get a 
result of 2. So far, you start with count = 0. Then you enter the for 
loop, and item gets the value buzz. The next line enters a while loop:

while item == fizz:

Since item does *not* equal fizz, the body of the while loop does not 
run at all, and Python jumps past the while loop, which takes it to the 
end of the for loop. So Python goes on to the next item. This time item 
gets set to fizz. So you enter the while loop again, only this time 
item *does* equal fizz:

while item == fizz:
count += 1
return count


Oh-oh, trouble ahead. But luckily, you have two bugs, and they *almost* 
cancel themselves out. The first problem is that the while loop would be 
an infinite loop, going around and around and around over and over again, 
since you enter it with item == fizz but item always stays equal to 
fizz. So the first two lines would keep adding one to count, over and 
over again, until count is so big your computer runs out of memory (and 
that might take *months*).

Fortunately, the very next line *almost* overcomes that bug. It doesn't 
*fix* it, but it does reduce the severity. After adding one to count the 
very first time, Python hits the line return count, which immediately 
exits the function, jumping out of the (infinite) while loop and the for-
loop. So your function always returns either 0 (if there are no fizz in 
the list at all) or 1 (if there is any fizz).

So, you have two problems, and they both need to be fixed:

1) The return count line must not happen until the for-loop has 
completed looking at each item in the list. So it must be outside the for-
loop, not inside it. Remember that Python decides what is inside the loop 
by its indentation.

2) You don't want an infinite loop inside the for-loop. There is no need 
to have two loops at all. The outer for-loop is sufficient. You look at 
each item *once*, not over and over again, and decide *once* if you 
should add one to count, then go on to the next item.


-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: (Learner-here) Lists + Functions = headache

2013-05-05 Thread Bradley Wright
On Sunday, May 5, 2013 9:24:44 PM UTC-4, Bradley Wright wrote:
 On Sunday, May 5, 2013 9:21:33 PM UTC-4, alex23 wrote:
 
  On May 6, 10:59 am, Bradley Wright bradley.wright@gmail.com
 
  
 
  wrote:
 
  
 
   def fizz_cout(x):
 
  
 
       count = 0
 
  
 
       for item in x:
 
  
 
           while item == fizz:
 
  
 
               count += 1
 
  
 
               return count
 
  
 
  
 
  
 
   Please remember that i am a eager beginner, where am i going wrong?
 
  
 
  
 
  
 
  There are several problems with your code:
 
  
 
  
 
  
 
       for item in x:
 
  
 
           while item == fizz:
 
  
 
               count += 1
 
  
 
  
 
  
 
  The `for` takes an item out of the list `x`. If that item is the
 
  
 
  string 'fizz', it increments count. As it's a `while` loop, it will
 
  
 
  continue to increment for as long as `item` is 'fizz'. Since the while
 
  
 
  loop doesn't look up another list item, it will remain as 'fizz' until
 
  
 
  the end of time. Well, it would except for your second bug:
 
  
 
  
 
  
 
           while item == fizz:
 
  
 
               count += 1
 
  
 
               return count
 
  
 
  
 
  
 
  The very first time it encounters a list item that is 'fizz', it adds
 
  
 
  one to `count`, then exits the function passing back `count`.
 
  
 
  
 
  
 
  You want to move the return to _outside_ the for loop, and you want to
 
  
 
  change your `while` condition to an `if` instead.
 
 
 
 Thank you Alex - much appreciated, about to implement right now!

Aha! lessons learned - got it!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: (Learner-here) Lists + Functions = headache

2013-05-05 Thread Steven D'Aprano
On Mon, 06 May 2013 01:31:48 +, Steven D'Aprano wrote:

 So your function always returns either 0 (if there are no
 fizz in the list at all) or 1 (if there is any fizz).

Correction: (thanks to Terry for pointing this out). It will return None 
or 1, not 0.

How easy it is to fall into the trap of assuming the function will do 
what you intend it to do, instead of what you actually tell it to do :-(



-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python not starting

2013-05-05 Thread drjreddy7

 import nt
 
 print nt.__file__
I have done above ones as you stated.
I'm getting an error
Traceback (most recent call last):
  File stdin, line 1, in module
AttributeError: 'module' object has no attribute '__file__'
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to avoid PEP8 'imported but unused'

2013-05-05 Thread Adam Jiang
Thank you. Problem solved.

/Adam
On Sun, May 05, 2013 at 06:27:44PM +0100, Fábio Santos wrote:
 That assert will never fail. If the symbol is not imported, the import
 statement raises ImportError. And actually assert makes sure that
 the value is not false-ish, not None/Null. And AFAIK a module object
 is *always* true.
 
  One more question. In this particular case it seems 'assert' should be
  safe as a workaround, doesn't it?  'assert' will check if the symbol
  is imported and not NULL. Is there side effect if I just applied this
  rule as a generic one.
 
 
 --
 Fábio Santos
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python not starting

2013-05-05 Thread drjreddy7
On Monday, May 6, 2013 3:59:01 AM UTC+5:30, Chris Angelico wrote:
 On Mon, May 6, 2013 at 4:15 AM, DRJ Reddy rama29...@gmail.com wrote:
 I did read and understood that while replying if  is there we will get a 
 blank line unnecessarily.
 If you read that page, you'll know that it does NOT advocate the total
 elimination of quoted text, which is what you've now done. Please
 don't. Your posts now lack any form of context.
 ChrisA

Sorry ChrisA,not only him for all, for the mess i have created.It was the first 
time for me on google groups. 
I am very happy to inform all of you that the problem is solved. The problem 
was due to the prescence of duplicates for genericpath.pyc and stat.pyc.I have 
deleted them and new ones were generated as i started python.
Thanking all of you for assisting me in solving the issue.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python not starting

2013-05-05 Thread Chris Angelico
On Mon, May 6, 2013 at 1:15 PM,  drjred...@gmail.com wrote:
 On Monday, May 6, 2013 3:59:01 AM UTC+5:30, Chris Angelico wrote:
 On Mon, May 6, 2013 at 4:15 AM, DRJ Reddy rama29...@gmail.com wrote:
 I did read and understood that while replying if  is there we will get a 
 blank line unnecessarily.
 If you read that page, you'll know that it does NOT advocate the total
 elimination of quoted text, which is what you've now done. Please
 don't. Your posts now lack any form of context.
 ChrisA

 Sorry ChrisA,not only him for all, for the mess i have created.It was the 
 first time for me on google groups.
 I am very happy to inform all of you that the problem is solved. The problem 
 was due to the prescence of duplicates for genericpath.pyc and stat.pyc.I 
 have deleted them and new ones were generated as i started python.
 Thanking all of you for assisting me in solving the issue.

Excellent! Glad it's sorted.

The .pyc problem is, if I understand correctly, more permanently
solved in newer versions of Python. So this won't ever be an issue
again :)

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: (Learner-here) Lists + Functions = headache

2013-05-05 Thread 88888 Dihedral
Bradley Wright於 2013年5月6日星期一UTC+8上午8時59分15秒寫道:
 Hey guys and gals doing this tutorial(codecademy) and needed a bit help from 
 the experienced.
 
 
 
 I'm writing a function that takes a list(one they supply during runtime)
 
 here's what my function is supposed to do
 
 
 
 1. for each instance of the string fizz make a count
 
 2. Finally return that count
 
 
 
 here's my code:
 
 
 
 def fizz_cout(x):
 
 count = 0
 
 for item in x:
 
 while item == fizz:
 
 count += 1
 

 return count
 
This is not indented right in the scope to return 
the total count.

-- 
http://mail.python.org/mailman/listinfo/python-list


[issue17408] second python execution fails when embedding

2013-05-05 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Should be fixed in 7de9852cdc0e, sorry.

--
resolution:  - fixed
stage:  - committed/rejected
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17408
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17809] FAIL: test_expanduser when $HOME ends with /

2013-05-05 Thread Antoine Pitrou

Changes by Antoine Pitrou pit...@free.fr:


--
assignee:  - ezio.melotti
stage:  - patch review

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17809
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17894] Edits to descriptor howto

2013-05-05 Thread Antoine Pitrou

Antoine Pitrou added the comment:

 in contrast to an authoritative document closely tied to the actually 
 implementation details

I fail to understand why a HOWTO should be an authoritative document closely 
tied to implementation details. If you don't want this document to be 
beginner-friendly, please move it into the language reference, not the HOWTO 
directory.

--
nosy: +pitrou

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17894
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17809] FAIL: test_expanduser when $HOME ends with /

2013-05-05 Thread koobs

koobs added the comment:

Thanks Antoine, I'm removing the 'Library' component on this one given the 
proposed resolution.

Additionally, given the trivial nature and isolation of the change strictly to 
the test, I'd like to request this go into 3.2 as well. 

For any future security fixes to 3.2 until its EoL, having our buildbots 
'green' is imperative and a prerequisite for identifying regressions

--
components:  -Library (Lib)

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17809
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11406] There is no os.listdir() equivalent returning generator instead of list

2013-05-05 Thread Charles-François Natali

Charles-François Natali added the comment:

 I'd slightly prefer the name iterdir_stat(), as that almost makes the (name, 
 stat) return values explicit in the name. But that's kind of bikeshedding -- 
 scandir() works too.

I find iterdir_stat() ugly :-)
I like the scandir name, which has some precedent with POSIX.

 That's right: if we have a separate scandir() that returns (name, stat) 
 tuples, then a plain iterdir() is pretty much unnecessary -- callers just 
 ignore the second stat value if they don't care about it.

Hum, wait.
scandir() cannot return (name, stat), because on POSIX, readdir() only
returns d_name and d_type (the type of the entry): to return a stat,
we would have to call stat() on each entry, which would defeat the
performance gain.
And that's the problem with scandir: it's not portable. Depending on
the OS/file system, you could very well get DT_UNKNOWN (and on Linux,
since it uses an adaptive heuristic for NFS filesystem, you could have
some entries with a resolved d_type and some others with DT_UNKNOWN,
on the same directory stream).

That's why scandir would be a rather low-level call, whose main user
would be walkdir, which only needs to know the entry time and not the
whole stat result.

Also, I don't know which information is returned by the readdir
equivalent on Windows, but if we want a consistent API, we have to
somehow map d_type and Windows's returned type to a common type, like
DT_FILE, DT_DIRECTORY, etc (which could be an enum).

The other approach would be to return a dummy stat object with only
st_mode set, but that would be kind of a hack to return a dummy stat
result with only part of the attributes set (some people will get
bitten by this).

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11406
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11406] There is no os.listdir() equivalent returning generator instead of list

2013-05-05 Thread Ben Hoyt

Ben Hoyt added the comment:

 I find iterdir_stat() ugly :-) I like the scandir name, which has some 
 precedent with POSIX.

Fair enough. I'm cool with scandir().

 scandir() cannot return (name, stat), because on POSIX, readdir() only 
 returns d_name and d_type (the type of the entry): to return a stat, we would 
 have to call stat() on each entry, which would defeat the performance gain.

Yes, you're right. I solved this in BetterWalk with the solution you propose 
of returning a stat_result object with the fields it could get for free set, 
and the others set to None.

So on Linux, you'd get a stat_result with only st_mode set (or None for 
DT_UNKNOWN), and all the other fields None. However -- st_mode is the one 
you're most likely to use, usually looking just for whether it's a file or 
directory. So calling code would look something like this:

files = []
dirs = []
for name, st in scandir(path):
if st.st_mode is None:
st = os.stat(os.path.join(path, name))
if stat.S_ISDIR(st.st_mode):
dirs.append(name)
else:
files.append(name)

Meaning you'd get the speed improvements 99% of the time (when st_mode) was 
set, but if st_mode is None, you can call stat and handle errors and whatnot 
yourself.

 That's why scandir would be a rather low-level call, whose main user would be 
 walkdir, which only needs to know the entry time and not the whole stat 
 result.

Agreed. This is in the OS module after all, and there's tons of stuff that's 
OS-dependent in there. However, I think that doing something like the above, we 
can make it usable and performant on both Linux and Windows for use cases like 
walking directory trees.

 Also, I don't know which information is returned by the readdir equivalent on 
 Windows, but if we want a consistent API, we have to somehow map d_type and 
 Windows's returned type to a common type, like DT_FILE, DT_DIRECTORY, etc 
 (which could be an enum).

The Windows scan directory functions (FindFirstFile/FindNextFile) return a 
*full* stat (or at least, as much info as you get from a stat in Windows). We 
*could* map them to a common type -- but I'm suggesting that common type might 
as well be stat_result with None meaning not present. That way users don't 
have to learn a completely new type.

 The other approach would be to return a dummy stat object with only st_mode 
 set, but that would be kind of a hack to return a dummy stat result with only 
 part of the attributes set (some people will get bitten by this).

We could document any platform-specific stuff, and places you'd users could get 
bitten. But can you give me an example of where the 
stat_result-with-st_mode-or-None approach falls over completely?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11406
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11406] There is no os.listdir() equivalent returning generator instead of list

2013-05-05 Thread Nick Coghlan

Nick Coghlan added the comment:

I think os.scandir is a case where we *want* a low level call that exposes 
everything we can retrieve efficiently about the directory entries given the 
underlying platform - not everything written in Python is written to be 
portable, especially when it comes to scripts rather than applications (e.g. 
given where I work, I write a fair bit of code that is Fedora/RHEL specific, 
and if that code happens to work anywhere else it's just a bonus rather than 
being of any specific value to me).

This may mean that we just return an info object for each item, where the 
available info is explicitly platform specific. Agreed it can be an actual stat 
object, though.

os.walk then become the cross-platform abstraction built on top of the low 
level scandir call (splitting files from directories is probably about all we 
can do consistently cross-platform without per-entry stat calls).

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11406
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1545463] New-style classes fail to cleanup attributes

2013-05-05 Thread Armin Rigo

Changes by Armin Rigo ar...@users.sourceforge.net:


--
nosy:  -arigo

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1545463
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11406] There is no os.listdir() equivalent returning generator instead of list

2013-05-05 Thread Charles-François Natali

Charles-François Natali added the comment:

 We could document any platform-specific stuff, and places you'd users could 
 get bitten. But can you give me an example of where the 
 stat_result-with-st_mode-or-None approach falls over completely?

Well, that's easy:

size = 0
for name, st in scandir(path):
if stat.S_ISREG(st.st_mode):
size += st.st_size

 Agreed it can be an actual stat object, though.

Well, the nice thing is that we don't have to create yet another info
object, the downside is that it can be tricky, see above.

We can probably use the DTTOIF macro to convert d_type to st_mode.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11406
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17908] Unittest runner needs an option to call gc.collect() after each test

2013-05-05 Thread Giampaolo Rodola'

Changes by Giampaolo Rodola' g.rod...@gmail.com:


--
nosy: +giampaolo.rodola

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17908
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1545463] New-style classes fail to cleanup attributes

2013-05-05 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Here is an updated patch after the latest changes on default.

--
Added file: http://bugs.python.org/file30129/gcshutdown2.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1545463
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17908] Unittest runner needs an option to call gc.collect() after each test

2013-05-05 Thread Antoine Pitrou

Antoine Pitrou added the comment:

 OTOH it's a useful option to have in case you're tracking down
 something that happens (or doesn't happen) when an object is collected

IMO this is a good reason to implement your specific tearDown method (or call 
addCleanup if you prefer), possibly in a shared base class.

I don't think this is a good candidate for a command-line option, it's too 
specialized and it's also not something which should be enabled blindly. In 
other words, each test case should know whether it needs a collection or not.

--
nosy: +pitrou

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17908
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17906] JSON should accept lone surrogates

2013-05-05 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

After investigating the problem deeper, I see that new parameter is not needed. 
RFC 4627 does not make exceptions for the range 0xD800-0xDFFF, and the decoder 
must accept lone surrogates, both escaped and unescaped. Non-BMP characters may 
be represented as escaped surrogate pair, so escaped surrogate pair may be 
decoded as non-BMP character, while unescaped surrogate pair shouldn't.

Here is a patch, with which JSON decoder accepts encoded lone surrogates. Also 
fixed a bug when Python implementation decodes \\ud834\\u0079x as 
\U0001d179.

--
keywords: +patch
stage: needs patch - patch review
title: Add a string error handler to JSON encoder/decoder - JSON should accept 
lone surrogates
type: enhancement - behavior
versions: +Python 2.7, Python 3.3
Added file: http://bugs.python.org/file30130/json_decode_lone_surrogates.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17906
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17906] JSON should accept lone surrogates

2013-05-05 Thread Serhiy Storchaka

Changes by Serhiy Storchaka storch...@gmail.com:


Added file: 
http://bugs.python.org/file30131/json_decode_lone_surrogates-2.7.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17906
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue995907] memory leak with threads and enhancement of the timer class

2013-05-05 Thread Yael

Yael added the comment:

Can you please review the patch? thanks!

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue995907
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17907] Deprecate imp.new_module() in favour of types.ModuleType

2013-05-05 Thread Antoine Pitrou

Antoine Pitrou added the comment:

If so, then at least the constructor should be documented.

--
nosy: +pitrou

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17907
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15902] imp.load_module won't accept None for the file argument for a C extension

2013-05-05 Thread Brett Cannon

Brett Cannon added the comment:

http://hg.python.org/cpython/rev/996a937cdf81 also applies to this.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15902
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17636] Modify IMPORT_FROM to fallback on sys.modules

2013-05-05 Thread Brett Cannon

Brett Cannon added the comment:

Don't be distracted when trying to write tests is the lesson learned. Fixed 
basic and rebinding and just deleted indirect.

--
Added file: http://bugs.python.org/file30132/import_from_tests.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17636
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17909] Autodetecting JSON encoding

2013-05-05 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

RFC 4627 specifies a method to determine an encoding (one of UTF-8, 
UTF-16(BE|LE) or UTF-32(BE|LE)) of encoded JSON text. The proposed preliminary 
patch (it doesn't include the documentation yet) allows load() and loads() 
functions accept bytes data when it is encoded with standard Unicode encoding. 
Also accepted data with BOM (this doesn't specified in RFC 4627, but is widely 
used).

There is only one case where the method can give a misfire. Serialized string 
\x00... encoded in UTF-16LE may be erroneously detected as encoded in 
UTF-32LE. This case violates the two rules of RFC 4627: the string was 
serialized instead of a an object or an array, and the control character U+ 
was not escaped. The standard encoded JSON always detected correctly.

This patch requires surrogatepass error handler for utf-16/32 (see issue12892 
and issue13916).

--
assignee: serhiy.storchaka
components: Library (Lib), Unicode
files: json_detect_encoding.patch
keywords: patch
messages: 188442
nosy: ezio.melotti, pitrou, rhettinger, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Autodetecting JSON encoding
type: enhancement
versions: Python 3.4
Added file: http://bugs.python.org/file30133/json_detect_encoding.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17909
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17909] Autodetecting JSON encoding

2013-05-05 Thread Serhiy Storchaka

Changes by Serhiy Storchaka storch...@gmail.com:


--
dependencies: +UTF-16 and UTF-32 codecs should reject (lone) surrogates, 
disallow the surrogatepass handler for non  utf-* encodings

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17909
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11406] There is no os.listdir() equivalent returning generator instead of list

2013-05-05 Thread STINNER Victor

STINNER Victor added the comment:

I really like scandir() - (name: str, stat: stat structure using None for
unknown fields).

I expect that this API to optimize use cases like:

- glob.glob(*.jpg) in a big directory with few JPEG picture
- os.walk(.) in a directory with many files: should reduce the number of
stat() to zero on most platforms

But as usual, a benchmark on a real platform would be more convicing.

Filtering entries in os.listdir() or os.scandir() would be faster (than
filtering their output), but it hard to design an API to filter arbitrary
fields (name, file type, size, ...) especially because the underlying C
functions does not provide required information. A generator is closer to
Python design and more natural.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11406
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12634] Random Remarks in class documentation

2013-05-05 Thread Yogesh Chaudhari

Yogesh Chaudhari added the comment:

Similar changes for 2.7 branch

--
hgrepos: +188
Added file: http://bugs.python.org/file30135/issue12634-27.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12634
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12634] Random Remarks in class documentation

2013-05-05 Thread Yogesh Chaudhari

Yogesh Chaudhari added the comment:

Based on Teery's comments, this patch makes the changes to the random remarks 
section of the class documentation

--
keywords: +patch
nosy: +Yogesh.Chaudhari
Added file: http://bugs.python.org/file30134/issue12634.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12634
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17732] distutils.cfg Can Break venv

2013-05-05 Thread Nick Sloan

Nick Sloan added the comment:

Just checking to see if anything else is needed from me on this.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17732
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17798] IDLE: can not edit new file names when using -e

2013-05-05 Thread Roundup Robot

Roundup Robot added the comment:

New changeset c8cdc2400643 by Roger Serwy in branch '3.3':
#17798: Allow IDLE to edit new files when specified on command line.
http://hg.python.org/cpython/rev/c8cdc2400643

New changeset a64a3da996ed by Roger Serwy in branch 'default':
#17798: merge with 3.3.
http://hg.python.org/cpython/rev/a64a3da996ed

--
nosy: +python-dev

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17798
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17798] IDLE: can not edit new file names when using -e

2013-05-05 Thread Roger Serwy

Roger Serwy added the comment:

I'm closing this issue as fixed.

--
resolution:  - fixed
stage: patch review - committed/rejected
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17798
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17903] Python launcher for windows should search path for #!/usr/bin/env

2013-05-05 Thread Paul Moore

Paul Moore added the comment:

There is a patch for this (against the standalone pylauncher project) at 
https://bitbucket.org/pmoore/pylauncher.

--
keywords: +patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17903
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17858] Different documentation for identical methods

2013-05-05 Thread Andriy Mysyk

Andriy Mysyk added the comment:

Made changes suggested by Ezio Melotti in the attached patch.

--
Added file: http://bugs.python.org/file30136/issue17858.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17858
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17908] Unittest runner needs an option to call gc.collect() after each test

2013-05-05 Thread Guido van Rossum

Guido van Rossum added the comment:

On Sun, May 5, 2013 at 4:29 AM, Antoine Pitrou rep...@bugs.python.org wrote:

 Antoine Pitrou added the comment:

 OTOH it's a useful option to have in case you're tracking down
 something that happens (or doesn't happen) when an object is collected

 IMO this is a good reason to implement your specific tearDown method (or call 
 addCleanup if you prefer), possibly in a shared base class.

 I don't think this is a good candidate for a command-line option, it's too 
 specialized and it's also not something which should be enabled blindly. In 
 other words, each test case should know whether it needs a collection or not.

This is not for tests that know or expect they need a call to
gc.collect(). This is for the case where you have 500 tests that
weren't written with gc.collect() in mind, and suddenly you have a
nondeterministic failure because something goes wrong during
collection. The cause is probably many tests earlier -- and if you
could just call gc.collect() in each tearDown() it would be a cinch to
pinpoint the test that causes this. But (unless you had all that
foresight) that's a massive undertaking. However turning on the
command line option makes it trivial.

It's rare that extra collections cause tests to fail (and if it does
that's a flakey test anyway) so just turning this on for all tests
shouldn't affect correct tests -- however it can slow down your test
suite 3x or more so you don't want this to be unittest's default
behavior. Hence the suggestion of a command line flag.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17908
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17094] sys._current_frames() reports too many/wrong stack frames

2013-05-05 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Here is an updated patch which doesn't hold the lock while calling 
PyThreadState_Clear(). It looks like it should be ok. Also, I've added some 
comments.

--
Added file: http://bugs.python.org/file30137/tstates-afterfork2.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17094
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16518] add buffer protocol to glossary

2013-05-05 Thread Ezio Melotti

Ezio Melotti added the comment:

Updated patch to include getargs.c too.

--
stage: patch review - commit review
Added file: http://bugs.python.org/file30138/issue16518-4.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16518
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9682] socket.create_connection error message for domain subpart with invalid length is very confusing

2013-05-05 Thread Mike Milkin

Mike Milkin added the comment:

Moved the conditional logic out of the method.  There are no tests for ToASCII 
function and I was not comfortable making changes to it without adding tests.

--
Added file: http://bugs.python.org/file30139/Issue9682-5513.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9682
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15528] Better support for finalization with weakrefs

2013-05-05 Thread Richard Oudkerk

Richard Oudkerk added the comment:

Here is an updated patch.  It is only really the example in the docs which is 
different, plus a note about daemon threads.

Antoine, do think this is ready to be committed?

--
Added file: http://bugs.python.org/file30140/finalize.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15528
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17883] Fix buildbot testing of Tkinter

2013-05-05 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 3c58fa7dc7f1 by Ezio Melotti in branch '2.7':
#17883: Fix buildbot testing of Tkinter on Windows.  Patch by Zachary Ware.
http://hg.python.org/cpython/rev/3c58fa7dc7f1

--
nosy: +python-dev

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17883
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



  1   2   >