Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1db3f2f

Browse files
authored
Merge pull requestwilfredinni#424 from lukaszwojcik89/patch-1
Update delattr.md
2 parents124ced0 +10c70c2 commit1db3f2f

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

‎docs/builtin/delattr.md‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,29 @@ Python delattr() built-in function
1616
</base-disclaimer-content>
1717
</base-disclaimer>
1818

19+
```python
20+
classPerson:
21+
def__init__(self,name,age):
22+
self.name= name
23+
self.age= age
24+
25+
>>> person= Person("John",30)
26+
>>>delattr(person,'age')
27+
>>> person.__dict__
28+
# {'name': 'John'}
29+
30+
classCar:
31+
def__init__(self,make,model):
32+
self.make= make
33+
self.model= model
34+
35+
>>> car= Car("Toyota","Corolla")
36+
>>>try:
37+
...delattr(car,'year')
38+
...exceptAttributeErroras e:
39+
...print(f"Error:{e}")
40+
# Error: 'Car' object has no attribute 'year'
41+
```
1942
<!-- remove this tag to start editing this page-->
2043
<empty-section />
2144
<!-- remove this tag to start editing this page-->

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp