All Questions
4 questions
2
votes
2
answers
4k
views
Module with globals or Class with attributes?
Currently I'm working with a lot of modules where the original developers used global variables to control states and to exchange important information between functions, like so:
STATE_VAR = 0
def ...
2
votes
1
answer
118
views
Is it a good software engineering practice to store libraries as attributes of objects?
Suppose I initialize a library, say, in python object -
#filename: file_A
import file_
class A():
def __init__(self):
self.pd = file_.pd
self.np = file_.np
And suppose the ...
13
votes
3
answers
27k
views
Is it a better practice pre-initialize attributes in a class, or to add them along the way?
I'm sorry if this is a ABSOLUTELY sophomoric question, but I'm curious what the best practices are out there, and I can't seem to find a good answer on Google.
In Python, I usually use an empty class ...
0
votes
1
answer
847
views
Should I put the parameters in constructor or in method? (Python 3)
I have the following code:
def __init__(self, vocable_file_path, xsd_file_path, word_list_file_path):
self.vocable_file_path = vocable_file_path
self.xsd_file_path = xsd_file_path
self....