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

Commit3cbba72

Browse files
Update delattr.md
Fixed heading structure for added examples for delattr()
1 parentcd4356d commit3cbba72

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

‎docs/builtin/delattr.md‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,27 @@ Python delattr() built-in function
1919
##Examples
2020

2121
```python
22-
# Example 1
2322
classPerson:
2423
def__init__(self,name,age):
2524
self.name= name
2625
self.age= age
2726

28-
person= Person("John",30)
29-
delattr(person,'age')
30-
print(person.__dict__)# Output: {'name': 'John'}
27+
>>> person= Person("John",30)
28+
>>>delattr(person,'age')
29+
>>> person.__dict__
30+
# {'name': 'John'}
3131

32-
# Example 2
3332
classCar:
3433
def__init__(self,make,model):
3534
self.make= make
3635
self.model= model
3736

38-
car= Car("Toyota","Corolla")
39-
try:
40-
delattr(car,'year')
41-
exceptAttributeErroras e:
42-
print(f"Error:{e}")# Output: Error: 'Car' object has no attribute 'year'
37+
>>> car= Car("Toyota","Corolla")
38+
>>>try:
39+
...delattr(car,'year')
40+
...exceptAttributeErroras e:
41+
...print(f"Error:{e}")
42+
# Error: 'Car' object has no attribute 'year'
4343
```
4444
<!-- remove this tag to start editing this page-->
4545
<empty-section />

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp