Because the text processor internally calls GetBoolean, which returns false if an attribute is not defined. When you reference an attribute directly, it must be defined. You can do the same:
if (GetBoolean(piano, "b")=True)
though I would just do:
if (GetBoolean(piano, "b"))