Skip to content

Commit 689ed42

Browse files
committed
better import for context
1 parent ec95331 commit 689ed42

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

ch05construction/02conventions.ipynb.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,23 @@
1313

1414
# %% [markdown]
1515
# ## Coding Conventions
16+
#
17+
# Let's import a few variables from context.py that will be used in the following lesson.
18+
19+
# %%
20+
from context import (
21+
sEntry,
22+
iOffset,
23+
entry,
24+
offset,
25+
anothervariable,
26+
variable,
27+
flag1,
28+
flag2,
29+
do_something,
30+
)
31+
32+
# %% [markdown]
1633
# ### One code, many layouts:
1734
#
1835
# Consider the following fragment of python:
@@ -135,8 +152,6 @@ def method_name(a_variable):
135152
#
136153

137154
# %%
138-
sEntry = "10.0"
139-
iOffset = 1
140155
fNumber = float(sEntry) + iOffset
141156

142157
# %% [markdown]
@@ -145,8 +160,6 @@ def method_name(a_variable):
145160
# People may find this useful in languages like Python where the type is intrisic in the variable.
146161

147162
# %%
148-
entry = "10.0"
149-
offset = 1
150163
number = float(entry) + offset
151164

152165
# %% [markdown]
@@ -167,13 +180,6 @@ def method_name(a_variable):
167180
# The following two snippets do the same, but the second is separated into more steps, making it more readable.
168181

169182
# %%
170-
anothervariable=1
171-
flag1 = True
172-
flag2 = False
173-
variable = 1
174-
anothervariable = 1
175-
def do_something(): pass
176-
177183
anothervariable += 1
178184
if ((variable == anothervariable) and flag1 or flag2): do_something()
179185

0 commit comments

Comments
 (0)