I am trying two join to Class args together to make another one. The code below outputs the Name property as a tuple instead of a string.
# Person
class Person(ParentClass):
def __init__(self,
Collection = 'People',
Firstname = '',
Lastname = '',
Name = '',
**kwargs):
self.Collection = Collection
self.Firstname = Firstname
self.Lastname = Lastname
self.Name = '%s %s' % (self.Firstname, self.Lastname),
self.__dict__.update(kwargs)
p = Person(Firstname='Foo',Lastname='Bar') ## tuple, not string
p.Name = ('Foo', 'Bar')
The reason I am trying to join the first and last names in the __init__ as opposed to just a property is because the __init__ is tied to an inherited save_to_database method. I want the Name property to be save to the db, but as a string, NOT as a tuple.
Any clues would be fantastic!
Remove the trailing comma. Turn this…
into this:
(You’re effectively doing
self.Name = 'foo',instead ofself.Name = 'foo', and'foo',is a single-element tuple with the only element being a string, whereas'foo'is just a string.)