Classes and Functions - General Questions

Setash Setash at gmail.com
Wed Oct 18 16:27:10 EDT 2006


> >
> > And have class2 inherit class1 without any import statements, or need
> > it be imported first?
>
> It needs to be imported first:
>
> class1.py:
>
>     class Class1(object):
>         pass
>
> class2.py:
>     import class1
>
>     class Class2(class1.Class1):
>         pass
  >

In response to this, would the following also be possible:

classes.py:

  class Class1
    pass

  class Class2(Class1)
    pass


or would I still need to call it as:

  class Class2(classes.Class1)
    pass


Also, I have seen the following syntax used once before, and havent
found any documentation on it, any comments as to use, where to find
docs, etc?:

    from module import x as name
    name.function()

Thanks for the help, you explanation pretty much covered what I wanted
to know, but also got some more questions!




More information about the Python-list mailing list