Quantcast
Channel: How to use a dot "." to access members of dictionary? - Stack Overflow
Viewing all articles
Browse latest Browse all 40

Answer by Sreeragh A R for How to use a dot "." to access members of dictionary?

$
0
0

Simplest solution.

Define a class with only pass statement in it. Create object for this class and use dot notation.

class my_dict:    passperson = my_dict()person.id = 1 # create using dot notationperson.phone = 9999del person.phone # Remove a property using dot notationname_data = my_dict()name_data.first_name = 'Arnold'name_data.last_name = 'Schwarzenegger'person.name = name_dataperson.name.first_name # dot notation access for nested properties - gives Arnold

Viewing all articles
Browse latest Browse all 40

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>