Searching for Lottery drawing list of ticket match...
ckaynor at zindagigames.com
Fri Aug 12 17:11:35 EDT 2011
On Fri, Aug 12, 2011 at 1:47 PM, MrPink <tdsimpson at gmail.com> wrote:
> Boy, that was a lot more elegant that I would have thought.
> Though hard for a greenhorn like me to really understand how the
> assignment are working, etc.
> Anyway, what are these kind of statement call so that I can read up
> more on this?
> What Python feature are you using?
> num_whites = ticket_whites & drawing_whites
This is a set intersection, using the "bit-wise and" operator (&). It can
also be written as either of:
num_whites = (ticket_whites & drawing_whites) # Makes it a bit clearer
that the "bit-wise and" operator runs before the "assignment" (=) operator.
num_whites = ticket_whites.intersection(drawing_whites) # Calls the
actual method rather than using the operator. A bit more verbose.
> black_matching = ticket_black == drawing_black
This is just the result of an equality operator being assigned. It may be a
bit clearer if you see it as:
black_matching = (ticket_black == drawing_black)
For more details, you can look up sets (both the math kind and the specific
Python implementation are relevant):
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list