#voice-chat-text-0

1 messages Β· Page 346 of 1

pine token
#

Agreed

#

LOL

#

men ngl

#

i just wanna

#

touch em toes

#

NAH

#

baegel

#

bae

#

bagel

#

NOT BAG

#

BAGEL

primal shadow
#

haggle for a baggle?

pine token
#

when the 2 g's?

#

bagel

#

or am i dumb?

#

ngl if yall want

#

a strong bagel

#

both πŸ™‚

#

u see

#

NOpe

#

NGL best variabel to use

#

ez to understand u know

somber heath
#

Variable.

pine token
#

😐

#

tnx for the correction 😐

#

ye

#

YEEEEEEEEEEEEEEEEEEEEEEEEEEEEE

#

i used ctrl + c

#

me at night

#

oh nah

#

i was chill with it

#

i didnt mind tbh

#

NAHHHHHHHHHHHH

#

SHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH

#

BOI STOP

#

😐

#

@somber heath help me with this

somber heath
#

@acoustic storm πŸ‘‹

pine token
#
#coinflip
#



import random

Coin = True
TF =True

Sides =["heads", "tails"]

#Randomness
AI = random.choice(Sides)
AI = AI.lower()

#guesses
guess = input("Heads or Tails \n")
guess = guess.lower()

#checking answer
if guess == AI:
    print("AYE!! You where correct.")
elif guess != AI:
    print("Sadly you where wrong.")

#again?
while TF == True:
    check = input("would you like to try again? (yes or no):  ").lower()
    if check == "yes":
        TF = False
    elif check == "no":
        print ("Np let I (lotus.AI) termiate the code.")
        exit()
    else:
        print ("invalid syntax, try again")
Lotus = AI
del AI
    
#game loop
while Coin == True:
    AI = random.choice(Sides)
    AI = AI.lower()

    guess = input("Heads or Tails \n")
    guess = guess.lower()
    if guess == AI:
        print("AYE!! You where correct.")
    else:
        print("Sadly you where wrong.")

    
    check = input("would you like to try again? (yes or no):  ").lower()
    if check == "yes":
        continue
    elif check == "no":
        print ("Np let I (lotus.AI) termiate the code.")
        exit()
    else:
        print ("invalid syntax, try again")
Lotus = AI
del AI
print("ight!")
#

is it good

#

or nah

#

@primal shadow what funny huh

#

ight

primal shadow
#

Just thinking it was a combination of both prior comments. I quite love autoformatters

#

and the problem list from the extensions to clean up the nits

#

where -> were

pine token
#

ummmm

#

like

#

def main():

#

ye

#

i have

#

but

#

i gave it up

#

i tried

#

using it in another code

whole bear
#

whats going on?

pine token
#

just chilling

#

and coding

#

stuff

#

@peak depot welcome back

#

@somber heath ye id also wipe it all away

#

yes sit

#

sir*

#

ight bet

#

ima re write it

#

back

#

this is good?

#

oh

#

tnx man

#

true

vestal copper
#

true

pine token
#

seperate?

#

ight

#

is thsi good tho ?

somber heath
#

!code

wise cargoBOT
#
Formatting code on Discord

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

For long code samples, you can use our pastebin.

pine token
#

ight BET

#

ah yes

somber heath
#

@errant laurel πŸ‘‹

vestal copper
#

@pine token hiy

pine token
#

hi

#

guys

#

so i re did it

#

here is the code

whole bear
#

contrasiv learning?

somber heath
pine token
#

huh

errant laurel
#

Need 50 chats to unmute

pine token
#
import random

sides = ["heads", "tails"]
ai = random.choice(sides)

guess = input("Heads or Tails: ").lower()
if guess == ai:
    print("You win!")
else:
    print("You lose!")

choice = input("Would you like to play again? (yes or no) \n").lower()

while True:
    ai = random.choice(sides)
    guess =  input("Pick  Heads or Tails: ").lower()
    if guess == ai:
        print("you win the answer was", ai)
    else:
        print("you lose the answer was", ai)
    choice = input("Would you like to play again? (yes or no) \n").lower()
    if choice == "no":
        break
    if choice == "yes":
        continue
    else:
        while choice not in ["no", "yes"]:
            print ("there seem to be a mistake pls type yes or no")
            choice = input("Would you like to play again? (yes or no) \n").lower
        else:
            break

errant laurel
#

Restructuring can also be done by python?

pine token
#

is the code correct?

errant laurel
#

Destructuring rather

pine token
#

oh

#

oh

#

damn

wind raptor
#

I've been enjoying Arc

vocal basin
wise cargoBOT
errant laurel
#

@wise cargo

#

@errant laurel check text

#

@wise cargo check text

pine token
#

yo

#

@somber heath i finished the code

#
import random

sides = ["heads", "tails"]
ai = random.choice(sides)

guess = input("Heads or Tails: ").lower()
if guess == ai:
    print("You win! the answer was "+ai)

else:
    print("You lose! the answer was", ai)

choice = input("Would you like to play again? (yes or no) \n").lower()

while True:
    ai = random.choice(sides)
    guess =  input("Heads or Tails: ").lower()
    if guess == ai:
        print("you win the answer was", ai)
    else:
        print("you lose the answer was", ai)
    choice = input("Would you like to play again? (yes or no) \n").lower()
    if choice == "no":
        break
    if choice == "yes":
        continue
    if choice not in ["no", "yes"]:
        print ("there seem to be a mistake pls type yes or no")
        choice = input("Would you like to play again? (yes or no) \n").lower
    if choice in ["no", "yes"]:
        continue

#

still long

#

ight

#

lemme try

#

AHHHHHHHHHHHH

#

dang

#

tnx man

#

true

whole bear
#

try deleting the home folder if he loses

#

πŸ˜‚

pine token
#

lol

#
import random

sides = ["heads", "tails"]
ai = random.choice(sides)

while True:
    ai = random.choice(sides)
    guess =  input("Heads or Tails: ").lower()
    if guess == ai:
        print("you win the answer was", ai)
    else:
        print("you lose the answer was", ai)
    choice = input("Would you like to play again? (yes or no) \n").lower()
    if choice == "no":
        break
    if choice == "yes":
        continue
    if choice not in ["no", "yes"]:
        print ("there seem to be a mistake pls type yes or no")
        choice = input("Would you like to play again? (yes or no) \n").lower
        break
    if choice in ["no", "yes"]:
        continue
#

damn code looks smaller

#

@somber heath tnx man

#

one while loop ow

#

damn

#

also @somber heath quick question is there anyway for me to do the

if choice not in ["no", "yes"]:
        print ("there seem to be a mistake pls type yes or no")
        choice = input("Would you like to play again? (yes or no) \n").lower
        break
    if choice in ["no", "yes"]:
        continue
#

its in the while loop

#

i should make another?

#

@somber heath so smthing like dis?

#
import random

sides = ["heads", "tails"]
ai = random.choice(sides)

while True:
    ai = random.choice(sides)
    guess =  input("Heads or Tails: ").lower()
    if guess == ai:
        print("you win the answer was", ai)
    else:
        print("you lose the answer was", ai)
    choice = input("Would you like to play again? (yes or no) \n").lower()
    if choice == "no":
        break
    if choice == "yes":
        continue
    while choice not in ["no", "yes"]:
        print ("there seem to be a mistake pls type yes or no")
        choice = input("Would you like to play again? (yes or no) \n").lower
        break
#

πŸ™‚

#

say it again

#

oh

#

EXPLAINS

versed heath
#
import random

sides = ["heads", "tails"]
ai = random.choice(sides)

while True:
    ai = random.choice(sides)
    guess = input("Heads or Tails: ").lower()
    if guess == ai:
        print("you win the answer was", ai)
    else:
        print("you lose the answer was", ai)
    choice = input("Would you like to play again? (yes or no) \n").lower()
    while choice not in ["no", "yes"]:
        print ("there seem to be a mistake pls type yes or no")
        choice = input("Would you like to play again? (yes or no) \n").lower
        break
    if choice == "no":
        break
pine token
#

add py

#

also

#

a problem

undone bane
#

```py

pine token
#

i think ik the fix tho

#

@somber heath

what about this?

import random

while True:
    sides = ["heads", " tails"]
    ai = random.choice(sides)
    guess =  input("Heads or Tails: ").lower()
    if guess == ai:
        print("you win the answer was", ai)
    else:
        print("you lose the answer was", ai)
    choice = input("Would you like to play again? (yes or no) \n").lower()
    if choice == "no":
        break
    if choice == "yes":
        continue
    while choice not in ["no", "yes"]:
        print ("there seem to be a mistake pls type yes or no")
        choice = input("Would you like to play again? (yes or no) \n").lower
    else:
        break
versed heath
#
choice = input("Would you like to play again? (yes or no) \n").lower()
    while choice not in ["no", "yes"]:
        print ("there seem to be a mistake pls type yes or no")
        choice = input("Would you like to play again? (yes or no) \n").lower
        break
    if choice == "no":
        break
wind raptor
#

get rid of that space before tails

pine token
#

ye

#

ight

pine token
#

alright

#

i made another adjustment

#
import random

while True:
    sides = ["heads", " tails"]
    ai = random.choice(sides)
    guess =  input("Heads or Tails: ").lower()
    if guess == ai:
        print("you win the answer was", ai)
    else:
        print("you lose the answer was", ai)
    choice = input("Would you like to play again? (yes or no) \n").lower()
    if choice == "no":
        break
    if choice == "yes":
        continue
    while choice not in ["no", "yes"]:
        print ("there seem to be a mistake pls type yes or no")
        choice = input("Would you like to play again? (yes or no) \n").lower
        if choice == "yes":
            continue
        elif choice == "no":
            break
#

idk

#

if this will work

#

but it looks like it should tho

#

ight

#

oh

#

what if i put exit()?

#

for elif choice=="no"?

upbeat bobcat
#

use else instead of if here ig and remove the choice == "yes" part

versed heath
#
import random

def heads_or_tails():
    sides = ["heads", "tails"]
    ai = random.choice(sides)

    while True:
        ai = random.choice(sides)
        guess = input("Heads or Tails: ").lower()
        while guess not in sides:
            print("there seem to be a mistake pls type heads or tails")
            guess = input("Heads or Tails: ").lower()
        if guess == ai:
            print("you win the answer was", ai)
        else:
            print("you lose the answer was", ai)
        choice = input("Would you like to play again? (yes or no) \n").lower()
        while choice not in ["no", "yes"]:
            print ("there seem to be a mistake pls type yes or no")
            choice = input("Would you like to play again? (yes or no) \n").lower
        if choice == "no":
            return

heads_or_tails()
pine token
#

ya

#

this thing

#

not funcioning

#

😐

wind raptor
#

Bye @somber heath πŸ‘‹

undone bane
#
import random

play_again_prompt = False
sides = ["heads", " tails"]

while True:
    if play_again_prompt:
        choice = input("Would you like to play again? (yes or no) \n").lower()
    
        if choice == "no":
            break
        elif choice == "yes":
            play_again_prompt = False
        else:
            print ("there seem to be a mistake pls type yes or no")
    else:
        ai = random.choice(sides)
        guess =  input("Heads or Tails: ").lower()
        if guess == ai:
            print("you win the answer was", ai)
        else:
            print("you lose the answer was", ai)
        play_again_prompt = True
pine token
#

BACK

dreamy relic
#

"there seem to be a mistake pls type yes or no" - evil

pine token
#

HELP MAN

#

or nah

#

dang

#

this is wierd man

upbeat bobcat
pine token
#

aight

#

give me a sec

#
import random

while True:
    sides = ["heads", " tails"]
    ai = random.choice(sides)
    guess =  input("Heads or Tails: ").lower()
    if guess == ai:
        print("you win the answer was", ai)
    else:
        print("you lose the answer was", ai)
    choice = input("Would you like to play again? (yes or no) \n").lower()
    if choice == "no":
        break
    if choice == "yes":
        continue
    if choice not in["no" or"yes"]:
        print ("there seem to be a mistake pls type yes or no")
        choice = input("Would you like to play again? (yes or no) \n").lower()
        if choice == "no":
            break
        else:
            continue
#

ight back

upbeat bobcat
pine token
#

oops

#

bruhe

#
import random

while True:
    sides = ["heads", "tails"]
    ai = random.choice(sides)
    guess =  input("Heads or Tails: ").lower()
    if guess == ai:
        print("you win the answer was", ai)
    else:
        print("you lose the answer was", ai)
    choice = input("Would you like to play again? (yes or no) \n").lower()
    if choice == "no":
        break
    if choice == "yes":
        continue
    if choice not in["no","yes"]:
        print ("there seem to be a mistake pls type yes or no")
        choice = input("Would you like to play again? (yes or no) \n").lower()
        if choice == "no":
            break
        else:
            continue
#

there current code

#

can someone do smhting man?

#

how to share screen?

upbeat bobcat
pine token
#

@wind raptor hi can i pls have share screen perms?

#
import random

while True:
    sides = ["heads", "tails"]
    ai = random.choice(sides)
    guess =  input("Heads or Tails: ").lower()
    if guess == ai:
        print("you win the answer was", ai)
    else:
        print("you lose the answer was", ai)
    choice = input("Would you like to play again? (yes or no) \n").lower()
    if choice == "no":
        break
    if choice == "yes":
        continue
    while choice not in["no","yes"]:
        print ("there seem to be a mistake pls type yes or no")
        choice = input("Would you like to play again? (yes or no) \n").lower()
        if choice == "no":
            exit()
        elif choice == "yes":
            continue

fixed the code πŸ™‚

#

nah

jovial iris
#

College/University.

pine token
#

im still in high school

#

ending next yr

upbeat bobcat
#

High school

wind raptor
#

!stream 890643057274396772

wise cargoBOT
#

βœ… @pine token can now stream until <t:1724513980:f>.

pine token
#

YESSSSSSSSSSSSSSSSSS

#

HEHEHE

#

i will use this power very responsibly

#

@upper basin you are still streaming btw

wind raptor
pine token
#

yes sir

#

i understand

#

and will be very careful

#

DAMN

#

in the next minute i can no longer stream

#

that stings

#

@undone bane Damn thats college knowledge πŸ˜‰

upbeat bobcat
#

@wind raptor The calculator I made was hard coded. Now I want to change the code so it's not hard coded but I don't know how can I do that? Can you give me a idea?

pine token
#

bro you been typing

#

can you show the code?

upbeat bobcat
jovial iris
#

@pine token can't stream, dw.

pine token
#

lol

#

i only stream code if i have the chance to

pine token
jovial iris
#

got no prompt from the bot.

pine token
#

lol

pine token
#

@undone bane damn same here

upbeat bobcat
# pine token

You should leave it and do your work because you will not understand the code

pine token
#

😐

#

i cant see other ppls code?

#

no more?

upbeat bobcat
pine token
#

wow

#

thats nice

upper basin
#

Brb.

pine token
#

you can do that using python?

#

i always thought python was limited to things 😐

upbeat bobcat
pine token
#

dng bro how long u been coding btw?

upbeat bobcat
pine token
#

dang

upbeat bobcat
pine token
#

can u recommend me stufff

#

?

#

to be better at pyhton?

#

@undone bane yee

#

u didnt responed

#

to ONE

#

np

upbeat bobcat
pine token
#

can

#

can u reccomend me stuff to get good at python

#

anyone?

wise cargoBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

pine token
#

@undone bane another question what can python do?

#

where?

#

YES

undone bane
upper basin
#

I think you mean 6.0001.

pine token
#

damn 😐

upper basin
#
MIT OpenCourseWare

6.0001 Introduction to Computer Science and Programming in Python is intended for students with little or no programming experience. It aims to provide students with an understanding of the role computation can play in solving problems and to help students, regardless of their major, feel justifiably confident of their ability to write small p...

#

Try this one.

wind raptor
upper basin
#

6.0002 is the continuation with focus on some applications of python.

#

I'd also suggest having a look at any 6 courses (6 prefix is for EECS department).

#

Greetings LX.

pine token
#

send links PLS

upper basin
stuck furnace
#

I remember berkeley took down some of their lectures due to accessibility requirements or something

pine token
#

i saw

upper basin
#

Above.

upbeat bobcat
upper basin
#

Ok, you're not talking to me. My bad.

pine token
#

i am

#

i checked it

#

ive alr like

#

covered that

#

or no

#

im gonna check it again

#

tnx @upper basin

#

@undone bane u havent answered the question what can python do ? like what can u make ?

upbeat bobcat
pine token
#

@undone bane so can i make websites and apps with python?

#

damn

#

question

#

html css and js > python ?

#

in web dev?

#

can u show me an example of a python app?

#

ill brb

hard quail
#

I have a question i have a class in a dir core.error_handling.error_logger but when i add it to main with this line from error_handling.error_logger import ErrorHandling im getting the error that its not there but when i click for example on error_logger or ErrorHandler i co to the class how is that possible im using VSCode

pine token
#

true

#

πŸ™‚

#

np

#

i will πŸ˜‰

#

sadk?

#

mhh

#

Chicken ~_~

#

dc servers arent good

#

c

#

vc in particular

#

based?

#

oh me

#

im strasburg

upper basin
#

You're not from Australia though, right?

pine token
#

strasburg france

upper basin
#

I see.

pine token
#

@upper basin wbu?

upper basin
#

Earth.

pine token
#

dang

#

i didnt know 😐

upper basin
#

Yeah, I'm a rare specimen.

#

Zeki you're awfully quiet. What's up brother?

pine token
#

nah let him be

#

his ping to high

#

he on the moon

upper basin
#

Shouldn't be.

#

Rotterdam is the middle ground.

#

@undone bane Did you do your bachelors in US?

#

Did you move to US for your bachelors or were you there before that?

#

Didn't hear that at all. It was all lag.

#

You came to US when you were 5?

#

Oh nice.

pine token
#

nice

#

i went to us when i was 2

upper basin
#

So, basically grew up the american way?

pine token
#

damn

#

chat pretty boring now tbh

upper basin
#

How much did your bachelors cost by the way? I've been a bit terrified of the costs over there.

#

Masters around 60k mostly.

#

Nice.

#

Wow.

pine token
#

damn

#

nice

upper basin
#

120K annual income is not low.

#

It's higher than avg in fact.

#

Wow.

#

Which university is that if you don't mind me asking.

pine token
#

looks like ill be attending free

upper basin
#

I may apply to it. Is the policy same for international students too? Probably not.

pine token
#

u went to MIT?

#

damn

upper basin
#

Ohh I see.

pine token
#

my dream college

undone bane
upper basin
#

What was your HS like then? You made me curious hehe.

#

Did you do any olympiads, tournaments, etc?

#

AIME I remember.

#

What would you say were the highlight of your application?

jovial iris
#

Olympiad ?

upper basin
#

Mostly national.

jovial iris
#

Yep

#

seems great.

undone frost
#
import gleam/http/request
import gleam/httpc
import gleam/result

pub fn get_product_info(slug: String) {
  let assert Ok(req) =
    request.to("https://www.wholefoodsmarket.com/api/product/" <> slug)
  use resp <- result.try(httpc.send(req))
  Ok(resp)
}
pine token
#

yo

#

here look at my code

#
# ClickArrowDraw.py
import turtle
t = turtle.Pen()
t.speed(0)
t.turtlesize(2,2,2)
turtle.bgcolor("black")
t.pencolor("yellow")
def up():
    t.forward(50)
def left():
    t.left(45)
def right():
    t.right(45)
def move(x,y):
    t.penup()
    t.setpos(x,y)
    t.pendown()
def thicker():
    t.width( t.width() + 2 )
def thinner():
    t.width( t.width() - 2 )
    
turtle.onkeypress(up, "w")
turtle.onkeypress(left, "a")
turtle.onkeypress(right, "d")
turtle.onkeypress(thicker, "e")
turtle.onkeypress(thinner, "q")
turtle.listen()
turtle.onscreenclick(move)

#

i aint random

#

i left to go buy pizza πŸ™‚

#

wut do u want me to do?

#

ask youtube?

#

YES @undone frost

undone bane
upper basin
#

Enjoy your saturday!

pine token
#

tnx

#

s

upper basin
#

I'm gonna hop off. It's late. Wish everyone a blessed weekend.

pine token
#

same to u

#

bye @undone bane

undone bane
#
pub fn get_product_info(slug: String) -> Result(http.Response, httpc.Error) {
  let req_result = request.to("https://www.wholefoodsmarket.com/api/product/" <> slug)
  
  case req_result {
    Ok(req) -> 
      result.try(httpc.send(req))
    Error(err) -> 
      Error(err)
  }
}
pine token
#

bye guys

#

was fun

upbeat bobcat
#

@undone frost Hi! Good hbu?

#

Why you want to do that?

#

okay call

red terrace
#

wsp

upbeat bobcat
woeful wyvern
#

Hey @somber heath, while explaining the problem we were discussing earlier, specifically while explaining that the threading method did not work since the inspect.stack() call simply returned the stack for that thread instead of the complete program, I had the idea of reading the stack in the global scope of the module and then reading from that stack inside of the thread instead of calling the inspect.stack() method directly inside of the thread. Naturally, this worked

import inspect
import time
import os
from threading import Thread

class AutoStart: pass

stacks = inspect.stack()

def test():
    global stacks
    time.sleep(1)
    
    for frame in stacks:
        
        if os.path.basename(__file__) in frame.filename:
            # exclude occurrences of AutoStart in this file (stack)
            continue
        
        if "AutoStart" in frame.frame.f_globals.keys():
            if frame.frame.f_globals["AutoStart"] is AutoStart:
                # there seems to be 2 stacks with the same globals,
                # so in my case the code here gets run twice
                print("Auto starting...")
                return 

Thread(target=test).start()
somber heath
#

Something to remember for later.

woeful wyvern
#

Absolutely

#

First time I'm having to check if __name__ != "__main__" haha

#

I guess I don't really need to since I already exclude occurrences in itself though...

vocal basin
#

I made some very weird CSS thing

#

(and it's probably wrong)

#

@wind raptor idk if my discord is broken, but I can't hear anything

#

I needed to fill a div with many square divs

#

seems like it worked

#

idk if there's a proper way to do this

#

the difficulty there is that it's mathematically non-trivial

#

so ig that's why browser doesn't provide a built-in way to do that

#

afaik

#

JS is less instant in how it applies sometimes

#

yes

#

otherwise it looks bad

#

I need a grid to show statuses (single colour) of instances of processes/services/whatever

#

this was taken from some stackoverflow answer

@property --100vw {
  syntax: "<length>";
  initial-value: 0px;
  inherits: false;
}

@property --100vh {
  syntax: "<length>";
  initial-value: 0px;
  inherits: false;
}

and this is weird maths stuff
||```css
.container {
display: grid;
--100vw: 100vw;
--100vh: 100vh;
--r: tan(atan2(var(--100vh), var(--100vw)));
--x1: round(up, sqrt(var(--n) / var(--r)));
--d: max(0, round(up, round(up, var(--n) / var(--x1)) - var(--x1) * var(--r)));
--x2: var(--x1) + var(--d); /* sometimes x1 is off by one */
grid-template-columns: repeat(calc(var(--x2)), 1fr);
}

#

(those two used together)

#

thing referenced in the comment is purely empirical, idk the underlying reason

#

I think I did that same derivation a long time ago

#

but I don't remember what for

#

task: fill thing like this given fixed number of cells and fixed outer bounds

#

(maximise used space with cells of same size)

#

that bit can stay

#

so, rather, for easier version just have it filled horizontally on all rows except last
and maximise the number of rows

#

fitting either horizontally or vertically depending on what fits more is more difficult

somber heath
#

Is there no divmod equivalent in the language?

vocal basin
#

the subtask is to find how many columns there are

#

to shove into grid-template-columns

vocal basin
#

i.e. filled-in fully along the smaller side

#

otherwise it'll look very not okay

vocal basin
#

the math is quite straightforward

#

the only "smart" part is +1 hack

#

I was considering making 32-levels-deep or whatever approximation, effectively doing a binary search, but found a simpler way

#

also calc has no if which makes binary search a bit harder

#

(only a bit, lack of if only means no short-circuit; after-the-computations switching works just fine)

#

and there's also an option to do that with @media

upbeat bobcat
woeful salmon
#

what about flux @wind raptor

wind raptor
#

What about it?

woeful salmon
#

you were talking about which image generation model to use right?

woeful salmon
woeful salmon
pine token
#

IM BACK BABAY

#

THANK U

#

quick question

#
import random

def country():
    c_score = 0
    print("Welcome to country quiz")
    letter = []
    for x  in range(3):
        country = input("alrighty name 3 countries that start with the letter 'C' (one at a time) \n").lower()
        letter.append(country)
        print(letter) 
        if country [0] != "c":
            print ("Wrong")
        else:
            print ("correct")
            c_score += 1
    print("your score for country quiz is: \n", c_score)

def math():
    m_score = 0
    print("Welcome to math quiz")
    
    questions = ["What is the square root of 100\n", "What is 2 + 3 x 4\n ",  "what is 9 x 9\n"]
    answers = ["10", "14", "81"]
    for i , questions in enumerate(questions):
        print(questions)
        answer = input("answer: ")
        if answer == answers[i]:
            print("correct")
            m_score += 1
        else:
            print ("wrong")
    print ("your score for math quiz is:", m_score)


choice = input("Welcome to the ultimate quiz platform choose between(math and country) (if both type m and c , or c and m): ").lower()
while True :
    if choice == "math":
        m_score = math()
        break 
    elif choice == "country":
        c_score = country()
        break
    elif choice == "m and c" or "c and m":
        m_score = math()
        c_score = country()
        print ("your total score is the addition of both")

        break
    else:
        print("invalid choice")
        exit()
#

is this correcr?

abstract urchin
#

Can someone help me with pyperclip

#

i installed it normally. pip install pyperclip

#

then i use import pyperclip

#

but Module not found

sly jolt
#

Otherwise restart the active window and see if that resolves the import issue

abstract urchin
#

ive restarted already four times

#

ive tried to install it via powershell and moved to the appdata directory with cd

#

iv etried to run powershell as an admin

#

Traceback (most recent call last):
File "L:\pycharmprojects\PasswordManagerGUI\main.py", line 4, in <module>
import pyperclip
ModuleNotFoundError: No module named 'pyperclip'

wise zephyr
#

pip install pyperclip

abstract urchin
sly jolt
#

can try this but i think the issue is related to the python directories you may have set up
pip install --user pyperclip

abstract urchin
#

never had problems with modules before

#

i am using pandas i.e

sly jolt
abstract urchin
#

i tried to use python3.8(using.12 usually)

#

omg idk why but i had to install it in the intepreter settings too :dumbmeeee:

wind raptor
#

You're using a virtual environment?

abstract urchin
#

i am using venv.

#

THANKS

spare galleon
#

also you should separate the quizzes into classes, for neater and easier implementation of more complex quizzes

dry heart
#

Yo would any one have an idea about 3d rendering

#

I’m new to Python just came from the cs50 introduction

dusty laurel
#

Uh

spare galleon
dry heart
#

cus im trying to study

#

i thoght it would be a good test

vocal basin
#

so technically possible

spare galleon
# dry heart is it imposable

anything is possible, i mean there are better frameworks on other languages to make 3d renders which you should probably use

undone bane
spare galleon
vocal basin
#

pygame links into C at some level

#

as all libs do

spare galleon
#

yeh tru

#

however the actual 3d rendering part i wrote myself in python, but id still recommend using JS or C++ for that

undone bane
dry heart
#

i thoght start with the 3D render

#

is good

spare galleon
dry heart
#

im trying to study python

spare galleon
#

three.js gotta be the easiest way to make a 3d game without a game engine(imo)

spare galleon
#

or turtle if you dare

dry heart
#

whats turtle

vocal basin
#

!d turtle

spare galleon
#

a built in python gui library

wise cargoBOT
dry heart
spare galleon
dry heart
#

its a lib right

#

i want to study python raw

spare galleon
#

built in aswell, so no need to install anything

dry heart
#

if i where to make a game engine where do i start

#

cus i thoght about the renderer it would need a space to read right

whole bear
#

LANG DEV TIME

spare galleon
spare galleon
vocal basin
#

you can also try with something like WebGL first

#

because digging directly into GPU is going to give you a few BSODs

spare galleon
vocal basin
#

might as well just make the engine target both WebGL and OpenGL

#

since Engine an abstraction anyway

#

so can abstract away multiple underlying implementations

dry heart
#

okay so making a game engine in python is hard what else should i do

#

to study

#

it

spare galleon
dry heart
#

okay

#

what should i do

spare galleon
vocal basin
dry heart
spare galleon
spare galleon
#

meant to reply to this message !1277358413705117860

vocal basin
#

didn't, like, Firefox have some early thing similar to WebGL

#

when they ported Unreal (the game) or whatever it was

spare galleon
#

if i were to make a game tho(using a webGL api) it would be in WebXR

vocal basin
#

10 years ago

spare galleon
vocal basin
#

they used Emscripten

#

pre-WASM tech

spare galleon
#

also isnt unreal an engine, and not a game?

vocal basin
#

Unreal is a game

#

Unreal Engine is an engine

#

same company

#

same logo

spare galleon
#

i havent heard of unreal, ima go look at it

#

nothing comes up other than unreal physics?

vocal basin
spare galleon
#

and thank you

rugged tendon
vocal basin
#

otherwise,

#

use X.Y.Z versions only to avoid such issues

#

-alpha.0 and similar prefixes for pre-releases

#

so like
tag 0.1.0
then update
tag 0.1.1

rugged tendon
split field
#

up to 256 different chars

whole bear
#

@wind raptor hi

#

My partner broke up with me around 2.5 seconds after I disconnected from the call. Atleast my lexer is working πŸ™‚

#

I am 13

#

nah

#

but now I dont have a partner so its ok

#

or any friends

#

online/real life

#

and they are gone lol

#

a3456789123123

#

btw I was trying to code a lexer just now

#

and instead of increasing the for loop iteration value

#

I was increasing the pointer... there fore the memory address

#

so every iteration I would have the pointer point to a different memory location

#

yeah

#

anyways how are you doing?

#

what is it?

#

is there a github?

#

I made a pr to a project like a few months ago and its still not aproved

#

and the repo has a few thousand stars

#

and no commits for years, no prs for years and the owner is not active since 2022

#

yes

#

they said yes

#

and I said I created one

#

and nothing...

#

@wind raptor

#

Could you please explain how I go from lexed tokens to stuff being done?

#

cause I got a lexer

#

but nothing to handle the tokens

#

@wind raptor
Its 1 Am I need to go to bed, good night! and good luck with your discord project!

vocal basin
#

@wind raptor I'm shoving my messages about that CSS thing into the AI

#

I have no idea what it means by colour

vocal basin
#

but with a nuance

#

I planned to do that in CSS only

whole bear
#

@wind raptor

#

@wind raptor

#

@wind raptor

#

I am getting doxed

#

rn

#

some kid got my address and is therening me

#

and full name and shit

wind raptor
#

That's a police thing. Can't really do much on here. Is it from a user on the server?

whole bear
#

no

#

I just didnt know who to msg

#

but I felt its important to msg someone

#

it was my ex

#

sooo not a big suprise there

wind raptor
#

Ahh I see

whole bear
#

I told him that I got A BUNCH of stuff on him and then I sent him the high ground star wars gif and blocked him on that note lol

#

@wind raptor

#

I got addresses and more but I just want him to be a bit worried

#

anyways

#

he got my address worng

#

its not even close

#

Anyways

#

Gn

wind raptor
#

Good night

whole bear
#

Fuck

#

I cant sleep

#

so instead I added flag recognition to my lexer

#

Now I added command name

#

You look so chill

#

like chiller than anyone here

#

like the coolest chillest guy ever

#

like

#

If I didnt know anything

#

I would want you to teach me

lavish rover
#

don't recommend doxing people

whole bear
wind raptor
#

It's all good

whole bear
wind raptor
#

22

whole bear
wind raptor
#

Β―_(ツ)_/Β―

whole bear
#

Anyways

#

Imma try to sleep for the 10th time

#

its 3 am

#

I got to get up at 8:30

#

I got 5 and a half hours of time before i got to get up

#

but I want to read my 912 page C++ book and the 200 page Microsoft winAPI docs for wstrings

#

and the 400 page quantum mechanics book

#

and watch a entire wan show

#

and finish 2 seasons of my show

#

@wind raptor How does one sleep!?

#

I dont have any

#

ok

#

Imma go then

#

bye!!

#

you too bye

wind raptor
somber heath
#

@sturdy trench πŸ‘‹

#

!voice

wise cargoBOT
#
Voice verification

Can’t talk in voice chat? Check out #voice-verification to get access. The criteria for verifying are specified there.

sturdy trench
#

is @stark river online

stark river
#

❓

ebon valve
#

I don't have mic access yet

astral raptor
#

Neither do I...

#

We just have to keep chatting πŸ˜‰

ebon valve
#

i'm 12 messages away

#

how are you today?

astral raptor
#

I think I'm pretty close too...

#

Doin good!

ebon valve
#

you can use !user to check

#

it's 9 AM rn

astral raptor
#

Ya, I'm gonna check on that

#

!user

wise cargoBOT
#

You are not allowed to use that command here. Please use the #bot-commands channel instead.

astral raptor
#

Where are you from?

ebon valve
#

in the bot commands section

#

m...

#

from middle east

astral raptor
#

Yes, just checked...

#

I'm at 24 msgs

#

I thought I had talked a lot more, but I guess not

#

What are you working on with python?

ebon valve
#

I've learned python quite recently (basics), I started doing projects like library management system and coffee machine simulator.

astral raptor
#

Are you using a data base?

#

I'm pretty new as well, but just learning about databases. I have a project I'm going to need one for

ebon valve
#

no i don't but I watched some videos about the topic, (but forgot everything)

astral raptor
#

Ha, of course

ebon valve
#

like that happened when I finished a login system using databases

astral raptor
#

I just watched this one. Pretty inspiring

ebon valve
#

like when you study for an exam and after it your brain just do a quick format

astral raptor
#

Ya, I feel the same... I just need more real work experience

#

If I can get voice approved, I might do some coding in the chat tomorrow morning

#

It's 9pm here, so we're 12 hours off

#

It's be around 9am my time, 9pm yours if you're awake

ebon valve
#

btw im trying to get voice approved while i dont have a mic

astral raptor
#

No mic? How will you chat?

#

Use your phone?

ebon valve
#

i will use my laptop i guess

astral raptor
ebon valve
#

and btw don't worry for the time difference

#

cuz i wake up at 5am everyday

#

so it will be 5pm for you

astral raptor
#

Cool cool

#

What kind of projects are you looking to build?

astral raptor
#

See ya later

versed heath
#

public static void main(String[] args) {

charred orchid
#
use proc_macros::DatabaseEntity;

use crate::database::DatabaseEntity;

#[derive(DatabaseEntity)]
#[entity(entity_name = "customers", primary_column_name = "id")]
pub struct CustomersDatabaseView {
    rows: Vec<CustomersDatabaseViewRow>,
}

// impl DatabaseEntity for CustomersDatabaseView {
//     type Row = CustomersDatabaseViewRow;
//     const ENTITY_NAME: &str = "customers_view";
//     const PRIMARY_COLUMN_NAME: &str = "id";

//     fn with_rows(rows: Vec<Self::Row>) -> Self {
//         Self { rows }
//     }

//     fn take_rows(self) -> Vec<Self::Row> {
//         self.rows
//     }

//     fn rows(&self) -> &[Self::Row] {
//         &self.rows
//     }
// }

#[derive(sqlx::FromRow, Clone)]
pub struct CustomersDatabaseViewRow {
    pub id: i32,
    pub name: String,
    pub email_address: Option<String>,
    pub phone_number: Option<String>,
    pub street_address: Option<String>,
}
#
macro_rules! synerror {
    ( $span_ident:ident, $message:literal ) => {
        return SynError::new($span_ident.span(), $message)
            .into_compile_error()
            .into()
    };
}

#[derive(ExtractAttributes)]
#[deluxe(attributes(entity))]
struct DatabaseEntityAttributes {
    schema_name: Option<String>,
    entity_name: String,
    primary_column: String,
}

#[proc_macro_derive(DatabaseEntity, attributes(entity))]
pub fn derive_database_entity(input: TokenStream) -> TokenStream {
    let mut input: DeriveInput = parse_macro_input!(input);
    let type_name = input.ident.clone();
    let Data::Struct(_) = input.data else {
        synerror!(
            type_name,
            "cannot derive `DatabaseEntity` for non-struct types"
        )
    };

    // TODO: Handle missing attributes
    let row_type_name = Ident::new(&format!("{}Row", type_name), type_name.span());
    let DatabaseEntityAttributes {
        schema_name,
        entity_name,
        primary_column,
    } = deluxe::extract_attributes(&mut input).unwrap();

    let optional_schema_definition = schema_name.map(|schema_name| {
        quote! {
            const SCHEMA_NAME: &str = #schema_name;
        }
    });

    quote! {
        impl DatabaseEntity for #type_name {
            type Row = #row_type_name;
            #optional_schema_definition
            const ENTITY_NAME: &str = #entity_name;
            const PRIMARY_COLUMN_NAME: &str = #primary_column;

            fn with_rows(rows: Vec<Self::Row>) -> Self {
                Self { rows }
            }

            fn take_rows(self) -> Vec<Self::Row> {
                self.rows
            }

            fn rows(&self) -> &[Self::Row] {
                &self.rows
            }
        }
    }
    .into()
}
#

@versed heath

daring totem
#

gg

wise cargoBOT
#

:incoming_envelope: :ok_hand: applied timeout to @daring totem until <t:1724657859:f> (10 minutes) (reason: duplicates spam - sent 4 duplicate messages).

The <@&831776746206265384> have been alerted for review.

daring totem
#

<@&831776746206265384> yolo srry I did that cuz it said to VC i needed to sent like 50 messages so I wanted to do it fast bc no one is ever on. 😦 don`t ban me 😦

somber heath
daring totem
#

idk

somber heath
#

Absent any other circumstance to which I am unaware, you may have either no further action taken against you or you may have your ability to voice verify suspended for an extra 14 days.

somber heath
daring totem
#

😐

#

welp

#

:\

somber heath
#

You're still welcome to hang out and listen and chat via text, unless there's some other consideration which would change that.

sour imp
woeful salmon
#

i gotta go now

#

cya guys

wind raptor
#

!stream 732291998274420828

wise cargoBOT
#

βœ… @sour imp can now stream until <t:1724679265:f>.

wind raptor
#

@sour imp

whole bear
#

@wind raptor hey

wind raptor
#

Hi

whole bear
#

@wind raptor Could I get screen share perms to continue working on my lexer/parser?

wind raptor
#

@upper basin We're getting a lot of echo from your mic

cerulean ridge
#

literally, only 1 position lol

#

And the will hire @upper basin way before me coz it is quantum

wind raptor
#

!stream 1028671867785068574

wise cargoBOT
#

βœ… @whole bear can now stream until <t:1724682586:f>.

upper basin
#

I am a nogo applicant. Tough nationality, and outside US at the moment. And don't have a MSc or PhD.

cerulean ridge
upper basin
#

You're a PhD grad.

#

That's a big deal.

cerulean ridge
#

If you published 1st author paper at top venue, I don't think anybody care about phd anymore.

cerulean ridge
#

really? why?
publications trump phd anyday imo.

upper basin
#

Tell it to them hehe.

#

!e

a = "2"
b = "2"
print(f"2 + 2 is {a + b}.")
wise cargoBOT
upper basin
#
for key, value in self.get_counts(num_shots=1).items():
            if value == 1:
                # Check if the value of the measurement matches the specified value
                condition = int(key[clbit_index]) == clbit_value
                break

Better way of doing this?

sour imp
upper basin
#

LinkedIn

cerulean ridge
#

Friendster is a social network originally based in Mountain View, California, founded by Jonathan Abrams and launched in March 2003. Before Friendster was redesigned, the service allowed users to contact other members, maintain those contacts, and share online content and media with those contacts. The website was also used for dating and discov...

whole bear
upper basin
#

How to make this into case sth?

elif match_pattern(gate_type, "x"):
whole bear
#
match var:
  case 1:
    something
  case _:
    default (called when no other cases worked)
#

@upper basin

sour imp
# upper basin How to make this into `case sth`? ```py elif match_pattern(gate_type, "x"): ```
def process_gate(gate_type):
    match gate_type:
        case "x":
            # Code to handle the "x" case
            handle_x_gate()
        case "y":
            # Code to handle the "y" case
            handle_y_gate()
        case "z":
            # Code to handle the "z" case
            handle_z_gate()
        case _:
            # Default case if needed
            handle_unknown_gate()

def handle_x_gate():
    print("Handling x gate")

def handle_y_gate():
    print("Handling y gate")

def handle_z_gate():
    print("Handling z gate")

def handle_unknown_gate():
    print("Unknown gate type")

# Example usage
process_gate("x")
process_gate("y")
process_gate("a")
wind raptor
#

!stream 732291998274420828

wise cargoBOT
#

βœ… @sour imp can now stream until <t:1724686081:f>.

tawdry mica
#

hello

whole bear
#

!paste

wind raptor
#

!stream 104903148853833728

wise cargoBOT
#

βœ… @sly jolt can now stream until <t:1724687422:f>.

pine token
#

wsg

#

can yall look at this code pls

upbeat bobcat
#

@verbal zenith I need some help.

#

With my calculator

#

yk

pulsar shale
#

Hello

upbeat bobcat
#

The last calculator was hard-coded, I want to change that and make some improvements like in windows calculator the equation or something is not on main screen only the answer is

#

@verbal zenith

#

Did you understand?

#

no

#

But I don't know how can I change the hard-coded part

#

let me give you

#

Okay.

#

!paste

wise cargoBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

upbeat bobcat
#

What I want to do is that I want to store the value the user typed and then show the answer or error if it is not valid if this makes sense

#

I didn't understand

#

Okay.

#

Thanks.

sour imp
#

Check if the expression is not empty and the last character is not an operator πŸ˜‰

verbal zenith
#

yeah thats a silly bug

#

its why I made a whole state machine

#

a bunch of if statements to manage state or one field that dictates it

sour imp
#
elif button_text == '+':
    # Check if the expression is not empty and the last character is not an operator
    if self.expression and self.expression[-1] not in '+-*/':
        self.expression += '+'
whole bear
verbal zenith
whole bear
#

!paste

#

g++ CPP-Dev/Orion-Shell/src/main.cpp CPP-Dev/Orion-Shell/src/cpp/utils.cpp CPP-Dev/Orion-Shell/src/cpp/lexer.cpp -o C:/coding-projects/CPP-Dev/Orion-Shell/build/Orion-Shell-Main-Build-ORS-A01 -lgdi32 -luser32 -lshell32 -w

spare galleon
upbeat bobcat
#

@whole bear What are you doing?

#

Why are you making a lexer?

#

like why we need a lexer?

#

Why we need a lexer?

whole bear
#

@wind raptor

#

Come back

whole bear
#

@whole bear @verbal zenith need to work on getting perms to speak in here

whole bear
#

i cant talk unless i get my activity up

#

the bot in here

#

its annoying

#

@whole bear

verbal zenith
#

!voice

wise cargoBOT
#
Voice verification

Can’t talk in voice chat? Check out #voice-verification to get access. The criteria for verifying are specified there.

whole bear
#

i need more than 50 messages

#

i got to work on z python

vocal basin
#

@verbal zenith make comments AI-linted: if AI can generate a similar enough comment, it automatically deletes them

#

(getting non-reasoning comments right is a very rare thing, which AI happily avoids even trying to do)

#

-= is defined separately in Rust

#

SubAssign iirc

whole bear
#
hello
there;
I 
am
bob;
hello there;
I am bob
vocal basin
#

compound assignment

#

indicate todo panic with todo!

verbal zenith
#
    pub fn get_line_info(filename: &'static str, start: usize) -> (usize, usize) {
        get_source(filename).unwrap()[..start].char_indices().fold(
            (1usize, 1usize),
            |(line, column), (i, c)| {
                if c == '\n' {
                    (line + 1, 1)
                } else {
                    (line, column + 1)
                }
            },
        )
    }
vocal basin
#

if you have a message, they're both same as panic!

#

the difference is just in ctr-f'ing it across the codebase

#

there's certain line between todo and unimplemented

#

first means "will implement", second means "may implement"

#

stricter rule is: never commit todo!s

whole bear
#

1qwer5678
clear

#

i need help with something

#

when i use string.lower it throws my program off and states game over.

#

so i got rid of the lower()

#

let me pastebin this shit

#

it is being weird

vocal basin
whole bear
vocal basin
#

@verbal zenith you know format_args!, right?

whole bear
#

i got it working

vocal basin
#

it's Rust

#

related to code on stream

whole bear
#

no wonder why i couldnt recognize it

vocal basin
#

generates something Displayable

#

Arguments<'_> specifically

#

you will run into weird issues if you overuse it

#

in implementations of Display you'd normally just write!(f, ...)

#

and whatever else you do with format! -- just wrap that in something implementing Display

#

sometimes the right approach

#

and sometimes doesn't work

#

stackoverflow can't Rust

#

stringify just turns tokens into &'static str iirc

#

(procedural) derive macro

#

or just use Zig where you get to have reflection

#

what context do you need the names in?

whole bear
#

does discord have a way of compiling your code in chat?

#

that may be really stupid question

vocal basin
#

no

whole bear
#

i figure

#

figured

vocal basin
#

@wise cargo can run Python code

#

with restrictions

whole bear
#

cool beans

vocal basin
#

and Python generally can be quite easily compiled

#

afaik compile call is relatively fast

whole bear
#

it doesnt have to be compiled

vocal basin
#

and secure-ish

whole bear
#

java does

#

thats what my cysa book says

vocal basin
#

C compilation, without preprocessor, is quite simple too

#

when it comes to C++, it becomes quite messy because of templates

#

those can go exponential in complexity

#

same with Rust/Haskell, but there it's because of different (though adjacent) reasons

#

is it possible to compile those without serious risk to whatever host compiles them? probably yes

#

is it easy? probably no

whole bear
#

i need 15 more mesages

#

so close

#

messages

vocal basin
#

@verbal zenith you seen match and let changes that are getting stabilised in current nightly/next beta?

#

it used to require Err(e) => match e {}

#

well, still does

#

won't be stable until 1.82

#

depends on the size

#

measure

#

if it gets faster and uses less memory, do the change

whole bear
#

make a dating app that doesnt suck

#

good challenge

vocal basin
#

I'd expect so

whole bear
#

what ide is this

vocal basin
#

RustRover ig

whole bear
#

what is rust mainly used for

#

googling it

vocal basin
#

and WASM

#

and maybe something else

vocal basin
whole bear
#

have to do my daily indeed search

vocal basin
#

@verbal zenith no Sized requirement

#

: Sized is implied by default

#

@verbal zenith precedence

#

@verbal zenith move empty to be first

#

hmm

#

@verbal zenith semicolon between rules is required

#

a hypothetically better solution:
make a Writeable wrapper around f, which adds indents after each newline if a non-space character is written afterwards

#

just so you don't have to create new macros

#

and then just write! to that wrapper

#
let f = self.indent(f);
#
struct Indent<F> {
    f: F,
    indent: usize,
    stored_space: usize,
}
#

when you see a newline, write the a newline and set stored_space to indent

#

when you see a space, increment stored_space

#

when you see any other space, unimplemented!

#

when you see non-space, write std::take::(&mut self.stored_space) spaces then that character

#

do not use str::repeat, it allocates

whole bear
#

done with my app

#

apps

vocal basin
whole bear
#

applying for stuff in georgia

#

sc is bad state

#

cant wait to leave

vocal basin
#

oh, I though the country not the state

#

(Georgia)

whole bear
#

yeah the state

#

sc is ass

vocal basin
#

@whole bear quite sure those are Greek not Cyrillic

#

yeah

#

@whole bear πŸ‘‹

whole bear
#

@whole bear
I can fluently speak english, german, russian and swedish

#

and a bit of dutch and ukranian

vocal basin
#

I should learn Ukrainian more systematically

#

anyway

#

I tried putting that set of easy challenges into AI again

#

no success so far

#

even worse than ever before

#

that's bash

#

hmm

whole bear
#

inputString
InputString
input_string

vocal basin
verbal zenith
#

_snailcaSe

vocal basin
#

have y'all seen what ALGOL allowed

#

spaces in identifiers

#

it's the top answer

#

+53

sour imp
vocal basin
whole bear
vocal basin
#

ALGOL 60 allows too allegedly

#

idk if they do the same as fortran (just remove the space)

#

@whole bear just a reminder that Oracle exists

#

way worse than Microsoft

vocal basin
#

Linux doesn't have viruses, it has vulnerabilities

#

ALT Linux only, all the way

#

++rep for prefix notation

#

@verbal zenith you used two different Writes?

#

that doesn't seem right

vocal basin
#

"what an amazing tool"

#

"""totally works"""

#

yeah, screenshots for code are problematic

#

@sour imp sounds normal for me

#

if the person doesn't know how to write/read to/from a file, they can't tell if discord bots are too advanced for them

whole bear
#

Kevin Fang

vocal basin
#

discord.py represents slash commands with less magic, at a cost of putting that effort onto the developers

#

@verbal zenith I'll try writing that thing

sour imp
#

!user

wise cargoBOT
#

You are not allowed to use that command here. Please use the #bot-commands channel instead.

vocal basin
#

first time I joined was in early 2020 or even late 2019; I left quite a lot of times

#

@verbal zenith I got it working, now making it more convenient

sour imp
vocal basin
#
impl<F: std::fmt::Write> std::fmt::Write for Indent<F> {
    fn write_str(&mut self, s: &str) -> std::fmt::Result {
        for c in s.chars() {
            self.write_char(c)?;
        }
        Ok(())
    }
    
    fn write_char(&mut self, c: char) -> std::fmt::Result {
        match c {
            '\n' => {
                self.f.write_char('\n')?;
                self.stored_space = self.indent;
            }
            ' ' => {
                self.stored_space += 1;
            }
            _ if c.is_whitespace() => {
                unimplemented!("unusual space characters aren't allowed");
            }
            _ => {
                for _ in 0..std::mem::take(&mut self.stored_space) {
                    self.f.write_char(' ')?;
                }
                self.f.write_char(c)?;
            }
        }
        Ok(())
    }
}

impl<F: std::fmt::Write> Indent<F> {
    fn write_fmt(&mut self, args: std::fmt::Arguments<'_>) -> std::fmt::Result {
        std::fmt::Write::write_fmt(self, args)
    }
}
#

why would I ever need an IDE for that

#

reminder what the struct looks like

struct Indent<F> {
    f: F,
    indent: usize,
    stored_space: usize,
}
#

also

#

now I need to make an extension trait

#

takes the value and sets to 0

#

drains all spaces it needs to push

#

it accumulates them

#

to stored_space

#

when you encounter non-space, you write those

#
trait IndentExt {
    fn indent(&mut self, n: usize) -> Indent<&mut Self> {
        Indent {
            f: self,
            indent: n,
            stored_space: n,
        }
    }
}

impl<F: ?Sized + std::fmt::Write> IndentExt for F {}
#

I'm going to commit a type system crime

#

wait, no, I remembered the mutabilities don't match

#

oh

#

oh

#

I can do it

#
trait IndentExt: Sized {
    fn indent(self, n: usize) -> Indent<Self> {
        Indent {
            f: self,
            indent: n,
            stored_space: n,
        }
    }
}

impl<F: std::fmt::Write> IndentExt for F {}
#

hmm

#

idk if this is worse or better

#

I think worse

#

not like it's going to stop me

vocal basin
#

so don't just replace whatever you have with it

#

type system crime in question (don't do this)

trait IndentExt: Sized {
    fn indent(self, n: usize) -> Indent<Self> {
        Indent {
            f: self,
            indent: n,
            stored_space: n,
        }
    }
}

impl<F: ?Sized + std::fmt::Write> IndentExt for &mut F {}
impl<F: ?Sized + std::fmt::Display> IndentExt for &F {}

impl<F: std::fmt::Display> std::fmt::Display for Indent<F> {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f.indent(self.indent), "{}", self.f)
    }
}
vocal basin