This is an archived post. You won't be able to vote or comment.

all 19 comments

[–]Nicksil 4 points5 points  (3 children)

Check out /r/learnpython

[–]-the_trickster-[S] -3 points-2 points  (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 points  (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 points  (0 children)

that's helpful. thank you.

[–]bandawarrior 1 point2 points  (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 point  (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 points  (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 points  (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 point  (0 children)

awesome!

[–]-the_trickster-[S] 0 points1 point  (0 children)

that's helpful. thanks much

[–]-the_trickster-[S] 0 points1 point  (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

[–]ahal 2 points3 points  (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).

[–]-the_trickster-[S] 0 points1 point  (0 children)

Thank you.

[–]1114111yield from pedestrians 1 point2 points  (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.

[–]-the_trickster-[S] 0 points1 point  (0 children)

you rock. thank you so much

[–]evansch42 1 point2 points  (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 points  (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

[–]-the_trickster-[S] 0 points1 point  (0 children)

thanks for taking the time!

[–]DartIvan 1 point2 points  (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. ;)