Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

The amount of weight an evangelist carries with the almighty is measured in billigrahams.


devel / comp.lang.python / code to initialize a sequence

SubjectAuthor
o code to initialize a sequencejoseph pareti

1
code to initialize a sequence

<mailman.497.1630262707.4164.python-list@python.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=19207&group=comp.lang.python#19207

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: joepareti54@gmail.com (joseph pareti)
Newsgroups: comp.lang.python
Subject: code to initialize a sequence
Date: Sun, 29 Aug 2021 20:44:53 +0200
Lines: 54
Message-ID: <mailman.497.1630262707.4164.python-list@python.org>
References: <CAN_spzhca96fw_sxO7mKRUdPQ6_t1vCEpWyqasffLniUT_OjBQ@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de K4B6V7zjAkJ8AsFViUq7oAz/OxUBV7+txMbm1eaQEL0w==
Return-Path: <joepareti54@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=qRb8knxM;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.006
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'def': 0.04; 'knows': 0.04;
'joseph': 0.05; 'random': 0.05; '1600': 0.09; '797': 0.09;
'identical': 0.09; 'import': 0.14; '+39': 0.16; '0644': 0.16;
'209cell': 0.16; 'from:addr:joepareti54': 0.16; 'from:name:joseph
pareti': 0.16; 'pareti': 0.16; "pareti's": 0.16; 'subject:code':
0.16; 'url-ip:52.48/16': 0.16; 'url:joepareti54-ai': 0.16;
'python': 0.16; 'to:addr:python-list': 0.23; 'code': 0.24; 'skip:p
30': 0.26; 'length': 0.27; 'else': 0.27; 'there': 0.31; 'code,':
0.31; 'but': 0.31; 'expect': 0.31; 'to:name:python': 0.32;
'message-id:@mail.gmail.com': 0.33; 'program': 0.33; 'work.':
0.33; 'same': 0.34; 'received:google.com': 0.34;
'from:addr:gmail.com': 0.35; 'cell': 0.37; 'way': 0.37;
'received:209.85': 0.38; 'received:209': 0.38; 'use': 0.38;
'does': 0.38; 'main': 0.40; 'skip:\xc2 10': 0.62; 'services':
0.63; 'consulting': 0.63; 'gives': 0.63; '\xc2\xa0\xc2\xa0': 0.63;
'attached': 0.68; 'consultant': 0.74; '8bit%:100': 0.75;
'sequence.': 0.84; '\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0': 0.84;
'\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0\xc2\xa0': 0.84; 'somebody': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
h=mime-version:from:date:message-id:subject:to;
bh=KyAYS4fWMl10i1IlfEhdIMlN1G13csCogAPDsSV3U1Q=;
b=qRb8knxMus83D+B1qeifgipb6trVx31iCMGKiubyi19I5ckWj2YqQwlTJJa4R0Hrfj
gZ4J1Nmu9TeDNWw+SlGy+/pnmDsGyilKNp/rzxRgJQzCPNgKFoz/WlBFAaqjagy+ZAvh
Ip3iSQxHJ6xec1/6w/tpyGltOiC69zdN9Lr3tFJ88OoiCqx1NWoUkc5lQAsXFpiiRV/a
PNSBuoT7Q8sbKLkFFIuPe3hja6NQ/DmZKZZN4SJ9oHQ+Eptrjj13xRcLmUEHKuyZSqC8
1nq7DCqTLRg4fba62TAN30GEh5moQBK7xmshf+8ubdQRYXBqlXyVWiFo0a3LEaba3STw
8hxg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20161025;
h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
bh=KyAYS4fWMl10i1IlfEhdIMlN1G13csCogAPDsSV3U1Q=;
b=Qif1nDcqEkrwL26iSvBxAWkQg2IFiHZctqCpFJiwgGDxSqmjlf8buu0zXHFCxwMvXw
F0D7urRK+NaWtjqQPI8Bwvov/F84avtbrx7F8jWxqw5nzYxxBOO2y81lIAjtZzjHBFLU
vZT3Ei4trOnfz9rqoBY6YYIlh6Xr2g+9a73RM5YtCBfmn1pMjMFpGFs4fgWddafyvCfu
p53lQZdy2m3nKhHOPzvD3wuLSc1ZgdDRLFi+VgpnkTHYIQMQW7TZFEsK9N6x/Ec0XA+r
nQIt2qz3mPwqs9/k8PGkKoMGDfzuUyLybGOOjvmEOyPcHRzU6td758g08O24yi2aX72b
I12g==
X-Gm-Message-State: AOAM531hrZZ3lPmX79nNl05UHQKXLbM7a1yy+RTUMbBfEkjPxD3gwlk+
7gEBz1zmGLXUBxHHua7CWeoHXO4WOwXEJux/BloWoUuP2lRo9LJj
X-Google-Smtp-Source: ABdhPJyugJlO05T5yM7R2vYFv9McbQ6Vs4w73CAeO0SA9VGJwQoJhblHY2UHKCgxnwj4w3gWWSdrZzXBJSy3CuK94bM=
X-Received: by 2002:a17:906:3809:: with SMTP id
v9mr21682965ejc.355.1630262704109;
Sun, 29 Aug 2021 11:45:04 -0700 (PDT)
X-Content-Filtered-By: Mailman/MimeDel 2.1.34
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.34
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <CAN_spzhca96fw_sxO7mKRUdPQ6_t1vCEpWyqasffLniUT_OjBQ@mail.gmail.com>
 by: joseph pareti - Sun, 29 Aug 2021 18:44 UTC

In the code attached below, the A-variant is from somebody else who knows
Python better than I. But I do not like to just use any code without having
a grasp, specifically the line in* bold*, so I wrote the B-variant which
gives the same results. The C-variant is identical to A and is there for
verification: after resetting the seed I expect the same sequence. The
D-variant is closer to the way I code, and it does not work.

import random
from random import randint, seed

def generate_sequence(length, n_unique):
*return [randint(0, n_unique-1) for k in range(length)]*

def generate_sequence_JP(length, n_unique):
LI = []
for k in range(length):
LI.append(randint(0, n_unique-1))
return(LI)
def generate_sequence_EXPLICIT(length, n_unique):
X =[None] * length
for i in range(length):
X[i] = [randint(0, n_unique-1)]
return X
# # MAIN PROGRAM
# random.seed(2)
A = generate_sequence(4, 10 )
random.seed(2)
B = generate_sequence_JP(4, 10)
random.seed(2)
C = generate_sequence(4, 10 )
random.seed(2)
D = generate_sequence_EXPLICIT(4, 10 )
print(A)
print(type(A))
print('-----------------------------')
print(B)
print(type(B))
print('-----------------------------')
print(C)
print(type(C))
print('-----------------------------')
print(D)
print(type(D))

Regards,
Joseph Pareti - Artificial Intelligence consultant
Joseph Pareti's AI Consulting Services
https://www.joepareti54-ai.com/
cell +49 1520 1600 209
cell +39 339 797 0644


devel / comp.lang.python / code to initialize a sequence

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor