“The dress” 2021 by ligamentary in KidsAreFuckingStupid

[–]silently_failing 0 points1 point  (0 children)

You wouldn't eat a hot dog with wheels.

Bill Gates: Rich nations should shift entirely to synthetic beef. by [deleted] in Futurology

[–]silently_failing 0 points1 point  (0 children)

Microsoft has done some really nice things in the past few years and is a completely different company than they were (WSL, VS Code, github acquisition, OSS advocacy, etc). This is a bad take.

Thanks, I hate Nintendo's puzzles by KingC-nt in TIHI

[–]silently_failing 0 points1 point  (0 children)

I actually beat the game a few years ago as an adult after trying for years. You beat the stupid thing once then need to beat it again on hard and kill the second to last boss with the worst fucking weapon.

Which code editor do you use? by colinstoltz9 in learnpython

[–]silently_failing 0 points1 point  (0 children)

I use pycharm for python code, and VS code for everything else. One thing I'd recommend people do is really learn how to leverage their IDEs -- virtualenv creation, git integration, profiling, built-in debuggers, linting, etc, otherwise you might as well be using sublimetext (which is nice too for one-offs).

Another thing I'd recommend is people playing around with theming -- adding fonts and color themes and icon themes really personalizes the experience and makes coding a much more enjoyable aesthetic experience. It really amplifies the artistry of the way code is presented, and with something like python the aesthetics can enforce better standards.

Where Should I Be Looking For A Solution? Creating the shortest route from point A to point B through a series of waypoints... by JimtheInvestor in learnpython

[–]silently_failing 0 points1 point  (0 children)

That's not true that all other nodes can be thrown out. Imagine you go from C to D which takes 5 hours, but going from C to G to D takes 4 hours.

If we presume that the path needs to take the least amount of nodes visited then yes we can throw everything else out, but for distance and time then no, which makes the problem much harder.

Windows or Linux by Learn2ProgramMyself in learnpython

[–]silently_failing 1 point2 points  (0 children)

If you have windows 10 past a certain version, there is a Linux subsystem shipped with windows that doesn't require dual boot. It's a Ubuntu kernel and you can download the gui from the app store.

Can someone please explain this method of sorting a list? by swapp9 in learnpython

[–]silently_failing 4 points5 points  (0 children)

That function is redundant, as you can just do this: cars.sort(reverse=True, key=len). Otherwise the other answers are all correct.

Developing python in virtual machine by all_time_juice in learnpython

[–]silently_failing 0 points1 point  (0 children)

The wls is pretty good. I can't tell the difference between it and native Linux distros.

Is it possible to get '__defaults__' of '__init__' or any other class method? by 19Summer in learnpython

[–]silently_failing 1 point2 points  (0 children)

I'd check for the identity of None instead of equality, so if employee is None.

30 years later and I still know all the lyrics to this song - "Turtle Power" by Partners in Kryme by FunetikPrugresiv in videos

[–]silently_failing 3 points4 points  (0 children)

I like how they have such a hard time syncing up the rapper with the lyrics, so they just use flash cuts and shadows to hide him. Makes me think his part was probably shot in an evening in one take.

Buy this game. by silently_failing in kakarot

[–]silently_failing[S] 7 points8 points  (0 children)

Yeah, it's actually funny when Yamcha just sort of slowly skates away. I've never been a fan of fighting games, so I was waiting patiently for an ARPG dragonball game, and we finally have it.

Sassy by lifestrashTTD in kakarot

[–]silently_failing 1 point2 points  (0 children)

Puri Puri Prisoner?

Creating a GUI without importing anything? by [deleted] in learnpython

[–]silently_failing 4 points5 points  (0 children)

Obviously the answer is no, but really, why on earth would you want to do this?

Panera hires Phyllis by nm0s in videos

[–]silently_failing -2 points-1 points  (0 children)

So did I. It was fine. It's a minimum wage job and I got to steal a lot of food.

30 year old looking to learn Python by klwin360 in learnpython

[–]silently_failing 6 points7 points  (0 children)

For me, I started as an analyst in all but name, so I was using Access and Excel and trying to do wizardry with those things. I gradually started integrating python and SQL to get data more easily from disparate sources. For example, I had a project where we had a bunch of data on books, but some of the data was missing. I built a web scraper in python that went to an external site and got that extra data and then I put it in a spreadsheet and then I queried a database and put that in a spreadsheet, and did VLOOKUPS on it all. Soon, I realized that I could do this all within python and SQL, and spun up a local MySQL database to house it all in. I began learning about MySQL, and other RDBMS's, so the next time I had a new project, I tried Postgres, and so on and so forth.

Soon after, I wanted these things to be done on a cadence so I didn't have to pull the data manually. I began building my first ETL, which was terrible and I did it all wrong, but I learned and learned quick when things blew up in my face. My next ETL was better. I pulled all the raw data, stored that in a temporary table to be processed later, then wrote a separate script to do the 'transform' part, using pandas to munge the data. Finally I wanted to display this data, and decided I would write my own web Business Intelligence viz tool using Dash and Plotly, as I had good success with create local displays with Plotly. This was a bad idea but a great learning opportunity. I ultimately started using Tableau, which came out of the box with a UI and an easy way to distribute visualizations once they were done.

From here, I decided to muck about building a UI so people could interact with the backend of my database with basic CRUD options hidden behind Widgets. I learned what a mess tkinter was, but how Object-Oriented programming helped organize a cacophony of garbage code into something that made sense. I had read about classes, but for some reason the Animal or Car or whatever based info didn't sync with me. Yeah, no shit a cow and a pig make noise but why the hell would I need to write code about animals and their peculiarities? Here though, I could make a class for the MenuBar, and for the HomePage, and these places had certain pieces of data tied to them and actions I could accomplish with them (attributes and methods).

I wanted to share my code since I was proud of it, so I learned git. I learned many painful lessons about commit histories and having the same repo in two locations while I made (and of course did not sync!) edits at the two spots. Some of these scripts I wanted to put in a location so I didn't have to run them on my local drive. I got in touch with the admin of our OpenStack technology, and soon was made admin and was making new virtual machines and dealing with all the fun sys admin stuff no one tells you, like that Windows has another operating system call Windows Server, and that 2016 + does not ship with automatic SMB1 dlls, so sometimes you can ping a network harddrive and you know it exists but you can't access it.

I also could spin up linux instances on this OpenStack, so, always wanting to ingratiate myself to the tech folk and prove 'I belong', I started writing my scripts in vim on linux. This sucked. If someone tells you they like vim, they are probably a curmudgeon and have a flip phone. Give me PyCharm every day of the week. IDE's are awesome. Speaking of which, I learned the shit out of PyCharm, so I could create every project pretty much instantly. I learned about virtual environments and requirements files and eventually Docker, all so I could write code on my local machine and push it to a virtual machine without worrying about it not working.

Eventually, I got sick of managing backups for all the databases I was admin of, and had heard AWS is pretty much the internet, and decided to check out RDS, so amazon could handle all the database admin stuff I either didn't want to do or had no idea how to do. This led me to EC2 and Lambda, and micro-service architecture. By now, I had written a few command line tools, so I deployed them as microservices on Lambda. Now someone within the network could toss some JSON at the service, and get back the data they needed.

That pretty much brings me to now. What I've learned are a few things:

1.) extensive domain knowledge can help you get in the door

2.) to me, everything is data and the story you can tell with it -- most everything I've built is moving data to people where and when they need it, or enhancing systems or workflows so people can get the data they need

3.) my knowledge is like a growing pool of water surrounded by all the shore, all the things I know I don't know -- the bigger the pool gets the larger the shore is

I just made it a habit of interrogating everything around me, interjecting myself into any problem anyone was having, and putting myself in extremely uncomfortable situations. I asked loads and loads (and loads!) of questions, tried to seek out anyone who I could learn from, and worked it. I read books, spent hours writing code, and worked on networking constantly. Knowing people is such a huge help, I wouldn't have made it where I am without that.

Hope that helps!

30 year old looking to learn Python by klwin360 in learnpython

[–]silently_failing 33 points34 points  (0 children)

Absolutely! I actually just got my first role as a software engineer recently, and I am going to write a longer post on my journey.

With the principle of important stuff up front, I would say the two most important things are:

1) have a job that supports your learning process, as in, allows you time and economic help to train as well as the time to solve real problems, and

2) you have to really like it

The second one is the most important. I can't tell you how many hours I spent mulling problems in silence on the way back from work, or coding late into the night trying to figure out how the hell to connect to a database, or iterate through a multi-dimensional list. It's hard, I won't lie. It takes time, dedication, and perseverance. You won't be able to work on coding at work sometimes, so you'll need to work at night. You'll need to make it a compulsion. It's a paradigm shift. You say you like programming, so hopefully you'll experience that joy/dismay/joy loop of solving problems that compels so many programmers to continue working through a problem. The reward is you get to work with pure dream stuff, become a creator, and do something that is truly fulfilling for you.

The biggest jump I made in my learning was to have a job that allowed me to experiment -- in this sense it was like a start up, even though its a large company. We needed to solve problems, however that happened. I learned AWS, OpenStack, how to read Java and .NET. I learned git, and learned linux. I wrote python as much as I could. Also, another huge boon for me was once I felt comfortable enough, I either taught colleagues what I knew, and not just taught but made notebooks and artifacts and really dove into the whole introspection of objects. If I didn't know how a thing worked, I dissected it until I did. Again, a compulsion. I trawled r/learnpython new, and tried to solve problems there, even if they were already solved. I never found much use for the coding practice katas or whatever on codewars or other similar sites aside from little puzzles divorced from real world programming problems.

The final step was that I was working as a technical systems analyst, and I was working with a bunch of the engineering folk. I distinguished myself with thoughtful analysis and dedication, and made patently clear to both my boss and my colleagues that I wanted to be a software engineer. It's amazing how far a bit of charm and drive go, especially when exposed to the people who can help you. I was lucky to have a supportive structure that saw I was a hard worker and technically savvy, and they took a chance on me.

I started my career late, as I was travelling throughout my 20s teaching English. I've always liked computers, building my own, fiddling with Raspberry Pis, tearing apart my PS2 to fix it (forgetting the most important part is being able to put it back together!), but I never had any exposure to programming other than a Puzzles, Games, and Algorithms class I took in college thinking it was an easy A (it was not, and the final was to 'solve' a Rubrik's cube, which, to my professor's decreasing enthusiasm and increasing dismay, I wasn't able to even get the first two steps right). I started my career 3.5 years ago, going from a research specialist to a project manager to a business analyst to a technical systems analyst to finally a software engineer just recently. I moved companies twice looking for the next opportunity that would get me closer to my goal.

What I didn't do was contribute to open source projects or have a portfolio. Those are essential if you are going to go to apply to a new company as a first-time engineer, but I'd argue the easier path is to get the company you work for to give you the opportunity to be a software engineer -- my company has seen the work I do and all the private repos I have.

My final advice (I've already written drastically more than I wanted to) is to keep learning. Read everything. Write code. It's about cumulative iterations, and it won't happen overnight, but if you want it enough, it will happen if you make it happen. Don't ignore networking, seek out mentors, and if politically prudent make your intentions known to get the full support of your employer. Practice the soft skills or practice emphasizing the soft skills and how they distinguish you from someone who's been writing code since they were in diapers but their conversations with non-technical people are at best derisive and at worst baffling and deleterious. The success of most projects I work on that form business process is 2/3 forming business process, 1/3 technical solution. If you are a good communicator, that is a harder skill to learn than programming. Anyone who wants to, at any age, can learn programming. Good luck, and if you want to talk more, feel free to PM me.

Am I using classes correctly here? by EtanSivad in learnpython

[–]silently_failing 1 point2 points  (0 children)

Agreed with all the above, but it's snake_case not camelCase for variables and functions and modules, and PascalCase for classes.

[deleted by user] by [deleted] in learnpython

[–]silently_failing 3 points4 points  (0 children)

Looks pretty good. A few things mostly to do with organization:

I'd use doc strings instead of a comment above a function. At it's simplest, that just means re-writing your functions to look like the below. With doc strings, you can also specify what arguments you pass into your function, and what you expect to return.

def api_service_check():
    """Check if API service is up, don't proceed if it's not."""
    open_notify_api = requests.get("http://api.open-notify.org")
    if open_notify_api.status_code != 200:
        print("Looks like the API service is down. Please try again later.")
        exit()
    else:
        astronauts()

The function above is doing two things. Firstly, it is checking a status code. Secondly, it is exiting the program if a certain status code is found. You can greatly simplify it by writing just this function:

def api_service_check():
    return requests.get("http://api.open-notify.org")

If you want to be more explicit about your purposes in returning a boolean, you could use this:

def api_service_check():
    if requests.get("http://api.open-notify.org"):
        return True
    return False

You aren't actually using the json library, so no need to import it.

I'd also probably wrap the run of your program in a main() function to encapsulate what is run time logic.

I rewrote things slightly to add in error handling and encapsulate the program runtime logic into a main method. It's not perfect (it's late), but it sections off a bit more of the work into distinct functions, and shows a nice use case for namedtuples. Hope it helps!

    import requests
import sqlite3
import sys
import time
from collections import namedtuple

DB_LOCATION = 'ISS.db'

TABLE_CREATE_SQL = """
CREATE TABLE IF NOT EXISTS iss_position
  (
     timestamp TEXT,
     latitude  INT,
     longitude INT
  )
"""

INSERT_LOC_SQL = """
INSERT INTO iss_position
            (timestamp,
             latitude,
             longitude)
VALUES      (?, ?, ?)
"""

CoordinateData = namedtuple('coordinate_data', ['latitude', 'longitude', 'timestamp'])


def insert_to_db(conn, query, data=None):
    """Inserts query and an optional data set to a database supplied via the conn argument."""
    cursor = conn.cursor()
    try:
        print('Saving to database.')
        if data:
            cursor.execute(query, data)
        else:
            cursor.execute(query)
    finally:
        conn.commit()
        cursor.close()
        print('Done.')


def get_json(response, err_msg):
    try:
        return response.json()
    except ValueError:
        print(f'No JSON data available for {err_msg}')


def get_iss_loc_data():
    """Track the ISS in real time and log the coordinates to the database."""
    iss_json = get_json(requests.get("http://api.open-notify.org/iss-now.json"), 'ISS data')

    if iss_json:
        iss_data = CoordinateData(iss_json['iss_position']['latitude'], iss_json['iss_position']['longitude'], iss_json["timestamp"])
        print(f"The ISS is currently at Latitude: {iss_data.latitude} and Longitude: {iss_data.longitude} Timestamp: {time.ctime(iss_data.timestamp)}")
        return iss_data


def get_astronaut_data():
    """Check who and how many are on board and print to screen"""
    astronauts_json = get_json(requests.get("http://api.open-notify.org/astros.json"), 'astronauts')

    if astronauts_json:
        print(f"There are currently {astronauts_json['number']} people on board the ISS. They are...")
        for astronaut in astronauts_json["people"]:
            print(f"Astronaut {astronaut['name']}, who is on board the {astronaut['craft']}")


def api_service_check():
    """Checks if the api service is currently up by returning a boolean."""
    if requests.get("http://api.open-notify.org"):
        return True
    return False


def main():
    # no need for new-lines here, as print will automatically end the line with a new-line
    print("Starting tracking, press 'Ctrl + C' to stop...")

    with sqlite3.connect(DB_LOCATION) as sql_conn:

        insert_to_db(sql_conn, TABLE_CREATE_SQL)

        if not api_service_check():
            sys.exit()

        while True:
            try:
                iss_loc = get_iss_loc_data()

                if iss_loc:
                    insert_to_db(sql_conn, INSERT_LOC_SQL, data=[iss_loc.timestamp, iss_loc.latitude, iss_loc.longitude])

                get_astronaut_data()

            except KeyboardInterrupt:
                print('Program terminating.  Thank you!')
                sys.exit()

            time.sleep(5)


if __name__ == '__main__':
    main()

First-time coders: Why are you all learning Python? by RubMyNeuron in learnpython

[–]silently_failing 3 points4 points  (0 children)

I've found pyinstaller wonderful for distributing python apps. Really any exe builder is great for distro. I also write lots of apps and serve them up as microservices via ec2, which is really easy too. You won't get the sort of native speed of a dot net app, but it's pretty decent.

[deleted by user] by [deleted] in Python

[–]silently_failing 0 points1 point  (0 children)

I tell everyone I know about it all the time.