question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Subscript assignment in Python 3.9

See original GitHub issue

What I did

I want to see live coding variable values for a numpy array created as below and assigning a value to one of the element.

import numpy as np

tempArr = np.zeros(5)
tempArr[0] = 0 #problematic line
print(tempArr)

What happened

Everything works but as soon as assignment expression is executed no output is shown in live code. (PyCharm plugin)

tempArr[0] = 0

What I wanted to happen

I would like to print all lines in live code including assignment line as blank line.

tempArr = array([0., 0., 0., 0., 0.])

print('[0. 0. 0. 0. 0.]')

My environment

Describe the versions of everything you were using:

  • Editor PyCharm
  • Operating system MacOS
  • Python 3.9

Other feedback

I a new python learner and enjoyed Live Code thoroughly. Planning to use it as much as possible but above error is stopping me to use it. Thanks for making such a great tool !

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
donkirkbycommented, Dec 28, 2020

Thanks for the bug report. It looks like a problem with Python 3.9, so I’ll dig into it. It doesn’t seem related to numpy, because this fails in the same way:

tempArr = [0] * 5
tempArr[0] = 0  # problematic line
print(tempArr)

There’s probably some new class in the ast module that I have to support.

0reactions
vijayk22commented, Jan 3, 2021

Thanks a lot !

Read more comments on GitHub >

github_iconTop Results From Across the Web

Assignment Expressions: The Walrus Operator - Real Python
The assignment expression allows you to assign True to walrus , and immediately print the value. But keep in mind that the walrus...
Read more >
python - Cannot use assignment expressions with subscript
There is some justification for the decision to disallow more complex assignments in assignment expressions given on the python-dev mailing ...
Read more >
PEP 572 – Assignment Expressions
Python already has a rule that subexpressions are generally evaluated from left to right. However, assignment expressions make these side effects more visible, ......
Read more >
What are Python Assignment Expressions and Using the ...
Each new version of Python adds new features to the language. For Python 3.8, the biggest change is the addition of assignment expressions....
Read more >
How To Use Assignment Expressions in Python - DigitalOcean
You initialize a list named some_list that contains three elements. Then, the if statement uses the assignment expression ((list_length := len( ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found