a fairly ugly/kludgy way to get 'aliases' in Python

Joshua Schmidlkofer menion at asylumwear.com
Sun Jan 19 08:47:16 CET 2003


On Sat, 2003-01-18 at 20:10, Cliff Wells wrote:
> On Fri, 2003-01-17 at 19:34, Jonathan P. wrote:
> > Cliff Wells <LogiplexSoftware at earthlink.net> wrote in message news:<mailman.1042827297.2914.python-list at python.org>...
> > 
> > > I don't think performance will be affected either way (it's all
> > > dictionary lookups).  Still, I wonder why you don't just use:
> > > 
> > > class A:
> > >     def __init__(self):
> > >         self.long_descriptive_name = 0
> > >         self.long_descriptive_name2 = 10
> > > 
> > >     def x(self):
> > >         alias1 = self.long_descriptive_name
> > >         alias2 = self.long_descriptive_name2
> > >         self.alias = alias2 * alias1
> > > 
> > > which would seem to be the equivalent, more readable form.
> > 
> > Ah but this won't work.  You need to do the D_[alias1]=newvalue
> > trick to get the value assigned to self.long_descriptive_name.
> > The behaviour is different and that's why I wonder if there
> > is a speed penalty involved.
> 
> Yes, after I posted this, I suddenly realized what you meant.  Then I
> frantically tried to reverse time, to a few seconds before I hit the
> send button, only to fail at that as well.  It seems I've lost my
> superpowers and will be forced to actually read posts before replying to
> them as I clearly can't rely on time-travel any more.  I'll probably
> have to start wearing my tinfoil hat again too.
> 
> Sadly,
> 
> -- 
> Cliff Wells <clifford.wells at attbi.com>

No... just start taking your pills again.


-- 
VB programmers ask why no one takes them seriously, 
it's somewhat akin to a McDonalds manager asking employees 
why they don't take their 'career' seriously.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 196 bytes
Desc: This is a digitally signed message part
URL: <http://mail.python.org/pipermail/python-list/attachments/20030118/745d111d/attachment.pgp>


More information about the Python-list mailing list