A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.w3schools.com/python/ref_func_hasattr.asp below:

Website Navigation


Python hasattr() Function

Python hasattr() Function

❮ Built-in Functions

Example

Check if the "Person" object has the "age" property:

class Person:

name = "John"

age = 36

country = "Norway"

x = hasattr(Person, 'age')


Try it Yourself » Definition and Usage

The hasattr() function returns True if the specified object has the specified attribute, otherwise False.

Syntax

hasattr(object, attribute)

Parameter Values Parameter Description object Required. An object. attribute The name of the attribute you want to check if exists Related Pages

The delattr() function, to remove an attribute

The getattr() function, to get the value of an attribute

The setattr() function, to set the value of an attribute

❮ Built-in Functions

Track your progress - it's free!


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4