Skip to content

Replace % with f-strings in multiple files mentioned in issue #19 #41

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

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add repr() in f-strings magicmethods.md
  • Loading branch information
tusharkhatriofficial committed Sep 22, 2022
commit 486a27eb1f08379dac698a01aa1e65b45c16ed04
6 changes: 3 additions & 3 deletions advanced/magicmethods.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ formatting](../basics/handy-stuff-strings.md#string-formatting) is also
easy.

```python
>>> print(f"the message is {message}")
>>> print(f"the message is {repr(message)}")
the message is 'hello'
>>>
```
Expand Down Expand Up @@ -152,7 +152,7 @@ follow one of these styles:
... self.name = name
... self.founding_year = founding_year
... def __repr__(self):
... return f'Website(name={self.name}, founding_year={self.founding_year})'
... return f'Website(name={repr(self.name)}, founding_year={repr(self.founding_year)})'
...
>>> github = Website('GitHub', 2008)
>>> github
Expand All @@ -170,7 +170,7 @@ follow one of these styles:
... self.name = name
... self.founding_year = founding_year
... def __repr__(self):
... return f'<Website {self.name}, founded in {self.founding_year}>'
... return f'<Website {repr(self.name)}, founded in {repr(self.founding_year)}>'
...
>>> github = Website('GitHub', 2008)
>>> github
Expand Down
3 changes: 1 addition & 2 deletions basics/answers.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ isn't exactly like mine but it works just fine it's ok, and you can
just fine if we run it, but there's a problem. The last line is
really long and it's hard to see what it does.

The solution is string formatting. At the time of writing this, I
recommend replacing the last line with this:
The solution is string formatting. I recommend replacing the last line with this:

```python
print(f"You entered {word1}, {word2}, {word3} and {word4}.")
Expand Down