Skip to content

Commit 906feb7

Browse files
committed
Fixed conditional.py script
Also: - Made self.locals_in_py = True for main.py and examples/python_scripting.py - This makes debugging easier in the embedded IPython shell provided by the opt-in ipy command
1 parent 5be70a0 commit 906feb7

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

examples/python_scripting.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ def __init__(self):
2828
super().__init__(use_ipython=True)
2929
self._set_prompt()
3030
self.intro = 'Happy 𝛑 Day. Note the full Unicode support: 😇 (Python 3 only) 💩'
31+
self.locals_in_py = True
3132

3233
def _set_prompt(self):
3334
"""Set prompt so it displays the current working directory."""

examples/scripts/conditional.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@
2424
original_dir = os.getcwd()
2525

2626
# Try to change to the specified directory
27-
cmd('cd {}'.format(directory))
27+
app('cd {}'.format(directory))
2828

2929
# Conditionally do something based on the results of the last command
3030
if self._last_result:
3131
print('\nContents of directory {!r}:'.format(directory))
32-
cmd('dir -l')
32+
app('dir -l')
3333

3434
# Change back to where we were
3535
print('Changing back to original directory: {!r}'.format(original_dir))
36-
cmd('cd {}'.format(original_dir))
36+
app('cd {}'.format(original_dir))
3737
else:
3838
# cd command failed, print a warning
3939
print('Failed to change directory to {!r}'.format(directory))

main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88
# Set "use_ipython" to True to include the ipy command if IPython is installed, which supports advanced interactive
99
# debugging of your application via introspection on self.
1010
app = cmd2.Cmd(use_ipython=True)
11+
app.locals_in_py = True
1112
app.cmdloop()

0 commit comments

Comments
 (0)