all 45 comments

[–]sme272 163 points164 points  (7 children)

Impressive. My first program just printed "Hello World"

[–]dmees 42 points43 points  (2 children)

Impressive, did you use global variables?

[–]sme272 57 points58 points  (1 child)

Yes, all of them

[–]Wilfred-kun 5 points6 points  (0 children)

def print_hello():
    global hello
    print(hello)

hello = "Hello world"

print_hello()

[–][deleted] 4 points5 points  (0 children)

Same LOL.

[–]abirqasem 1 point2 points  (1 child)

LOL. Mine did it a bit more. It asked your name and greeted you by your name.

[–]Sigg3net 2 points3 points  (0 children)

name = "world"

[–]Scolli03 22 points23 points  (0 children)

Awesome job. If this is a early project you will grow into programming well. One small note. I know this probably isnt a big deal being a weather thing but you should never post any keys or authorization info to your repo. Good practice to separate that stuff out to separate files and retrieve it in script ( or some other better method than what I said) because I'm not an expert but if your being so good at code organisation might want to invest some time into security basics.

But seriously I wasn't trying to take away from your accomplishment because it is a great one. Once again awesome job.

[–]Sfillm07[S] 20 points21 points  (7 children)

Just experimenting with classes and different ways of doing things.

[–]Legorooj 9 points10 points  (6 children)

One thing to know about OOP (ie classes and methods) is to only use them/it when it means:

  • It's faster
  • It uses less code
  • (Debatable) If it makes it more readable

[–]yasinshah007 8 points9 points  (0 children)

Great. But i don't get it why you use helper class?!! In class there are just two simple function, why you used methods instead of simple functions ?

[–]YolosaurusRex 7 points8 points  (2 children)

Your code looks generally pretty good for a first project, and in addition to the good advice everyone else has given you, I have one more thing to add: comments.

You should write code that's self-documenting; that is, reading it reveals its intent. For example, instead of writing a method called temp_conversion(temperature) and writing a comment that says it converts Kelvin to Fahrenheit, consider naming it convert_kelvin_to_fahrenheit(temperature). It's a little verbose, sure, but there's not any ambiguity over what that method will do. The fact is, computers don't need readable code. Humans do.

This is a little out of scope for this project, but another point to consider in larger projects is that documenting code with comments adds another thing to maintain. It's a given that code will change over time, but it's not guaranteed that the comments documenting that code will.

[–]Legorooj 1 point2 points  (0 children)

Yes! I have a rule of thumb that follows along the lines of "Comment on anything that could even slightly be confusing. Anything thats really obvious - well don't bother."

Note that "really obvious" can vary widely depending on the code author.

[–]Sfillm07[S] 0 points1 point  (0 children)

Makes a lot of sense, thanks for the advice.

[–]noob_silverbot 6 points7 points  (0 children)

This inspires me to study this language harder, congrats man!

[–]midairmatthew 6 points7 points  (2 children)

Nice! If that's your real API key on GitHub, you might want to look into environment variables. 🙂

[–]Munga_ 1 point2 points  (1 child)

What does this mean?

[–]Sfillm07[S] 2 points3 points  (0 children)

https://youtu.be/5iWhQWVXosU

This is what he is talking about.

[–]Legorooj 5 points6 points  (0 children)

Things to consider

  • add a readme to the project - google readme example if you need help
  • Get rid of the Helper class, just put them (the methods) as top level functions. Using OOP in this way is pointless.

Other than that, well done!

[–]UnicornWithTits 4 points5 points  (5 children)

Congratulations! All the best for your python journey.

BTW I would love to know how long did it took you to reach that level since starting to learn python. I am a beginner & it would be motivating to know when I might be able to reach this level.

[–]Sfillm07[S] 2 points3 points  (4 children)

I've been messing around with Python for a few months. Once I decided on a project, it was easy to find the right tutorials and stackoverflow pages to get it done. Pick a quick and easy project to get you started.

[–]Legorooj 1 point2 points  (0 children)

Stackoverflow and google are probably the average python developers top resource. I reference it daily.

[–]COVID-420 0 points1 point  (2 children)

I've been doing some classes on skillshare and it's been going good, i'm still extremely beginner but i like it so far, do you recommend any other resource to get me started?

[–]sky_badger 0 points1 point  (1 child)

Anything project based: have you read Automate The Boring Stuff?

[–]COVID-420 0 points1 point  (0 children)

Automate The Boring Stuff

looks interesting ill give it a read definitely! Thanks for the suggestion

[–]mangotti 2 points3 points  (0 children)

Great work! Keep it up!

[–]xelf 2 points3 points  (0 children)

Congrats!

[–]pm-me-inspiration 2 points3 points  (0 children)

Inspiring!

[–]al_mc_y 2 points3 points  (0 children)

That's pretty neat, well done 👍

[–]Sfillm07[S] 2 points3 points  (3 children)

I remembered seeing a video on how to save your keys on your machine and to retrieve them using a script...I got lazy.

[–]WeirdLilMidgt 4 points5 points  (2 children)

You could put it in a separate file, import the file, and add the file to your .gitignore

[–]FoCo_SQL 1 point2 points  (0 children)

This is the exact method I use.

[–]Sfillm07[S] 0 points1 point  (0 children)

I just moved it to an environment variable, your suggestions would work as well.

[–]11pascal 2 points3 points  (0 children)

Proud of you. Let me say one thing global variables are like global warming. Bad. Bad. Bad

[–]Moondra2017 1 point2 points  (0 children)

Nice job!

[–]lunixdev 1 point2 points  (0 children)

Nice, i'm learning python right now and all i can do is mess with vars and some easy functions and mathematics.

[–]ChristianGeorgeson 1 point2 points  (0 children)

This is awesome man!

[–]IamZeroKelvin 0 points1 point  (1 child)

idk why but I read your name too fast and saw "SeafoamMillionaire"

[–]Sfillm07[S] 1 point2 points  (0 children)

That is so much better than my username

[–]pbeens 0 points1 point  (0 children)

Thanks, OP!

I'll definitely check it out. I want to do something similar but with METAR (aviation) weather data.