sequence multiplied by -1

Paul Rubin no.email at nospam.invalid
Sun Sep 26 02:46:57 EDT 2010


Steven D'Aprano <steve at REMOVE-THIS-cybersource.com.au> writes:
> I'm surprised that you think that you should be able to apply
> arbitrary mathematical operations to strings *before* turning them
> into an int and still get sensible results. That boggles my mind.

I think the idea is you should not be able to do mathematical operations
on strings, and if you try to do one, Python should raise an exception,
rather than using hokey analogies to guess at what you were trying to
do.  If you want to replicate a sequence, introduce a function with a
name like "replicate", rather than overloading an arithmetic operator.



More information about the Python-list mailing list