Re: if the else short form

2010-10-10 Thread NevilleDNZ
ttp://xkcd.com/353/ Enjoy NevilleDNZ -- To download Linux's Algol68 Compiler, Interpreter & Runtime: * http://sourceforge.net/projects/algol68/files -- http://mail.python.org/mailman/listinfo/python-list

Re: if the else short form

2010-10-09 Thread NevilleDNZ
On Oct 9, 6:55 pm, Lawrence D'Oliveiro wrote: > In message , BartC wrote: > > > "NevilleDNZ" wrote in message > >news:ad9841df-49a1-4c1b-95d0-e76b72df6...@w9g2000prc.googlegroups.com... > > >> In Algol68 this would be: > >> x:=(i|"One&

Re: if the else short form

2010-10-08 Thread NevilleDNZ
ef" form if IF clause: ( condition1 | statements |: condition2 | statements | statements ) CASE switch1 IN statements, statements,... OUSE switch2 IN statements, statements,... [ OUT statements ] ESAC "brief" form of CASE statement: ( switch1 | statements,statements,... |: switch

Re: if the else short form

2010-10-08 Thread NevilleDNZ
On Oct 7, 9:23 am, Lawrence D'Oliveiro wrote: > x = {1 : "One", 2 : "Two", 3 : "Three"}.get(i, "None Of The Above") More like: x = {1:lambda:"One", 2:lambda:"Two", 3:lambda:"Three"}.get(i, lambda:"None Of The Above")() i.e. deferred evaluation of selected case. In Algol68 this would be: x:=(i|"

Re: Modifying Class Object

2010-02-23 Thread NevilleDNZ
u to join one of the below groups (my .sig below) and deposit some of your Algol68 impressions There is also a chrestomathy site http://rosettacode.org/wiki/ALGOL_68 where you can pick out an code sample unimplemented in Algol68 and torture test your Algol68 memories. (Be warned: Most of the eas

Re: Annoying octal notation

2009-09-04 Thread NevilleDNZ
On Sep 3, 2:57 pm, James Harris wrote: > On 3 Sep, 14:26, Albert van der Horst > wrote: > > > In article > > <6031ba08-08c8-416b-91db-ce8ff57ae...@w6g2000yqw.googlegroups.com>, > > James Harris   wrote: > > > > > >So you are saying that Smalltalk has r where > > >r is presumably for radix? That

Re: Numeric literals in other than base 10 - was Annoying octal notation

2009-08-24 Thread NevilleDNZ
On Aug 23, 9:42 pm, James Harris wrote: > The numbers above would be > > 0b1011, 0t7621, 0xc26b Algol68 has the type BITS, that is converted to INT with the ABS operator. The numbers above would be: > 2r1011, 8r7621, 16rc26b "r" is for radix: http://en.wikipedia.org/wiki/Radix The standard

Re: RegEx for matching brackets

2008-05-03 Thread NevilleDNZ
To check a complete python expression use: def check_open_close(expr): try: eval(expr) except SyntaxError: return False else: return True This also ignores brackets in quotes, and checks <= & >= operators are syntatically correct etc... But is may have side effects... ;-) eg. c

Re: RegEx for matching brackets

2008-05-02 Thread NevilleDNZ
On May 2, 11:13 am, George Sakkis <[EMAIL PROTECTED]> wrote: > [1]http://en.wikipedia.org/wiki/Context-free_language > [2]http://en.wikipedia.org/wiki/Regular_language > [3]http://wiki.python.org/moin/LanguageParsing Thanx for the link to these parsers. ANTLR looks interesting. Yoyo: http://www-us

RegEx for matching brackets

2008-05-01 Thread NevilleDNZ
Below is a (flawed) one line RegEx that checks curly brackets (from awk/c/python input) are being matched. Is there a one liner for doing this in python? ThanX N re_open_close="(((\{))[^{}]*((?(0)\})))+" re_open_close=re.compile(re_open_close) tests=""" { this is a test BAD { this is a test

Just TOO easy.... Re: Q: a simple(?) raw-utf-8 conversion to internal type unicode "\304\246\311\231\316\257\316\271\303\222"

2006-12-31 Thread NevilleDNZ
)" $ ./uc.py English/ASCII quoting: "ĦəίιÒ ώσŔĹĐ" SUCCEEDS :-) German/ALCOR quoting: ᛭test᛭ AOK :-) German/ALCOR quoting: ᛭ĦəίιÒ ώσŔĹĐ᛭ Just TOO easy :-) NevilleDNZ wrote: > Hi, > > Apologies first as I am not a unicode expert indeed I the details > probably totally e

Q: a simple(?) raw-utf-8 conversion to internal type unicode "\304\246\311\231\316\257\316\271\303\222"

2006-12-31 Thread NevilleDNZ
ror: 'ascii' codec can't decode byte 0xc4 in position 0: ordinal not in range(128) The last print statement fails because the ascii "imported" characters are 8 bit encoded UTF-8 and dont know it! How do I tell "imported" that it is actually already UTF-8 unicode? Cheers NevilleDNZ -- http://mail.python.org/mailman/listinfo/python-list

Re: proc A def/calls proc B: variable scoping rules.

2006-08-15 Thread NevilleDNZ
Steven D'Aprano wrote: > Basically, when you access a variable name on the left hand side of an > assignment (e.g. "a = 1") ANYWHERE in a function, that name is local to > that function UNLESS it has been declared global. ThanX Steven, I am still getting used to python scoping rules. I didn't real

Re: proc A def/calls proc B: variable scoping rules.

2006-08-15 Thread NevilleDNZ
Steve Holden wrote: > No. It's too horrible to contemplate without getting mild feelings of > nausea. What exactly is it you are tring to achieve here (since I assume > your goal wasn't to make me feel sick :-)? It is part of an algorithum: #!/usr/bin/env python def A(k, x1, x2, x3, x4, x5): de

Re: proc A def/calls proc B: variable scoping rules.

2006-08-15 Thread NevilleDNZ
I inserted x1,x2 into A to force a wider scope and it works. #!/usr/bin/env python def A(): print "begin A:" A.x1=123; A.x2=456; def B(): print "begin B:",A.x1,A.x2 A.x2 = A.x2 + 210; # problem gone. print "end B:",A.x1,A.x2 print "pre B:",A.x1,A.x2 B() print "end A:",A.x

Re: proc A def/calls proc B: variable scoping rules.

2006-08-15 Thread NevilleDNZ
Steve Holden wrote: > Hardly surprising. This statement is an assignment to x2, which > therefore becomes local to the function. Since no previous value has > been assigned to this local, the exception occurs. But: In this case the assignment is never reached eg.. #!/usr/bin/env python def A(

proc A def/calls proc B: variable scoping rules.

2006-08-15 Thread NevilleDNZ
Can anyone explain why "begin B: 123" prints, but 456 doesn't? $ /usr/bin/python2.3 x1x2.py begin A: Pre B: 123 456 begin B: 123 Traceback (most recent call last): File "x1x2.py", line 13, in ? A() File "x1x2.py", line 11, in A B() File "x1x2.py", line 7, in B print "begin B:",x