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
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
|
|
|
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.
Top Community Contributors
|