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
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