Although the behaviour with 1.real
seems unlogical, it is expected due to the language specification: Python interprets 1.
as a float (see floating point literals). But as @mutzmatron pointed out (1).real
works because the expression in brackets is a valid Python object.
Update: Note the following pits:
1 + 2j.real
>>> 1.0 # due to the fact that 2j.real == 0
# but
1 + 2j.imag
>>> 3.0 # due to the fact that 2j.imag == 2