Sujet : Re: Checking That Two Args Are Of Same Type (Posting On Python-List Prohibited)
De : no.email (at) *nospam* nospam.invalid (Paul Rubin)
Groupes : comp.lang.pythonDate : 23. Jun 2024, 09:00:29
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <871q4ota7m.fsf@nightsong.com>
References : 1
User-Agent : Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Lawrence D'Oliveiro <
ldo@nz.invalid> writes:
Consider a function taking two args “a” and “b”, which can be of str,
bytes or bytearray type, just so long as both are of the same type.
One easy way to test this is
if type(a)==type(b) and type(a) in (str, bytes, bytearray): ...