variable assigned at the end of a module
up vote
0
down vote
favorite
I have a quick question about how variables are passed from 1 module to another.
Scenarios:
I have 2 scripts, 1 name a.py and b.py.
## a.py
import datetime
import numpy as np
import os
class LOG:
testid = ""
log_f = None
perf_log_f = None
def __init__(self):
self.testid = ""
def setTestId (testid, log_f , perf_log_f):
log_v.testid = comp
log_v.log_f = open(log_f , 'w')
log_v.perf_log_f = open(perf_log_f, 'w')
log_v = LOG()
l is initiated
## b.py
from a import *
testid = 999
log_f = "kk.log"
perf_log_f = "kk_perf.log"
setTestId (testid, log_f , perf_log_f)
#### Does this setTestId do this step?
"log_v.log_f = open("kk.log", 'w')
"log_v.perf_log_f = open("kk_perf.log", 'w')
Make the amendment. So when I call setTestId
(imported from a
) into b.py
, log_v = LOG()
is only contained within a.py
, right?
I would like to check if the the variable log_v
in a.py
will be overwritten if we assign log_v
to another variable in b.py
python class variables
add a comment |
up vote
0
down vote
favorite
I have a quick question about how variables are passed from 1 module to another.
Scenarios:
I have 2 scripts, 1 name a.py and b.py.
## a.py
import datetime
import numpy as np
import os
class LOG:
testid = ""
log_f = None
perf_log_f = None
def __init__(self):
self.testid = ""
def setTestId (testid, log_f , perf_log_f):
log_v.testid = comp
log_v.log_f = open(log_f , 'w')
log_v.perf_log_f = open(perf_log_f, 'w')
log_v = LOG()
l is initiated
## b.py
from a import *
testid = 999
log_f = "kk.log"
perf_log_f = "kk_perf.log"
setTestId (testid, log_f , perf_log_f)
#### Does this setTestId do this step?
"log_v.log_f = open("kk.log", 'w')
"log_v.perf_log_f = open("kk_perf.log", 'w')
Make the amendment. So when I call setTestId
(imported from a
) into b.py
, log_v = LOG()
is only contained within a.py
, right?
I would like to check if the the variable log_v
in a.py
will be overwritten if we assign log_v
to another variable in b.py
python class variables
2
assuming your indentation is correct the answer is no.
– Red Cricket
Nov 15 at 5:56
you are callingl.selfTestId
onl
but your method is not part of the classLOG
. Check your indentation or refresh OOP concepts
– Prakash Palnati
Nov 15 at 5:58
Naming a variable "l" is too ambiguous, try to name it properly and for your answer it is no.
– Vishnudev
Nov 15 at 6:05
Let's put it this way:l
inb.py
will be exactly whatl
is ina.py
.
– deceze♦
Nov 15 at 6:09
so the c = Clog() is contain within scripts a.py? and if I have a variable c in b.py, this is not related to the c in a.py>? I apologise for my bad OOP concepts. Also, the indentation is correct.
– snookrun
Nov 15 at 6:44
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have a quick question about how variables are passed from 1 module to another.
Scenarios:
I have 2 scripts, 1 name a.py and b.py.
## a.py
import datetime
import numpy as np
import os
class LOG:
testid = ""
log_f = None
perf_log_f = None
def __init__(self):
self.testid = ""
def setTestId (testid, log_f , perf_log_f):
log_v.testid = comp
log_v.log_f = open(log_f , 'w')
log_v.perf_log_f = open(perf_log_f, 'w')
log_v = LOG()
l is initiated
## b.py
from a import *
testid = 999
log_f = "kk.log"
perf_log_f = "kk_perf.log"
setTestId (testid, log_f , perf_log_f)
#### Does this setTestId do this step?
"log_v.log_f = open("kk.log", 'w')
"log_v.perf_log_f = open("kk_perf.log", 'w')
Make the amendment. So when I call setTestId
(imported from a
) into b.py
, log_v = LOG()
is only contained within a.py
, right?
I would like to check if the the variable log_v
in a.py
will be overwritten if we assign log_v
to another variable in b.py
python class variables
I have a quick question about how variables are passed from 1 module to another.
Scenarios:
I have 2 scripts, 1 name a.py and b.py.
## a.py
import datetime
import numpy as np
import os
class LOG:
testid = ""
log_f = None
perf_log_f = None
def __init__(self):
self.testid = ""
def setTestId (testid, log_f , perf_log_f):
log_v.testid = comp
log_v.log_f = open(log_f , 'w')
log_v.perf_log_f = open(perf_log_f, 'w')
log_v = LOG()
l is initiated
## b.py
from a import *
testid = 999
log_f = "kk.log"
perf_log_f = "kk_perf.log"
setTestId (testid, log_f , perf_log_f)
#### Does this setTestId do this step?
"log_v.log_f = open("kk.log", 'w')
"log_v.perf_log_f = open("kk_perf.log", 'w')
Make the amendment. So when I call setTestId
(imported from a
) into b.py
, log_v = LOG()
is only contained within a.py
, right?
I would like to check if the the variable log_v
in a.py
will be overwritten if we assign log_v
to another variable in b.py
python class variables
python class variables
edited Nov 15 at 7:02
tripleee
87.6k12122177
87.6k12122177
asked Nov 15 at 5:52
snookrun
255
255
2
assuming your indentation is correct the answer is no.
– Red Cricket
Nov 15 at 5:56
you are callingl.selfTestId
onl
but your method is not part of the classLOG
. Check your indentation or refresh OOP concepts
– Prakash Palnati
Nov 15 at 5:58
Naming a variable "l" is too ambiguous, try to name it properly and for your answer it is no.
– Vishnudev
Nov 15 at 6:05
Let's put it this way:l
inb.py
will be exactly whatl
is ina.py
.
– deceze♦
Nov 15 at 6:09
so the c = Clog() is contain within scripts a.py? and if I have a variable c in b.py, this is not related to the c in a.py>? I apologise for my bad OOP concepts. Also, the indentation is correct.
– snookrun
Nov 15 at 6:44
add a comment |
2
assuming your indentation is correct the answer is no.
– Red Cricket
Nov 15 at 5:56
you are callingl.selfTestId
onl
but your method is not part of the classLOG
. Check your indentation or refresh OOP concepts
– Prakash Palnati
Nov 15 at 5:58
Naming a variable "l" is too ambiguous, try to name it properly and for your answer it is no.
– Vishnudev
Nov 15 at 6:05
Let's put it this way:l
inb.py
will be exactly whatl
is ina.py
.
– deceze♦
Nov 15 at 6:09
so the c = Clog() is contain within scripts a.py? and if I have a variable c in b.py, this is not related to the c in a.py>? I apologise for my bad OOP concepts. Also, the indentation is correct.
– snookrun
Nov 15 at 6:44
2
2
assuming your indentation is correct the answer is no.
– Red Cricket
Nov 15 at 5:56
assuming your indentation is correct the answer is no.
– Red Cricket
Nov 15 at 5:56
you are calling
l.selfTestId
on l
but your method is not part of the class LOG
. Check your indentation or refresh OOP concepts– Prakash Palnati
Nov 15 at 5:58
you are calling
l.selfTestId
on l
but your method is not part of the class LOG
. Check your indentation or refresh OOP concepts– Prakash Palnati
Nov 15 at 5:58
Naming a variable "l" is too ambiguous, try to name it properly and for your answer it is no.
– Vishnudev
Nov 15 at 6:05
Naming a variable "l" is too ambiguous, try to name it properly and for your answer it is no.
– Vishnudev
Nov 15 at 6:05
Let's put it this way:
l
in b.py
will be exactly what l
is in a.py
.– deceze♦
Nov 15 at 6:09
Let's put it this way:
l
in b.py
will be exactly what l
is in a.py
.– deceze♦
Nov 15 at 6:09
so the c = Clog() is contain within scripts a.py? and if I have a variable c in b.py, this is not related to the c in a.py>? I apologise for my bad OOP concepts. Also, the indentation is correct.
– snookrun
Nov 15 at 6:44
so the c = Clog() is contain within scripts a.py? and if I have a variable c in b.py, this is not related to the c in a.py>? I apologise for my bad OOP concepts. Also, the indentation is correct.
– snookrun
Nov 15 at 6:44
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
I figured it out.
LOG()
class is initiated at importing of a.py
. It is assigned to the instance log_v
In b.py
, when I call the functions setTestId (testid, log_f , perf_log_f)
, it passes the arguments, testid, log_f , perf_log_f
to log_v
to a.py
and allow the initialization of the class with these variables.
Hence suppose I have a new functions logging()
in a.py
that uses log_v
, by simply importing a.py
and call the function logging()
, I am able to access the class LOG()
using the instance log_v
that is contained within a.py
and make any modification or updates to the class. This log_v
is also protected from the scripts in b.py
so it does not get overwritten if we also have another instance or variable name log_v
in b.py
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
I figured it out.
LOG()
class is initiated at importing of a.py
. It is assigned to the instance log_v
In b.py
, when I call the functions setTestId (testid, log_f , perf_log_f)
, it passes the arguments, testid, log_f , perf_log_f
to log_v
to a.py
and allow the initialization of the class with these variables.
Hence suppose I have a new functions logging()
in a.py
that uses log_v
, by simply importing a.py
and call the function logging()
, I am able to access the class LOG()
using the instance log_v
that is contained within a.py
and make any modification or updates to the class. This log_v
is also protected from the scripts in b.py
so it does not get overwritten if we also have another instance or variable name log_v
in b.py
add a comment |
up vote
0
down vote
accepted
I figured it out.
LOG()
class is initiated at importing of a.py
. It is assigned to the instance log_v
In b.py
, when I call the functions setTestId (testid, log_f , perf_log_f)
, it passes the arguments, testid, log_f , perf_log_f
to log_v
to a.py
and allow the initialization of the class with these variables.
Hence suppose I have a new functions logging()
in a.py
that uses log_v
, by simply importing a.py
and call the function logging()
, I am able to access the class LOG()
using the instance log_v
that is contained within a.py
and make any modification or updates to the class. This log_v
is also protected from the scripts in b.py
so it does not get overwritten if we also have another instance or variable name log_v
in b.py
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
I figured it out.
LOG()
class is initiated at importing of a.py
. It is assigned to the instance log_v
In b.py
, when I call the functions setTestId (testid, log_f , perf_log_f)
, it passes the arguments, testid, log_f , perf_log_f
to log_v
to a.py
and allow the initialization of the class with these variables.
Hence suppose I have a new functions logging()
in a.py
that uses log_v
, by simply importing a.py
and call the function logging()
, I am able to access the class LOG()
using the instance log_v
that is contained within a.py
and make any modification or updates to the class. This log_v
is also protected from the scripts in b.py
so it does not get overwritten if we also have another instance or variable name log_v
in b.py
I figured it out.
LOG()
class is initiated at importing of a.py
. It is assigned to the instance log_v
In b.py
, when I call the functions setTestId (testid, log_f , perf_log_f)
, it passes the arguments, testid, log_f , perf_log_f
to log_v
to a.py
and allow the initialization of the class with these variables.
Hence suppose I have a new functions logging()
in a.py
that uses log_v
, by simply importing a.py
and call the function logging()
, I am able to access the class LOG()
using the instance log_v
that is contained within a.py
and make any modification or updates to the class. This log_v
is also protected from the scripts in b.py
so it does not get overwritten if we also have another instance or variable name log_v
in b.py
answered Nov 19 at 0:27
snookrun
255
255
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53313227%2fvariable-assigned-at-the-end-of-a-module%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
assuming your indentation is correct the answer is no.
– Red Cricket
Nov 15 at 5:56
you are calling
l.selfTestId
onl
but your method is not part of the classLOG
. Check your indentation or refresh OOP concepts– Prakash Palnati
Nov 15 at 5:58
Naming a variable "l" is too ambiguous, try to name it properly and for your answer it is no.
– Vishnudev
Nov 15 at 6:05
Let's put it this way:
l
inb.py
will be exactly whatl
is ina.py
.– deceze♦
Nov 15 at 6:09
so the c = Clog() is contain within scripts a.py? and if I have a variable c in b.py, this is not related to the c in a.py>? I apologise for my bad OOP concepts. Also, the indentation is correct.
– snookrun
Nov 15 at 6:44