Skip to content

have ipython_utils define __file__ and other globals assumed by script #116

@tomasohara

Description

@tomasohara

Cut-n-paste of code with __file__ into ipython leads to an exception. It would be good for ipython_utils.py to define this with a dummy value for convenience (e.g., for use in ~/.ipython/profile_default/startup/25-quarter.py).

In [22]: # Sanity checks
    ...: # note: should precede module import, but isort messes up order and hard to configure.
    ...: debug.assertion(__file__.startswith(SRC_DIR))
    ...:
    ...:
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In[22], line 3
      1 # Sanity checks
      2 # note: should precede module import, but isort messes up order and hard to configure.
----> 3 debug.assertion(__file__.startswith(SRC_DIR))

NameError: name '__file__' is not defined

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions