do something
do something
do something
do something
do something
do something
I MEAN WHAT THE FUCK??? THERES LIKE THINGS YOU CAN USE TO SEPERATE BLOCKS OF CODE LIKE {[()]} PYTHON WTF?
Name:
Anonymous2007-09-09 12:41 ID:kXNqOVzd
I hate lisp because everything looks like:
(do (something
((do) something)
((do) (something
(do something)
(do something)
do) something)))
I MEAN WHAT THE FUCK??? THERES LIKE THINGS YOU CAN USE TO SEPERATE BLOCKS OF CODE LIKE INDENTATION LISP WTF?
Name:
Anonymous2007-09-09 12:54 ID:kEBk5Why
At least with lisp is painfully clear what code belongs to what expression as well you can indent as you wish
10 do something
20 do something
30 do something
40 do something
50 do something
60 do something
I MEAN WHAT THE FUCK??? THERES LIKE THINGS YOU CAN USE TO SEPERATE BLOCKS OF CODE LIKE GOTO BASIC WTF?
Name:
Anonymous2007-09-09 16:31 ID:2EBI8923
>>10
You obviously haven't used BASIC since the 80s
Name:
Anonymous2007-09-09 16:38 ID:LrriB7bi
loopStatement (condition){
conditionalStatement (condition){
do something;
}
conditionalStatement (condition){
do otherthing;
}
}
FUCK YEA JAVA
Name:
Anonymous2007-09-09 16:55 ID:J61iE+TC
>>1
Stupid fuck, there are these things you use to separate code: newline, indent and dedent.
>>3 At least with lisp is painfully clear what code belongs to what expression
If it isn't in Python, you're a complete loser, drop programming and get a job at McDonalds.
as well you can indent as you wish
As if this were a feature.
"ONE WORD, THE FORCED INDENTATION OF ONE WORD, THE FORCED INDENTATION OF code! THREAD OVER!! THREAD OVER!"
Name:
Anonymous2007-09-10 6:56 ID:f5TxuP0i
def ProclaimForcedIndentationOf(code):
return "ONE WORD, THE FORCED INDENTATION OF %s! THREAD OVER!" % code
Python wins sorry sir
Name:
Anonymous2007-09-10 7:14 ID:ApAu+LX3
[BBCPL]
[DEF = "CODE"]"one word, the forced ["[/DEF]
[DEF = "OVER"]"] THREAD OVER!"[/DEF]
[DEF = "NEST"][CODE][NEST]INDENTATION OF CODE![OVER][/DEF]
[NEST]
[/BBCPL]
[b][o][u]expert[/u][/o][/b] bbcode improvement on >>29
Name:
Anonymous2007-09-10 7:38 ID:f5TxuP0i
[define [ProclaimForcedIndentationOf [code]]
[join "" "ONE WORD, THE FORCED INDENTATION OF " code "! THREAD OVER!"]]
Name:
Anonymous2007-09-10 8:34 ID:sUp+5BMX
>>34
no it fails, the fucking FORCED INDENTATION OF CODE, THRAED OVER.
Name:
Anonymous2007-09-10 12:07 ID:5U0KnjIU
/tmp$ cat foo2.py
def f():
x = 3
def g():
print x+1
x = 2
print x
g()
f()
/tmp$ python foo2.py
3
Traceback (most recent call last):
File "foo2.py", line 8, in <module>
f()
File "foo2.py", line 7, in f
g()
File "foo2.py", line 4, in g
print x+1
UnboundLocalError: local variable 'x' referenced before assignment
Name:
Anonymous2007-09-10 15:38 ID:weUDNfFg
>>38
= rebinds a variable in the local scope, instead of modifying its contents which is what you wanted. When Python sees "x = 2" in g, it'll make x a local variable, shadowing f's x, and producing an error when you read it before assignment in print x+1.
I know this sucks, but at least it makes sense: variables are all references to objects, numbers and strings are immutable, and the assignment statement rebinds a variable; it doesn't change its contents. If you want to modify an object, use a mutable object such as a list or a dictionary.
In Python 3.0 (beta coming soon), you'll be able to work the way you want, by declaring x an "outer" variable with the outer keyword. You'd just insert: outer x
between def g(): and print x+1.