how to use more than 1 __init__ constructor in a class ?

Paul McGuire ptmcg at
Wed Jun 22 19:36:32 CEST 2005

This recipe that I submitted to the Python Cookbook
describes a technique for doing this.  I use the example of creating
Color objects for plotting to a bitmap, using either R,G,andB values,
or a single integer representing the RGB encoded value.

This style you describe is a Java language artifact.  If you have
optional params, then these really don't represent different method
signatures.  In my color example, you truly have different signatures,
either 3 integers representing color components, or a single encoded

-- Paul

More information about the Python-list mailing list