Thank you all,

I was taking a look at the module decimal.py as you cited, and it makes
sense now. Looks very useful to make tools without having to instantiate
anything.

On Mon, Sep 13, 2010 at 7:05 AM, Steven D'Aprano <[email protected]>wrote:

> On Mon, 13 Sep 2010 12:29:07 pm Huy Ton That wrote:
> > Hm, thanks guys; I just had to verify I was thinking sanely about it.
> > I am going to pick up classmethods next. Do any of you have common
> > design patterns for the usage. They are just items I haven't
> > integrated in my coding, and I want to be certain I'm off on the
> > right foot (:
>
> The most common use for classmethods is to implement alternative
> constructors. For example, in the Decimal class starting in version 2.7
> and 3.1, you have two constructors:
>
> >>> from decimal import Decimal
> >>> Decimal("1.2345")
> Decimal('1.2345')
> >>> Decimal.from_float(1.2345)
> Decimal('1.2344999999999999307220832633902318775653839111328125')
>
> from_float is a class method.
>
>
> --
> Steven D'Aprano
> _______________________________________________
> Tutor maillist  -  [email protected]
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
_______________________________________________
Tutor maillist  -  [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to