Benny K
Benny K

Reputation: 2087

Any way to see variables defined in PyCharm console with one liner?

In PyCharm if I use the Python Console to define some variable like:

>>> import numpy as np
>>> scale = np.random.rand(1)[0]

I am not getting any feedback, so to actually see the value of scale I need to:

>>> scale
0.6160226502566429

Any way of getting the value without the second line?

Upvotes: 1

Views: 48

Answers (1)

If you are using python3.8+, you can use (scale := np.random.rand(1)[0]), which will return the value but also assign the variable.

See https://www.python.org/dev/peps/pep-0572/

Upvotes: 1

Related Questions