Searching for Lottery drawing list of ticket match...

Chris Kaynor 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)


>
> Thanks,
>
>
For more details, you can look up sets (both the math kind and the specific
Python implementation are relevant):
    http://docs.python.org/library/stdtypes.html#set
    http://en.wikipedia.org/wiki/Set_(mathematics)
    http://en.wikipedia.org/wiki/Set_theory

Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110812/43d2710c/attachment-0001.html>


More information about the Python-list mailing list