#python-discussion

1 messages Β· Page 588 of 1

chilly whale
#

that's euler's number

granite wyvern
#

!doc math.e

edgy krakenBOT
#

math.e```
The mathematical constant *e* = 2.718281…, to available precision.
wise imp
#

Edmonton Eulers

unborn lagoon
#

I meant that.

wise imp
#

that's not a lot of hardware

tame raptor
peak relic
#

I was thinking the Sigma function E

vale wasp
chilly whale
#

The number e is a mathematical constant, approximately equal to 2.71828, that is the base of the natural logarithm and exponential function. It is sometimes called Euler's number, after the Swiss mathematician Leonhard Euler, though this can invite confusion with Euler numbers, or with Euler's constant, a different constant typically denoted
...

fiery yarrow
#

i wonder how many mathematicians pronounce it as "you-ler" / /ˈjuːlΙ™r/

wise imp
#

.wa s e

verbal wedgeBOT
vale wasp
#

Diplomas are overrated. It's the education that matters.

tame raptor
#

@silver plover i remember 2 yrs ago i hated coding now it makes me happy

chilly whale
#

you'll get further with an education and a degree than with only one or the other

vale wasp
pallid garden
wise imp
#

short

pallid garden
#

oo

tame raptor
#

yooo i just imported my first thing in py πŸ™Œ

grim hatch
vale wasp
grim hatch
#

The rate of change in an instant

pallid garden
#

this is going to take forever

runic flower
grim hatch
#

πŸ₯

#

I'll take the L on this one ngl

vale wasp
pallid garden
grim hatch
vale wasp
grim hatch
#

You know, in the midst of my python projects, I think it'll be healthy to do fun or stupid projects so I dont get bored

vale wasp
grim hatch
pallid garden
muted rampart
vale wasp
runic flower
vale wasp
grim hatch
vale wasp
grim hatch
pallid garden
#

no rational person will spend so much time on these, right?

vale wasp
runic flower
#

ok, raise your hand if you mispronounced Euler having only read it before finding out how it actually sounds.

pallid garden
#

i didnt actually, i read about euler in murderous maths, which explained how to pronounce euler

grim hatch
#

(Did you get it)

pallid garden
#

ahh, the good old days, reading murderous maths and horrible histories in primary (elementary) school

rare gazelle
#

sounds like u had fun

grim hatch
runic flower
pallid garden
#

not really no, primary school was a bit too easy

runic flower
#

as in "Euler's gif"

silver plover
pallid garden
#

https://www.youtube.com/watch?v=sdWEGzWFcCc
no thanks, take back this gift cursed creation

This has to be the worst measurement system still in widespread use.

This video is a kind of follow up to my previous video on nuclear fracking. I've hinted at doing a rant about the awful awful units system the oil industry insists on using for a couple of years now, so here it finally is.

I suppose the only source (apart from my memory) is t...

β–Ά Play video
rare gazelle
#

too much high iq

vale wasp
#

Do not blame the US from imperial measurements. Blame the pirates for us still using them.

fiery yarrow
#

alexander the ok is british, btw

#

complaining about units used on british rigs in the north sea

vale wasp
#

I'm kinda surprised nobody asked about the pirates....

floral terrace
vale wasp
floral terrace
raven urchin
#

ts gave me such a fucking headache, now I learnt that I have to appreciate regex

for prefix in ["!e ", "!eval "]:
    if reaction.message.content.startswith(prefix):
        code = reaction.message.content[len(prefix):].strip()
        break```
vale wasp
#

Thomas Jefferson, the 3rd president of the US, was a Francophile and ordered a set of standards from France. Pirates raided the ship and stole the standards. And the rest is history.

rare gazelle
#

the only word i understood is pirates

craggy willow
#

verb or noun

floral terrace
rare gazelle
#

πŸ˜΅β€πŸ’«

vale wasp
raven urchin
vale wasp
#

Metric wasn't around until the French revolution.

vale wasp
rare gazelle
#

A Francophile is someone who has a strong affinity, love, or admiration for France, its people, language, history, and culture

#

francophile sounds bad though

vale wasp
raven urchin
vale wasp
#

Very famously.

vale wasp
floral terrace
rare gazelle
#

words ending with phile aren't so pleasent usually

raven urchin
raven urchin
#

😭

#

wait i mixed spanish there

tame raptor
#

@raven urchin

import math

d = input("Enter the diameter of your pizza in inches: ")
Ο€ = math.pi

pizza_area = (Ο€ * pow(float(d), 2))/4
pizza_area = round(pizza_area, 1)

print(f"The area of your pizza is {pizza_area} inchesΒ²")
vale wasp
raven urchin
fiery yarrow
# vale wasp Snopes blocks ad blockers so I can't see that.

hmm glorious ublock_origin lets me see it
anyways, not-really tl;dr:

While it was true that physical items to demonstrate metric standards intended for Jefferson did not make it to him because of piracy, there was no plausible alternative history in which the delivery of such items would have overcome the political stalemate over establishing a standardized measuring system β€” no matter if it was the decimal-based metric system or something else.

At the time of Dombey's death, Jefferson was already convinced of the virtue of these ideas. Congress was not. As such, we rate the claim that piracy prevented the U.S. adoption of the metric system as "False."

rare gazelle
#

pirates used to steal everything huh

tame raptor
floral terrace
vale wasp
#

And it's a fun story even if the interpretation is far-fetched. Jefferson could've had another set sent over.

flint cloak
#

i thought there was an attempt by the us govt to switch to the metric system during the cold war but the public went bananas

pallid garden
#

that's humans for ya

vale wasp
#

They started teaching it in the 50s IIRC but it has not caught on outside of the scientific community.

brisk gazelle
#

Outside the country, however...

floral terrace
vale wasp
#

Leave our freedom units alone.

floral terrace
floral terrace
vale wasp
#

You are not getting any arguments.

#

But the fact is that things that have smaller tolerances use metric.

grim hatch
#

I love how my Linux teacher keeps mentioning Galiger's travels when explaining why some commands do the same thing but at the same time are used differently

flint cloak
#

yup

flint cloak
grim hatch
vale wasp
grim hatch
#

CS is full of metaphors

vale wasp
grim hatch
#

When a parent process is killed and leaves a child process running, the child process is now called an orphan process

flint cloak
grim hatch
#

Think about that next time you kill a process

vale wasp
#

Kill all the processes. Got it.

raven urchin
flint cloak
#

processes aren't sentient, so i'm pretty sure you can go Machete on them

raven urchin
vale wasp
raven urchin
#

Dan

#

thanks for the regex thingy

vale wasp
raven urchin
#

I think my problem is fixed now

vale wasp
vale wasp
raven urchin
#

thats the magic of programming HAHA

fiery yarrow
#

discord y u hire gh devs sobMeltdown
oh it worked this time firHappy

vale wasp
spice hill
vale wasp
raven urchin
rare gazelle
#

very nice

fiery yarrow
#

there's currently a bit of a outage

raven urchin
#

Biophysics was the hardest and I got 89 theory and 87 lab :D

pallid garden
floral terrace
vale wasp
#

Somehow I manage to have a typo doing ❀️ - I is talented.

flint cloak
fiery yarrow
flint cloak
spice hill
#

It's like kilobytes and kibibytes

vale wasp
#

0.22 caliber is also 5.56mm

floral terrace
rare gazelle
#

these guys are trying to disease us

spice hill
#

Who knows what facts you'll need in the apocapylse

vale wasp
#

Having knowledge is never bad.

rare gazelle
#

how do you even know this fix

spice hill
#

I have no idea. I've never shot a live firearm in my life

vale wasp
#

I know it because of my time in the IDF.

fiery yarrow
#

because you killed them all first and shot dead firearms?

floral terrace
vale wasp
flint cloak
#

yes

raven urchin
#

I think I know but I forgot

flint cloak
#

Internet de France

brisk gazelle
#

Israel's armed forces.

raven urchin
silver plover
#

Let's come back to Python

raven urchin
#

oh sorry

vale wasp
flint cloak
raven urchin
vale wasp
flint cloak
#

nipping a kerfuffle in the bud

silver plover
#

(and 5.56 != .22... close but it's a .223... wouldn't want a .22 in a .223 or vice versa)

rare gazelle
#

.topic

verbal wedgeBOT
#
**Have you ever tried making your own programming language?**

Suggest more topics here!

raven urchin
raven urchin
vale wasp
rare gazelle
#

the probblem with the topics is that they're bad

raven urchin
#

the dominican programming language HAHA

fiery yarrow
#

Suggest more topics here!

vale wasp
# verbal wedge

Programming, no. Tried making a language with friends in school umpteen years ago.

vale wasp
spice hill
#

I never knew this google form even existed. No clue how to see the results

rare gazelle
#

i think grey suggested some

raven urchin
vale wasp
vale wasp
rare gazelle
#

oh nvm, he did facts, not topics

velvet trout
#

Hi chat

zealous lion
#

yay or nay?

x = async lambda: None
velvet trout
rare gazelle
raven urchin
# vale wasp Always.

That for loop i replaced with a regex was super annoying, because it worked, but was easy to break. So easy we didn't even notice when testing it.

I used THE EXACT AND ONLY WAY for it to work, and all others just wrote all the ways that didn't work.. So we thought I messed up the permissions or some ownership check of the messages, but it was formatting, it's always formatting 😭

velvet trout
#

ducky_concerned a CPython core dev randomly appeared

deep dome
# verbal wedge

I've tried making an esoteric programming language, but lost motivation πŸ˜…

zealous lion
#

yes hello

raven urchin
spice hill
#

I think the problem is that the topics are personal, rather than discussing something third-party. Very few people posted an actually useful PyPI package for example. And it's going to be those 3 people repeating it.

raven urchin
#

hru tonight?

rare gazelle
zealous lion
#

now why not:

async if x == y:
    ...

if x async in y:
    ...
velvet trout
zealous lion
rare gazelle
#

there is no ieq dunder i think

spice hill
fiery yarrow
#

are you actually trying to pr this to cpy

rare gazelle
#

no icontain

zealous lion
rare gazelle
#

a i mean, not i

zealous lion
rare gazelle
#

aeq, acontain

#

there's acontains?

zealous lion
#

no

spice hill
rare gazelle
#

i dont like it

zealous lion
#

or may 21st 2026

raven urchin
#

whar

velvet trout
#

__aeq__ __acontains__ ducky_concerned

rare gazelle
#

i think its too much

fiery yarrow
rare gazelle
final hollow
#

@wise imp what's the difference between event.dict["size"] and screen.get_size()?

vale wasp
rare gazelle
#

oh, didn't even think of it lol

silver plover
#

We really should have more April 1sts in a year.

vale wasp
#

The day when we must believe everything on the internet.

vale wasp
rare gazelle
#

a real april first prank would be on the last day of march

velvet trout
rare gazelle
#

got confused for a second

velvet trout
fiery yarrow
#

do you mean march or are you proposing we name months after categories of purchasable objects

rare gazelle
#

english is exhausting

chilly whale
#

there's 365.2425 days per year

fiery yarrow
#

There are currently about 365.2421875 solar days in one mean tropical year
sure about that, godly?

velvet trout
spice hill
velvet trout
rare gazelle
#

or sign language

fiery yarrow
velvet trout
#

+, -

velvet trout
wise imp
chilly whale
fiery yarrow
#

nice try

final hollow
# wise imp there's `event.dict`? anyway, you can just do `event.size` probably, but also, p...
w, h = (dim - 100 for dim in pygame.display.get_desktop_sizes()[0])
screen = pygame.display.set_mode((w, h), pygame.RESIZABLE)
pic = pygame.image.load("assets/temp.jpg")
clock = pygame.time.Clock()
running = True

while running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False
        elif event.type == pygame.WINDOWRESIZED:
            screen.blit(pygame.transform.scale(pic, event.dict["size"]), (0, 0))
            pygame.display.update()
        elif event.type == pygame.WINDOWEXPOSED:
            screen.fill((0, 0, 0))
            screen.blit(pygame.transform.scale(pic, screen.get_size()), (0, 0))
            pygame.display.update()

I'm just trying to make the screen resizeable and according to some old documentation I needed all this

chilly whale
#

the Gregorian calendar has a surprisingly complicated leap year rule that results in the .2425

#

a year is a leap year if it's divisible by 4, unless it's divisible by 100, unless it's divisible by 400

fiery yarrow
#

unfun fact: there's disagreement of whether year 4000 is gonna be a leap year or not

chilly whale
#

it should be - it's divisible by 400

rare gazelle
#

luckily we won't live by then

wise imp
rare gazelle
#

unless medicine will evolve insanely, and then we won't be so lucky

fiery yarrow
chilly whale
#

sure, but if we change the rules it's no longer clear that we can call it the Gregorian calendar

rare gazelle
#

whats special about 4000 or 20k

fiery yarrow
#

that's basically why we haven't done it yet:

thus reducing the average length of the calendar year from 365.2425 days to 365.24225. Although this is closer to the mean tropical year of 365.24219 days, his proposal has never been adopted because the Gregorian calendar is based on the mean time between vernal equinoxes (currently 365.242374 days)

raven urchin
fiery yarrow
#

a smart fella programs hello world in python, and a text-to-binary converter in python that translates the first one

ashen cipher
raven urchin
fiery yarrow
ashen cipher
fiery yarrow
#

tl;dr orbital dynamics sucks

wise imp
raven urchin
rare gazelle
#

maybe he knows only binary

raven urchin
#

It was a youtube video about "the worst ways to program"
he tried in a minecraft book and quill, and had to farm for them 😭

rare gazelle
#

this server is only english though

raven urchin
#

he also tried nintendo ds pictochat

rare gazelle
#

you can use a binary to english translator though

raven urchin
#

the video was funny af, also he gave Vim an F.

tame raptor
#

holy fuck i just created a masterpiece

#

its 11 pm rn

raven urchin
rare gazelle
#

very nice

ashen cipher
zealous lion
#

I guess it would be possible to write machine code in only 0s and 1s but in practice the only 0s and 1s are going to be physically on your CPU

raven urchin
#

(timezone)

tame raptor
#

ET

zealous lion
raven urchin
zealous lion
#

you can't write machine code with an ascii table

rare gazelle
#

._.

raven urchin
#

imagine spending 3 hours writting meaningless 0s and 1s just to figure out it wouldnt work anyway lmao

#

let me find the video so yall suffer too

rare gazelle
#

01101000 01101111 01110111 00100000 01100001 01100010 01101111 01110101 01110100 00100000 01101110 01101111

spice hill
rare gazelle
#

i'm gonna steal it thuri, everytime i wanna say "how about no"

raven urchin
fiery yarrow
raven urchin
#

He gave Vim an F tier on his "horrible" list (which means least bad)

#

that's hilarious, thats like getting Vs code in it for no actual reason 😭

rare gazelle
#

least bad?

#

the ranking is most bad gets highest rank?

wise imp
raven urchin
#

the highest was his attempt of coding in ascii 😭

velvet trout
raven urchin
#

also somehow he liked coding in a minecraft book and quill πŸ”₯

fiery yarrow
#

you really like that emoji, huh, aji?

raven urchin
spice hill
velvet trout
#

Yes, iteration fan, yes

fiery yarrow
#

like aboo with 😩

raven urchin
#

and also Β©

velvet trout
#

Who is aboo

#

New character unlocked

zealous lion
wise imp
#

wait, true, going to 360 is not a slow-down, it's a speed-up

fiery yarrow
#

@dusty ember get weary pinged lol

raven urchin
rare gazelle
wise imp
#

a-boo
hope I didn't scare ya

raven urchin
velvet trout
#

ducky_concerned if my ducks get scared, i am reporting y'all!

rare gazelle
#

imagine you do what fix said, and end up ruining it for other planets, thats kind of funny

wise imp
#

and is such a speed even achievable

#

without disintegrating earth

spice hill
fiery yarrow
#

probably about a zillion years

keen fox
#

How much is zillion

limpid meadow
#

We just have to increase the diameter of earth's orbit, ezpz

silver plover
dusty ember
velvet trout
spice hill
fiery yarrow
#

gdi aboo
you were supposed to respond with 😩

dusty ember
#

I'm a new man now

velvet trout
fiery yarrow
#

fine, so commission fix to make a weary_lemon or somthing

velvet trout
#

ducky_yellow all ducks on this server are mine, my duck army

raven urchin
#

Grr

#

I feel like coding more

#

But I have like 13 hours straight coding

#

I should sleep

fiery yarrow
#

i saw that

#

give it back

raven urchin
#

whar

fiery yarrow
#

hey aboo

raven urchin
fiery yarrow
#

weary_lemon sup

raven urchin
#

LEMONSAURUS

spice hill
fiery yarrow
#

uh brb

spice hill
fiery yarrow
velvet trout
ashen cipher
#

i'm lowkey using basedpyright purely for autocomplete

zealous lion
#

what even is basedpyright

#

in contrast to pyright I mean

ashen cipher
#

but based

keen fox
#

With based features

zealous lion
#

what features does it have

keen fox
#

Based ones?

zealous lion
#

such as?

chilly whale
#

it adds some features that pylance has but pyright doesn't, changes some defaults to make type checking more aggressive by default, and adds the ability to set up a project baseline so that basedpyright in CI only complains about new stuff and ignores existing lines

ashen cipher
keen fox
chilly whale
#

I don't think that's true

zealous lion
#

you guys will find any reason to hate on ms

chilly whale
#

I'm pretty sure features added to pyright get ported to basedpyright

zealous lion
chilly whale
#

the thing where parameter names show up if you hover over function calls is the big one I know of

ashen cipher
spice hill
ashen cipher
chilly whale
#

"inlay hints" is the one I was referring to

spice hill
#

Auto-completion, go-to-definition, and import suggestions while typing are already present in pyright

ashen cipher
spice hill
#

those things have always been in pyright

zealous lion
#

it gets all messy when I type

#

the other stuff looks cool though

spice hill
#

I too hate inlay hints in Python

velvet trout
#

inlay what

zealous lion
#

I haven’t enjoyed them in any language, but I haven’t tried them too much

#

I bet it’s a rust thing

spice hill
#

yeah, I find them useful in Rust when chaining methods

tropic temple
#

its like really overwhelming in rust

#

imo

zealous lion
#

called it

tropic temple
#

but i do like enabling implicit drop inlay hints

#

and its useful in iterators

velvet trout
#

What's inlay hints?

zealous lion
#

i’d be fine with them if the LSP was actually able to keep up with me, but usually they just get out of date or mess with my cursor

velvet trout
#

Inline hints?

ashen cipher
#

i just enabled it, am gonna try using it for a bit

zealous lion
#

it’s like where the editor shows you type hints on things that you didn’t actually add type hints for

tropic temple
#

its insane when you have really deep type generics

#

like with iced

velvet trout
tropic temple
#

they keep just poppin up everywhere and shiftin the cursor around

zealous lion
#

hate that

chilly whale
#

I have no idea how everyone else has decided that it's a good thing to have every word on the line colored a different color

brisk gazelle
#

I think it's fabulous. πŸ³οΈβ€πŸŒˆ

spice hill
ashen cipher
#

i personally rather like it although my theme is comparatively low contrast

brisk gazelle
#

I wouldn't want it in written English.

chilly whale
#

I find it incredibly distracting.

pallid garden
#

oh ho

#

i have inlay hints turned on for literally everything

spice hill
ashen cipher
chilly whale
wise imp
#

emacs has a command for it, too, I'm sure

rugged barn
#

I have spent the last six hours wrangling demons in order to get my Rust shitpit code working properly

pallid garden
#

skill issue

#

i would have taken only 5

ashen cipher
#

skill issue

#

i would've taken 17

rugged barn
#

Real

pallid garden
ashen cipher
#

powder that makes you say real

rugged barn
#

It's a good language
But by fucking God it's an exhausting language

ashen cipher
rugged barn
#

Couple that with trying to spoof a hardware you literally don't own nor can verify its inputs due to a lack of documentation...
GG

#

Fuck you Logitech

ashen cipher
#

basedpyright doesnt consider unions a type sigh

spice hill
gray siren
#

Today's News : Linkdin layoff 600 employees

pallid garden
ashen cipher
spice hill
#

smh post text as text

gray siren
ashen cipher
#
  Β Β Β Β "tuple[str, UnionType]" is not assignable to "Tuple[str, type]"
  Β Β Β Β Β Β Tuple entry 2 is incorrect type
  Β Β Β Β Β Β Β Β "UnionType" is not assignable to "type"``` but that requires me to exit (n)vim
#

also i cant extract that into a type alias

spice hill
ashen cipher
#

not my library

#

:(

spice hill
#

What's the library? And what function are you using?

ashen cipher
#

msgspec.defstruct

chilly whale
ashen cipher
#

annoying thing too is that it allows it and it shows it in an example

spice hill
wise imp
ashen cipher
wise imp
#

btw @chilly whale how do you say get your config across machines? like if you ssh into some server, how do you get same config as you have on your computer locally for like nvim or tmux

chilly whale
#

I don't change machines that often, so for me it's just manually cloning the repo with my settings

spice hill
chilly whale
#

or repos, actually - I've got neovim and tmux configs in different repos

wise imp
#

mmm, that sounds useful and quick to sync, too, thanks

spice hill
# ashen cipher :o ty!

I would guess that defstruct is mostly intended for dynamically generating struct classes

ashen cipher
#

although TypedDict doesnt seem to work that way

spice hill
ashen cipher
#

huh

wise imp
#

!pypi msgspec

edgy krakenBOT
#

A fast serialization and validation library, with builtin support for JSON, MessagePack, YAML, and TOML.

Released on <t:1776030290:D>.

rain sail
#

I m not getting what decorator is at all while creating class methods and how they can be used?

spice hill
rain sail
# spice hill Are you talking about specific decorators?

I saw @classmethod in a code like this

            def how_many(cls):
                print("We have {} robots".format(cls.population))

But then the page where I saw this also said

Decorators can be imagined to be a shortcut to calling a wrapper function (i.e. a function that "wraps" around another function so that it can do something before or after the inner function), so applying the @classmethod decorator is the same as calling:

how_many = classmethod(how_many)

But then I wanna ask how can how_many.population possible

Btw the page is this https://python.swaroopch.com/oop.html

spice hill
spice hill
# rain sail No and that's why I m confused

Normal methods ("instance methods") allow you to ask something or change something about a specific instance of a class. But class methods are about the class as a whole. In the example, you can see that you can do Robot.how_many() -- that's operating on the Robot class, not any particular robot.

rain sail
granite wyvern
rain sail
#

Self.method?

granite wyvern
spice hill
rain sail
granite wyvern
dry pike
#

ah, not "puta CC"

spice hill
wise imp
#

though you could

granite wyvern
velvet trout
#

super().__new__() ?

velvet trout
granite wyvern
rain sail
velvet trout
wise imp
#

pretty sure __init__ is also referred to as the constructor

spice hill
granite wyvern
velvet trout
#

its an initializer/setup though, not sure if calling it constructor would be appropriate

velvet trout
granite wyvern
velvet trout
#

Until dunder new knocked on my door for his rights

#

dunder new is underrated fr

brisk gazelle
# rain sail Oh so I can create instance methods just inside init and if I m creating it outs...
class Circle:
    def __init__(self, diameter):
        self.diameter = diameter

    @classmethod
    def by_radius(cls, radius):
        return cls(radius * 2)

circle_one = Circle(10)
circle_two = Circle.by_radius(5)
print(circle_one.diameter)
print(circle_two.diameter)```This is one use case for the classmethod decorator. Circle.by_radius becomes an "alternate" constructor here, another way of creating a Circle instance.
spice hill
#

I'm now realizing that A Byte of Python is a bad textbook if you're not already familiar with Java or another OO language and just need a crash course

velvet trout
#

everyone pays attention to the popular kid dunder init, thinking its the constructor. Meanwhile the real hero is dunder new, creating new instance object for you.

rain sail
spice hill
granite wyvern
dry pike
#

syntax error

spice hill
velvet trout
wise imp
inland karma
#

good morning!

spice hill
#

Speaking of... does anyone know a good free resource that explains the basics of classes?

velvet trout
#

Ohayo gozaimasu, eivl!

inland karma
brisk gazelle
#
def decorator(obj):
    return "Decorated thing."

def func():
    pass
func = decorator(func)

# being roughly equivalent to

@decorator
def func():
    pass

print(func)``````
Decorated thing.```@unsure.9
rain sail
velvet trout
#

OpalMist already cooked that answer for you

inland karma
#

a decorator is code that writes and changes code

granite wyvern
velvet trout
#

Transformation πŸ˜‹

wise imp
rain sail
granite wyvern
pallid garden
velvet trout
#

The constructor is the call to the class itself???

type.__call__(MyClass) ?

pallid garden
# rain sail Yeah...

one of the most common usage you will see is to declare that function as the handler for a URL/endpoint

brisk gazelle
wise imp
#

MyClass(...) is seemingly what is the constructor (or at least the constructor expression)

rain sail
granite wyvern
spice hill
rain sail
wise imp
brisk gazelle
#

It could also access it explicitly through the class name itself.

#

Like it's doing elsewhere.

pallid garden
#

when you declare that the method is a classmethod, it receives the class as the first argument, the same way that the instance/object of a class gets passed as the first argument in an instance method

granite wyvern
# rain sail Ye

Think of @staticmethod and @classmethod as describing the context the method receives. A normal instance method receives the instance, self. A class method receives the class. A static metho doesn't receive anything special as the first argument.

An instance method needs to be called from an instance: obj.method(....)
Because a class method provides just the class as context (the first argument, often called cls), you can call is via an instance obj.method() or via the class ObjClass.method().

A static method is just a function. Call it directly, call it via the class or call it via an instance.

gilded herald
#

remind me please, where can i throw in my code?

wise imp
velvet trout
# rain sail So we are just passing a function in a decorator but why do we need to pass it a...

Suppose this:

def deco(func):
    def wrapped():
           print("being called from wrapped() function.")
          return func()
    return wrapped

the deco is a function, which takes a function (func), and returns another function (wrapped) and the wrapped function returns the result of the original func function.

This is called the higher-order function. This is a kind of wrapping a function and adding a middle person.

def my_func():
     return "Hello, world!"

my_func = deco(my_func)  # this is what we call being decorated.
result = my_func()
print("Result:", result)
edgy krakenBOT
#
Pasting large amounts of code

So that everyone can easily read your code, you can paste it in this website:
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.

gilded herald
#

thx

quartz fulcrum
#

what is pytest?

velvet trout
#

Teaching is hard. πŸ˜”

granite wyvern
quartz fulcrum
#

unit tests?

granite wyvern
#

!pypi pytest

edgy krakenBOT
#

pytest: simple powerful testing with Python

Released on <t:1775582178:D>.

gilded herald
velvet trout
# quartz fulcrum what is pytest?

One of the usage: test your code before pushing so that you don't have unexpected bugs from new commits/updates and everything works as you expected

granite wyvern
# quartz fulcrum unit tests?

Unit tests are functions which exercise little bits of your code and check that they do what is intended. You write a heap of these, and it finds bugs, or checks that changes you've made still do the right thing. Etc.

pallid garden
#

now write a program that finds a specific combination of the story

wise imp
#

wdym "finds"?

pallid garden
#

trial and error different seeds until you get the story you want

wise imp
#

ah

#

and then write a minecraft seed-finder

velvet trout
pallid garden
gilded herald
quartz fulcrum
#

i dont need to activate venv for a new project in pycharm right?

gilded herald
spice hill
inland karma
#

yeahh, thats a good one, i just have never done it, and i was in a headspace thinking of a book

velvet trout
#

Chatto deado

#

.topic

verbal wedgeBOT
#
**What made you want to learn Python?**

Suggest more topics here!

velvet trout
#

To conqueror the world

wise yarrow
#

I had to for class

ocean ridge
arctic plank
#

Hi

white knot
#

hi

final hollow
# verbal wedge

programming was my second option after structural engineering, then I realized that im not good at chemistry

quartz fulcrum
wise yarrow
#

uni student, but yes

quartz fulcrum
#

oh

turbid onyx
#

Yo guys I am making a project

brisk gazelle
ocean ridge
turbid onyx
#

I am making a project voice command activation which runs without a seeable window, a d uses a local AI model to ans queries else use wikipedia and can open apps, write for you etc

ocean ridge
turbid onyx
#

It can even tell you about your own c specs and temps etc and what is using ur ram and etc

#

I am still finding Models, I have tried Qwen Coder 7B and 14B

ocean ridge
turbid onyx
#

One sec

brisk gazelle
ocean ridge
turbid onyx
#

One sec

#

Yea

#

Also it does not have capacity to delte files, that is still in progress as what if it deletes a same named file in another directory which is important?

#

I'm still training it

#

And I wish to make it into a application instead of a python file

#

But that's for layer

honest cradle
#

!paste

edgy krakenBOT
#
Pasting large amounts of code

So that everyone can easily read your code, you can paste it in this website:
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.

honest cradle
#

guys im having some trouble with figuring out how to make aces work

turbid onyx
#

Pyinstaller makes exe files which is good for instant butttt I want to make it so that it does not get flagged by windows defender

ocean ridge
turbid onyx
#

Yeah

swift sparrow
honest cradle
#
    def handle_aces_pls(self):
        list_of_cards = self.hand.cards
        dupe_list_of_cards = list_of_cards[:]
        ace_list = []
        for card in dupe_list_of_cards:
            if card.value == "ace":
                ace_list.append(dupe_list_of_cards.pop(card))
            else:
                pass
            aceless_value = 0
            for card in dupe_list_of_cards:
                try:
                    aceless_value += int(card.value)
                except ValueError:
                    aceless_value += 10

            if len(ace_list) != 0:
                for i in range(len(ace_list)):
                    if aceless_value + 11 > 21:
                        return 1
                else:
                    return 11```
#

im doing all this currently

#

i love how i was doing this to learn classes originally

swift sparrow
turbid onyx
#

Having a certificate is quite hard

honest cradle
#

and thats what im having the least problem with

honest cradle
#

its easier for me to wrap my head around

turbid onyx
swift sparrow
honest cradle
swift sparrow
#

there's no reason you should be duplicating your hand. All you need is a function that returns the score of your hand

turbid onyx
#

I have already made it so that you can just say a code word and the AI will auto start

swift sparrow
white knot
honest cradle
white knot
#

they are 10 ?

honest cradle
#

my values in my deck class are stored as strings

#

the numbers are 1-10

swift sparrow
honest cradle
#

but str

white knot
#

hm but cant you like map those into 10s before than waiting for a valueerror

honest cradle
#
class Deck:
    suits = ["spades", "clubs", "diamonds", "hearts"]
    values = [
        "1",
        "2",
        "3",
        "4",
        "5",
        "6",
        "7",
        "8",
        "9",
        "10",
        "jack",
        "queen",
        "king",
        "ace",
    ]

    def __init__(self):
        self.cards = []
        self.make_cards()

    def make_cards(self):
        self.cards.clear()
        for suit in Deck.suits:
            for value in Deck.values:
                card = Card(suit, value)
                self.cards.append(card)

    def count_cards(self):
        return len(self.cards)

    def shuffle(self):
        random.shuffle(self.cards)

    def deal_card(self):
        return self.cards.pop()```
#

this is my deck class

swift sparrow
#
def score_hand(hand):
    aces = 0
    total = 0
    for card in hand:
        if card.value.isdigit():
            total += int(card.value)
honest cradle
#

basically i need those to be strings to make them be able to be converted into a readable string

swift sparrow
#

have a look at this simple setup

#

does this make sense so far?

honest cradle
swift sparrow
#
def score_hand(hand):
    aces = 0
    total = 0
    for card in hand:
        if card.value.isdigit():
            total += int(card.value)
        elif card.value in ('jack', 'queen', 'king'):
            total += 10
#

how about now?

honest cradle
turbid onyx
#

I have never played black jack so Idk how to help lol

swift sparrow
#
def score_hand(hand):
    aces = 0
    total = 0
    for card in hand:
        if card.value.isdigit():
            total += int(card.value)
        elif card.value in ('jack', 'queen', 'king'):
            total += 10
        else:
            total += 11
            aces += 1
#

now?

carmine skiff
#

Man i got some bad news today

turbid onyx
white knot
#

but in blackjack there is some rule right? when to choose A

#

idk properly

honest cradle
swift sparrow
#

it's ALWAYS 11 unless you bust

#

then it's 1

white knot
#

idk the game tbh

swift sparrow
#

that's it

white knot
#

ok

carmine skiff
swift sparrow
honest cradle
swift sparrow
#

if we're over 21 and we have aces in our hand, we can subtract 10

swift sparrow
honest cradle
swift sparrow
#

no you don't

#

you just need a function that scores your hand

#

that's it

#

you don't score a dealer's hand until they flip their 2nd card

honest cradle
carmine skiff
#

Yup drunk drivers are a whole different breed of moron

swift sparrow
#

you can add another condition after to check for soft 17

honest cradle
swift sparrow
#

"if score_hand(hand) == 17 and "ace" in dealer.hand.values:"

#

this is slightly pseudocode, but roughly like this

honest cradle
#

i get that

swift sparrow
#

we don't care if the hand is scored with an ace initially

#

don't try and do too much in a single function

#

keep them as simple and general as possible

honest cradle
swift sparrow
#

it's better to have 3 simple functions than 1 complex function

honest cradle
#

like say after i end my turn

#

does the dealer reveal his cards?

swift sparrow
#

the dealer only has 1 card to reveal

#

they are dealt 1 face down and 1 face up

honest cradle
#

but cant the dealer hit?

swift sparrow
#

yes, they MUST hit on <=16 or soft 17

honest cradle
swift sparrow
#

yes, once all players have resolved, the dealer goes

honest cradle
#

ok that doesnt really matter in my code

#

move on

swift sparrow
#

that's it

#

after the players go, you reveal the dealer's hand and score it

#

you should know if the dealer has blackjack initially though

#

if the dealer is dealt blackjack, it ends

swift sparrow
#

everybody loses if the dealer is dealt blackjack

honest cradle
#

wait so my blackjack gets overriden by his one?

swift sparrow
#

unless you have blackjack too, then it's a push

honest cradle
swift sparrow
#

push means tie

honest cradle
#

so we kinda dont need to knw tho

swift sparrow
#

you should keep track of the dealer's stuff internally even if the player doesn't have that information yet

honest cradle
#

why tho

#

its 1v1 blackjack

swift sparrow
#

so you know if they're dealt a blackjack

#

the player doesn't play out their turn if the dealer is dealt a blackjack

white knot
#

how do i remove an added file from git

swift sparrow
#

1v1

#

I get dealt a card, dealer gets a card (face down). I get dealt another card, dealer gets another card (face up)

honest cradle
#

so they just get 2 cards and it s over?

velvet trout
swift sparrow
#

if the dealer's face up card is a 10 value, they peek at their face down card

honest cradle
swift sparrow
#

if their face down card is an ace, the round automatically ends

#

if you ALSO have blackjack, you get your money back

#

otherwise, you lose

velvet trout
#

Don't nuke people, nuke code

- Alex

honest cradle
white knot
#

i am writing my code in text editor now

#

its C code

honest cradle
swift sparrow
white knot
swift sparrow
#

it's the game's responsibility to score the hand

honest cradle
#

my brother took 11th grade html in notepad

swift sparrow
#

treat your card/deck/player classes as if they could be used for any card game

honest cradle
#

but my player class is only for my blackjack

swift sparrow
honest cradle
#

that is pretty much what it is

swift sparrow
#

it should be a generic "player" class. It's something that holds onto cards

#

it's the game that gives those cards meaning

honest cradle
quartz fulcrum
#

how to convert the string like ''10 -20" into [10, 20]

swift sparrow
swift sparrow
ocean ridge
swift sparrow
ocean ridge
swift sparrow
ocean ridge
#

serializing a string to this array

granite wyvern
swift sparrow
#

I'd maybe say "parse"

ocean ridge
#

oh yeah

honest cradle
granite wyvern
#

Serialising is typically transcribing something to a string or bytes.

#

parsing/tokenising is the other way

swift sparrow
ocean ridge
golden mortar
ocean ridge
bronze dragon
#

"deserialize" maybe
but that feels like too strong of a word for a .split lol

velvet trout
#

parsed = list(map(int, s.split()))

pithink ducky_concerned functional programming guys.

quartz fulcrum
#

what does map do

swift sparrow
#

calls a function on every element of another iterable

quartz fulcrum
#

i also hv to convert those numbers into int too

velvet trout
#

Takes a callable and an iterable, and passes each item from iterable to that callable

swift sparrow
#
data = ['a', 'abc', 'abcde']
#

let's say I have this list

#

and I want a list of all the lengths of these strings

#

can you tell me what that would look like @quartz fulcrum ?

quartz fulcrum
#

a loop?

swift sparrow
#

no, just what would the list look like

velvet trout
#

yeah, the map just makes it even easier

swift sparrow
#

instead of 'a', 'abc', 'abcde'

#

I want the len of these strings

quartz fulcrum
#

len(data)

velvet trout
#

Of each string

swift sparrow
#

no, that gives me how many things are in the list

honest cradle
#
    def score(self):
        aces = 0
        t_value = 0
        for card in self.hand.cards:
            if card.value.is_digit():
                t_value += int(card.value)
            elif card.value.lower() in ('king','jack','queen'):
                t_value += 10
            else:
                if t_value + 11 > 21:
                    t_value += 1
                else:
                    t_value += 11
                aces += 1```
#

does this work

velvet trout
golden mortar
swift sparrow
#

we need to total the full hand, then we can retroactively correct the score if necessary

honest cradle
#

ok

#
    def score(self):
        aces = 0
        t_value = 0
        for card in self.hand.cards:
            if card.value.is_digit():
                t_value += int(card.value)
            elif card.value.lower() in ('king','jack','queen'):
                t_value += 10
            else:
                t_value += 11
                aces += 1
            ```
golden mortar
#

Though in Python list comprehensions and the like are more commonly used than map

honest cradle
#

boom

quartz fulcrum
#

no idea, i can only think of loop

swift sparrow
#

I'm not asking you about any code

quartz fulcrum
#

ann int

swift sparrow
#

when you write code, you should know what result you're trying to achieve

chrome isle
velvet trout
ocean ridge
swift sparrow
#

if you don't know what the result will be, how can you write code to work towards that result?

quartz fulcrum
golden mortar
#

!e ```py
lst = [1, 2, 3]

loop

result = []
for x in lst:
result.append(x**2)
print(result)

map

result = list(map(lambda x: x**2, lst))
print(result)

comprehension

result = [x**2 for x in lst]
print(result)

#

oops

swift sparrow
#

what's len('a')?

edgy krakenBOT
quartz fulcrum
velvet trout
honest cradle
swift sparrow
swift sparrow
honest cradle
#

my bust check logic is in my game function

honest cradle
quartz fulcrum
#

3

swift sparrow
swift sparrow
quartz fulcrum
#

5

velvet trout
#

Why do i feel like we are making wizard look like the python interpreter ducky_concerned

swift sparrow
#

ok, so what would that look like in a list?

#
text = ['a', 'abc', 'abcde']
#

if I want the len of each of these strings?

quartz fulcrum
#

[1, 3, 5]

swift sparrow
#

yes exactly

golden mortar
swift sparrow
#
text = [len('a'), len('abc'), len('abcde')]
#

we can think of it like this

#

but we can use map

velvet trout
# quartz fulcrum [1, 3, 5]

Like his each output is exactly how in a REPL would be ducky_concerned he ain't even putting words. Quiet straightforward result

swift sparrow
#

!e

text = ['a', 'abc', 'abcde']

print(list(map(len, text)))
edgy krakenBOT
swift sparrow
#

mapping len to this list will give us that same result

honest cradle
#

bt i think im gonna need to rewrite my game function for that

olive sable
#

hiiiii
what is map in this code

velvet trout
edgy krakenBOT
#
map

map(function, iterable, /, *iterables, strict=False)```
Return an iterator that applies *function* to every item of *iterable*, yielding the results. If additional *iterables* arguments are passed, *function* must take that many arguments and is applied to the items from all iterables in parallel. With multiple iterables, the iterator stops when the shortest iterable is exhausted. If *strict* is `True` and one of the iterables is exhausted before the others, a [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError) is raised. For cases where the function inputs are already arranged into argument tuples, see [`itertools.starmap()`](https://docs.python.org/3/library/itertools.html#itertools.starmap).

Changed in version 3.14: Added the *strict* parameter.
olive sable
#

ohhh

swift sparrow
olive sable
#

thansks

quartz fulcrum
swift sparrow
#

!e

text = 'python'

print(list(map(str.upper, text)))
edgy krakenBOT
quartz fulcrum
#

so it will create a new list, always?

velvet trout
#

no, map returns a generator iterator

swift sparrow
#

it creates a "map" object

velvet trout
#

You can use any container which consumes that generator

swift sparrow
#

but I'm calling list() on it so you can see the result

velvet trout
#

tuple(map(int, my_list)) works too

swift sparrow
#

!e

text = 'python'

print(*map(str.upper, text))
golden mortar
edgy krakenBOT
spice hill
honest cradle
#

im gonna need to make a computer computing function too

velvet trout
#

i am too biased towards generator πŸ₯€

#

Thanks for correction

golden mortar
#

I have to look up the definitions of the terms generator, iterator and iterable every time I need to use them.

spice hill
#

i thought it's pretty clear

ocean ridge
#

why do i share this problem too?

golden mortar
#

I feel like I see a lot of other people having the same issue.

swift sparrow
#

they also overlap quite a bit

velvet trout
#

i call anything a generator which uses yield, iterator when its just implementing iterator protocol and iterable is any object returning an iterator

swift sparrow
#

it's like a square/rectangle problem

velvet trout
velvet trout
#

str() doesn't take iterable... Had to use "".join(...) ducky_concerned broke my intuition/prediction as tuple/list/dict/set takes an iterable

swift sparrow
#

dict() takes a mapping

velvet trout
#

Yeah right

#

though its intuitional

gleaming knoll
velvet trout
#

russia has a great memory ducky_concerned

swift sparrow
velvet trout
#

I ain't putting a print bro

white knot
#

what was the advantage of switch statements over chained if-elif

swift sparrow
#

matching shape

velvet trout
#

!pep 636

gleaming knoll
edgy krakenBOT
velvet trout
#

As the name says, Structural Pattern Matching

swift sparrow
honest cradle
#

in blackjack

#

1v1

#

i get a turn and the dealer gets a turn right?

#

so when is it scored

swift sparrow
#

it doesn't alternate

#

the player goes first and hits (asks for cards) until they stand (no longer want cards)

#

if the player busts, it just ends there

honest cradle
#

so i just rewrote my logic for no reason

past wave
#

Is it just me or OOP is a little bit hard haha

swift sparrow
#

if the player stands with a value of 21 or less, then the dealer takes their turn

swift sparrow
golden mortar
past wave
#

So I need to be scared, fu*k -.-

golden mortar
#

OOP is also a big area

swift sparrow
golden mortar
#

There are parts of it that are harder than others

wise imp
#

OOP is a hoax anyway /hj

spice hill
swift sparrow
#

We all figured it out eventually, you can too

swift sparrow
golden mortar
honest cradle
#

@swift sparrow this isnt finished

#

but am i on the right path

swift sparrow
#

the score function?

honest cradle
#

everything

#

check out my game function

rain sail
#

best way to use free ai forever in pycharm?

swift sparrow
#

whenever the player hits, you'll score their hand

rain sail
swift sparrow
# honest cradle wdym

you have a value function and a score function and I don't understand why you have both

#

just get the scoring function working first, then you can continue

#

you nearly have it

#

let's say for example the hand is 6, king, ace

#

we go through first scoring everything (with ace as 11) and we calculate 27

#

6 + 10 + 11

#

after we score, we can say "if we have over 21, but we scored an ace, then subtract 10"

honest cradle
#

my scoring does that

swift sparrow
#

no it doesn't

#

it handles the first part

#

not the corrective part

velvet trout
#

Like how tuple & list consumes items and creates a tuple/list container of the given object

past wave
swift sparrow
#

sounds pretty reasonable that str() would call the object's __str__

past wave
velvet trout
#

Yeah, indeed

#

does it have anything like str.from_iterable(iterable) ?

swift sparrow
#

nope

velvet trout
#

I could only think of using "".join(iterable) at the moment.

swift sparrow
#

basically join

bronze dragon
#

str.join is what you want

swift sparrow
#

assuming the iterable contains only strings

velvet trout
swift sparrow
#

no

bronze dragon
#

str.from_iterable as you describe it could only be a less-general (and less-useful) version of str.join

bronze dragon
swift sparrow
#

you couldn't ''.join(range(5))

velvet trout
bronze dragon
velvet trout
#

HEHEHE

swift sparrow
#

@honest cradle sorry I gotta go but you're nearly there!

#

good luck