Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Code Reviews

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

Post History

75%
+4 −0
Code Reviews A class to access dicts using attribute syntax

I like the idea, but more as an exercise or a demonstration what can be done with Python. I also like that the code comes with a set of test cases which are written in a way that they nicely serve...

posted 2y ago by Dirk Herrmann‭

Answer
#1: Initial revision by user avatar Dirk Herrmann‭ · 2022-03-26T12:02:12Z (over 2 years ago)
I like the idea, but more as an exercise or a demonstration what can be done with Python.  I also like that the code comes with a set of test cases which are written in a way that they nicely serve as user documentation.  In fact, I could even imagine this example being used in a tutorial about the `__setattr__` etc. methods. 

However, unless there is a real use-case where such a feature is needed for some reason, I would rather not start using it only for the syntactic difference: For readers of code, such tricks increase the cognitive complexity.

Having one idiomatic way of doing something makes things easier in most cases (https://peps.python.org/pep-0020):
>There should be one -- and preferably only one -- obvious way to do it.