Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

7
  • 2
    sounds like dictionaries should do the job. I find it's best to find the python way to do it than fit another language in to python. BTW -- if you don't like the dictionary, foo["bar"] access method an alternative is to use the get method: foo.get("bar") Commented Jul 14, 2009 at 1:36
  • 1
    Given that this is trivially implementable in Python if needed, I don't see any particular reason not to do so, and definitely don't consider it "fitting another language in to Python". Especially as it seems pretty close to the existing namedtuple in intent. Commented Jul 14, 2009 at 1:41
  • 2
    I find it bizarre to ask a question if language X has the feature of language Y, and then require everything to be exactly the same. Languages are not exactly the same. Python does not have anonymous functions, but they have dictionaries, and they work just as well. Yes, the access syntax is different. Big friggin deal. Commented Jul 14, 2009 at 7:30
  • 4
    I'm not asking for feature to be exactly the same - if I did, I'd be asking for static typing and immutability as well ;) I'm merely asking for syntax which I view as more natural and convenient. Commented Jul 14, 2009 at 8:01
  • 1
    You don't need those backslashes. In Python, a line hasn't ended until the brackets have all closed. Commented Apr 8, 2017 at 18:14