Oct 12th, 2021
- course_db = Course(title='Databases')
- Coming from a C++ background, I would expect `(course_db = Course(title='Databases'))` to behave like it would in C++, that is assign `Course(title='Databases')` to `course_db` *and return the assigned object so that I can use it as part of a larger expression*. For example, I would expect this code to do the same thing as the code above:
- (course_db = Course(title='Databases')).save()
- But when I tried this, I got a syntax error.
- Why can't I do this in Python, and what can I do instead?
Please, Sign In to add comment