create account

What if your code is ugly but it works? Amateur python programmers journey. by geekgirl

View this thread on: hive.blogpeakd.comecency.com
· @geekgirl · (edited)
$30.68
What if your code is ugly but it works? Amateur python programmers journey.
For simplicity I will refer to Hive as rebranding of Steem and when I say Hive I mean its entire history even before HF23. Yesterday I received a comment from @hivebuzz by @arcange that reminded me I have been on Hive for 3 years. I have been on the blockchain for 3 years. Time flies indeed.

![happybirthday.png](https://images.hive.blog/DQmQAT93RgWCrzXSicpts636s6Bdr4z9ynqPiWHD9SQMtsn/happybirthday.png)

Hive has many features that attract people like myself. Among them is learning new skills. If you have been following my posts recently, you would know that I like writing codes in python to automate things. But you may not know that I have become familiar with Python and started learning how to code is here on Hive. 

My early days on Hive were heavily involved with Curie and curation. As soon as I discovered Curie, I was more interested in curating than blogging. Not everybody have blogging skills. But luckily Hive is not only about blogging. I have made many friends among curators who would spends hours on daily basis to find talents and makes sure they get rewarded handsomely. 

One of the curators, @locikll introduced me to python. Initially I wanted to learn more python to make curating more efficient. Curating the entire blockchain involves a lot of repetitive moves. Combining automation to discover brilliant posts makes the process more efficient. Later, I was introduced to HiveSQL by @carlgnash and @markangeltrueman. Back then HiveSQL was affordable for an average curator. It might be a bit more expensive these days. It has always been a joy to use HiveSQL combined with python. 

Let me explain just to give an idea how one of my codes would help with curating. I have python code that would utilize HiveSQL. I would run it on a daily basis. It would filter out the posts that are most likely to be quality posts. But still return about 400-500 posts. Then it would open up 50 tabs at a time with all the posts. I would go through every single tab manually, read, evaluate, and keep the ones I would consider for suggesting for Curie. Utilizing shot-cut keys to close the tabs and move to the next one would also speed up the process. In no time I would be able to go through about 500 posts. Submit the ones I chose to Curie and move on the next day of curation. Later, I even purchased a special mouse, that I used for curating. It is a ring mouse with some keys that can be assigned to certain function.

As I was exploring python and learning more, I wrote some bot codes for Steem.chat and later for discord. None of those projects were completed. But they worked for a certain time period as intended. The problem I constantly keep facing is the ugly code. Even if the codes work well at the time they are needed, over some period of time they become unusable, because I don't know what their functions were and they were not written in a fashion to be reused. 

The reason is simple. When I start writing a code, initially I try to plan to make it reusable in future codes, organize it a little bit. But once codes starts getting longer, more complicated, I find myself rushing to finish and keep getting various errors. Whenever errors occur, there is always a simpler approach to take, that is simpler, sort of a patch, but ends up making code hard to read when revisited at a later time.

If you have been following my automating Stock Prices Traders Diary blog posts recently, you would know that I was working on automating record keeping of watched stock prices. Today I was able to finish the project. But end result ended up being an ugly code. But it works. 

What do I mean with an ugly code? It is a code that if someone else read it probably would be confused and decides that it is more efficient to rewrite it from the scratch. Not only that, it is a code that I myself probably would have hard time understand what I was trying to do when I read it a month from now. 

I was able to finish the project and get the code to work as intended. For that to happen though I had to compromise, make patches to fix errors, and not organizing it well so it can be reused in the future. I do see a lot of potential in the skills I learnt though, and I believe they will help me develop more based on them. Maybe I will revisit this code and improve to make it more readable and reusable in the future. For now, I will keep it, as it fulfills the functions I need. 

I will attach the screenshots of the code below. You be the judge how ugly it is. 

![uglycode1.png](https://images.hive.blog/DQmdGsLFqKKtzmLns7LB6bjW5E7yzJ23DEy2SMXL8ScFEhT/uglycode1.png)

![uglycase2.png](https://images.hive.blog/DQmfCa1wPhN45hjmKEDC6jWg2DkqAzs2i2bKmuA1j2KJtH7/uglycase2.png)

![unglycase3.png](https://images.hive.blog/DQmcrbj3wvqRpyq1gAkD22g5FLbKyTkvJaE83jEWcZrhVuA/unglycase3.png)

Posted Using [LeoFinance](https://leofinance.io/@geekgirl/what-if-your-code-is-ugly-but-it-works-amateur-python-programmers-journey)
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 131 others
👎  
properties (23)
authorgeekgirl
permlinkwhat-if-your-code-is-ugly-but-it-works-amateur-python-programmers-journey
categoryhive-167922
json_metadata{"tags":["market","stocks","coding","trading","dev","hivedev","hive","neoxian","ctp","stem","education","leofinance"],"image":["https://images.hive.blog/DQmQAT93RgWCrzXSicpts636s6Bdr4z9ynqPiWHD9SQMtsn/happybirthday.png","https://images.hive.blog/DQmdGsLFqKKtzmLns7LB6bjW5E7yzJ23DEy2SMXL8ScFEhT/uglycode1.png","https://images.hive.blog/DQmfCa1wPhN45hjmKEDC6jWg2DkqAzs2i2bKmuA1j2KJtH7/uglycase2.png","https://images.hive.blog/DQmcrbj3wvqRpyq1gAkD22g5FLbKyTkvJaE83jEWcZrhVuA/unglycase3.png"],"app":"leofinance/0.1","format":"markdown","canonical_url":"https://leofinance.io/@geekgirl/what-if-your-code-is-ugly-but-it-works-amateur-python-programmers-journey","users":["hivebuzz","arcange","locikll","carlgnash","markangeltrueman"],"links":["https://leofinance.io/@geekgirl/what-if-your-code-is-ugly-but-it-works-amateur-python-programmers-journey"]}
created2020-06-23 05:12:15
last_update2020-06-23 06:37:24
depth0
children17
last_payout2020-06-30 05:12:15
cashout_time1969-12-31 23:59:59
total_payout_value16.312 HBD
curator_payout_value14.368 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length4,950
author_reputation1,586,488,611,824,452
root_title"What if your code is ugly but it works? Amateur python programmers journey."
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id98,126,513
net_rshares76,879,687,437,811
author_curate_reward""
vote details (196)
@arcange ·
$0.14
Happy Hive Birthday @geekgirl (sorry being a bit late)
🎉🎈🎂🎉🎈<div class="pull-right"><a href="/@hive.engage">![](https://i.imgur.com/XsrNmcl.png)</a></div>
👍  
👎  
properties (23)
authorarcange
permlinkre-what-if-your-code-is-ugly-but-it-works-amateur-python-programmers-journey
categoryhive-167922
json_metadata{"app":"engage"}
created2020-06-24 18:32:00
last_update2020-06-24 18:32:00
depth1
children1
last_payout2020-07-01 18:32:00
cashout_time1969-12-31 23:59:59
total_payout_value0.070 HBD
curator_payout_value0.071 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length154
author_reputation1,146,606,639,109,506
root_title"What if your code is ugly but it works? Amateur python programmers journey."
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id98,156,270
net_rshares606,454,052,627
author_curate_reward""
vote details (2)
@geekgirl ·
Thank You.
properties (22)
authorgeekgirl
permlinkre-arcange-qcg7jj
categoryhive-167922
json_metadata{"tags":["hive-167922"],"app":"peakd/2020.05.5"}
created2020-06-24 20:57:21
last_update2020-06-24 20:57:21
depth2
children0
last_payout2020-07-01 20:57:21
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length10
author_reputation1,586,488,611,824,452
root_title"What if your code is ugly but it works? Amateur python programmers journey."
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id98,158,551
net_rshares0
@behiver ·
$0.13
You start with a dirty code and once is working you do the optimizations. Functionality before the performance I think is a natural way of doing things.
👍  
properties (23)
authorbehiver
permlinkre-geekgirl-2020628t10454482z
categoryhive-167922
json_metadata{"tags":["market","stocks","coding","trading","dev","hivedev","hive","neoxian","ctp","stem","education","leofinance"],"app":"esteem/2.2.7-surfer","format":"markdown+html","community":"esteem.app"}
created2020-06-28 07:45:42
last_update2020-06-28 07:45:42
depth1
children0
last_payout2020-07-05 07:45:42
cashout_time1969-12-31 23:59:59
total_payout_value0.062 HBD
curator_payout_value0.065 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length152
author_reputation567,890,467,975,745
root_title"What if your code is ugly but it works? Amateur python programmers journey."
beneficiaries
0.
accountesteemapp
weight300
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id98,218,862
net_rshares585,104,031,161
author_curate_reward""
vote details (1)
@brianoflondon ·
$0.42
I recently found I had my PhD C++ code on my laptop (I hadn't thought I still had this). It was written on a Silicon Graphics machine in the late 90's. That code formed part of my PhD thesis and even though I was a Physicist working in a Physics department, because I used C++ instead of Fortran my boss had me defend my thesis in front of a full on Computer Science Prof. My code was OK but not cutting edge... I scrapped through that bit but thank heavens my code was well commented!
👍  , ,
properties (23)
authorbrianoflondon
permlinkre-geekgirl-qcd5to
categoryhive-167922
json_metadata{"tags":["hive-167922"],"app":"peakd/2020.05.5"}
created2020-06-23 05:27:24
last_update2020-06-23 05:27:24
depth1
children1
last_payout2020-06-30 05:27:24
cashout_time1969-12-31 23:59:59
total_payout_value0.208 HBD
curator_payout_value0.208 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length485
author_reputation760,188,324,097,883
root_title"What if your code is ugly but it works? Amateur python programmers journey."
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id98,126,692
net_rshares1,605,920,829,647
author_curate_reward""
vote details (3)
@geekgirl ·
$0.22
Finding lost/old works is amazing. It is like a treasure you never valued before. I didn't know you were a physicist. That is awesome. I think physicists are among the smartest people we have.

Once I tried to read the C++ book, I gave up in couple of days. That's why I like python. Much simpler than any other programming languages and can get simple tasks done.
👍  ,
👎  
properties (23)
authorgeekgirl
permlinkre-brianoflondon-qcd7rd
categoryhive-167922
json_metadata{"tags":["hive-167922"],"app":"peakd/2020.05.5"}
created2020-06-23 06:09:15
last_update2020-06-23 06:09:15
depth2
children0
last_payout2020-06-30 06:09:15
cashout_time1969-12-31 23:59:59
total_payout_value0.152 HBD
curator_payout_value0.071 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length364
author_reputation1,586,488,611,824,452
root_title"What if your code is ugly but it works? Amateur python programmers journey."
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id98,127,094
net_rshares1,213,391,901,045
author_curate_reward""
vote details (3)
@enjar ·
$0.26
Congratulations on 3 years!
👍  
properties (23)
authorenjar
permlinkre-geekgirl-qcd61u
categoryhive-167922
json_metadata{"tags":["hive-167922"],"app":"peakd/2020.05.5"}
created2020-06-23 05:32:21
last_update2020-06-23 05:32:21
depth1
children1
last_payout2020-06-30 05:32:21
cashout_time1969-12-31 23:59:59
total_payout_value0.130 HBD
curator_payout_value0.130 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length27
author_reputation1,187,063,994,439,210
root_title"What if your code is ugly but it works? Amateur python programmers journey."
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id98,126,737
net_rshares1,047,438,451,053
author_curate_reward""
vote details (1)
@geekgirl ·
Thank you @enjar! Friends like you made this journey fun. You are awesome!
properties (22)
authorgeekgirl
permlinkre-enjar-qcd7xe
categoryhive-167922
json_metadata{"tags":["hive-167922"],"app":"peakd/2020.05.5"}
created2020-06-23 06:12:51
last_update2020-06-23 06:12:51
depth2
children0
last_payout2020-06-30 06:12:51
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length74
author_reputation1,586,488,611,824,452
root_title"What if your code is ugly but it works? Amateur python programmers journey."
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id98,127,125
net_rshares0
@foxon ·
$0.26
> skillz

It's pretty cool that you got paid to hang out on a social network while you learned all this

p.s.
Ugly code? I didn't think it was too bad.... until I got to col_letter 😂
👍  
properties (23)
authorfoxon
permlinkre-geekgirl-qcd61e
categoryhive-167922
json_metadata{"tags":["hive-167922"],"app":"peakd/2020.05.5"}
created2020-06-23 05:32:06
last_update2020-06-23 05:32:06
depth1
children1
last_payout2020-06-30 05:32:06
cashout_time1969-12-31 23:59:59
total_payout_value0.132 HBD
curator_payout_value0.132 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length182
author_reputation9,226,931,685,882
root_title"What if your code is ugly but it works? Amateur python programmers journey."
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id98,126,735
net_rshares1,068,422,220,731
author_curate_reward""
vote details (1)
@geekgirl ·
Thank you. Actually, things started not working right after col_letter. I just kept changing until it started working. :)

I have skillz. 
properties (22)
authorgeekgirl
permlinkre-foxon-qcd7ux
categoryhive-167922
json_metadata{"tags":["hive-167922"],"app":"peakd/2020.05.5"}
created2020-06-23 06:11:21
last_update2020-06-23 06:11:21
depth2
children0
last_payout2020-06-30 06:11:21
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length138
author_reputation1,586,488,611,824,452
root_title"What if your code is ugly but it works? Amateur python programmers journey."
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id98,127,114
net_rshares0
@fsm-core ·
Ugly code is fine as long as no other person will be tasked to maintain or upgrade the code. I make sure I comment a lot on my code because that "other person" could be future me lol.
properties (22)
authorfsm-core
permlinkre-geekgirl-qcf2vc
categoryhive-167922
json_metadata{"tags":["hive-167922"],"app":"peakd/2020.05.5"}
created2020-06-24 06:18:57
last_update2020-06-24 06:18:57
depth1
children0
last_payout2020-07-01 06:18:57
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length183
author_reputation23,077,214,807
root_title"What if your code is ugly but it works? Amateur python programmers journey."
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id98,145,943
net_rshares0
@gitplait-mod1 ·
$0.14
Coding is a tough job. But in my opinion if one can write ugly code he can write efficient code. All the thing required is passion and little efforts. Thanka for sharing your experience with codes. 
Your post has been curated with @gitplait community account because this is the kind of publications we like to see in our community.

Join our Community on [Hive](https://hive.blog/trending/hive-103590) and Chat with us on [Discord](https://discord.com/invite/CWCj3rw).
👍  
properties (23)
authorgitplait-mod1
permlinkqcdjiy
categoryhive-167922
json_metadata{"users":["gitplait"],"links":["https://hive.blog/trending/hive-103590","https://discord.com/invite/CWCj3rw"],"app":"hiveblog/0.1"}
created2020-06-23 10:23:27
last_update2020-06-23 10:23:27
depth1
children0
last_payout2020-06-30 10:23:27
cashout_time1969-12-31 23:59:59
total_payout_value0.068 HBD
curator_payout_value0.068 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length469
author_reputation64,455,719,431
root_title"What if your code is ugly but it works? Amateur python programmers journey."
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id98,129,785
net_rshares572,298,233,950
author_curate_reward""
vote details (1)
@hiro-hive ·
$0.13
Good luck in your journey to becoming a Python Expert. This skills do not die but it keeps evolving overtime because it is open source indeed. Best of luck to you my friend, see you on Twitter Hustling! 🤗❤💯
👍  
properties (23)
authorhiro-hive
permlinkre-geekgirl-qcgl3z
categoryhive-167922
json_metadata{"tags":["hive-167922"],"app":"peakd/2020.05.5"}
created2020-06-25 01:50:24
last_update2020-06-25 01:50:24
depth1
children1
last_payout2020-07-02 01:50:24
cashout_time1969-12-31 23:59:59
total_payout_value0.062 HBD
curator_payout_value0.063 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length206
author_reputation461,949,875,870,711
root_title"What if your code is ugly but it works? Amateur python programmers journey."
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id98,162,103
net_rshares538,308,744,159
author_curate_reward""
vote details (1)
@geekgirl ·
Thank You.
properties (22)
authorgeekgirl
permlinkre-hiro-hive-qcgt5m
categoryhive-167922
json_metadata{"tags":["hive-167922"],"app":"peakd/2020.05.5"}
created2020-06-25 04:44:09
last_update2020-06-25 04:44:09
depth2
children0
last_payout2020-07-02 04:44:09
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length10
author_reputation1,586,488,611,824,452
root_title"What if your code is ugly but it works? Amateur python programmers journey."
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id98,163,984
net_rshares0
@josediccus ·
$0.25
What can I say, your journey has been amazing so far, I mean you were huge on the chain then with curie and I think I remember vividly then as well. What can I say but congratulations my friends it's been a splendid 3 years on the chain for you.
👍  
properties (23)
authorjosediccus
permlinkqcd988
categoryhive-167922
json_metadata{"app":"hiveblog/0.1"}
created2020-06-23 06:40:57
last_update2020-06-23 06:40:57
depth1
children2
last_payout2020-06-30 06:40:57
cashout_time1969-12-31 23:59:59
total_payout_value0.124 HBD
curator_payout_value0.125 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length245
author_reputation2,576,113,899,533,584
root_title"What if your code is ugly but it works? Amateur python programmers journey."
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id98,127,433
net_rshares1,013,938,325,908
author_curate_reward""
vote details (1)
@geekgirl ·
Thank You @josedicuss!
properties (22)
authorgeekgirl
permlinkre-josediccus-qcda06
categoryhive-167922
json_metadata{"tags":["hive-167922"],"app":"peakd/2020.05.5"}
created2020-06-23 06:57:45
last_update2020-06-23 06:57:45
depth2
children1
last_payout2020-06-30 06:57:45
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length22
author_reputation1,586,488,611,824,452
root_title"What if your code is ugly but it works? Amateur python programmers journey."
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id98,127,606
net_rshares0
@josediccus · (edited)
You're welcome, looking forward to your 4th year
properties (22)
authorjosediccus
permlinkqcda2k
categoryhive-167922
json_metadata{"app":"hiveblog/0.1"}
created2020-06-23 06:59:09
last_update2020-06-23 06:59:36
depth3
children0
last_payout2020-06-30 06:59:09
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length48
author_reputation2,576,113,899,533,584
root_title"What if your code is ugly but it works? Amateur python programmers journey."
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id98,127,626
net_rshares0
@slackerman ·
$0.13
I am not much of a coder, but I  found your article very interesting.  Keep at it and you will get better!  Try something new every day and don't be afraid to make mistakes!  That is how we learn.

![included.png](https://images.hive.blog/DQmQs9D3oCVGNAkpMabLwBNdvpkD2A65pSgZWVyk3HTiYrB/included.png)
👍  
properties (23)
authorslackerman
permlinkqcdsn0
categoryhive-167922
json_metadata{"tags":["ctp"],"image":["https://images.hive.blog/DQmQs9D3oCVGNAkpMabLwBNdvpkD2A65pSgZWVyk3HTiYrB/included.png"],"app":"clicktrackprofit/0.1","canonical_url":"https://www.ctptalk.com/@slackerman/qcdsn0"}
created2020-06-23 13:40:15
last_update2020-06-23 13:40:15
depth1
children0
last_payout2020-06-30 13:40:15
cashout_time1969-12-31 23:59:59
total_payout_value0.066 HBD
curator_payout_value0.067 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length300
author_reputation6,949,361,367,724
root_title"What if your code is ugly but it works? Amateur python programmers journey."
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id98,132,346
net_rshares566,601,673,027
author_curate_reward""
vote details (1)