I have the following class:
import Radar
class Domain(Radar):
URL = 'https://mxtoolbox.com/DNSLookup.aspx'
ADDRESS_KEYS = ('mailing_address', 'city_name', 'state_name', 'zip_code',
'country_name')
GENERAL_PARAMS = {'format': 'json'}
BALANCE_PARAMS = {**Radar.GENERAL_PARAMS, 'account': 'balance'}
SUCCESSFUL_QUERY = 1
API_KEY_ERROR_REASON = 'Invalid API Key'
MASKED_ENTITY_INDICATOR = 'To View Unmasked Data'
def __init__(self, *args, **kwargs):
self.entity_title = 'Crawling'
super().__init__(*args, **kwargs)
The class' methods (only them) access each of these constant static members few times.
What are the advantages/disadvantages of putting these variables in the outer scope (as a file level variables - and not class level static variables)?
Even though I know both approaches would work, I wonder where is the best place put the variables - inside the class or above it.
The other option:
import Radar
URL = 'https://mxtoolbox.com/DNSLookup.aspx'
ADDRESS_KEYS = ('mailing_address', 'city_name', 'state_name', 'zip_code',
'country_name')
GENERAL_PARAMS = {'format': 'json'}
BALANCE_PARAMS = {**Radar.GENERAL_PARAMS, 'account': 'balance'}
SUCCESSFUL_QUERY = 1
API_KEY_ERROR_REASON = 'Invalid API Key'
MASKED_ENTITY_INDICATOR = 'To View Unmasked Data'
class Domain(Radar):
def __init__(self, *args, **kwargs):
self.entity_title = 'Crawling'
super().__init__(*args, **kwargs)