say i have a class which takes a attribute called bucket_name, on basis of this bucket i want to set an attribute bucket_path for class which is of kind bucket_path = "{bucket_name}_created".format(bucket_path='master-bucket')
I am trying to use metaclass for it which is like this:
class MyMeta(type):
def __new__(meta, klassname, bases, attrs):
# trying to get bucket_name here from attrs but attrs is {}
return type.__new__(meta, klassname, bases, attrs)
class M(object):
__metaclass__= MyMeta
def __init__(self, bucket_name):
self.bucket_name = bucket_name
but i am failing because attrs is empty when i do m = M('my_bucket_name'), how to go about it?