Best Practices for Internal Package Structure

Sven R. Kunze srkunze at mail.de
Tue Apr 5 15:09:16 EDT 2016


On 05.04.2016 20:40, Ethan Furman wrote:
>
>> (utils.py does export a couple of functions, but they should be in 
>> the main
>> module, or possibly made into a method of BidirectionalMapping.)
>>
>> Your package is currently under 500 lines. As it stands now, you could
>> easily flatten it to a single module:
>>
>> bidict.py
>
> Yup... well, actually you could just stick it in __init__.py.

Interesting. We did (and I started it) a similar thing for some packages 
which then grew unbearably in a single year.


Now, everybody in team agrees with: 'who idiot put this stuff in 
__ini__.py?' It was me who started it so I take it with a smile. But 
it's definitely a wart.

So, we have a new guideline since then: "empty __init__.py" if possible 
of course; you sometimes need to collect/do magic imports but that's a 
separate matter.


Best,
Sven



More information about the Python-list mailing list