473,412 Members | 1,921 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

Global Variables Over Multiple Source Files

So basically I can't seem to get global variables in functions I import from a different file.

Also are the only scopes in python classes and functions?
Or is there a way to set your own scopes.
Like in C++ you can put {} brackets anywhere you like.
Jul 31 '11 #1
1 2551
bvdet
2,851 Expert Mod 2GB
Not unless the variable is declared global, which makes it an attribute of the module after the function is called as in:
Expand|Select|Wrap|Line Numbers
  1. import xyz
  2. xyz.f()
  3. xyz.f_var
Why not return the value of the variable? The use of classes with mutable attributes is my preference. That way you can have multiple variables directly accessible.
Jul 31 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Rita Mathoa | last post by:
I have a giant xsl-fo document that I am running though Apache FOP to generate a pdf. I would like to break this xsl-fo file into smaller, more manageable pieces, but have those pieces get pulled...
2
by: John J. Lee | last post by:
I was cheered to see that this guy claims to have solved the problem with onload only firing very late: http://dean.edwards.name/weblog/2005/09/busted/ However, "ash" comments on that...
2
by: Vinu | last post by:
Hi, I am facing one problem related to global variables in .so file. When ever I access the variable the application is crashing I have a class called services. class services { services(){...
3
by: eBob.com | last post by:
(Not that size matters, but ...) I have a program which is getting too big. So I'd like to split it into several source files. I know that I can create a ModuleX.vb source file which looks like...
3
by: Matt | last post by:
Hey guys. I'm currently working through a number of C programming exercises to get me up to speed with the syntax. Before now I have been using Fortran and I've found Plato3 in Windows to be an...
1
weaknessforcats
by: weaknessforcats | last post by:
C++: The Case Against Global Variables Summary This article explores the negative ramifications of using global variables. The use of global variables is such a problem that C++ architects have...
1
by: broli | last post by:
How can this be done in windows based C compilers like PellesC ?? Is it possible to write a makefile or use the cc- o option as available in unix/linux ?? does anyone know of good makefile...
1
by: RossGK | last post by:
Newbie questions on PyDev project setup. Things are going fine - writing python code in eclipse/pydev and running them with various imports etc, doing wxpython stuff blah, blah, blah. My .py code...
0
by: Sells, Fred | last post by:
the short answer is a file is a module; therefore to 'include' access to 'myclass' in file xyz.py from another file called 'abc.py' you would put this in abc.py import xyz #note no '.py' x =...
6
by: Oliver Graeser | last post by:
Ok, stupid question.... I used to write programs all into one text files and compile them. Works, fine. Then I discovered XCode (or IDEs in general) which appear to be really increasing my...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.