[Tutor] self.attribute and import attribute

Joson zhuchunml at gmail.com
Sat Apr 24 04:27:12 CEST 2010


Hi all,
I have a problem about variables efficiency.
As below, I import f from config.py, Then f is appended to app1.py global
variables.
In class App, there're two ways to use this variable. One is "self.file =f",
then use self.file; the other is using "f" directory. Which way is high
efficient?

config.py:
f = file("test.txt")


app1.py:
from config import *

class App:
    def __init__(self):
        self.file = Attr1

    def run(self):
        self.file.write("...")
        # f.write("...")

Regards.
Joson
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100424/2e684f53/attachment.html>


More information about the Tutor mailing list