What is wrong with the following with this tuple [closed] - python

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 have the following list of tuples in Python.
CHECKS = [
('Standard JavaScript Inlining Optimization', ('EMBED_JAVASCRIPT',), 'check_js_inlining'),
('HTML5 Advanced Cache', ('JAVASCRIPT_HTML5_CACHE', 'CSS_HTML5_CACHE'), 'check_html5_advanced_cache'),
('Cookieless Resource Domain', ('RENAME_JAVASCRIPT', 'RENAME_CSS'), 'check_cookieless_resource_domain'),
('Minificatiopn of JS', ('MINIFY_JAVASCRIPT',), 'check_js_minifaction'),
('File Versioning', ('RENAME_JAVASCRIPT', 'RENAME_IMAGE', 'RENAME_CSS'), 'check_file_versioning'),
('Small Image Embedding', ('EMBED_IMAGE',), 'check_small_image_embedding'),
('Responsive Image Loading', ('RESPONSIVE_IMAGES',), 'check_responsive_image_loading')
('Asynchronous JS and CSS Loading', ('ASYNC_JAVASCRIPT',), 'check_async_js_and_css_loading'),
('JS Pre-Execution', ('PRE_EXECUTE_JAVASCRIPT',), 'check_js_pre_execution'),
]
Upon execution it throws the error
File "FEO_processor.py", line 14, in FEOProcessor
('Asynchronous JS and CSS Loading', ('ASYNC_JAVASCRIPT',), 'check_async_js_and_css_loading'),
TypeError: 'tuple' object is not callable
What am I missing here.

You are missing a comma:
('...', ('RESPONSIVE_IMAGES',), 'check_responsive_image_loading')
↑ HERE

Related

"+=" operator not working when modifying .json in variable (Python) [closed]

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 1 year ago.
Improve this question
I'm new to Python, and I'm trying to store data in a .json, and then access and modify it through Python. Currently I'm having an issue where I can't modify the data if I try to use a variable instead of directly modifying it. It works fine if it's not in a variable, or if I'm just reading the information, or if it's not in a function.
import json
with open('testprog.json', 'r+') as f:
data = json.load(f)
x = int(data['valueOne'])
def test():
x += 1
#VSC tells me this variable is not defined.
#If I swap the variable for “int(data[‘valueOne’])” it works.
f.seek(0)
json.dump(data, f, indent=4)
f.truncate()
test()
print("New first value is: "+str(data['valueOne']))
.json:
{
"valueOne": 10,
"valueTwo": 5,
"valueThree": 8
}
I assume that the value associated with the key valueOne is a string. Therefore you could do this:
data['valueOne'] = str(int(data['valueOne']) + 1)

AttributeError: 'DataFrame' object has no attribute 'to_CSV' [closed]

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'm trying to store my extracted chrome data into a csv format using df.to_CSV
here is my code :
content = driver.page_source
soup = BeautifulSoup(content)
for a in soup.findAll('a',href=True, attrs={'class':'_13oc-S'}):
name=a.find('div', attrs={'class':'_4rR01T'})
price=a.find('div', attrs={'class':'_30jeq3 _1_WHN1'})
rating=a.find('div', attrs={'class':'hGSR34 _2beYZw'})
products.append(name.text)
prices.append(price.text)
ratings.append(rating.text)
df = pd.DataFrame({'Product Name':products, 'Price':prices, 'Rating':ratings})
df.to_CSV(r'C:\Users\Krea\Documents\products.csv', index=False)
It's case-sensitive, should be df.to_csv(...)
Python is case sensitive. Change the last row to:
df.to_csv(r'C:\Users\Krea\Documents\products.csv', index=False)

python Flask, TypeError: 'NoneType' object is not subscriptable [closed]

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'm studying Flask very recently and trying to create API.
However, when It request json data, this error occurs.
if content['words'] is not None:
TypeError: 'NoneType' object is not subscriptable
could anyone can help this?
Thanks
my code is below:
#app.route("/process",methods=['GET', 'POST'])
def process():
content = request.json
words = {}
if content['words'] is not None:
for data in content['words'].values():
words[data['word']] = data['weight']
process_from_text(content['text'], content['maxCount'], content['minLength'], words)
result = {'result':True}
return jsonify(result
The problem is most likely that request is not a valid json request. If that is the case then content will be equal to None which means it is not subscriptable.

AttributeError: 'FirefoxProfile' object has no attribute 'update' error usingFirefoxProfile through Selenium and Python [closed]

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
Hello Guys I'm having problem on my code.
from selenium import webdriver
import time
profile = webdriver.FirefoxProfile()
profile.set_preference('network.proxy_type',1)
profile.set_preference('network.proxy.http',"91.xx.xxx.xx")
profile.set_preference('network.proxy.http_port',xxxx)
# profile.update_preference() ---> this code letter giving the error.
driver = webdriver.Firefox(firefox_profile=profile)
driver.get('http://whatismyipaddress.com')
time.sleep(3)
driver.close()
Here Is The Error I'm Getting:
AttributeError: 'FirefoxProfile' object has no attribute 'update'
I cant figure out the problem i just want to save the profile settings to use.
I Think You Need To Change This
profile.update_preference()
With This:
profile.update_preferences()
update_preferences()
update_preferences() updates the default_preferences with the frozen preferences of the desired FirefoxProfile which is defined as:
def update_preferences(self):
for key, value in FirefoxProfile.DEFAULT_PREFERENCES['frozen'].items():
self.default_preferences[key] = value
self._write_user_prefs(self.default_preferences)
However, you were close. You need to replace update_preference() with update_preferences() i.e. effectively in your code you need to replace:
profile.update_preference()
with
profile.update_preferences()
References
You can find a relevant discussions in:
How to connect to Tor browser using Python

Detail AttributeError: 'module' object has no attribute 'workbook' [closed]

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 keep getting the Detail AttributeError: 'module' object has no attribute 'workbook' error.
below is my code
import xlwt
workbook = xlwt.workbook()
sheet = workbook.add_sheet('Eswar')
sheet.write (4,4,'Test passed')
workbook.save("D:\resultsLatest.xls")
what have i done wrong?
I am using python 2.7
In source code on github you can see right spelling Workbook. Your code should be:
import xlwt
workbook = xlwt.Workbook()
sheet = workbook.add_sheet('Eswar')
sheet.write(4,4,'Test passed')
workbook.save("D:\\resultsLatest.xls")

Categories