Mapytex/mapytex/calculus/core/random/str_gene.py

40 lines
715 B
Python

#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2017 lafrite <lafrite@Poivre>
#
# Distributed under terms of the MIT license.
"""
Function to create random strings
:example:
>>> form = "{a} / {b} + {c} / {k*b}"
>>> conditions = [
... "abs({b}) != 1",
... "{d} > 1",
... "{b} != {d}",
... "gcd({a},{b}) == 1",
... "gcd({c},{k*b}) == 1",
... ]
>>> #random_str(form, conditions)
>>> form = "{a:int}x + {b:fraction}"
>>> conditions = [
... "{b.denom} > 2",
... ]
>>> #random_str(form, conditions)
"""
import random
__all__ = []
# -----------------------------
# Reglages pour 'vim'
# vim:set autoindent expandtab tabstop=4 shiftwidth=4:
# cursor: 16 del