Problem porting class to python3.2
Nick Buchholz
nbuchholz at noao.edu
Thu Jun 2 16:22:08 EDT 2011
On Thu, 02 Jun 2011 09:18:18 -0700
"Nick Buchholz" <nbuchholz at noao.edu> wrote:
>Hi all,
> I've been wandering through the DOCs for an hour and haven't found a solution to this
>I'm just starting to convert from 2.5 to 3.2 and I have a problem. I have a code that looks like this.
>
...code removed
>
First thanks to all who replied. FYI the classes in the file have been working in various
environments since I wrote them in python1.3 and updated them to python 2.x in 2005.
I think I solved the problem, well not solved in that I don't know why the technique I used failed.
but at least the code works when used as an import.
Under my 2.5 system I had a startup file that included the line
ld = execfile
mostly because I got tired of typing execfile('filename') to load in a file I was testing
2to3 complained it couldn't parse this line so I changed to
def ld(filename):
exec(compile(open(file).read(), file, 'exec'))
when I tried
ld('starDate.py') at the python3.2 prompt I got the indicated errors
if at the prompt I instead type
import starDate
I get no errors and the classes and methods work as expected. I'm sure this is a
name space problem but I don't know what the problem is. Its obvious that the 3.2
replacement for execfile does not have the same effect as execfile.
Thanks again
Nick
nbuchholz at noao.edu
Day phone: (520) 318-8203
"Time is an illusion, Lunchtime doubly so" - Ford Prefect
Time is an illusion perpetrated by the manufacturers of space.
More information about the Python-list
mailing list