[Tutor] Converting from a single module to a package

Timo timomlists at gmail.com
Sat Aug 6 12:17:55 CEST 2011


On 06-08-11 01:38, Emile van Sebille wrote:
> On 8/5/2011 4:22 PM Tim Johnson said...
>> * Christopher King<g.nius.ck at gmail.com>  [110805 12:03]:
>>> To make a package, you make a folder named what you want to name the
>>> package, for example: virus_toolkit. Then you make a file in it called
>>> __init__.py. This is what you import if you import the 
>>> virus_toolkit. You
>>> usually put documentation and general functions in this
>
>
> But you can provide for both methods if in tlib.__init__ you provide 
> for backward compatibility.
>
>
>>   # current way
>>   import tlib as std
>>   ....
>>   std.htmlButton(*arglist)
>>
>>   # New way, after transition
>>   import tlib as std
>
> in tlib.__init__, include the following:
>
> import html
> htmlButton = html.button
And print a deprecation warning when people use it like this. That way 
you let them know this method could be removed in a next version.
See the warnings module.

Cheers,
Timo

>
>>   std.html.button(*arglist)
>>   #OR
>>   import html from tlib
>>   html.button(*arglist)
>
> Emile
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor



More information about the Tutor mailing list