Re: Keeping track of state without globals?

If your program is too small to deserve not using globals, if you are going to finish this then never touch it again, then just use globals.  Doing class-level variables that get changed by classmethods doesn't help you because they're globals, you've just put a little bit of code on them so that you can pretend they're not and feel good about it.

I suspect what you want is a singleton.  To do that, make a class like you're going to make an instance, then make an instance of that class and use it as the global.  It's not as good as not having globals, but it's better than making everything a global.


There is a difference between a script and a program.  A script does one thing and is effectively write only.  You are talking about this like it's a script.  Scripts don't deserve being clean code.  You finish them, they're small, they're done forever, it doesn't matter.  If that's the case, wait for a bigger project in which to learn about modularity and avoidance of globals.

-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Dragonlee via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Dragonlee via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Dragonlee via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : chrisnorman7 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : chrisnorman7 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Dragonlee via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : GrannyCheeseWheel via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : chrisnorman7 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : GrannyCheeseWheel via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : GrannyCheeseWheel via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Dragonlee via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Dragonlee via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : GrannyCheeseWheel via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : chrisnorman7 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : GrannyCheeseWheel via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Dragonlee via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : GrannyCheeseWheel via Audiogames-reflector

Reply via email to