Как вызвать функцию класса из другого файла на python
У меня есть файл parser.py
import requests
from bs4 import BeautifulSoup
import time
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
class Currency:
url = 'юрл для сокращения'
headers = {
'юзер агент'}
diferent = 1
compare_currency = 0
# init
def __init__(self):
self.compare_currency = float(self.get_currency())
# get currency bitcoin
def get_currency(self):
full_page = requests.get(self.url, headers=self.headers)
soup = BeautifulSoup(full_page.content, 'html.parser')
convert = soup.findAll(
"span", {"class": "DFlfde SwHCTb"})
return (convert[0].text).replace(",", "")
# compare and conclusion
def check_currency(self):
price = float(self.get_currency())
if price >= self.compare_currency + self.diferent:
print("Цена биткоина выросла, можно отдыхать.")
self.send_mail()
elif price <= self.compare_currency - self.diferent:
print("Цена упала надо что-то делать!")
self.send_mail()
print("Сейчас курс биткоина= " + str(price))
time.sleep(3)
self.check_currency()
и пустой файл bot.py. Так вот я не понимаю как вызвать функцию check_currency через файл bot.py. Попытался сделать так
import parser
s = Currency()
s.check_currency()
но выдаёт ошибку NameError: name 'Currency' is not defined