Maybe use Python sets: full_range = set(xrange(100)) used = set() used.add(5) used.add(30) used.add(65) unused = full_range - used # A set of the integers 0-99, excluding 5, 30, and 65
Anthony On Tuesday, March 28, 2017 at 2:14:23 PM UTC-4, Dave S wrote: > > I use a set in one project that needs to keep track of used "ids", so > essentially I'm appending integers (from within a specified range) to the > set. I'd like to find out, when I'm all done appending, which integers > from the range I DIDN'T add. > > What is the efficient and pythonic way of checking this? My first thought > is to start with an empty found[] set, and fill up a candidate[] set; as > I find an "id", delete it from candidate[] and append to found[]. > > Other suggestions? > > /dps > > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.

