Searching for Lottery drawing list of ticket match...

Chris Kaynor ckaynor at
Fri Aug 12 17:11:35 EDT 2011

On Fri, Aug 12, 2011 at 1:47 PM, MrPink <tdsimpson at> 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)

> Thanks,
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...
URL: <>

More information about the Python-list mailing list