Importing problems

Discussion in 'Python' started by Gabriele *darkbard* Farina, Nov 6, 2004.

  1. 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.buffers import FileBuffer

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

    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
     
    Gabriele *darkbard* Farina, Nov 6, 2004
    #1
    1. Advertising

  2. Am Sat, 06 Nov 2004 06:53:02 -0800 schrieb Gabriele *darkbard* Farina:

    > Hi
    >
    > I've my application filesystem structured like this:


    ....

    > 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.buffers import FileBuffer


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


    The indentation got lost.

    > In 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??


    What does this print?
    print t.buffer.__class__

    HTH,
    Thomas
     
    Thomas Guettler, Nov 8, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    1,007
  2. John D.

    problems importing "bsddb"

    John D., Aug 12, 2003, in forum: Python
    Replies:
    0
    Views:
    305
    John D.
    Aug 12, 2003
  3. Michael Robinson

    Sporadic problems importing xml.dom.minidom

    Michael Robinson, May 27, 2004, in forum: Python
    Replies:
    3
    Views:
    373
    Peter Hansen
    May 28, 2004
  4. plb
    Replies:
    2
    Views:
    369
  5. Harold
    Replies:
    3
    Views:
    281
    Harold
    Jan 12, 2013
Loading...

Share This Page