2009-12-30

Reminder: PyCon 2010 early bird registration ends January 6!

So people don't forget to register for the early bird rate for PyCon, it closes January 6. Below is the email sent to python-dev by Van Lindberg, PyCon chair for 2010:

Do you have a year-end hole in your training budget? Or will the
improved economy let you finally attend a work conference? Come to sunny
and warm Atlanta in February for PyCon 2010. Early bird registration
ends on January 6.

Register: https://us.pycon.org/2010/register/

See the talks: http://us.pycon.org/2010/conference/talks/
Get trained at a tutorial:  http://us.pycon.org/2010/tutorials/

Also see the five (or more!) talks that people can't miss at PyCon:

PyOraGeek: PyCon pre-favorites
<http://catherinedevlin.blogspot.com/2009/11/pycon-pre-favorites.html>

Pyright: PyCon pre-favorites, the Carl T. edition:
<http://pyright.blogspot.com/2009/11/pycon-2010-pre-favorites-carl-t-edition.html>

Aftermarket Pipes: Five Pycon 2010 Talks I Need to See:
<http://apipes.blogspot.com/2009/12/five-pycon-2010-talks-i-need-to-see.html>

Jessenoller.com: PyCon 2010: Talks I want to see:
<http://jessenoller.com/2009/12/06/pycon-2010-talks-i-want-to-see-keynotes-registration-open/>

The Third Bit: Five PyCon Talks I Want To See:
<http://pyre.third-bit.com/blog/archives/3364.html>

See you at PyCon!

Register: https://us.pycon.org/2010/register/

2009-12-12

How to handle multiple inheritance of ABCs that implement each others abstract methods

Let's say I have two ABCs, NeedA and NeedB, that implement each others' abstract methods:

class NeedA(metaclass=abc.ABCMeta):
  @abc.abstractmethod
  def need_A(self):
    pass
  def need_B(self):
    pass

class NeedB(metaclass=abc.ABCMeta):
  @abc.abstractmethod
  def need_B(self):
    pass
  def need_A(self):
    pass
Now, how do you create a subclass, through multiple inheritance, that inherits both ABCs such that their abstract method requirements are met by each other? You can't do the naive solution of inheriting both because whomever comes first in the inheritance chain will trigger a TypeError:

class SubClass(NeedA, NeedB):
  pass

SubClass()  # Raises TypeError for NeedA.need_A not being implemented.


The TypeError is triggered because NeedA.need_A() shadows NeedB.need_A(), preventing the abstract method from being implemented.

Luckily it is easy to get around this:

class SubClass(NeedA, NeedB):
  need_A = NeedB.need_A


By explicitly pulling up into the subclass the shadowed method needed to meet the abstract method requirement you fix the error. This trick works because class statements essentially execute the code contained within them, making any created variables class variables; this obviously includes assignment.

I came across this problem myself and it took my a second to figure out how best to solve it w/o trying some crazy metaclass that searched both up and down the inheritance tree looking for methods that implement an abstract method.

2009-12-04

PyCon 2010 early-bird registration is open!

In case you have not heard yet, PyCon 2010 early-bird registration is now open and will end on January 6.

2009-12-02

Short personality test on how you design software

A good friend of mine has created a personality test to both let you know what kind of developer you are when it comes to designing software as well as gather data for his PhD. If you have the 10 minutes it takes to do the test, please do take it; turns out HR and secretaries don't like letting PhD students talk to managers to let them give a short online test to their developers.