I have a Python class that contains all the AWS regions. I wrote a class method that would return me the list of all the regions. Is there a better way of returning all the class variable values so I don't have to hard-code all the values in the return statement like I am doing in the example below?
class AwsRegion():
'''
Class to define AWS Regions
'''
OHIO = 'us-east-2'
NORTH_VIRGINIA = 'us-east-1'
NORTH_CALIFORNIA = 'us-west-1'
OREGON = 'us-west-2'
MUMBAI = 'ap-south-1'
SEOUL = 'ap-northeast-2'
SINGAPORE = 'ap-southeast-1'
SYDNEY = 'ap-southeast-2'
TOKYO = 'ap-northeast-1'
FRANKFURT = 'eu-central-1'
IRELAND = 'eu-west-1'
LONDON = 'eu-west-2'
SAO_PAULO = 'sa-east-1'
@classmethod
def all(cls, ):
return [AwsRegion.OHIO, AwsRegion.NORTH_VIRGINIA, AwsRegion.NORTH_CALIFORNIA, AwsRegion.OREGON, \
AwsRegion.MUMBAI, AwsRegion.SEOUL, AwsRegion.SINGAPORE, AwsRegion.SYDNEY, AwsRegion.TOKYO, \
AwsRegion.FRANKFURT, AwsRegion.IRELAND, AwsRegion.LONDON, AwsRegion.SAO_PAULO]
all
is a class attribute too. Do you mean anything that isn't a callable or otherwise a descriptor? – Engvall