From 3cf8659c5b1e632dac3030bb3b7ce4853ab54bb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Sat, 16 Jun 2018 17:53:42 +0200 Subject: [PATCH] Double quotes around strings to single --- README.md | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index eb2cf19..3ea69d8 100644 --- a/README.md +++ b/README.md @@ -579,11 +579,11 @@ Exceptions ```python while True: try: - x = int(input("Please enter a number: ")) + x = int(input('Please enter a number: ')) except ValueError: - print("Oops! That was no valid number. Try again...") + print('Oops! That was no valid number. Try again...') else: - print("Thank you.") + print('Thank you.') break ``` @@ -623,13 +623,13 @@ from itertools import * ### Combinations ```python ->>> combinations("abc", 2) +>>> combinations('abc', 2) [('a', 'b'), ('a', 'c'), ('b', 'c')] ``` ### Permutations ```python ->>> permutations("abc", 2) +>>> permutations('abc', 2) [('a', 'b'), ('a', 'c'), ('b', 'a'), ('b', 'c'), ('c', 'a'), ('c', 'b')] ``` @@ -641,7 +641,7 @@ from itertools import * ### Compress ```python ->>> compress("abc", [True, 0, 23]) +>>> compress('abc', [True, 0, 23]) ['a', 'c'] ``` @@ -654,17 +654,17 @@ from itertools import * ### Cycle ```python ->>> a = cycle("abc") +>>> a = cycle('abc') >>> [next(a) for _ in range(10)] ['a', 'b', 'c', 'a', 'b', 'c', 'a', 'b', 'c', 'a'] ``` ### Groupby ```python ->>> a = [{"id": 1, "name": "bob"}, - {"id": 2, "name": "bob"}, - {"id": 3, "name": "peter"}] ->>> {k: list(v) for k, v in groupby(a, key=lambda x: x["name"])} +>>> a = [{'id': 1, 'name': 'bob'}, + {'id': 2, 'name': 'bob'}, + {'id': 3, 'name': 'peter'}] +>>> {k: list(v) for k, v in groupby(a, key=lambda x: x['name'])} {'bob': [{'id': 1, 'name': 'bob'}, {'id': 2, 'name': 'bob'}], 'peter': [{'id': 3, 'name': 'peter'}]} @@ -860,7 +860,7 @@ def main(): def draw(screen): screen.clear() - screen.addstr(0, 0, "Press ESC to quit.") + screen.addstr(0, 0, 'Press ESC to quit.') while screen.getch() != 27: pass @@ -905,7 +905,8 @@ with pycallgraph.PyCallGraph(output=graph): #### Utility code for unique PNG filenames: ```python def get_filename(): - return "{}-{}.png".format("profile", get_current_datetime_string()) + time_str = get_current_datetime_string() + return f'profile-{time_str}.png' def get_current_datetime_string(): now = datetime.datetime.now() @@ -920,7 +921,7 @@ Audio #### Saves list of floats of size 0 to 1 to a WAV file: ```python import wave, struct -frames = [struct.pack("%dh"%(1), int((a-0.5)*60000)) for a in ] +frames = [struct.pack('%dh'%(1), int((a-0.5)*60000)) for a in ] wf = wave.open(filename, 'wb') wf.setnchannels(1) wf.setsampwidth(4)