Python Forum
PyCharm dir() not displaying output
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PyCharm dir() not displaying output
#1
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
Reply
#2
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)
bodisha likes this post
Reply
#3
Worked like a charm... thank you!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Facing problem with Pycharm - Not getting the expected output amortal03 1 889 Sep-09-2022, 05:44 PM
Last Post: Yoriz
  String output displaying \n instead of new line... nicklesprout 4 25,892 Jul-28-2017, 08:01 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020