What happens in these two scenarios?
# Scenario 1
type(3)
# <class 'int'>
type = "A random value"
# This will throw an error
type(3)
# Traceback (most recent call last):
# File "<stdin>", line 1, in <module>
# TypeError: 'str' object is not callable
Did we loose reference to type
for the rest of the application?
# Scenario 2
class Foo:
type = 3
bar = Foo()
bar.type
# 3
type(bar.type)
# <class 'int'>
What does that mean when using type
as a django model field?
class FooBar(models.Model):
baz = models.IntegerField(...)
type = models.CharField(...)
And why does python allow assigning a value to type?