from scapy.all import sniff, NetflowSession, TCPSession, IPSession
my_session = NetflowSession()
sniff(session=my_session, prn= lambda x:x.summary())
test = my_session._ip_process_packet(r"192.168.1.35" in r"IP")
print(test)
Result:
TypeError: argument of type 'bool' is not iterable
Why am i getting TypeError: argument of type 'bool' is not iterable ?
Related
I'm trying to find duplicates and group them in "technician" table.
display(technician['Tech_id'].value_counts().sort_values(ascending=False).head())
duplicate_technicians = technician.groupby('Tech_id').filter(lambda x: len(x) == 2)
This line throws an error
TypeError: 'int' object is not callable
Error is particularly in the lambda function.
duplicate_technicians.filter(lambda x: len(x) == 2)
Here is the "technician" table for reference,
I'm new to this. Can anyone help me out?
I am getting an error when I try to compose a string using f-string syntax in Python 3.7.
My code is the following:
i = 1
site_id= 0
meter = 0
model_id = i
target_name = 'log1p_meter_reading_corrected2'
f'model_site_id_{str(site_id)}_meter_{str(meter)}_{target_name}_model_id_{str(model_id)}_11_12_19.hdf5'
which returns the error:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-68-1ebe1c78d868> in <module>
6 target_name = 'log1p_meter_reading_corrected2'
7
----> 8 f'model_site_id_{str(site_id)}_meter_{str(meter)}_{target_name}_model_id_{str(model_id)}_11_12_19.hdf5'
TypeError: 'str' object is not callable
What creates the error and how should I correct my code?
In f-strings you don't need to wrap the variable with str(). The following should work:
f'model_site_id_{site_id}_meter_{meter}_{target_name}_model_id_{model_id}_11_12_19.hdf5'
However, your code should technically work fine, the str() calls are just redundant - you have probably reassigned the reserved keyword str at some point by doing something like:
str = 'test'
Now, if we do
>>> str(site_id)
We get
TypeError: 'str' object is not callable
Both f(x) or fp(x) aren't "NoneType" but however
it's telling me that abs can't operate "NoneType". What seems to be the problem?
abs(fp(x))
TypeError: bad operand type for abs(): 'NoneType'
So I'm assuming here that fp(x) or f(x) are functions that don't return anything.
Take a look at this,
def fp(x):
print(x)
print(fp(10))
You might think that the output of this would be 10 but you get this,
10
None
Take a look at this function,
def fp():
pass
print(fp())
Output:
None
Functions by default return a None type. So in your case when you are doing abs(fp(x)) the problem seems to be that you are doing abs() on None that's why you get the error.
Look at this,
def fp():
pass
abs(fp())
Output:
TypeError: bad operand type for abs(): 'NoneType' python error
So add a return statement to the function and you can see the error will be gone
def fp(x):
return x
some_value = abs(fp(-10.5))
print(some_value)
Output:
10.5
Now the error is gone.
I wrote some code for calculating the differential equation and it's solution using sympy, but I'm getting an error, my code : ( example )
from sympy.parsing import sympy_parser
expr=1/2
r='3/2'
r=sympy_parser(r)
I get
TypeError: 'module' object is not callable
What am I doing wrong here ?
sympy_parser is a module, and modules are not a callable. What you want is sympy_parser.parse_expr:
>>> from sympy.parsing import sympy_parser
>>> r ='3/2'
>>> r = sympy_parser.parse_expr(r)
>>> r
3/2
I get this error when trying to convert possible integer variables:
for page in domain.page_set.all():
filename = str(domain.url) + '_page_' +str(page.id())+ '.html'
The error:
File "/Applications/djangostack-1.4.7-0/apps/django/django_projects/controls/polls/models.py", line 40, in make_config_file
filename = str(domain.url)+"_page_"+str(page.id())+".html"
TypeError: 'long' object is not callable
What is wrong here? what does "long is not callable" means?
page.id is a long, which is not a function, and thus not callable:
In [1]: id = 5586L
In [2]: type(id)
Out[2]: long
In [3]: id()
TypeError: 'long' object is not callable
Try just doing str(page.id).
Alternatively, you could use Python's string formatting like so:
for page in domain.page_set.all():
filename = "{}_page_{}.html".format(domain.url, page.id)