Skip to content

Commit c806411

Browse files
authored
Merge pull request #372 from Peefy/docs-hyphen-attribute-name
docs: add hyphen attribute name in language tour documents
2 parents 5124b2e + 86d7641 commit c806411

File tree

2 files changed

+19
-1
lines changed
  • docs/reference/lang
  • i18n/zh-CN/docusaurus-plugin-content-docs/current/reference/lang

2 files changed

+19
-1
lines changed

docs/reference/lang/tour.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ data = {
604604
} # {"key1": "value1", "key2": "value2"}
605605
```
606606

607-
We can ignore the key quotation marks when we writing simple literals on the key.
607+
We can ignore the attribute quotation marks when we writing simple literals on the key.
608608

609609
```python
610610
data = {
@@ -613,6 +613,15 @@ data = {
613613
} # {"key1": "value1", "key2": "value2"}
614614
```
615615

616+
Note that when there is `-`, `.` and other hyphens in the attribute, we must use quotation marks.
617+
618+
```python
619+
data = {
620+
"config.dot.attr" = "value1" # Note we use `"config.dot.attr"` instead of `config.dot.attr` here.
621+
"config-hyphen-attr" = "value2" # Note we use `"config-hyphen-attr"` instead of `config-hyphen-attr` here.
622+
}
623+
```
624+
616625
In addition, the **config selector expressions** can be used to init a dict instance with nested keys.
617626

618627
```python

i18n/zh-CN/docusaurus-plugin-content-docs/current/reference/lang/tour.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,15 @@ data = {
611611
} # {"key1": "value1", "key2": "value2"}
612612
```
613613

614+
请注意,当属性中存在 `-``.` 等其他连字符时,我们必须使用引号。
615+
616+
```python
617+
data = {
618+
"config.dot.attr" = "value1" # Note we use `"config.dot.attr"` instead of `config.dot.attr` here.
619+
"config-hyphen-attr" = "value2" # Note we use `"config-hyphen-attr"` instead of `config-hyphen-attr` here.
620+
}
621+
```
622+
614623
此外,**选择表达式**可以用于定义包含嵌套键 dict 实例。
615624

616625
```python

0 commit comments

Comments
 (0)