Re: how to reference my own module ?

2008-05-10 Thread Stef Mientki

Terry Reedy wrote:
"Stef Mientki" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]

| hello,
|
| I've a library that I import as
|
|import ppygui.api as gui
|
| the reason for this construct is that I've to use different libraries
| for different platforms.
|
| Now I like to write some examples in the library (activated by if
| __name__ == '__main__' :)
| and I would that these examples can be used in the user program just by
| copy / paste.
|
| For calling a function / class in the user program I've to write:
|
|sizer = gui.VBox ()
|
| So also write exactly the same sentence in the library examples,
| but  "gui" is not recognized
|
| Any ideas how I can realize the above ?

Put the import statement in the example so 'gui' *is* recognized ;-)

If I understand what you meant ...
xploro/test/begin.py
-
def start():
print('hello')

if __name__ == '__main__':
import xploro.test.begin as etb
etb.start()

prints 'hello'|

Import is a name-binding statement that also creates a module when it does 
not exist already.  Modules can be bound to multiple names just like any 
other object.
  

Thanks Terry,
works like a charm,
why is the obvious often so difficult overlooked ;-)

cheers,
Stef

Terry Jan Reedy



--
http://mail.python.org/mailman/listinfo/python-list
  


--
http://mail.python.org/mailman/listinfo/python-list


Re: how to reference my own module ?

2008-05-10 Thread Terry Reedy

"Stef Mientki" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
| hello,
|
| I've a library that I import as
|
|import ppygui.api as gui
|
| the reason for this construct is that I've to use different libraries
| for different platforms.
|
| Now I like to write some examples in the library (activated by if
| __name__ == '__main__' :)
| and I would that these examples can be used in the user program just by
| copy / paste.
|
| For calling a function / class in the user program I've to write:
|
|sizer = gui.VBox ()
|
| So also write exactly the same sentence in the library examples,
| but  "gui" is not recognized
|
| Any ideas how I can realize the above ?

Put the import statement in the example so 'gui' *is* recognized ;-)

If I understand what you meant ...
xploro/test/begin.py
-
def start():
print('hello')

if __name__ == '__main__':
import xploro.test.begin as etb
etb.start()

prints 'hello'|

Import is a name-binding statement that also creates a module when it does 
not exist already.  Modules can be bound to multiple names just like any 
other object.

Terry Jan Reedy



--
http://mail.python.org/mailman/listinfo/python-list


how to reference my own module ?

2008-05-10 Thread Stef Mientki

hello,

I've a library that I import as

   import ppygui.api as gui

the reason for this construct is that I've to use different libraries 
for different platforms.


Now I like to write some examples in the library (activated by if 
__name__ == '__main__' :)
and I would that these examples can be used in the user program just by 
copy / paste.


For calling a function / class in the user program I've to write:

   sizer = gui.VBox ()

So also write exactly the same sentence in the library examples,
but  "gui" is not recognized

Any ideas how I can realize the above ?

thanks,
Stef Mientki



--
http://mail.python.org/mailman/listinfo/python-list