Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Globals vs Function
#1
Is using a function like this to define variables ok? 
def variables(a, b):
    a = something
    b = another

def some_function():
    do something with variables(a).
    do something with variables(b).
What is the difference between using a function to define variables and just using globals like this?
a = something
b = another

def some_function():
    do something with a.
    do something with b.
Reply


Messages In This Thread
Globals vs Function - by mcmxl22 - Feb-04-2017, 12:29 AM
RE: Globals vs Function - by wavic - Feb-04-2017, 12:53 AM
RE: Globals vs Function - by ichabod801 - Feb-04-2017, 11:38 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  why globals() exits python when quit() is aliased as q abc12346 4 714 May-23-2023, 08:56 AM
Last Post: Gribouillis
  How to avoid exec(), globals(), locals(), eval() paul18fr 10 5,125 Apr-21-2021, 05:53 PM
Last Post: snippsat
  accessing globals from a function Skaperen 8 4,181 Sep-01-2018, 11:50 PM
Last Post: Skaperen
  Use of Globals CWatters 5 3,876 Nov-13-2017, 09:00 PM
Last Post: CWatters

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020