Re: How to process syntax errors

2016-10-11 Thread Pierre-Alain Dorange
Chris Angelico wrote: > >> Yes and no. Syntax errors are detected when the script is compiled, so > >> you can't do something like this: > > > > You're right, except that Python is never compiled, it was just checked > > for syntax error before interpreting code. > > https://docs.python.org/3/li

Re: How to process syntax errors

2016-10-11 Thread Chris Angelico
On Tue, Oct 11, 2016 at 7:02 PM, Pierre-Alain Dorange wrote: > Chris Angelico wrote: > >> >> Yes and no. Syntax errors are detected when the script is compiled, so >> >> you can't do something like this: >> > >> > You're right, except that Python is never compiled, it was just checked >> > for sy

Python code is compiled before execution (was: How to process syntax errors)

2016-10-11 Thread Ben Finney
pdora...@pas-de-pub-merci.mac.com (Pierre-Alain Dorange) writes: > Chris Angelico wrote: > > > https://docs.python.org/3/library/functions.html#compile > > > > [Python code is] compiled. > > Using this function, the code is "compiled". You have it backward: Python code is compiled. That's what

Re: How to process syntax errors

2016-10-11 Thread Marko Rauhamaa
Chris Angelico : >>> > You're right, except that Python is never compiled, it was just >>> > checked for syntax error before interpreting code. >>> >>> https://docs.python.org/3/library/functions.html#compile >>> >>> It's compiled. >> >> Using this function, the code is "compiled". >> I do not thi

Is it possible Python can distinguish capital letter and small letter in the path of Windows?

2016-10-11 Thread jfong
I have two files in the Q:\lib directory: Q:\lib>dir 2007/03/11 AM 08:025,260 lib_MARK.so 2007/03/11 AM 08:024,584 lib_mark.so Under Python 3.4.4 I got: >>> f = open('lib_MARK.so', 'br') >>> data = f.read() >>> f.close() >>> len(data) 4584 I know Windows won't, but can Python

Python Shell in Russian exists/possible??

2016-10-11 Thread Андрей Логунов
I need the Python Shell for use in education (turtle graphics, etc.), but the UI must be localized in the Russian language. The question is if it's at all possible to feed the strings in or rebuild it or... -- https://mail.python.org/mailman/listinfo/python-list

Re: Python code is compiled before execution

2016-10-11 Thread Pierre-Alain Dorange
Ben Finney wrote: > The "small translation into byte-code" *is* compilation. > > Don't make the mistake that the only product of "compile" is some CPU > code; that is a foolishly narrow definition. OK right. For my part, i differenciate a strict compilation (ie. C) from a translation into byte-

Re: Is it possible Python can distinguish capital letter and small letter in the path of Windows?

2016-10-11 Thread eryk sun
On Tue, Oct 11, 2016 at 10:34 AM, wrote: > I have two files in the Q:\lib directory: > > Q:\lib>dir > 2007/03/11 AM 08:025,260 lib_MARK.so > 2007/03/11 AM 08:024,584 lib_mark.so > > Under Python 3.4.4 I got: > f = open('lib_MARK.so', 'br') data = f.read() f.close(

Re: Python code is compiled before execution

2016-10-11 Thread BartC
On 11/10/2016 13:35, Pierre-Alain Dorange wrote: Ben Finney wrote: The "small translation into byte-code" *is* compilation. Don't make the mistake that the only product of "compile" is some CPU code; that is a foolishly narrow definition. OK right. For my part, i differenciate a strict comp

Re: Is it possible Python can distinguish capital letter and small letter in the path of Windows?

2016-10-11 Thread BartC
On 11/10/2016 13:49, Dennis Lee Bieber wrote: Unfortunately, Windows is one of the poorest documented OS I've encountered The problem is more that there is too much documentation! -- Bartc -- https://mail.python.org/mailman/listinfo/python-list

Conventions and requirements for a python module

2016-10-11 Thread Michael Felt
From reading the python source, and other projects I am looking to patch I see that there is often a file __init__.py, sometimes empty (only comments), sometimes not. I have tried looking in what I hope are the "regular" places such as: https://docs.python.org, readthedocs (it took 454 second

Re: Conventions and requirements for a python module

2016-10-11 Thread Michael Torrie
On 10/11/2016 08:29 AM, Michael Felt wrote: > From reading the python source, and other projects I am looking to > patch I see that there is often a file __init__.py, sometimes empty > (only comments), sometimes not. > > I have tried looking in what I hope are the "regular" places such as: > h

shadows name from outer scope

2016-10-11 Thread Daiyue Weng
Hi, I have the following code structure, def one_func(param1, param2, param3): process_outcome = {'dict': None} outcome = another_func(param1, process_outcome, db_host=param2, funcs_to_run=param3) PyCharm warns me Shadows name from outer scope on every variable here, param1,2,3, proc

Re: Python-based monads essay (Re: Assignment versus binding)

2016-10-11 Thread Anuradha Laxminarayan
On Sunday, 9 October 2016 13:18:32 UTC+5:30, Gregory Ewing wrote: > Here's the first part of the essay I said I'd write about > monads: > > http://www.cosc.canterbury.ac.nz/greg.ewing/essays/monads/DemystifyingMonads.html > > Hope it's useful, > Greg Thanks, that made a very interesting read.

Re: Python code is compiled before execution

2016-10-11 Thread Grant Edwards
On 2016-10-11, Pierre-Alain Dorange wrote: > For my part, i differenciate a strict compilation (ie. C) from a > translation into byte-code (ie. Python). FWIW I've seen C compilers that produced byte-code. They allowed for a highly interactive developemnt environment. -- Grant Edwards

Re: Python code is compiled before execution

2016-10-11 Thread Pierre-Alain Dorange
Grant Edwards wrote: > > For my part, i differenciate a strict compilation (ie. C) from a > > translation into byte-code (ie. Python). > > FWIW I've seen C compilers that produced byte-code. They allowed for > a highly interactive developemnt environment. I do not want to fight every word and

Re: Python Shell in Russian exists/possible??

2016-10-11 Thread Steve D'Aprano
On Tue, 11 Oct 2016 10:33 pm, Андрей Логунов wrote: > I need the Python Shell for use in education (turtle graphics, etc.), but > the UI must be localized in the Russian language. The question is if it's > at all possible to feed the strings in or rebuild it or... Yes it is possible, but it is pr

Re: How to process syntax errors

2016-10-11 Thread Steve D'Aprano
On Tue, 11 Oct 2016 03:58 pm, Terry Reedy wrote: > On 10/10/2016 11:24 AM, Chris Angelico wrote: >> On Tue, Oct 11, 2016 at 1:13 AM, wrote: >>> Is there any way to capture syntax errors and process them ? I want to >>> write a function which calls every time whenever there is syntax error >>> in

Re: Python code is compiled before execution

2016-10-11 Thread Steve D'Aprano
On Wed, 12 Oct 2016 12:19 am, BartC wrote: > Python is not really suited for AOT native-code compilation. You might be right, but the author of Nuitka disagrees. http://nuitka.net/ Nice to see that there's a new release, only a week or so ago! -- Steve “Cheer up,” they said, “things could

Re: Python-based monads essay (Re: Assignment versus binding)

2016-10-11 Thread Paul Rubin
Anuradha Laxminarayan writes: > seq f g x = f (\s1 -> g x s1) > because naming conventions imply that h is function. Also if this operation is what it looks like, it's usually called "bind". seq is something else entirely. -- https://mail.python.org/mailman/listinfo/python-list

Re: Python-based monads essay (Re: Assignment versus binding)

2016-10-11 Thread Rustom Mody
On Tuesday, October 11, 2016 at 9:53:25 PM UTC+5:30, Anuradha Laxminarayan wrote: > On Sunday, 9 October 2016 13:18:32 UTC+5:30, Gregory Ewing wrote: > > Here's the first part of the essay I said I'd write about > > monads: > > > > http://www.cosc.canterbury.ac.nz/greg.ewing/essays/monads/Demyst

Not getting output

2016-10-11 Thread dhawanpawan32
def abc(a,b): l=[] for i in range(a,b+1): if i%2!=0: l.append(i) print l return 1 def bg(): y=abc(11,31) print y I am not getting the output, but if i call method abc outside the function then it's coming -- https://mail.python.org/mai

while loop

2016-10-11 Thread dhawanpawan32
n=6 x=1 while x<=n: print "*"*x x+=1 while n>=x: n=n-1 print "*"* n Only first loop is executing not the second one? -- https://mail.python.org/mailman/listinfo/python-list

Re: while loop

2016-10-11 Thread Larry Martell
On Tue, Oct 11, 2016 at 1:58 PM, wrote: > > n=6 > x=1 > while x<=n: > print "*"*x > x+=1 > while n>=x: > n=n-1 > print "*"* n > > > Only first loop is executing not the second one? Because after the first loop n < x -- https://mail.python.org/mailman/listinfo/python-list

Re: Python Shell in Russian exists/possible??

2016-10-11 Thread Michael Torrie
On 10/11/2016 05:33 AM, Андрей Логунов wrote: > I need the Python Shell for use in education (turtle graphics, etc.), > but the UI must be localized in the Russian language. The question is > if it's at all possible to feed the strings in or rebuild it or... For educational purposes, you might fin

Re: while loop

2016-10-11 Thread Michael Torrie
On 10/11/2016 11:58 AM, dhawanpawa...@gmail.com wrote: > > n=6 > x=1 > while x<=n: > print "*"*x > x+=1 > while n>=x: > n=n-1 > print "*"* n > > > Only first loop is executing not the second one? Did you try printing out the loop variable to see what it does and what it is aft

Re: Not getting output

2016-10-11 Thread Jussi Piitulainen
dhawanpawa...@gmail.com writes: > def abc(a,b): > l=[] > for i in range(a,b+1): > if i%2!=0: > > l.append(i) > print l > return 1 > > def bg(): > y=abc(11,31) > print y > > I am not getting the output, but if i call method abc outside th

Re: Not getting output

2016-10-11 Thread Michael Torrie
On 10/11/2016 11:57 AM, dhawanpawa...@gmail.com wrote: > def abc(a,b): > l=[] > for i in range(a,b+1): > if i%2!=0: > > l.append(i) > print l > return 1 > > def bg(): > y=abc(11,31) > print y > I am not getting the output, but if i call

Re: while loop

2016-10-11 Thread Jussi Piitulainen
dhawanpawa...@gmail.com writes: > n=6 > x=1 > while x<=n: > print "*"*x > x+=1 > while n>=x: > n=n-1 > print "*"* n > > > Only first loop is executing not the second one? It's a basic fact about while loops that after the loop the condition is false. The two conditions x <= n a

Re: Not getting output

2016-10-11 Thread BartC
On 11/10/2016 18:57, dhawanpawa...@gmail.com wrote: def abc(a,b): l=[] for i in range(a,b+1): if i%2!=0: l.append(i) print l return 1 def bg(): y=abc(11,31) print y I am not getting the output, but if i call method abc outside the function then it's

Re: Python code is compiled before execution

2016-10-11 Thread BartC
On 11/10/2016 18:14, Steve D'Aprano wrote: On Wed, 12 Oct 2016 12:19 am, BartC wrote: Python is not really suited for AOT native-code compilation. You might be right, but the author of Nuitka disagrees. http://nuitka.net/ I tried the same thing with a dynamic language: translating byte-cod

Re: Conventions and requirements for a python module

2016-10-11 Thread Michael Felt
On 11/10/2016 17:30, Michael Torrie wrote: On 10/11/2016 08:29 AM, Michael Felt wrote: From reading the python source, and other projects I am looking to patch I see that there is often a file __init__.py, sometimes empty (only comments), sometimes not. I have tried looking in what I hope are

Re: Python Shell in Russian exists/possible??

2016-10-11 Thread Андрей Логунов
среда, 12 октября 2016 г., 4:29:02 UTC+10 пользователь Michael Torrie написал: > On 10/11/2016 05:33 AM, Андрей Логунов wrote: > > I need the Python Shell for use in education (turtle graphics, etc.), > > but the UI must be localized in the Russian language. The question is > > if it's at all possi

Re: while loop (Reposting On Python-List Prohibited)

2016-10-11 Thread BartC
On 11/10/2016 22:26, Lawrence D’Oliveiro wrote: On Wednesday, October 12, 2016 at 6:58:46 AM UTC+13, dhawan...@gmail.com wrote: Only first loop is executing not the second one? n=6 x=1 while x<=n: print("*"*x) x+=1 print('n=', n)

Re: shadows name from outer scope

2016-10-11 Thread Terry Reedy
On 10/11/2016 11:50 AM, Daiyue Weng wrote: Hi, I have the following code structure, def one_func(param1, param2, param3): process_outcome = {'dict': None} outcome = another_func(param1, process_outcome, db_host=param2, funcs_to_run=param3) PyCharm warns me Shadows name from outer sc

Re: How to process syntax errors

2016-10-11 Thread Terry Reedy
On 10/11/2016 4:02 AM, Pierre-Alain Dorange wrote: Using this function, the code is "compiled". I do not think this function is often used and most python project simply use the interpreter (which do a small translation into byte-code to be faster and check syntax error before running interpreta

Pip error on installing Python 3.5

2016-10-11 Thread Steve D'Aprano
I've just installed Python 3.5 from the source tarball and received an unexpected error related to pip. On Linux, as a regular user (except for the last line): wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tgz tar xvf Python-3.5.2.tgz cd Python-3.5.2 ./configure make sudo make altinst

repr/str diff between Python 2 and 3

2016-10-11 Thread Skip Montanaro
I'm trying to port some code from Python 2 to 3, and beyond the usual mechanical stuff, I've encountered a difference between the str() of floats. Here's an example. In Python 3 I get: >>> print(repr(27.04 - 0.01)) 27.028 >>> print(str(27.04 - 0.01)) 27.028 but in Python 2

Re: repr/str diff between Python 2 and 3

2016-10-11 Thread Ethan Furman
On 10/11/2016 05:59 PM, Skip Montanaro wrote: Is there documentation of this particular change? My searching turned up documentation of plenty of other changes, but not this particular one. 3.1 What's new: https://docs.python.org/3/whatsnew/3.1.html It's the third hit when searching for 'f

Re: repr/str diff between Python 2 and 3

2016-10-11 Thread Ben Finney
Skip Montanaro writes: > >>> print repr(27.04 - 0.01) > 27.028 > >>> print str(27.04 - 0.01) > 27.03 > > My test case writes through a csv writer, which writes the str() of each > element to the output. For Python 2, that's a mistake: str(object='') Return a string containi

Re: repr/str diff between Python 2 and 3

2016-10-11 Thread Skip Montanaro
> https://docs.python.org/3/whatsnew/3.1.html > > It's the third hit when searching for 'float'. Assuming I understand what it's saying. ;) Thanks. Is that the "David Gay's algorithm"? That seems to apply only to repr(), while the change I observed was in str(). Skip -- https://mail.python.or

Re: repr/str diff between Python 2 and 3

2016-10-11 Thread Skip Montanaro
> Only that one should not rely on ‘str’ preserving the value accurately, > as documented in Python 2. Sure, but this choice is out of my hands. It's csv.writerow that calls str(), not me. I could probably subclass csv.writer and csv.DictWriter, and override the writerow method, but I would prefer

Re: repr/str diff between Python 2 and 3

2016-10-11 Thread Terry Reedy
On 10/11/2016 8:59 PM, Skip Montanaro wrote: I'm trying to port some code from Python 2 to 3, and beyond the usual mechanical stuff, I've encountered a difference between the str() of floats. Here's an example. In Python 3 I get: print(repr(27.04 - 0.01)) 27.028 print(str(27.04 -

Re: repr/str diff between Python 2 and 3

2016-10-11 Thread Ben Finney
Skip Montanaro writes: > > Only that one should not rely on ‘str’ preserving the value accurately, > > as documented in Python 2. > > Sure, but this choice is out of my hands. It's csv.writerow that calls > str(), not me. Ah, good old ‘csv’. If the implementation is leaking an abstraction and y

Re: Is it possible Python can distinguish capital letter and small letter in the path of Windows?

2016-10-11 Thread jfong
Hi, eryk, thanks for your solution. I had try to find the document of the _winapi module, but can't find any in my installed Python directory. Can you give me a link to look for? > This alone doesn't make the Windows API case sensitive, but it does > enable individual CreateFile calls to be case

Re: Is it possible Python can distinguish capital letter and small letter in the path of Windows?

2016-10-11 Thread jfong
wxjm...@gmail.com at 2016/10/11 9:40:21PM wrote: > If you are about to modify your registry, do not > forget to switch your Windows in a *utf-8 mode*. Have no idea how to "switch" Windows in a "utf-8 mode"? What will happens if not? Can you give a simple example? Thanks ahead. --Jach -- https:/

Re: repr/str diff between Python 2 and 3

2016-10-11 Thread Ethan Furman
On 10/11/2016 06:30 PM, Skip Montanaro wrote: https://docs.python.org/3/whatsnew/3.1.html It's the third hit when searching for 'float'. Assuming I understand what it's saying. ;) Thanks. Is that the "David Gay's algorithm"? That seems to apply only to repr(), while the change I observed wa

Re: repr/str diff between Python 2 and 3

2016-10-11 Thread Terry Reedy
On 10/11/2016 9:30 PM, Skip Montanaro wrote: https://docs.python.org/3/whatsnew/3.1.html It's the third hit when searching for 'float'. Assuming I understand what it's saying. ;) Thanks. Is that the "David Gay's algorithm"? That seems to apply only to repr(), while the change I observed was

OFF TOPIC mov is Turing complete

2016-10-11 Thread Steven D'Aprano
Completely off-topic, but too awesome not to share: The x86 assembly language "mov" instruction is Turing complete: https://www.cl.cam.ac.uk/~sd601/papers/mov.pdf Abstract It is well-known that the x86 instruction set is baroque, overcom- plicated, and redundantly redundant. We show jus

Re: Is it possible Python can distinguish capital letter and small letter in the path of Windows?

2016-10-11 Thread eryk sun
On Wed, Oct 12, 2016 at 2:36 AM, wrote: > > I had try to find the document of the _winapi module, but can't find any in my > installed Python directory. Can you give me a link to look for? _winapi is not documented. It contains light wrappers around a small set of Windows functions. It's ok for

Re: OFF TOPIC mov is Turing complete

2016-10-11 Thread Michael Torrie
On 10/11/2016 09:19 PM, Steven D'Aprano wrote: > Completely off-topic, but too awesome not to share: > > The x86 assembly language "mov" instruction is Turing complete: > > https://www.cl.cam.ac.uk/~sd601/papers/mov.pdf And apparently someone has taken this and made a small C compiler that compi

Re: Is it possible Python can distinguish capital letter and small letter in the path of Windows?

2016-10-11 Thread Gregory Ewing
Dennis Lee Bieber wrote: VMS documentation set was around 60 linear inches (two 30" shelves) of 3-ring binders. Amiga RKMs were five volumes with the main documentation in fine print -- two "pages" side-by-side on a landscape page. Apparently if you're writing software for the US Air Fo

Re: Pip error on installing Python 3.5

2016-10-11 Thread Zachary Ware
On Tue, Oct 11, 2016 at 7:07 PM, Steve D'Aprano wrote: > I've just installed Python 3.5 from the source tarball and received an > unexpected error related to pip. On Linux, as a regular user (except for > the last line): > > > wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tgz > tar xvf

Re: Python-based monads essay (Re: Assignment versus binding)

2016-10-11 Thread Gregory Ewing
Anuradha Laxminarayan wrote: seq f g h = f (\s1 -> g h s1) better be written as seq f g x = f (\s1 -> g x s1) because naming conventions imply that h is function. Well, for the subset of monads I'm talking about, it always is a function -- it's the continuation to be run after f and g. -- G

Re: Python-based monads essay (Re: Assignment versus binding)

2016-10-11 Thread Gregory Ewing
Paul Rubin wrote: Also if this operation is what it looks like, it's usually called "bind". seq is something else entirely. Ah, I hadn't realised there was already a function in Haskell called seq -- sorry about that! I don't really want to call the Python version 'bind', because it seems a b

Re: repr/str diff between Python 2 and 3

2016-10-11 Thread Serhiy Storchaka
On 12.10.16 04:30, Skip Montanaro wrote: https://docs.python.org/3/whatsnew/3.1.html It's the third hit when searching for 'float'. Assuming I understand what it's saying. ;) Thanks. Is that the "David Gay's algorithm"? That seems to apply only to repr(), while the change I observed was in