0

I am trying to write a python program, and trying to learn classes. My program is as follows:

class Account():
    def __init__(self, name, account_number, initial_amount, transactions):
        self.name = name
        self.no = account_number
        self.balance = initial_amount
        self.transactions = 0

    def deposit(self, amount):
        self.balance += amount
        self.transactions += 1

    def withdraw(self, amount):
        self.balance -= amount
        self.transactions += 1

    def dump(self):
        s = '$s, %s, balance: %s, number of transactions: %s' %\
             (self.name, self.no, self.balance, self.transactions) 
        print s 

In terminal, when i am in the folder the python program is located, I try to write from classes import Account to test my program, but the error code I get is: from: can't read /var/mail/classes. What does this mean, and how do I fix it?

1 Answers1

1

You should not run python from the python program folder. Instead, you should launch python from the same directory where your code is located.

The from classes import Account will first look for a file named classes.py in your working folder. Then it will look through the other python paths.

Joe
  • 2,496
  • 1
  • 22
  • 30