Name: Anonymous 2006-11-30 5:28
I'm considering writing a Python preprocessor that will parse Python code "with stuff" and write real Python code, to add to Python what many want, at the cost of reserving all names starting with four underscores (I doubt you'll need these). I'm considering of supporting the following, but I'm interested on hearing comments, feedbacks, etc. Also, if you're interested on doing this, go for it, I may take a long time as I have little spare time.
1. Support for inline def (anonymous block closures) like:
#We call hello(int, function, int) with a new anonymous block closure as follows:
2. More comfortable if..else (with flawless workaround for Python < 2.5): iff (cond) (expr_true) (expr_false)
3. Switch:
4. Do..while:
5. until expr = while not (expr), serves for both while and do..while blocks
6. /* ... */ comments, as in C
7. q{ ... } and q[ ... ] quotes with recursive {} or [] matching (e.g. q[a['k']="v"] is fine), as in Perl; q{} and q[] for str strings and u{} and u[] for unicode strings
8. Alternate syntax for decorators: instead of:
@staticmethod
def mymethod():
you can simply do:
@staticmethod mymethod():
9. swap statement to exchange the value of two lvalues: swap x y
10. defined() special function which returns whether an identifier has been defined or not (like isset) without raising an exception
11. Optionally enabled: ? becomes an alias to lambda, so ?x: x + 1 is equivalent to lambda x: x + 1
12. Optionally enabled: automatic Unicode conversion: str to unicode, '' to u'', q{} to u{}, etc.
1. Support for inline def (anonymous block closures) like:
#We call hello(int, function, int) with a new anonymous block closure as follows:
hello(1, def (x):
...code of anonymous closure...
, 2) #Starts in the same column as hello2. More comfortable if..else (with flawless workaround for Python < 2.5): iff (cond) (expr_true) (expr_false)
3. Switch:
switch expr:
case expr1:
block
case expr2:
block
default: #Optional
block4. Do..while:
do:
block
while cond5. until expr = while not (expr), serves for both while and do..while blocks
6. /* ... */ comments, as in C
7. q{ ... } and q[ ... ] quotes with recursive {} or [] matching (e.g. q[a['k']="v"] is fine), as in Perl; q{} and q[] for str strings and u{} and u[] for unicode strings
8. Alternate syntax for decorators: instead of:
@staticmethod
def mymethod():
you can simply do:
@staticmethod mymethod():
9. swap statement to exchange the value of two lvalues: swap x y
10. defined() special function which returns whether an identifier has been defined or not (like isset) without raising an exception
11. Optionally enabled: ? becomes an alias to lambda, so ?x: x + 1 is equivalent to lambda x: x + 1
12. Optionally enabled: automatic Unicode conversion: str to unicode, '' to u'', q{} to u{}, etc.