Re: Help with loading file into an array
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
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
peter berrett 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
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 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
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 > 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
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 > > > 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
> 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 , DRJ Reddy 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
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 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
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 , > > DRJ Reddy 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
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 > > >>> 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
On Mon, May 6, 2013 at 12:16 AM, Roy Smith wrote: > In article , > DRJ Reddy 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
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 wrote: > > > In article , > > > DRJ Reddy 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
On Mon, May 6, 2013 at 1:11 AM, DRJ Reddy 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 wrote: >> >> > In article , >> >> > DRJ Reddy 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'
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
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'
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" 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'
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
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
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'
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'
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" 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
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
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
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 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
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 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'
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
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 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
On Mon, May 6, 2013 at 3:11 AM, 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. > > 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
On May 5, 10:11 pm, 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#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
In article <9d2513ed-2738-4b6f-92af-82c1faa54...@googlegroups.com>, DRJ Reddy 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
> 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
In article , Ignoramus16992 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
thanks! Il giorno 05/mag/2013, alle ore 18:58, Eric Brunson 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
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
On 05/05/2013 18:35, rusi wrote: On May 5, 10:11 pm, 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#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
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 > 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
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
On Sun, 05 May 2013 13:58:51 -0400, Roy Smith wrote: > In article , > Ignoramus16992 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
In comp.lang.python Steven D'Aprano 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
On May 5, 2013, at 9:13 PM, Steven D'Aprano wrote: > On Sun, 05 May 2013 13:58:51 -0400, Roy Smith wrote: > >> In article , >> Ignoramus16992 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
j...@toerring.de (Jens Thoms Toerring) writes: > In comp.lang.python Steven D'Aprano > 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
In article <5186af75$0$29997$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano 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
Ignoramus16992 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
Paul Rubin 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
In comp.lang.python Rainer Weikusat wrote: > j...@toerring.de (Jens Thoms Toerring) writes: > > In comp.lang.python Steven D'Aprano > > 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
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
In article , 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
In comp.lang.python Roy Smith wrote: > In article , > 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
In article , Dennis Lee Bieber wrote: > On Sun, 05 May 2013 17:07:41 -0400, Roy Smith declaimed > the following in gmane.comp.python.general: > > > In article <5186af75$0$29997$c3e8da3$54964...@news.astraweb.com>, > > Steven D'Aprano 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? 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
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
On Mon, May 6, 2013 at 7:09 AM, Rainer Weikusat 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
On Mon, May 6, 2013 at 4:15 AM, DRJ Reddy 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
On 2013-05-05, Paul Rubin wrote: > Paul Rubin 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
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
On May 6, 10:59 am, Bradley Wright 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
On Sunday, May 5, 2013 9:21:33 PM UTC-4, alex23 wrote: > On May 6, 10:59 am, Bradley Wright > > 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
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
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
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 > > > > > > 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
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
import nt print nt.__file__ I have done above ones as you stated. I'm getting an error Traceback (most recent call last): File "", line 1, in AttributeError: 'module' object has no attribute '__file__' -- http://mail.python.org/mailman/listinfo/python-list
Re: How to avoid PEP8 'imported but unused'
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
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 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
On Mon, May 6, 2013 at 1:15 PM, 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 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
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
Re: Python not starting
On Sun, 05 May 2013 20:15:08 -0700, drjreddy7 wrote: > 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. Well, I'm glad it's sorted, but the solution raises as many questions as it answers. How did you get duplicate genericpath.pyc and stat.pyc files? If they were duplicates, why didn't they have the right code in them? It's probably not worth spending any more time investigating, but it is still rather mysterious. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Why do Perl programmers make more money than Python programmers
On 05/05/13 18:11, Ignoramus16992 wrote: According to CIO.com What an amusing thread; lightened my (non-programmer) day. -- Henry LawManchester, England -- http://mail.python.org/mailman/listinfo/python-list
Re: Why do Perl programmers make more money than Python programmers
On Sunday, May 5, 2013 12:10:47 PM UTC-7, Steven D'Aprano wrote: > > > 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 And of course, the Python Programmer's moral code is only 80 characters wide. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why do Perl programmers make more money than Python programmers
> And of course, the Python Programmer's moral code is only 80 characters wide. No! Was it not seventy characters wide? Was I fooled my entire life? -- http://mail.python.org/mailman/listinfo/python-list