Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Python Code Contraction

Name: Anonymuus 2011-05-15 2:50

Working on python code, there are a few ways to contract code:
print 'hi'
print 'ho'

can be written as:
print 'hi';print 'ho'

something like
for i in range(9):print i
is perfectly like acceptable in one line, yet these don't work for one reason or another:
print 'hi';for i in range(9):print i
for i in range(9):if i != 8:print i
if i != 8: print i;else:print 'no'

because nesting a loop or a condition anywhere but the beginning of a line gives a syntax error.
Is is possible any other way?

Name: Anonymous 2011-05-15 5:59

>>6 it looks, like you want to use code indentation, to express, that some data is strictly bound to some computations. It can be elegantly expressed in Haskell by using let construction:

Prelude>let x=9; y=99 in x+y

Name: JAVASCRIPTTER 2011-05-15 6:21

>>9
{var x=9,y=99; return x+y;}

Name: PERLLER 2011-05-15 7:27

>>9,11
108

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List