Eike Welk wrote:
My secret agenda was however, to later introduce a new class and object syntax for Python. I just didn't dare to propose a completely revised Python. But here we go: :-)
Class Creation --------------
Foo = class {| a, b |}
This should be equivalent to:
class Foo(object): def __init__(self, a, b): self.a = a self.b = b
Really? So Foobar = class {| 17, 'yellow' |} means class Foobar() def __init__(self, 17, 'yellow'): self.17 = 17 self.'yellow' = 'yellow' Looks like I'm either stuck with always using a, b, c, etc for attribute names, or I get compile errors. This is *definitely* not Pythonic -- offers nothing for readability, requires new strange symbols... yuck. If you want a one-liner, make a function: def Class(*args, **kwargs): obj = type('Simple', (object, ), dict()) for i, arg in enumerate(args): attr = chr(ord('a') + i) setattr(obj, attr, arg) for kw in kwargs: setattr(obj, kw, kwargs[kw]) return obj then Foobar = Class( 17, 'yellow', this='that' ) and season to taste. ~Ethan~