Multiply a tuple by a constant

Michele Simionato michele.simionato at poste.it
Fri Feb 13 12:52:53 EST 2004


dj00302003 at yahoo.com (Jay Davis) wrote in message news:<1d17eeb7.0402130220.7258a5bd at posting.google.com>...
> I often need to multiply a tuple by a
> constant and the methods I use now are
> not very pretty.  The idea is to get a
> new tuple that is some factor times the
> start tuple, like  'newtup = .5 * oldtup'.
> 
> Is there a slick way to do this?

You can always subclass tuple and redefine "*". Dunno if you would
consider it slick enough.

   Michele



More information about the Python-list mailing list