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

Proposal - store generated object field value to generate depended fields #107

Closed
yn-coder opened this issue Jan 16, 2017 · 20 comments
Closed
Labels
enhancement Enhancement proposals

Comments

@yn-coder
Copy link
Contributor

yn-coder commented Jan 16, 2017

This is a proposal.

Right now I type

from elizabeth import Personal
p = Personal('en')
print( p.age() )
print( p.age() )

And got output

25
40

Because age is generated by request and doesn't store in object p. What if I want to add the field child_count or work experience, depend on previously generated age value?

@lk-geimfari
Copy link
Owner

lk-geimfari commented Jan 16, 2017

from elizabeth import Personal
p = Personal('en')

saved_age = p.age(18, 25)
do_something(saved_age)

@yn-coder
Copy link
Contributor Author

:)
I mean store in object.

@lk-geimfari
Copy link
Owner

I understand and i think that it's not good idea. We have to many methods in all providers.

@yn-coder
Copy link
Contributor Author

yn-coder commented Jan 16, 2017

SO lib should be used for generate for unrelated, noise data.
If so, then proposal is not usefull

@lk-geimfari
Copy link
Owner

@yn-coder You don't understand. Depended data is very cool, but i think that saving data in object is not good idea. We need something else.

@yn-coder
Copy link
Contributor Author

Some cash?

@lk-geimfari
Copy link
Owner

@yn-coder Not yet.

@yn-coder
Copy link
Contributor Author

@lk-geimfari

...but i think that saving data in object is not good idea.

Why? Can you explain?

@lk-geimfari
Copy link
Owner

@yn-coder Maybe I do not understand what you want.

You can try add your feature in your fork. If everything is okay we also add it to Elizabeth.

Maybe like that:

from elizabeth import Personal

p = Personal(locale='en', dependent=True)

Give us example of how it will work.

@lk-geimfari lk-geimfari added the waits-feedback Waits feedback label Jan 18, 2017
@yn-coder
Copy link
Contributor Author

I read your examples of Elizabeth usage, and now I think I understood.

Person object doesn't contain the generated data because you design it just as wrapper for generator funcion. Person.age() yeld the new value each time and tester could use it in a loop, without creating the object instance for next person.

Now I see the root of our miscommunication.

I'll prepare a some example for my proposal in a fork.

@lk-geimfari
Copy link
Owner

Exactly!

@yn-coder
Copy link
Contributor Author

This is a simple illustration for my idea in my fork

yn-coder@4fa723c

Code is not production ready, just a demo.

@lk-geimfari
Copy link
Owner

lk-geimfari commented Jan 18, 2017

@yn-coder Generally it looks good.

But i think that this

    def __init__(self, locale='en'):
        """
        :param locale: Current language.
        """
        self.locale = locale
        self.data = pull('personal.json', self.locale)
        self.stored_age = 0

Should be:

    def __init__(self, locale='en'):
        """
        :param locale: Current language.
        """
        self.locale = locale
        self.data = pull('personal.json', self.locale)
        self._store = {'age': 0}

What do you think about it?

@lk-geimfari
Copy link
Owner

lk-geimfari commented Jan 18, 2017

Now i see that it's can be really useful.

@yn-coder
Copy link
Contributor Author

@lk-geimfari

What do you think about it?

You think self._store could be expanded for more parameters?

@lk-geimfari
Copy link
Owner

lk-geimfari commented Jan 18, 2017

@yn-coder Yes, we can store in self._store other dependent data if we'll need.

@lk-geimfari lk-geimfari added enhancement Enhancement proposals and removed waits-feedback Waits feedback labels Jan 18, 2017
@yn-coder
Copy link
Contributor Author

yn-coder@d352188

@lk-geimfari
Copy link
Owner

lk-geimfari commented Jan 18, 2017

@yn-coder Great! Please, check it with pycodestyle (or with similar tool) and send us PR.

@lk-geimfari
Copy link
Owner

Also don't forget about tests.

@yn-coder
Copy link
Contributor Author

#109

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement proposals
Projects
None yet
Development

No branches or pull requests

2 participants