On Jul 23, 9:42 am, Chris Angelico <ros...@gmail.com> wrote: > On Sat, Jul 23, 2011 at 4:53 PM, Frank Millman <fr...@chagford.com> wrote: > > The problem with that is that it will silently ignore any non-zero > > digits after the point. Of course int(float(x)) does the same, which I > > had overlooked. > > If you know that there will always be a trailing point, you can trim > off any trailing 0s, then trim off a trailing '.', and then cast to > int: > > int(s.rstrip('0').rstrip('.')) >
I like it. 100% solution to the problem, and neater than the alternatives. Thanks Frank -- http://mail.python.org/mailman/listinfo/python-list