RE: [ENG/ITA] Python and Hive: Learning from Other Hiveans!
You are viewing a single comment's thread:
That's how I taught myself.
Really!? You are so good and you have done all by yourself? Dang, that's beyond motivating 😅
omg, you've ruined it! 😅
I know 🤣 but don't worry, the comments are there only for the sake of this post: I promise I won't put any when I'll use your code in my scripts ahahah
So instead of me explaining, you had a chance to experience it happening and come to your own conclusions. Which was the plan.
I love your approach, tbh: it challenges the reader to actively learn and this is by far more efficient than just reading an explanation. By trying myself your code I was able to ask myself why you did something, look for an answer by using my brain and than, finally, understand what was doing what and, most importantly, why.
Sessions/Requests are still a bit obscure for me, though, but I can't hope to understand everything immediately, so I'll keep checking the docs and experimenting with different API call to strengthen my knowledge.
Yes.
I am not even good.
The stuff I build is far from industry standard.
What seems impressive now, will look like a joke another month in.
Once you've built a few things, you'll notice.
Repetition -> learning.
Sometimes I do totally unrelated stuff and suddenly I understand something that I tried weeks ago...
Yeah... I can tell by your comments on the code, that it hasn't 'clicked' for you.
Thing is: that has nothing to do with HIVE, but you just need more practice with Python and code in general.
...and there are enough Python tutorials out there.
If something isn't clear, I am happy to help, but I can't also try to teach Python in my tutorials.
That
with
statement is very pythonic and it's powerful.Other languages don't even have that concept...
For now: Please trust me, it's the cleanest way to go about it.
I use it for reasons and they will become clearer when I continue.
It's worth exploring...
That's it. Feels good that it worked for you.
But it really only works, when people actually try to use it.
Tagging @slobberchops for good measure here.
Still far from clicking, but slowly I'll get it :)
100% trust! I know that "with" is very powerful and I was using it to open a file, but from your code I learned that it can do much more, so yup, just from a few lines of yours thare's a lot of stuff which are very much worth exploring!
Your comments and posts are already way much more than what I was hoping to find :)
...and close it.
with
keeps any session (writing files, accessing databases, http sessions) open and closes it, too. This leads to cleaner structure and cleaner code.(The other way would be using
open()
andclose()
functions, which can lead to all sorts of trouble)btw did you manage to use condenser's get_accounts function?
I was aware that it open and close a file, but I didn't know it could be used for different tasks, like databases and http sessions: a knowledge worth remembering... and mastering :)
Today I tried a bit the condenser_api.get_discussions_by_author_before_date, because I needed to see what info were submitted when publishing a post... and after that I started experimenting a bit 😅
And here is when I found that my reputation hasn't changed with the last 100 posts I published 😂
EDIT: unless I made a mistake, because now I'm trying to change the date and it keeps giving me the same results as before:
No matter what date I set, I always see the data and title about my last 3 posts... I guess I'll try to understand what I messed up tomorrow after a good sleep 😴
Condenser provides 'higher level' information. The further you deviate from the core functions of Hive, the more complicated (and unreliable) it gets.
Reputation for example is abstracted. It never was a core feature of Hive, but was built on top of it.
Whenever you get a vote (up or down) it affects your reputation.
So yeah, something went wrong.
I am not familiar with all calls in the documentation.
I have never touched
get_discussions_by_author_before_date
There's also no guarantee that the calls are properly documented and I raged about that a while ago:
https://peakd.com/dev/@felixxx/hive-api-reference-incomplete
I have since been told that the documentation is incomplete on purpose, because the higher level (hivemind) stuff, will be abandoned in the future in favor of a HAF infrastructure.
I am pretty sure there is no extra table that saves how high your reputation was at a given time. That would be a very long database table that makes an entry after every vote you ever received and that for every user... too much data for too little benefit...
I could look into the above call more closely, depending on how important it is for you.
Generally, I'd say: stay away from
get_discussion
and anythingreputation
for now. They are soft.block_api
,account_api
are core features and the most reliable...What an unusual purpose LOL also considering that I guess that this situation is going on since a long time, and this doesn't sound like something which could help increase adoption...
Don't worry, I chose that key only to see if was able to access it, but I could have chosen a different one! oc I had to choose one that wasn't working properly among all the available keys 🤣
Gotcha!
Well...
I actually went ahead an wrote a whole post about it...
Already seen and upvoted! :) Happy to see you posting more snippets and useful tips! As soon as I can I will read again it and use it to make more progress with my coding.