subclassing str

Chris Rebert clp2 at rebertia.com
Wed Nov 10 23:29:59 EST 2010


On Wed, Nov 10, 2010 at 8:14 PM, not1xor1 (Alessandro) <"
"@libero.it> wrote:
> Il 09/11/2010 03:18, Lawrence D'Oliveiro ha scritto:
>
>> How exactly does
>>
>>    a.f(b, c)
>>
>> save time over
>>
>>     f(a, b, c)
>
> unfortunately in real world you have:
>
> objId = objId.method(args)
>
> vs.
>
> objId = moduleName.method(objId, args)
>
> I know you can use "from moduleName import *", but IMHO that produces code
> much harder to manage and extend

So just don't use the form with the asterisk. Explicitly list the
members you wish to import from the module (`from moduleName import
meth1, meth2`). That way, you don't have to specify the module name on
every invocation, but the origin of the functions is still made
explicit.

Cheers,
Chris
--
http://blog.rebertia.com



More information about the Python-list mailing list