[Yum-devel] [PATCH] clean up all the import yum.blah and from yum.blah import blah

Tim Lauridsen tim.lauridsen at googlemail.com
Wed Sep 30 16:05:48 UTC 2009


On 09/30/2009 04:20 PM, Seth Vidal wrote:
>
>
> On Wed, 30 Sep 2009, Tim Lauridsen wrote:
>
>>> from constants import *
>>> import metalink
>>>
>>
>> Why ?
>>
>> from yum.i18n import ....
>>
>> is more readable than
>>
>> from i18n import .....
>>
>> and it is easier to see what is a yum submodule.
>>
>
> That's a fair point - major concern I've ever had is importing the wrong
> module if you're working in a separate working path.
>
> maybe that's not a real concern but it was at one point for me and I got
> into that habit.
>
> You do make a good point about figuring out what is from the yum module
> and what is not, though..
>
> I'll think about it.
>

Another point is Python 3, where local dir imports are changed[1] so.

import constants (Python 2.x)

will be

from . import constants (Python 3.x)

but

import yum.constants

with work in both 2.x and 3.x

Tim

[1] : http://diveintopython3.org/porting-code-to-python-3-with-2to3.html#import


More information about the Yum-devel mailing list