Skip to content

Commit

Permalink
TR updates, first round
Browse files Browse the repository at this point in the history
  • Loading branch information
lpozo committed Nov 26, 2024
1 parent eaae842 commit 75c5f15
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions python-dicts/configs.py
Original file line number Diff line number Diff line change
@@ -1,62 +1,62 @@
configs = {
config = {
"color": "green",
"width": 42,
"height": 100,
"font": "Courier",
}

# Access a value through its key
print(configs["color"])
print(config["color"])

# Update a value
configs["font"] = "Helvetica"
print(configs)
config["font"] = "Helvetica"
print(config)

configs = {
config = {
"color": "green",
"width": 42,
"height": 100,
"font": "Courier",
}
user_configs = {
user_config = {
"path": "/home",
"color": "red",
"font": "Arial",
"position": (200, 100),
}
configs.update(user_configs)
print(configs)
configs.update([("width", 200), ("api_key", 1234)])
print(configs)
configs.update(color="yellow", script="__main__.py")
print(configs)
config.update(user_config)
print(config)
config.update([("width", 200), ("api_key", 1234)])
print(config)
config.update(color="yellow", script="__main__.py")
print(config)

default_configs = {
default_config = {
"color": "green",
"width": 42,
"height": 100,
"font": "Courier",
}
user_configs = {
user_config = {
"path": "/home",
"color": "red",
"font": "Arial",
"position": (200, 100),
}
configs = default_configs | user_configs
print(configs)
config = default_config | user_config
print(config)

configs = {
config = {
"color": "green",
"width": 42,
"height": 100,
"font": "Courier",
}
user_configs = {
user_config = {
"path": "/home",
"color": "red",
"font": "Arial",
"position": (200, 100),
}
configs |= user_configs
print(configs)
config |= user_config
print(config)

0 comments on commit 75c5f15

Please sign in to comment.