News for hackers. Stuff that matters.
Re:Show HN: Array – A Better Python List by brian_herman on Sunday January 10, 2021 @09:37AM (#25714970)
Can you do the same thing with dicts and make it so d['non_existant_key'] does not create an exception?
Re:Show HN: Array – A Better Python List by basdftrewq on Sunday January 10, 2021 @09:40AM (#25714992)

    from collections import defaultdict

    d = defaultdict(int)

    d['non_existant_key']
Re:Show HN: Array – A Better Python List by st0le on Sunday January 10, 2021 @02:20PM (#25718504)
Not quite the same what OP asked for. This will create the key and assign value 0 to it.
Re:Show HN: Array – A Better Python List by lauriat on Sunday January 10, 2021 @09:42AM (#25715017)
You can already do that with

  d.get("non_existant_key", default)