CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-mimesis

Mimesis is a robust fake data generator for Python that produces realistic fake data across 35 different locales with high performance and multilingual support.

Pending
Overview
Eval results
Files

location-data.mddocs/

Location and Address Data

Generate geographical and address information including streets, cities, countries, coordinates, and postal codes with locale-appropriate formatting and realistic regional data.

Capabilities

Street and Address Generation

Generate street-level address components with proper formatting for different locales.

class Address(BaseDataProvider):
    def street_number(self, maximum: int = 1400) -> str:
        """
        Generate a street number.
        
        Parameters:
        - maximum (int): Maximum street number value
        
        Returns:
        str: Street number like "123"
        """
    
    def street_name(self) -> str:
        """
        Generate a street name appropriate for the locale.
        
        Returns:
        str: Street name like "Main Street", "Oak Avenue"
        """
    
    def street_suffix(self) -> str:
        """
        Generate a street suffix/type.
        
        Returns:
        str: Street suffix like "Street", "Avenue", "Boulevard"
        """
    
    def address(self) -> str:
        """
        Generate a complete street address.
        
        Returns:
        str: Full address like "123 Main Street"
        """

Administrative Divisions

Generate administrative region data like states, provinces, and regions.

class Address(BaseDataProvider):
    def state(self, abbr: bool = False) -> str:
        """
        Generate a state name or abbreviation.
        
        Parameters:
        - abbr (bool): Return abbreviation if True
        
        Returns:
        str: State like "California" or "CA"
        """
    
    def region(self) -> str:
        """
        Alias for state().
        
        Returns:
        str: Region/state name
        """
    
    def province(self) -> str:
        """
        Alias for state().
        
        Returns:
        str: Province name
        """

Cities and Postal Information

Generate city names and postal codes appropriate for the locale.

class Address(BaseDataProvider):
    def city(self) -> str:
        """
        Generate a city name appropriate for the locale.
        
        Returns:
        str: City name like "New York", "London", "Tokyo"
        """
    
    def postal_code(self) -> str:
        """
        Generate a postal code in the locale's format.
        
        Returns:
        str: Postal code like "12345", "SW1A 1AA", "1010"
        """
    
    def zip_code(self) -> str:
        """
        Alias for postal_code().
        
        Returns:
        str: ZIP/postal code
        """

Countries and Territories

Generate country information with various formatting options.

class Address(BaseDataProvider):
    def country(self) -> str:
        """
        Generate a country name.
        
        Returns:
        str: Country name like "United States", "Germany"
        """
    
    def country_code(self, code: CountryCode = CountryCode.A2) -> str:
        """
        Generate a country code in various formats.
        
        Parameters:
        - code (CountryCode): Format type (A2, A3, or NUMERIC)
        
        Returns:
        str: Country code like "US", "USA", or "840"
        
        Usage:
        ```python
        address.country_code(CountryCode.A2)      # "US"
        address.country_code(CountryCode.A3)      # "USA"
        address.country_code(CountryCode.NUMERIC) # "840"
        ```
        """

Geographic Coordinates

Generate latitude, longitude, and coordinate data with various formatting options.

class Address(BaseDataProvider):
    def latitude(self, dms: bool = False) -> Union[float, str]:
        """
        Generate latitude coordinates.
        
        Parameters:
        - dms (bool): Return in Degrees-Minutes-Seconds format if True
        
        Returns:
        float or str: Latitude like 40.7128 or "40°42'46.1\"N"
        """
    
    def longitude(self, dms: bool = False) -> Union[float, str]:
        """
        Generate longitude coordinates.
        
        Parameters:
        - dms (bool): Return in Degrees-Minutes-Seconds format if True
        
        Returns:
        float or str: Longitude like -74.0060 or "74°0'21.6\"W"
        """
    
    def coordinates(self, dms: bool = False) -> dict:
        """
        Generate latitude and longitude pair.
        
        Parameters:
        - dms (bool): Return in Degrees-Minutes-Seconds format if True
        
        Returns:
        dict: Coordinates like {"latitude": 40.7128, "longitude": -74.0060}
        """

Continental and Regional Data

Generate continent names and international calling codes.

class Address(BaseDataProvider):
    def continent(self, code: bool = False) -> str:
        """
        Generate a continent name or code.
        
        Parameters:
        - code (bool): Return continent code if True
        
        Returns:
        str: Continent like "North America" or "NA"
        """
    
    def calling_code(self) -> str:
        """
        Generate an international calling code.
        
        Returns:
        str: Calling code like "+1", "+44", "+81"
        """

Usage Examples

Basic Address Generation

from mimesis import Address
from mimesis.locales import Locale

address = Address(Locale.EN_US)

# Generate complete address
full_address = {
    'street': address.address(),
    'city': address.city(),
    'state': address.state(),
    'postal_code': address.postal_code(),
    'country': address.country()
}
# Result: {'street': '123 Oak Street', 'city': 'New York', ...}

Localized Address Formats

from mimesis import Address
from mimesis.locales import Locale

# Different locales produce appropriate formats
address_us = Address(Locale.EN_US)
address_uk = Address(Locale.EN_GB)
address_de = Address(Locale.DE)

us_postal = address_us.postal_code()  # "12345"
uk_postal = address_uk.postal_code()  # "SW1A 1AA"
de_postal = address_de.postal_code()  # "10115"

Geographic Coordinates

from mimesis import Address

address = Address()

# Decimal coordinates
lat_decimal = address.latitude()      # 40.7128
lng_decimal = address.longitude()     # -74.0060

# Degrees-Minutes-Seconds format
lat_dms = address.latitude(dms=True)  # "40°42'46.1\"N"
lng_dms = address.longitude(dms=True) # "74°0'21.6\"W"

# Coordinate pair
coords = address.coordinates()        # {"latitude": 40.7128, "longitude": -74.0060}
coords_dms = address.coordinates(dms=True)  # DMS format pair

Country Information

from mimesis import Address
from mimesis.enums import CountryCode

address = Address()

# Different country code formats
country_name = address.country()                           # "United States"
country_a2 = address.country_code(CountryCode.A2)        # "US"
country_a3 = address.country_code(CountryCode.A3)        # "USA"
country_numeric = address.country_code(CountryCode.NUMERIC) # "840"

# Calling code
calling_code = address.calling_code()  # "+1"

Address Variations

from mimesis import Address

address = Address(Locale.EN_US)

# State formats
state_full = address.state(abbr=False)  # "California"
state_abbr = address.state(abbr=True)   # "CA"

# Continental information
continent_name = address.continent(code=False)  # "North America"
continent_code = address.continent(code=True)   # "NA"

Complete Location Profile

from mimesis import Address
from mimesis.enums import CountryCode

def generate_location_profile(locale: Locale):
    address = Address(locale)
    
    return {
        'address': {
            'street': address.address(),
            'city': address.city(),
            'state': address.state(),
            'postal_code': address.postal_code(),
        },
        'country': {
            'name': address.country(),
            'code_a2': address.country_code(CountryCode.A2),
            'code_a3': address.country_code(CountryCode.A3),
            'calling_code': address.calling_code(),
        },
        'coordinates': address.coordinates(),
        'coordinates_dms': address.coordinates(dms=True),
        'continent': {
            'name': address.continent(),
            'code': address.continent(code=True),
        }
    }

# Generate profiles for different regions
us_location = generate_location_profile(Locale.EN_US)
uk_location = generate_location_profile(Locale.EN_GB)
jp_location = generate_location_profile(Locale.JA)

Bulk Address Generation

from mimesis import Address

address = Address(Locale.EN_US)

# Generate multiple addresses
addresses = []
for _ in range(10):
    addr = {
        'id': len(addresses) + 1,
        'street_number': address.street_number(),
        'street_name': address.street_name(),
        'street_suffix': address.street_suffix(),
        'city': address.city(),
        'state': address.state(abbr=True),
        'postal_code': address.postal_code(),
        'coordinates': address.coordinates()
    }
    addresses.append(addr)

Install with Tessl CLI

npx tessl i tessl/pypi-mimesis

docs

configuration.md

core-providers.md

datetime.md

financial-data.md

index.md

internet-data.md

location-data.md

personal-data.md

schema.md

specialized-providers.md

text-content.md

tile.json