Python Forum
PyCharm dir() not displaying output - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: PyCharm dir() not displaying output (/thread-35563.html)



PyCharm dir() not displaying output - bodisha - Nov-17-2021

Trying to figure out Python and PyCharms isn't acting how I'm expecting it too.... and the dir() function isn't producing any output for me. When I run the following in PyCharms

import yfinance
dir(yfinance)
All I receive is the following without displaying the output I was expecting

Output:
Process finished with exit code 0
But when I run the same thing from the python console in Powershell it works and I receive

Output:
['Ticker', 'Tickers', '__all__', '__author__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', '__version__', 'base', 'download', 'multi', 'pdr_override', 'shared', 'ticker', 'tickers', 'utils', 'version']
I'm running

Windows 10
Python 3.9.8
Pycharms 2021.2.3 (Community Edition)
yfinance 0.1.64

Any suggestions on what I'm doing wrong would be appreciated! Thanks


RE: PyCharm dir() not displaying output - Larz60+ - Nov-18-2021

when in your shell, output is directed to stdout, thus you see the list.
when in a script, you have to direct where you want the output to go.
thus changing line 2 to print(dir(yfinance)) will show the output of the dir statement.
you could also save it in a variable, like this:
import yfinance
yfin = dir(yfinance)
print(yfin)



RE: PyCharm dir() not displaying output - bodisha - Nov-21-2021

Worked like a charm... thank you!