Python Import Statement

Tim Roberts timr at
Sun Jun 29 07:58:47 CEST 2003

jinal jhaveri <jhaveri at> wrote:
>Hi I have two files
> has 3 classes
>Now in I want to instantiate an object of class B
>so this is what I do in file b
>from xyz.A import B    (xyz is the directory where A is lying and the
>paths are set accordingly)

Python treats file names as case sensitive, so you probably want

  from xyz.a import B

Do you have an in directory xyz so Python knows it is a module?

>but it gives me an error of the kind, object cannot be called?

Not from that line, it doesn't.  Show us the line where you try to
instantiate it.  This kind of thing should work:

  from xyz.a import B
  bb = B()
- Tim Roberts, timr at
  Providenza & Boekelheide, Inc.

More information about the Python-list mailing list