On Mon, 07 Dec 2009 22:18:49 -0000, J <dreadpiratej...@gmail.com> wrote:

On Mon, Dec 7, 2009 at 16:57, Diez B. Roggisch <de...@nospam.web.de> wrote:

if I put the import at the beginning of the class, it just dawned on
me that perhaps I still have to explicitly call the function by class:

sysinfo.py

class myclass():
   import os
   def findDMIDecode(self):
       for r,d,f in myclass.os.walk(args)

is that correct?

It is correct in the sense that it works, but it is by no means good
practice.

So good practice (I'm doing this for real as well as for my own
education) would be:

sysinfo.py:

import os

class ClassA():
    sysinfo.os.walk()

class ClassB():
    sysinfo.os.walk()

Nope.  Good practice would be:

import os

class ClassA(object):
    os.walk()

class ClassB(object):
    os.walk()

--
Rhodri James *-* Wildebeest Herder to the Masses
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to