Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@jnothman
Copy link
Member

Fixes #8370

@GaelVaroquaux is likely to reject this outright, due to the free use of magic. However, it likely works more smoothly than any other conceivable implementation.

And we have at least agreed that freezing (in some manner) should be possible.

@GaelVaroquaux
Copy link
Member

Yes, it's the kind of stuff that I had in mind when I said that generating classes was possible but I didn't like it.

I don't like it because I think that it surprises people and my experience is that it leads to bugs and misunderstanding of the library. That said, it's a nice realization of the idea, @jnothman. You're definitely a Python wizard with great powers in magic.

@jnothman
Copy link
Member Author

Sigh. That's why I ask for the ability to overload clone, so that I can play with fire at home :)

@GaelVaroquaux
Copy link
Member

GaelVaroquaux commented Feb 16, 2017 via email

@jnothman
Copy link
Member Author

jnothman commented Feb 16, 2017 via email

@jnothman
Copy link
Member Author

But if we give up on inheritance, we can use a little less magic, no?

Also, giving up on inheritance still requires __setattr__ and __getattr__ games, and since the frozen model is then a wrapper rather than the same object, I suspect there is much more room for surprise, bugs, misunderstanding.

In this case, at least, __dict__ and dir work as expected (and hence tab completion, etc, etc.).

I think I have a simpler solution I can try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants