Python Forum
Global Variables. Migrate code from MatLab
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Global Variables. Migrate code from MatLab
#1
Hi guys,

During my undergraduation I wrote a program in MatLab. This program have functions separated in different files that are called in the main file. I want to pass the code to Python 3.5.2.

My program read a huge data base recorded with sensors installed on airplanes. I load this data base in the main program and every column is stored in vectors that are global variables. That way the functions can access the values without necessity to load the data base again.

The problem is that every explanation that I read, showed which I need to change the value of a global variable when I call it. For example:

def func1():
    global myGlobal
    myGlobal = 42
But I want to do something like that:

def func1():
    global myGlobal
    local = myGlobal
    # do any math which I need in this function with the "local" variable
I appreciate all help with this question.
Reply


Messages In This Thread
Global Variables. Migrate code from MatLab - by Felipe - Jan-11-2017, 12:16 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Trying to understand global variables 357mag 5 1,111 May-12-2023, 04:16 PM
Last Post: deanhystad
  Global variables or local accessible caslor 4 1,014 Jan-27-2023, 05:32 PM
Last Post: caslor
  global variables HeinKurz 3 1,139 Jan-17-2023, 06:58 PM
Last Post: HeinKurz
  Clarity on global variables JonWayn 2 939 Nov-26-2022, 12:10 PM
Last Post: JonWayn
  migrate code from tkinter to pygame Frankduc 16 3,100 Jun-01-2022, 12:45 PM
Last Post: Frankduc
  Global variables not working hobbyist 9 4,704 Jan-16-2021, 03:17 PM
Last Post: jefsummers
  Global vs. Local Variables Davy_Jones_XIV 4 2,646 Jan-06-2021, 10:22 PM
Last Post: Davy_Jones_XIV
  Global - local variables Motorhomer14 11 4,221 Dec-17-2020, 06:40 PM
Last Post: Motorhomer14
  Question regarding local and global variables donmerch 12 5,069 Apr-12-2020, 03:58 PM
Last Post: TomToad
  local/global variables in functions abccba 6 3,420 Apr-08-2020, 06:01 PM
Last Post: jefsummers

Forum Jump:

User Panel Messages

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