dir changes attributes of praw.objects.Subreddits in place
See original GitHub issueToday I noticed that the built-in function dir()
seems to change the attributes of praw.objects.Subreddits in place.
Could this possibly be the result of a buggy __dir__()
implementation in a praw.objects.Subreddit parent class? I honestly have no clue what to make of this.
Issue Analytics
- State:
- Created 8 years ago
- Comments:12 (10 by maintainers)
Top Results From Across the Web
Submission — PRAW 7.6.1 documentation
This table describes attributes that typically belong to objects of this class. PRAW dynamically provides the attributes that Reddit returns via the API....
Read more >Subreddit — PRAW 7.6.1 documentation - Read the Docs
This table describes attributes that typically belong to objects of this class. PRAW dynamically provides the attributes that Reddit returns via the API....
Read more >Change Log — PRAW 3.6.2 documentation
[CHANGE] Fixed the subreddits attribute of praw.objects.Multireddit being returned as a list of dicts. It is now a list of Subreddit objects.
Read more >Redditor — PRAW 7.6.1 documentation
This table describes attributes that typically belong to objects of this class. PRAW dynamically provides the attributes that Reddit returns via the API....
Read more >Message — PRAW 7.6.1 documentation
PRAW dynamically provides the attributes that Reddit returns via the API. Since those attributes are subject to change on Reddit's end, PRAW makes...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Okay, must be the difference between Python 2 and 3, that’s an interesting distinction. Does
two.__dict__
instead ofdir(two)
cause the same thing to happen?If this is something that can be fixed in a clean and version-compatible way, I’d say there’s no reason not to, but I’m not sure how you could change the behavior of something as basic as
dir
. It appears (in 3.5), that it can be overridden:I don’t know what you would put inside that method that achieves all the normal functionality of
dir
and doesn’t do whatever causes Python 2 to trip the lazy loader. Plus it just seems like something that should never have to be done. You mentionedbut I think
hasattr
is always the correct answer anyway. We should have a very good reason before overriding this kind of thing.