Re: IPython-dev Digest, Vol 174, Issue 2
Andreas Yankopolus <[email protected]> Sat, 12 Jan 2019 20:56:54 -0500
| Newsgroups | gmane.comp.python.ipython.devel |
|---|---|
| Message-ID | <[email protected]> |
--===============2774398033176162302==
Content-Type: multipart/alternative;
boundary="Apple-Mail=_427E2848-BF62-48E2-A7FD-68DCD6AD068A"
--Apple-Mail=_427E2848-BF62-48E2-A7FD-68DCD6AD068A
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
charset=utf-8
Wes,
> =
https://stackoverflow.com/questions/48112226/update-a-function-during-debu=
gging-pdb-or-ipdb
> - Does this work from just a plain ipdb shell (when not sending the =
new function definition from emacs)?
This is getting close, but updating the function as proposed doesn=E2=80=99=
t work. Using the example code from my previous post:
ayank@snorri:~/Documents$ ./foo.py=20
In main.
> /home/ayank/Documents/foo.py(16)main()
14 print ("In main.")
15 Pdb().set_trace()
---> 16 name()
17=20
18 if __name__ =3D=3D "__main__":
ipdb> print_name()
Alice
ipdb> name()
Alice
ipdb> !def print_name(): print ("Bob")
ipdb> print_name()
Bob
ipdb> name()
Alice
We can see that the function is updated, but functions that call it do =
not get updated to use the new definition. Any idea what=E2=80=99s going =
on here?
This kind of thing is no problem in Lisp, but its macro facility means =
that support for changing code at runtime is baked deep into the =
language. Perhaps there=E2=80=99s something missed in the IPython REPL?
Thanks,
Andreas
--Apple-Mail=_427E2848-BF62-48E2-A7FD-68DCD6AD068A
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
charset=utf-8
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html; =
charset=3Dutf-8"></head><body style=3D"word-wrap: break-word; =
-webkit-nbsp-mode: space; line-break: after-white-space;" =
class=3D""><div>Wes,</div><div><br class=3D""><blockquote type=3D"cite" =
class=3D""><div class=3D""><div class=3D""><a =
href=3D"https://stackoverflow.com/questions/48112226/update-a-function-dur=
ing-debugging-pdb-or-ipdb" =
class=3D"">https://stackoverflow.com/questions/48112226/update-a-function-=
during-debugging-pdb-or-ipdb</a><br class=3D"">- Does this work from =
just a plain ipdb shell (when not sending the new function =
definition from emacs)?<br class=3D""></div></div></blockquote><div><br =
class=3D""></div><div>This is getting close, but updating the function =
as proposed doesn=E2=80=99t work. Using the example code from my =
previous post:</div><div><br class=3D""></div></div><div style=3D"margin: =
0px; font-stretch: normal; font-size: 11px; line-height: normal; =
font-family: Menlo; color: rgb(47, 180, 29);" class=3D""><span =
style=3D"font-variant-ligatures: no-common-ligatures" class=3D""><b =
class=3D"">ayank@snorri</b></span><span style=3D"font-variant-ligatures: =
no-common-ligatures; color: #000000" class=3D"">:</span><span =
style=3D"font-variant-ligatures: no-common-ligatures; color: #400bd9" =
class=3D""><b class=3D"">~/Documents</b></span><span =
style=3D"font-variant-ligatures: no-common-ligatures; color: #000000" =
class=3D"">$ ./foo.py </span></div><div style=3D"margin: 0px; =
font-stretch: normal; font-size: 11px; line-height: normal; font-family: =
Menlo;" class=3D""><span style=3D"font-variant-ligatures: =
no-common-ligatures" class=3D"">In main.</span></div><div style=3D"margin:=
0px; font-stretch: normal; font-size: 11px; line-height: normal; =
font-family: Menlo; color: rgb(47, 180, 29);" class=3D""><span =
style=3D"font-variant-ligatures: no-common-ligatures; color: #000000" =
class=3D"">> </span><span style=3D"font-variant-ligatures: =
no-common-ligatures" class=3D"">/home/ayank/Documents/foo.py</span><span =
style=3D"font-variant-ligatures: no-common-ligatures; color: #000000" =
class=3D"">(16)</span><span style=3D"font-variant-ligatures: =
no-common-ligatures; color: #2eaebb" class=3D"">main</span><span =
style=3D"font-variant-ligatures: no-common-ligatures; color: #400bd9" =
class=3D"">()</span></div><div style=3D"margin: 0px; font-stretch: =
normal; font-size: 11px; line-height: normal; font-family: Menlo; color: =
rgb(64, 11, 217);" class=3D""><span style=3D"font-variant-ligatures: =
no-common-ligatures; color: #2fb41d" class=3D""> 14 =
</span><span style=3D"font-variant-ligatures: no-common-ligatures; =
color: #b42419" class=3D""> </span><span =
style=3D"font-variant-ligatures: no-common-ligatures; color: #000000" =
class=3D"">print </span><span style=3D"font-variant-ligatures: =
no-common-ligatures" class=3D"">("In main.")</span></div><div =
style=3D"margin: 0px; font-stretch: normal; font-size: 11px; =
line-height: normal; font-family: Menlo;" class=3D""><span =
style=3D"font-variant-ligatures: no-common-ligatures; color: #2fb41d" =
class=3D""> 15 </span><span =
style=3D"font-variant-ligatures: no-common-ligatures; color: #b42419" =
class=3D""> </span><span style=3D"font-variant-ligatures: =
no-common-ligatures" class=3D"">Pdb</span><span =
style=3D"font-variant-ligatures: no-common-ligatures; color: #400bd9" =
class=3D"">().</span><span style=3D"font-variant-ligatures: =
no-common-ligatures" class=3D"">set_trace</span><span =
style=3D"font-variant-ligatures: no-common-ligatures; color: #400bd9" =
class=3D"">()</span></div><div style=3D"margin: 0px; font-stretch: =
normal; font-size: 11px; line-height: normal; font-family: Menlo; color: =
rgb(47, 180, 29);" class=3D""><span style=3D"font-variant-ligatures: =
no-common-ligatures" class=3D"">---> 16 </span><span =
style=3D"font-variant-ligatures: no-common-ligatures; color: #b42419" =
class=3D""> </span><span style=3D"font-variant-ligatures: =
no-common-ligatures; color: #000000" class=3D"">name</span><span =
style=3D"font-variant-ligatures: no-common-ligatures; color: #400bd9" =
class=3D"">()</span></div><div style=3D"margin: 0px; font-stretch: =
normal; font-size: 11px; line-height: normal; font-family: Menlo; color: =
rgb(47, 180, 29);" class=3D""><span style=3D"font-variant-ligatures: =
no-common-ligatures" class=3D""> =
17 </span></div><div style=3D"margin: 0px; font-stretch: normal; =
font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(64, =
11, 217);" class=3D""><span style=3D"font-variant-ligatures: =
no-common-ligatures; color: #2fb41d" class=3D""> 18 =
if</span><span style=3D"font-variant-ligatures: no-common-ligatures; =
color: #000000" class=3D""> __name__ </span><span =
style=3D"font-variant-ligatures: no-common-ligatures" =
class=3D"">=3D=3D</span><span style=3D"font-variant-ligatures: =
no-common-ligatures; color: #000000" class=3D""> </span><span =
style=3D"font-variant-ligatures: no-common-ligatures" =
class=3D"">"__main__":</span></div><div style=3D"margin: 0px; =
font-stretch: normal; font-size: 11px; line-height: normal; font-family: =
Menlo; min-height: 13px;" class=3D""><span =
style=3D"font-variant-ligatures: no-common-ligatures" =
class=3D""></span><br class=3D""></div><div style=3D"margin: 0px; =
font-stretch: normal; font-size: 11px; line-height: normal; font-family: =
Menlo;" class=3D"">ipdb> print_name()</div><div style=3D"margin: 0px; =
font-stretch: normal; font-size: 11px; line-height: normal; font-family: =
Menlo;" class=3D""><span style=3D"font-variant-ligatures: =
no-common-ligatures" class=3D"">Alice</span></div><div style=3D"margin: =
0px; font-stretch: normal; font-size: 11px; line-height: normal; =
font-family: Menlo;" class=3D""><span style=3D"font-variant-ligatures: =
no-common-ligatures;" class=3D"">ipdb> name()</span></div><div =
style=3D"margin: 0px; font-stretch: normal; font-size: 11px; =
line-height: normal; font-family: Menlo;" class=3D""><span =
style=3D"font-variant-ligatures: no-common-ligatures;" =
class=3D"">Alice</span></div><div style=3D"margin: 0px; font-stretch: =
normal; font-size: 11px; line-height: normal; font-family: Menlo;" =
class=3D""><span style=3D"font-variant-ligatures: no-common-ligatures" =
class=3D"">ipdb> !def print_name(): print ("Bob")</span></div><div =
style=3D"margin: 0px; font-stretch: normal; font-size: 11px; =
line-height: normal; font-family: Menlo;" class=3D"">ipdb> =
print_name()</div><div style=3D"margin: 0px; font-stretch: normal; =
font-size: 11px; line-height: normal; font-family: Menlo;" =
class=3D""><span style=3D"font-variant-ligatures: no-common-ligatures" =
class=3D"">Bob</span></div><div style=3D"margin: 0px; font-stretch: =
normal; font-size: 11px; line-height: normal; font-family: Menlo;" =
class=3D""><span style=3D"font-variant-ligatures: no-common-ligatures;" =
class=3D"">ipdb> name()</span></div><div style=3D"margin: 0px; =
font-stretch: normal; font-size: 11px; line-height: normal; font-family: =
Menlo;" class=3D""><span style=3D"font-variant-ligatures: =
no-common-ligatures;" class=3D"">Alice</span></div><div style=3D"margin: =
0px; font-stretch: normal; font-size: 11px; line-height: normal; =
font-family: Menlo;" class=3D""><br class=3D""></div><div style=3D"margin:=
0px; font-stretch: normal; font-size: 11px; line-height: normal; =
font-family: Menlo;" class=3D""><div style=3D"font-family: Helvetica; =
font-size: 12px;">We can see that the function is updated, but functions =
that call it do not get updated to use the new definition. Any idea =
what=E2=80=99s going on here?</div><div style=3D"font-family: Helvetica; =
font-size: 12px;"><br class=3D""></div><div style=3D"font-family: =
Helvetica; font-size: 12px;">This kind of thing is no problem in Lisp, =
but its macro facility means that support for changing code at runtime =
is baked deep into the language. Perhaps there=E2=80=99s something =
missed in the IPython REPL?</div><div style=3D"font-family: Helvetica; =
font-size: 12px;"><br class=3D""></div><div style=3D"font-family: =
Helvetica; font-size: 12px;">Thanks,</div><div style=3D"font-family: =
Helvetica; font-size: 12px;"><br class=3D""></div><div =
style=3D"font-family: Helvetica; font-size: 12px;">Andreas</div><div =
class=3D""><br class=3D""></div><div class=3D""><br =
class=3D""></div></div></body></html>=
--Apple-Mail=_427E2848-BF62-48E2-A7FD-68DCD6AD068A--
--===============2774398033176162302==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
IPython-dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/ipython-dev
--===============2774398033176162302==--