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

Added Item __str__ #9

Merged
merged 4 commits into from
Sep 25, 2023
Merged

Added Item __str__ #9

merged 4 commits into from
Sep 25, 2023

Conversation

antoninoLorenzo
Copy link
Contributor

I added the __str__ function to item.py because I had some difficulty reading the output of the api requests so I tought it was a good idea adding a better string formatting.

I didn't added new tests because this hasn't nothing to do with functionality so I just tried to print the output and run the main.py script in the test folder. Still if it needs a standalone test I can add one without problems.

@wchistow
Copy link
Owner

This method (__str__) can be like this:

def __str__(self) -> str:
    out = [f'{k}: {v}' for k, v in self.data.items()]
    return '\n'.join(out)

but your variant is good too.

@wchistow wchistow merged commit d580750 into wchistow:master Sep 25, 2023
6 checks passed
@wchistow wchistow added the enhancement New feature or request label Sep 25, 2023
@antoninoLorenzo
Copy link
Contributor Author

Didn't tought about doing it that way, however there shouldn't be performance/memory drawbacks.

Still, thank you for your time.

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

Successfully merging this pull request may close these issues.

2 participants