How can I define a class in Python?

python

Solution

class Team:
  def __init__(self):
    self.name = None
    self.logo = None
    self.members = 0

In Python, you typically don't write getters and setters, unless you really have a non-trivial implementation for them (at which point you use property descriptors).

Problem

Quite simple, I'm learning Python, and I can't find a reference that tells me how to write the following: ``` public class Team { private String name; private String logo; private int members; public Team(){} // Getters/setters } ``` Later: ``` Team team = new Team(); team.setName("Oscar"); team.setLogo("http://...."); team.setMembers(10); ``` That is a class Team with the properties: name/logo/members Edit After a few attempts I got this: ``` class Team: pass ``` Later ``` team = Team() team.name = "Oscar" team.logo = "http://..." team.members = 10 ``` Is this the Python way? It feels odd (coming from a strongly typed language of course).

Original source

Related problems