Python Forum
Trying to convert a script from "2to3" - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Trying to convert a script from "2to3" (/thread-2126.html)

Pages: 1 2


Trying to convert a script from "2to3" - JohnathanMonkey - Feb-21-2017

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.


RE: Trying to convert a script from "2to3" - micseydel - Feb-21-2017

Could you elaborate? What reference resources are you using? What exactly did you try? How exactly did it not work?


RE: Trying to convert a script from "2to3" - JohnathanMonkey - Feb-21-2017

(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:




RE: Trying to convert a script from "2to3" - Skaperen - Feb-21-2017

and what comes out as py3 code that does not work? (/me not looking at the code, yet)


RE: Trying to convert a script from "2to3" - JohnathanMonkey - Feb-21-2017

(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.


RE: Trying to convert a script from "2to3" - Skaperen - Feb-21-2017

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 ?


RE: Trying to convert a script from "2to3" - buran - Feb-21-2017

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.


RE: Trying to convert a script from "2to3" - Skaperen - Feb-21-2017

file is gone in python 3.   so i wonder how 2to3 will handle that


RE: Trying to convert a script from "2to3" - buran - Feb-21-2017

(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.


RE: Trying to convert a script from "2to3" - JohnathanMonkey - Feb-21-2017

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]