0

I am building a code that looks something like this:

def firstfunction()
 index1 = 0
 index2 = 0
 somedataframe1 = [...]
 somedataframe2 = [...]
 while somecondition1:
  secondfunction(index1 somedataframe1)
  secondfunction(index2 somedataframe2)

def secondfunction(index somedataframe)
 while somecondition2:
  somedataframe.doathing[index]
  index = index + 1

firstfunction is supposed to iterate through calling secondfunction a number of times for two different dataframes, then second function iterates through a big section of code where it manipulates parts of the supplied dataframe according to the index value, and at the end I want it to increment the index value. And it follows the exact same process separately with both dataframes. When secondfunction changes the value of index, will that change automatically be extended to index1 or index2, whichever 1 is being used at the time? Or will the change be local?

  • 1
    Have you tried it to see the outcome? In a case like this it seems fairly trivial to create a sample dataframe and simple code to see what the results are – G. Anderson Jan 24 '22 at 17:38
  • Welcome to Stack Overflow. You don't pass variables to functions. You pass *values* to functions. I can't understand your example, though, because you are saying something about global variables, but you don't show any in the code. Please try to write actual code that would be accepted without a syntax error, and please use a normal amount of indentation (4 spaces per level). – Karl Knechtel Jan 24 '22 at 17:38
  • No, assignment to a parameter **is never** seen in the caller. That would be call by reference semantics, which Python *never supports*. – juanpa.arrivillaga Jan 24 '22 at 17:38
  • 1
    parameters must be separated by comma. –  Jan 24 '22 at 17:39

0 Answers0