I agree.

I stick with empty __init__.py files, unless there is very good reason for
not doing so. I would google about it and gain some perspective. There are
reasons to use and not to use in both personal style all the way
to performance.

On Sunday, May 11, 2014, Justin Israel <[email protected]> wrote:

> I would say though that some might find it bad form to put class
> definitions and extensive code into the __init__.py of the package, as
> really what it is meant for is initialization. Personally I feel it is more
> appropriate to do this:
>
> mypackage/
>     __init__.py
>     myclass.py
>
> *__init__.py*
>
> from myclass import MyClass
> __all__ = ["MyClass"]
>
> If you end up with a package (directory) with just an __init__.py, then
> what you really wanted was a single module file.
> The kinds of things I put in my __init__.py (if they have anything at all)
> are import that aggregate subpackages, or initialization code that has to
> take the current platform into consideration. Basically anything that
> should set up the package.
>
>
>
>
> On Sun, May 11, 2014 at 9:59 PM, Marcus Ottosson 
> <[email protected]<javascript:_e(%7B%7D,'cvml','[email protected]');>
> > wrote:
>
>> You’d be rather unique in doing that and I wouldn’t consider it very
>> Pythonic, making it an extra barrier for readers of your code to grasp.
>>
>> Instead, you could define a class in your __init__.py and inherit from
>> that.
>>
>> Folders with __init__.py files are called “Packages” and can be treated
>> much like a class.
>>
>> import mypackage
>> mypackage.MyClass()
>> class MyNewClass(mypackage.MyClass):
>>     pass
>>
>> This would be called working with namespaces, which is very Pythonic.
>>
>>
>> On 11 May 2014 10:51, Jeremy YeoKhoo 
>> <[email protected]<javascript:_e(%7B%7D,'cvml','[email protected]');>
>> > wrote:
>>
>>> Hey gu
>>> I'm starting to cleanup my code, and since I've self taught programming
>>> from the get go and arent aware of some basic things. I have a question,.
>>> In regards to an __init__.py file. Can I use a folder that contains a
>>> __init__.py as an inherited object? And if I can, how do i structure the
>>> code?
>>>
>>>
>>> So if Car folder has __init__ how do I the call:
>>>
>>> class sportscar(car):
>>>     def __init__(self, car.__init__):
>>>         print "go vroom"
>>>
>>>
>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Python Programming for Autodesk Maya" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to 
>>> [email protected]<javascript:_e(%7B%7D,'cvml','python_inside_maya%[email protected]');>
>>> .
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/python_inside_maya/f36c7b49-d6dd-41c0-aa5f-4cc31a581034%40googlegroups.com<https://groups.google.com/d/msgid/python_inside_maya/f36c7b49-d6dd-41c0-aa5f-4cc31a581034%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> --
>> *Marcus Ottosson*
>> [email protected]<javascript:_e(%7B%7D,'cvml','[email protected]');>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Python Programming for Autodesk Maya" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to 
>> [email protected]<javascript:_e(%7B%7D,'cvml','python_inside_maya%[email protected]');>
>> .
>>  To view this discussion on the web visit
>> https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOBMJbSHqRV96nFQH_1J4dsBY-pkGL769LRVSSZZ%2BfN6Ww%40mail.gmail.com<https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOBMJbSHqRV96nFQH_1J4dsBY-pkGL769LRVSSZZ%2BfN6Ww%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to 
> [email protected]<javascript:_e(%7B%7D,'cvml','python_inside_maya%[email protected]');>
> .
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1DrN_0wD1%2BwNHTWqa-7E2L1QrrHJ2-%2B-NZaodqPyqrmw%40mail.gmail.com<https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1DrN_0wD1%2BwNHTWqa-7E2L1QrrHJ2-%2B-NZaodqPyqrmw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
*Marcus Ottosson*
[email protected]

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOCKxuibS_4Jwnc%2BgqVoSaBArzgo%3DhhPzr1wUJeHHZHsrA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to