I posted about this code on another Reddit account and I was rightly told that my code was shit and given code to properly use a json in Python. I then replied this:
Does that also make the code run faster?
If it does, I may steal it because otherwise I have no point in stealing it.
I wouldn't call this stupid at all. You found a clever and creative solution without knowing native JSON handling. If I everybody started programming like this, we would have flying cars by now. Give yourself a pad on the back.
I thought of a terrible algorithm. I'll write it in python
temp = ""
found_key = False
for char in JSON:
temp += char
if not found_key and not "JSON_key: ".startswith(temp):
temp = ""
elif not found_key and "JSON_key: " == temp:
found_key = True
temp = ""
elif found_key and char == ",":
res = temp
break
14
u/jso__ Mar 25 '23 edited Mar 25 '23
I posted about this code on another Reddit account and I was rightly told that my code was shit and given code to properly use a json in Python. I then replied this:
Yes, I was very stupid.
6
u/Seliba Mar 25 '23
Could have been way worse without regex, lol
5
u/fekkksn Mar 25 '23
FYI, Darksky is dead. Merrysky now provides the same service and a compatible API.
22
u/[deleted] Mar 25 '23 edited Mar 25 '23
Nice. At least when I was starting programming, I wasn't straight onto regex or requests. Took me about 6 months to a year to learn about that stuff
2
u/[deleted] Apr 03 '23
i see nothing wrong here, except COMPILING THE REGEX EVERY TIME YOU USE THE FUNCTION AAAAA
2
u/fnieidhfenmbvfekh Apr 05 '23
At least it’s better than me when starting programming.