To access field or method of an object use dot .
:
user = User()
print user.fullName
If a name of the field will be defined at run time, use buildin getattr
function:
field_name = "fullName"
print getattr(user, field_name) # prints content of user.fullName
Related Contents:
- How do I sort a list of dictionaries by a value of the dictionary?
- Why can’t I call read() twice on an open file?
- How do I print colored text to the terminal in Python?
- How to print number with commas as thousands separators?
- Convert hex string to int in Python
- Python: Removing list element while iterating over list [duplicate]
- Activate a virtualenv with a Python script
- How do I turn a python datetime into a string, with readable format date?
- Python referencing old SSL version
- Keras not training on entire dataset
- How do I activate a virtualenv inside PyCharm’s terminal?
- Getting list of lists into pandas DataFrame
- if x:, vs if x == True, vs if x is True
- Why use Flask’s url_for?
- Convert a list with strings all to lowercase or uppercase
- How can I filter a date of a DateTimeField in Django?
- How can you determine a point is between two other points on a line segment?
- How do I perform HTML decoding/encoding using Python/Django?
- Flask at first run: Do not use the development server in a production environment
- rect collision with list of rects
- Python raises SyntaxError on “=” in if statement [closed]
- Subclass in type hinting
- Find index of last occurrence of a substring in a string
- Complete scan of dynamoDb with boto3
- Most efficient property to hash for numpy array
- Compulsory usage of if __name__==”__main__” in windows while using multiprocessing [duplicate]
- Cannot return results from stored procedure using Python cursor
- numpy max vs amax vs maximum
- Detect text region in image using Opencv
- Resampling a numpy array representing an image
- How can I replicate rows in Pandas?
- How can I prevent Google Colab from disconnecting?
- “ImportError: No module named webapp2” after Linux SDK upgrade (1.9.35 -> 1.9.38)
- Print very long string completely in pandas dataframe
- How do you read a file into a list in Python? [duplicate]
- Python unit test with base and sub class
- Search for a file using a wildcard
- How do I convert a list in a Pandas DF into a string?
- ImportError: No module named pywintypes
- Why can’t I end a raw string with a backslash? [duplicate]
- Python UTF-16 CSV reader
- Python append multiple files in given order to one big file
- Leveraging “Copy-on-Write” to Copy Data to Multiprocessing.Pool() Worker Processes
- How to set colors for nodes in NetworkX?
- Unload a module in Python
- Streaming large training and test files into Tensorflow’s DNNClassifier
- Getting “ImportError: DLL load failed: The specified module could not be found” when using cx_Freeze even with tcl86t.dll and tk86t.dll added in
- Detecting a keypress in python while in the background
- How to check if Paramiko successfully uploaded a file to an SFTP server?
- method of iterating over sqlalchemy model’s defined columns?