Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #6890

Re: Problem porting class to python3.2

From "Nick Buchholz" <nbuchholz@noao.edu>
Subject Re: Problem porting class to python3.2
Date 2011-06-02 13:22 -0700
References <web-74580125@email.noao.edu>
Newsgroups comp.lang.python
Message-ID <mailman.2403.1307052432.9059.python-list@python.org> (permalink)

Show all headers | View raw


On Thu, 02 Jun 2011 09:18:18 -0700
 "Nick Buchholz" <nbuchholz@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@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.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Problem porting class to python3.2 "Nick Buchholz" <nbuchholz@noao.edu> - 2011-06-02 13:22 -0700

csiph-web