On 1/16/06, Bob Ippolito <[EMAIL PROTECTED]> wrote: > > On Jan 16, 2006, at 9:12 PM, Andrew Bennetts wrote: > > > On Mon, Jan 16, 2006 at 11:54:05PM -0500, Raymond Hettinger wrote: > > [...] > >> That suggests that it would be better to simply add an int method: > >> > >> x.convert_to_base(7) > > > > This seems clear and simple to me. I like it. I strongly suspect > > the "bright > > beginners" Alex is interested in would have no trouble using it or > > finding it. > > I don't know about that, all of the methods that int and long > currently have are __special__. They'd really need to start with > Python 2.5 (assuming int/long grow "public methods" in 2.5) to even > think to look there. A format code or a built-in would be more > likely to be found, since that's how you convert integers to hex and > oct string representations with current Python. > > >>> [name for name in dir(0)+dir(0L) if not name.startswith('__')]
If a method is the best solution, then fine, 2.5 is the beginning of methods on int/long. We could do a static method like int.from_str("101", 2) and str.from_int(5, 2) if people don't like the overloading of the constructors. Otherwise add methods like '101'.to_int(2) or 5 .to_str(2) . -Brett _______________________________________________ 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