Discuss Scratch

-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

kccuber wrote:

-EmeraldThunder- wrote:

What's the best python GUI library.
i would have said tkinter, but it's not that great in all honesty hahaha

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
mumu245
Scratcher
1000+ posts

Python programming language

-EmeraldThunder- wrote:

What's the best python GUI library.
PySide6

select this text then press Ctrl+Shift+Down to read more
mybearworld
Scratcher
1000+ posts

Python programming language

ScratchCatHELLO wrote:

kccuber wrote:

-EmeraldThunder- wrote:

What's the best python GUI library.
i would have said tkinter, but it's not that great in all honesty hahaha

hot take: tkinter sucks
I only ever did one GUI-app with python. It was with tkinter. That… certainly was… terrible xD

Signatures are the only place where assets links still work.
scott170
Scratcher
84 posts

Python programming language

gosoccerboy5 wrote:

gosoccerboy5 wrote:

imfh wrote:

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.
How does python async work? Promises/Futures?
Hmm, I run
async def foo():
    return 0
print(foo())
and the output says
<coroutine object foo at 0x7ff18363e8c0>
<string>:3: RuntimeWarning: coroutine 'foo' was never awaited
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
so maybe coroutines?
try
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

scott170 wrote:

try
async def foo():
    return 0
print(await foo())
I know how to use async code, I just wanted to see the representation of a not-yet-completed async function
also, please close your code tags..

Last edited by gosoccerboy5 (Sept. 25, 2021 19:50:39)


imfh
Scratcher
1000+ posts

Python programming language

gosoccerboy5 wrote:

gosoccerboy5 wrote:

imfh wrote:

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.
How does python async work? Promises/Futures?
Hmm, I run
async def foo():
    return 0
print(foo())
and the output says
<coroutine object foo at 0x7ff18363e8c0>
<string>:3: RuntimeWarning: coroutine 'foo' was never awaited
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
so maybe coroutines?
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.

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())
Output:
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!
mumu245
Scratcher
1000+ posts

Python programming language

Wei-ern_520 wrote:

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).
It is very fast.

select this text then press Ctrl+Shift+Down to read more
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

mumu245 wrote:

Wei-ern_520 wrote:

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).
It is very fast.
Then if you were to make a tile scrolling game (any), would you rather:

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

Virus6120 wrote:

Making a programming language in Python was a bad idea…
why?
ScratchCatHELLO
Scratcher
1000+ posts

Python programming language

Wei-ern_520 wrote:

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:

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

Froggo | She/Her

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

codeitfast wrote:

Does anyone know how to inject python into scratch? I've been hoping to do so, but I don't know where to start.
You can't.
codeitfast
Scratcher
11 posts

Python programming language

scott170 wrote:

Virus6120 wrote:

Making a programming language in Python was a bad idea…
why?
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.
gosoccerboy5
Scratcher
1000+ posts

Python programming language

codeitfast wrote:

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

gosoccerboy5 wrote:

scott170 wrote:

try
async def foo():
    return 0
print(await foo())
I know how to use async code, I just wanted to see the representation of a not-yet-completed async function
also, please close your code tags..
ah I see
gosoccerboy5
Scratcher
1000+ posts

Python programming language

scott170 wrote:

ah I see
Well in retrospect I could have used `type()`

Powered by DjangoBB