Re: learning to use iterators

2014-12-25 Thread Peter Otten
Ian Kelly wrote: On Wed, Dec 24, 2014 at 1:34 PM, Rustom Mody rustompm...@gmail.com wrote: +1 for the slice in succinct form Not only more succinct but also more correct. The purpose of islice is to slice arbitrary iterables as opposed to just sequences. But this function requires a

If One Line

2014-12-25 Thread JC
Hello, Is it possible in python: if ((x = a(b,c)) == 'TRUE'): print x Thanks. -- https://mail.python.org/mailman/listinfo/python-list

Re: If One Line

2014-12-25 Thread Fetchinson .
Is it possible in python: if ((x = a(b,c)) == 'TRUE'): print x Nope. Assignment is not allowed in a conditional. Cheers, Daniel Thanks. -- https://mail.python.org/mailman/listinfo/python-list -- Psss, psss, put it down! - http://www.cafepress.com/putitdown --

Re: If One Line

2014-12-25 Thread Ian Kelly
On Thu, Dec 25, 2014 at 8:18 AM, JC chalao.a...@gmail.com wrote: Hello, Is it possible in python: if ((x = a(b,c)) == 'TRUE'): print x No, assignments in Python are statements, not expressions. -- https://mail.python.org/mailman/listinfo/python-list

Future of python on android

2014-12-25 Thread Fetchinson .
Hi all, I was using sl4a for quite some time on android and it basically worked very well although some features are missing. It looks like sl4a is dead, although I could be wrong. Does anyone knowledgeable have any further info on the future of sl4a? For instance it doesn't work with android 5

Re: If One Line

2014-12-25 Thread Jacob Kruger
One line assignment is ok, but, seems like you can't perform actions. #the following will work: I = 1 if True else 2 #but the following will generate an error: if I == 1: print(one) And, not sure if/how to work around that second one myself. Stay well Jacob Kruger Blind Biker Skype: BlindZA

Re: If One Line

2014-12-25 Thread Jacob Kruger
One line assignment is ok, but, seems like you can't perform actions. #the following will work: I = 1 if True else 2 #but the following will generate an error: if I == 1: print(one) And, not sure if/how to work around that second one myself. Stay well Jacob Kruger Blind Biker Skype: BlindZA

Re: If One Line

2014-12-25 Thread Skip Montanaro
I don't get an error. I = 1 if True else 2 if I == 1: print(one) ... one What error did you get? Skip -- https://mail.python.org/mailman/listinfo/python-list

Re: If One Line

2014-12-25 Thread Rick Johnson
On Thursday, December 25, 2014 10:16:54 AM UTC-6, Jacob Kruger wrote: One line assignment is ok, but, seems like you can't perform actions. #the following will work: I = 1 if True else 2 #but the following will generate an error: if I == 1: print(one) Only if I is undefined. --

Re: question on string object handling in Python 2.7.8

2014-12-25 Thread Denis McMahon
On Tue, 23 Dec 2014 20:28:30 -0500, Dave Tian wrote: Hi, There are 2 statements: A: a = ‘h’ B: b = ‘hh’ According to me understanding, A should be faster as characters would shortcut this 1-byte string ‘h’ without malloc; B should be slower than A as characters does not work for 2-byte

Re: Future of python on android

2014-12-25 Thread Billy Earney
try kivy, instead of sl4a http://kivy.org/ I believe in the past year or two, the python foundation gave a grant to kivy to add further functionality.. According to wikipedia http://en.wikipedia.org/wiki/Guido_van_Rossum Guido works for dropbox. Billy On Thu, Dec 25, 2014 at 9:31 AM,

Re: If One Line

2014-12-25 Thread Rick Johnson
On Thursday, December 25, 2014 9:19:25 AM UTC-6, JC wrote: Hello, Is it possible in python: if ((x = a(b,c)) == 'TRUE'): print x Thanks. Could you not simply rephrase: result = foo() if result == 'TRUE': do_something() Of course, another oddity is fact that

Re: If One Line

2014-12-25 Thread Jacob Kruger
Actually more that in the interpreter, it's prompting me with ... as if I had left out a closing ) or something, but, suppose it could work fine in an actual imported bit of code? Stay well Jacob Kruger Blind Biker Skype: BlindZA Roger Wilco wants to welcome you...to the space janitor's

Re: If One Line

2014-12-25 Thread Skip Montanaro
Actually more that in the interpreter, it's prompting me with ... as if I had left out a closing ) or something, but, suppose it could work fine in an actual imported bit of code? That's how it's supposed to work. Given that Python block structure is determined by indentation, you need some way

Re: If One Line

2014-12-25 Thread Jacob Kruger
Ok, makes sense - just slipped same one line if: action bit of code inside a function, and worked fine. Stay well Jacob Kruger Blind Biker Skype: BlindZA Roger Wilco wants to welcome you...to the space janitor's closet... - Original Message - From: Skip Montanaro To: Jacob

Re: If One Line

2014-12-25 Thread Jacob Kruger
Ok, makes sense - just slipped same one line if: action bit of code inside a function, and worked fine. Stay well Jacob Kruger Blind Biker Skype: BlindZA Roger Wilco wants to welcome you...to the space janitor's closet... - Original Message - From: Skip Montanaro To: Jacob

Re: Future of python on android

2014-12-25 Thread Fetchinson .
On 12/25/14, Billy Earney billy.ear...@gmail.com wrote: try kivy, instead of sl4a http://kivy.org/ I believe in the past year or two, the python foundation gave a grant to kivy to add further functionality.. Thanks, I didn't know about kivy but it looks quite nice, will give it a try!

Re: converting PDF files is now an easy task

2014-12-25 Thread David H. Lipman
From: joshuaemsteves joshuaemste...@yahoo.com There is a familiar chance Pdf to Doc wasn't going to take off as long as don't be an idiot and use this pdf to docx converter. I expect this was a bad hypothesis, but you really have to open your mind. While Pdf to Doc is used in those situations,

Re: OFF TOPIC Snow Crash [was Re: Hello World]

2014-12-25 Thread alex23
On 24/12/2014 2:20 AM, Grant Edwards wrote: And even _with_ all the technical jibber-jabber, none of it explained or justified the whole writing a virus to infect the brain through the optic nerve thing which might just have well been magick and witches. While I love SNOW CRASH, I do think

Re: OFF TOPIC Snow Crash [was Re: Hello World]

2014-12-25 Thread alex23
On 24/12/2014 9:50 PM, alister wrote: what feels like 3 or 4 chapters in it is still trying to set the scene, an exercise in stylish writing with very little content so far. even early scifi written for magazines on a per word basis were not this excessive (because if they were they would

Re: If One Line

2014-12-25 Thread alex23
On 26/12/2014 1:18 AM, JC wrote: Is it possible in python: if ((x = a(b,c)) == 'TRUE'): print x One approach is to use a function in the condition to do the assignment: x = None def assign_to_x(val): global x x = val return val def a(x, y):

suggestions for VIN parsing

2014-12-25 Thread Vincent Davis
I would like to parse the VIN, frame and engine numbers found on this page (below). I don't really know any regex, I have looked a little at pyparsing. I have some other similar numbers to. I am looking for suggestions, which tool should I learn, how should I approach this.

Re: suggestions for VIN parsing

2014-12-25 Thread Dan Stromberg
On Thu, Dec 25, 2014 at 4:02 PM, Vincent Davis vinc...@vincentdavis.net wrote: I would like to parse the VIN, frame and engine numbers found on this page (below). I don't really know any regex, I have looked a little at pyparsing. I have some other similar numbers to. I am looking for

Re: suggestions for VIN parsing

2014-12-25 Thread Vincent Davis
These are vintage motorcycles so the VIN's are not like modern VIN's these are frame numbers and engine number. I don't want to parse the page, I what a function that given a VIN (frame or engine number) returns the year the bike was made. Vincent Davis 720-301-3003 On Thu, Dec 25, 2014 at 5:56

Re: suggestions for VIN parsing

2014-12-25 Thread Tim Chase
On 2014-12-25 17:59, Vincent Davis wrote: These are vintage motorcycles so the VIN's are not like modern VIN's these are frame numbers and engine number. I don't want to parse the page, I what a function that given a VIN (frame or engine number) returns the year the bike was made. While I've

Re: suggestions for VIN parsing

2014-12-25 Thread Ben Finney
Vincent Davis vinc...@vincentdavis.net writes: I don't want to parse the page, I what a function that given a VIN (frame or engine number) returns the year the bike was made. So the page has a collection of tables which the reader can use to manually look up the VIN, or elements of the VIN, to

Re: suggestions for VIN parsing

2014-12-25 Thread Vincent Davis
Tim and Ben, Thanks for your input, I am working on it now and will come back when I have questions. Any comment on using pyparsing VS regex Vincent Davis 720-301-3003 On Thu, Dec 25, 2014 at 7:18 PM, Ben Finney ben+pyt...@benfinney.id.au wrote: Vincent Davis vinc...@vincentdavis.net writes:

Re: suggestions for VIN parsing

2014-12-25 Thread Tim Chase
On 2014-12-25 19:58, Vincent Davis wrote: Any comment on using pyparsing VS regex If the VIN had any sort of regular grammar (especially if it involved nesting) then pyparsing would have value. I defaulted to regexp (1) because it's available out of the box, and (2) while it might be overkill,

Re: suggestions for VIN parsing

2014-12-25 Thread Skip Montanaro
You're extracting structured data from an html file. You might want to look at the lxml.etree module. (I think that's where ElementTree landed when it was adopted into the stdlib). Skip -- https://mail.python.org/mailman/listinfo/python-list

Re: If One Line

2014-12-25 Thread Steven D'Aprano
JC wrote: Hello, Is it possible in python: if ((x = a(b,c)) == 'TRUE'): print x Fortunately, no. Assignment as an expression is an anti-pattern and a bug magnet. The above is best written as: if a(b,c) == 'TRUE': print 'TRUE' If you need the result of calling the a()

Re: If One Line

2014-12-25 Thread Steven D'Aprano
alex23 wrote: On 26/12/2014 1:18 AM, JC wrote: Is it possible in python: if ((x = a(b,c)) == 'TRUE'): print x One approach is to use a function in the condition to do the assignment: Let me fix that for you: /s/approach/bad idea/ All you have done is replace one anti-pattern

Re: OFF TOPIC Snow Crash [was Re: Hello World]

2014-12-25 Thread Steven D'Aprano
alex23 wrote: On 24/12/2014 2:20 AM, Grant Edwards wrote: And even _with_ all the technical jibber-jabber, none of it explained or justified the whole writing a virus to infect the brain through the optic nerve thing which might just have well been magick and witches. While I love SNOW

Re: what is wrong with d.clear()?

2014-12-25 Thread Ian Kelly
On Wed, Dec 24, 2014 at 5:21 AM, Rustom Mody rustompm...@gmail.com wrote: On Tuesday, December 23, 2014 6:30:30 PM UTC+5:30, shawool wrote: Thank you for answering my query. Fonts and colors are reset to defaults now. Sorry for the inconvenience caused. Regards, Shawool Sorry for the

Re: Future of python on android

2014-12-25 Thread Steven D'Aprano
Fetchinson . wrote: Guido is still working at google, right? No. Google is still using Python for lots of things, but Guido is now working for Dropbox. https://www.python.org/~guido/ -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Classes - delegation question.

2014-12-25 Thread Ben Finney
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info writes: However, be warned that there are two subtly different models for delegation. Here's the one that people seem to forget: http://code.activestate.com/recipes/519639-true-lieberman-style-delegation-in-python/ Very interesting! The

Re: If One Line

2014-12-25 Thread alex23
On 26/12/2014 1:37 PM, Steven D'Aprano wrote: One approach is to use a function in the condition to do the assignment: Let me fix that for you: /s/approach/bad idea/ I never said it was a _good_ approach ;) And you don't even save any lines! Instead of a one-liner, you have six lines!

Re: suggestions for VIN parsing

2014-12-25 Thread Ben Finney
Vincent Davis vinc...@vincentdavis.net writes: Any comment on using pyparsing VS regex A full-blown parser (with ‘pyparsing’) is overkill for this. Even regular expressions isn't needed. The built-in text type (‘str’) in Python 3 should have everything you need; you only need to match

[issue20069] Add unit test for os.chown

2014-12-25 Thread Vajrasky Kok
Vajrasky Kok added the comment: Here is the latest patch which executes unittest.main inside __main__ based on R. David Murray's review. Thanks! -- Added file: http://bugs.python.org/file37540/add_unit_test_os_chown_v7.patch ___ Python tracker

[issue23112] SimpleHTTPServer/http.server adds trailing slash after query string

2014-12-25 Thread Josep Portella Florit
New submission from Josep Portella Florit: To reproduce: 1) Create directory foo in the current directory. 2) Run python -m SimpleHTTPServer or python3 -m http.server. 3A) Point web browser to http://127.0.0.1:8000/foo/?;. The request is redirected to http://127.0.0.1:8000/foo/?/;. The

[issue23113] Compiler doesn't recognize qualified exec('', {})

2014-12-25 Thread John Firestone
New submission from John Firestone: Python 2.7.8 (v2.7.8:ee879c0ffa11, Jun 29 2014, 21:07:35) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type help, copyright, credits or license for more information. def outer(): ... def inner(arg): ... len(arg) ... exec('', {}) ...

[issue23113] Compiler doesn't recognize qualified exec('', {})

2014-12-25 Thread John Firestone
John Firestone added the comment: Sorry. Duplicates 21591 -- status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23113 ___ ___

[issue23113] Compiler doesn't recognize qualified exec('', {})

2014-12-25 Thread R. David Murray
Changes by R. David Murray rdmur...@bitdance.com: -- resolution: - duplicate stage: - resolved superseder: - exec(a, b, c) not the same as exec a in b, c in nested functions ___ Python tracker rep...@bugs.python.org

[issue23107] Tighten-up search loops in sets

2014-12-25 Thread STINNER Victor
Changes by STINNER Victor victor.stin...@gmail.com: -- nosy: +pitrou, serhiy.storchaka ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23107 ___ ___

[issue22926] asyncio: raise an exception when called from the wrong thread

2014-12-25 Thread STINNER Victor
STINNER Victor added the comment: I'm going to commit check_thread-3.patch if nobody complains: in debug mode, call_soon(), call_at() and call_later() now check threading.get_ident() to ensure that they are called from the thread running the event loop. -- Added file:

[issue23104] [Windows x86-64] Incorrect function call

2014-12-25 Thread STINNER Victor
STINNER Victor added the comment: testfun(objid(), c_wchar_p('test')) I'm not sure that the objid object lives until testfun() is called. It would be safer to write: o = objid() testfun(o, c_wchar_p('test'))) o = None -- nosy: +haypo ___ Python

[issue23104] [Windows x86-64] ctypes: Incorrect function call

2014-12-25 Thread STINNER Victor
Changes by STINNER Victor victor.stin...@gmail.com: -- title: [Windows x86-64] Incorrect function call - [Windows x86-64] ctypes: Incorrect function call ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23104

[issue20069] Add unit test for os.chown

2014-12-25 Thread Roundup Robot
Roundup Robot added the comment: New changeset 32c5b9aeee82 by R David Murray in branch 'default': #20069: Add tests for os.chown. https://hg.python.org/cpython/rev/32c5b9aeee82 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org

[issue20069] Add unit test for os.chown

2014-12-25 Thread R. David Murray
R. David Murray added the comment: Thanks, Vajrasky. -- resolution: - fixed stage: commit review - resolved status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20069 ___

[issue19539] The 'raw_unicode_escape' codec buggy + not appropriate for Python 3.x

2014-12-25 Thread Jan Kaliszewski
Changes by Jan Kaliszewski z...@chopin.edu.pl: -- resolution: - duplicate status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19539 ___

[issue19539] The 'raw_unicode_escape' codec buggy + not appropriate for Python 3.x

2014-12-25 Thread Jan Kaliszewski
Jan Kaliszewski added the comment: My concerns are now being addressed in the issue19548. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19539 ___

[issue22926] asyncio: raise an exception when called from the wrong thread

2014-12-25 Thread Guido van Rossum
Guido van Rossum added the comment: SGTM. Merry Xmas! -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22926 ___ ___ Python-bugs-list mailing list