function als value in einem dict

Stefan Fuhrmann <[email protected]>
Newsgroups gmane.comp.python.general.german
Message-ID <[email protected]>
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


_______________________________________________
python-de maillist  -  [email protected]
https://mail.python.org/mailman/listinfo/python-de
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.