Meta classes - real example

Mr. Wrobel mr at e-wrobel.pl
Mon Oct 17 12:03:33 EDT 2016


Hi,

I am looking for an example of metaclass usage. Especially I am 
interestet in manipulating instance variables, for example:

My class:
class MrMeta(type):
	pass

class Mr(object):
	__metaclass__ = MrMeta
	
	def __init__(self):
		self.imvariable = 'Zmienna self'

	def aome method(self):
		print 'I am in instance'

So in general, I would like to create a mechanism, that is changing 
value for self.imvariable to capital letters and this should be included 
in my metaclass called MrMeta(type).

Can you guide me please?

Thanks!
Mr. Wrobel



More information about the Python-list mailing list