Discuss Scratch

Reev0102
Scratcher
1000+ posts

Python programming language

Chiroyce wrote:

OK then, and also use .json to parse JSON response and .text for non-JSON responses.
I am aware of that. I am also aware that
["x"]
is used to get a part of the JSON.
ScratchCatHELLO
Scratcher
1000+ posts

Python programming language

Reev0102 wrote:

Chiroyce wrote:

OK then, and also use .json to parse JSON response and .text for non-JSON responses.
I am aware of that. I am also aware that
["x"]
is used to get a part of the JSON.

because parsing the JSON returns a dict





ScratchCatHELLO
I have 5600+ posts, I've been on scratch for 5 1/2 years, I'm a Forum Helper™ and I have a Scratch Wiki account!
I like: Python, CSS, Javascript, Rust



Python 3 Text Adventure
cool new browser game - cursed laughing-crying emoji - Illuminati - you know waterbenders, but do you know stock-imagebenders? - snek - vibin' - Bump song (vevo) - Speed bump - yee - fred - m i c k e y
Meowswish55
Scratcher
100+ posts

Python programming language

ScratchCatHELLO wrote:

Meowswish55 wrote:

Yeah. I hate having to redefine the “if mouse position is within object's borders”.

if you want it to detect clicks, you can use event.pos and have a rect object for the clickable area. then you can use spritecollide to detect whether the rect was clicked on.

Thats what ive been doing.

Froggo | She/Her

ScratchCatHELLO
Scratcher
1000+ posts

Python programming language

“fun” facts:
since True is 1, (and False is 0)
print(["a", "b"][True])
will print
b

you can get an overflow error in python in just 17 letters:
int(float("inf"))
also, yes, there is infinity in python
and negative infinity
but only when working with floats

Last edited by ScratchCatHELLO (Aug. 10, 2021 23:08:35)






ScratchCatHELLO
I have 5600+ posts, I've been on scratch for 5 1/2 years, I'm a Forum Helper™ and I have a Scratch Wiki account!
I like: Python, CSS, Javascript, Rust



Python 3 Text Adventure
cool new browser game - cursed laughing-crying emoji - Illuminati - you know waterbenders, but do you know stock-imagebenders? - snek - vibin' - Bump song (vevo) - Speed bump - yee - fred - m i c k e y
Reev0102
Scratcher
1000+ posts

Python programming language

Is it possible to set a variable to the contents of a Scratch cloud variable with ScratchClient or something?
Chiroyce
Scratcher
1000+ posts

Python programming language

Reev0102 wrote:

Is it possible to set a variable to the contents of a Scratch cloud variable with ScratchClient or something?
yep, i have some code here not tested
"""
make sure you have the requests module installed
if not, run `pip install requests` in a terminal window
"""
import requests as req
def getValue(varName, projectID): # both args are strings
    # get the cloud log as json
    response = req.get(f"https://clouddata.scratch.mit.edu/logs?projectid={projectID}&limit=100&offset=1").json()
    for i in range(0,100):
        # loop through every item in the log, as we go from 0  - 100
        # we will surely get the LATEST value of the variable
        if response[i]['name'] == varName:
            # if we find that an item in the log is related to our variable
            return response[i]['value']
            break
it may not work try it out and tell me …

Last edited by Chiroyce (Aug. 11, 2021 15:32:47)








April Fools' topics:
New Buildings in Scratch's headquarters
Give every Scratcher an M1 MacBook Air
Scratch should let users edit other Scratchers' projects
Make a statue for Jeffalo
Scratch Tech Tips™
Make a Chiroyce statue emoji


<img src=“x” onerror=“alert('XSS vulnerability discovered')”>

this is a test sentence
Reev0102
Scratcher
1000+ posts

Python programming language

Chiroyce wrote:

-snip-
What about a regular variable?
Chiroyce
Scratcher
1000+ posts

Python programming language

Reev0102 wrote:

What about a regular variable?
We can! Gimme a sec …

You'd have to get it somehow via the project.JSON api, here https://projects.scratch.mit.edu/390546523/
390546523 = project ID

i think you may also need the sprite name for this … not sure since the JSON file has a lot of keys and is confusing

Last edited by Chiroyce (Aug. 11, 2021 16:27:07)








April Fools' topics:
New Buildings in Scratch's headquarters
Give every Scratcher an M1 MacBook Air
Scratch should let users edit other Scratchers' projects
Make a statue for Jeffalo
Scratch Tech Tips™
Make a Chiroyce statue emoji


<img src=“x” onerror=“alert('XSS vulnerability discovered')”>

this is a test sentence
wvj
Scratcher
1000+ posts

Python programming language

run this in shell

import this

mybearworld
Scratcher
1000+ posts

Python programming language

wvj wrote:

run this in shell

import this

Import this now! You get 5 perks!
  1. A variable named this.c with the value 97!
  2. A variable named this.d containing a dictionary of all letters a-z+A-Z with their rot13 counterparts!
  3. A variable named this.i with the value 25!
  4. A variable named this.i which is The Zen of Python encoded using rot13!
  5. Best of all, when importing this, you get The Zen of Python printed in your console for FREE!!!

Last edited by mybearworld (Aug. 12, 2021 13:17:48)


Signatures are the only place where assets links still work.
Sid72020123
Scratcher
500+ posts

Python programming language

Python Program to invite your all followers to a studio automatically:
See The code here: https://gist.github.com/Sid72020123/c8293359b57c93ca908cfc246079b02b

Last edited by Sid72020123 (Aug. 17, 2021 09:49:31)


Sid72020123
Reev0102
Scratcher
1000+ posts

Python programming language

Sid72020123 wrote:

Here's a Python Program to invite your all followers to a studio automatically:
-snip-
I don't think you should share that.
Chiroyce
Scratcher
1000+ posts

Python programming language

Reev0102 wrote:

I don't think you should share that.
I agree - people may abuse it, make sure to license it under the MIT license, remove the code from your forum post, and upload it to GitHub. Only share the link to it on scratch and not the code itself.







April Fools' topics:
New Buildings in Scratch's headquarters
Give every Scratcher an M1 MacBook Air
Scratch should let users edit other Scratchers' projects
Make a statue for Jeffalo
Scratch Tech Tips™
Make a Chiroyce statue emoji


<img src=“x” onerror=“alert('XSS vulnerability discovered')”>

this is a test sentence
Sid72020123
Scratcher
500+ posts

Python programming language

Chiroyce wrote:

Reev0102 wrote:

I don't think you should share that.
I agree - people may abuse it, make sure to license it under the MIT license, remove the code from your forum post, and upload it to GitHub. Only share the link to it on scratch and not the code itself.
Done

Sid72020123
Chiroyce
Scratcher
1000+ posts

Python programming language

Sid72020123 wrote:

Done
great!







April Fools' topics:
New Buildings in Scratch's headquarters
Give every Scratcher an M1 MacBook Air
Scratch should let users edit other Scratchers' projects
Make a statue for Jeffalo
Scratch Tech Tips™
Make a Chiroyce statue emoji


<img src=“x” onerror=“alert('XSS vulnerability discovered')”>

this is a test sentence
devms
Scratcher
500+ posts

Python programming language

Hi ( I'm currently learning python 3.9) also how can you use python to make websites because I can't find it in any section in the IDE's (I use pycharm community edition 2021.2 and Microsoft visual studio code with python)
Edit: I am asking this question because I saw someone do web development in python

Last edited by devms (Aug. 21, 2021 08:20:02)


Last edited by devms(May. 15th, 2007, 00:00:00)
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
My Scratch Profile

Sadly, my old signature was sent to the shadow realm

My browser / operating system: Windows Vista (NT 6.0), Internet Explorer 7.0, Flash 32 (Release 0)

Reev0102
Scratcher
1000+ posts

Python programming language

devms wrote:

Hi ( I'm currently learning python 3.9) also how can you use python to make websites because I can't find it in any section in the IDE's (I use pycharm community edition 2021.2 and Microsoft visual studio code with python)
You can't make websites with Python; to make a website you need to use HTML, CSS and JavaScript.
devms
Scratcher
500+ posts

Python programming language

Reev0102 wrote:

devms wrote:

Hi ( I'm currently learning python 3.9) also how can you use python to make websites because I can't find it in any section in the IDE's (I use pycharm community edition 2021.2 and Microsoft visual studio code with python)
You can't make websites with Python; to make a website you need to use HTML, CSS and JavaScript.
Oh ok I was asking question because I saw in a yt video about hacking scammers with python

Last edited by devms(May. 15th, 2007, 00:00:00)
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
My Scratch Profile

Sadly, my old signature was sent to the shadow realm

My browser / operating system: Windows Vista (NT 6.0), Internet Explorer 7.0, Flash 32 (Release 0)

-EmeraldThunder-
Scratcher
1000+ posts

Python programming language

devms wrote:

Reev0102 wrote:

devms wrote:

Hi ( I'm currently learning python 3.9) also how can you use python to make websites because I can't find it in any section in the IDE's (I use pycharm community edition 2021.2 and Microsoft visual studio code with python)
You can't make websites with Python; to make a website you need to use HTML, CSS and JavaScript.
Oh ok I was asking question because I saw in a yt video about hacking scammers with python
You can use python as a backend for your site and use a framework like Flask or Django.

Nothing here.
ScratchCatHELLO
Scratcher
1000+ posts

Python programming language


Reev0102 wrote:

devms wrote:

Hi ( I'm currently learning python 3.9) also how can you use python to make websites because I can't find it in any section in the IDE's (I use pycharm community edition 2021.2 and Microsoft visual studio code with python)
You can't make websites with Python; to make a website you need to use HTML, CSS and JavaScript.

you can use python instead of javascript by using brython, and you can use flask or django (for big projects) with a (no?)SQL database to do a backend





ScratchCatHELLO
I have 5600+ posts, I've been on scratch for 5 1/2 years, I'm a Forum Helper™ and I have a Scratch Wiki account!
I like: Python, CSS, Javascript, Rust



Python 3 Text Adventure
cool new browser game - cursed laughing-crying emoji - Illuminati - you know waterbenders, but do you know stock-imagebenders? - snek - vibin' - Bump song (vevo) - Speed bump - yee - fred - m i c k e y

Powered by DjangoBB