On 25 Aug, 01:25, Steven D'Aprano <st...@remove-this- cybersource.com.au> wrote:
> On Mon, 24 Aug 2009 16:23:06 -0700, James Harris wrote: > > Sure but while I wouldn't normally want to type something as obscure as > > 32"rst" into a file of data I might want to type 0xff00 or similar. That > > is far clearer than 65280 in some cases. > > > My point was that int('ff00', 16) is OK for the programmer but cannot be > > used generally as it includes a function call. > > No, it's the other way around. If you have *data*, whether entered at run > time by the user or read from a file, you can easily pass it to a > function to convert to an int. (In fact you have to do this anyway, > because the data will be a string and you need an int.) > > If you want your data file to have values entered in hex, or oct, or even You are looking at this the other way round from me and I'll explain why I think this is important. I'm not talking about the *programmer* prescribing how the user should enter the data but the *user* being able to choose to prepare the data in a certain format - the format which makes sense for the data being entered. Your way only works if those fields in every row have the same format. That may be the case sometimes but is not general. > unary (1=one, 11=two, 111=three, 1111=four...) you can. There's no need > to have the user enter int('ff00', 16) to get hex, just have them enter > ff00. > > But when writing *code*, you want syntax which will accept integers in > the most common bases (decimal, a distant second hex, an even more > distant third octal, and way out on the horizon binary) without the > runtime cost of a function call. Be careful! When designing a language feature don't be too ready to *tell* the users of that language what restrictions they want. Just because the designer wants features with a certain frequency does not mean that all users will have the same priorities. (If it is impossible or unreasonable to support a feature then by all means don't support it. But don't decide up-front before examining the options that something in not personally appealing.) James -- http://mail.python.org/mailman/listinfo/python-list