lundi 19 septembre 2016

in Python, are statements objects?

As far as I understand, everything in python is an object or a reference. For example: in x = 1, x is a reference to the integer object 1. If I write print type(x), then Python will tell me the object that x is referencing is an integer.

So what about statements such as if?

if I try print type(if), unsurprisingly, I get a syntax error. I can speculate on why this is the case. Maybe if is a static method of a class, or maybe it has somehow been weirdly defined as non returnable, etc. I just don't know.

Ultimately, I suspect that if has nothing to do with an object or a reference. However, that would surely go against the idea of everything being an object or a reference?

Aucun commentaire:

Enregistrer un commentaire