Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > de.comp.lang.python > #5693
| From | Stefan Fuhrmann <stefan@fuhrmann.homedns.org> |
|---|---|
| Newsgroups | de.comp.lang.python |
| Subject | [Python-de] function als value in einem dict |
| Date | 2020-10-10 12:10 +0200 |
| Message-ID | <mailman.1290.1602324605.9580.python-de@python.org> (permalink) |
| References | <e2b40afb-97c2-79c3-e1cf-42605612c251@fuhrmann.homedns.org> |
Hallo zusammen,
leider finde ich nichts, wie ich einen passwort generator, als value in
einem dict aufrufen kann.
Geht das überhaupt?
##### password_generator ############
18 #def generator_pw():
19 # pwd = string.ascii_letters + string.digits + string.punctuation
20 # return "".join(random.choice(pwd) for x in
range(random.randint(1, 13)))
21
22 #print(generator_pw())
23
24 #####################################
25
26
27 with open('docker-compose.yml', "r") as f:
28 docker_compose = yaml.full_load(f)
29
30 def generator_pw():
31 pwd = string.ascii_letters + string.digits + string.punctuation
32 return "".join(random.choice(pwd) for x in
range(random.randint(1, 13)))
33
34 print(generator_pw())
35
36 # docker_compose["services"]["db"]["environment"] =
dict(MYSQL_ROOT_PASSWORD= "passingTest")
37 docker_compose["services"]["db"]["environment"] =
dict(MYSQL_ROOT_PASSWORD= generator_pw)
38
39 with open('docker-compose.yml', "w") as f:
40 yaml.dump(docker_compose, f)
momentan wird in der yaml "null" geliefert.
Was ist hier die richtige Vorgehensweise?
Kann jemand helfen?
Danke!
Gruß
Stefan
Back to de.comp.lang.python | Previous | Next | Find similar
[Python-de] function als value in einem dict Stefan Fuhrmann <stefan@fuhrmann.homedns.org> - 2020-10-10 12:10 +0200
csiph-web