News for hackers. Stuff that matters.
Re:Using attrs for everything in Python by stinos on Thursday August 25, 2016 @03:50PM (#12361941)
I can't find it at the moment but wasn't there another solution to this problem where you could just populate an object at will (like matlab's struct for instance)? IIRC it was dict-based and allowed something like

    foo = SomePythonWizardry()
    foo.x = 1
    foo.a.b = 2
    print( foo ) #yields e.g. foo.x = 1, foo.a.b = 2
Or am I just dreaming? It would be all the goodness and none of the weird syntax.
Re:Using attrs for everything in Python by desdiv on Thursday August 25, 2016 @04:03PM (#12362028)
You're probably thinking of jsobject¹:

    from jsobject import Object
    foo = Object()
    foo.x = 1
    foo.a = {}  # foo.a.b will fail without this line
    foo.a.b = 2
    print(foo)  # prints: {'a': {'b': 2}, 'x': 1}
¹ https://pypi.python.org/pypi/jsobject/
Re:Using attrs for everything in Python by asciihacker on Thursday August 25, 2016 @05:30PM (#12362669)
I think if you import mock you can create mock.Mock() instances that allow you to assign fields that way.