News for hackers. Stuff that matters.
Re:Why is OOP still so widely spread? by dheera on Thursday September 03, 2020 @12:36PM (#24365791)
Checks in Python are pretty concise. If you just want to have a default value if the key my_value doesn't exist, this is all you need:

    value_I_want = some_dict.get('my_value', default_value)
If you want a more strict check including type checking:

    value_I_want = some_dict.get('my_value')
    if type(value_I_want) is not str:
        do_something()
In Java the real problem is nested JSON objects -- it's a real PITA to read those. You can't do something like this (Python):

    value = some_dict.get("foo", {}).get("bar", {}).get("blah", default_value)
Re:Why is OOP still so widely spread? by teekert on Friday September 04, 2020 @02:23AM (#24372246)
I believe one can even do:

    value_I_want = some_dict.get('my_value':str)
and

    value = some_dict["foo"]["bar"]["blah"]