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

Wrong example in README #9

Closed
vpoulailleau opened this issue Nov 12, 2020 · 1 comment
Closed

Wrong example in README #9

vpoulailleau opened this issue Nov 12, 2020 · 1 comment

Comments

@vpoulailleau
Copy link
Contributor

The README says:

from linqit import List


programmers = List()
Avi = type('Avi', (), {})

# Go ahead and fill the list with whatever you want... like a list of <Programmer> objects.

# Then play:
last_hot_pizza_slice = programmers.where(lambda e:e.experience > 15)
                      .except_for(elon_musk)
                      .of_type(Avi)
                      .take(3) # [<Avi>, <Avi>, <Avi>]
                      .select(lambda avi:avi.lunch) # [<Pizza>, <Pizza>, <Pizza>]
                      .where(lambda p:p.is_hot() and p.origin != 'Pizza Hut').
                      .last() # <Pizza>
                      .slices.last() # <PizzaSlice>
                      
# What do you think?

I think there's a syntax error… .except_for(elon_musk) is not part of the last_hot_pizza_slice = … statement. You may add parenthesis around the whole statement.

I also think that there is an extra dot after p.origin != 'Pizza Hut')

You may also use black to format the code. This would finally give:

from seven_dwwarfs import Grumpy, Happy, Sleepy, Bashful, Sneezy, Dopey, Doc
from linqit import List


programmers = List()
Avi = type("Avi", (), {})

# Go ahead and fill the list with whatever you want... like a list of <Programmer> objects.

# Then play:
last_hot_pizza_slice = (
    programmers.where(lambda e: e.experience > 15)
    .except_for(elon_musk)
    .of_type(Avi)
    .take(3)  # [<Avi>, <Avi>, <Avi>]
    .select(lambda avi: avi.lunch)  # [<Pizza>, <Pizza>, <Pizza>]
    .where(lambda p: p.is_hot() and p.origin != "Pizza Hut")
    .last()  # <Pizza>
    .slices.last()  # <PizzaSlice>
)

# What do you think?

BTW, your project seems fun to try, thanks for what you've done.

@avilum
Copy link
Owner

avilum commented Nov 12, 2020

Thanks a lot for your feedback,
I haven't use any linter for the README code, that's a great idea.
I have corrected the README with your suggestions. 💯

@avilum avilum closed this as completed Nov 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants