DISQUS

DISQUS Hello!  The comments on this profile are unclaimed and thus are unverified.

Do they belong to you? Claim these comments.

Anon E. Moose's picture

Unregistered

Feeds

aliases

  • Anon E. Moose
  • aoeu

Anon E. Moose

6 months ago

in Python extended slice assignment - gumuz.nl on gumuz.nl
Actually, I still haven't simplified completely; the middle part of the slice could be omitted entirely. Man I love python.
so, the final concise Line 7 would be:
siv[2*i::i]=[0]*(n/i-1)

-DtBeloBrown

6 months ago

in Python extended slice assignment - gumuz.nl on gumuz.nl
the middle part of the slice in question (on line 7) is the expression n/i*i+1.
This is not incorrect, but could be simply n+1. Why divide and then multiply by i? Am I missing something subtle here?
2 replies
aoeu Actually, I still haven't simplified completely; the middle part of the slice could be omitted entirely. Man I love python.
so, the final concise Line 7 would be:
siv[2*i::i]=[0]*(n/i-1)

-DtBeloBrown
remy Because of integer division it works a bit differently. For example:
5/2*2+1 = 2*2+1 = 5 and not 6.

2 years ago

in I’m back up! on Zac Bowling's Blog
Nice :)
Returning? Login