[Python-ideas] Add a feature similar to C++ "using some_namespace"
Manuel Bärenz
manuel at enigmage.de
Mon Feb 7 22:48:20 CET 2011
> My 2 cents: Javascript has this "feature" (with). It's utterly terrible, and mainly a very good way to shoot yourself in the foot repeatedly.
>
> I especially find the assertion that:
>> This could be easier to […] read
> Extremely debatable: in my experience of that feature in Javascript, it makes code much harder to understand and reason about.
I get your point. Another downside is the uselessness of a "using"-block
on a frequent problem:
class Spam(object):
def frobnicate(self, egg1, egg2):
self.egg1 = egg1
self.egg2 = egg2
would translate to
class Spam(object):
def frobnicate(self, egg1, egg2):
using self:
egg1 = egg1
egg2 = egg2
, which is ridiculous.
However with Ethans Foxpro style suggestion, it would be ok and IMO
readable.
More information about the Python-ideas
mailing list