[Python Edinburgh] Pub Meetup Tomorrow: Who's Coming?

Mark Smith mark.smith at practicalpoetry.co.uk
Tue Oct 26 14:52:47 CEST 2010


Great to hear that you're coming.

I haven't tested the following, but maybe it helps?

def check_bit(bit, value):
    mask == 0x1 >> bit
    return (value & mask) == mask

if check_bit(3, y) and not check_bit(0, y):
    print 'yay!'

--Mark

On 26 October 2010 13:04, Ed HAWKINS <ed.hawkins at st.com> wrote:

>  Hi all,
>
>
>
> I hope to come along tonight.
>
>
>
> Simple(?) python question:
>
>
>
> Suppose I have a variable, y, which contains a binary number (4 bits,
> (3:0)). I want to compare individual bits within y and return True if some
> of the bits are set/clear.
>
>
>
> For example, suppose I want to check bit3 is set and bit0 is clear... At
> present I have:
>
>
>
> (y & 0x08) == 8 and (y & 0x01) == 0
>
>
>
> which seems a bit clunky (especially since I want to set up a dictionary of
> possible compares). Is there a better way to do it?
>
>
>
> I suppose I really want to match the ‘pattern’ 0b1XX0 with y (where X is
> don’t care)...
>
>
>
> Thanks, Ed.
>
>
>
>
>
> *From:* edinburgh-bounces+ed.hawkins=st.com at python.org [mailto:
> edinburgh-bounces+ed.hawkins <edinburgh-bounces%2Bed.hawkins>=st.com@
> python.org] *On Behalf Of *Mark Smith
> *Sent:* 26 October 2010 12:51
> *To:* The list for Pythonistas in Edinburgh.;
> edinburgh-pug at googlegroups.com
> *Subject:* Re: [Python Edinburgh] Pub Meetup Tomorrow: Who's Coming?
>
>
>
> Table booked for 8 people, for 6:30pm at Berts Bar (I'm assuming we'll get
> a couple of extra people at the last minute - although it has just occurred
> to me that Derek won't be along until later - ah well, no matter.)
>
>
>
> Look forward to seeing you all there!
>
>
>
> --Mark
>
> On 25 October 2010 14:16, Derek Hoy <derek.hoy at gmail.com> wrote:
>
> I'll be along later, so no pie for me.
>
> Derek
>
> On Mon, Oct 25, 2010 at 10:37 AM, Mark Smith
>
> <mark.smith at practicalpoetry.co.uk> wrote:
>
> > Hi All,
> > There's a Pub Meetup tomorrow (Tuesday!) -- same details as before:
> Bert's
> > Bar[1] from 6:30pm, followed by a switch to Teuchters across the road
> after
> > we've eaten (7:30ish). Please mail the list (or me) if you plan to come
> so I
> > can get an idea of numbers for the table booking. Unexpected arrivals are
> > always welcome, but have a reduced chance of getting a seat :-)
> > Don't forget that if you use Google Calendar, or a calendar that can take
> > iCal, you can subscribe to the calendar feeds on the site[2].
> > --Mark
> > 1: http://www.bertsbar.co.uk/berts-bar/home/berts-bar-edinburgh.html
> > 2: http://www.pythonedinburgh.org/
>
> > _______________________________________________
> > Edinburgh mailing list
> > Edinburgh at python.org
> > http://mail.python.org/mailman/listinfo/edinburgh
> >
> >
> _______________________________________________
> Edinburgh mailing list
> Edinburgh at python.org
> http://mail.python.org/mailman/listinfo/edinburgh
>
>
>
> _______________________________________________
> Edinburgh mailing list
> Edinburgh at python.org
> http://mail.python.org/mailman/listinfo/edinburgh
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/edinburgh/attachments/20101026/a28a9926/attachment.html>


More information about the Edinburgh mailing list