Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #68581 > unrolled thread
| Started by | notbob <notbob@nothome.com> |
|---|---|
| First post | 2014-03-20 14:58 +0000 |
| Last post | 2014-03-20 22:19 +0000 |
| Articles | 10 on this page of 70 — 21 participants |
Back to article view | Back to comp.lang.python
running python 2 vs 3 notbob <notbob@nothome.com> - 2014-03-20 14:58 +0000
Re: running python 2 vs 3 Marko Rauhamaa <marko@pacujo.net> - 2014-03-20 17:21 +0200
Re: running python 2 vs 3 notbob <notbob@nothome.com> - 2014-03-20 16:00 +0000
Re: running python 2 vs 3 Zachary Ware <zachary.ware+pylist@gmail.com> - 2014-03-20 11:14 -0500
Re: running python 2 vs 3 notbob <notbob@nothome.com> - 2014-03-20 17:10 +0000
Re: running python 2 vs 3 Chris Angelico <rosuav@gmail.com> - 2014-03-21 04:30 +1100
Re: running python 2 vs 3 Gary Herron <gary.herron@islandtraining.com> - 2014-03-20 10:45 -0700
Re: running python 2 vs 3 John Gordon <gordon@panix.com> - 2014-03-20 19:07 +0000
Re: running python 2 vs 3 Terry Reedy <tjreedy@udel.edu> - 2014-03-20 18:05 -0400
Re: running python 2 vs 3 alex23 <wuwei23@gmail.com> - 2014-03-21 12:37 +1000
Re: running python 2 vs 3 Michael Torrie <torriem@gmail.com> - 2014-03-20 15:44 -0600
Re: running python 2 vs 3 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-20 18:56 +0000
Re: running python 2 vs 3 Eric Jacoboni <eric.jacoboni@gmail.com> - 2014-03-20 20:07 +0100
Re: running python 2 vs 3 Ned Batchelder <ned@nedbatchelder.com> - 2014-03-20 16:26 -0400
Re: running python 2 vs 3 notbob <notbob@nothome.com> - 2014-03-20 21:16 +0000
Re: running python 2 vs 3 Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-21 00:32 +0000
Re: running python 2 vs 3 Ned Batchelder <ned@nedbatchelder.com> - 2014-03-20 21:06 -0400
Re: running python 2 vs 3 Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-21 03:16 +0000
Re: running python 2 vs 3 Chris Angelico <rosuav@gmail.com> - 2014-03-21 14:34 +1100
Re: running python 2 vs 3 Chris Angelico <rosuav@gmail.com> - 2014-03-21 12:10 +1100
Re: running python 2 vs 3 Ned Batchelder <ned@nedbatchelder.com> - 2014-03-20 21:20 -0400
Re: running python 2 vs 3 Alan Meyer <ameyer2@yahoo.com> - 2014-03-20 15:53 -0400
Re: running python 2 vs 3 Marko Rauhamaa <marko@pacujo.net> - 2014-03-20 22:08 +0200
Re: running python 2 vs 3 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-20 20:22 +0000
Re: running python 2 vs 3 Marko Rauhamaa <marko@pacujo.net> - 2014-03-20 22:30 +0200
Re: running python 2 vs 3 Zachary Ware <zachary.ware+pylist@gmail.com> - 2014-03-20 15:43 -0500
Re: running python 2 vs 3 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-20 20:44 +0000
Re: running python 2 vs 3 Marko Rauhamaa <marko@pacujo.net> - 2014-03-20 22:50 +0200
Re: running python 2 vs 3 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-20 21:36 +0000
Re: running python 2 vs 3 Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-21 00:59 +0000
Re: running python 2 vs 3 Roy Smith <roy@panix.com> - 2014-03-20 21:06 -0400
Re: running python 2 vs 3 Chris Angelico <rosuav@gmail.com> - 2014-03-21 13:18 +1100
Re: running python 2 vs 3 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-21 09:40 +0000
Re: running python 2 vs 3 alister <alister.nospam.ware@ntlworld.com> - 2014-03-21 12:09 +0000
Re: running python 2 vs 3 Chris Angelico <rosuav@gmail.com> - 2014-03-21 12:15 +1100
Re: running python 2 vs 3 Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-20 22:39 +0000
Re: running python 2 vs 3 Ned Batchelder <ned@nedbatchelder.com> - 2014-03-20 16:27 -0400
Re: running python 2 vs 3 Marko Rauhamaa <marko@pacujo.net> - 2014-03-20 22:42 +0200
Re: running python 2 vs 3 Ned Batchelder <ned@nedbatchelder.com> - 2014-03-20 16:53 -0400
Re: running python 2 vs 3 Marko Rauhamaa <marko@pacujo.net> - 2014-03-20 22:59 +0200
Re: running python 2 vs 3 Chris Kaynor <ckaynor@zindagigames.com> - 2014-03-20 14:18 -0700
Re: running python 2 vs 3 Ned Batchelder <ned@nedbatchelder.com> - 2014-03-20 17:31 -0400
Re: running python 2 vs 3 Marko Rauhamaa <marko@pacujo.net> - 2014-03-21 00:23 +0200
Re: running python 2 vs 3 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-20 22:42 +0000
Re: running python 2 vs 3 Chris Angelico <rosuav@gmail.com> - 2014-03-21 10:18 +1100
Re: running python 2 vs 3 Marko Rauhamaa <marko@pacujo.net> - 2014-03-21 07:49 +0200
Re: running python 2 vs 3 Chris Angelico <rosuav@gmail.com> - 2014-03-21 16:54 +1100
Re: running python 2 vs 3 Marko Rauhamaa <marko@pacujo.net> - 2014-03-21 08:08 +0200
Re: running python 2 vs 3 Rustom Mody <rustompmody@gmail.com> - 2014-03-20 23:51 -0700
Re: running python 2 vs 3 Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-21 00:37 +0000
Re: running python 2 vs 3 Ethan Furman <ethan@stoneleaf.us> - 2014-03-20 18:23 -0700
Re: running python 2 vs 3 Rustom Mody <rustompmody@gmail.com> - 2014-03-20 19:20 -0700
Re: running python 2 vs 3 Chris Angelico <rosuav@gmail.com> - 2014-03-21 10:04 +1100
Re: running python 2 vs 3 Mark H Harris <harrismh777@gmail.com> - 2014-03-20 15:10 -0500
Re: running python 2 vs 3 notbob <notbob@nothome.com> - 2014-03-20 21:28 +0000
Re: running python 2 vs 3 Mark H Harris <harrismh777@gmail.com> - 2014-03-20 16:46 -0500
Re: running python 2 vs 3 Marko Rauhamaa <marko@pacujo.net> - 2014-03-21 00:17 +0200
Re: running python 2 vs 3 Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-21 00:29 +0000
Re: running python 2 vs 3 Dan Stromberg <drsalists@gmail.com> - 2014-03-20 13:38 -0700
Re: running python 2 vs 3 Marko Rauhamaa <marko@pacujo.net> - 2014-03-20 22:46 +0200
Re: running python 2 vs 3 Mark H Harris <harrismh777@gmail.com> - 2014-03-20 11:11 -0500
Re: running python 2 vs 3 notbob <notbob@nothome.com> - 2014-03-20 17:23 +0000
Re: running python 2 vs 3 Chris Angelico <rosuav@gmail.com> - 2014-03-21 04:29 +1100
Re: running python 2 vs 3 Marko Rauhamaa <marko@pacujo.net> - 2014-03-20 19:45 +0200
Re: running python 2 vs 3 Mark H Harris <harrismh777@gmail.com> - 2014-03-20 12:42 -0500
Re: running python 2 vs 3 Marko Rauhamaa <marko@pacujo.net> - 2014-03-20 19:47 +0200
Re: running python 2 vs 3 Ned Batchelder <ned@nedbatchelder.com> - 2014-03-20 14:45 -0400
Re: running python 2 vs 3 Mark H Harris <harrismh777@gmail.com> - 2014-03-20 14:36 -0500
Re: running python 2 vs 3 Terry Reedy <tjreedy@udel.edu> - 2014-03-20 17:52 -0400
Re: running python 2 vs 3 notbob <notbob@nothome.com> - 2014-03-20 22:19 +0000
Page 4 of 4 — ← Prev page 1 2 3 [4]
| From | Mark H Harris <harrismh777@gmail.com> |
|---|---|
| Date | 2014-03-20 11:11 -0500 |
| Message-ID | <lgf3ve$iuc$1@speranza.aioe.org> |
| In reply to | #68581 |
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 side-by-side. If you access your scripts from the same directory (I do not) there really is no problem. The reason is that the .pyc files created for python2.x are only used by python2. The .pyc files for python3.x are kept (by a naming convention) in __pycache__ , so there really is no problem. Having said that, the only problem is that your script for python3 might not run in python2 (for various reasons) but the problem is not that the scripts are contained in the same folder. I keep my python2 scripts in one folder ~/Documents/Python2/ and my python3 scripts in another one ~/Documents/Python3/ I add the two folders in the python paths browser (using site-packages) so that when I start IDLE for python2 it pulls its scripts from ~/Documents/Python2/ and when I start IDLE for python3 it pulls its scripts from ~/Documents/Python3/ There are *many* ways to organize this. Often I have to maintain two scripts (packages) one for each version. Although, I try to make my scripts run in both environments. Often I have IDLE(2) ane IDLE(3) running and testing at the same time on the same box. This works very well. marcus
[toc] | [prev] | [next] | [standalone]
| From | notbob <notbob@nothome.com> |
|---|---|
| Date | 2014-03-20 17:23 +0000 |
| Message-ID | <bp0mgcF7aqdU4@mid.individual.net> |
| In reply to | #68585 |
On 2014-03-20, Mark H Harris <harrismh777@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 compiled binary, but I where did it come from? I went back to my ~/python/ dir and noticed one .pyc file out of 15 .py files I created from following Learning Python the Hard Way. No one said anything about creating a binary. I know I discovered how to create/edit python scripts from IDLE. Is that it? I've been using gedit and emacs up till now. Seems the file with the .pyc file is the one I edited in IDLE. Is that why LPtHW eschews IDLE for gedit? Why do I feel like I've really stepped in it? ;) nb
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2014-03-21 04:29 +1100 |
| Message-ID | <mailman.8305.1395336598.18130.python-list@python.org> |
| In reply to | #68588 |
On Fri, Mar 21, 2014 at 4:23 AM, notbob <notbob@nothome.com> wrote: > On 2014-03-20, Mark H Harris <harrismh777@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 compiled binary, but I where did it come from? > > I went back to my ~/python/ dir and noticed one .pyc file out of 15 > .py files I created from following Learning Python the Hard Way. No > one said anything about creating a binary. I know I discovered how to > create/edit python scripts from IDLE. Is that it? I've been using > gedit and emacs up till now. Seems the file with the .pyc file is the > one I edited in IDLE. Is that why LPtHW eschews IDLE for gedit? > > Why do I feel like I've really stepped in it? ;) > You should be able to completely ignore .pyc files, most of the time. The only thing to remember is that you should delete them any time you delete the corresponding .py files. They're a cached version that Python will use to speed up imports, nothing more. Nowadays they'll be pushed away into a separate directory, which makes them easier for you to ignore. This is a good thing. ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Marko Rauhamaa <marko@pacujo.net> |
|---|---|
| Date | 2014-03-20 19:45 +0200 |
| Message-ID | <87k3bon4qg.fsf@elektro.pacujo.net> |
| In reply to | #68589 |
Chris Angelico <rosuav@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
[toc] | [prev] | [next] | [standalone]
| From | Mark H Harris <harrismh777@gmail.com> |
|---|---|
| Date | 2014-03-20 12:42 -0500 |
| Message-ID | <lgf99a$3fc$1@speranza.aioe.org> |
| In reply to | #68588 |
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 bytecode. The process takes time. So, the solution is to place the tokenized stuff into a .pyc file so that the process does not have to be repeated unless, of course, the source has changed since the last .pyc file create. It used to be that the .pyc files went into the same dir as the source (that's how it works for python2) but now with python3 they go into a directory in your source tree called __pycache__, and they are named based on python version (a way better scheme for sure). 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 source from their users). marcus
[toc] | [prev] | [next] | [standalone]
| From | Marko Rauhamaa <marko@pacujo.net> |
|---|---|
| Date | 2014-03-20 19:47 +0200 |
| Message-ID | <87fvmcn4o1.fsf@elektro.pacujo.net> |
| In reply to | #68591 |
Mark H Harris <harrismh777@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 source from their > users). 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. Marko
[toc] | [prev] | [next] | [standalone]
| From | Ned Batchelder <ned@nedbatchelder.com> |
|---|---|
| Date | 2014-03-20 14:45 -0400 |
| Message-ID | <mailman.8309.1395341130.18130.python-list@python.org> |
| In reply to | #68593 |
On 3/20/14 1:47 PM, Marko Rauhamaa wrote: > Mark H Harris <harrismh777@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 source from their >> users). > > 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. > Python3 still makes no guarantees about the compatibility of bytecode (and therefore .pyc files) across versions of Python, so if you want to run from pure .pyc files, you have to be sure to use the same version of Python that produced the files. --Ned. > > Marko > -- Ned Batchelder, http://nedbatchelder.com
[toc] | [prev] | [next] | [standalone]
| From | Mark H Harris <harrismh777@gmail.com> |
|---|---|
| Date | 2014-03-20 14:36 -0500 |
| Message-ID | <lgffvt$n40$1@speranza.aioe.org> |
| In reply to | #68593 |
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 principles and sensibilities these days. So, 1) no intellectual property 2) no software idea patents 3) no obfuscated code 4) ship the source, or don't ship anything/ In my view coding (and all other aspects of computer science including software engineering) is a liberal art; it should be open, free (libre), and available to everyone. People learn best by doing, and the do best by reading what others have done before them. marcus
[toc] | [prev] | [next] | [standalone]
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Date | 2014-03-20 17:52 -0400 |
| Message-ID | <mailman.8324.1395352349.18130.python-list@python.org> |
| In reply to | #68588 |
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 typically short and often volotile. They may be as short as "from start import run; run()" in order to have as much as possible stored in compiled form. This has nothing to do with Idle. > I went back to my ~/python/ dir and noticed one .pyc file out of 15 > .py files I created from following Learning Python the Hard Way. That must be the only one you imported. -- Terry Jan Reedy
[toc] | [prev] | [next] | [standalone]
| From | notbob <notbob@nothome.com> |
|---|---|
| Date | 2014-03-20 22:19 +0000 |
| Message-ID | <bp17riFaoq9U5@mid.individual.net> |
| In reply to | #68629 |
On 2014-03-20, Terry Reedy <tjreedy@udel.edu> wrote: > That must be the only one you imported. So it is. Thank you. nb
[toc] | [prev] | [standalone]
Page 4 of 4 — ← Prev page 1 2 3 [4]
Back to top | Article view | comp.lang.python
csiph-web