[Tutor] Converting from a single module to a package

Emile van Sebille emile at fenx.com
Sat Aug 6 01:38:29 CEST 2011

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

>   std.html.button(*arglist)
>   #OR
>   import html from tlib
>   html.button(*arglist)


More information about the Tutor mailing list