Gerhard H=E4ring wrote: > In article <3D9423FB.9070303@lemburg.com>, M.-A. Lemburg wrote: >=20 >>[mxNumber] >>I was wondering whether it would be worth adding something >>like a registry of literal modifiers to Python, >=20 >=20 > Especially for this purpose, that would be great. And have potential fo= r > misuse, too. Just like, say, operator overloading. But in the context o= f > Python, I didn't see any misuse of operator overloading, yet. I was thinking of giving the current concept of literal modifiers a more general scope. Of course, this can be misused, but then we could e.g. put certain constraints on the possible modifiers, say only allow a predefined number of modifiers and then have the compiler at compile time or the interpreter at run-time apply the necessary logic to the literal to turn it into an object. We currently have 'u', 'r', 'U', 'R' as modifiers for strings (prefixes) and 'l', 'L', 'j', 'J' for numbers (postfix). >>[...] 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) >=20 >=20 > A single literal, however, doesn't (easily) allow you to give precision= and > scale arguments to your decimal literal. That's of course easy if you c= an > declare your variable, which you can't in Python. So we're back to > constructors/factory functions here, right? Not really, since mxNumber Integers have arbitrary precision, so scale and precision are not needed. --=20 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/
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4