About 12,500 results
Open links in new tab
  1. Global keyword in Python - GeeksforGeeks

    Jul 11, 2025 · The global keyword in Python allows a function to modify variables that are defined outside its scope, making them accessible globally. Without it, variables inside a function are treated …

  2. Python - Global Variables - W3Schools.com

    Variables that are created outside of a function (as in all of the examples in the previous pages) are known as global variables. Global variables can be used by everyone, both inside of functions and …

  3. Using and Creating Global Variables in Your Python Functions

    This tutorial will guide you through accessing and modifying global variables in Python functions using the global keyword and the globals() function. You’ll also learn to manage scope and avoid potential …

  4. python - How can I use a global variable in a function? - Stack Overflow

    Jul 11, 2016 · If you want to refer to a global variable in a function, you can use the global keyword to declare which variables are global. You don't have to use it in all cases (as someone here incorrectly …

  5. Python Global Variables

    In Python, a global variable is a variable defined outside of any function, making it accessible throughout the entire module or script. Unlike local variables that are confined to a specific function's scope, …

  6. Python Global Keyword (With Examples) - Programiz

    In this tutorial, we'll learn about the global keyword with the help of examples.

  7. Understanding and Using Global Variables in Python - PyTutorial

    Oct 21, 2024 · In this article, we'll explore global variables in Python - what they are, how to use them, their advantages and disadvantages, and best practices for working with them.

  8. Python Global Variables: The Good, the Bad, and the Ugly

    6 days ago · Python global variables and the global keyword — when to use them, why they're usually bad, and better alternatives.

  9. Python Global Variables | Definition, Scope and Examples

    Sep 9, 2025 · Python global variables explained! Learn how to declare, modify and use them effectively while understanding their scope, limitations and best practices.

  10. Understanding Global Variables in Python - Medium

    Sep 3, 2025 · In Python, the global keyword plays a pivotal role in managing the scope of variables. It allows you to modify the value of a global variable inside a function. This ability can be extremely...