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

Python + global variables = ;_;

Name: Anonymous 2007-09-02 6:17 ID:Fm5EpQWi

I'm new to python and 'real' programming. I fucked around with logo and qbasic before briefly, but never anything serious.

I want to change a variable from inside a function, but it only creates a local one with the same name. How the fuck do i change the global variable? (in this case "current_room").

please explain it to me or link to something useful.

;_;

in b4 people flip out and call me names + act like fags and bitch about python

Name: Anonymous 2009-03-03 6:57

Wrap it into a list.
Why do people do that? It's hideous.

Use a dummy class instead. More readable.

class loli: count = 3
def get_another_loli():
    loli.count += 1


It sort of sidesteps the entire scoping issue. Probably "real" Python fagtards will bitch about it not being Pythonic or some stupid shit like that, but fuck, it's better than writing [0] all over the damn place.

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