Pygments 1.6rc1 released
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 I'm happy to announce the release of Pygments 1.6, release candidate 1. Pygments is a generic syntax highlighter written in Python. Pygments 1.6 is again a large release, with over 30 new languages or markups supported, and a few interesting new features. Heavy thanks go to all the contributors of these lexers, and to all those who reported bugs and waited patiently for this release, and as always many thanks also to Tim Hatch for his continued care for Pygments. Download it from http://pypi.python.org/pypi/Pygments, or look at the demonstration at http://pygments.org/demo. Enjoy, Georg -BEGIN PGP SIGNATURE- Version: GnuPG v2.0.19 (GNU/Linux) iEYEARECAAYFAlDt0soACgkQN9GcIYhpnLB81ACglru6Wb5z9DvflhlVATEnIQLH 7UwAn27zvhAnVnEefViKxihcrhEgkeYZ =/xSd -END PGP SIGNATURE- -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Re: [Tutor] How to run multiline shell command within python
On Thu, Jan 10, 2013 at 7:01 AM, Karim kliat...@gmail.com wrote: Hello all, I want to run multiline shell command within python without using a command file but directly execute several lines of shell. I already use *subprocess.checkoutput(csh -f my_file.csh.split())* but I want to know if it is posssible to avoid making file and execute shell lines of code directly. Yes, this is very possible. Specify shell=True as an argument and you can do anything you can do in a shell: commands = echo hello ... echo hello | wc -l ... ps aux | grep python b = subprocess.check_output(commands, shell=True) print(b.decode('ascii')) hello 1 hugo 1255 1.0 0.6 777316 49924 ?Sl 09:14 0:08 /usr/bin/python2 /usr/bi hugo 6529 0.0 0.0 42408 7196 pts/0S+ 09:23 0:00 python hugo 6559 0.0 0.0 10656 1128 pts/0S+ 09:28 0:00 grep python watch out though, accepting user input into the commands variable will lead to shell injection, which can be a dangerous security vulnerability. HTH, Hugo -- http://mail.python.org/mailman/listinfo/python-list
Re: PIL or something to open EXIF Metadata with Python
Tim Golden m...@timgolden.me.uk writes: On 09/01/2013 14:45, Jose Trevino wrote: I am trying to load the PIL module to manage exif metadata with Python but have had no success. Try pyexiv2: http://tilloy.net/dev/pyexiv2/ TJG Or Hachoir http://pypi.python.org/pypi/hachoir-metadata https://bitbucket.org/haypo/hachoir/wiki/Home -- Pete Forman -- http://mail.python.org/mailman/listinfo/python-list
Re: ANNOUNCE: Thesaurus - a recursive dictionary subclass using attributes
Dave Cinege d...@cinege.com wrote: You will notice that the code is disgusting simple. However I have found that this has completely changed the way I program in python. I've re-written some exiting programs using Thesaurus, and often relized 15-30% code reduction. Additionally I find the new code much easier to read. And here's the same code written without your class but maintaining as far as possible the same structure. I find my version far easier to read then your's with all your spurious 'g.' 'L.' prefixes. - #!python2.7 from textwrap import dedent class Blob(object): pass prog = Blob() prog.VERSION = '1.0'# But isn't this so much cleaner? prog.NAME = 'Thesaurus' class TestClass: no = 'Class' way = 'this' def main (): tc = TestClass() l = ['Some', 'objects'] # Here's how you should create output without a fight. print dedent('''\ When programing python without {prog.NAME}, it is very easy to access your {l[1]}. {l[0]} people might say {prog.NAME} has no {tc.no}.''').format(prog=prog, l=l, tc=tc) if hasattr(prog, 'VERSION'): print 'But I challenge them to write code {tc.way} clean without it!'.format(**locals()) if __name__ == '__main__': main() - -- Duncan Booth http://kupuguy.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
Re: ANNOUNCE: Thesaurus - a recursive dictionary subclass using attributes
在 2013年1月10日星期四UTC+8下午7时34分23秒,Duncan Booth写道: Dave Cinege d...@cinege.com wrote: You will notice that the code is disgusting simple. However I have found that this has completely changed the way I program in python. I've re-written some exiting programs using Thesaurus, and often relized 15-30% code reduction. Additionally I find the new code much easier to read. And here's the same code written without your class but maintaining as far as possible the same structure. I find my version far easier to read then your's with all your spurious 'g.' 'L.' prefixes. - #!python2.7 from textwrap import dedent class Blob(object): pass prog = Blob() prog.VERSION = '1.0' # But isn't this so much cleaner? prog.NAME = 'Thesaurus' class TestClass: no = 'Class' way = 'this' def main (): tc = TestClass() l = ['Some', 'objects'] # Here's how you should create output without a fight. print dedent('''\ When programing python without {prog.NAME}, it is very easy to access your {l[1]}. {l[0]} people might say {prog.NAME} has no {tc.no}.''').format(prog=prog, l=l, tc=tc) if hasattr(prog, 'VERSION'): print 'But I challenge them to write code {tc.way} clean without it!'.format(**locals()) if __name__ == '__main__': main() - -- Duncan Booth http://kupuguy.blogspot.com An object can accquire new properties and methods in the run time without the limitations from the class definition of the object which belongs to. This is a true OOP language. -- http://mail.python.org/mailman/listinfo/python-list
Re: [Tutor] How to run multiline shell command within python
On 10/01/2013 09:31, Hugo Arts wrote: On Thu, Jan 10, 2013 at 7:01 AM, Karim kliat...@gmail.com mailto:kliat...@gmail.com wrote: Hello all, I want to run multiline shell command within python without using a command file but directly execute several lines of shell. I already use *subprocess.checkoutput(csh -f my_file.csh.split())* but I want to know if it is posssible to avoid making file and execute shell lines of code directly. Yes, this is very possible. Specify shell=True as an argument and you can do anything you can do in a shell: commands = echo hello ... echo hello | wc -l ... ps aux | grep python b = subprocess.check_output(commands, shell=True) print(b.decode('ascii')) hello 1 hugo 1255 1.0 0.6 777316 49924 ?Sl 09:14 0:08 /usr/bin/python2 /usr/bi hugo 6529 0.0 0.0 42408 7196 pts/0S+ 09:23 0:00 python hugo 6559 0.0 0.0 10656 1128 pts/0S+ 09:28 0:00 grep python watch out though, accepting user input into the commands variable will lead to shell injection, which can be a dangerous security vulnerability. HTH, Hugo Many thanks Hugo. It makes my day! In my case there are no possibilities for shell injection. It is internal to a class. Regards Karim -- http://mail.python.org/mailman/listinfo/python-list
Re: Python-list Digest, Vol 112, Issue 79
-- Weitergeleitete Nachricht -- From: Dave Angel d...@davea.name To: python-list@python.org Cc: Date: Thu, 10 Jan 2013 00:56:20 -0500 Subject: Re: subprocess.Popen and multiprocessing fails to execute external program On 01/09/2013 11:08 PM, Niklas Berliner wrote: I have a pipline that involves processing some data, handing the data to an external program (t_coffee used for sequence alignments in bioinformatics), and postprocessing the result. Since I have a lot of data, I need to run my pipeline in parallel which I implemented using the multiprocessing module following Doug Hellmanns blog ( http://blog.doughellmann.com/2009/04/pymotw-multiprocessing-part-1.html ). My pipeline works perfectly fine when I run it with the multiprocessing implementation and one consumer, i.e. on one core. If I increase the number of consumers, i.e. that multiple instances of my pipeline run in parallel the external program fails with a core dump. Could it be that the external program is not designed to have multiple simultaneous instances? There are many such programs, some of which check for an existing process before allowing another one to get far. When using the multiprocessing module, always make sure your externals are well-behaved before looking for problems in your multi-code. To put it more strongly, a well-written program cannot easily be crashed by the parent that launched it. -- DaveA Hi Dave, the developers of the external program said that they are using the program with multiple simultaneous instances. Also, when I execute multiple simultaneous instances of the external program using a bash wrapper script on my machine it works (the same wrapper scripts that fail when executed through python). Before asking here I have contacted the developers of the external program but they couldn't help me any further. Cheers, Niklas -- http://mail.python.org/mailman/listinfo/python-list
Re: [Tutor] How to run multiline shell command within python
Have you looked a the pexpect class? It works like gangbusters, especially if you're trying to run something with an interactive shell. http://www.noah.org/wiki/pexpect On Thu, Jan 10, 2013 at 9:25 AM, Karim kliat...@gmail.com wrote: On 10/01/2013 09:31, Hugo Arts wrote: On Thu, Jan 10, 2013 at 7:01 AM, Karim kliat...@gmail.com wrote: Hello all, I want to run multiline shell command within python without using a command file but directly execute several lines of shell. I already use *subprocess.checkoutput(csh -f my_file.csh.split())* but I want to know if it is posssible to avoid making file and execute shell lines of code directly. Yes, this is very possible. Specify shell=True as an argument and you can do anything you can do in a shell: commands = echo hello ... echo hello | wc -l ... ps aux | grep python b = subprocess.check_output(commands, shell=True) print(b.decode('ascii')) hello 1 hugo 1255 1.0 0.6 777316 49924 ?Sl 09:14 0:08 /usr/bin/python2 /usr/bi hugo 6529 0.0 0.0 42408 7196 pts/0S+ 09:23 0:00 python hugo 6559 0.0 0.0 10656 1128 pts/0S+ 09:28 0:00 grep python watch out though, accepting user input into the commands variable will lead to shell injection, which can be a dangerous security vulnerability. HTH, Hugo Many thanks Hugo. It makes my day! In my case there are no possibilities for shell injection. It is internal to a class. Regards Karim -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Why BOM in logging message?
In article roy-10b053.20174309012...@news.panix.com, Roy Smith r...@panix.com wrote: In article mailman.344.1357772847.2939.python-l...@python.org, Chris Angelico ros...@gmail.com wrote: On Thu, Jan 10, 2013 at 9:54 AM, Roy Smith r...@panix.com wrote: What's weird is that two of the servers, and only those two, stick a BOM (Byte Order Mark) in front of the message they log. Could it be this issue you're looking at? http://bugs.python.org/issue14452 What are the exact Python versions in use? Are the two different servers running an older revision of Py 2.7? ChrisA It sounds like it might be it, but we're running 2.7.3 on all machines. Well, this is fascinating. It turns out that while all of our machines report that they're running 2.7.3, they have two different versions of /usr/lib/python2.7/logging/handlers.py! -rw-r--r-- 1 root root 45076 Aug 1 05:39 /usr/lib/python2.7/logging/handlers.py -rw-r--r-- 1 root root 45143 Apr 20 2012 /usr/lib/python2.7/logging/handlers.py The April 24th version has the BOM code in SysLogHander.emit(): | # Message is a string. Convert to bytes as required by RFC 5424 |if type(msg) is unicode: |msg = msg.encode('utf-8') |if codecs: |msg = codecs.BOM_UTF8 + msg |msg = prio + msg and the August 1st version doesn't: |# Message is a string. Convert to bytes as required by RFC 5424 |if type(msg) is unicode: |msg = msg.encode('utf-8') |msg = prio + msg Is it possible there's two different 2.7.3 builds that somehow got packaged by Ubuntu at different times? The pattern of which machines have the August code and which have the April code correlates with when we rolled out each server instance. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why BOM in logging message?
On Fri, Jan 11, 2013 at 3:06 AM, Roy Smith r...@panix.com wrote: Well, this is fascinating. It turns out that while all of our machines report that they're running 2.7.3, they have two different versions of /usr/lib/python2.7/logging/handlers.py! -rw-r--r-- 1 root root 45076 Aug 1 05:39 /usr/lib/python2.7/logging/handlers.py -rw-r--r-- 1 root root 45143 Apr 20 2012 /usr/lib/python2.7/logging/handlers.py Ha, that would do it! I don't have a corresponding system to compare against, but what package is that file managed by? $ dpkg -S /usr/lib/python2.7/logging/handlers.py See if both systems show it as part of the same package, and if so, if the package is at the same version on each. On my Maverick desktop, I have 2.6, and the package is python2.6-minimal. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
problems importing from /usr/lib/pyshared/
Dear all, I recently upgraded my system from ubuntu 11.4 to 12.4 and since run into an issue when trying to import several packages in python2.7, e.g. harold@ubuntu:~$ python -c 'import gtk' Traceback (most recent call last): File string, line 1, in module File /usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py, line 30, in module import gobject as _gobject File /usr/share/pyshared/gobject/__init__.py, line 26, in module from glib import spawn_async, idle_add, timeout_add, timeout_add_seconds, \ File /usr/share/pyshared/glib/__init__.py, line 22, in module from glib._glib import * ImportError: No module named _glib the same, for example, with pysvn: harold@ubuntu:~$ python -c 'import pysvn' Traceback (most recent call last): File string, line 1, in module File /usr/share/pyshared/pysvn/__init__.py, line 99, in module import _pysvn_2_7 ImportError: No module named _pysvn_2_7 After playing around a bit, I realized that I can import said packages without problems, if I delete /usr/lib/pyshared from the python path: import sys sys.path ['', '/usr/share/pyshared', '/home/harold', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/PIL', '/usr/lib/python2.7/dist-packages/gst-0.10', '/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/python2.7/dist-packages/ubuntu-sso-client', '/usr/lib/python2.7/dist-packages/ubuntuone-client', '/usr/lib/python2.7/dist-packages/ubuntuone-control-panel', '/usr/lib/python2.7/dist-packages/ubuntuone-couch', '/usr/lib/python2.7/dist-packages/ubuntuone-installer', '/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol', '/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode'] del sys.path[1] import gtk import pysvn Is /usr/lib/pyshared supposed to be in the python path? If not, how can I ensure that it is not included? Where is PYTHONPATH initialized by default, anyway? Thanks, harold. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why BOM in logging message?
On Fri, Jan 11, 2013 at 3:06 AM, Roy Smith r...@panix.com wrote: -rw-r--r-- 1 root root 45076 Aug 1 05:39 /usr/lib/python2.7/logging/handlers.py -rw-r--r-- 1 root root 45143 Apr 20 2012 /usr/lib/python2.7/logging/handlers.py Chris Angelico ros...@gmail.com wrote: $ dpkg -S /usr/lib/python2.7/logging/handlers.py Yup, on some machines we've got 2.7.3-0ubuntu3, and on others, 2.7.3-0ubuntu3.1 of python2.7-minimal. Details at: https://launchpad.net/ubuntu/+source/python2.7/2.7.3-0ubuntu3.1 Well, I guess today is dist-upgrade day :-) -- http://mail.python.org/mailman/listinfo/python-list
Re: Why BOM in logging message?
On Fri, Jan 11, 2013 at 3:40 AM, Roy Smith r...@panix.com wrote: On Fri, Jan 11, 2013 at 3:06 AM, Roy Smith r...@panix.com wrote: -rw-r--r-- 1 root root 45076 Aug 1 05:39 /usr/lib/python2.7/logging/handlers.py -rw-r--r-- 1 root root 45143 Apr 20 2012 /usr/lib/python2.7/logging/handlers.py Chris Angelico ros...@gmail.com wrote: $ dpkg -S /usr/lib/python2.7/logging/handlers.py Yup, on some machines we've got 2.7.3-0ubuntu3, and on others, 2.7.3-0ubuntu3.1 of python2.7-minimal. Details at: https://launchpad.net/ubuntu/+source/python2.7/2.7.3-0ubuntu3.1 I love it when everything adds up! The message even cites the specific change. It's like a cryptic crossword - once you get the answer, you KNOW it's the answer because suddenly it all makes sense :) Thanks for bringing a fun problem to solve! It's (unfortunately) a refreshing change to read a post from someone who knows how to ask smart questions. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
average time calculation??
Hi there guys i've got a script that's suppose to find the average of two times as strings. The times are in minutes:seconds:milliseconds i'm doing ok in printing the right minutes and seconds my problem is with the milliseconds. Example if i have 00:02:20 and 00:04:40 the average will be 00:03:30 or 00:02:00 and 00:03:00 will be 00:02:30 Can anyone help me out with this please. Here is the code that i have so far: def lap_average(lap1, lap2): t1 = lap1.replace(:,'') t2 = lap2.replace(:,'') mins1, secs1, hundreths1 = t1[:2], t1[2:4], t1[4:] mins2, secs2, hundreths2 = t2[:2], t2[2:4], t2[4:] total_seconds = int(secs1) + int(secs2) + int(mins1) * 60 + int(mins2) * 60 millisec = (total_seconds * 1000) millisec = millisec / 2 micro_x = millisec minutes = micro_x / (60*1000) micro_x = micro_x - minutes * (60*1000) seconds = micro_x / 1000 micro_x = micro_x - seconds print '%02d:%02d:%s' % (minutes, seconds, micro_x) lap_average('03:40:00', '05:20:00') lap_average('03:00:02', '02:00:00') lap_average('02:25:50', '06:50:75') lap_average('00:02:00', '00:03:00') lap_average('00:02:20', '00:04:40') lap_average('02:40:40', '03:30:30') lap_average('02:60:30', '60:40:40') Thanks in Advance -- http://mail.python.org/mailman/listinfo/python-list
Re: average time calculation??
On 10 January 2013 17:50, pmec pcura...@gmail.com wrote: Hi there guys i've got a script that's suppose to find the average of two times as strings. The times are in minutes:seconds:milliseconds i'm doing ok in printing the right minutes and seconds my problem is with the milliseconds. You might find it easier to do this arithmetic if using datetime.time objects from the datetime module: http://docs.python.org/2/library/datetime.html Example if i have 00:02:20 and 00:04:40 the average will be 00:03:30 or 00:02:00 and 00:03:00 will be 00:02:30 Can anyone help me out with this please. Here is the code that i have so far: def lap_average(lap1, lap2): t1 = lap1.replace(:,'') t2 = lap2.replace(:,'') mins1, secs1, hundreths1 = t1[:2], t1[2:4], t1[4:] mins2, secs2, hundreths2 = t2[:2], t2[2:4], t2[4:] Are these really hundredths? At the top you said it goes minutes:seconds:milliseconds. A hundredth of a second is 10 milliseconds so you need to be clear about which one you want. total_seconds = int(secs1) + int(secs2) + int(mins1) * 60 + int(mins2) * 60 What happened to the hundredths in the line above. Surely you wanted to add 0.01 * hundredths there. millisec = (total_seconds * 1000) millisec = millisec / 2 In Python 2 this division will always round down if millisec is an integer. Is that what you want? micro_x = millisec Is the line above just there to confuse me? I thought millisec was a good descriptive name. In this context micro would suggest microseconds which would be 1000 times smaller. minutes = micro_x / (60*1000) Wouldn't it have been easier to just get this from total_seconds? micro_x = micro_x - minutes * (60*1000) seconds = micro_x / 1000 This will behave differently in Python 3. Safest to use floor division // here: http://stackoverflow.com/questions/183853/in-python-what-is-the-difference-between-and-when-used-for-division micro_x = micro_x - seconds Surely that should be seconds*1000? print '%02d:%02d:%s' % (minutes, seconds, micro_x) Until your done debugging, I suggest you print all of these values out directly (without the format string): print(minutes, seconds, microx) lap_average('03:40:00', '05:20:00') lap_average('03:00:02', '02:00:00') lap_average('02:25:50', '06:50:75') lap_average('00:02:00', '00:03:00') lap_average('00:02:20', '00:04:40') lap_average('02:40:40', '03:30:30') lap_average('02:60:30', '60:40:40') Oscar -- http://mail.python.org/mailman/listinfo/python-list
Re: average time calculation??
Two quick corrections to what I wrote... On 10 January 2013 18:13, Oscar Benjamin oscar.j.benja...@gmail.com wrote: On 10 January 2013 17:50, pmec pcura...@gmail.com wrote: Hi there guys i've got a script that's suppose to find the average of two times as strings. The times are in minutes:seconds:milliseconds i'm doing ok in printing the right minutes and seconds my problem is with the milliseconds. You might find it easier to do this arithmetic if using datetime.time objects from the datetime module: http://docs.python.org/2/library/datetime.html Actually I meant datetime.timedelta objects. Example if i have 00:02:20 and 00:04:40 the average will be 00:03:30 or 00:02:00 and 00:03:00 will be 00:02:30 Can anyone help me out with this please. Here is the code that i have so far: def lap_average(lap1, lap2): t1 = lap1.replace(:,'') t2 = lap2.replace(:,'') mins1, secs1, hundreths1 = t1[:2], t1[2:4], t1[4:] mins2, secs2, hundreths2 = t2[:2], t2[2:4], t2[4:] Are these really hundredths? At the top you said it goes minutes:seconds:milliseconds. A hundredth of a second is 10 milliseconds so you need to be clear about which one you want. total_seconds = int(secs1) + int(secs2) + int(mins1) * 60 + int(mins2) * 60 What happened to the hundredths in the line above. Surely you wanted to add 0.01 * hundredths there. millisec = (total_seconds * 1000) millisec = millisec / 2 In Python 2 this division will always round down if millisec is an integer. Is that what you want? micro_x = millisec Is the line above just there to confuse me? I thought millisec was a good descriptive name. In this context micro would suggest microseconds which would be 1000 times smaller. minutes = micro_x / (60*1000) Wouldn't it have been easier to just get this from total_seconds? micro_x = micro_x - minutes * (60*1000) seconds = micro_x / 1000 This will behave differently in Python 3. Safest to use floor division // here: http://stackoverflow.com/questions/183853/in-python-what-is-the-difference-between-and-when-used-for-division micro_x = micro_x - seconds Surely that should be seconds*1000? print '%02d:%02d:%s' % (minutes, seconds, micro_x) micro_x is in units of microseconds. Did you want microseconds or hundredths of a second here in the output? Until your done debugging, I suggest you print all of these values out directly (without the format string): print(minutes, seconds, microx) lap_average('03:40:00', '05:20:00') lap_average('03:00:02', '02:00:00') lap_average('02:25:50', '06:50:75') lap_average('00:02:00', '00:03:00') lap_average('00:02:20', '00:04:40') lap_average('02:40:40', '03:30:30') lap_average('02:60:30', '60:40:40') Oscar -- http://mail.python.org/mailman/listinfo/python-list
Re: average time calculation??
On 2013-01-10 17:50, pmec wrote: Hi there guys i've got a script that's suppose to find the average of two times as strings. The times are in minutes:seconds:milliseconds i'm doing ok in printing the right minutes and seconds my problem is with the milliseconds. Example if i have 00:02:20 and 00:04:40 the average will be 00:03:30 or 00:02:00 and 00:03:00 will be 00:02:30 If the final 2 digits are milliseconds, then the second average would be 00:02:500; if they're centiseconds (hundredths of a second), then the second average would be 00:02:50. If the average you give is correct ('00:02:30'), then that suggests that they are in fact hours:minutes:seconds. Can anyone help me out with this please. Here is the code that i have so far: def lap_average(lap1, lap2): t1 = lap1.replace(:,'') t2 = lap2.replace(:,'') mins1, secs1, hundreths1 = t1[:2], t1[2:4], t1[4:] mins2, secs2, hundreths2 = t2[:2], t2[2:4], t2[4:] total_seconds = int(secs1) + int(secs2) + int(mins1) * 60 + int(mins2) * 60 millisec = (total_seconds * 1000) millisec = millisec / 2 micro_x = millisec minutes = micro_x / (60*1000) micro_x = micro_x - minutes * (60*1000) seconds = micro_x / 1000 micro_x = micro_x - seconds print '%02d:%02d:%s' % (minutes, seconds, micro_x) lap_average('03:40:00', '05:20:00') lap_average('03:00:02', '02:00:00') lap_average('02:25:50', '06:50:75') lap_average('00:02:00', '00:03:00') lap_average('00:02:20', '00:04:40') lap_average('02:40:40', '03:30:30') lap_average('02:60:30', '60:40:40') Thanks in Advance I don't see the point of these 2 lines of removing the ':'; slice 'lap1' and 'lap2' instead: mins1, secs1, hundreths1 = lap1[:2], lap1[3:5], lap1[6:] mins2, secs2, hundreths2 = lap2[:2], lap2[3:5], lap2[6:] Better yet, split on ':': mins1, secs1, hundreths1 = lap1.split(':') mins2, secs2, hundreths2 = lap2.split(':') Incidentally, you're talking about milliseconds, but the names say 'hundreths'. A useful function is 'divmod', which, as its name suggests, performs both (integer) division and modulo in one step: seconds, millisec = divmod(millisec, 1000) minutes, seconds = divmod(seconds, 60) -- http://mail.python.org/mailman/listinfo/python-list
How to change colors of multiple widgets after hovering in Tkinter
Hello, I´m trying to make a script, which will change the background and foreground color of widgets after hovering. - from Tkinter import * root=Tk() Hover1=Button(root,text=Red color, bg=white) Hover1.pack() Hover2=Button(root,text=Yellow color, bg=white) Hover2.pack() Hover1.bind(Enter,Hover1.configure(bg=red)) Hover1.bind(Leave,Hover1.configure(bg=white)) Hover2.bind(Enter,Hover2.configure(bg=yellow)) Hover2.bind(Leave,Hover2.configure(bg=white)) root.mainloop() - but when I hover on any button, nothing happens, they stay white. I know I could use a function, but there would be two functions for every widget (1 for , 1 for ). I'd like to create a single function, which will recolor that widget I hover on and explain why this script is not doing what I want it to do. I hope I described my problem well. Thanks for every answer. PS: I would like to avoid classes. mountDoom -- http://mail.python.org/mailman/listinfo/python-list
Re: [Tutor] How to run multiline shell command within python
On 10/01/2013 16:21, Matty Sarro wrote: Have you looked a the pexpect class? It works like gangbusters, especially if you're trying to run something with an interactive shell. http://www.noah.org/wiki/pexpect On Thu, Jan 10, 2013 at 9:25 AM, Karim kliat...@gmail.com mailto:kliat...@gmail.com wrote: On 10/01/2013 09:31, Hugo Arts wrote: On Thu, Jan 10, 2013 at 7:01 AM, Karim kliat...@gmail.com mailto:kliat...@gmail.com wrote: Hello all, I want to run multiline shell command within python without using a command file but directly execute several lines of shell. I already use *subprocess.checkoutput(csh -f my_file.csh.split())* but I want to know if it is posssible to avoid making file and execute shell lines of code directly. Yes, this is very possible. Specify shell=True as an argument and you can do anything you can do in a shell: commands = echo hello ... echo hello | wc -l ... ps aux | grep python b = subprocess.check_output(commands, shell=True) print(b.decode('ascii')) hello 1 hugo 1255 1.0 0.6 777316 49924 ? Sl 09:14 0:08 /usr/bin/python2 /usr/bi hugo 6529 0.0 0.0 42408 7196 pts/0S+ 09:23 0:00 python hugo 6559 0.0 0.0 10656 1128 pts/0S+ 09:28 0:00 grep python watch out though, accepting user input into the commands variable will lead to shell injection, which can be a dangerous security vulnerability. HTH, Hugo Many thanks Hugo. It makes my day! In my case there are no possibilities for shell injection. It is internal to a class. Regards Karim -- http://mail.python.org/mailman/listinfo/python-list Thanks Matty! I will have a look specially for interactive session. Regards Karim -- http://mail.python.org/mailman/listinfo/python-list
Re: How to change colors of multiple widgets after hovering in Tkinter
mountdoo...@gmail.com wrote: I´m trying to make a script, which will change the background and foreground color of widgets after hovering. but when I hover on any button, nothing happens, they stay white. I know I could use a function, but there would be two functions for every widget (1 for , 1 for ). I'd like to create a single function, which will recolor that widget I hover on and explain why this script is not doing what I want it to do. I hope I described my problem well. You did. from Tkinter import * root=Tk() Hover1=Button(root,text=Red color, bg=white) Hover1.pack() Hover2=Button(root,text=Yellow color, bg=white) Hover2.pack() Hover1.bind(Enter,Hover1.configure(bg=red)) This calls Hover1.configure(bg=red) once and binds the result of that method call (which is None) to the event. So the above line is equivalent to Hover1.configure(bg=red) Hover1.bind(Enter, None) You say you don't want to write a function, but that is really the correct aproach. Fortunately there is a way to create such a function on the fly: def f(event): Hover1.configure(bg=red) can be written as f = lambda event: Hover1.configure(bg=red) With that your code becomes Hover1.bind(Enter, lambda event: Hover1.configure(bg=red)) Hover1.bind(Leave, lambda event: Hover1.configure(bg=white)) and so on. In this specific case this doesn't have the desired effect because when the mouse enters a Button widget its background color changes to 'activebackground'. So you don't really need to bind the enter/leave events. Specify an activebackground instead when you create the buttons. For example: Hover1 = Button(root, text=Red color, bg=white, activebackground=red) Hover1.pack() -- http://mail.python.org/mailman/listinfo/python-list
Re: RIse and fall of languages in 2012
On 01/10/2013 12:23 AM, Steven D'Aprano wrote: In general-purpose scripting languages, Python continues to grow slowly, JavaScript and Ruby are treading water, and Perl continues its long decline. According to Google trends, the number of searches for Perl is 19% of what it was in 2004. Its declining role in open-source communities further cements the perception that it's in an irretrievable tailspin. One should always be careful pronouncing a language dead or dying, because rare resurrections have occurred: JavaScript and Objective-C being two stand-out cases. However, Perl is unlikely to see such a new lease on life because of direct competition from Python, which is considerably more popular (whereas Objective-C and JavaScript had no direct equivalents when they came back). http://www.drdobbs.com/jvm/the-rise-and-fall-of-languages-in-2012/240145800 And from the TIOBE Index, Python is steady at number 8: http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html The TIOBE index is meaningless. Since it's based on google searches, one could probably guess that any language that is awkward and difficult will require more searches to figure out how to use the thing. Thus of course C is top! Especially if ranked by sarcastic queries like, C sucks, and why does C suck so much. Javascript is doing much more than just treading water. Javascript may not be glamorous but it is *the* glue that makes the web run. Funny to see such a reputable journal make such an absurd statement. I can buy that Perl is in a slow decline. Certainly I'd use Python for the same tasks that people used to use Perl for. In short I see no rise and fall of languages in 2012. Seems like business as usual, and the usual suspects continue to get steady use. -- http://mail.python.org/mailman/listinfo/python-list
Re: average time calculation??
Hi Oscar, Thank you for your reply, and you are absolutely right, I meant hundredths of a second to be outputed -- http://mail.python.org/mailman/listinfo/python-list
Re: average time calculation??
Hi Oscar, again I do apologize for my beginner mistakes, I've changed the code taking in consideration some of your and MRAB suggestions. Could you give me an example on how could I use the datetime.timedelta function in this particular case. This is my code: def lap_average(lap1, lap2): mins1, secs1, hundreths1 = lap1.split(:) mins2, secs2, hundreths2 = lap2.split(:) minutes = int(mins1) + int(mins2) seconds = float(secs1) + float(secs2) hundredths = int(6 * minutes + 1000 * seconds) hundredths = hundredths // 2 print hundredths lap_average('03:40:00', '05:20:00') lap_average('03:00:02', '02:00:00') lap_average('02:25:50', '06:50:75') lap_average('00:02:00', '00:03:00') #should output: 00:02:50 lap_average('00:02:20', '00:04:40') # 00:03:30 lap_average('02:40:40', '03:30:30') # etc lap_average('02:60:30', '60:40:40') Also I was a bit confused with what you said about : total_seconds = int(secs1) + int(secs2) + int(mins1) * 60 + int(mins2) * 60 What happened to the hundredths in the line above. Surely you wanted to add 0.01 * hundredths there. I thought the above was already the entire time as hundredths of second?? -- http://mail.python.org/mailman/listinfo/python-list
Organic Chemistry, 8th Ed by Wade, Jan Simek
I have solutions manuals to all problems and exercises in these textbooks. To get one in an electronic format contact me at: kalvinmanual(at)gmail(dot)com and let me know its title, author and edition. Please this service is NOT free. instructor's solutions manual to OpenScape Voice V3.1R3 Test Configuration and connectivity Vol 2 , Application and Hardware Configuratio instructor's solutions manual to Operating System Concepts, 6E, Silberschatz, Galvin, Gagne instructor's solutions manual to Operating System Concepts, 7E, Silberschatz, Galvin, Gagne instructor's solutions manual to Operating systems Internals and Design principles 4th Edition Stallings instructor's solutions manual to Operating systems Internals and Design principles 5th Edition Stallings instructor's solutions manual to Operations Management 5th Ed by Nigel Slack, Chambers, Johnston instructor's solutions manual to Optical Fiber Communications 3rd E by Gerd Keiser instructor's solutions manual to Optical Properties of Solids 2nd Ed by Mark Fox instructor's solutions manual to Optics 4th Edition by Hecht E., Coffey M., Dolan P instructor's solutions manual to Optimal Control Theory An Introduction By Donald E. Kirk instructor's solutions manual to Optimal State Estimation Dan Simon instructor's solutions manual to Optimization of Chemical Processes by Edgar instructor's solutions manual to Options, Futures and Other Derivatives, 4E, by John Hull instructor's solutions manual to Options, Futures and Other Derivatives, 5E, by John Hull instructor's solutions manual to Options, Futures, and Other Derivatives 7th Ed by John C. Hull instructor's solutions manual to Orbital Mechanics for Engineering Students 2nd ED by Curtis instructor's solutions manual to Orbital Mechanics for Engineering Students by Curtis instructor's solutions manual to ORDINARY DIFFERENTIAL EQUATIONS by Adkins, Davidson instructor's solutions manual to Organic Chemistry - Clayden et.al. instructor's solutions manual to Organic Chemistry 2nd ed by Schore instructor's solutions manual to Organic Chemistry 2nd Edition by Hornback instructor's solutions manual to Organic Chemistry 5th Ed by Brown, Foote, Iverson, Ansyln instructor's solutions manual to Organic Chemistry 7ed, McMurry instructor's solutions manual to Organic Chemistry, 4E., by Carey, Atkins instructor's solutions manual to Organic Chemistry, 5E., by Carey, Atkins instructor's solutions manual to Organic Chemistry, 6 Ed by Wade, Jan Simek instructor's solutions manual to Organic Chemistry, 8th Ed by Wade, Jan Simek instructor's solutions manual to Parallel Distributed Computation Numerical Methods by Bertsekas Tsitsiklis instructor's solutions manual to Parallel Programming: Techniques and Applications Using Networked Workstations and Parallel Computers (2nd Ed., Barry Wilkinson Michael Allen) instructor's solutions manual to PARTIAL DIFFERENTIAL EQUATIONS WITH FOURIER SERIES and BOUNDARY VALUE PROBLEMS 2nd Edition by NAKHLE H. ASMAR (Students Solutions Manual) instructor's solutions manual to Physical Basis of Biochemistry 2nd Ed by Bergethon, Hallock instructor's solutions manual to Physical Chemistry (7E, Peter Atkins Julio de Paula) instructor's solutions manual to Physical Chemistry by Prem Dhawan instructor's solutions manual to Physical Chemistry by Thomas Engel Philip Reid instructor's solutions manual to Physics - Concept and Connections - Book Two by Brian Heimbecker, Igor Nowikow, et al instructor's solutions manual to Physics - Concept and Connections -by Brian Heimbecker, Igor Nowikow, et al instructor's solutions manual to Physics - Principles and Problems instructor's solutions manual to Physics - Principles and Problems ( Glencoe ) instructor's solutions manual to Physics , Fifth Edition, Volume One (Halliday, Resnick, Krane) instructor's solutions manual to Physics 7th ed by Paul E. Tippens instructor's solutions manual to Physics 8 ED by Cutnell Johnsen instructor's solutions manual to Physics for Scientist and Engineers, 5E, by Tipler, Mosca instructor's solutions manual to Physics For Scientists Engineers 5th Ed (vol.I,vol.II) by Serway Beichner instructor's solutions manual to Physics For Scientists Engineers 7th Ed. by Serway Jewett instructor's solutions manual to Physics For Scientists Engineers Vol.1 2 3rd Ed. by Serway Jewett instructor's solutions manual to Physics For Scientists Engineers Vol.1 2 4th Ed. by Serway Jewett instructor's solutions manual to Physics For Scientists Engineers Vol.I 6th Ed. by Serway Jewett instructor's solutions manual to Physics For Scientists Engineers Vol.II 6th Ed. by Serway Jewett instructor's solutions manual to Physics for Scientists Engineers with Modern Physics 4th E by Douglas Giancoli instructor's solutions manual to Physics For Scientists and Engineers 8th ed VOL.1 by Gordon, McGrew, Serway ( student solutions manual and study guide ) instructor's solutions manual to Physics for
Re: average time calculation??
On Thu, Jan 10, 2013 at 1:31 PM, pmec pcura...@gmail.com wrote: Hi Oscar, again I do apologize for my beginner mistakes, I've changed the code taking in consideration some of your and MRAB suggestions. Could you give me an example on how could I use the datetime.timedelta function in this particular case. td1 = timedelta(minutes=mins1, seconds=secs1, milliseconds=hundredths1*10) td2 = timedelta(minutes=mins2, seconds=secs2, milliseconds=hundredths2*10) average = (td1 + td2) / 2 mins, secs = divmod(average.seconds, 60) hundredths = average.microseconds // 1 print({:02d}:{:02d}:{:02d}.format(mins, secs, hundredths)) -- http://mail.python.org/mailman/listinfo/python-list
Re: RIse and fall of languages in 2012
On Wednesday, January 9, 2013 11:23:51 PM UTC-8, Steven D'Aprano wrote: One should always be careful pronouncing a language dead or dying, No kidding! https://www.google.com/#q=is+fortran+still+used I usually use the query phrase Why isn't Fortran dead yet?, but you get a better list of links with a less biased phrase. -- http://mail.python.org/mailman/listinfo/python-list
Re: RIse and fall of languages in 2012
On Thu, 10 Jan 2013 12:42:49 -0700, Michael Torrie wrote: And from the TIOBE Index, Python is steady at number 8: http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html The TIOBE index is meaningless. Since it's based on google searches, one could probably guess that any language that is awkward and difficult will require more searches to figure out how to use the thing. Thus of course C is top! Especially if ranked by sarcastic queries like, C sucks, and why does C suck so much. If you have a problem with TIOBE's methodology, feel free to come up with your own. Or take it up with them. I dispute that TIOBE measures difficulty of language. If it did, Malbolge would likely be at the top of the list. Yes, there are sarcastic queries asking C sucks, but that's just measurement error: 21,200 hits for C sucks versus 9,900,000 for C programming. It's not as if there is any language, not even Python, that is so easy to use that nobody needs to write about it. Javascript is doing much more than just treading water. How do you know? What's *your* methodology for determining the popularity of a language? * But everybody knows that Javascript is super popular!!! * All my friends are using Javascript. * I'm a web developer, and I use Javascript for my day job. * I counted 14 job adverts on Monster.com for Javascript devs last week, what more evidence does anyone need? * I googled for `What's the most popular language?` and found a blog that says it's Javascript, that's good enough for me. * I have a gut feeling. If you are going to criticise TIOBE's methodology, and then make your own claims for language popularity, you really need to demonstrate that your methodology is better. Javascript may not be glamorous but it is *the* glue that makes the web run. And web development is a tiny fraction of all software development. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Why BOM in logging message?
On 1/10/2013 11:06 AM, Roy Smith wrote: Well, this is fascinating. It turns out that while all of our machines report that they're running 2.7.3, they have two different versions of /usr/lib/python2.7/logging/handlers.py! -rw-r--r-- 1 root root 45076 Aug 1 05:39 /usr/lib/python2.7/logging/handlers.py -rw-r--r-- 1 root root 45143 Apr 20 2012 /usr/lib/python2.7/logging/handlers.py The April 24th version has the BOM code in SysLogHander.emit(): The 'BOM' you are discussing here is not a true 2 or 4 byte byte-order-mark, but the pseudo-BOM (pseudo because a stream of single bytes has no byte order within the single bytes) that Micro$tupid adds (sometimes) to utf-8 encoded bytes to mark their encoding as utf-8 rather than anything else. In otherwords, it is a non-(anti-)standard U(nicode)E(ncoding)M(ark). It is actually the utf-8 encoding of the 2-byte BOM, and hence not a single mark! It is really confusing when people use 'BOM' to refer to a UEM sequence instead of a BOM. | # Message is a string. Convert to bytes as required by RFC 5424 |if type(msg) is unicode: |msg = msg.encode('utf-8') |if codecs: |msg = codecs.BOM_UTF8 + msg |msg = prio + msg 2.7.3 was released in April. and the August 1st version doesn't: |# Message is a string. Convert to bytes as required by RFC 5424 |if type(msg) is unicode: |msg = msg.encode('utf-8') |msg = prio + msg The issue referenced in an earlier messaged was to remove the UEM where it did not belong. Is it possible there's two different 2.7.3 builds that somehow got packaged by Ubuntu at different times? As you discovered, Ubuntu sometimes updates a release with bug patches before we release a new official bugfix release. 2.7.4, with many bugfixes, is still to see the light of day. The pattern of which machines have the August code and which have the April code correlates with when we rolled out each server instance. Great detective work ;-). -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: RIse and fall of languages in 2012
On Thu, 10 Jan 2013 07:23:51 +, Steven D'Aprano wrote: In general-purpose scripting languages, Python continues to grow slowly, JavaScript and Ruby are treading water, and Perl continues its long decline. According to Google trends, the number of searches for Perl is 19% of what it was in 2004. Its declining role in open-source communities further cements the perception that it's in an irretrievable tailspin. One should always be careful pronouncing a language dead or dying, because rare resurrections have occurred: JavaScript and Objective-C being two stand-out cases. However, Perl is unlikely to see such a new lease on life because of direct competition from Python, which is considerably more popular (whereas Objective-C and JavaScript had no direct equivalents when they came back). Why should we care? We use Python because it's powerful, easy, elegant and all the other things. -- http://mail.python.org/mailman/listinfo/python-list
Probabilistic unit tests?
Hi, I've got a unit test that will usually succeed but sometimes fails. An occasional failure is expected and fine. It's failing all the time I want to test for. What I want to test is on average, there are the same number of males and females in a sample, give or take 2%. Here's the unit test code: import unittest from collections import counter sex_count = Counter() for contact in range(self.binary_check_sample_size): p = get_record_as_dict() sex_count[p['Sex']] += 1 self.assertAlmostEqual(sex_count['male'], sex_count['female'], delta=sample_size * 2.0 / 100.0) My question is: how would you run an identical test 5 times and pass the group *as a whole* if only one or two iterations passed the test? Something like: for n in range(5): # self.assertAlmostEqual(...) # if test passed: break else: self.fail() (except that would create 5+1 tests as written!) Thanks for any thoughts, Best wishes, Nick -- http://mail.python.org/mailman/listinfo/python-list
Re: Probabilistic unit tests?
In article b312f3e7-5c73-486e-925e-da8343963...@googlegroups.com, Nick Mellor thebalance...@gmail.com wrote: Hi, I've got a unit test that will usually succeed but sometimes fails. An occasional failure is expected and fine. It's failing all the time I want to test for. What I want to test is on average, there are the same number of males and females in a sample, give or take 2%. [...] My question is: how would you run an identical test 5 times and pass the group *as a whole* if only one or two iterations passed the test? Something like: for n in range(5): # self.assertAlmostEqual(...) # if test passed: break else: self.fail() I would do something like: def do_test_body(): Returns 1 if it passes, 0 if it fails results = [do_test() for n in range(number_of_trials)] self.assert(sum(results) threshold) That's the simple part. The more complicated part is figuring out how many times to run the test and what an appropriate threshold is. For that, you need to talk to a statistician. -- http://mail.python.org/mailman/listinfo/python-list
Re: Probabilistic unit tests?
On Thu, 10 Jan 2013 17:59:05 -0800, Nick Mellor wrote: Hi, I've got a unit test that will usually succeed but sometimes fails. An occasional failure is expected and fine. It's failing all the time I want to test for. Well, that's not really a task for unit testing. Unit tests, like most tests, are well suited to deterministic tests, but not really to probabilistic testing. As far as I know, there aren't really any good frameworks for probabilistic testing, so you're stuck with inventing your own. (Possibly on top of unittest.) What I want to test is on average, there are the same number of males and females in a sample, give or take 2%. Here's the unit test code: import unittest from collections import counter sex_count = Counter() for contact in range(self.binary_check_sample_size): p = get_record_as_dict() sex_count[p['Sex']] += 1 self.assertAlmostEqual(sex_count['male'], sex_count['female'], delta=sample_size * 2.0 / 100.0) That's a cheap and easy way to almost get what you want, or at least what I think you should want. Rather than a Succeed/Fail boolean test result, I think it is worth producing a float between 0 and 1 inclusive, where 0 is definitely failed and 1 is definitely passed, and intermediate values reflect some sort of fuzzy logic score. In your case, you might look at the ratio of males to females. If the ratio is exactly 1, the fuzzy score would be 1.0 (definitely passed), otherwise as the ratio gets further away from 1, the score would approach 0.0: if males = females: score = males/females else: score = females/males should do it. Finally you probabilistic-test framework could then either report the score itself, or decide on a cut-off value below which you turn it into a unittest failure. That's still not quite right though. To be accurate, you're getting into the realm of hypotheses testing and conditional probabilities: - if these random samples of males and females came from a population of equal numbers of each, what is the probability I could have got the result I did? - should I reject the hypothesis that the samples came from a population with equal numbers of males and females? Talk to a statistician on how to do this. My question is: how would you run an identical test 5 times and pass the group *as a whole* if only one or two iterations passed the test? Something like: for n in range(5): # self.assertAlmostEqual(...) # if test passed: break else: self.fail() (except that would create 5+1 tests as written!) Simple -- don't use assertAlmostEqual, or any other of the unittest assertSomething methods. Write your own function to decide whether or not something passed, then count how many times it passed: count = 0 for n in range(5): count += self.run_some_test() # returns 0 or 1, or a fuzzy score if count some_cut_off: self.fail() -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: How to modify this script?
Kurt wrote: Spooky behavior. Yes, the green-apple-example also works for me with your new script, BUT ...! Try to copy the table content on this page: http://www.danacord.dk/frmsets/records/732-r.html which is a realistic scenario. That's whar I am doing these days. Pasting it into Gedit and running the snippet blanks the edit area (on MY Mac at least). And yes: I have pasted your code excatly and I've double-checked for linewraps. Everything is okay. Chaouche replied: Indeed, the console shows a traceback where data is misinterpreted, maybe due to my triple protective quotes around $GEDIT_SELECTED_TEXT. Try without them, like so (it worked for me) : Yes!!! :-) Of course it would be nice if the script could be developed to take into account some of the antics I have made in my tables over the years, but with this script the basic codes of rows and columns is formatted properly; refinements of some collapsed fields with with line breaks a.o. is up to me now ;-). Thanks to you and others who have participated in this thread. -- Venlig hilsen Kurt Hansen -- http://mail.python.org/mailman/listinfo/python-list
Re: RIse and fall of languages in 2012
At one point or another I'm pretty sure I've googled _ sucks for every language I've ever used- even the ones I like. ie: Python easily more than once. Craig reporting from the road 10550 N Torrey Pines Rd La Jolla CA 92037 work: 858 784 9208 cell: 619 623 2233 On Jan 10, 2013, at 3:32 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Thu, 10 Jan 2013 12:42:49 -0700, Michael Torrie wrote: And from the TIOBE Index, Python is steady at number 8: http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html The TIOBE index is meaningless. Since it's based on google searches, one could probably guess that any language that is awkward and difficult will require more searches to figure out how to use the thing. Thus of course C is top! Especially if ranked by sarcastic queries like, C sucks, and why does C suck so much. If you have a problem with TIOBE's methodology, feel free to come up with your own. Or take it up with them. I dispute that TIOBE measures difficulty of language. If it did, Malbolge would likely be at the top of the list. Yes, there are sarcastic queries asking C sucks, but that's just measurement error: 21,200 hits for C sucks versus 9,900,000 for C programming. It's not as if there is any language, not even Python, that is so easy to use that nobody needs to write about it. Javascript is doing much more than just treading water. How do you know? What's *your* methodology for determining the popularity of a language? * But everybody knows that Javascript is super popular!!! * All my friends are using Javascript. * I'm a web developer, and I use Javascript for my day job. * I counted 14 job adverts on Monster.com for Javascript devs last week, what more evidence does anyone need? * I googled for `What's the most popular language?` and found a blog that says it's Javascript, that's good enough for me. * I have a gut feeling. If you are going to criticise TIOBE's methodology, and then make your own claims for language popularity, you really need to demonstrate that your methodology is better. Javascript may not be glamorous but it is *the* glue that makes the web run. And web development is a tiny fraction of all software development. -- Steven -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Over 30 types of variables available in python ?
On 1-7-2013 2:53:26 AM UTC-6, chaouche yacine wrote: Thanks for all your comments. It appears to me that there is a slight confusion between types and classes then, plus other entities (protocols ?) The only confusion stems from improper terminology. Class is the worst possible word to describe: /the code written by a programmer to define an object/. This epidemic of transforming words improperly is not only a python problem (as you well know). I believe it is high time we stop designing languages by propagating foolish terminology simply because we have no will to break the status quo. And everybody needs to help push this cause along by refusing to use the word class and only use the words object definition. This is something we can all do WITHOUT modifying the python source. This is how you get the snowball rolling. However, if we do this for long enough, language designers will start to realize that class is NOT the proper terminology and MAYBE they will consider terminology a bit more. Well, a boy can dream... We MUST separate the idea of: an object that lives in memory from the: code that defines the object AND we must do so by wielding intuitive terminology. Just because person X decides to jump off a bridge, that action does not impose person Y to blindly follow -- http://mail.python.org/mailman/listinfo/python-list
Re: How to change colors of multiple widgets after hovering in Tkinter
On Thursday, January 10, 2013 1:13:38 PM UTC-6, Peter Otten wrote: mountdoom wrote: I´m trying to make a script, which will change the background and foreground color of widgets after hovering. Peter's advice is spot on except you may want ALL widgets to change colors on ENTER and LEAVE events. If you want all widgets use the w.bind_all method instead of w.bind. Also check out the w.bind_class method to confine bindings to one particular class of widget (like a Tkinter.Button). -- http://mail.python.org/mailman/listinfo/python-list
PyWart: Module access syntax
Python's module/package access uses dot notation. mod1.mod2.mod3.modN Like many warts of the language, this wart is not so apparent when first learning the language. The dot seems innocently sufficient, however, in truth it is woefully inadequate! Observe: name1.name2.name3.name4.name5 Can you tell me which names are modules, which are classes, and which are methods/functions? Wait, i know the argument you'll use: I can decipher from spelling! Modules use all lowercase, classes use initial uppercase, and methods use words_sep_by_underscore. I'm so smart! Indeed. But that's only *_IF_* everybody used the same style guide. And as we know many people don't follow the style guide (not to mention the style guide has issues!) And since style is NOT enforced, we suffer the unintuitive syntax nightmare! The solution is obvious by using proper syntax. import lib:gui:tkinter:dialogs.SimpleDialog as Blah You /could/ use two colons: import lib::gui::tkinter::dialogs.SimpleDialog as Blah ...and i think this syntax does help to separate the identifiers more clearly, but since these imports can be quite long, i prefer the single colon myself. -- http://mail.python.org/mailman/listinfo/python-list
PyWart: Import resolution order
Python's import resolution order is terrible.[1] The fact that Python looks in the stdlib _first_ is not a good idea. It would seem more intuitive for a custom math module (living in the current directory) to /override/ the stlib math module. The proper order is as follows: 1. Current package or directory 2. stdlib 3. under the bed 4. who cares at this point Look, if you want to keep you foolish imports starting from the stdlib, fine, just create a switch so we can change it to package/directory if we like. If /only/ the Python gods had placed all stdlib modules in a package named, i don't know, lib then none of this would be an issue. You could happily have a stdlib::math and a mylib::math, and when you import either module your code will reflect that path explicitly. Hmm, this last sentence reminded me of something??? Oh yes - Explicit is better than implicit. [1]: Yes, yes, i know about sys.path.insert. *puke*! -- http://mail.python.org/mailman/listinfo/python-list
Re: PyWart: Import resolution order
On Fri, Jan 11, 2013 at 5:13 PM, Rick Johnson rantingrickjohn...@gmail.com wrote: The fact that Python looks in the stdlib _first_ is not a good idea. It would seem more intuitive for a custom math module (living in the current directory) to /override/ the stlib math module. The proper order is as follows: 1. Current package or directory 2. stdlib 3. under the bed 4. who cares at this point Why is it better to import from the current directory first? Windows has that policy for executable commands; Unix, on the other hand, requires that you put an explicit path for anything that isn't in the standard search path. Which of these options is the more likely to produce security holes and/or unexpected behaviour? Welcome back to the list, Rick. Got any demonstrable code for Python 4000 yet? ChrisA -- http://mail.python.org/mailman/listinfo/python-list
[issue16913] ElementTree tostring error when method='text'
Serhiy Storchaka added the comment: Can you please provide an example of data for which the tostring method fails? I can't reproduce this on simple data. import xml.etree.ElementTree as ET ET.tostring(ET.XML('rootbq/bwerty/root'), method='text', encoding='unicode') 'qwerty' -- nosy: +serhiy.storchaka ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16913 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6975] symlinks incorrectly resolved on POSIX platforms
Changes by Hynek Schlawack h...@ox.cx: -- title: symlinks incorrectly resolved on Linux - symlinks incorrectly resolved on POSIX platforms ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6975 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16913] ElementTree tostring error when method='text'
Serhiy Storchaka added the comment: I found such example. It happens when the data contains XML entity. ET.tostring(ET.XML('rootaamp;/root'), method='text', encoding='unicode') Traceback (most recent call last): File stdin, line 1, in module File /home/serhiy/py/cpython/Lib/xml/etree/ElementTree.py, line 1171, in tostring ElementTree(element).write(stream, encoding, method=method) File /home/serhiy/py/cpython/Lib/xml/etree/ElementTree.py, line 824, in write _serialize_text(write, self._root) File /home/serhiy/py/cpython/Lib/xml/etree/ElementTree.py, line 1057, in _serialize_text write(part) TypeError: string argument expected, got 'list' Indeed, itertext() returns a list of lists instead of list of strings. list(ET.XML('rootaamp;/root').itertext()) [['a', '']] The bug is in the C implementation of itertext(). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16913 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16909] urlparse: add userinfo attribute
Olof Johansson added the comment: Thank you for you feedback. I agree, the reason I wanted this was because of a corner case, but otoh, the username:password syntax is the real corner case imho. Of course, I understand that this must be supported for backwards compatability. (For fully RFC compliant URLs however, userinfo would be the same as user since : in userinfo isn't allowed, so again, you have a very valid point for your corner case argument.) The patch was developed against 2.7, so it won't apply on 3.4, but looking at 3.4, urlparse already has a _userinfo property method, but it splits the userinfo in a tuple of (username, password). It would be easy to adapt the change to 3.4, but I'll wait until I get additional feedback. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16909 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16913] ElementTree tostring error when method='text'
Frank added the comment: It happens whenever the method is called, regardless of input. I'm using HTML that has been tidied first with HTML entities (if any) converted to unicode values. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16913 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16912] Wrong float sum w/ 10.14+10.1 and 10.24+10.2
Changes by Mark Dickinson dicki...@gmail.com: -- nosy: +mark.dickinson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16912 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16913] ElementTree tostring error when method='text'
Frank added the comment: Scratch that, it happens whenever there are XML entities (lt;, quot; and friends) that are appearing the text as you pointed out. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16913 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16913] ElementTree tostring error when method='text'
Serhiy Storchaka added the comment: Here is a patch for 3.3+. 2.7 and 3.2 are not affected. -- keywords: +patch stage: needs patch - patch review versions: +Python 3.4 Added file: http://bugs.python.org/file28666/etree_itertext.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16913 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15948] Unchecked return value of I/O functions
Changes by Serhiy Storchaka storch...@gmail.com: -- stage: needs patch - patch review ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15948 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16894] Function attribute access doesn't invoke methods in dict subclasses
Changes by Daniel Urban urban.dani...@gmail.com: -- nosy: +daniel.urban ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16894 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16865] ctypes arrays =2GB in length causes exception
Amaury Forgeot d'Arc added the comment: In _ctypes.c there are (only!) two occurrences of the long type... both are related to ctypes arrays and look suspect. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16865 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16914] timestamping in smtplib.py to help troubleshoot server timeouts/delays
New submission from gac: I had cause to use smtplib to help me pinpoint why some outgoing mail was failing, but found that while it offered verbose logging (via debuglevel 1) this was without timestamps, making it difficult to make my case to the server operator that it was a server-side delay causing the issue. I've changed smtplib.py to add a second debugging level which includes timestamps down to microsecond granularity so that the debug log produced can pinpoint when a server isn't responding promptly. debuglevel 1 is unchanged, so anyone depending on the output from this being in a particular format won't be affected (either by setting debuglevel to 1 or true), but if debuglevel 2 is used explicitly then the standard output is preceded by a timestamp. -- components: Library (Lib) files: smtplib.py.patch keywords: patch messages: 179538 nosy: gac priority: normal severity: normal status: open title: timestamping in smtplib.py to help troubleshoot server timeouts/delays type: enhancement versions: Python 3.4 Added file: http://bugs.python.org/file28667/smtplib.py.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16914 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16874] setup.py upload option repeated in docs
Marek Šuppa added the comment: So what do you think should be done here? Just removing the or --repository= part? -- nosy: +mrshu ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16874 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16874] setup.py upload option repeated in docs
Berker Peksag added the comment: I think the problem is the usage of `:option:`. |:option:`--repository=url` or :option:`--repository=section`| should be written like |:option:`--repository=*url*` or :option:`--repository=*section*`| See: - http://hg.python.org/cpython/file/default/Doc/distutils/uploading.rst#l39 - http://hg.python.org/cpython/file/default/Doc/distutils/uploading.rst#l28 Patch attached. -- keywords: +patch nosy: +berker.peksag Added file: http://bugs.python.org/file28668/distutils-upload-markup.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16874 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16715] Get rid of IOError. Use OSError instead
Andrew Svetlov added the comment: It's not a typo. 1. LoadError is inherited from OSError so LoadError exception is also caught. 2. Pointed code just resets cookie state and reraises exception, exception type is saved. The code is correct from my perspective. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16715 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13198] Remove duplicate definition of write_record_file
Andrew Svetlov added the comment: Eric, if you want to keep distutils2 issues on the tracker for a while — I'm ok with that. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13198 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16915] mode of socket.makefile is more limited than documentation suggests
New submission from Antoon Pardon: The documentation of socket.makefile states that its arguments are interpreted the same way as by the built-in open() function. However the mode argument of socket.makefile only allows 'r', 'w' and 'b'. That some options are not allowed seems perfectly normal, like there being no use of an 'x' option but the documentation should probably reflect that. But I don't see why the 't' should cause trouble. If people can open a file explicitly in text mode, I don't see why it wouldn't be possible to explicitly ask for text mode in socket.makefile -- components: Library (Lib) messages: 179543 nosy: Antoon.Pardon priority: normal severity: normal status: open title: mode of socket.makefile is more limited than documentation suggests type: behavior versions: Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16915 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16076] xml.etree.ElementTree.Element is no longer pickleable
Roundup Robot added the comment: New changeset 8d6dadfecf22 by Eli Bendersky in branch '3.3': Issue #16076: make _elementtree.Element pickle-able in a way that is compatible http://hg.python.org/cpython/rev/8d6dadfecf22 New changeset 4c268b7c86e6 by Eli Bendersky in branch 'default': Issue #16076: make _elementtree.Element pickle-able in a way that is compatible http://hg.python.org/cpython/rev/4c268b7c86e6 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16076 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16917] Misleading missing parenthesis syntax error
New submission from Dražen Lučanin: When running this script: things = ['a', 'b'] things.append('c' for a in things: print a I get the following output: $ python script.py File script.py, line 3 for a in things: ^ SyntaxError: invalid syntax the SyntaxError is very misguiding. The error is in a missing parenthesis after the append call, but the error output points to the colon in the for loop. It got me looking for some invisible characters around the colon (which sometimes do pop up in my IPython notebook in OS X). Expected behaviour - the interpreter should warn me that I have an unmatched parenthesis or at least give some hint as to what possible tokens were expected instead of a colon to help me identify the faulty expression. It is hard to match all parentheses as it is, let alone when the error caused by them shows up in a different line pointing to a token of a different expression with a very vague description. -- components: Interpreter Core messages: 179547 nosy: kermit666 priority: normal severity: normal status: open title: Misleading missing parenthesis syntax error type: compile error versions: Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16917 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16916] The Extended Iterable Unpacking (PEP-3132) for byte strings doesn't match the specification
New submission from Marco Buttu: The PEP 3132 said: ... if seq is a slicable sequence, all the following assignments are equivalent if seq has at least three elements: a, b, c = seq[0], seq[1:-1], seq[-1] a, *b, c = seq [a, *b, c] = seq But this doesn't happen for byte strings: seq = b'xyz' a, b, c = seq[0], seq[1:-1], seq[-1] a, b, c (120, b'y', 122) a, *b, c = seq a, b, c (120, [121], 122) Tested on Python3.3 and Python3.2 (Linux Ubuntu 11.04) -- components: Interpreter Core messages: 179545 nosy: marco.buttu priority: normal severity: normal status: open title: The Extended Iterable Unpacking (PEP-3132) for byte strings doesn't match the specification type: behavior versions: Python 3.2, Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16916 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16076] xml.etree.ElementTree.Element is no longer pickleable
Eli Bendersky added the comment: Fixed in 3.3 and default. Thanks for the good work, Daniel. A separate issue can be opened for TreeBuilder. -- resolution: - fixed stage: needs patch - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16076 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16917] Misleading missing parenthesis syntax error
Changes by Dražen Lučanin kermit...@gmail.com: -- type: compile error - behavior ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16917 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16917] Misleading missing parenthesis syntax error
Ezio Melotti added the comment: The colon is the first invalid char, for example this is valid python and works: things = ['a', 'b'] things.append('c' ... for a in things) things ['a', 'b', generator object genexpr at 0xb76dacfc] In your case Python expects a genexp like things.append('c' for a in things), and when it finds the ':' it gives error. If you use e.g. a 'while', you will see the error earlier: things = ['a', 'b'] things.append('c' ... while True: File stdin, line 2 while True: ^ SyntaxError: invalid syntax -- nosy: +ezio.melotti resolution: - invalid stage: - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16917 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16917] Misleading missing parenthesis syntax error
Mark Dickinson added the comment: The error is in a missing parenthesis after the append call Well, that's one *possible* cause of the error. But fixing that missing parenthesis isn't the only way to make the code correct, and Python doesn't have any reasonable way to guess which of the various possible errors you made or what you intended to write. For example, the following is valid code: things = ['a', 'b'] things.append('c' for a in things) -- nosy: +mark.dickinson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16917 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16913] ElementTree tostring error when method='text'
Roundup Robot added the comment: New changeset d965ff47cf94 by Eli Bendersky in branch '3.3': Issue #16913: Fix Element.itertext()'s handling of text with XML entities. http://hg.python.org/cpython/rev/d965ff47cf94 New changeset 9ab8632e7213 by Eli Bendersky in branch 'default': Issue #16913: Fix Element.itertext()'s handling of text with XML entities. http://hg.python.org/cpython/rev/9ab8632e7213 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16913 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16913] ElementTree tostring error when method='text'
Eli Bendersky added the comment: Fixed. Thanks. -- resolution: - fixed stage: patch review - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16913 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16076] xml.etree.ElementTree.Element is no longer pickleable
Roundup Robot added the comment: New changeset c46054b49b6c by Eli Bendersky in branch '3.3': Update Misc/NEWS for issue #16076 http://hg.python.org/cpython/rev/c46054b49b6c -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16076 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16613] ChainMap.new_child could use improvement
Walter Dörwald added the comment: I'd like to have this feature too. However the code should use d if d is not None else {} instead of d or {} For example I might want to use a subclass of dict (lowerdict) that converts all keys to lowercase. When I use an empty lowerdict in new_child(), new_child() would silently use a normal dict instead: class lowerdict(dict): def __getitem__(self, key): return dict.__getitem__( self, key.lower() if isinstance(key, str) else key ) import collections cm = collections.ChainMap(lowerdict(), lowerdict()) cm2 = cm.new_child(lowerdict()) print(type(cm2.maps[0])) This would print class 'dict'. -- nosy: +doerwalter ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16613 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15442] Expand the list of default dirs filecmp.dircmp ignores
Eli Bendersky added the comment: Attaching an alternative patch, that goes one (little) step further. Instead of repeating the ignored list all over the place (code, docstrings, ReST docs), the module exposes DEFAULT_IGNORES so everything can refer to it. Also added some tests for this feature. The patch is only vs. default (3.4), of course. -- Added file: http://bugs.python.org/file28669/eli_issue15442.1.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15442 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14377] Modify serializer for xml.etree.ElementTree to allow forcing the use of long tag closing
Eli Bendersky added the comment: Ariel, are you interested in pursuing this issue? Serhiy, I see you assigned this to yourself - would you like to submit a patch? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14377 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16917] Misleading missing parenthesis syntax error
Serhiy Storchaka added the comment: For better syntax error messages see issue1634034. -- nosy: +serhiy.storchaka ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16917 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16917] Misleading missing parenthesis syntax error
Dražen Lučanin added the comment: Yes, sure, I agree with both comments. Fors are a bit disambiguous in this context in comparison to while loops. But something in the style of Ezio's explanation might come in handy in the error output. e.g. SyntaxError: invalid syntax. , or ) expected in the argument list of the method append, but ':' found instead. (or the equivalent that's possible on that syntactic tree level) Something that might explain that it's some sort of list being parsed, not a for-loop command. It would point the coder in the right direction, speeding him up. This would all be a bit simpler if an indent was obligatory after inserting a newline in the middle of a command. Then this would pass OK things.append('c' for a in things) while this would fail things.append('c' for a in things) with a syntax error on the first line, because the second line would've been interpreted as a new command, not a continuation of the first one. I don't know if something like that would be possible, due to some other aspects, though... On Thu, Jan 10, 2013 at 3:23 PM, Mark Dickinson rep...@bugs.python.org wrote: Mark Dickinson added the comment: The error is in a missing parenthesis after the append call Well, that's one *possible* cause of the error. But fixing that missing parenthesis isn't the only way to make the code correct, and Python doesn't have any reasonable way to guess which of the various possible errors you made or what you intended to write. For example, the following is valid code: things = ['a', 'b'] things.append('c' for a in things) -- nosy: +mark.dickinson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16917 ___ -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16917 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16509] sqlite3 docs do not explain check_same_thread
Changes by R. David Murray rdmur...@bitdance.com: -- nosy: +r.david.murray ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16509 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16917] Misleading missing parenthesis syntax error
Ezio Melotti added the comment: This would all be a bit simpler if an indent was obligatory after inserting a newline in the middle of a command. This is not such a bad idea, but it is not backward-compatible and it would be inconsistent with how parentheses works in other situations. Developers usually learn that they should look back at least till the previous line while investigating syntax errors. Even in C (and similar languages) it's common that errors reported on one line are caused by e.g. a missing ';' on the previous line. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16917 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15545] sqlite3.Connection.iterdump() does not work with row_factory = sqlite3.Row
R. David Murray added the comment: For the record, this is a regression introduced by the fix for issue 9750. I plan to commit the fix shortly, thanks for the report and patch. -- nosy: +r.david.murray stage: - commit review type: crash - behavior versions: +Python 2.7, Python 3.3, Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15545 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9750] sqlite3 iterdump fails on column with reserved name
R. David Murray added the comment: For the record, this patch also introduced another regression (issue 15545). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9750 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10182] match_start truncates large values
Barry A. Warsaw added the comment: Note that this change is causing problems with genshi due to API backward incompatibility. This is reported here: https://bugs.launchpad.net/ubuntu/+source/python2.7/+bug/1097783 The reason the user found it in Ubuntu first is that we track hg tip, but I've reproduced it in my own hg tip, and the diff of r80680 makes it pretty obvious. I'm not saying the change should necessarily be reverted, but it *is* a backward incompatibility, and at a minimum the NEWS file (and release notes for 2.7.4) should make it clear that the return types have changed. As we're seeing, it breaks at least one existing package. -- nosy: +barry ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10182 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10182] match_start truncates large values
Barry A. Warsaw added the comment: Nosied Benjamin since this is a release issue. Re-opened, assigned to him, and release blocked for 2.7.4. -- assignee: - benjamin.peterson nosy: +georg.brandl, larry priority: normal - release blocker status: closed - open ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10182 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15545] sqlite3.Connection.iterdump() does not work with row_factory = sqlite3.Row
Roundup Robot added the comment: New changeset 2cdb599172ab by R David Murray in branch '3.2': #15545: fix sqlite3.iterdump regression on unsortable row_factory objects. http://hg.python.org/cpython/rev/2cdb599172ab New changeset 6a85894c428f by R David Murray in branch '3.3': merge #15545: fix sqlite3.iterdump regression on unsortable row_factory objects. http://hg.python.org/cpython/rev/6a85894c428f New changeset 7a62b5ee32ec by R David Murray in branch 'default': merge #15545: fix sqlite3.iterdump regression on unsortable row_factory objects. http://hg.python.org/cpython/rev/7a62b5ee32ec New changeset bb4e4f0cec2e by R David Murray in branch '2.7': #15545: sort iterdump via SQL instead of in python code http://hg.python.org/cpython/rev/bb4e4f0cec2e -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15545 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10182] match_start truncates large values
Changes by Barry A. Warsaw ba...@python.org: -- nosy: +benjamin.peterson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10182 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16613] ChainMap.new_child could use improvement
Vinay Sajip added the comment: d if d is not None else {} Your intention makes sense, though I would prefer to write it as: if d is None: d = {} return self.__class__(d, *self.maps) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16613 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16218] Python launcher does not support unicode characters
Andrew Svetlov added the comment: Thanks! -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16218 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9750] sqlite3 iterdump fails on column with reserved name
Roundup Robot added the comment: New changeset 2cdb599172ab by R David Murray in branch '3.2': #15545: fix sqlite3.iterdump regression on unsortable row_factory objects. http://hg.python.org/cpython/rev/2cdb599172ab New changeset 6a85894c428f by R David Murray in branch '3.3': merge #15545: fix sqlite3.iterdump regression on unsortable row_factory objects. http://hg.python.org/cpython/rev/6a85894c428f New changeset 7a62b5ee32ec by R David Murray in branch 'default': merge #15545: fix sqlite3.iterdump regression on unsortable row_factory objects. http://hg.python.org/cpython/rev/7a62b5ee32ec New changeset bb4e4f0cec2e by R David Murray in branch '2.7': #15545: sort iterdump via SQL instead of in python code http://hg.python.org/cpython/rev/bb4e4f0cec2e -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9750 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10182] match_start truncates large values
Benjamin Peterson added the comment: Actually, 2.7 should just use PyInt_FromSsize_t, which only promotes when needed. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10182 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15545] sqlite3.Connection.iterdump() does not work with row_factory = sqlite3.Row
R. David Murray added the comment: Peter, I see you've made contributions before, but you don't show as having a contributor agreement on file according to the tracker. Have you sent one in? If not, would you, please? Thanks again for the fix. -- components: +Library (Lib) -None resolution: - fixed stage: commit review - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15545 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10182] match_start truncates large values
Roundup Robot added the comment: New changeset 0f5067d9e1d8 by Benjamin Peterson in branch '2.7': use PyInt_FromSsize_t instead of PyLong_FromSsize_t (#10182) http://hg.python.org/cpython/rev/0f5067d9e1d8 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10182 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10182] match_start truncates large values
Benjamin Peterson added the comment: It's good you were able to report this before we released anything. -- status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10182 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16918] Fix test discovery for test_codecs.py
New submission from Zachary Ware: Here's the fix for test_codecs.py, I believe. I had a few headaches trying to get this patch created without changing some of the characters or adding a BOM to the file, and at one point the test was failing for no apparent reason. This version of the patch seems to work on my machine, though. -- components: Tests files: test_codecs_discovery.diff keywords: patch messages: 179571 nosy: brett.cannon, ezio.melotti, zach.ware priority: normal severity: normal status: open title: Fix test discovery for test_codecs.py type: behavior versions: Python 3.3, Python 3.4 Added file: http://bugs.python.org/file28670/test_codecs_discovery.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16918 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16914] timestamping in smtplib.py to help troubleshoot server timeouts/delays
Changes by R. David Murray rdmur...@bitdance.com: -- components: +email nosy: +barry, r.david.murray stage: - patch review ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16914 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16919] Fix test discovery for test_crypt.py
New submission from Zachary Ware: Here's a fix for test_crypt.py, inspired by Ezio's mention of using setUpModule in issue 16905. I can't test this on a platform that actually has _crypt at the moment, but I should be able to later today if nobody else has before then. Some tinkering has shown me that it /should/ work, though. -- components: Tests files: test_crypt_discovery.diff keywords: patch messages: 179572 nosy: brett.cannon, ezio.melotti, zach.ware priority: normal severity: normal status: open title: Fix test discovery for test_crypt.py type: behavior versions: Python 3.3, Python 3.4 Added file: http://bugs.python.org/file28671/test_crypt_discovery.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16919 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6975] symlinks incorrectly resolved on POSIX platforms
Serhiy Storchaka added the comment: Patch rewritten using recursion. Non-recursive version is not stack limited (and a little faster), but recursive version is perhaps more understandable. Some comments added. -- Added file: http://bugs.python.org/file28672/posix_realpath_2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6975 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1634034] Show expected token on syntax error
Serhiy Storchaka added the comment: dict(a = i for i in range(10)) +SyntaxError: invalid syntax - ')' expected The () are ok, the message is misleading. dict(a = i) is valid syntax, the compiler expects ) instead of invalid for. 'name' here is a bit vague. The compiler actually expects a name (using Python terminology, see for example NameError). Of course you can propose an other name for name (this is just an entity in _PyParser_TokenDescs array). def f(x, None): ... pass +SyntaxError: invalid syntax - ')' expected def f(*None): ... pass +SyntaxError: invalid syntax - ')' expected Here the () are ok too. The compiler means def f(x,) and def f(*), not def f() as you possible expects. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1634034 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16919] Fix test discovery for test_crypt.py
Changes by Ezio Melotti ezio.melo...@gmail.com: -- assignee: - ezio.melotti stage: - patch review ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16919 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14377] Modify serializer for xml.etree.ElementTree to allow forcing the use of long tag closing
Serhiy Storchaka added the comment: Serhiy, I see you assigned this to yourself - would you like to submit a patch? Not right now. This is low priority for me too. But I want to see this feature in 3.4. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14377 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16918] Fix test discovery for test_codecs.py
Changes by Ezio Melotti ezio.melo...@gmail.com: -- assignee: - ezio.melotti stage: - patch review ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16918 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1634034] Show expected token on syntax error
Ezio Melotti added the comment: I'm not saying that these errors are wrong -- just that they are misleading (i.e. they might lead the user on the wrong path, and make finding the actual problem more difficult). It should be noted that the examples I pasted don't include a full traceback though. The presence of the caret (^) in the right place will definitely make things clearer. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1634034 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16920] multiprocessing.connection listener gets MemoryError on recv
New submission from John Brearley: Using a multiprocessing.connection listener, I can accept an incoming socket OK, but when I do conn.recv(), I get memory error. The attached script mpl_bug.py will readily reproduce the issues on WinXP WinVista, see sample output below: pre c:\python mpl_bug.py main server listening on host port 10500 main created simple_client Process(Process-1, initial) simple_client connecting to host localhost port 10500 main conn: multiprocessing.connection.Connection object at 0x00C94B50 waiting for data simple_client sending: b'abcd' simple_client waiting for data Traceback (most recent call last): File mpl_bug.py, line 61, in module data=conn.recv() ;# Memory Error occurs here == == File c:\python33\lib\multiprocessing\connection.py, line 251, in recv buf = self._recv_bytes() File c:\python33\lib\multiprocessing\connection.py, line 405, in _recv_bytes return self._recv(size) File c:\python33\lib\multiprocessing\connection.py, line 380, in _recv chunk = read(handle, remaining) MemoryError /pre -- files: mpl_bug.py messages: 179577 nosy: jbrearley priority: normal severity: normal status: open title: multiprocessing.connection listener gets MemoryError on recv versions: Python 3.3 Added file: http://bugs.python.org/file28673/mpl_bug.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16920 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16920] multiprocessing.connection listener gets MemoryError on recv
Changes by John Brearley brear...@magma.ca: -- versions: +Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16920 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16921] Docs of subprocess.CREATE_NEW_CONSOLE are wrong
New submission from Torsten Landschoff: The documentation of CREATE_NEW_CONSOLE at http://docs.python.org/3/library/subprocess.html#subprocess.CREATE_NEW_CONSOLE states: This flag is always set when Popen is created with shell=True. This does not fit the code which does if (_subprocess.GetVersion() = 0x8000 or os.path.basename(comspec).lower() == command.com): # Win9x, or using command.com on NT. We need to creationflags |= _subprocess.CREATE_NEW_CONSOLE So the statement is only true on very old versions on Windows. I suggest to fix the documentation (patch attached) or to remove that obsolete hack (and drop support for Windows = NT). -- components: Windows files: create_new_console.diff keywords: patch messages: 179578 nosy: torsten priority: normal severity: normal status: open title: Docs of subprocess.CREATE_NEW_CONSOLE are wrong versions: Python 3.5 Added file: http://bugs.python.org/file28674/create_new_console.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16921 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16920] multiprocessing.connection listener gets MemoryError on recv
John Brearley added the comment: In V3.2.2.3, the conn.accept() was failing to resolve the socket address. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16920 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16922] ElementTree.findtext() returns empty bytes object instead of empty string
New submission from Serhiy Storchaka: import xml.etree.cElementTree as ET ET.XML('rootempty //root').findtext('empty') b'' -- components: XML files: etree_finditer_empty.patch keywords: patch messages: 179580 nosy: eli.bendersky, serhiy.storchaka priority: normal severity: normal stage: patch review status: open title: ElementTree.findtext() returns empty bytes object instead of empty string type: behavior versions: Python 3.2, Python 3.3, Python 3.4 Added file: http://bugs.python.org/file28675/etree_finditer_empty.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16922 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com