NameError: name 'p' is not defined

672 views
Skip to first unread message

Rink Tang

unread,
May 29, 2017, 12:23:05 AM5/29/17
to pytables-users
I run the file examples/tutorial2.py  with windows+Python3.6

there is an error,  name 'p' is not defined
when run 
e = [ p['TDCcount'] for p in table if p['ADCcount'] < 20 and 4 <= p['TDCcount'] < 15 ]
print("Last record ==>", p)
how to fixed it?

Francesc Alted

unread,
May 29, 2017, 4:10:49 AM5/29/17
to Rink Tang, pytables-users
'p' is a local variable inside the  comprehension list and it used to be available outside it in Python 2, but apparently this is no longer try in Python 3.  Just use 'e[-1]' instead.

Francesc

--
You received this message because you are subscribed to the Google Groups "pytables-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pytables-users+unsubscribe@googlegroups.com.
To post to this group, send email to pytables-users@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Francesc Alted
Reply all
Reply to author
Forward
0 new messages