Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

automatic_names in Jupyter #29888

Open
kcrisman opened this issue Jun 17, 2020 · 3 comments
Open

automatic_names in Jupyter #29888

kcrisman opened this issue Jun 17, 2020 · 3 comments

Comments

@kcrisman
Copy link
Member

See #9048 and #25837, among others. This was at least a reasonably often requested feature for teaching. Part of #29889.

Component: notebook

Issue created by migration from https://trac.sagemath.org/ticket/29888

@kcrisman kcrisman added this to the sage-9.2 milestone Jun 17, 2020
@kcrisman

This comment has been minimized.

@mkoeppe mkoeppe modified the milestones: sage-9.2, sage-9.3 Sep 5, 2020
@mkoeppe
Copy link
Contributor

mkoeppe commented Feb 13, 2021

comment:3

Setting new milestone based on a cursory review of ticket status, priority, and last modification date.

@mkoeppe mkoeppe modified the milestones: sage-9.3, sage-9.4 Feb 13, 2021
@mkoeppe mkoeppe modified the milestones: sage-9.4, sage-9.5 Jul 19, 2021
@mkoeppe mkoeppe modified the milestones: sage-9.5, sage-9.6 Dec 18, 2021
@mkoeppe mkoeppe modified the milestones: sage-9.6, sage-9.7 Apr 2, 2022
@mkoeppe mkoeppe modified the milestones: sage-9.7, sage-9.8 Aug 31, 2022
@mkoeppe mkoeppe removed this from the sage-9.8 milestone Jan 29, 2023
@EmmanuelCharpentier
Copy link
Contributor

EmmanuelCharpentier commented Jan 12, 2024

I'm not sure that re-implementing this feature is worth the pain : it has the drawback of creating a symbolic variable for each instance of undefined Python identifier ; as a consequence, if the identifier is later re-used, the created symbolic variable still exists, but no valid reference to it exists.

Nevertheless, a way to do this is to trap the "NameError" exception and treat it suitably (possibly only at the top level of the interpreter). This could be useful to clean up expression returned by some Maxima or Sympy routines creating such dynamic variables (integratin, differential equation solvers, and possibly others).

A possibly more useful alternative coul be a function accepting some symbolic expression , finding all unbound identifiers and binding them to suitable symbolic variables. This should be trivial if one wants global identifiers. The REPL setup code might be the right place to implement this feature.

An harder problem is to do this at the level of identifiers in the local frame of a defined (Python or Cython) function. While some idioms for dynamically creating new identifiers in the local frameof a function were published for Python 2.x interpreters, I am not aware of any such trick accepted in current or recent Python interpreters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants