Newbie - instanciating classes from other files

Jorge Godoy godoy at ieee.org
Wed Sep 14 23:28:55 EDT 2005


comanighttrain at gmail.com writes:

> Hey guys, i just started learning python (i usually use java/C).
> 
> this has got me stumped as its not mentioned in the documentation
> (unless im skimming it every time).
> 
> How does one instanciate a class from another file
> 
> i thought it would be
> -----------------------------------code---------------------------
> import file.py
> 
> thisFile = ClassName()
> -------------------------------not code---------------------------

import file    # see that there's no ".py"
thisFile = file.ClassName()

or


from file import ClassName
thisFile = ClassName()


This is in the docs.

-- 
Jorge Godoy      <godoy at ieee.org>



More information about the Python-list mailing list