title: Are object literals Pythonic?
body: <p>JavaScript has object literals, e.g.</p>
  
  <pre><code>var p = {
    name: "John Smith",
    age:  23
  }
  </code></pre>
  
  <p>and .NET has anonymous types, e.g.</p>
  
  <pre><code>var p = new { Name = "John Smith", Age = 23}; // C#
  </code></pre>
  
  <p>Something similar can be emulated in Python by (ab)using named arguments:</p>
  
  <pre><code>class literal(object):
      def __init__(self, **kwargs):
          for (k,v) in kwargs.iteritems():
              self.__setattr__(k, v)
      def __repr__(self):
          return 'literal(%s)' % ', '.join('%s = %r' % i for i in sorted(self.__dict__.iteritems()))
      def __str__(self):
          return repr(self)
  </code></pre>
  
  <p>Usage:</p>
  
  <pre><code>p = literal(name = "John Smith", age = 23)
  print p       # prints: literal(age = 23, name = 'John Smith')
  print p.name  # prints: John Smith
  </code></pre>
  
  <p>But is this kind of code considered to be Pythonic?</p>