issue #2243 -- prefer f-strings over %-interpolation

edited docs to prefer f-strings, then str.format(), and remove %-interpolation

additional ad-hoc documentation fixes, as opportunities seen:
- replace Built-In Function (BIF) "min" variable with "mins"
- prefer BIF str(var) over "%s" % var
- reformat some code examples to clarify multiple args passed to functions
- change some single-quote strings to double-quotes for consistency
- fix mismatched parens

misc edits:
- add .vscode/ to gitignore
This commit is contained in:
Dimitri 2021-10-12 12:13:42 -06:00
parent f45051050e
commit 851ca30be5
30 changed files with 207 additions and 193 deletions

View file

@ -59,10 +59,8 @@ Here is a simple example of the prompt sent/updated from a command class:
self.caller.msg("Not a valid target!")
return
text = "You diagnose %s as having " \
"%i health, %i mana and %i stamina." \
% (hp, mp, sp)
prompt = "%i HP, %i MP, %i SP" % (hp, mp, sp)
text = f"You diagnose {target} as having {hp} health, {mp} mana and {sp} stamina."
prompt = f"{hp} HP, {mp} MP, {sp} SP"
self.caller.msg(text, prompt=prompt)
```
## A prompt sent with every command
@ -86,9 +84,7 @@ class MuxCommand(default_cmds.MuxCommand):
def at_post_cmd(self):
"called after self.func()."
caller = self.caller
prompt = "%i HP, %i MP, %i SP" % (caller.db.hp,
caller.db.mp,
caller.db.sp)
prompt = f"{caller.db.hp} HP, {caller.db.mp} MP, {caller.db.sp} SP"
caller.msg(prompt=prompt)
```