I\'m wondering if Python has anything like the C# anonymous classes feature. To clarify, here\'s a sample C# snippet:
var foo = new { x = 1, y = 2 };
var bar
Quoted from this page:
class Struct:
def __init__(self, **entries): self.__dict__.update(entries)
def __eq__(self, other): return self.__dict__ == other.__dict__
def __ne__(self, other): return self.__dict__ != other.__dict__
options = Struct(answer=42, linelen = 80, font='courier')
options.answer
>>> 42
options.answer = 'plastics'
vars(options)
>>> {'answer': 'plastics', 'font': 'courier', 'linelen': 80}