w3resource
w3resource logo

Python: delattr() function

(追記) (追記ここまで)
(追記) (追記ここまで)

delattr() function

The delattr() function is used to delete the specified attribute from the specified object.

Version:

(Python 3)

Syntax:

delattr(object, name)

Parameter:

Name Description Required /
Optional
object The object from which name attribute is to be removed. Required.
name The name of one of the object’s attributes. Required.

Return value:

The delattr() doesn't return any value (returns None).

Example: Python delattr() function

class Rollnums:
 a = 15
 b = -7
 c = 0
rno = Rollnums() 
print('a = ',rno.a)
print('b = ',rno.b)
print('c = ',rno.c)
delattr(Rollnums, 'c')
print('--After deleting c attribute--')
print('a = ',rno.a)
print('b = ',rno.b)

Output:

a = 15
b = -7
c = 0
--After deleting c attribute--
a = 15
b = -7

Pictorial Presentation:

Python: Built-in-function - delattr() function

Python Code Editor:

[フレーム]

PREV : complex()
NEXT : dict()

Test your Python skills with w3resource's quiz



Follow us on Facebook and Twitter for latest update.

(追記) (追記ここまで)


(追記) (追記ここまで)
(追記) (追記ここまで)


AltStyle によって変換されたページ (->オリジナル) /