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 7 years ago.
Improve this question
I have some simple code to load an image file in and then display it's size, using Pillow fork and their documentation on how to find image attributes.
This is a code snippet taken from a larger file, but I don't think any of the other parts should have any bearing on PIL. I need to get the image header file, size in particular so I can convert it into a particular format for a machine learning project that takes a particular input array. Below is what I understand the documentation to be telling me to do.
from PIL import Image
im = Image.open("test.jpg")
print im
print im.size()
This is the error I get when I run this
File "DataStorage.py", line 31, in <module>
print im.size()
TypeError: 'tuple' object is not callable
size is an attribute, not a method of the image object. Just type im.size without the brackets.
Note that this is basically hinted at by the error message:
TypeError: 'tuple' object is not callable
"callable" refers to the action of calling something, usually by adding parentheses () to an object. Here, the error message was pointing out that you were actually performing a calling operation like this:
(1,2)() # attempting to "call" a tuple will result in a TypeError
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 5 months ago.
Improve this question
Here is the documentation: QTableWidget.sortItems
This is the function:
PySide6.QtWidgets.QTableWidget.sortItems(column[, order=Qt.AscendingOrder])
The following is my code:
self.notes_current_table_widget.sortItems(column[2, order=Qt.AscendingOrder])
PyCharm displays this as an error, when I try to run I get:
SyntaxError: invalid syntax. Maybe you meant '==' or ':=' instead of '='?
Syntax error is in regards to: order=Qt.AscendingOrder
I have tried on other QTableWidgets with the same issue. I have verified that the type is QTableWidget. I have updated all packages to the latest within the project. I have checked syntax of lines before and after.
I ran into this issue because I wanted to sort a dataframe and display the dataframe using a QTableWidget. df = dataframe. The dataframe is sorted until adding the df to the QTableWidget. That's when I looked at this QTableWidget.sortItems function. Any thoughts or ideas?
The docs say:
PySide6.QtWidgets.QTableWidget.sortItems(column[, order=Qt.AscendingOrder])
The square brackets here indicate that order is an optional argument, with default value Qt.AscendingOrder. You're not supposed to write the square brackets explicitly.
So, your code should probably look like this:
self.notes_current_table_widget.sortItems(column=2, order=Qt.AscendingOrder)
Or leave out order altogether, as you're using the default value anyway.
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
I am trying to make a script that can delete a file with Python. When I moved the file to my startup directory with my script, a lot of the code was changed, not by me. I've just assumed this was normal and continued trying to make it delete a file on startup. I later realized it wasn't working because one of the call methods kept getting an invalid syntax. Here's my code.
Python Version: 3.8.7
Error message is :
invalid syntax (<unknown>, line 7)
LOAD_CONST(0), LOAD_CONST(None), IMPORT_NAME(os), STORE_NAME(os)
LOAD_CONST(0), LOAD_CONST(None), IMPORT_NAME(shutil), STORE_NAME(shutil)
source = 'C:\\Users\\me\\OneDrive\\Desktop\\startup.py'
destination = 'C:\\Users\\me\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup'
LOAD_NAME(shutil), LOAD_METHOD(move), LOAD_NAME(source), LOAD_NAME(destination), CALL_METHOD[2], STORE_NAME(new_path)
print(new_path)
LOAD_NAME(os), LOAD_METHOD(remove), LOAD_CONST('C:/Users/me/OneDrive/Desktop/delete.txt'), CALL_METHOD[1], POP_TOP
print('File Removed!'), return None
From the code, it's difficult to understand what you are trying to do. If you want to delete a file, you can use the os module in python. For example:
import os
os.remove("/some/file/path/to/remove.txt")
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
I am using google colab sheet.
Before a minute this line was working but I don't what happened now.
----> 3 rang = [num for num in range(100)]
TypeError: 'list' object is not callable
This error is coming every time, I tried refreshing the page.
Looks like you accidentally defined range somewhere within your code. This overwrote the built-in definition. The line may look something like range = [1, 2, 3].
You should find and get rid of that line. Then, refresh your kernel to bring back the regular definition of 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 6 years ago.
Improve this question
I'm attempting to make a Dungeons and Dragons like game in Python, but I seem to have hit a wall. Whenever I run this code
file.write("Name:" (str(Char2)))
It returns
str object is not callable
You are using "file.write()" function. Inside parentheses you must put string. When you use "Name:" (str(Char2)) the Pythton see "Name:" as a function.
In other words, try this:
file.write("Name:{}".format(str(Char2)))
If you would like understand more see 6.1.3. Format String Syntax in this link: https://docs.python.org/3.4/library/string.html
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 7 years ago.
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.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Improve this question
My code:
hi = glob.glob("hi/FEC[0-9][0-9][0-9][0-9][0-9]_[0-9].seq")
I'm using a glob module and I'm trying to get all the path file names but all it returns back is a empty list. I don't know why it keeps doing that. It worked before my code was accidentally erased.
[]
Regardless if the file isn't even there, it still gives me an empty list.
Update:
So the following files I have are
FEC00001_1.seq
FEC00002_1.seq
FEC00002_2.seq
and so on..
Update 2:
So it I just realized that it might have to do something with the wrong folder like you guys said.
Because right now, my script is in "folder1" and all the files I'm trying to access is in "folder2"
/mainfolder/folder1/script.py
/mainfolder/folder2/files im trying to access
glob.glob is done by using the os.listdir() and fnmatch.fnmatch() functions in concert. So it's important that you search at the right place.
Considering your file hierarchy:-
/mainfolder/folder1/script.py
/mainfolder/folder2/files im trying to access
try the following :-
hi = glob.glob("../folder2/FEC[0-9][0-9][0-9][0-9][0-9]_[0-9].seq")