Comments (5)
Warning: Caught error in request 'searchTrending' - Full error below Traceback (most recent call last): File "C:\Users\#####\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\scratchattach\cloud_requests.py", line 116, in call_request output = req_obj["on_call"](*arguments) # Calls the request function and saves the function's returned data in the output variable ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\######\Documents\scratchattach\scratchBrowser.py", line 14, in searchTrending tempProject = projects[i] ~~~~~~~~^^^ TypeError: list indices must be integers or slices, not Project
Here is the
searchTrending
function@client.request def searchTrending(): #called when client receives request response = "" projects = scratch3.search_projects(query="query", mode="trending", language="en", limit=40, offset=0) for i in projects: tempProject = projects[i] if len(projects) == i: response = response + tempProject.title + ";" + tempProject.author + ";" + tempProject.id else: response = response + tempProject.title + ";" + tempProject.author + ";" + tempProject.id + ":" return response
How am i supposed to get a
Project
from a list of them?
@client.request
def searchTrending(): #called when client receives request
response = ""
projects = scratch3.search_projects(query="query", mode="trending", language="en", limit=40, offset=0)
for i in range(len(projects) - 1):
tempProject = projects[i]
if len(projects) - 1 == i:
response = response + tempProject.title + ";" + tempProject.author + ";" + tempProject.id
else:
response = response + tempProject.title + ";" + tempProject.author + ";" + tempProject.id + ":"
return response
Here is updated code.
from scratchattach.
@client.request def searchTrending(): #called when client receives request response = "" projects = scratch3.search_projects(query="query", mode="trending", language="en", limit=40, offset=0) for i in range(len(projects) - 1): tempProject = projects[i] if len(projects) == i: response = response + tempProject.title + ";" + tempProject.author + ";" + tempProject.id else: response = response + tempProject.title + ";" + tempProject.author + ";" + tempProject.id + ":" return response
Here is updated code.
Please, do not use this code, it's unclear and even drops 1 project completely.
For complete code, see my answer
from scratchattach.
@client.request
def searchTrending(): #called when client receives request
response = ""
projects = scratch3.search_projects(query="query", mode="trending", language="en", limit=40, offset=0)
for p in projects:
response += f"{p.title};{p.author};{p.id}:"
return response
Basic python. You should look into Python beginner's guide
from scratchattach.
@client.request def searchTrending(): #called when client receives request response = "" projects = scratch3.search_projects(query="query", mode="trending", language="en", limit=40, offset=0) for p in projects: response += f"{p.title};{p.author};{p.id}" response += ":" return responseBasic python. You should look into Python beginner's guide
I want the last one to not have a : , An example of a response i want is: title;author;id:title;author;id:title;author;id
from scratchattach.
@client.request
def searchTrending(): #called when client receives request
response = ""
projects = scratch3.search_projects(query="query", mode="trending", language="en", limit=40, offset=0)
for p in projects:
response += f"{p.title};{p.author};{p.id}:"
response = response[:-1]
return response
or (with indexes)
@client.request
def searchTrending(): #called when client receives request
response = ""
projects = scratch3.search_projects(query="query", mode="trending", language="en", limit=40, offset=0)
for idx, p in enumerate(projects):
response += f"{p.title};{p.author};{p.id}"
if idx != len(projects)-1: response += ":"
return response
from scratchattach.
Related Issues (20)
- Pass integers in session.connect_user() as user ID values HOT 3
- Ghost requests are back. HOT 4
- no way to get a comment from its comment id (at least i think) HOT 3
- Incorrect Error HOT 4
- Issue getting messages HOT 1
- How to check if user exists? HOT 2
- Weird error??? HOT 1
- How do i sign in with an incorrect password, and make the program know that something is incorrect without crashing HOT 2
- Make api request functions unlimited #206 HOT 3
- Implement a Proper Way to Check “New Scratcher” Status HOT 8
- Implement a Way to Check Account Status HOT 2
- (upcoming update) Enhance cloud requests by replacing busy-sleep event loop HOT 6
- Scratch project response list is randomly (at least seems like randomly) displaying "Error: Check the Python console" HOT 4
- How do you create a request in the python code HOT 3
- 'User' object has no attribute 'is_new_scratcher' HOT 2
- Bug in the function of obtaining cloud variables HOT 1
- How do/can I package a scratchattach project using the turbowarp packager? HOT 2
- SESSION IDS EXPIRED HOT 2
- Why events.user reports None while logged in? HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scratchattach.