Discuss Scratch
- Discussion Forums
- » Things I'm Making and Creating
- » Python programming language
- -TWILIGHTMISTY-
- Scratcher
1000+ posts
Python programming language
print ("I should get back on my python learning course")
I'm Callisto(please don't call me Twilight), but you can call me Cal/Cass. I go by she/he/they pronouns.
- ScratchCatHELLO
- Scratcher
1000+ posts
Python programming language
i would have said tkinter, but it's not that great in all honesty hahaha What's the best python GUI library.
hot take: tkinter sucks
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
- mybearworld
- Scratcher
1000+ posts
Python programming language
I only ever did one GUI-app with python. It was with tkinter. That… certainly was… terrible xDi would have said tkinter, but it's not that great in all honesty hahaha What's the best python GUI library.
hot take: tkinter sucks
Signatures are the only place where assets links still work.
- scott170
- Scratcher
84 posts
Python programming language
tryHmm, I runHow does python async work? Promises/Futures? Async is newer a lot newer, while threading has been around since Python 2 and is also lower level, needing to deal with the operating system.and the output saysasync def foo(): return 0 print(foo())so maybe coroutines?<coroutine object foo at 0x7ff18363e8c0>
<string>:3: RuntimeWarning: coroutine 'foo' was never awaited
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
async def foo(): return 0 print(await foo())
Last edited by scott170 (Sept. 25, 2021 17:54:10)
- gosoccerboy5
- Scratcher
1000+ posts
Python programming language
I know how to use async code, I just wanted to see the representation of a not-yet-completed async function tryasync def foo(): return 0 print(await foo())
also, please close your code tags..
Last edited by gosoccerboy5 (Sept. 25, 2021 19:50:39)
- imfh
- Scratcher
1000+ posts
Python programming language
Python uses several different types of awaitables. When you create a function like the above, it is a coroutine. Another awaitable is a Task, which is used to schedule a function to run without blocking (example below). Finally, Python also uses Futures, but they are just a low level type mainly used behind the scenes to create more useful types. See the Python docs about these.Hmm, I runHow does python async work? Promises/Futures? Async is newer a lot newer, while threading has been around since Python 2 and is also lower level, needing to deal with the operating system.and the output saysasync def foo(): return 0 print(foo())so maybe coroutines?<coroutine object foo at 0x7ff18363e8c0>
<string>:3: RuntimeWarning: coroutine 'foo' was never awaited
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
import asyncio async def foo(): print("foo") async def bar(): print("bar1") foo() # Wrong, foo is never awaited so it will never run print("bar2") await foo() # This works but also blocks print("bar3") asyncio.create_task(foo()) # This schedules foo to run later print("bar4") await asyncio.sleep(0) # Sleeping lets other tasks run print("bar5") asyncio.run(bar())
bar1 <stdin>:3: RuntimeWarning: coroutine 'foo' was never awaited RuntimeWarning: Enable tracemalloc to get the object allocation traceback bar2 foo bar3 bar4 foo bar5
Scratch to Pygame converter: https://scratch.mit.edu/discuss/topic/600562/
- Wei-ern_520
- Scratcher
500+ posts
Python programming language
What do you think of pygame? Is it slow? It seems to be able to withstand a FPS stress test of 3000 particles(from a video that I seen), but some say it is slow.
Last edited by Wei-ern_520 (Sept. 26, 2021 05:51:23)
Please consider checking out my suggestion ->here<-.
Hello, I’m Wei-ern_520, and I will randomly appear in your room! Just kidding, I make rpg engines.
I have no custom pfp, not because I don't know how to make one. I just don't know what suits me best, and I'm just too lazy and prefer sticking to simplicity. Or at least so. I also have the need to trip people with my profile picture. Just wait till it happens.
Fun fact: you don't clean your mess, you move it somewhere else. (Source: somewhere)
Also: Ooh, look at the cheese!
- Virus6120
- Scratcher
100+ posts
Python programming language
Making a programming language in Python was a bad idea…
Welcoming all contributors, explorers, and kumquats
Heya there, I'm currently doing some renovations to my signature, but you're welcome to stay if you like.
- Wei-ern_520
- Scratcher
500+ posts
Python programming language
Then if you were to make a tile scrolling game (any), would you rather:It is very fast. What do you think of pygame? Is it slow? It seems to be able to withstand a FPS stress test of 3000 particles(from a video that I seen).
Create instances of each tiles and update by their own class
Or:
Use a loop to iterate through all items in the list and blit them all in one “for” loop
Would they be differently affected?
Which is faster in your opinion, which would you prefer, and what tips or advice would you give for this?
Last edited by Wei-ern_520 (Sept. 26, 2021 10:19:56)
Please consider checking out my suggestion ->here<-.
Hello, I’m Wei-ern_520, and I will randomly appear in your room! Just kidding, I make rpg engines.
I have no custom pfp, not because I don't know how to make one. I just don't know what suits me best, and I'm just too lazy and prefer sticking to simplicity. Or at least so. I also have the need to trip people with my profile picture. Just wait till it happens.
Fun fact: you don't clean your mess, you move it somewhere else. (Source: somewhere)
Also: Ooh, look at the cheese!
- scott170
- Scratcher
84 posts
Python programming language
why? Making a programming language in Python was a bad idea…
- ScratchCatHELLO
- Scratcher
1000+ posts
Python programming language
What do you think of pygame? Is it slow? It seems to be able to withstand a FPS stress test of 3000 particles(from a video that I seen), but some say it is slow.
AFAIK it’s written in C++, so the engine itself is definitely not slow. the script that uses it is the slow part.
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
EmeraldThunder, try this:
If that doesn't work, come back
from flask import Flask, render_template, templating
import requests, sys
app = Flask(__name__)
@app.route('/')
def index():
return render_template('homePage.html')
def loadBlockMarkup(blockname, blockInputs):
print(blockname, file=sys.stdout)
if blockname == ‘set icon’:
return f'<script>changeFavicon({blockInputs});<script>\n'
def LoadProject(id):
blocks = requests.get(f'https://projects.scratch.mit.edu/{id}').json()
if requests.get(f'https://api.scratch.mit.edu/projects/{id}').status_code == 404:
return ‘It appears there is not a scratchweb project here’ # Return the HTML 404 page if there is no ScratchWeb page.
RAW_HTML = ‘Hello’
for key in blocks:
if blocks == ‘procedures_call’:
inputs = blocks
blockName = blocks.split(' %s').lower()
input_array =
for _input in inputs:
input_array.append(inputs)
RAW_HTML += str(loadBlockMarkup(blockName, input_array))
return RAW_HTML
@app.route('/projects/<id>/')
def projectPage(id):
# Parse project.json and return appropriate HTML
print(id)
return templating.Template('site.html').render(LoadProject=LoadProject, _id=id)
if __name__ == ‘__main__’:
app.run(host='localhost')
If that doesn't work, come back
- codeitfast
- Scratcher
11 posts
Python programming language
Does anyone know how to inject python into scratch? I've been hoping to do so, but I don't know where to start.
- Reev0102
- Scratcher
1000+ posts
Python programming language
You can't. Does anyone know how to inject python into scratch? I've been hoping to do so, but I don't know where to start.
- codeitfast
- Scratcher
11 posts
Python programming language
I think they thought that making a programming language in python was a bad idea because it is an interpreted language and not a compiled one. This makes it slower for heavy computational languages.why? Making a programming language in Python was a bad idea…
- gosoccerboy5
- Scratcher
1000+ posts
Python programming language
Does anyone know how to inject python into scratch? I've been hoping to do so, but I don't know where to start.edublocks.org is kind of similar to Scratch but it lets you use Python.
It also gives you a longer syntactic leash (ie, you can do what you like with the blocks at the risk that you will get a syntax error)
Last edited by gosoccerboy5 (Sept. 27, 2021 16:45:30)
- scott170
- Scratcher
84 posts
Python programming language
ah I seeI know how to use async code, I just wanted to see the representation of a not-yet-completed async function tryasync def foo(): return 0 print(await foo())
also, please close your code tags..
- gosoccerboy5
- Scratcher
1000+ posts
Python programming language
Well in retrospect I could have used `type()` ah I see