Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggest add_rand() creates attribute if it does not exist #60

Open
jonpovey opened this issue Nov 2, 2021 · 1 comment
Open

Suggest add_rand() creates attribute if it does not exist #60

jonpovey opened this issue Nov 2, 2021 · 1 comment
Labels
enhancement New feature or request question Further information is requested

Comments

@jonpovey
Copy link
Contributor

jonpovey commented Nov 2, 2021

I have been reading the documentation (and source) for Randomized and add_rand()
It seems like add_rand() could create an attribute if it is not found in the object, and perhaps initialise it to the first element in the domain list.
It seems like this would reduce boilerplate in common code where currently the examples require writing self.x = some_dummy_value before add_rand("x", ...)

@mciepluc mciepluc added question Further information is requested enhancement New feature or request labels Jan 15, 2022
@mciepluc
Copy link
Owner

Hi @jonpovey
Not sure if I like it - you do not need to randomize an object to use it. I agree it is an additional code needed, but also readability is better. I don't like being too pythonic by reducing amount of code, paying the clarity price.
I would agree to add this feature if there are more votes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants