python: Use list comprehension in string_to_byte_array()
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Wed, 12 Oct 2022 00:56:19 +0000 (13:56 +1300)
committerDouglas Bagnall <dbagnall@samba.org>
Fri, 21 Oct 2022 03:57:33 +0000 (03:57 +0000)
Samba is now a mature user of Python and can cope with a
list comprehension from time to time.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
python/samba/__init__.py

index ec540a61521916ec287a9eb7a02af568e9661cc6..54c67fed2331a5b341ab539bb34700ade4ea6a6f 100644 (file)
@@ -334,12 +334,7 @@ def current_unix_time():
 
 
 def string_to_byte_array(string):
-    blob = [0] * len(string)
-
-    for i in range(len(string)):
-        blob[i] = string[i] if isinstance(string[i], int) else ord(string[i])
-
-    return blob
+    return [c if isinstance(c, int) else ord(c) for c in string]
 
 
 def arcfour_encrypt(key, data):