[Python-Dev] new language ideas

Brian Rzycki bmr at austin.rr.com
Sun Nov 2 21:27:14 EST 2003


Hi all,

I've been tinkering with a bit of a pet project on and off for some 
time now.  I'm basically trying to adapt the python style/syntax for a 
language that is a bit better suited as a classical systems programming 
language.  To be able to program with Python at the high level and 
something very pythonesque at the lower level is very appealing. :)

Well, when thinking about this, I've come up with a few ideas I think 
might benefit Python as well.  Please forgive me if these are repeats, 
I've never seen anything related to this in the PEPs or on the list.  
I'm just tossing these out for Python's benefit...

/me dons asbestos long-johns...

Multiline comments
--------------------------
#BEGIN
...
#END

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

__doc__ variable
------------------------
docstrings are really a special case of programmer documentation.  It'd 
be a lot nicer if there were some way to isolate certain portions of 
information in the docstring.  Most contain a short description as well 
as the expect things (I won't say types on this list) ;).  docstrings 
could be aliased through the dictionary __doc__.  The exact symantics 
are a bit fuzzy right now, but I wanted to toss out the idea for public 
scrutiny.  Here's an example:

def f(x):
     "does nothing, really."
     return(x)

In this case, __doc__.desc would equal the docstring.  This would allow 
for backward compatibility and allow for extension.  Think author, 
webpage, and version at the global scope and pre/post conditions, 
dynamically created information about a function/class.

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. ;)


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.  It would be nice 
to treat it almost as if it were a call to a radix() function.  I think 
the notation has a nice look to it and I think makes it easy to read.

So that's it for now.  Let me know what you think.

-Brian Rzycki




More information about the Python-Dev mailing list