[Tutor] Alias for a class name

Ismael Garrido ismaelgf at adinet.com.uy
Thu Jul 13 01:49:12 CEST 2006


Gregor Lingl wrote:
> Hi everyoen,
>
> say in some module I have defined a class Pen
> and I want an alias for the class name, say
> Turtle
>
> I can do this:
>
> class Turtle(Pen):
>     pass
>
> or simply (after having defined Pen):
>
> Turtle = Pen
>
> Are those two variants different in effect?
> Are there pros or cons for one of both
> variants?
>
> Regards,
> Gregor
If you are making an alias... use Turtle = Pen...
Inheritance for this seems WAY too weird. It took me a minute to realise 
what you were trying to do. Instead, Turtle = Pen is clear and direct... 
More "pythonic" perhaps.

Also, Inheritance may cause some variables to be hardly accesible (like 
if they're __mangled).

Ismael


More information about the Tutor mailing list