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: newfag 2007-09-02 6:34 ID:Fm5EpQWi

I got the first example, until i saw what came after, and you fucking lost me... All you're doing for fvar is wrapping it in a list? why does this work?

I want a current_room variable (just a single int)  that is changeable from any number of nested functions deep, and is also readable from any number deep.

I'm not trying to do anything correct with this, I just need it to work. (this is my first 24 hours working with python, i'm coding this thing for the sake of reviewing what I learned)

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