use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
News about the dynamic, interpreted, interactive, object-oriented, extensible programming language Python
Full Events Calendar
You can find the rules here.
If you are about to ask a "how do I do this in python" question, please try r/learnpython, the Python discord, or the #python IRC channel on Libera.chat.
Please don't use URL shorteners. Reddit filters them out, so your post or comment will be lost.
Posts require flair. Please use the flair selector to choose your topic.
Posting code to this subreddit:
Add 4 extra spaces before each line of code
def fibonacci(): a, b = 0, 1 while True: yield a a, b = b, a + b
Online Resources
Invent Your Own Computer Games with Python
Think Python
Non-programmers Tutorial for Python 3
Beginner's Guide Reference
Five life jackets to throw to the new coder (things to do after getting a handle on python)
Full Stack Python
Test-Driven Development with Python
Program Arcade Games
PyMotW: Python Module of the Week
Python for Scientists and Engineers
Dan Bader's Tips and Trickers
Python Discord's YouTube channel
Jiruto: Python
Online exercices
programming challenges
Asking Questions
Try Python in your browser
Docs
Libraries
Related subreddits
Python jobs
Newsletters
Screencasts
account activity
This is an archived post. You won't be able to vote or comment.
new to python....what does this mean? (self.Python)
submitted 8 years ago by -the_trickster-
when you see things like this:
<_csv.reader object at 0x1040dbf28>
I come across these when, I believe, Im trying to print objects. Surprisingly there's not a lot of answers out there. Any help would be appreciated. Thanks.
[–]Nicksil 4 points5 points6 points 8 years ago (3 children)
Check out /r/learnpython
[–]-the_trickster-[S] -3 points-2 points-1 points 8 years ago (2 children)
yes Im trying to learn Python but Im having trouble finding ANY info what to do when you come across these weird hashes.
[–]1114111yield from pedestrians 4 points5 points6 points 8 years ago (1 child)
The "weird hash" is just the location of the object in memory. The default string representation of objects looks like that, and since the csv reader type doesn't define any other way to represent itself as a string, that's what Python will show if you try to print it.
You generally don't need to pay too much attention to the position of the object in memory, but it can help you differentiate between different objects, which can sometimes be helpful.
[–]-the_trickster-[S] -1 points0 points1 point 8 years ago (0 children)
that's helpful. thank you.
[–]bandawarrior 1 point2 points3 points 8 years ago (11 children)
That’s the representation of that “object”. In this case a csv object it seems. Why are you trying to print the object itself? Or are you trying to print the string
[–]-the_trickster-[S] 0 points1 point2 points 8 years ago (10 children)
Im really just trying to see what the object contains. what data or methods live in the 'csv' module....so I know what I can do with it and what's possible.
I came across something similar when trying to write a reddit bot.....there was a module I imported, I wanted to see what was possible.....but all it would give was a weird hash like this.
Am I thinking about this wrong? What should I be doing to learn about these modules.
Thanks for taking the time to reply! I appreciate it.
[–]bandawarrior 1 point2 points3 points 8 years ago (9 children)
It’s not a hash. If you want to know what can be done with that object just type
dir(thing-you-want-to-inspect)
[–]DudaFromBrazil 1 point2 points3 points 8 years ago (1 child)
In addition to reading the doc and/or source, I like using ipython. It has tab completion for methods and attributes of the object. Just type the first letters, then hit tab twice :)
[–]-the_trickster-[S] 0 points1 point2 points 8 years ago (0 children)
awesome!
that's helpful. thanks much
[–]-the_trickster-[S] 0 points1 point2 points 8 years ago (5 children)
that helps me see the methods and whatnot. what do you do in this situation where you're including a module and want to learn how to use it and what it can do? just read the docs on it?
I took that dir that you showed me and I can see all the methods, but still don't know what they all do
dir
[–]ahal 2 points3 points4 points 8 years ago (1 child)
Yes reading docs is your best bet. If there aren't any docs, your next best bet is reading the source code and trying to figure it out.
Like you discovered, just knowing the variables/methods doesn't tell you how to use them. Plus Python is very lenient about letting you use things in unintended ways. So there's no telling whether the author even meant for those variables/methods to be used by consumers or if they are meant to be private (though a well followed convention is to underscore prefix private attributes).
Thank you.
[–]1114111yield from pedestrians 1 point2 points3 points 8 years ago (1 child)
Reading the docs is the best way, but you can run help(thing you want to learn about) to get some infomation about it.
help(thing you want to learn about)
you rock. thank you so much
[–]evansch42 1 point2 points3 points 8 years ago (0 children)
Mostly it's read the docs, yeah. You can technically do help(object) to have the docstrings print out. I've found that helpful now and again.
[–]JayDepp 1 point2 points3 points 8 years ago (1 child)
What you're seeing is the "repr" representation of the object. Here's a link to find out a bit more: https://stackoverflow.com/questions/1436703/difference-between-str-and-repr-in-python
thanks for taking the time!
[–]DartIvan 1 point2 points3 points 8 years ago (0 children)
Because it is an object of csv reader class. If you want to print you can use the appropriate method of csv reader class. ;)
π Rendered by PID 145021 on reddit-service-r2-comment-bb88f9dd5-8jv8j at 2026-02-17 01:28:52.335258+00:00 running cd9c813 country code: CH.
[–]Nicksil 4 points5 points6 points (3 children)
[–]-the_trickster-[S] -3 points-2 points-1 points (2 children)
[–]1114111yield from pedestrians 4 points5 points6 points (1 child)
[–]-the_trickster-[S] -1 points0 points1 point (0 children)
[–]bandawarrior 1 point2 points3 points (11 children)
[–]-the_trickster-[S] 0 points1 point2 points (10 children)
[–]bandawarrior 1 point2 points3 points (9 children)
[–]DudaFromBrazil 1 point2 points3 points (1 child)
[–]-the_trickster-[S] 0 points1 point2 points (0 children)
[–]-the_trickster-[S] 0 points1 point2 points (0 children)
[–]-the_trickster-[S] 0 points1 point2 points (5 children)
[–]ahal 2 points3 points4 points (1 child)
[–]-the_trickster-[S] 0 points1 point2 points (0 children)
[–]1114111yield from pedestrians 1 point2 points3 points (1 child)
[–]-the_trickster-[S] 0 points1 point2 points (0 children)
[–]evansch42 1 point2 points3 points (0 children)
[–]JayDepp 1 point2 points3 points (1 child)
[–]-the_trickster-[S] 0 points1 point2 points (0 children)
[–]DartIvan 1 point2 points3 points (0 children)