any interest in type-scoped static constants?

Aahz Maruch aahz at panix.com
Sun Mar 11 17:12:29 CET 2001


In article <3AAB9578.4C8754E4 at fxtech.com>,
Paul Miller  <paul at fxtech.com> wrote:
>
>If I write an extension type that mirrors the functionality of a C++
>class, and the C++ has static constants within its scope, I can do this
>in C++:
>
>	Point p = Point::ZERO;
>
>Where ZERO is defined as:
>
>	class Point
>	{
>		static Point ZERO = Point(0, 0);
>	};
>
>If I create an extension type for Point, I can't do this:
>
>	p = Point.ZERO

Hmmmm....  The problem is that in Python, you've got a recursive
structure definition -- is that exact syntax really legal in C++?  In
Python itself, the way I'd do this is to create a module Point that
contains the Point class, and following the class definition create the
ZERO object.  Then you refer to it as Point.ZERO and create new points
with Point.Point().
-- 
                      --- Aahz (Copyright 2001 by aahz at pobox.com)

Androgynous poly kinky vanilla queer het    <*>     http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6

"Perhaps God rewards martyrs, but life seldom does..." --Ulrika O'Brien



More information about the Python-list mailing list