Giter Site home page Giter Site logo

Comments (5)

Loreton avatar Loreton commented on June 6, 2024 1

It's ok.
keyattr_dynamic=False should rise AttributeError also reading a not existing attribute.
Thank you Fabio

from python-benedict.

Loreton avatar Loreton commented on June 6, 2024 1

Ciao Fabio,
I believe that the default must be exactly like for the normal dictionary: False
So that accessing an undefined attribute gives an error. There should be no difference in results between the two access modes to the attribute value.
But this is just my thought.

from python-benedict.

fabiocaccamo avatar fabiocaccamo commented on June 6, 2024 1

@Loreton the keyattr_dynamic property is available in 0.30.0 version.

from python-benedict.

fabiocaccamo avatar fabiocaccamo commented on June 6, 2024

@Loreton I'm glad you enjoy this library and thank you for the useful feedback!

Example.1

The behaviour your reported is a direct consequence of having the possibility to create nested dicts using the chained dotted notation a.b.c.d.e.f without having an AttributeError.

Example.2

Attributes starting with _ are generally protected variables or dunder methods.
Some standard libraries use/check the presence of some protected variables and methods; the side effect is that some keys are created dynamically and the resulting dictionary contains unexpected keys (for a better understanding you could check #259).

I agree with the idea of adding a new option keyattr_dynamic=True: setting it to False would restrict the feature to write only already existing items otherwise an AttributeError is raised.

from python-benedict.

fabiocaccamo avatar fabiocaccamo commented on June 6, 2024

@Loreton what do you think should be the best default value for the keyattr_dynamic property, True of False?

from python-benedict.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.