Selenium + Python · Lesson 7 of 43
Module 7: Modules & Packages
Your task
Implement safe_convert_price(raw_price: str) -> float:
Write it in the editor, then press Check answer (Ctrl + Enter).
# Reusable helper module: utils/string_helper.py
def clean_currency(raw_price: str) -> float:
return float(raw_price.replace("$", "").strip())
# Importing in page or test files:
from utils.string_helper import clean_currency
import datetime as dt
price = clean_currency(" $49.99 ")Organizing automation suites into clean modules and packages ensures easy imports and zero circular dependency issues. In this lesson, you will master import, from ... import, aliases, and __init__.py. Let's organize our modules!
Part of the Selenium + Python course (Selenium with Python). Practice this concept live in the Selenium Online Compiler or explore our free automation practice form.
__init__.py signals to Python that the folder is a package, allowing other test files to import modules from that folder cleanly.
Ready? Solve the task in the editor
Use Check answer to mark it complete. Hints are there if you need them.
___