From dougal85 at gmail.com Fri Oct 1 00:02:30 2010 From: dougal85 at gmail.com (Dougal Matthews) Date: Thu, 30 Sep 2010 23:02:30 +0100 Subject: [Python Edinburgh] Hack Session In-Reply-To: References: Message-ID: On 30 September 2010 20:01, Hasan Veldstra wrote: > Good idea. Easiest thing to do is look through the bug tracker of your > favorite project and pick an item. > Absolutely, I can think of loads of projects I would like to get involved in. It's perhaps a little harder to find one that we all interested in but of course there is scope for various projects being hacked on. I guess it just depends how much interest etc. we can drum up. We had thought of picking a project, say Gunicorn just for example, and then starting with a few lightning talks to get those less familiar up to speed. So a bit of talks, coding and then off to the pub :). This format is just an idea at the moment so I'd again be interested to hear thoughts. > E.g. Gunicorn (http://gunicorn.org) could do with sendfile support > [1]. If I turn up, I may work on that. Anyone here have WSGI > implementation experience? > I have only used gunicorn and don't know the internals but it's awesome so I would love to be more involved in the project. We could hold it in Appleton Tower perhaps (Techmeetup location). I > can try to arrange that if it seems like a good venue. Appleton tower was on our short list of places to contact. If there is somebody specific we should speak to I'd be happy to do that - just let me know. Cheers, Dougal -------------- next part -------------- An HTML attachment was scrubbed... URL: From dougal85 at gmail.com Fri Oct 1 00:09:55 2010 From: dougal85 at gmail.com (Dougal Matthews) Date: Thu, 30 Sep 2010 23:09:55 +0100 Subject: [Python Edinburgh] Hack Session In-Reply-To: References: Message-ID: On 30 September 2010 20:00, John Sutherland wrote: > I think I suggested PyPy [1] on Tuesday, although I?m not sure how > much use that would be to anyone (I certainly haven?t used PyPy). > I haven't used PyPy either but I should really learn more about it. I wonder if there is quite a bit of overhead and understanding before we can get into it? We may need some expert knowledge. Another possibility might by a port of Ruby?s chronic library. Chronic looks really nice. I'd like that to have that thanks! Cheers, Dougal -------------- next part -------------- An HTML attachment was scrubbed... URL: From dougal85 at gmail.com Tue Oct 5 21:52:51 2010 From: dougal85 at gmail.com (Dougal Matthews) Date: Tue, 5 Oct 2010 20:52:51 +0100 Subject: [Python Edinburgh] Hack Session In-Reply-To: References: Message-ID: I've got a few idea's that I'd like to throw out there for consideration. 1. Benchmarking There is a project called djangobench[1] that was started by Jacob Kaplan-moss. Basically the idea is to monitor the performance of Django as its versions progress. I can see a couple of ways we could extend this; The obvious one, write more benchmarks and the other is to create a website that automatically runs the benchmarks and keeps track overtime to see how the current trunk is compared to the latest release. This would ideally automatically run when new commits are made to SVN. This could be extended further and create a generic benchmark system for python that would then have a front end etc. but that maybe is a bit too far for the first pass. 2. Django 1.3 Django 1.3 is coming up soon(ish)[2] - there are loads of bug fixes etc. that need to be done. 3. Django Bursar Bursar[3] is a generic payment gateway, its got much of the code there but its far from a finished project. It's a spin-off from satchmo[4] and thus implements a number of gateways - they are not all confirmed as working and mostly untested. It's a great idea and I would like to see it as a more generic Python library with then a set of django helpers. I've used it in a project fairly recently so I'm quite familiar with the internals as I had to dive in and do some bug fixing. It may well be that we are best to work on a number of projects, for example we have a set of mentors and then other's that choose to go with one of the projects or don't really mind. This would help with the diversity as for example I realise lots of my idea's are very Django or web centric. Dougal [1]: http://github.com/jacobian/djangobench [2]: http://www.djangoproject.com/weblog/2010/sep/30/django-1_3-release-schedule/ [3]: http://bitbucket.org/bkroeze/django-bursar/overview [4]: http://www.satchmoproject.com/ On 30 September 2010 23:09, Dougal Matthews wrote: > On 30 September 2010 20:00, John Sutherland wrote: > >> I think I suggested PyPy [1] on Tuesday, although I?m not sure how >> much use that would be to anyone (I certainly haven?t used PyPy). >> > > I haven't used PyPy either but I should really learn more about it. I > wonder if there is quite a bit of overhead and understanding before we can > get into it? We may need some expert knowledge. > > Another possibility might by a port of Ruby?s chronic library. > > > Chronic looks really nice. I'd like that to have that thanks! > > Cheers, > Dougal > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dougal85 at gmail.com Thu Oct 7 15:59:42 2010 From: dougal85 at gmail.com (Dougal Matthews) Date: Thu, 7 Oct 2010 14:59:42 +0100 Subject: [Python Edinburgh] Hack Session In-Reply-To: References: Message-ID: On 7 October 2010 14:29, Graeme Urquhart wrote: > > On 5 October 2010 20:52, Dougal Matthews wrote: > >> >> 3. Django Bursar >> Bursar[3] is a generic payment gateway, its got much of the code there but >> its far from a finished project. It's a spin-off from satchmo[4] and thus >> implements a number of gateways - they are not all confirmed as working and >> mostly untested. It's a great idea and I would like to see it as a more >> generic Python library with then a set of django helpers. I've used it in a >> project fairly recently so I'm quite familiar with the internals as I had to >> dive in and do some bug fixing. >> > > I didn't know this existed, if I did I wouldn't have spent the last week > decoupling Satchmo's payment processor - which felt like it was more tightly > knitted than a sheet of graphene! Ha, yes it really is a pain and there are some ugly naming conventions that came out of it too. The state of it is pretty bad but the initial work has been done at least, I've got a fork on bitbucket with a couple of minor fixes but we ended up doing an internal fork (at the company I was contracting for at the time) to get it working. As a result I've got a pretty decent basis where to start to get (at least) the pay pal gateway going. Dougal -------------- next part -------------- An HTML attachment was scrubbed... URL: From mark.smith at practicalpoetry.co.uk Fri Oct 8 09:04:32 2010 From: mark.smith at practicalpoetry.co.uk (Mark Smith) Date: Fri, 8 Oct 2010 08:04:32 +0100 Subject: [Python Edinburgh] Hack Session In-Reply-To: References: Message-ID: Hi Guys, I haven't really had any inspiration on this topic myself. I like the idea of porting Chronic to Python for a couple of reasons: * The learning curve should be relatively shallow. * It doesn't require knowledge of web development or django to either understand it or to see the point. I realise that the majority of us are web developers, but it would be nice to pick a project that wasn't too intimidating, and was open to all. --Mark On 7 October 2010 14:59, Dougal Matthews wrote: > On 7 October 2010 14:29, Graeme Urquhart wrote: > >> >> On 5 October 2010 20:52, Dougal Matthews wrote: >> >>> >>> 3. Django Bursar >>> Bursar[3] is a generic payment gateway, its got much of the code there >>> but its far from a finished project. It's a spin-off from satchmo[4] and >>> thus implements a number of gateways - they are not all confirmed as working >>> and mostly untested. It's a great idea and I would like to see it as a more >>> generic Python library with then a set of django helpers. I've used it in a >>> project fairly recently so I'm quite familiar with the internals as I had to >>> dive in and do some bug fixing. >>> >> >> I didn't know this existed, if I did I wouldn't have spent the last week >> decoupling Satchmo's payment processor - which felt like it was more tightly >> knitted than a sheet of graphene! > > > Ha, yes it really is a pain and there are some ugly naming conventions that > came out of it too. The state of it is pretty bad but the initial work has > been done at least, I've got a fork on bitbucket with a couple of minor > fixes but we ended up doing an internal fork (at the company I was > contracting for at the time) to get it working. As a result I've got a > pretty decent basis where to start to get (at least) the pay pal gateway > going. > > Dougal > > > _______________________________________________ > Edinburgh mailing list > Edinburgh at python.org > http://mail.python.org/mailman/listinfo/edinburgh > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dougal85 at gmail.com Fri Oct 8 14:30:00 2010 From: dougal85 at gmail.com (Dougal Matthews) Date: Fri, 8 Oct 2010 13:30:00 +0100 Subject: [Python Edinburgh] Hack Session In-Reply-To: References: Message-ID: On 8 October 2010 08:04, Mark Smith wrote: > > I haven't really had any inspiration on this topic myself. I like the idea > of porting Chronic to Python for a couple of reasons: > > * The learning curve should be relatively shallow. > * It doesn't require knowledge of web development or django to either > understand it or to see the point. > I think this is a good project and something I have a real use for. Depending how many people we get I think it would be best if we have multiple projects going. For example, how many people can seriously get into coding on something like Chronic? Especially for a brand new project its hard to get lots of people involved. Anyway, we can work this out when we see who turns up. Details about the time and venue are coming up shortly. Dougal -------------- next part -------------- An HTML attachment was scrubbed... URL: From dougal85 at gmail.com Fri Oct 8 14:55:01 2010 From: dougal85 at gmail.com (Dougal Matthews) Date: Fri, 8 Oct 2010 13:55:01 +0100 Subject: [Python Edinburgh] Hack Session In-Reply-To: References: Message-ID: Over lunch I briefly spoke with Russell Keith-Magee (Django core dev) and Alex Gaynor (almost a core dev) and they had a few suggestions for those that want to get involved with Django. Alex Gaynor also said that if people are interested he will try to be around on IRC to help out. * General Django 1.3 bug fixing * Reviewing tickets and ticket triaging. * "doctest genocide" - removing doctests and replacing with Unit tests. Cheers, Dougal On 8 October 2010 13:30, Dougal Matthews wrote: > On 8 October 2010 08:04, Mark Smith wrote: >> >> I haven't really had any inspiration on this topic myself. I like the idea >> of porting Chronic to Python for a couple of reasons: >> >> * The learning curve should be relatively shallow. >> * It doesn't require knowledge of web development or django to either >> understand it or to see the point. >> > > I think this is a good project and something I have a real use for. > Depending how many people we get I think it would be best if we have > multiple projects going. For example, how many people can seriously get into > coding on something like Chronic? Especially for a brand new project its > hard to get lots of people involved. > > Anyway, we can work this out when we see who turns up. > Details about the time and venue are coming up shortly. > > Dougal > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dougal85 at gmail.com Fri Oct 8 15:41:23 2010 From: dougal85 at gmail.com (Dougal Matthews) Date: Fri, 8 Oct 2010 14:41:23 +0100 Subject: [Python Edinburgh] Hack Session In-Reply-To: References: Message-ID: On 8 October 2010 14:29, Dan Jacob wrote: > Are class-based generic views still going into 1.3 ? I know they were > supposed to be in 1.2 but didn't make the cut. I'm going to go out of a limb and say yes. There is 102 (!!!) message long email thread on the subject[1] that seems to have mostly come to a conclusion thankfully. Unfortunately this feature was victum to heavy bikeshedding[2]. I don't think there is anything we can add to it really, its basically done. There are just many different view points on the level of abstraction and how multi-threaded actions are handled (i.e. should it be safe to store on self). Dougal p.s. not sure if you meant to reply off list but I cc'ed us back on. [1]: http://groups.google.co.uk/group/django-developers/browse_thread/thread/27cec79b784ef73f/d984fd1314fe7334 [2]: http://bikeshed.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From dougal85 at gmail.com Sun Oct 10 21:28:25 2010 From: dougal85 at gmail.com (Dougal Matthews) Date: Sun, 10 Oct 2010 20:28:25 +0100 Subject: [Python Edinburgh] Python Hack Day Message-ID: Hey all, We've managed to confirm a space in Appleton Tower[1] (where TechMeetup is hosted) for our hacking session. We have access from 2pm onwards. I'll try and update the website and get this information on at some point this week. Since no idea has risen to the top as a favourite I think we'll probably play it a bit by year - depending how many people turn up and what idea's people mentor and push forward. For the discussion of idea's have a look here: http://mail.python.org/pipermail/edinburgh/2010-September/000021.html. We can still focus on something and work towards are more detailed plan of what we can work on as the weekend gets closer. Many thanks to vidiowiki[2] for hosting us at Appleton Tower and Hassan for setting up the venue. Please reply and let us know if your coming so we get a rough idea of the numbers. Cheers, Dougal [1] http://www.ed.ac.uk/maps/buildings/appleton-tower [2] http://www.vidiowiki.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From dougal85 at gmail.com Sun Oct 10 22:29:37 2010 From: dougal85 at gmail.com (Dougal Matthews) Date: Sun, 10 Oct 2010 21:29:37 +0100 Subject: [Python Edinburgh] Python Hack Day In-Reply-To: References: Message-ID: I guess it would be really useful If i added the date. It's happening on the 23rd of October at the Appleton Tower, 2pm onwards. Dougal On 10 October 2010 20:28, Dougal Matthews wrote: > Hey all, > > We've managed to confirm a space in Appleton Tower[1] (where TechMeetup is > hosted) for our hacking session. We have access from 2pm onwards. I'll try > and update the website and get this information on at some point this week. > > Since no idea has risen to the top as a favourite I think we'll probably > play it a bit by year - depending how many people turn up and what idea's > people mentor and push forward. For the discussion of idea's have a look > here: > http://mail.python.org/pipermail/edinburgh/2010-September/000021.html . We > can still focus on something and work towards are more detailed plan of what > we can work on as the weekend gets closer. > > Many thanks to vidiowiki[2] for hosting us at Appleton Tower and Hassan for > setting up the venue. > > Please reply and let us know if your coming so we get a rough idea of the > numbers. > > Cheers, > Dougal > > [1] http://www.ed.ac.uk/maps/buildings/appleton-tower > [2] http://www.vidiowiki.com/ > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From judy at judy.co.uk Sun Oct 10 23:57:31 2010 From: judy at judy.co.uk (Mark Smith) Date: Sun, 10 Oct 2010 22:57:31 +0100 Subject: [Python Edinburgh] Python Hack Day In-Reply-To: References: Message-ID: I'll be there! On 10 Oct 2010 21:33, "Dougal Matthews" wrote: > I guess it would be really useful If i added the date. > > It's happening on the 23rd of October at the Appleton Tower, 2pm onwards. > > Dougal > > > On 10 October 2010 20:28, Dougal Matthews wrote: > >> Hey all, >> >> We've managed to confirm a space in Appleton Tower[1] (where TechMeetup is >> hosted) for our hacking session. We have access from 2pm onwards. I'll try >> and update the website and get this information on at some point this week. >> >> Since no idea has risen to the top as a favourite I think we'll probably >> play it a bit by year - depending how many people turn up and what idea's >> people mentor and push forward. For the discussion of idea's have a look >> here: >> http://mail.python.org/pipermail/edinburgh/2010-September/000021.html . We >> can still focus on something and work towards are more detailed plan of what >> we can work on as the weekend gets closer. >> >> Many thanks to vidiowiki[2] for hosting us at Appleton Tower and Hassan for >> setting up the venue. >> >> Please reply and let us know if your coming so we get a rough idea of the >> numbers. >> >> Cheers, >> Dougal >> >> [1] http://www.ed.ac.uk/maps/buildings/appleton-tower >> [2] http://www.vidiowiki.com/ >> >> -------------- next part -------------- An HTML attachment was scrubbed... URL: From dougal85 at gmail.com Thu Oct 14 23:32:08 2010 From: dougal85 at gmail.com (Dougal Matthews) Date: Thu, 14 Oct 2010 22:32:08 +0100 Subject: [Python Edinburgh] Hack Session In-Reply-To: References: Message-ID: On 5 October 2010 20:52, Dougal Matthews wrote: > 3. Django Bursar > Bursar[3] is a generic payment gateway, its got much of the code there but > its far from a finished project. It's a spin-off from satchmo[4] and thus > implements a number of gateways - they are not all confirmed as working and > mostly untested. It's a great idea and I would like to see it as a more > generic Python library with then a set of django helpers. I've used it in a > project fairly recently so I'm quite familiar with the internals as I had to > dive in and do some bug fixing. > For those that are interested. I just read about another project similar to Bursar that looks promising. It looks more polished but also missing a large number of features too. http://github.com/agiliq/merchant Dougal -------------- next part -------------- An HTML attachment was scrubbed... URL: From dougal85 at gmail.com Tue Oct 19 00:10:55 2010 From: dougal85 at gmail.com (Dougal Matthews) Date: Mon, 18 Oct 2010 23:10:55 +0100 Subject: [Python Edinburgh] Python Hack Day - 23rd October Message-ID: Hey all, Not too long now until we kick things off! I've been hacking away at the website[1] (even if I'm a bit too tired[2]) and I've added a simple wiki to help us organise things or at least store information easily. I've started adding the initial information for Saturday. Please add yourself to the list (or remove yourself if your not coming). I added people that have confirmed one way or another to me or on the list. Any more project idea's are welcome too - nothing has been decided yet and I think it's something we will probably work out on the day depending on what mood we are in. Looking forward to see you all there, Cheers, Dougal [1]: http://github.com/d0ugal/pythonedinburgh/commit/a2391ec739e8b6ac9389b0192be4c37ea3f04b13 [2]: http://github.com/d0ugal/pythonedinburgh/commit/697a82dbc6522f14bf7d02c6909c7f4204a4cd39 -------------- next part -------------- An HTML attachment was scrubbed... URL: From dougal85 at gmail.com Tue Oct 19 00:16:30 2010 From: dougal85 at gmail.com (Dougal Matthews) Date: Mon, 18 Oct 2010 23:16:30 +0100 Subject: [Python Edinburgh] Python Hack Day - 23rd October In-Reply-To: References: Message-ID: I've now added the wiki page for the hack day. Edit, update, etc. etc. http://www.pythonedinburgh.org/wiki/HackDay-oct10 Cheers, Dougal On 18 October 2010 23:10, Dougal Matthews wrote: > Hey all, > > Not too long now until we kick things off! > > I've been hacking away at the website[1] (even if I'm a bit too tired[2]) > and I've added a simple wiki to help us organise things or at least store > information easily. I've started adding the initial information for > Saturday. > > Please add yourself to the list (or remove yourself if your not coming). I > added people that have confirmed one way or another to me or on the list. > Any more project idea's are welcome too - nothing has been decided yet and > I think it's something we will probably work out on the day depending on > what mood we are in. > > Looking forward to see you all there, > > Cheers, > Dougal > > [1]: > http://github.com/d0ugal/pythonedinburgh/commit/a2391ec739e8b6ac9389b0192be4c37ea3f04b13 > [2]: > http://github.com/d0ugal/pythonedinburgh/commit/697a82dbc6522f14bf7d02c6909c7f4204a4cd39 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From g.urkhart at gmail.com Tue Oct 19 00:27:33 2010 From: g.urkhart at gmail.com (Graeme Urquhart) Date: Mon, 18 Oct 2010 23:27:33 +0100 Subject: [Python Edinburgh] Hack Session In-Reply-To: References: Message-ID: Thanks for the heads-up, Merchant has a much more sensible API than Bursar. Needs more gateways, I'd probably use it on my current project if it had ProTx support. Graeme On 14 October 2010 22:32, Dougal Matthews wrote: > On 5 October 2010 20:52, Dougal Matthews wrote: > >> 3. Django Bursar >> Bursar[3] is a generic payment gateway, its got much of the code there but >> its far from a finished project. It's a spin-off from satchmo[4] and thus >> implements a number of gateways - they are not all confirmed as working and >> mostly untested. It's a great idea and I would like to see it as a more >> generic Python library with then a set of django helpers. I've used it in a >> project fairly recently so I'm quite familiar with the internals as I had to >> dive in and do some bug fixing. >> > > For those that are interested. I just read about another project similar to > Bursar that looks promising. It looks more polished but also missing a large > number of features too. > > http://github.com/ailiq/merchant > > Dougal > > _______________________________________________ > Edinburgh mailing list > Edinburgh at python.org > http://mail.python.org/mailman/listinfo/edinburgh > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mark.smith at practicalpoetry.co.uk Wed Oct 20 10:31:31 2010 From: mark.smith at practicalpoetry.co.uk (Mark Smith) Date: Wed, 20 Oct 2010 09:31:31 +0100 Subject: [Python Edinburgh] Hack Day on Saturday & Pub Meetup on Tuesday Message-ID: Hi All, I just wanted to remind everyone that we have the Hack Day[1] coming up on Saturday - thanks to Dougal for arranging this whole thing and for getting the Wiki up and running on the web-site. I've been a total flake and have been no help at all. Very much looking forward to meeting up with you guys and coding with some of you. If anyone for some reason can't make the session in the afternoon but would like to meet up for some beers with us later, send me an email and we'll work out a way to let you know where we end up. Don't forget we also have a scheduled Pub Meetup on Tuesday (I'm afraid it's masked on the website because it only shows the next upcoming event, and that's the Hack Day) - same as previous arrangements - 6:30pm, Bert's Bar[2], moving across to Teuchters when we've eaten - it's worked well the last two times we tried it, and I have no reason to think it won't work well again :-) I look forward to seeing you at one or both of these events! --Mark 1: http://www.pythonedinburgh.org/wiki/HackDay-oct10 2: http://www.bertsbar.co.uk/berts-bar/home/berts-bar-edinburgh.html -------------- next part -------------- An HTML attachment was scrubbed... URL: From david at hackbinary.com Wed Oct 20 10:57:53 2010 From: david at hackbinary.com (David) Date: Wed, 20 Oct 2010 09:57:53 +0100 Subject: [Python Edinburgh] E-commerce web video Message-ID: Hi Everybody, My company has client that needs some video e-commerce stuff done. If you or your company would be interested in the referral, please drop me a line. Thanks, David -- +------------------------------------------------------------------------------------- David I have no doubt that in reality the future will be vastly more surprising than anything I can imagine. Now my own suspicion is that the Universe is not only queerer than we suppose, but queerer than we can suppose. - J.B.S. Haldane +------------------------------------------------------------------------------------- -------------- next part -------------- An HTML attachment was scrubbed... URL: From dougal85 at gmail.com Wed Oct 20 12:36:16 2010 From: dougal85 at gmail.com (Dougal Matthews) Date: Wed, 20 Oct 2010 11:36:16 +0100 Subject: [Python Edinburgh] Hack Day on Saturday & Pub Meetup on Tuesday In-Reply-To: References: Message-ID: On 20 October 2010 09:31, Mark Smith wrote: > If anyone for some reason can't make the session in the afternoon but would > like to meet up for some beers with us later, send me an email and we'll > work out a way to let you know where we end up. > My phone number is *07719 780 595* - Feel free to take note of it and give me a call if you want to join us later or have trouble getting into appleton tower etc. Don't forget we also have a scheduled Pub Meetup on Tuesday (I'm afraid it's > masked on the website because it only shows the next upcoming event, and > that's the Hack Day) > I added the Python Edinburgh site to the list of project ideas. If anybody fancies giving it some love I've got quire a few ideas (ranging from simple tweaks like showing more han just the next event) to some more complex idea's too. Unfortunately I wont be making the pub meetup this month (or for the next few!) Cheers, Dougal -------------- next part -------------- An HTML attachment was scrubbed... URL: From dougal85 at gmail.com Wed Oct 20 16:03:58 2010 From: dougal85 at gmail.com (Dougal Matthews) Date: Wed, 20 Oct 2010 15:03:58 +0100 Subject: [Python Edinburgh] Comparing two Tuples Message-ID: Random question for you all. I've got a solution but I don't think its that intuitive, so I'm curious if there is a neater way. What is the best to compare two tuples and see if they contain one or more of the same items. A = (1,2,3) B = (3,4,5) C = (6,7,8) Where A would match B because they both have 3 and C wouldn't match either. if : print "One or more item is the same" else: print "The tuples don't contain any of the same items" Dougal -------------- next part -------------- An HTML attachment was scrubbed... URL: From danjac354 at gmail.com Wed Oct 20 16:12:37 2010 From: danjac354 at gmail.com (danjac354 at gmail.com) Date: Wed, 20 Oct 2010 15:12:37 +0100 Subject: [Python Edinburgh] Comparing two Tuples In-Reply-To: References: Message-ID: Off the top of my head: bool(set(A).intersection(B)) On 20 October 2010 15:03, Dougal Matthews wrote: > Random question for you all. I've got a solution but I don't think its that > intuitive, so I'm curious if there is a neater way. > What is the best to compare two tuples and see if they contain one or more > of the same items. > A = (1,2,3) > B = (3,4,5) > C = (6,7,8) > Where A would match B because they both have 3 and C wouldn't match either. > if : > ?? ?print "One or more item is the same" > else: > ?? ?print "The tuples don't contain any of the same items" > > Dougal > _______________________________________________ > Edinburgh mailing list > Edinburgh at python.org > http://mail.python.org/mailman/listinfo/edinburgh > > From dougal85 at gmail.com Wed Oct 20 16:19:09 2010 From: dougal85 at gmail.com (Dougal Matthews) Date: Wed, 20 Oct 2010 15:19:09 +0100 Subject: [Python Edinburgh] Comparing two Tuples In-Reply-To: References: Message-ID: On 20 October 2010 15:12, danjac354 at gmail.com wrote: > Off the top of my head: > > bool(set(A).intersection(B)) That's what I'm using. Although you don't need the bool method call - maybe its more intuitive than I thought! Dougal -------------- next part -------------- An HTML attachment was scrubbed... URL: From liw at liw.fi Wed Oct 20 16:14:25 2010 From: liw at liw.fi (Lars Wirzenius) Date: Wed, 20 Oct 2010 15:14:25 +0100 Subject: [Python Edinburgh] Comparing two Tuples In-Reply-To: References: Message-ID: <1287584065.2807.7.camel@havelock> On ke, 2010-10-20 at 15:03 +0100, Dougal Matthews wrote: > What is the best to compare two tuples and see if they contain one or > more of the same items. > > A = (1,2,3) > B = (3,4,5) > C = (6,7,8) > > Where A would match B because they both have 3 and C wouldn't match > either. Sets would be a simple solution for this. >>> a=(1,2,3) >>> b=(3,4,5) >>> c=(6,7,8) >>> set(a).intersection(set(b)) set([3]) >>> set(a).intersection(set(c)) set([]) >>> if set(a).intersection(set(c)): print 'yay' ... >>> if set(a).intersection(set(b)): print 'yay' ... yay >>> From danjac354 at gmail.com Wed Oct 20 16:25:49 2010 From: danjac354 at gmail.com (danjac354 at gmail.com) Date: Wed, 20 Oct 2010 15:25:49 +0100 Subject: [Python Edinburgh] Comparing two Tuples In-Reply-To: References: Message-ID: On 20 October 2010 15:19, Dougal Matthews wrote: > On 20 October 2010 15:12, danjac354 at gmail.com wrote: >> >> Off the top of my head: >> >> bool(set(A).intersection(B)) > > That's what I'm using. Although you don't need the bool method call - maybe > its more?intuitive?than I thought! Sure, you don't - it's just if you specifically wanted a bool as opposed to a set. > Dougal > _______________________________________________ > Edinburgh mailing list > Edinburgh at python.org > http://mail.python.org/mailman/listinfo/edinburgh > > From mark.smith at practicalpoetry.co.uk Wed Oct 20 16:28:58 2010 From: mark.smith at practicalpoetry.co.uk (Mark Smith) Date: Wed, 20 Oct 2010 15:28:58 +0100 Subject: [Python Edinburgh] Comparing two Tuples In-Reply-To: References: Message-ID: Yeah, that was more or less my solution - I think it's pretty intuitive - although I used slightly different syntax: if set([1,2,3]) & set([3,4,5]): print 'yay!' --Mark On 20 October 2010 15:19, Dougal Matthews wrote: > On 20 October 2010 15:12, danjac354 at gmail.com wrote: >> >> Off the top of my head: >> >> bool(set(A).intersection(B)) > > That's what I'm using. Although you don't need the bool method call - maybe > its more?intuitive?than I thought! > Dougal > _______________________________________________ > Edinburgh mailing list > Edinburgh at python.org > http://mail.python.org/mailman/listinfo/edinburgh > > -- Mark Smith Practical Poetry - Software development done the right way. From dougal85 at gmail.com Wed Oct 20 16:33:27 2010 From: dougal85 at gmail.com (Dougal Matthews) Date: Wed, 20 Oct 2010 15:33:27 +0100 Subject: [Python Edinburgh] Comparing two Tuples In-Reply-To: References: Message-ID: Cool - so we are all pretty much in agreement. Good to know I'm doing it right ;) Dougal -------------- next part -------------- An HTML attachment was scrubbed... URL: From mark.smith at practicalpoetry.co.uk Mon Oct 25 11:37:48 2010 From: mark.smith at practicalpoetry.co.uk (Mark Smith) Date: Mon, 25 Oct 2010 10:37:48 +0100 Subject: [Python Edinburgh] Pub Meetup Tomorrow: Who's Coming? Message-ID: 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/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From g.urkhart at gmail.com Mon Oct 25 12:12:57 2010 From: g.urkhart at gmail.com (Graeme Urquhart) Date: Mon, 25 Oct 2010 11:12:57 +0100 Subject: [Python Edinburgh] Pub Meetup Tomorrow: Who's Coming? In-Reply-To: References: Message-ID: Hi Mark, I'll see you there! Graeme On 25 October 2010 10:37, Mark Smith 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 > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mean2030 at gmail.com Mon Oct 25 12:22:41 2010 From: mean2030 at gmail.com (Mathew Taylor) Date: Mon, 25 Oct 2010 11:22:41 +0100 Subject: [Python Edinburgh] Pub Meetup Tomorrow: Who's Coming? In-Reply-To: References: Message-ID: I'll be there too, see you all tomorrow. On 25 October 2010 11:12, Graeme Urquhart wrote: > Hi Mark, > > I'll see you there! > > Graeme > > On 25 October 2010 10:37, Mark Smith 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 > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From g.urkhart at gmail.com Mon Oct 25 13:03:12 2010 From: g.urkhart at gmail.com (Graeme Urquhart) Date: Mon, 25 Oct 2010 12:03:12 +0100 Subject: [Python Edinburgh] Python IDEs Message-ID: Hello list, Any of you folks experienced with IDEs for Python, if so what's your preference? Cheers, Graeme -------------- next part -------------- An HTML attachment was scrubbed... URL: From dougal85 at gmail.com Mon Oct 25 14:20:08 2010 From: dougal85 at gmail.com (Dougal Matthews) Date: Mon, 25 Oct 2010 13:20:08 +0100 Subject: [Python Edinburgh] Python IDEs In-Reply-To: References: Message-ID: On 25 October 2010 12:03, Graeme Urquhart wrote: > Hello list, > > Any of you folks experienced with IDEs for Python, if so what's your > preference? > ?Which editor?? The classic question. I used to be quite into my IDE's (I think its something I got into after doing C# and Java at university). I don't really use them anymore favouring a simpler editor (TextMate and vim). pyDev is pretty good if you can stand eclipse and its all free which is a bonus. I used this for a while and it really helped me learn Python. http://pydev.org/ PyCharm is very new and I've only tried it briefly but it seems good and I've heard great things about it. www.jetbrains.com/pycharm/ Dougal -------------- next part -------------- An HTML attachment was scrubbed... URL: From mark.smith at practicalpoetry.co.uk Mon Oct 25 15:09:03 2010 From: mark.smith at practicalpoetry.co.uk (Mark Smith) Date: Mon, 25 Oct 2010 14:09:03 +0100 Subject: [Python Edinburgh] Python IDEs In-Reply-To: References: Message-ID: I use Pydev on Eclipse for anything larger than 2 or 3 python files, and TextMate (Mac) or Notepad++(Windows) (or Vim) for anything else. Dougal's right that Pydev's auto-completion can make life a lot easier if you can't quite remember the name of a function, but Eclipse is a bit of a behemoth. I've heard mixed things about PyCharm, but it seems that they're putting a lot of effort into it and it seems to be improving very rapidly (from a reasonably good start). That opinion is mainly based on the experiences of those trying out a Beta version (or was it a Release Candidate) around me at EuroPython. Is it worth paying for? Probably not, IMHO, but give the demo a try and see for yourself. --Mark On 25 October 2010 12:03, Graeme Urquhart wrote: > Hello list, > > Any of you folks experienced with IDEs for Python, if so what's your > preference? > > Cheers, > Graeme > > _______________________________________________ > Edinburgh mailing list > Edinburgh at python.org > http://mail.python.org/mailman/listinfo/edinburgh > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From john at sneeu.com Mon Oct 25 15:13:36 2010 From: john at sneeu.com (John Sutherland) Date: Mon, 25 Oct 2010 14:13:36 +0100 Subject: [Python Edinburgh] Pub Meetup Tomorrow: Who's Coming? In-Reply-To: References: Message-ID: I should be there. J. On Mon, Oct 25, 2010 at 11:22 AM, Mathew Taylor wrote: > I'll be there too, see you all tomorrow. > > On 25 October 2010 11:12, Graeme Urquhart wrote: >> >> Hi Mark, >> >> I'll see you there! >> >> Graeme >> >> On 25 October 2010 10:37, Mark Smith >> 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 > > -- sneeu.com "A computer shall not waste your time or require you to do more work than is strictly necessary" ? Jef Raskin. From derek.hoy at gmail.com Mon Oct 25 15:16:48 2010 From: derek.hoy at gmail.com (Derek Hoy) Date: Mon, 25 Oct 2010 14:16:48 +0100 Subject: [Python Edinburgh] Pub Meetup Tomorrow: Who's Coming? In-Reply-To: References: Message-ID: I'll be along later, so no pie for me. Derek On Mon, Oct 25, 2010 at 10:37 AM, Mark Smith 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 > > From dougal85 at gmail.com Mon Oct 25 15:23:11 2010 From: dougal85 at gmail.com (Dougal Matthews) Date: Mon, 25 Oct 2010 14:23:11 +0100 Subject: [Python Edinburgh] =?utf-8?Q?Re=3A_?=Python IDEs In-Reply-To: References: Message-ID: <417F14E873FA4078B019F9229337955E@gmail.com> On Monday, 25 October 2010 at 14:09, Mark Smith wrote:Dougal's right that Pydev's auto-completion can make life a lot easier if you can't quite remember the name of a function, but Eclipse is a bit of a behemoth.I used to have a problem remembering where to import a function from rather than the name itself. With pydev it has a nice feature that you can hit ctrl + space after typing something, like "login_" then you will see various options and one of them should be login_required (in django.contrib.auth.decorators iirc) when selecting that it'll finish the function call and add the import line at the top (but not in alphabetical order - grrr).I've never actually found a replacement for this functionality but I've gotten used to not having it either. The danger here is that it can sometimes import from the wrong place (where is still works but its not the official API) - importing CharField from django.forms.fields rather than just django.forms for example.Now if I need to fi nd something I tend to just ack[1] for it and I have a copy of the source tree for most bit projects I work with.Dougal[1]: http://betterthangrep.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From mark.smith at practicalpoetry.co.uk Mon Oct 25 15:29:25 2010 From: mark.smith at practicalpoetry.co.uk (Mark Smith) Date: Mon, 25 Oct 2010 14:29:25 +0100 Subject: [Python Edinburgh] Python IDEs In-Reply-To: <417F14E873FA4078B019F9229337955E@gmail.com> References: <417F14E873FA4078B019F9229337955E@gmail.com> Message-ID: Hey! Ack looks pretty cool! By bizarre coincidence, I bookmarked 'grin'[1] this morning, which does many of the same things (but not all), and is written in Python, so must be better ;-) --Mark [1]: http://pypi.python.org/pypi/grin On 25 October 2010 14:23, Dougal Matthews wrote: > On Monday, 25 October 2010 at 14:09, Mark Smith wrote: > > Dougal's right that Pydev's auto-completion can make life a lot easier if > you can't quite remember the name of a function, but Eclipse is a bit of a > behemoth. > > I used to have a problem remembering where to import a function from rather > than the name itself. With pydev it has a nice feature that you can hit ctrl > + space after typing something, like "login_" then you will see various > options and one of them should be login_required (in > django.contrib.auth.decorators iirc) when selecting that it'll finish the > function call and add the import line at the top (but not in alphabetical > order - grrr). > > I've never actually found a replacement for this functionality but I've > gotten used to not having it either. The danger here is that it can s > ometimes import from the wrong place (where is still works but its not the > official API) - importing CharField from django.forms.fields rather than > just django.forms for example. > > Now if I need to find something I tend to just ack[1] for it and I have a > copy of the source tree for most bit projects I work with. > > Dougal > > [1]: http://betterthangrep.com/ > > _______________________________________________ > Edinburgh mailing list > Edinburgh at python.org > http://mail.python.org/mailman/listinfo/edinburgh > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From g.urkhart at gmail.com Mon Oct 25 18:08:59 2010 From: g.urkhart at gmail.com (Graeme Urquhart) Date: Mon, 25 Oct 2010 17:08:59 +0100 Subject: [Python Edinburgh] Python IDEs In-Reply-To: References: <417F14E873FA4078B019F9229337955E@gmail.com> Message-ID: Mark and Dougal thanks for your thoughts on this. I've been using Aptana Studio 3 with the PyDev extensions, however it's still in beta and crashes occasionally. I tried Eclipse a while back and found it to be a total resource hog but that was on an older machine so maybe I should give it another chance! I often use TextMate when hacking around so Ack looks like a welcome addition especially since it's available as a TM bundle. Cheers, Graeme -------------- next part -------------- An HTML attachment was scrubbed... URL: From dougal85 at gmail.com Mon Oct 25 18:29:14 2010 From: dougal85 at gmail.com (Dougal Matthews) Date: Mon, 25 Oct 2010 17:29:14 +0100 Subject: [Python Edinburgh] Python IDEs In-Reply-To: References: <417F14E873FA4078B019F9229337955E@gmail.com> Message-ID: On 25 October 2010 17:08, Graeme Urquhart wrote: > I've been using Aptana Studio 3 with the PyDev extensions, however it's > still in beta and crashes occasionally. I tried Eclipse a while back and > found it to be a total resource hog but that was on an older machine so > maybe I should give it another chance! > Isn't Aptana essentially an eclipse plugin? I've not used it lately but AFAIK it is just their own release of eclipse or you can install it into a regular eclipse install as a plugin. > I often use TextMate when hacking around so Ack looks like a welcome > addition especially since it's available as a TM bundle. > Yeah, AckMate is awesome. Although I'm mostly using the vim ack plugin now. Dougal -------------- next part -------------- An HTML attachment was scrubbed... URL: From g.urkhart at gmail.com Mon Oct 25 19:16:41 2010 From: g.urkhart at gmail.com (Graeme Urquhart) Date: Mon, 25 Oct 2010 18:16:41 +0100 Subject: [Python Edinburgh] Python IDEs In-Reply-To: References: <417F14E873FA4078B019F9229337955E@gmail.com> Message-ID: > > Isn't Aptana essentially an eclipse plugin? I've not used it lately but > AFAIK it is just their own release of eclipse or you can install it into a > regular eclipse install as a plugin. > Yeah I think it is. For some reason it just seemed to run smoother than Eclipse on my old PC at work. Yeah, AckMate is awesome. Although I'm mostly using the vim ack plugin now. > I've never tried vim, was put off by past experience of vi. _______ Graeme -------------- next part -------------- An HTML attachment was scrubbed... URL: From mark.smith at practicalpoetry.co.uk Tue Oct 26 13:51:13 2010 From: mark.smith at practicalpoetry.co.uk (Mark Smith) Date: Tue, 26 Oct 2010 12:51:13 +0100 Subject: [Python Edinburgh] Pub Meetup Tomorrow: Who's Coming? In-Reply-To: References: Message-ID: 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 wrote: > I'll be along later, so no pie for me. > > Derek > > On Mon, Oct 25, 2010 at 10:37 AM, Mark Smith > 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ed.hawkins at st.com Tue Oct 26 14:04:13 2010 From: ed.hawkins at st.com (Ed HAWKINS) Date: Tue, 26 Oct 2010 14:04:13 +0200 Subject: [Python Edinburgh] Pub Meetup Tomorrow: Who's Coming? In-Reply-To: References: Message-ID: 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=st.com at 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 > wrote: I'll be along later, so no pie for me. Derek On Mon, Oct 25, 2010 at 10:37 AM, Mark Smith > 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: From john at sneeu.com Tue Oct 26 14:52:27 2010 From: john at sneeu.com (John Sutherland) Date: Tue, 26 Oct 2010 13:52:27 +0100 Subject: [Python Edinburgh] Pub Meetup Tomorrow: Who's Coming? In-Reply-To: References: Message-ID: On Tue, Oct 26, 2010 at 1:04 PM, Ed HAWKINS wrote: > 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)... I?m not a bit twiddler, but I don?t think you need the octal notation, also 0 is ?Falsy?, while all other integers are ?Truthy?, so the following could be: y & 8 and not y & 1 John. -- sneeu.com "A computer shall not waste your time or require you to do more work than is strictly necessary" ? Jef Raskin. From mark.smith at practicalpoetry.co.uk Tue Oct 26 14:52:47 2010 From: mark.smith at practicalpoetry.co.uk (Mark Smith) Date: Tue, 26 Oct 2010 13:52:47 +0100 Subject: [Python Edinburgh] Pub Meetup Tomorrow: Who's Coming? In-Reply-To: References: Message-ID: 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 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 =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 wrote: > > I'll be along later, so no pie for me. > > Derek > > On Mon, Oct 25, 2010 at 10:37 AM, Mark Smith > > 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: From mark.smith at practicalpoetry.co.uk Tue Oct 26 15:02:54 2010 From: mark.smith at practicalpoetry.co.uk (Mark Smith) Date: Tue, 26 Oct 2010 14:02:54 +0100 Subject: [Python Edinburgh] Pub Meetup Tomorrow: Who's Coming? In-Reply-To: References: Message-ID: You can also mask-out characters you're not interested in (I don't know if python2.5 will do the int() conversion with base 2 below... it might do.): def bits(v): return int(v, 2) # returns an int for a binary string bits_i_care_about = bits('0b1001') # Your bitmask - removes bits you don't care about expected_value = bits('0x1000') # Your expected value - masked-out values will be 0. # Use mask to remove bits you don't care about, then check the result against expected value (bit 3 high, bit 0 low, all others 0): if (y & bits_i_care_about) == expected_value: print 'yay!' --Mark On 26 October 2010 13:52, Mark Smith wrote: > 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 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 =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 wrote: >> >> I'll be along later, so no pie for me. >> >> Derek >> >> On Mon, Oct 25, 2010 at 10:37 AM, Mark Smith >> >> 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: From mark.smith at practicalpoetry.co.uk Tue Oct 26 15:19:00 2010 From: mark.smith at practicalpoetry.co.uk (Mark Smith) Date: Tue, 26 Oct 2010 14:19:00 +0100 Subject: [Python Edinburgh] Pub Meetup Tomorrow: Who's Coming? In-Reply-To: References: Message-ID: Sorry, I'm getting a bit carried away now. You can generate the two binary numbers you need using the bitmask function below. I used to have a load of these simple bit-twiddling functions when I was at ST. Unfortunately I stopped using them some time ago and didn't take a copy when I left. def bitmask(high_bits): """Takes a list of bit-indexes you want to be high, and returns an int with those bits high and all others low.""" result = 0 for i in high_bits: result |= (1 << i) return result mask = bitmask([3,0]) # Bits you want to test (we want to ensure 3 is high, 0 is low) expected_value = bitmask([3]) # Bits you want to be high (we want to ensure 3 is high, all others are low) if (y & mask) == expected_value: print 'yay!' -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben at moopet.net Tue Oct 26 15:32:23 2010 From: ben at moopet.net (Ben Sinclair) Date: Tue, 26 Oct 2010 14:32:23 +0100 Subject: [Python Edinburgh] Pub Meetup Tomorrow: Who's Coming? Message-ID: Hi, I'm Ben. I'm new here, but I'm planning on turning up tonight - hope to meet as many of you as possible :) ~Ben -------------- next part -------------- An HTML attachment was scrubbed... URL: From mark.smith at practicalpoetry.co.uk Tue Oct 26 16:14:57 2010 From: mark.smith at practicalpoetry.co.uk (Mark Smith) Date: Tue, 26 Oct 2010 15:14:57 +0100 Subject: [Python Edinburgh] Pub Meetup Tomorrow: Who's Coming? In-Reply-To: References: Message-ID: Welcome to the group, Ben. We're a relatively small and friendly bunch. Feel free to use the list to discuss anything interesting (loosely) related to Python, ask questions, recruit, or be recruited. See you tonight! --Mark On 26 October 2010 14:32, Ben Sinclair wrote: > Hi, I'm Ben. > I'm new here, but I'm planning on turning up tonight - hope to meet as many > of you as possible :) > > ~Ben > > _______________________________________________ > Edinburgh mailing list > Edinburgh at python.org > http://mail.python.org/mailman/listinfo/edinburgh > > -------------- next part -------------- An HTML attachment was scrubbed... URL: