[Python-Dev] new language ideas

Phillip J. Eby pje at telecommunity.com
Sun Nov 2 22:54:32 EST 2003

At 08:27 PM 11/2/03 -0600, Brian Rzycki wrote:
>Multiline comments
>Everything in between is ignored.  It would be very useful when debugging 
>decent sized blocks of code.  I know certain editors can auto-comment 
>blocks, but it can be difficult to un-auto-comment said block.  The same 
>smart editors could colorize the block accordingly, minimizing readiblity 

Just triple quote.  I usually use """ for actual strings in my programs, 
and if I need to comment out a block I use '''.

>bit access of integers
>Like strings, we can use [] to index into python integers.  It'd be a nice 
>way to set/read individual bits of a given integer.  For example:
>x = 5
>x[0] = 0
>print x
>(prints 4)
>The details of how to index (I was assuming big-endian in this example) 
>are open to discussion.  This would make bit-banging in python be even 
>easier than C (not to mention easier to read).  This assumes we want 
>Python to be good at bit-banging. ;)

Integers are immutable.  What you want is a bit array; you could write one 
of your own in Python easily enough, or C if you need higher 
performance.  Or maybe you could supply a patch for the Python 'array' 
module to support a bit type.

>alternative base notation
>Python inherited C's notation for numbers of non-decimal bases.  I propose 
>another with simpler syntax: number_base.  An example:
>x = 24b_16
>y = 1001_2
>z = 96zz_36
>The range for this notation would be 2 to 36 for the base.  This allows 
>for the entire alphabet plus numbers to be used as numerical 
>placeholders.  I'd be happy if _2, _8, _16 were the only ones implemented 
>because those are the most commonly used.

Python already implements 8 and 16, using 0 and 0x prefixes.  Presumably, 
you're therefore requesting an 0b or some such.  Note that you can already 
do this like so:

 >>> print int("100100",2)

However, if I were using bit strings a lot, I'd probably convert them to 
integers or longs in hex form, just to keep the program more compact.

More information about the Python-Dev mailing list