On Wednesday 2006-01-18 16:55, Steven Bethard wrote: > [Raymond] > > Perhaps introduce a single function, base(val, radix=10, > > prefix=''), as a universal base converter that could replace > > bin(), hex(), oct(), etc. > > +1 on introducing base()
Introducing a new builtin with a name that's a common, short English word is a bit disagreeable. The other thing about the name "base" is that it's not entirely obvious which way it converts: do you say base(123,5) to get a string representing 123 in base 5, or base("123",5) to get the integer whose base 5 representation is "123"? Well, one option would be to have both of those work :-). (Some people may need to do some deep breathing while reciting the mantra "practicality beats purity" in order to contemplate that with equanimity.) Alternatively, a name like "to_base" that clarifies the intent and is less likely to clash with variable names might be an improvement. Or there's always %b, whether that ends up standing for "binary" or "base". Or %b for binary and %r for radix, not forgetting the modifiers to get numbers formatted as Roman numerals. -- Gareth McCaughan _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com