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
cur.execute(command, tuple(values))
if (fetch := cur.fatchone()) is not None:
return fetch[0]
#bot_has_permissions(manage_roles=True)
#has_permissions(manage_roles=True, manage_guild=True)
async def unmute_members(self, ctx, members: Greedy[Member], *, reason: Optional[str] = "لا يكثر هرجك"):
if not len(members):
await ctx.send("!unmute #member [reason]")
else:
await self.unmute(ctx, members, reason=reason)
AttributeError: 'sqlite3.Cursor' object has no attribute 'fatchone'
Typo.
if (fetch := cur.fatchone()) is not None:
should be
if (fetch := cur.fetchone()) is not None:
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 months ago.
Improve this question
I'm noobie/beginner at Python
I was creating this script
I tried to curl a URL and got a response(A)
now I want to get the response(B) from that response A
result = os.popen("curl https://raw.githubusercontent.com/SirdLay/test/main/test.txt").read()
index = os.popen("curl [what to be used here?]")
response1 = os.popen("curl https://raw.githubusercontent.com/SirdLay/test/main/test.txt").read()
url = response1[<key>]
# key is some key in the response1.
# You can print the response1 to see the object.
# For your particular case you dont need a key.
# so you can use
url = response1
response2 = os.popen("curl " + url).read()
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
Well, I just noticed that variables in if name == 'main': are shared to the classes in the same file - why is this? I don't recall having this issue in python2...
class A:
def __init__(self, b):
self.b = b
def func_a(self):
return d
if __name__ == '__main__':
classA = A(1)
d = 2
print(classA.func_a())
prints out 2.
What's the reasoning?
this definitely also happens in python2
and is very simple: declaring variables outside of functions/classes makes them global and when python searches for variables with the name d it doesn't find it in the local scope but it does find the global variable
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 created a simple program to python that check if this X is expired.
import datetime
expired_on = datetime.datetime.now() + datetime.timedelta(0, 20) # add 20 seconds for expiration time
while True:
X = datetime.datetime.now()
if expired_on == X:
print(f"this {X} is expired.")
break
but it didn't break after 20 seconds.
This will be much cleaner.
import datetime
expired_on = datetime.datetime.now() + datetime.timedelta(seconds=20) # Add 20 seconds for expiration time
while True:
now = datetime.datetime.now()
if expired_on <= now:
print('Expired.')
break
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
Having used pandas for a long time, this is the first time I got an error as shown in the title of this question and I'm stuck because I don't see any reason why the DataFrame would not have the groupby function "available." Already reinstalled pandas, even looked in the code that is being used (groupby is defined in the core modules).
This is what I'm doing, the error is shown below:
def _bin_by_answer(row):
collocated_answer = row['colname']
if collocated_answer <= -1:
return -1
elif collocated_answer >= 1:
return 1
else:
return 0
df = pd.read_pickle(somepath)
df['binned'] = df.apply(func=lambda row: _bin_by_answer(row), axis=1)
df_sampled = df.groupyby(by='binned', group_keys=False).apply(lambda grp: grp.sample(n=50))
Here is the error:
Traceback (most recent call last):
File "/Users/felix/IdeaProjects/cope/ann4class/exportfromaestoretomturk.py", line 858, in <module>
process_and_export_ps2_inductive()
File "/Users/felix/IdeaProjects/cope/ann4class/exportfromaestoretomturk.py", line 786, in process_and_export_ps2_inductive
df_sampled = df_results.groupyby(by=COL_ANSWER1_COLLOCATED_MAJORITY, group_keys=False).apply(
File "/Users/felix/anaconda3/envs/cope/lib/python3.7/site-packages/pandas/core/generic.py", line 5179, in __getattr__
return object.__getattribute__(self, name)
AttributeError: 'DataFrame' object has no attribute 'groupyby'
As suggested by ddoGas, the cause of this error was a typo. So, I guess the general answer would be: In case you're reading this question because you're running into a similar problem, double check that you wrote the function name correctly.
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
def shut_down(s):
s = s.Lower()
if s == 'yes' :
return "Shutting down..."
elif s == 'no':
return "Shutdown aborted!"
else :
return "Sorry, I didn't understand you."
the computer tell me that Your shut_down function threw the following error: 'str' object has no attribute 'Lower'
Your .Lower() is not available in python because it's case sensitive language use .lower()
def shut_down(s):
s = s.lower()
if s == 'yes' :
return "Shutting down..."
elif s == 'no':
return "Shutdown aborted!"
else :
return "Sorry, I didn't understand you."