Python Forum

Full Version: Trying to convert a script from "2to3"
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I cannot for the life of me get 2to3 work for me and I was wondering if anyone would be gracious enough to help me out with it. I would sincerely appreciate it.
Could you elaborate? What reference resources are you using? What exactly did you try? How exactly did it not work?
(Feb-21-2017, 02:22 AM)micseydel Wrote: [ -> ]Could you elaborate? What reference resources are you using? What exactly did you try? How exactly did it not work?

Hello! Thank you for responding!

I am using this video as a reference:


It does it's thing, but never tells me to "try" to fix anything. So, I assumed that it corrected all of the mistakes, I typed -w in my command to write it and it created the script and the backup, but when I remove Python2, it asks me what program I want to use to open it. When I choose Python (33), it opens the program, but it's not working correctly. Basically, it is supposed to "sign" tga images with specific names. But even though it is in the same folder with the tga files, it's like they don't exist if that makes any sense at all. Am I allowed to post my script here? I am a complete infant when it comes to this so please bear with me.

(Feb-21-2017, 02:22 AM)micseydel Wrote: [ -> ]Could you elaborate? What reference resources are you using? What exactly did you try? How exactly did it not work?

Here is the Python 2 script:

And here is the 2to3 converted Python 3 script:

and what comes out as py3 code that does not work? (/me not looking at the code, yet)
(Feb-21-2017, 06:29 AM)Skaperen Wrote: [ -> ]and what comes out as py3 code that does not work?  (/me not looking at the code, yet)


It states that the files are not found, even though they are in the same folder as the script, which is how it is supposed to be.
in line 8 of either source code where does the variable name file come from?

is this "files not found" issue happening when you run your script or when you run 2to3 ?
Files (I assume that's the tga files) not found sounds like problem with the way you run the script (i.e. paths where it is looking for the files), not a problem with 2to3 conversion.

by the way file is built-in function in python2 so I would not use it as argument to the functions. Same for type.
file is gone in python 3.   so i wonder how 2to3 will handle that
(Feb-21-2017, 08:41 AM)Skaperen Wrote: [ -> ]file is gone in python 3.   so i wonder how 2to3 will handle that

You can look at the result code posted by the OP. Anyway I don't think this could cause problem as long as he doesn't try to use it as originally intended.
Note that it doesn't rise an exception, just os.path.exists cannot find the files.
Thank you guys for your help! The picture below is how it should look, but instead, it says that the files can't be found, but that they were verified.

[Image: fwhfgi.png]
Pages: 1 2