[New-bugs-announce] [issue41616] Global variable in whole project and Relative imports problem

ManPython report at bugs.python.org
Sat Aug 22 09:43:37 EDT 2020


New submission from ManPython <ManPython at outlook.com>:

1. Curently we have easy option to declare global variable (GV) 
a) like this:
global var1
var1 = 'whatever'

b) with some improved version like this:
global var1 'whatever'
or:
global var1,var2, 'whatever1','whatever2'

c) The Python is in way to produce small lines of code but this philosophy around GV not offering this.


2. Can we have easy option to delclare global variable for whole project including MVC?
a) By this is requiments to call GV in any place like in Model, View or Controler and change thits var globaly.

b) I noticed that programers many often calling module in main to operate with, where this way made many problems withs Relative imports
https://stackoverflow.com/questions/30669474/beyond-top-level-package-error-in-relative-import
https://stackoverflow.com/questions/14132789/relative-imports-in-python-2-7/
https://stackoverflow.com/questions/35166821/valueerror-attempted-relative-import-beyond-top-level-package
https://stackoverflow.com/questions/40022220/attempted-relative-import-beyond-toplevel-package

b) In my test the Relative imports made often problems (As imposible to load - most often Django, but similar with Pyside2) and I noticed that exist some relation with global var. In some of P36 version most often due to libs. Wan't checking this, expecting other way (more easy) to solve typical problems with GV.
1) in Django most often is meeting in config.py
2) in Pyside2 most often is meeting in main.py where we calling model,view,controler (or other liek utils) and we trying working in some core variables that limitig projects to easy manage GV

----------
components: Interpreter Core
messages: 375799
nosy: ManPython
priority: normal
severity: normal
status: open
title: Global variable in whole project and Relative imports problem
type: enhancement
versions: Python 3.10, Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41616>
_______________________________________


More information about the New-bugs-announce mailing list