|
View:
New views
20 Messages
—
Rating Filter:
Alert me
|
| < Prev | 1 - 2 | Next > |
|
|
trouble using 2to3.pyI'm in the process to learning Python 3.1, and need to convert a bunch
of handy functions I wrote and stole over several years. They are all written in 2.x, and are together in one file, mycalc.py. I created a folder E:\Python31\temp\ (my OS is Vista SP1 64-bit), and in it I placed copies of mycalc.py, 2to3.py, and a folder, lib2to3\ . Then I tried E:\Python31\temp>2to3.py -w mycalc.py and got Traceback (most recent call last): File "E:\Python31\temp\2to3.py", line 2, in <module> from lib2to3.main import main File "E:\Python31\temp\lib2to3\main.py", line 33 except os.error as err: ^ SyntaxError: invalid syntax How have others dealt with this? Dick Moores _______________________________________________ Tutor maillist - Tutor@... To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor |
|
|
Re: trouble using 2to3.pyAre you sure you're using the 3.1 version of Python to run the script?
Welcome back, btw. haven't heard from you in a while. On Tue, Nov 3, 2009 at 2:09 AM, Richard D. Moores <rdmoores@...> wrote: I'm in the process to learning Python 3.1, and need to convert a bunch _______________________________________________ Tutor maillist - Tutor@... To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor |
|
|
Re: trouble using 2to3.pyWell, here's the same try again, followed by starting the shell:
========================================= E:\Python31\temp>2to3.py -w mycalc.py Traceback (most recent call last): File "E:\Python31\temp\2to3.py", line 2, in <module> from lib2to3.main import main File "E:\Python31\temp\lib2to3\main.py", line 33 except os.error as err: ^ SyntaxError: invalid syntax E:\Python31\temp>python Python 3.1 (r31:73574, Jun 26 2009, 20:21:35) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> ========================================== Otherwise, how can I tell? BTW I'm doing this on my old desktop, which runs XP SP2 32-bit. And thanks, Luke, I took some time off to get back to my piano playing with a new teacher, my 6th IIRC. Now its time to do both. Dick On Tue, Nov 3, 2009 at 01:50, Luke Paireepinart <rabidpoobear@...> wrote: > Are you sure you're using the 3.1 version of Python to run the script? > Welcome back, btw. haven't heard from you in a while. > > On Tue, Nov 3, 2009 at 2:09 AM, Richard D. Moores <rdmoores@...> > wrote: >> >> I'm in the process to learning Python 3.1, and need to convert a bunch >> of handy functions I wrote and stole over several years. They are all >> written in 2.x, and are together in one file, mycalc.py. >> >> I created a folder E:\Python31\temp\ (my OS is Vista SP1 64-bit), and >> in it I placed copies of mycalc.py, 2to3.py, and a folder, lib2to3\ . >> >> Then I tried >> E:\Python31\temp>2to3.py -w mycalc.py >> >> and got >> >> Traceback (most recent call last): >> File "E:\Python31\temp\2to3.py", line 2, in <module> >> from lib2to3.main import main >> File "E:\Python31\temp\lib2to3\main.py", line 33 >> except os.error as err: >> ^ >> SyntaxError: invalid syntax >> >> How have others dealt with this? >> >> Dick Moores >> _______________________________________________ >> Tutor maillist - Tutor@... >> To unsubscribe or change subscription options: >> http://mail.python.org/mailman/listinfo/tutor > > Tutor maillist - Tutor@... To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor |
|
|
Re: trouble using 2to3.pyAnd here's the same try (without the -w switch, to keep it simple),
but this time on my laptop (64-bit Vista SP1). The result is a bit different: ===================================== C:\Python31\temp>2to3.py mycalc.py Traceback (most recent call last): File "C:\Python31\temp\2to3.py", line 2, in <module> from lib2to3.main import main File "C:\Python31\temp\lib2to3\main.py", line 121 print("At least one file or directory argument required.", file=sys.stderr) ^ SyntaxError: invalid syntax C:\Python31\temp>python Python 3.1.1 (r311:74483, Aug 17 2009, 16:45:59) [MSC v.1500 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> 1/4 0.25 >>> ========================================== Dick On Tue, Nov 3, 2009 at 02:15, Richard D. Moores <rdmoores@...> wrote: > Well, here's the same try again, followed by starting the shell: > > ========================================= > E:\Python31\temp>2to3.py -w mycalc.py > Traceback (most recent call last): > File "E:\Python31\temp\2to3.py", line 2, in <module> > from lib2to3.main import main > File "E:\Python31\temp\lib2to3\main.py", line 33 > except os.error as err: > ^ > SyntaxError: invalid syntax > > E:\Python31\temp>python > Python 3.1 (r31:73574, Jun 26 2009, 20:21:35) [MSC v.1500 32 bit > (Intel)] on win32 > Type "help", "copyright", "credits" or "license" for more information. >>>> > ========================================== > > Otherwise, how can I tell? > > BTW I'm doing this on my old desktop, which runs XP SP2 32-bit. > > And thanks, Luke, I took some time off to get back to my piano playing > with a new teacher, my 6th IIRC. Now its time to do both. > > Dick > > On Tue, Nov 3, 2009 at 01:50, Luke Paireepinart <rabidpoobear@...> wrote: >> Are you sure you're using the 3.1 version of Python to run the script? >> Welcome back, btw. haven't heard from you in a while. >> >> On Tue, Nov 3, 2009 at 2:09 AM, Richard D. Moores <rdmoores@...> >> wrote: >>> >>> I'm in the process to learning Python 3.1, and need to convert a bunch >>> of handy functions I wrote and stole over several years. They are all >>> written in 2.x, and are together in one file, mycalc.py. >>> >>> I created a folder E:\Python31\temp\ (my OS is Vista SP1 64-bit), and >>> in it I placed copies of mycalc.py, 2to3.py, and a folder, lib2to3\ . >>> >>> Then I tried >>> E:\Python31\temp>2to3.py -w mycalc.py >>> >>> and got >>> >>> Traceback (most recent call last): >>> File "E:\Python31\temp\2to3.py", line 2, in <module> >>> from lib2to3.main import main >>> File "E:\Python31\temp\lib2to3\main.py", line 33 >>> except os.error as err: >>> ^ >>> SyntaxError: invalid syntax >>> >>> How have others dealt with this? >>> >>> Dick Moores >>> _______________________________________________ >>> Tutor maillist - Tutor@... >>> To unsubscribe or change subscription options: >>> http://mail.python.org/mailman/listinfo/tutor >> >> > Tutor maillist - Tutor@... To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor |
|
|
Re: trouble using 2to3.py(Erasing entire history, since you both top-posted, and it's too confusing)
When you run a xxx.py on Windows, it locates the python.exe using the registry entries set up by assoc and ftype. But when you run "python" it looks for python.exe (or python.bat, or ...) on the PATH. So there's not necessarily any conection between your tests. You're probably running two different versions. Easiest way to know which python is being used is to run it same way: e:\python31\temp> python 2to3.py -w mycalc.py Or the way I do it, have python31.bat and python26.bat, which launch the exact pythons that I want. DaveA _______________________________________________ Tutor maillist - Tutor@... To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor |
|
|
Re: trouble using 2to3.pyAfter much fiddling around, I got 2to3 to work! And it did a fine, if
not perfect job on mycalc.py (which has about 120 functions and 1993 lines). What I did that worked, was to use the E:\Python26\Tools\Scripts, and not Python31. E:\Python26\Tools\Scripts has 2to3.py. I added the folder lib2to3\ and mycalc.py to E:\Python26\Tools\Scripts, and did a E:\Python26\Tools\Scripts>2to3 -w mycalc.py The -w switch first backed up mycalc.py as mycalc.py.bak, and then 2to3.py went to work. The only problems it couldn't handle are shown below. They are all of the same sort, involving a unicode error. I simply remmed out the problem causing functions, and now it seems mycalc.py is good to go with Python 3.1. I'll look into the "unicode" errors later -- much later. >>> from mycalc import * Traceback (most recent call last): File "<pyshell#0>", line 1, in <module> from mycalc import * File "E:\Python31\lib\site-packages\mycalc.py", line 172 """ SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 33-34: malformed \N character escape >>> from mycalc import * Traceback (most recent call last): File "<pyshell#1>", line 1, in <module> from mycalc import * File "E:\Python31\lib\site-packages\mycalc.py", line 186 """ SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 198-199: malformed \N character escape >>> from mycalc import * Traceback (most recent call last): File "<pyshell#2>", line 1, in <module> from mycalc import * File "E:\Python31\lib\site-packages\mycalc.py", line 207 file = open('E:\PythonWork\Nutshell\\words.txt', 'r') SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 13-14: malformed \N character escape >>> from mycalc import * >>> I also ran 2to3 again and this time captured the output as what appears to be a diff file: ================================== E:\Python26\Tools\Scripts>2to3 -w mycalc.py > 2to3_at_work.txt RefactoringTool: Skipping implicit fixer: buffer RefactoringTool: Skipping implicit fixer: idioms RefactoringTool: Skipping implicit fixer: set_literal RefactoringTool: Skipping implicit fixer: ws_comma RefactoringTool: Files that were modified: RefactoringTool: mycalc.py E:\Python26\Tools\Scripts> ================================== You can see the file produced at <http://www.rcblue.com/Misc/2to3_at_work.txt> Dick _______________________________________________ Tutor maillist - Tutor@... To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor |
|
|
Re: trouble using 2to3.pyOn Tue, Nov 3, 2009 at 05:30, Dave Angel <davea@...> wrote:
> (Erasing entire history, since you both top-posted, and it's too confusing) > > When you run a xxx.py on Windows, it locates the python.exe using the > registry entries set up by assoc and ftype. But when you run "python" it > looks for python.exe (or python.bat, or ...) on the PATH. So there's not > necessarily any conection between your tests. You're probably running two > different versions. > > Easiest way to know which python is being used is to run it same way: > > e:\python31\temp> python 2to3.py -w mycalc.py > > Or the way I do it, have python31.bat and python26.bat, which launch the > exact pythons that I want. Thanks, Dave. I'm not familiar with .bat files. Could you give me a look at one of them? Dick _______________________________________________ Tutor maillist - Tutor@... To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor |
|
|
Re: trouble using 2to3.pyRichard D. Moores wrote:
> On Tue, Nov 3, 2009 at 05:30, Dave Angel <davea@...> wrote: >> (Erasing entire history, since you both top-posted, and it's too confusing) >> >> When you run a xxx.py on Windows, it locates the python.exe using the >> registry entries set up by assoc and ftype. But when you run "python" it >> looks for python.exe (or python.bat, or ...) on the PATH. So there's not >> necessarily any conection between your tests. You're probably running two >> different versions. >> >> Easiest way to know which python is being used is to run it same way: >> >> e:\python31\temp> python 2to3.py -w mycalc.py >> >> Or the way I do it, have python31.bat and python26.bat, which launch the >> exact pythons that I want. > > Thanks, Dave. I'm not familiar with .bat files. Could you give me a > look at one of them? As an alternative, I've created python26.exe, python31.exe etc. in my c:\tools directory (which is on my PATH wherever I am) and which are hardlinks to their corresponding c:\python26\python.exe etc. Same as the batch file, really, only without a batch file! TJG _______________________________________________ Tutor maillist - Tutor@... To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor |
|
|
Re: trouble using 2to3.pyOn Tue, Nov 3, 2009 at 7:30 AM, Dave Angel <davea@...> wrote:
(Erasing entire history, since you both top-posted, and it's too confusing) I was under the impression that you were supposed to top-post unless you were referring to a specific thing someone said, in which case you quoted it, much like you do on a forum. Is that not how it works? I'd personally rather people top-posted unless they're specifically referencing something, otherwise there's a huge tree of quotiness that I have to scroll past before I can see what they're trying to say. Maybe that's just me, though. No one else seems to mind having to hit "reply to all" to send a message to the list either. Hopefully Google will succeed in their mission to replace e-mail with Wave and all messages will be in context and there will be no need for quoting one way or the other. -Luke _______________________________________________ Tutor maillist - Tutor@... To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor |
|
|
Re: trouble using 2to3.pyOn Tue, Nov 3, 2009 at 1:10 PM, Luke Paireepinart
<rabidpoobear@...> wrote: > I was under the impression that you were supposed to top-post unless you > were referring to a specific thing someone said, in which case you quoted > it, much like you do on a forum. > Is that not how it works? Presumably you are replying to *something* in the previous post, yes? > I'd personally rather people top-posted unless they're specifically > referencing something, otherwise there's a huge tree of quotiness that I > have to scroll past before I can see what they're trying to say. You (or whoever) should delete the part of the "huge tree of quotiness" that is not relevant to the reply. > Hopefully Google will succeed in their mission to replace e-mail with Wave > and all messages will be in context and there will be no need for quoting > one way or the other. Yes, that would help. Kent _______________________________________________ Tutor maillist - Tutor@... To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor |
|
|
Re: trouble using 2to3.py"Richard D. Moores" <rdmoores@...> wrote >> Or the way I do it, have python31.bat and python26.bat, which launch the >> exact pythons that I want. > > Thanks, Dave. I'm not familiar with .bat files. Could you give me a > look at one of them? A bat file is just a file of "DOS" commands and ends in .bat so python31.bat will contain the single line C:\path\ro\python\31\python.exe %* The %* is a placeholder for any commandline arguments you give when calling the batch file - like sys.argv in python. You then call it with python31 myscript.py There is a brief discussion and example of a bat file in the intro to my tutor, in the What is Programming topic. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ _______________________________________________ Tutor maillist - Tutor@... To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor |
|
|
Stolen thread: Bottom folk vs. toppers was trouble using 2to3.pyThe war between bottom posters and top posters has been long, arduous,
and most often incredibly silly. There have been written group rules mandating one over the other. Oft times these rules have doomed the group. I have used both approaches most often favoring top posting only because my mail program is set to reply from the top. True, it can be set to reply from the bottom and I can pick and choose as I see fit, but I usually let the program dictate. The reality is, bottom posters are not blessed by god and top posters are not bottom feeders. I simply propose that the only requirement to communications here is that replies and questions be well formulated, courteous, and reasonably intelligent. We are not 'Facebooks' and we hopefully do not condone cute rudeness and sophmoric attempts at vast intellect. I must say that the answers to my questions have almost always been incredibly well constructed and concisely and clearly presented. I almost never notice their placement within the post. If there are going to be arguments pertaining to the posts, let them be over content and not placement. Thanks to all who participate in this group. Robert Berman On Tue, 2009-11-03 at 12:10 -0600, Luke Paireepinart wrote: > > > On Tue, Nov 3, 2009 at 7:30 AM, Dave Angel <davea@...> wrote: > (Erasing entire history, since you both top-posted, and it's > too confusing) > I was under the impression that you were supposed to top-post unless > you were referring to a specific thing someone said, in which case you > quoted it, much like you do on a forum. > Is that not how it works? > I'd personally rather people top-posted unless they're specifically > referencing something, otherwise there's a huge tree of quotiness that > I have to scroll past before I can see what they're trying to say. > Maybe that's just me, though. No one else seems to mind having to hit > "reply to all" to send a message to the list either. > Hopefully Google will succeed in their mission to replace e-mail with > Wave and all messages will be in context and there will be no need for > quoting one way or the other. > -Luke > > _______________________________________________ > Tutor maillist - Tutor@... > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor _______________________________________________ Tutor maillist - Tutor@... To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor |
|
|
Re: trouble using 2to3.pyRichard D. Moores wrote:
> On Tue, Nov 3, 2009 at 05:30, Dave Angel <davea@...> wrote: > >> <snip> >> >> Easiest way to know which python is being used is to run it same way: >> >> e:\python31\temp> python 2to3.py -w mycalc.py >> >> Or the way I do it, have python31.bat and python26.bat, which launch the >> exact pythons that I want. >> > > Thanks, Dave. I'm not familiar with .bat files. Could you give me a > look at one of them? > > Dick > > It's a "program" interpreted by CMD.EXE, the shell processor for a "Command Prompt". Anyway, it's usually not much more than a list of programs to run, with their arguments. In our case, we just want to run a particular python.exe in a particular path, with whatever arguments were passed to the batch file. So mine are one line each, and look like: python26.bat ------------------- c:\progfiles\python26\python.exe %* python31.bat ------------------- c:\progfiles\python31\python.exe %* Obviously, yours will be different, unless you happened to pick the same install path as I did. The %* magic just means copy the rest of the original command line. You run these something like: m:\myscripts\ready > python31 myprogram.py to explicitly run python31 on the python script, myprogram.py DaveA _______________________________________________ Tutor maillist - Tutor@... To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor |
|
|
Re: Stolen thread: Bottom folk vs. toppers was trouble using 2to3.py[snip]
> The war between bottom posters and top posters has been long, arduous, > and most often incredibly silly. There have been written group rules > mandating one over the other. Oft times these rules have doomed the > group. > Two words come to mind: Bikeshed color. > I simply propose that the only requirement to communications here is > that replies and questions be well formulated, courteous, and reasonably > intelligent. Yup. -Modulok- _______________________________________________ Tutor maillist - Tutor@... To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor |
|
|
Re: Stolen thread: Bottom folk vs. toppers was trouble using2to3.py"Robert Berman" <bermanrl@...> wrote
> The war between bottom posters and top posters has been long, arduous, > and most often incredibly silly. It has, I agree but there is a very real difference in that gratuitous top posting does actually become unreadable if not done very carefully. And it also encorages people to leave the whole previous thread in place which is very naughty for those who pay for ther internet access by the byte! (Or those whose mail server implements space quotas!) But if a general comment is being made that does not need to refer to specific quotations from the earlier rtext then I have no problem with top posting. Provided all but a small context quote is left below. But please don't send me 3 pages of text to just add two sentences at the top!!! > I simply propose that the only requirement to communications here is > that replies and questions be well formulated, courteous, and reasonably > intelligent. Ah but there's the rub, what is "well formatted"? :-) > If there are going to be arguments pertaining to the posts, let them be > over content and not placement. When you are trying to respond to hundreds of emails a day a few top posted messages can cause severe headaches. Personally I just ignore anything that has top posting that is hard to read, I don't have time to unscramble it nor to waste time asking the poster to desist. If they post scrambled mail it doesn't get answered... So its not quite a case of the "color of the bikeshed" because this one does make a very real difference to the usability of the medium and to the success of the message in reaching its full audience. In most cases it doesn't hurt much but in longer threads it does. So, please folks, be sensitive to your readers. Alan G. _______________________________________________ Tutor maillist - Tutor@... To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor |
|
|
Re: trouble using 2to3.pyTim Golden wrote:
> Richard D. Moores wrote: >> On Tue, Nov 3, 2009 at 05:30, Dave Angel <davea@...> wrote: >>> <snip> >>> Or the way I do it, have python31.bat and python26.bat, which launch >>> the >>> exact pythons that I want. >> >> Thanks, Dave. I'm not familiar with .bat files. Could you give me a >> look at one of them? > > As an alternative, I've created python26.exe, python31.exe etc. in my > c:\tools directory (which is on my PATH wherever I am) and which are > hardlinks to their corresponding c:\python26\python.exe etc. > Same as the batch file, really, only without a batch file! > > TJG is interested), but I keep my scripts and batch files, as well as small utilities on a separate drive partition from the one that has my OS and installed programs. And hard links don't work across separate partitions. But tell me, how does python.exe find its "home" directory, to set initial sys.path and suchlike? I assumed it was done relative to the python.exe's full path location. But if you hard link, nobody knows where the real executable image resides (and in fact the concept has no meaning, since the two directory entries equally own the content). I once downloaded a program (which worked on many python scripts, but not all) which was written as a standin for python.exe, loading the pythonNN.dll and executing the script. The intentional difference was that instead of getting the script name from the commandline, it used its own name as the name of the script, and searched in the same directory for that script. So effectively if you made a copy of this program and called it doit.exe, when it ran it would find doit.py and run that script. One advantage it conferred is that the tasklist now identifies your program by name, instead of just having an anonymous python.exe running one (or six) instances. I don't remember what it was called, but I'd love to play with it further. And now I'd like to know how it could know where the lib files and suchlike are, as well. DaveA _______________________________________________ Tutor maillist - Tutor@... To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor |
|
|
Re: trouble using 2to3.pyMy sincere thanks to Dave Angel and Alan Gauld for their clear
explanations of .bat files and how to use them. I've already made several useful ones. Dick Moores _______________________________________________ Tutor maillist - Tutor@... To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor |
|
|
Re: trouble using 2to3.py"Richard D. Moores" <rdmoores@...> wrote > My sincere thanks to Dave Angel and Alan Gauld for their clear > explanations of .bat files and how to use them. I've already made > several useful ones. Start the cmd shell in windows and run the help command to get a list of things you can put in to spruce them up. It will explain how to use IF statements and FOR loops to make them much more powerful. But in practice if you know Python you will usually find it easier with that! :-) Alan G _______________________________________________ Tutor maillist - Tutor@... To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor |
|
|
Re: trouble using 2to3.pyOn Tue, Nov 3, 2009 at 16:46, Alan Gauld <alan.gauld@...> wrote:
> > "Richard D. Moores" <rdmoores@...> wrote >> >> My sincere thanks to Dave Angel and Alan Gauld for their clear >> explanations of .bat files and how to use them. I've already made >> several useful ones. > > Start the cmd shell in windows and run the help command to get a list of > things you can put in to spruce them up. Sorry, put in where? > It will explain how to use IF > statements and FOR loops to make them much more powerful. But in practice if > you know Python you will usually find it easier with that! :-) Wow, the "online help utility" for 3.1 looks really useful and informative. One question. Many of the articles are LONG. When I've got what wanted out of one, I want to quit, but don't know how to quit More. How to? Another is, although I've seen this before in older Python docs, I never really understood things like for_stmt ::= "for" target_list "in" expression_list ":" suite ["else" ":" suite] help> ::= no Python documentation found for '::=' In particular, what exactly does "::=" mean? Thanks, Dick _______________________________________________ Tutor maillist - Tutor@... To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor |
|
|
Re: trouble using 2to3.pyOn Tue, Nov 3, 2009 at 17:21, Richard D. Moores <rdmoores@...> wrote:
> Another is, although I've seen this before in older Python docs, I > never really understood things like > > for_stmt ::= "for" target_list "in" expression_list ":" suite > ["else" ":" suite] > > help> ::= > no Python documentation found for '::=' > > In particular, what exactly does "::=" mean? Found it. See <http://docs.python.org/3.1/reference/introduction.html#notation> Dick _______________________________________________ Tutor maillist - Tutor@... To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor |
| < Prev | 1 - 2 | Next > |
| Free embeddable forum powered by Nabble | Forum Help |