Atom and Pycharm

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
sayhello_to_the_world
Posts: 77
Joined: Mon 24 Dec 2012, 15:19

Atom and Pycharm

#1 Post by sayhello_to_the_world »

well i have two IDE up and running


well since it is fairly easy to start the script in pycharm i think that atom is a bit more tricky.



there is no option to start /& run the code... or did i miss it!?

Code: Select all


#!/usr/bin/env python3
"""
contacts.py
This program uses a Person class to keep track of contacts.
"""

class Person(object):
    """
    The Person class defines a person in terms of a
    name, phone number, and email address.
    """
    # Constructor
    def __init__(self, theName, thePhone, theEmail):
        self.name = theName
        self.phone = thePhone
        self.email = theEmail
    # Accesser Methods (getters)
    def getName(self):
        return self.name
    def getPhone(self):
        return self.phone
    def getEmail(self):
        return self.email
    # Mutator Methods (setters)
    def setPhone(self, newPhoneNumber):
        self.phone = newPhoneNumber
    def setEmail(self, newEmailAddress):
        self.email = newEmailAddress
    def __str__(self):
        return "Person[name=" + self.name + \
               ",phone=" + self.phone + \
               ",email=" + self.email + \
               "]"

def enter_a_friend():
    name = input("Enter friend's name: ")
    phone = input("Enter phone number: ")
    email = input("Enter email address: ")
    return Person(name, phone, email)

def lookup_a_friend(friends):
    found = False
    name = input("Enter name to lookup: ")
    for friend in friends:
        if name in friend.getName():
            print(friend)
            found = True
    if not found:
        print("No friends match that term")

def show_all_friends(friends):
    print("Showing all contacts:")
    for friend in friends:
        print(friend)

def main():
    friends = []
    running = True
    while running:
        print("\nContacts Manager")
        print("1) new contact    2) lookup")
        print("3) show all       4) end ")
        option = input("> ")
        if option == "1":
            friends.append(enter_a_friend())
        elif option == "2":
            lookup_a_friend(friends)
        elif option == "3":
            show_all_friends(friends)
        elif option == "4":
            running = False
        else:
            print("Unrecognized input. Please try again.")
    print("Program ending.")

if __name__ == "__main__":
    main() 

User avatar
bpuppy
Posts: 14
Joined: Tue 25 Apr 2017, 13:03
Location: Quebec

#2 Post by bpuppy »

@sayhello_to_the_world

Don't know about pycharm though i know it is for big python projects.
I used your script in Thonny and it works just great.

Thonny is for testing parts of code or python v.3 scripts.
I just love it. :P

Post Reply