Calling a function from module question.

Sean sean at buildingonline.com
Tue Feb 15 15:25:47 EST 2005


Is there any way I could have the following work?

First I would have a module define a function to do
something like print some data.

----- module_name.py -----

[snip]

def print_this(data):
    print "This is the data: %s" %data

[/snip]

-----------------------------


Then I would have a script that uses the
print_this function defined in the module
without using the module name in the call.

----- test_file.py -----

[snip]

import module_name.py
print_this("lots of data")

[/snip]

----------------------

Now, I know I can call the function using
module_name.print_this("lots of data")
but can using the module name at the beginning
be avoided?

If not, why?  I am sure there is a good pythonic
explanation.

Thanks 





More information about the Python-list mailing list