Participer au site avec un Tip
Rechercher
 

Améliorations / Corrections

Vous avez des améliorations (ou des corrections) à proposer pour ce document : je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.

Emplacement :

Description des améliorations :

Module « flask »

Classe « Markup »

Informations générales

Héritage

builtins.object
    builtins.str
        Markup

Définition

class Markup(builtins.str):

Description [extrait de Markup.__doc__]

A string that is ready to be safely inserted into an HTML or XML
    document, either because it was escaped or because it was marked
    safe.

    Passing an object to the constructor converts it to text and wraps
    it to mark it safe without escaping. To escape the text, use the
    :meth:`escape` class method instead.

    >>> Markup("Hello, <em>World</em>!")
    Markup('Hello, <em>World</em>!')
    >>> Markup(42)
    Markup('42')
    >>> Markup.escape("Hello, <em>World</em>!")
    Markup('Hello &lt;em&gt;World&lt;/em&gt;!')

    This implements the ``__html__()`` interface that some frameworks
    use. Passing an object that implements ``__html__()`` will wrap the
    output of that method, marking it safe.

    >>> class Foo:
    ...     def __html__(self):
    ...         return '<a href="/foo">foo</a>'
    ...
    >>> Markup(Foo())
    Markup('<a href="/foo">foo</a>')

    This is a subclass of :class:`str`. It has the same methods, but
    escapes their arguments and returns a ``Markup`` instance.

    >>> Markup("<em>%s</em>") % ("foo & bar",)
    Markup('<em>foo &amp; bar</em>')
    >>> Markup("<em>Hello</em> ") + "<foo>"
    Markup('<em>Hello</em> &lt;foo&gt;')
    

Constructeur(s)

Signature du constructeur Description
__new__(cls, base: Any = '', encoding: Optional[str] = None, errors: str = 'strict') -> 'Markup'
__init__(self, /, *args, **kwargs) Initialize self. See help(type(self)) for accurate signature. [extrait de __init__.__doc__]

Liste des opérateurs

Signature de l'opérateur Description
__add__(self, other: Union[str, ForwardRef('HasHTML')]) -> 'Markup'
__mod__(self, arg: Any) -> 'Markup'
__mul__(self, num: int) -> 'Markup'
__radd__(self, other: Union[str, ForwardRef('HasHTML')]) -> 'Markup'
__rmul__(self, num: int) -> 'Markup'

Opérateurs hérités de la classe str

__contains__, __eq__, __ge__, __getitem__, __gt__, __le__, __lt__, __ne__, __rmod__

Opérateurs hérités de la classe object

__eq__, __ge__, __gt__, __le__, __lt__, __ne__

Liste des méthodes

Toutes les méthodes Méthodes d'instance Méthodes statiques Méthodes dépréciées
Signature de la méthodeDescription
__html__(self) -> 'Markup'
__html_format__(self, format_spec: str) -> 'Markup'
__repr__(self) -> str
escape(s: Any) -> 'Markup' Escape a string. Calls :func:`escape` and ensures that for [extrait de escape.__doc__]
format(self, *args: Any, **kwargs: Any) -> 'Markup'
join(self, seq: Iterable[Union[str, ForwardRef('HasHTML')]]) -> 'Markup' Concatenate any number of strings. [extrait de join.__doc__]
partition(self, sep: str) -> Tuple[ForwardRef('Markup'), ForwardRef('Markup'), ForwardRef('Markup')]
rpartition(self, sep: str) -> Tuple[ForwardRef('Markup'), ForwardRef('Markup'), ForwardRef('Markup')]
rsplit(self, sep: Optional[str] = None, maxsplit: int = -1) -> List[ForwardRef('Markup')] Return a list of the words in the string, using sep as the delimiter string. [extrait de rsplit.__doc__]
split(self, sep: Optional[str] = None, maxsplit: int = -1) -> List[ForwardRef('Markup')] Return a list of the words in the string, using sep as the delimiter string. [extrait de split.__doc__]
splitlines(self, keepends: bool = False) -> List[ForwardRef('Markup')] Return a list of the lines in the string, breaking at line boundaries. [extrait de splitlines.__doc__]
striptags(self) -> str :meth:`unescape` the markup, remove tags, and normalize [extrait de striptags.__doc__]
unescape(self) -> str Convert escaped markup back into a text string. This replaces [extrait de unescape.__doc__]

Méthodes héritées de la classe str

__format__, __getattribute__, __getnewargs__, __hash__, __init_subclass__, __iter__, __len__, __sizeof__, __str__, __subclasshook__, capitalize, casefold, center, count, encode, endswith, expandtabs, find, format_map, index, isalnum, isalpha, isascii, isdecimal, isdigit, isidentifier, islower, isnumeric, isprintable, isspace, istitle, isupper, ljust, lower, lstrip, maketrans, removeprefix, removesuffix, replace, rfind, rindex, rjust, rstrip, startswith, strip, swapcase, title, translate, upper, zfill

Méthodes héritées de la classe object

__delattr__, __dir__, __format__, __getattribute__, __hash__, __init_subclass__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__, __subclasshook__