DEV Community

Cover image for Building a basic Python todo app and pushing on GitHub
Osahenru
Osahenru

Posted on

Building a basic Python todo app and pushing on GitHub

Hello guys,
to conclude what we have been on for a couple of days now, here is a blog post I have prepared for you that you can always reflect back on, you can check out the whole code on github [here].

In this article we will:

  1. Complete the todo app we started by adding a users class to it and then push to GitHub
  2. Go through basic git commands

here is a snippet of the previous code

class Task():
    def __init__(self, title):
        self.name = title
        self.description = ""
        self.is_completed = False
Enter fullscreen mode Exit fullscreen mode

to extend the code to accommodate a user, we will create a User class and initialize with a name for each instance of the User object

class User():
    def __init__(self, name):
        self.name = name
        self.tasks = []
Enter fullscreen mode Exit fullscreen mode

we want to also add more functionality to the app by allowing a user to be able to add tasks, delete tasks and view task
so an updated main.py file will look like this

class User():
    def __init__(self, name):
        self.name = name
        self.tasks = []


    def add_task(self, task):
        self.tasks.append(task)


    def delete_task(self, task):
        if task in self.tasks:
            self.tasks.remove(task)


    def display_tasks(self):
        print("Username: ", self.name)
        for task in self.tasks:
            print("Title", task.title)
            print("Description", task.description)
            print("Completed", task.is_completed)
            print()



class Task():
    def __init__(self, title):
        self.name = title
        self.description = ""
        self.is_completed = False
Enter fullscreen mode Exit fullscreen mode

PUSHING TO GITHUB

It is expected the project has been cloned with git clone and is resting on your local machine, here is a link to repo to clone from

after copying the contents of main.py with git status you can see the current status of your repo

screenshot of the terminal

Next, we add out implementation to git with the command git add main.py and to commit the changes you have made run the command
git commit -m “created a user model for each task object”

run git status again to be sure you changes were added and committed

and to finally push to github we run the command
git push

viola an updated project should be sitting on the repo from which you cloned from.

for questions and comments you can contact me via mail timosahenru@gmail.com

Top comments (0)