The REALLY bad thing about Python lists ..
Ben Wolfson
rumjuggler at cryptarchy.org
Wed May 24 23:48:18 EDT 2000
On Thu, 25 May 2000 03:16:57 +0100, Russell Wallace
<rwallace at esatclear.ie> wrote:
>Greg Ewing wrote:
>> I'd much rather have an honest, well-defined "wrap around"
>> operator that I can rely on, even if I have to look up the
>> language definition now and then, than have to wade through
>> code that's been obfuscated to work around its absence.
>
>So define one.
>
>def wrapmod(x, y):
> while x < 0:
> x = x + y # simple implementation, could do it more efficiently
> return x % y
>From what I've seen of what negative modulo operators do, it seems as
if
def wrapmod(x, y):
return (( x%y ) + y ) % y )
would work
--
Barnabas T. Rumjuggler
The world is turning into a cesspool of imbeciles.
-- Harlan Ellison
More information about the Python-list
mailing list