sign in | join about | help | sitemap
Connecting Tech Pros Worldwide
Gabriele *darkbard* Farina's Avatar

Importing problems


Question posted by: Gabriele *darkbard* Farina (Guest) on July 18th, 2005 06:24 PM
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

1 Answer Posted
Thomas Guettler's Avatar
Thomas Guettler July 18th, 2005 06:27 PM
Guest - n/a Posts
#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.buffers import FileBuffer[/color]
[color=blue]
> and then I use the class this way:
> class Tokenizer:
> def __init__(self, source):
> self.buffer = FileBuffer(source)[/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.__class__

HTH,
Thomas

 
Not the answer you were looking for? Post your question . . .
196,949 members ready to help you find a solution.
Join Bytes.com

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 196,949 network members.
Post your question now . . .
It's fast and it's free

Popular Articles

Top Community Contributors