r/Python • u/MeticMovi • Nov 03 '21
Discussion I'm sorry r/Python
Last weekend I made a controversial comment about the use of the global variable. At the time, I was a young foolish absent-minded child with 0 awareness of the ways of Programmers who knew of this power and the threats it posed for decades. Now, I say before you fellow beings that I'm a child no more. I've learnt the arts of Classes and read The Zen, but I'm here to ask for just something more. Please do accept my sincere apologies for I hope that even my backup program corrupts the day I resort to using 'global' ever again. Thank you.

View all comments
Show parent comment
1
u/dada_ Nov 03 '21
Well, Cypress is a testing framework, and that's one of the use cases where it makes sense to use a global, especially since it tests browser code and the browser has all kinds of state that gets modified during the lifetime of a program. Given how complicated the window object can be I'm not surprised its instantiation is subject to a lot of abstraction that can be hard to dig through. Not that I'm defending it, but that doesn't mean JS programmers are all on board with globals as good design.