Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I'm running a snippest like that:
p = re.compile(b'^((?!-)[*A-Za-z0-9-]{1,63}(?<!-)\\.)+[A-Za-z]{2,6}$')
m = p.match(domain)
'domain' are the ip addresses get from google dns. I know there is something wrong with the decoding, so I've tried to encode the regular expressions after it was compiled, but still get the bug notice like this,
Traceback (most recent call last):
File "D:\python34\lib\threading.py", line 921, in _bootstrap_inner
self.run()
File "update.py", line 101, in run
if validate_domain(domain):
File "update.py", line 182, in validate_domain
m = pattern.match(domain)
TypeError: can't use a bytes pattern on a string-like object
Could you give me some tips for this situation
!!!Programming language: python 3.4
Appending a b to the start of your pattern makes it a bytes object. But you can't match string objects with a bytes pattern. The error is quite clear:
p = re.compile(b'^((?!-)[*A-Za-z0-9-]{1,63}(?<!-)\\.)+[A-Za-z]{2,6}$')
# ^
You probably intended to use r''
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
my code looks like:
list_var = ['rh','temp','tl','Tt','DPD','PAR']
for L in range(1, len(list_var)):
for subset in itertools.combinations(list_var, L):
f = 'inf ~ {} + C(area)'.format(' * '.join(list(subset)))
error 'range' object is not callable jumped up even I changed len(list_var) into a number.
Can you identify the problem and fix it?
Thank you in advance!!!
I can reproduce the issue when assigning the range name to a range instanciated object:
>>> range = range(10)
>>> range(1)
Traceback (most recent call last):
File "<string>", line 301, in runcode
File "<interactive input>", line 1, in <module>
TypeError: 'range' object is not callable
you probably reassigned the name earlier in your code, triggering this exact error.
A quick & dirty fix is:
del range
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
What is causing this error? Isn't it possible commenting out lines like this inside code?
for i in (Class_1, """Class_2, Class_3"""):
name = i.__name__
Class_1, Class_2 and Class_3 are classes declared before the upper code.
Error output:
> Traceback (most recent call last):
File "", line 2, in <module>
name = i.__name__
AttributeError: 'str' object has no attribute '__name__'
Process finished with exit code 1
Error message line edited to fit the example code
Remove the triple-quoted string """Class_2, Class_3""" to avoid iterating over it which is what you're doing in this case so it looks like for i in (Class_1,) (parenthesis are optional).
It seems you want to comment out those unnecessary sides, but please note that those triple-quotes strings technically aren't comments, so they can still affect the script in some areas you didn't intend.
What do you mean by
for i in (Class_1, """Class_2, Class_3"""):
When you iterate over this tuple, the second element is a string, thus causing the error.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I'm trying to follow the Text Classification Tutorial on http://mxnet.io/tutorials/nlp/cnn.html
Until I call the function:
conv_input = mx.sym.Reshape(data=embed_layer, target_shape=(batch_size, 1, sentence_size, num_embed))
everything goes well. But then I get the error:
conv_input = mx.sym.Reshape(data=embed_layer, target_shape=(batch_size, 1, sentence_size, num_embed))
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\my.name\Downloads\WinPython-64bit-2.7.10.3\python-2.7.10.amd64\lib\site-packages\mxnet-0.7.0-py2.7.egg\mxnet\symbol.py", line 1062, in creator
ctypes.byref(sym_handle)))
File "C:\Users\my.name\Downloads\WinPython-64bit-2.7.10.3\python-2.7.10.amd64\lib\site-packages\mxnet-0.7.0-py2.7.egg\mxnet\base.py", line 77, in check_call
raise MXNetError(py_str(_LIB.MXGetLastError()))
mxnet.base.MXNetError: Invalid Parameter format for target_shape expect Shape(tuple) but value='(50, 1, 56L, 300)'
Does anyone have an idea, How to make this work?
Looks like your symbol.py file is not the updated version. Maybe rebuild mxnet with the latest version?
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
def open_file(filename):
file_open= open(filename,"r")
return file_open
When I try and call the function I get the following results:
>>> open_file(random.txt)
Traceback (most recent call last):
File "<pyshell#17>", line 1, in <module>
open_file(random.txt)
NameError: name 'random' is not defined
try
open_file('random.txt')
Strings in Python need to be quoted.
random is being interpreted as an object, and is undefined.
You forgot quotes:
open_file('random.txt')
python thinks random is an object, which obviously you didn't define. The quotes make it a string.
you just need to input the filename as a string; here's how it must be done:
>>> open_file('random.txt')
note that your function works just fine, all you need to do is call it properly.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I got an error using numpy.zeros, it seems like my value a can't be filled since i got an error:
track=2
a=np.zeros(shape=(3,2))
eps_real=a(Cp-0.5,2)/2*3.14*track
eps_imag=a(Cp-0.5,2*track)/2*3.14*track
tau=a(Cp-1,2)
print tau
My error when i ran is:
Traceback (most recent call last):
File "Main.py", line 35, in <module>
eps_real=a(Cp-0.5,2)/2*3.14*track
TypeError: 'numpy.ndarray' object is not callable
Collection members in Python use square brackets ([]), not parentheses. So your code should be:
eps_real=a[Cp-0.5,2]/2*3.14*track
eps_imag=a[Cp-0.5,2*track]/2*3.14*track
tau=a[Cp-1,2]
Parentheses are used for calling functions, hence the error message object is not callable