Can I initialize mangled names with metaclass in Python and is it safe? -


Can I start dirty names with Metcalaces and is it safe?

  class meta (type): def __new __ (metacles, names, chairs, clsdict): clsDict ['_% s__ counter'% name] = 0 Return super (meta, metaclaces). __ New __ (Metacles, Names, Chairs, CLSDict) Category A (object): __metaclass__ = Meta   

I did not get the explanation and clear explanation. I'm often using dirty names but rarely metalex and not sure that this is a valid code if valid '_% s __% s'% (className, attrName) - it works Is, but probably not compatible.

What you want to do is legal, more or less secure (it is safe because it To reach those attributes that are names which i.e. they intend to be private) This is not a good idea, however, from a design perspective.

The question is, why are you using the name in the first place? If the feature is to be used to access multiple classes (including class and its metacalls), then you should probably use an unusual feature name instead.

If you often find yourself needing to work in a similar manner, of an attribute, you are probably going over the dirty names to suggest that a name is "private" (or At least, a class of stable, not part of the public API) Use a single major underscores to suggest.

Only some classes usually require messy names, usually because you want their properties namespace to be kept "clean" for some reason. For example, to function as a proxy class, its attribute may be like a namespace, as if it was a duplicate of a target objcecte. Using disturbing names can help to prevent the instances of the proxy by hiding the properties of any target.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -