On Fri, Mar 21, 2014 at 4:49 PM, Marko Rauhamaa ma...@pacujo.net wrote:
Chris Angelico ros...@gmail.com:
go for the lowest common denominator:
print(some single string)
which works happily in all versions of Python.
Whenever I have used print in my code, it has been with a
redirection.
Chris Angelico ros...@gmail.com:
Then you're probably not using sys.stdout.write but some other file
object's write method.
Correct, sys.stderr.write would have been a more accurate choice.
Also, I find it highly unusual that you never use print in its most
basic and intended form.
On Friday, March 21, 2014 11:38:42 AM UTC+5:30, Marko Rauhamaa wrote:
Chris Angelico :
Then you're probably not using sys.stdout.write but some other file
object's write method.
Correct, sys.stderr.write would have been a more accurate choice.
Also, I find it highly unusual that you
On 21/03/2014 02:18, Chris Angelico wrote:
On Fri, Mar 21, 2014 at 12:06 PM, Roy Smith r...@panix.com wrote:
In article 532b8f0d$0$29994$c3e8da3$54964...@news.astraweb.com,
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote:
The rule of three applies here: anything you do in three
On Fri, 21 Mar 2014 09:40:40 +, Mark Lawrence wrote:
On 21/03/2014 02:18, Chris Angelico wrote:
On Fri, Mar 21, 2014 at 12:06 PM, Roy Smith r...@panix.com wrote:
In article 532b8f0d$0$29994$c3e8da3$54964...@news.astraweb.com,
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote:
notbob not...@nothome.com:
I've installed python 3.3 on my Slack box, which by default comes with
python 2.7. I know how to fire up the different IDLE environments, but
how do I differentiate between the scripts? IOW, up till now, I've
used .py on all my 2.7 files. How do I know not to run a
On 2014-03-20, Marko Rauhamaa ma...@pacujo.net wrote:
That's a bit of a sore spot.
On a linux box, the initial line of the script indicates the
interpreter:
#!/usr/bin/env python2
for Python 2.x
#!/usr/bin/env python3
for Python 3.x.
All tutorials will tell you to start it
On 3/20/14 9:58 AM, notbob wrote:
I've installed python 3.3 on my Slack box, which by default comes with
python 2.7. I know how to fire up the different IDLE environments,
but how do I differentiate between the scripts?
hi notbob, the two (or more) IDLE environments run very nicely
On Thu, Mar 20, 2014 at 11:00 AM, notbob not...@nothome.com wrote:
Ahhh! now a shabang I understand. So, I guess the only way, short
of looking at the actual file, is to include the version in the
filename. Can I safely assume I can run all 2.7 files w/o a shebang
(which I have not, so
On 2014-03-20, Zachary Ware zachary.ware+pyl...@gmail.com wrote:
If you're specifying the interpreter in your command (by calling
python scriptname.py, etc), the shebang won't mean anything
anyway.
DOH!
I was following you, fine, until that last sentence. Then how should
I invoke the
On 2014-03-20, Mark H Harris harrismh...@gmail.com wrote:
not) there really is no problem. The reason is that the .pyc files
created for python2.x are only used by python2.
Lordy, what hath I wrought!? ;)
What the heck is a .pyc file and how are they created? Actually, I
can see it's a
On Fri, Mar 21, 2014 at 4:23 AM, notbob not...@nothome.com wrote:
On 2014-03-20, Mark H Harris harrismh...@gmail.com wrote:
not) there really is no problem. The reason is that the .pyc files
created for python2.x are only used by python2.
Lordy, what hath I wrought!? ;)
What the heck is a
On Fri, Mar 21, 2014 at 4:10 AM, notbob not...@nothome.com wrote:
On 2014-03-20, Zachary Ware zachary.ware+pyl...@gmail.com wrote:
If you're specifying the interpreter in your command (by calling
python scriptname.py, etc), the shebang won't mean anything
anyway.
DOH!
I was following you,
On 3/20/14 12:23 PM, notbob wrote:
What the heck is a .pyc file and how are they created? Actually, I
can see it's a compiled binary, but I where did it come from?
The world according to me: python is an interpreter (vs compiler) which
converts your source code into tokens and then into a
Chris Angelico ros...@gmail.com:
Nowadays they'll be pushed away into a separate directory, which makes
them easier for you to ignore. This is a good thing.
Still, I don't think Python should go and soil my directories without an
explicit permission.
Marko
--
Mark H Harris harrismh...@gmail.com:
If you wanted to you could run your python scripts from the .pyc file
alone. In other words, you may import as long as the .pyc file exists
and the source does not need to be there. Some folks use this (not
recommended) trick to hide or obfuscate their
On 03/20/2014 10:10 AM, notbob wrote:
On 2014-03-20, Zachary Ware zachary.ware+pyl...@gmail.com wrote:
If you're specifying the interpreter in your command (by calling
python scriptname.py, etc), the shebang won't mean anything
anyway.
DOH!
I was following you, fine, until that last
On 3/20/14 1:47 PM, Marko Rauhamaa wrote:
Mark H Harris harrismh...@gmail.com:
If you wanted to you could run your python scripts from the .pyc file
alone. In other words, you may import as long as the .pyc file exists
and the source does not need to be there. Some folks use this (not
On 20/03/2014 15:21, Marko Rauhamaa wrote:
notbob not...@nothome.com:
I've installed python 3.3 on my Slack box, which by default comes with
python 2.7. I know how to fire up the different IDLE environments, but
how do I differentiate between the scripts? IOW, up till now, I've
used .py on all
In bp0lohf7aq...@mid.individual.net notbob not...@nothome.com writes:
On 2014-03-20, Zachary Ware zachary.ware+pyl...@gmail.com wrote:
If you're specifying the interpreter in your command (by calling
python scriptname.py, etc), the shebang won't mean anything
anyway.
DOH!
I was
Le 20/03/2014 16:21, Marko Rauhamaa a écrit :
All tutorials will tell you to start it with
#!/usr/bin/env python
which will start python2 on all (?) existing linux distros, but is
expected to start python3 within the next decade.
With Arch-Linux, python is python3...
--
On 3/20/14 12:47 PM, Marko Rauhamaa wrote:
I've seen it done, but at least in those Python 2 days the pyc format
changed between minor releases of Python, so Python itself had to be
shipped with the pyc files.
hi Marko, yeah, I have not done this; being that the concept is contrary
to my
On 3/20/2014 11:21 AM, Marko Rauhamaa wrote:
On a linux box, the initial line of the script indicates the
interpreter:
#!/usr/bin/env python2
for Python 2.x
#!/usr/bin/env python3
for Python 3.x.
All tutorials will tell you to start it with
#!/usr/bin/env python
which will
Alan Meyer amey...@yahoo.com:
I presume it would still be a good idea to test both python
interpreters against any script that you didn't knowingly write with a
feature that will only work in one of the two python versions.
If it works fine in both - and many will, then use:
On 3/20/14 2:53 PM, Alan Meyer wrote:
#!/usr/bin/env python
Only use the python2 or python3 versions if you really have a reason
to do so.
It gets tricky for distribution (you need docs for your distros, imho)
because #!/usr/bin/env python means different things on different
systems.
I
On 20/03/2014 20:08, Marko Rauhamaa wrote:
Alan Meyer amey...@yahoo.com:
I presume it would still be a good idea to test both python
interpreters against any script that you didn't knowingly write with a
feature that will only work in one of the two python versions.
If it works fine in both -
On 3/20/14 3:07 PM, Eric Jacoboni wrote:
Le 20/03/2014 16:21, Marko Rauhamaa a écrit :
All tutorials will tell you to start it with
#!/usr/bin/env python
which will start python2 on all (?) existing linux distros, but is
expected to start python3 within the next decade.
With
On 3/20/14 4:08 PM, Marko Rauhamaa wrote:
Alan Meyer amey...@yahoo.com:
I presume it would still be a good idea to test both python
interpreters against any script that you didn't knowingly write with a
feature that will only work in one of the two python versions.
If it works fine in both -
Mark Lawrence breamore...@yahoo.co.uk:
The starter is 2to3 which had been in the standard library for what
seems like an eternity to me.
No problem there. It helps you transition from python2 to python3.
However, python3 is here and you should be able to write genuine python3
code with the
On Thu, Mar 20, 2014 at 8:21 AM, Marko Rauhamaa ma...@pacujo.net wrote:
notbob not...@nothome.com:
I've installed python 3.3 on my Slack box, which by default comes with
python 2.7. I know how to fire up the different IDLE environments, but
how do I differentiate between the scripts? IOW, up
On Thu, Mar 20, 2014 at 3:30 PM, Marko Rauhamaa ma...@pacujo.net wrote:
I must say, though, that Python3 destroyed print forever for me. To
avoid nausea, I write sys.stdout.write() in all Python3 code.
To each their own :). I can't stand using 'print' as a statement.
It's a very nice trick to
Ned Batchelder n...@nedbatchelder.com:
Plenty of people have adopted a dual-support strategy, with one code
base that supports both Python 2 and Python 3. The six module can help
a great deal with this.
I wonder how easy the resulting code is to the eyes and how easy it is
for the casual
On 20/03/2014 20:30, Marko Rauhamaa wrote:
Mark Lawrence breamore...@yahoo.co.uk:
The starter is 2to3 which had been in the standard library for what
seems like an eternity to me.
No problem there. It helps you transition from python2 to python3.
However, python3 is here and you should be
Dan Stromberg drsali...@gmail.com:
Actually, I formerly used /usr/bin/env, but have recently (within the
last couple of years) stopped.
This is because the env trick doesn't play nicely with top IME. Also,
it's a trick.
I'm not sure I like it either, but it's a standard idiom in Pythonland.
On 3/20/14 4:42 PM, Marko Rauhamaa wrote:
Ned Batchelder n...@nedbatchelder.com:
Plenty of people have adopted a dual-support strategy, with one code
base that supports both Python 2 and Python 3. The six module can help
a great deal with this.
I wonder how easy the resulting code is to the
Mark Lawrence breamore...@yahoo.co.uk:
On 20/03/2014 20:30, Marko Rauhamaa wrote:
I must say, though, that Python3 destroyed print forever for me. To
avoid nausea, I write sys.stdout.write() in all Python3 code.
Not for me, I was using from __future__ import print_function for
years so got
Ned Batchelder n...@nedbatchelder.com:
It's an extreme case, but the latest released version of coverage.py
supports Python 2.3 through 3.3 with one code base. To do it, there's
a compatibility layer (akin to six). Then you stay away from features
that aren't available on all versions. In a
On Thu, Mar 20, 2014 at 1:59 PM, Marko Rauhamaa ma...@pacujo.net wrote:
Well, with proper care, I suppose the same code base could support perl
as well. ;)
Go even farther; how about C, PHP, and bash? I'm sure if you tried, you
could mix in some Python as well.
On 2014-03-20, Mark H Harris harrismh...@gmail.com wrote:
When I call python2 that means python2.7.6 /
When I call python3 that means python3.3.4 /
I can also call python2.7, which is 2.7.2 /
You get the idea. There is no one set rule, because there are many
distros (gnu/linux) that
On 3/20/14 4:59 PM, Marko Rauhamaa wrote:
Ned Batchelder n...@nedbatchelder.com:
It's an extreme case, but the latest released version of coverage.py
supports Python 2.3 through 3.3 with one code base. To do it, there's
a compatibility layer (akin to six). Then you stay away from features
that
On 2014-03-20, Ned Batchelder n...@nedbatchelder.com wrote:
On 3/20/14 3:07 PM, Eric Jacoboni wrote:
With Arch-Linux, python is python3...
Yes, and they have been told many times that this was foolish and wrong,
but it persists, much to our pain.
I've read that 2.7 is the defacto std for
On 20/03/2014 20:50, Marko Rauhamaa wrote:
Mark Lawrence breamore...@yahoo.co.uk:
On 20/03/2014 20:30, Marko Rauhamaa wrote:
I must say, though, that Python3 destroyed print forever for me. To
avoid nausea, I write sys.stdout.write() in all Python3 code.
Not for me, I was using from
On 3/20/14 4:28 PM, notbob wrote:
No wonder the latest O'Reilly book, Learning Python, 5th ed,
is 1600 pgs. I coulda swore someone sed python is easy. ;)
nb
Python is easy, but its not simple.
Python is elegant, and full of art, but it has no paucity of constructs,
types, and
On 3/20/2014 1:23 PM, notbob wrote:
What the heck is a .pyc file and how are they created?
.pyc contained compiled bytecode. They are created when, and only when,
you import a module. Imported library files are often big and stable,
so their compiled forms get cached. Top-level scripts are
On 3/20/2014 3:07 PM, John Gordon wrote:
There are two ways (at least!) to run a python script:
1. Execute the python interpreter manually, supplying the python script name
as an arugment, like so:
python myscript.py
python2 otherscript.py
python3 yetanotherscript.py
On 03/20/2014 11:10 AM, notbob wrote:
On 2014-03-20, Zachary Ware zachary.ware+pyl...@gmail.com wrote:
If you're specifying the interpreter in your command (by calling
python scriptname.py, etc), the shebang won't mean anything
anyway.
DOH!
I was following you, fine, until that last
notbob not...@nothome.com:
Weeping Chryst on the cross!!. No wonder the latest O'Reilly book,
Learning Python, 5th ed, is 1600 pgs. I coulda swore someone sed
python is easy. ;)
It's not that bad. There are two principal dialects: python2 and
python3. Take the oldest python version you have
On 2014-03-20, Terry Reedy tjre...@udel.edu wrote:
That must be the only one you imported.
So it is. Thank you.
nb
--
https://mail.python.org/mailman/listinfo/python-list
Ned Batchelder n...@nedbatchelder.com:
On 3/20/14 4:59 PM, Marko Rauhamaa wrote:
Well, with proper care, I suppose the same code base could support perl
as well. ;)
I'm not sure how to take this comment. I feel like you are mocking my
choice. I wanted to make coverage.py available to as
On Thu, 20 Mar 2014 22:30:57 +0200, Marko Rauhamaa wrote:
To avoid nausea, I write sys.stdout.write() in all Python3 code.
Now that's funny.
I-know-I-shouldn't-respond-to-obvious-trolling-but-I-can't-help-myself-ly
yrs,
--
Steven D'Aprano
--
On 20/03/2014 22:23, Marko Rauhamaa wrote:
Ned Batchelder n...@nedbatchelder.com:
On 3/20/14 4:59 PM, Marko Rauhamaa wrote:
Well, with proper care, I suppose the same code base could support perl
as well. ;)
I'm not sure how to take this comment. I feel like you are mocking my
choice. I
On Fri, Mar 21, 2014 at 7:08 AM, Marko Rauhamaa ma...@pacujo.net wrote:
Alan Meyer amey...@yahoo.com:
I presume it would still be a good idea to test both python
interpreters against any script that you didn't knowingly write with a
feature that will only work in one of the two python
On Fri, Mar 21, 2014 at 9:23 AM, Marko Rauhamaa ma...@pacujo.net wrote:
Ned Batchelder n...@nedbatchelder.com:
On 3/20/14 4:59 PM, Marko Rauhamaa wrote:
Well, with proper care, I suppose the same code base could support perl
as well. ;)
I'm not sure how to take this comment. I feel like you
On Thu, 20 Mar 2014 21:28:43 +, notbob wrote:
On 2014-03-20, Mark H Harris harrismh...@gmail.com wrote:
When I call python2 that means python2.7.6 /
When I call python3 that means python3.3.4 /
I can also call python2.7, which is 2.7.2 /
You get the idea. There is no one set rule,
On Thu, 20 Mar 2014 16:26:39 -0400, Ned Batchelder wrote:
On 3/20/14 3:07 PM, Eric Jacoboni wrote:
Le 20/03/2014 16:21, Marko Rauhamaa a écrit :
All tutorials will tell you to start it with
#!/usr/bin/env python
which will start python2 on all (?) existing linux distros, but is
On Thu, 20 Mar 2014 16:53:25 -0400, Ned Batchelder wrote:
On 3/20/14 4:42 PM, Marko Rauhamaa wrote:
Ned Batchelder n...@nedbatchelder.com:
Plenty of people have adopted a dual-support strategy, with one code
base that supports both Python 2 and Python 3. The six module can help
a great deal
On Thu, 20 Mar 2014 22:50:45 +0200, Marko Rauhamaa wrote:
Mark Lawrence breamore...@yahoo.co.uk:
On 20/03/2014 20:30, Marko Rauhamaa wrote:
I must say, though, that Python3 destroyed print forever for me. To
avoid nausea, I write sys.stdout.write() in all Python3 code.
Not for me, I was
On 3/20/14 8:32 PM, Steven D'Aprano wrote:
On Thu, 20 Mar 2014 16:26:39 -0400, Ned Batchelder wrote:
On 3/20/14 3:07 PM, Eric Jacoboni wrote:
Le 20/03/2014 16:21, Marko Rauhamaa a écrit :
All tutorials will tell you to start it with
#!/usr/bin/env python
which will start python2 on
In article 532b8f0d$0$29994$c3e8da3$54964...@news.astraweb.com,
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote:
The rule of three applies here: anything you do in three different places
ought to be managed by a function.
I prefer the rule of two :-)
--
On Fri, Mar 21, 2014 at 11:32 AM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
Perhaps Arch-Linux is guilty of being prematurely Python 3...
I have no idea what our pain you are referring to, or who our refers
to. In the three or five years or so since Arch-Linux moved to Python
On Fri, Mar 21, 2014 at 11:59 AM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
The rule of three applies here: anything you do in three different places
ought to be managed by a function. Printing a newline at the end of a
line of output is *incredibly* common. Any language which
On 3/20/14 9:06 PM, Ned Batchelder wrote:
On 3/20/14 8:32 PM, Steven D'Aprano wrote:
On Thu, 20 Mar 2014 16:26:39 -0400, Ned Batchelder wrote:
On 3/20/14 3:07 PM, Eric Jacoboni wrote:
Le 20/03/2014 16:21, Marko Rauhamaa a écrit :
All tutorials will tell you to start it with
On 03/20/2014 05:37 PM, Steven D'Aprano wrote:
In my experience, such as it is, the hard part about writing code that
works from 2.4 to 3.4 is not the 3 versions but the 2.4 and 2.5 versions.
+1000! (yes, that's factorial ;)
--
~Ethan~
--
On Fri, Mar 21, 2014 at 12:06 PM, Roy Smith r...@panix.com wrote:
In article 532b8f0d$0$29994$c3e8da3$54964...@news.astraweb.com,
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote:
The rule of three applies here: anything you do in three different places
ought to be managed by a
On Friday, March 21, 2014 2:23:25 AM UTC+5:30, Ned Batchelder wrote:
On 3/20/14 4:42 PM, Marko Rauhamaa wrote:
Ned Batchelder :
Plenty of people have adopted a dual-support strategy, with one code
base that supports both Python 2 and Python 3. The six module can help
a great deal with
On 3/20/2014 3:07 PM, John Gordon wrote:
There are two ways (at least!) to run a python script:
On 21/03/2014 8:05 AM, Terry Reedy wrote:
3. [...]
Our chief weapon is...
--
https://mail.python.org/mailman/listinfo/python-list
On Thu, 20 Mar 2014 21:06:24 -0400, Ned Batchelder wrote:
In the #python IRC channel, there's a steady flow of people who run
programs they find online, and they get a syntax error on print, and
we say, Arch? and they say, yup.
When you install random programs you find online without going
On Fri, Mar 21, 2014 at 2:16 PM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
I haven't seen scripts broken because env
has moved, but I guess that's only a matter of time.
That usage is extremely common, and isn't it also specified by POSIX?
I think that's about as dependable as
Chris Angelico ros...@gmail.com:
go for the lowest common denominator:
print(some single string)
which works happily in all versions of Python.
Whenever I have used print in my code, it has been with a
redirection.
Marko
--
https://mail.python.org/mailman/listinfo/python-list
69 matches
Mail list logo