Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > de.comp.lang.python > #5693
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Stefan Fuhrmann <stefan@fuhrmann.homedns.org> |
| Newsgroups | de.comp.lang.python |
| Subject | [Python-de] function als value in einem dict |
| Date | Sat, 10 Oct 2020 12:10:00 +0200 |
| Lines | 53 |
| Message-ID | <mailman.1290.1602324605.9580.python-de@python.org> (permalink) |
| References | <e2b40afb-97c2-79c3-e1cf-42605612c251@fuhrmann.homedns.org> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8; format=flowed |
| Content-Transfer-Encoding | 8bit |
| X-Trace | news.uni-berlin.de pba8RWX7m9eb7VWQsn21ZAA9WWp9Qv7Q4qYlS10iSvPQ== |
| Return-Path | <stefan@fuhrmann.homedns.org> |
| X-Original-To | python-de@python.org |
| Delivered-To | python-de@mail.python.org |
| Authentication-Results | mail.python.org; dkim=none reason="no signature"; dkim-adsp=none (unprotected policy); dkim-atps=neutral |
| X-Virus-Scanned | Debian amavisd-new at willy.nopanicsystems.net |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 |
| Content-Language | en-US |
| X-BeenThere | python-de@python.org |
| X-Mailman-Version | 2.1.34 |
| Precedence | list |
| List-Id | Die Deutsche Python Mailingliste <python-de.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-de>, <mailto:python-de-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-de/> |
| List-Post | <mailto:python-de@python.org> |
| List-Help | <mailto:python-de-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-de>, <mailto:python-de-request@python.org?subject=subscribe> |
| X-Mailman-Original-Message-ID | <e2b40afb-97c2-79c3-e1cf-42605612c251@fuhrmann.homedns.org> |
| Xref | csiph.com de.comp.lang.python:5693 |
Show key headers only | View raw
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