You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While teaching Scapy, I realized that it is difficult to understand which indices to use to iterate a response of type SndRcvList().
For example, to display the first answer, a user must do:
>>> r, u = sr(IP(dst="8.8.8.8") / ICMP())
>>> r[0][1]
Beginners might do the following, which is more complex to understand:
>>> r = sr(IP(dst="8.8.8.8") / ICMP())
>>> r[0][0][1]
Using a namedtuple instead of a tuple in SndRcvList(), it is possible to simplify the access to the answer with .answer while maintaining [1] for backward compatibility:
While teaching Scapy, I realized that it is difficult to understand which indices to use to iterate a response of type
SndRcvList(
).For example, to display the first answer, a user must do:
Beginners might do the following, which is more complex to understand:
Using a
namedtuple
instead of atuple
inSndRcvList()
, it is possible to simplify the access to the answer with.answer
while maintaining[1]
for backward compatibility:Do you think that this feature is interesting?
The text was updated successfully, but these errors were encountered: