From 2f9cc7ab0c5e4c240b7412af2e33d086cd900077 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Wed, 31 Aug 2016 23:00:32 -0700 Subject: [PATCH] Minor beautification (turn nested-if into a conjunction). --- Lib/random.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Lib/random.py b/Lib/random.py index 0178693ba93..13e115a8f41 100644 --- a/Lib/random.py +++ b/Lib/random.py @@ -119,12 +119,11 @@ def seed(self, a=None, version=2): x ^= len(a) a = -2 if x == -1 else x - if version == 2: - if isinstance(a, (str, bytes, bytearray)): - if isinstance(a, str): - a = a.encode() - a += _sha512(a).digest() - a = int.from_bytes(a, 'big') + if version == 2 and isinstance(a, (str, bytes, bytearray)): + if isinstance(a, str): + a = a.encode() + a += _sha512(a).digest() + a = int.from_bytes(a, 'big') super().seed(a) self.gauss_next = None