Calling a function from module question.

Steven Bethard steven.bethard at gmail.com
Tue Feb 15 17:04:07 EST 2005


Sean wrote:
>>>>from module_name import print_this
>>>
>>>>or, even:
>>>>
>>>
>>>>from module_name import print_this as other_nice_name
>>>
>>>So what if I have a whole bunch of functions - say 25 of them.
>>>Is there a way to do this without naming each function?
>>
>>Yes [1], but it's basically deprecated and you shouldn't use it. Consider 
>>refactoring your code.
> 
> Refactoring my code?  Sorry, I am not sure what you mean here.
> 
> How would one refactor the example in my original post? 

The original post only had one name to import, not 25, so refactoring 
isn't really necessary. ;)  What are the 25 functions you want to 
import?  Perhaps you can group them together in classes?  Or maybe a 
couple of (sub-)modules is the way to go...

STeVe



More information about the Python-list mailing list