[Python-Dev] User extendable literal modifiers ?!

M.-A. Lemburg mal@lemburg.com
Fri, 27 Sep 2002 11:25:15 +0200


As you might have noticed, I have wrapped several parts of the
GMP Multi-Precision (GMP) library in form of Python types
in mxNumber.

Since these are numbers, it would be convenient if there were
some way to create them in form of literals, much like 123L
creates longs instead of integers or u"abc" gives you Unicode
instead of an 8-bit string.

I was wondering whether it would be worth adding something
like a registry of literal modifiers to Python, so that
extensions can register new modifiers with the compiler,
e.g.

sitecustomize.py:
def create_I_literal(literal_string):
     return 'mx.Number.Integer(%s)' % literal_string
sys.register_numberlitmod('I', create_I_literal)

test.py:
x = 123I * 456I
print x, 234I

-- 
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
_______________________________________________________________________
eGenix.com -- Makers of the Python mx Extensions: mxDateTime,mxODBC,...
Python Consulting:                               http://www.egenix.com/
Python Software:                    http://www.egenix.com/files/python/