Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
question about getattr()
#1
This may sound like an unimportant question but finding patterns in Python is what helps me memorize syntax.
Why are the attributes in quotes e.g. 'age'? Am I going to have to remember when to use quotes around variables and when not to? Or is there a pattern that can help me remember?

class Person:
    name = "John"
    age = 36
    country = "Norway"

x = getattr(Person, 'age')
Reply


Messages In This Thread
question about getattr() - by ryfoa6 - Apr-07-2020, 06:13 PM
RE: question about getattr() - by ndc85430 - Apr-07-2020, 06:19 PM
RE: question about getattr() - by ryfoa6 - Apr-07-2020, 06:27 PM
RE: question about getattr() - by deanhystad - Apr-07-2020, 07:16 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  About getattr() MingyuanLuo 7 6,063 Mar-20-2019, 01:46 PM
Last Post: ichabod801
  Vars and getattr problem catosp 5 4,296 Aug-28-2018, 02:54 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020