Discuss Scratch

Wei-ern_520
Scratcher
500+ posts

Python programming language

Does anyone know about “this” module?

All you need to import this module (no pun intended) is to run the following line:

 import this

Last edited by Wei-ern_520 (Sept. 28, 2021 06:24:51)


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

Python programming language

Wei-ern_520 wrote:

Does anyone know about “this” module?
ninja'd!
https://scratch.mit.edu/discuss/post/5515579/

mybearworld wrote:

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!!!







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
Wei-ern_520
Scratcher
500+ posts

Python programming language

Chiroyce wrote:

Wei-ern_520 wrote:

Does anyone know about “this” module?
ninja'd!
https://scratch.mit.edu/discuss/post/5515579/

mybearworld wrote:

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!!!
What about antigravity

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

Python programming language

Wei-ern_520 wrote:

What about antigravity
I'm not sure if it was mentioned but I know that one.
https://github.com/python/cpython/blob/main/Lib/antigravity.py

Last edited by ninjaMAR (Sept. 28, 2021 07:40:18)

Wei-ern_520
Scratcher
500+ posts

Python programming language

ninjaMAR wrote:

Wei-ern_520 wrote:

What about antigravity
I'm not sure if it was mentioned but I know that one.
https://github.com/python/cpython/blob/main/Lib/antigravity.py
Does importing that module in your ide take you to a website with a comic?

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

Python programming language

Wei-ern_520 wrote:

ninjaMAR wrote:

Wei-ern_520 wrote:

What about antigravity
I'm not sure if it was mentioned but I know that one.
https://github.com/python/cpython/blob/main/Lib/antigravity.py
Does importing that module in your ide take you to a website with a comic?
Yes. It takes me to https://xkcd.com/353/
Wei-ern_520
Scratcher
500+ posts

Python programming language

Then that is it. Also, why does importing ok just print ok? And why are there so many random modules as such?

Such as this, six, ok, antigravity, that I do not understand.

Last edited by Wei-ern_520 (Sept. 28, 2021 10:58:43)


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

Python programming language

Wei-ern_520 wrote:

that I do not understand.
for fun reasons I guess? also they're called Easter Eggs - https://en.wikipedia.org/wiki/Easter_egg_(media)







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

Python programming language

def recursion(a):
    try:
        recursion(a)
    except RecursionError:
        try:
            recursion(a)
        except RecursionError:
            try:
                recursion(a)
            except RecursionError:
                return 'whew im tired after all of this recursion!'
recursion(1)
throws an error like -

Fatal Python error: _Py_CheckRecursiveCall: Cannot recover from stack overflow.
Python runtime state: initialized

....

zsh: abort /usr/local/bin/python3
what?!

Last edited by Chiroyce (Sept. 29, 2021 08:53:00)








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
Wei-ern_520
Scratcher
500+ posts

Python programming language

Chiroyce wrote:

def recursion(a):
    try:
        recursion(a)
    except RecursionError:
        try:
            recursion(a)
        except RecursionError:
            try:
                recursion(a)
            except RecursionError:
                return 'whew im tired after all of this recursion!'
recursion(1)
throws an error like -

Fatal Python error: _Py_CheckRecursiveCall: Cannot recover from stack overflow.
Python runtime state: initialized

....

zsh: abort /usr/local/bin/python3
what?!
Throws the same error for me, but who would do this in a program? And by stacking perhaps they meant the number of times it's run, or the fact that calling it after an error and again causes this overflow?

No matter what, only the real writers of this language will know what it means.

Last edited by Wei-ern_520 (Sept. 29, 2021 09:10:09)


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

Python programming language

Chiroyce wrote:

def recursion(a):
    try:
        recursion(a)
    except RecursionError:
        try:
            recursion(a)
        except RecursionError:
            try:
                recursion(a)
            except RecursionError:
                return 'whew im tired after all of this recursion!'
recursion(1)
throws an error like -

Fatal Python error: _Py_CheckRecursiveCall: Cannot recover from stack overflow.
Python runtime state: initialized

....

zsh: abort /usr/local/bin/python3
what?!
>>> def _():
	_()
	
>>> _()
Traceback (most recent call last):
  File "<pyshell#3>", line 1, in <module>
    _()
  File "<pyshell#2>", line 2, in _
    _()
  File "<pyshell#2>", line 2, in _
    _()
  File "<pyshell#2>", line 2, in _
    _()
  [Previous line repeated 1022 more times]
RecursionError: maximum recursion depth exceeded
>>> 
However…
>>> import sys
>>> sys.setrecursionlimit(10000)
>>> def _():
	_()
	
>>> _()
================================ RESTART: Shell ================================
>>> 
No idea how you got that message.

Last edited by mybearworld (Sept. 29, 2021 12:18:05)


Signatures are the only place where assets links still work.
Chiroyce
Scratcher
1000+ posts

Python programming language

mybearworld wrote:

No idea how you got that message.
Why don't you make a .py file with the same contents as this and run it
def recursion(a):
    try:
        recursion(a)
    except RecursionError:
        try:
            recursion(a)
        except RecursionError:
            try:
                recursion(a)
            except RecursionError:
                return 'whew im tired after all of this recursion!'
recursion(1)







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

Python programming language

The most useful feature of requests

Signatures are the only place where assets links still work.
mybearworld
Scratcher
1000+ posts

Python programming language

Chiroyce wrote:

mybearworld wrote:

No idea how you got that message.
Why don't you make a .py file with the same contents as this and run it
def recursion(a):
    try:
        recursion(a)
    except RecursionError:
        try:
            recursion(a)
        except RecursionError:
            try:
                recursion(a)
            except RecursionError:
                return 'whew im tired after all of this recursion!'
recursion(1)
because I sometimes don't realize extremely obvious things xD
Anyways…


Signatures are the only place where assets links still work.
mybearworld
Scratcher
1000+ posts

Python programming language

ScratchCatHELLO wrote:

I think it stores other stuff too
Python 3.9.5 (default, May  5 2021, 02:58:34) 
[GCC 7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> a = 1
>>> globals()
{'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <class '_frozen_importlib.BuiltinImporter'>, '__spec__': None, '__annotations__': {}, '__builtins__': <module 'builtins' (built-in)>, 'a': 1}
>>> 
Responding to this post just to say that globals does only store variables.
Python 3.9.7 (tags/v3.9.7:1016ef3, Aug 30 2021, 20:19:38) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> a = 1
>>> globals()
{'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <class '_frozen_importlib.BuiltinImporter'>, '__spec__': None, '__annotations__': {}, '__builtins__': <module 'builtins' (built-in)>, 'a': 1}
>>> print(__name__)
__main__
>>> print(__doc__)
None
>>> print(__package__)
None
>>> print(__loader__)
<class '_frozen_importlib.BuiltinImporter'>
>>> print(__spec__)
None
>>> print(__annotations__)
{}
>>> print(__builtins__)
<module 'builtins' (built-in)>
>>> print(a)
1
also, fun fact, you can call help(__builtins__).

Signatures are the only place where assets links still work.
chandler2010
Scratcher
25 posts

Python programming language

I made a text editor appender

Full code:
————-

writing = 1
name = str(input('Name of the document: '))
print(f'PyWrite with {name}.txt\n')
with open(f'{name}.txt', 'a') as f:
pass
with open(f'{name}.txt', 'r') as f:
for line in f:
print(line, end='')
with open(f'{name}.txt', 'a') as f:
while writing == 1:
writestring = str(input(''))
if writestring == '@exit':
writing = 0
else:
f.write(f'{writestring}\n')
Explanation:
—————–
This creates the file if the file doesn't already exist:

with open(f'{name}.txt', 'a') as f:
pass
This reads the file and prints it to the screen:
with open(f'{name}.txt', 'r') as f:
for line in f:
print(line, end='')
This writes any new input to the file:
with open(f'{name}.txt', 'a') as f:
while writing == 1:
writestring = str(input(''))
if writestring == '@exit':
writing = 0
else:
f.write(f'{writestring}\n')
If the input is ‘@exit’ it would stop the script.

Last edited by chandler2010 (Oct. 3, 2021 14:21:36)

-EmeraldThunder-
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.
It's the best python game library about.

Nothing here.
roketH77
Scratcher
1000+ posts

Python programming language

chandler2010 wrote:

I made a text editor appender

Full code:
————-

writing = 1
name = str(input('Name of the document: '))
print(f'PyWrite with {name}.txt\n')
with open(f'{name}.txt', 'a') as f:
pass
with open(f'{name}.txt', 'r') as f:
for line in f:
print(line, end='')
with open(f'{name}.txt', 'a') as f:
while writing == 1:
writestring = str(input(''))
if writestring == '@exit':
writing = 0
else:
f.write(f'{writestring}\n')
Explanation:
—————–
This creates the file if the file doesn't already exist:

with open(f'{name}.txt', 'a') as f:
pass
This reads the file and prints it to the screen:
with open(f'{name}.txt', 'r') as f:
for line in f:
print(line, end='')
This writes any new input to the file:
with open(f'{name}.txt', 'a') as f:
while writing == 1:
writestring = str(input(''))
if writestring == '@exit':
writing = 0
else:
f.write(f'{writestring}\n')
If the input is ‘@exit’ it would stop the script.
Set writing to True at the start, and when @exit is called set it to False (not “True”, just True or False, no quotes) and you can replace while writing == 1: to just while writing:

Moved to reidling–
cinnamvn
Scratcher
3 posts

Python programming language

i work part time as a tutor, and i’m currently teaching computer science to a few of my students ^^ python is the main programming language i use, as well as scratch for the more younger ones. i’m /attempting/ to make a mystery game right now :>

Last edited by cinnamvn (Oct. 3, 2021 20:24:55)

gosoccerboy5
Scratcher
1000+ posts

Python programming language

cinnamvn wrote:

i work part time as a tutor, and i’m currently teaching computer science to a few of my students ^^ python is the main programming language i use, as well as scratch for the more younger ones. i’m /attempting/ to make a mystery game right now :>
Pretty cool! Good luck!

Powered by DjangoBB