Importing problems

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Gabriele *darkbard* Farina

    #1

    Importing problems

    Hi

    I've my application filesystem structured like this:

    app/
    -main.py
    -pharaon/
    --__init__.py
    --engine/
    ---__init__.py
    ---php/
    ----__init__.py
    ----tokenizer.py
    --utils
    ---__init__.py
    ---buffers.py


    I'd like to use a class defined in the module pharaon/utils/buffers.py
    inside a class defined in pharaon/engine/php/tokenizer.py

    I import the class this way (inside buffers.py):
    from pharaon.utils.b uffers import FileBuffer

    and then I use the class this way:
    class Tokenizer:
    def __init__(self, source):
    self.buffer = FileBuffer(sour ce)

    inside the main.py file I got this code:
    from pharaon.engine. php.tokenizer import Tokenizer
    t = Tokenizer("test .php")
    print t.buffer

    but when I run the code it prints None.
    why?? I wrong importing the modules??

    bye

  • Thomas Guettler

    #2
    Re: Importing problems

    Am Sat, 06 Nov 2004 06:53:02 -0800 schrieb Gabriele *darkbard* Farina:
    [color=blue]
    > Hi
    >
    > I've my application filesystem structured like this:[/color]

    ....
    [color=blue]
    > I'd like to use a class defined in the module pharaon/utils/buffers.py
    > inside a class defined in pharaon/engine/php/tokenizer.py
    >
    > I import the class this way (inside buffers.py):
    > from pharaon.utils.b uffers import FileBuffer[/color]
    [color=blue]
    > and then I use the class this way:
    > class Tokenizer:
    > def __init__(self, source):
    > self.buffer = FileBuffer(sour ce)[/color]

    The indentation got lost.
    [color=blue]
    > In main.py file I got this code:
    > from pharaon.engine. php.tokenizer import Tokenizer
    > t = Tokenizer("test .php")
    > print t.buffer[/color]
    [color=blue]
    > but when I run the code it prints None.
    > why?? I wrong importing the modules??[/color]

    What does this print?
    print t.buffer.__clas s__

    HTH,
    Thomas

    Comment

    Working...