ipython / ipython/ipython

%time magic funtion prevents variable assigment when used in function

Open
#13,137 3 comments 1 reaction 0 assignees View on GitHub
magics
Dominant language
Python
Stars
16.8k
Forks
4.5k
Avg merge
1d 2h
Merged PRs (30d)
6

Description

I'm using IPython version 7.27. The following code snippet throws a `NameError: name 'variable' is not defined`:

```
def test(msg):
%time variable = msg
print(variable)

test("moin")
```

The bug is similar to #11659 and #11813, but it seems to only occur when used inside a function body.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.