Discuss Scratch

TimMcCool
Scratcher
100+ posts

scratchattach - A Scratch API wrapper (Python)

ScratchcatandGobo wrote:

How are you even supposed to set a cloud variable to a python variable? This is really bugging me…
conn = session.connect_cloud(project_id=“688967859”)
user = session.connect_user(“griffpatch”)
session.get_linked_user()
variable = user.follower_count()
conn.set_var(“Username”, variable)

To fix the problem, replace
 conn.set_var("Username", variable) 
with
 conn.set_var("Username", str(variable)) 

Or update to the latest scratchattach version using
 pip install scratchattach --upgrade

Developer of scratchattach, the most popular Python Scratch API wrapper
ScratchTheCoder12345
Scratcher
500+ posts

scratchattach - A Scratch API wrapper (Python)

What caused you to rename it? Just curious.

Hello, I'm Brandon a Python developer who loves math and coding.
he/him
Feel free to message me with any questions
coolcoder1213
Scratcher
100+ posts

scratchattach - A Scratch API wrapper (Python)

ScratchTheCoder12345 wrote:

What caused you to rename it? Just curious.


Yeah?

So, this is just a signature.

Scratchleton - Hamilton Mod

Cloud Stats Projects

My Profile:
coolcoder1213

I am great at cloud variables and Python.
BLUE_2030
Scratcher
3 posts

scratchattach - A Scratch API wrapper (Python)

Traceback (most recent call last):
File “C:\Users\X240\PycharmProjects\pythonProject6\scratch3.py\test.py”, line 1, in <module>
import scratch3
File “C:\Users\X240\PycharmProjects\pythonProject6\venv\scratch3.py”, line 3, in <module>
session = scratch3.login(“username”, “passwordo”) #replace with your data
AttributeError: partially initialized module ‘scratch3’ has no attribute ‘login’ (most likely due to a circular import)

Last edited by BLUE_2030 (May 11, 2022 23:42:51)

ScratchcatandGobo
Scratcher
1000+ posts

scratchattach - A Scratch API wrapper (Python)

BLUE_2030 wrote:

Traceback (most recent call last):
File “C:\Users\X240\PycharmProjects\pythonProject6\scratch3.py\test.py”, line 1, in <module>
import scratch3
File “C:\Users\X240\PycharmProjects\pythonProject6\venv\scratch3.py”, line 3, in <module>
session = scratch3.login(“username”, “passwordo”) #replace with your data
AttributeError: partially initialized module ‘scratch3’ has no attribute ‘login’ (most likely due to a circular import)
add ()

Yeah, but at least we've learned something today… that every moment of our life should be lived to the fullest because it can be very long or very short, my friend. - Gumball
I felt like I wanted to develop games on here, so I won't leave! (for now)
(last edited 2/8/24)





























kccuber
Scratcher
1000+ posts

scratchattach - A Scratch API wrapper (Python)

ScratchTheCoder12345 wrote:

What caused you to rename it? Just curious.
It sounded like it was the name of a python file before

BLUE_2030 wrote:

Traceback (most recent call last):
File “C:\Users\X240\PycharmProjects\pythonProject6\scratch3.py\test.py”, line 1, in <module>
import scratch3
File “C:\Users\X240\PycharmProjects\pythonProject6\venv\scratch3.py”, line 3, in <module>
session = scratch3.login(“username”, “passwordo”) #replace with your data
AttributeError: partially initialized module ‘scratch3’ has no attribute ‘login’ (most likely due to a circular import)
update the module, it's called scratchattach now and shouldn't be causing circular import error because it's not named scratch3.py anymore
pip install scratchattach --upgrade

Last edited by kccuber (May 12, 2022 01:26:39)



Made using Nord Theme & Inkscape
-FreeEngines-
Scratcher
100+ posts

scratchattach - A Scratch API wrapper (Python)

ScratchcatandGobo wrote:

How are you even supposed to set a cloud variable to a python variable? This is really bugging me…
conn = session.connect_cloud(project_id=“688967859”)
user = session.connect_user(“griffpatch”)
session.get_linked_user()
variable = user.follower_count()
conn.set_var(“Username”, variable)

scratchAttach.get_var(“project_id”, “variable”)
(thats whati get from the github docs, you should read it)
this function returns the value of the variable, so you can kind catch it with
variableOfYourChoice = scratch3.get_var(“project_id”, “variable”)
-FreeEngines-
Scratcher
100+ posts

scratchattach - A Scratch API wrapper (Python)

ScratchcatandGobo wrote:

How are you even supposed to set a cloud variable to a python variable? This is really bugging me…
conn = session.connect_cloud(project_id=“688967859”)
user = session.connect_user(“griffpatch”)
session.get_linked_user()
variable = user.follower_count()
conn.set_var(“Username”, variable)

oh im stupid, cloud variable to python variable..
so the first thing you wanna do is create an VALID session, which you do by doing
session = scratchattach.login(“username”, “password”)
not that the password must be correct.
connection = session.connect_cloud(project_id=“project_id”)
this sends a handshake to the scratch servers to know you want to connect to the cloud
connection.set_var(“variable”, “value”)
this now sets the variable on the project you specified when connecting to the project with session.connect_cloud(project_id=“yourprojectid”)
so thats it. just replace everything that is in “” with the values you have
_Paxw_
Scratcher
1 post

scratchattach - A Scratch API wrapper (Python)

how are you
ScratchTheCoder12345
Scratcher
500+ posts

scratchattach - A Scratch API wrapper (Python)

kccuber wrote:

ScratchTheCoder12345 wrote:

What caused you to rename it? Just curious.
It sounded like it was the name of a python file before

BLUE_2030 wrote:

Traceback (most recent call last):
File “C:\Users\X240\PycharmProjects\pythonProject6\scratch3.py\test.py”, line 1, in <module>
import scratch3
File “C:\Users\X240\PycharmProjects\pythonProject6\venv\scratch3.py”, line 3, in <module>
session = scratch3.login(“username”, “passwordo”) #replace with your data
AttributeError: partially initialized module ‘scratch3’ has no attribute ‘login’ (most likely due to a circular import)
update the module, it's called scratchattach now and shouldn't be causing circular import error because it's not named scratch3.py anymore
pip install scratchattach --upgrade
ohhhh, I'm so stupid lol

Hello, I'm Brandon a Python developer who loves math and coding.
he/him
Feel free to message me with any questions
PoIygon
Scratcher
1000+ posts

scratchattach - A Scratch API wrapper (Python)

ScratchTheCoder12345 wrote:

What caused you to rename it? Just curious.
Why would a person name it “scratch3” or something like that when it can only do cloud stuff? He changed it because it can only do cloud stuff and “scratch3” implies that it can do everything in the scratch website










UxuginAI
Scratcher
4 posts

scratchattach - A Scratch API wrapper (Python)

scratchfan321 wrote:

Danger comes from myself + terminal
More danger comes from You + Terminal + Sudo
ScratchcatandGobo
Scratcher
1000+ posts

scratchattach - A Scratch API wrapper (Python)

project.set_title(“This project has ”project.views“ Views and ”project.loves“ Loves”)
Syntax error

Yeah, but at least we've learned something today… that every moment of our life should be lived to the fullest because it can be very long or very short, my friend. - Gumball
I felt like I wanted to develop games on here, so I won't leave! (for now)
(last edited 2/8/24)





























coolcoder1213
Scratcher
100+ posts

scratchattach - A Scratch API wrapper (Python)

ScratchTheCoder12345 wrote:

kccuber wrote:

ScratchTheCoder12345 wrote:

What caused you to rename it? Just curious.
It sounded like it was the name of a python file before

BLUE_2030 wrote:

Traceback (most recent call last):
File “C:\Users\X240\PycharmProjects\pythonProject6\scratch3.py\test.py”, line 1, in <module>
import scratch3
File “C:\Users\X240\PycharmProjects\pythonProject6\venv\scratch3.py”, line 3, in <module>
session = scratch3.login(“username”, “passwordo”) #replace with your data
AttributeError: partially initialized module ‘scratch3’ has no attribute ‘login’ (most likely due to a circular import)
update the module, it's called scratchattach now and shouldn't be causing circular import error because it's not named scratch3.py anymore
pip install scratchattach --upgrade
ohhhh, I'm so stupid lol


Yeah. I asked the same question.

So, this is just a signature.

Scratchleton - Hamilton Mod

Cloud Stats Projects

My Profile:
coolcoder1213

I am great at cloud variables and Python.
SansStudios
Scratcher
1000+ posts

scratchattach - A Scratch API wrapper (Python)

ScratchcatandGobo wrote:

project.set_title(“This project has ”project.views“ Views and ”project.loves“ Loves”)
Syntax error

That isn't how you combine strings in python.

You can use an addition operator:

text = "This project has " + str(project.views) + " Views and " + str(project.loves) + " Loves"

Or a f-string:

text = f"This project has {project.views} Views and {project.loves} Loves"

Or others like `str.format`

scratchcloud
Click above to check it out! I've worked on it for over a year!























Just like sudden sadness comes hangin' on the breeze
Wolf_Hunter77
Scratcher
37 posts

scratchattach - A Scratch API wrapper (Python)

Sounds hard but good. I hope to see more projects using it in the future.

Hello everyone who is reading this! Check out my game Spider Scratch where you play as the scratch universe's Spider Man as you fight villains and try to escape Oscorp! Click it to play!
.


.
scratchyjimjam
Scratcher
84 posts

scratchattach - A Scratch API wrapper (Python)

this is really good! I'm using it on one of my projects right now!

when green flag clicked
say [This is scratchyjimjam's signature] for (2) secs


-SCRATCHYJIMJAM-
729593Patrek
Scratcher
12 posts

scratchattach - A Scratch API wrapper (Python)

What server do you recommend? Replit shuts down all the time for me? I have to keep it free though…
CST1229
Scratcher
1000+ posts

scratchattach - A Scratch API wrapper (Python)

729593Patrek wrote:

(#60)
What server do you recommend? Replit shuts down all the time for me? I have to keep it free though…
Personally I'd use Replit + some library to have the server serve a HTTP page somewhere + some pinger that pings said page (uptimerobot or verixion's pinger also on replit)

This is a signature. It's a piece of text that appears below every post I write. Click here to learn more, including how to make your own.

Thanks Jeffalo
RIP assets image hosting. 2013?-2023


-FreeEngines-
Scratcher
100+ posts

scratchattach - A Scratch API wrapper (Python)

If replit shuts down, you're most likely using it wrongly

Powered by DjangoBB