Faker-Edu
Faker-Edu is a provider for the Faker library, extending its capabilities to generate fake information related to educational institutions and academics. It's currently at version 1.1.0 and has a moderate release cadence, focusing on adding new generators. It's designed to be used in conjunction with the main Faker library for data generation in testing and development.
Common errors
-
AttributeError: 'Generator' object has no attribute 'high_school'
cause The faker-edu provider has not been added to the Faker instance.fixAdd the provider using `fake.add_provider(EduProvider)` after initializing your `Faker` object. -
ModuleNotFoundError: No module named 'faker_edu'
cause The `faker-edu` library is not installed in your current Python environment.fixInstall the package: `pip install faker-edu`. -
ModuleNotFoundError: No module named 'faker'
cause The base `faker` library, which `faker-edu` depends on, is not installed.fixInstall the base Faker library: `pip install faker`.
Warnings
- gotcha After installing 'faker-edu', you must explicitly add its 'Provider' class to your Faker instance using `fake.add_provider()`.
- gotcha Ensure you have the base 'faker' library installed. 'faker-edu' is a provider and depends on 'faker' to function.
Install
-
pip install faker-edu
Imports
- Provider
from faker_edu.provider import EduProvider
from faker_edu import Provider as EduProvider
- Faker
from faker import Faker
Quickstart
from faker import Faker
from faker_edu import Provider as EduProvider
# Initialize Faker
fake = Faker()
# Add the Faker-Edu provider
fake.add_provider(EduProvider)
# Generate fake educational data
print(f"High School: {fake.high_school()}")
print(f"College: {fake.college()}")
print(f"Academic Discipline: {fake.academic_discipline()}")
print(f"Facility: {fake.facility()}")
print(f"Sport: {fake.sport()}")