[Python-3000] Octal

Guido van Rossum guido at python.org
Wed Mar 14 20:22:46 CET 2007


On 3/14/07, Patrick Maupin <pmaupin at gmail.com> wrote:
> Sure.  I'll do that tonight or tomorrow.
>
> It would be great to get my feet wet on the process on a relatively
> simple PEP.  One other question, first though -- not that I want to
> open a huge can of worms or anything, but if we are trying to make
> things nice and consistent, how about:
>
>     x = int("0x500")
>
> I know I can do int("500", 16) (and I think we want to keep that for
> sure), but for the cases of binary, octal, and hexadecimal which we
> have decided are special and useful, should the standard integer
> constructor also take these strings?

You can do this with

 x = int("0x500", 0)

> Thanks,
> Pat
>
>
> On 3/14/07, Guido van Rossum <guido at python.org> wrote:
> > Great! Mind writing up writing up a PEP that summarizes the discussion
> > (a bit)? In particular it should explain (a) why we need octal
> > literals; (b) why leading-zero is bad; (c) why we don't need general
> > bases; (d) why 0t is the best choice. Oh, and please add 0b too;
> > there's no formal proposal for that yet. Thanks!
> >
> > --Guido
> >
> > On 3/14/07, Patrick Maupin <pmaupin at gmail.com> wrote:
> > > On 3/14/07, Oleg Broytmann <phd at phd.pp.ru> wrote:
> > > >
> > > >       0b101010
> > > >       0c660
> > > >       0xffe
> > > >
> > > >    I.e. the first letter from "bin", the second from "oct", the third from
> > > > "hex". Also "0c" resembles "oc" from "oct".
> > >
> > > -1 on "c" It's too visually close to "0" in some fonts.
> > >
> > > +1 on "t"
> > >
> > > "t" does not appear in 'binary' or 'hexadecimal'
> > > "x" does not appear in 'binary' or 'octal'
> > > "b" does not appear in 'octal' or 'hexadecimal'
> > >
> > > And finally "c" means "character" in %s or PEP3101, and "t" is not yet
> > > defined as a type specifier.
> > >
> > > So just to couch it all in terms of a proposal:
> > >
> > > - In 2.6 and 3.0, we add 0t1234 as a valid octal number
> > > - In 2.6, we issue a deprecation warning for a leading literal 0 which
> > > is followed immediately by another digit.
> > > - In 3.0, that becomes an exception
> > > - If people really are still using octal that much, we should also
> > > consider adding it in to PEP3101.
> > >
> > > Regards,
> > > Pat
> > > _______________________________________________
> > > Python-3000 mailing list
> > > Python-3000 at python.org
> > > http://mail.python.org/mailman/listinfo/python-3000
> > > Unsubscribe: http://mail.python.org/mailman/options/python-3000/guido%40python.org
> > >
> >
> >
> > --
> > --Guido van Rossum (home page: http://www.python.org/~guido/)
> >
>


-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list