0
I wonder how I check for variable object in Python.
I tried so:
try:
select_me = User.select_me(request)
select_random = User.select_random(request, 3)
me = select_me.username
random = select_random.username
gender = select_random.gender
except:
me = 'Error'
random = 'Error'
gender = 'Error'
But I think, you know, I think you can sort this out, for example, "shorten"
In Python, there is some function to check if there is an object inside that variable?
PS: Without the treatment with try
and except
he throws me:
'Nonetype' Object has no attribute 'username'
in PHP a if (is_object(...))
would solve, and in Python?
Something with if
or else
or even some native Python function, has as?
What are the possible function returns
User.select_me
? An objectUser
orNone
?– Woss
@Andersoncarloswoss, returns, username, name, lastname...
– user148010