Skip to content
Open
Changes from all commits
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
26 changes: 13 additions & 13 deletions pyguide.md
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,9 @@ Exceptions must follow certain conditions:
example:


```python
Yes:
def connect_to_next_port(self, minimum):
```python
def connect_to_next_port(self, minimum):
"""Connects to the next available port.

Args:
Expand All @@ -329,20 +329,20 @@ Exceptions must follow certain conditions:
ConnectionError: If no available port is found.
"""
if minimum < 1024:
# Note that this raising of ValueError is not mentioned in the doc
# string's "Raises:" section because it is not appropriate to
# guarantee this specific behavioral reaction to API misuse.
raise ValueError('Minimum port must be at least 1024, not %d.' % (minimum,))
# Note that this raising of ValueError is not mentioned in the doc
# string's "Raises:" section because it is not appropriate to
# guarantee this specific behavioral reaction to API misuse.
raise ValueError('Minimum port must be at least 1024, not %d.' % (minimum,))
port = self._find_next_open_port(minimum)
if not port:
raise ConnectionError('Could not connect to service on %d or higher.' % (minimum,))
raise ConnectionError('Could not connect to service on %d or higher.' % (minimum,))
assert port >= minimum, 'Unexpected port %d when minimum was %d.' % (port, minimum)
return port
```

```python
No:
def connect_to_next_port(self, minimum):
```python
def connect_to_next_port(self, minimum):
"""Connects to the next available port.

Args:
Expand Down Expand Up @@ -388,9 +388,9 @@ Exceptions must follow certain conditions:

```python
try:
raise Error()
raise Error()
except Error as error:
pass
pass
```

<a id="s2.5-global-variables"></a>
Expand Down Expand Up @@ -668,10 +668,10 @@ Use generators as needed.
<a id="291-definition"></a>

<a id="generators-definition"></a>
#### 2.9 Definition
#### 2.9.1 Definition

A generator function returns an iterator that yields a value each time it
executes a yield statement. After it yields a value, the runtime state of the
executes a `yield` statement. After it yields a value, the runtime state of the
generator function is suspended until the next value is needed.

<a id="s2.9.2-pros"></a>
Expand Down