Ah, always mess up micro = 6/9 until I think about it for half a second.
Maybe a "n" suffix could have saved me there ;) For "long" numbers there's
the new _ so you can say 0.000_000_1 if you so preferred for 0.1 micro (I
generally see _ as more useful for high-precison numbers with more non-zero
digits, e.g. 1_234_456_789). Would that be 0.1µ, 0.1u in a new system.
Veering a bit away from the 'suffixing SI prefixes for literals': Literal
unary suffix operators might be slightly nicer than multiplication if they
were #1 in operator precedence, then you could omit some parentheses. Right
now if I want to use a unit:
$ pip install quantities
import quantities as pq
F = 1 * pq.N
d = 1 * pq.m
F * d # => array(1.0) * m*N
but with literal operators & functions could be something like
F = 1 pq.N
d = 1 pq.m
On Sat, Oct 29, 2016 at 1:18 PM, Todd
On Sat, Oct 29, 2016 at 12:43 PM, Nick Timkovich
wrote: From that page:
User-defined literals are basically normal function calls with a fancy syntax. [...] While user defined literals look very neat, they are not much more than syntactic sugar. There is not much difference between defining and calling a literal operator with "foo"_bar and doing the same with an ordinary function as bar("foo"). In theory, we could write literal operators that have side effects and do anything we want, like a normal function.
Obviously the arbitrary-function-part of that will never happen in Python (yes?)
Why not? It seems like that would solve a lot of use-cases. People get bringing up various new uses for prefix or suffix syntax that they want built directly into the language. Providing a generic way to implement third-party prefixes or suffixes would save having to put all of these directly into the language. And it opens up a lot of other potential use-cases as well.
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/