module to store functions/variables and how to call them? - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: module to store functions/variables and how to call them? (/thread-27341.html) |
module to store functions/variables and how to call them? - mstichler - Jun-03-2020 Can I create a module to store all my functions? for instance could i have a module that contains every function I need for my program, and if so how do I call on them? Can I create a module that hosts only variables? If so how do I call on them? Appreciate the help and apologize for noob questions. RE: Another basic question sorry im new lol - Yoriz - Jun-03-2020 variables.py VARIABLE1 = 'Variable1'my_funtions.py def function1(something): print(something)another.py import variables import my_funtions my_funtions.function1(variables.VARIABLE1)
RE: Another basic question sorry im new lol - DT2000 - Jun-03-2020 A program reads code line for line and execute according to its structure. Variables are defined and store specific values and information given to them according to the writers need or wants and they are called and used accordingly. If you are trying to save time in writing the code using modules containing variables in one and functions in another makes no viable sense and even if it were possible, and I do not believe it is, it would be more work in writing the code instead of writing it with conventional means. But of course I could be wrong in what you are trying to do and this reply may not apply. RE: Another basic question sorry im new lol - mstichler - Jun-03-2020 (Jun-03-2020, 06:15 PM)DT2000 Wrote: A program reads code line for line and execute according to its structure. Variables are defined and store specific values and information given to them according to the writers need or wants and they are called and used accordingly. in other languages I've used I find it makes my code more organized and easier for me to maintain, just a preference I guess. (Jun-03-2020, 06:10 PM)Yoriz Wrote: variables.py ty! |