#voice-chat-text-1

1 messages ยท Page 32 of 1

thin night
#

ok miser mac donald

#

just need unmute

proper ridge
thin night
#

@proper ridgenot today bro

delicate wren
#

for the next two weeks, you can use text instead of voice for communication

thin night
#

@proper ridgewhere rus phyton community?

mild flume
#

Rust Python community?

thin night
#

AHhahaha. russian

mild flume
#

Ah that makes more sense. I don't know, actually. There must be, but I haven't had anyone mention one before

thin night
#

@mild flume
maybe you should create a Russian chat?

proper ridge
#

Why russian?

mild flume
#

We stick with English since we can really only moderate languages we know. And since most commands/functions/etc. are in English for programming, that ended up being the most reasonable option

delicate wren
#

learn English, it's useful for programming in general

mild flume
#

But if you do find a Russian Python server, please let me know! I like finding other resources I can potentially recommend to people

delicate wren
#

there is some community that can be found thorugh Discoverable Servers but it's sketchy

mild flume
#

Fair

delicate wren
mild flume
#

Lame

wintry sparrow
#

How is All?

mild flume
#

Hanging in there. You?

#

@zenith wedge When you were mentioning wanting breakfast stuff, this came to mind: https://youtu.be/EHIHl8Rw6W8?si=YKzDl024RDYj0QNO

Full breakfast, The Full English, The Big Breakfast. Unless you are running a double marathon, you absolutely don't need one.

Me Profile on Spotify - https://open.spotify.com/artist/0hQBk...

Itunes/Apple Music - https://music.apple.com/au/artist/tom...

Bandcamp - https://tomcardy.bandcamp.com/album/a...

Merch - https://tomcardy.bandtshirts.c...

โ–ถ Play video
#

The Python Software Foundation

#

Not for profit

#

Actually is there a difference between not for profits and non-profits?

#

Or are those just two phrases for the same thing

#

Yep, Excel is going to have native (well relatively native) Python useage

#

It's.... odd

obtuse mauve
#

How to use django in python

mild flume
#

We do

#

We have some CPython core devs

delicate wren
mild flume
#

Some are just here as individuals, we do have a few on staff

#

We are not run by the PSF

#

We're a separate entity

#

We have worked with them and hosted some launch parties and a code sprint

wintry sparrow
#

Scotch,Spliff & Ice

obtuse mauve
#

Is Mysql Mandatory for Web application making in python

mild flume
#

But we are not officially a part of the PSF

wintry sparrow
#

Good to hear mate, hope you well

delicate wren
mild flume
#

Not sure

mild flume
mild flume
delicate wren
#

terrible as in his joke taste

proper ridge
#

Was thinking of proposing sth.

wintry sparrow
#

Scotch,Spliff&Ice

Hit the city, hit the dice

Don't forget the slice...

proper ridge
#

Could we do...a python course with some of PSF being guest speakers?

mild flume
#

@zenith wedge I used to

#

But I use a trackball now

obtuse mauve
#

If we use django in python , as a framework, can we use HTML and Javascript Front end in VS.Code to do coding furtheras a static page...

mild flume
#

You don't have your move your hand to move the cursor

#

That's the one I use

#

You just use your thumb to move it

delicate wren
mild flume
#

Trackballs have been around for ages

delicate wren
#

Django does not prevent usage of JS on the frontend, although composing front-end frameworks with Django's templating is non-trivial

mild flume
#

Not only that, you don't have to have it on your desk

#

You can have it just sitting in your lap or wherever

delicate wren
#

often if you're building a complex enough front-end application Django will end up just handling API stuff

obtuse mauve
#

@delicate wren Python is a backend, But Html and Javascript is front end, im confused...

mild flume
#

Javascript also has engines to act as a backend

#

Most common one being Node.js

#

Front end for web is made of 3 pieces: HTML, CSS, and JavaScript

delicate wren
#

mostly

mild flume
#

HTML tells the browser what to put on screen, CSS tells it how to make it look, JS handles interaction and other stuff

#

@zenith wedge Your mom?

#

It's weird setting up a Dell machine

#

We've had only HP for ages

delicate wren
#

Django on its own does not provide any front-end interactivity as far as I know

proper ridge
#

They're all communities dedicated to python.

delicate wren
#

there are some packages that help integrating HTMX into Django

#

at least allegedly

mild flume
#

3rd column, last row

wintry sparrow
#

Scotch,Spliff&Ice

Hit the city, hit the dice

Don't forget the slice...

Large extra small,

Can't do it in public, can't do it at all

Enough to Stumbling

Weak be crumbling

Aren't no stunting

Tryk den Kobling

Vi OG...

mild flume
#

@pseudo raven I guess I count as not normal, then

proper ridge
#

I was thinking of hosting some courses, hackathons, etc. to engage more with the community.

mild flume
#

@pseudo raven Tell that to light sleepers

proper ridge
#

Like what IBM does. They host events here and there as short courses with guest speakers, teach some stuff through code, and that's it. They've been getting their community through these.

#

And that's one company with one package. We'd be representing python itself, and could host events like those as domain-specific use-cases.

proper ridge
#

I've never seen it?

mild flume
proper ridge
#

Ohh very nice.

delicate wren
#

@pseudo raven also that's why many cars now have fake engine sounds to make them louder

mild flume
#

@pseudo raven I've never heard that phrase before

wintry sparrow
#

"IF you put something on internet, it's there forever

No it's not there forever

It's there as long the computer you put it on, is turned on

If Facebook/Meta turn off their PC, it's not there anymore

So you rely on somebody else...

It's all about DNS>..

mild flume
#

That's great

mild flume
#

By dangerous I mean things that would help people track or blackmail them

wintry sparrow
#

For sure

#

Or i don't know

#

Because you make people stupid

#

But i can understand the perspective

mild flume
#

How does that make people stupid?

#

That encourages people to think twice before posting things

#

If anything that's making them slightly wiser or at least better informed of the dangers

wintry sparrow
#

If minority is smart, then majority must be stupid, but you don't have to make people stupid

#

Unaware, misguided then

#

because it's incorrect

mild flume
#

Factually? Yes. Practically? No

#

You tell someone that "no, that's not actually the case", a lot of people will go "oh, then I don't have to worry"

#

That's counter productive if you're still trying to get them to be smarter about their online presence

wintry sparrow
#

Isn't unawareness the issue to begin with?

mild flume
#

True

#

But it's missing the forest for the trees

#

The big picture is make people be careful

delicate wren
#

yes I do

wintry sparrow
#

I can see it, i don't know

Just wanted to say it ๐Ÿ˜„

mild flume
#

Oh for sure

delicate wren
#

as for Python I've only used the built-in thing

#

!d unittest

coarse hearthBOT
#

Source code: Lib/unittest/__init__.py

(If you are already familiar with the basic concepts of testing, you might want to skip to the list of assert methods.)

The unittest unit testing framework was originally inspired by JUnit and has a similar flavor as major unit testing frameworks in other languages. It supports test automation, sharing of setup and shutdown code for tests, aggregation of tests into collections, and independence of the tests from the reporting framework.

To achieve this, unittest supports some important concepts in an object-oriented way:

delicate wren
#

it's okay

proper ridge
#

!paste

delicate wren
#

what was the preferred one

#

pytest?

mild flume
#

pytest is crazy common, too

#

Yep

proper ridge
#

I use pytest.

delicate wren
#

test_init is wrong

proper ridge
#

Yeah, I've been trying to see how to properly test initialization.

delicate wren
#

generally you should be testing behaviours/scenarios/usecases not methods

#

state what you assert in the test name

#

(if possible)

mild flume
#

Expect test names to be long and descriptive

delicate wren
#

if you want to test __init__, check invariants (if any)

proper ridge
delicate wren
#

if your __init__ just assigns data, there isn't really anything to test

proper ridge
delicate wren
#

if __init__ does conversion and/or validation, test those specific things not initialisation in general

proper ridge
#

It shouldn't raise an error.

proper ridge
mild flume
#

Then you're covered

delicate wren
#

test when it does

#

and when it doesn't

proper ridge
#

Could you kindly have a look at how I've written the testers? Is it terrible or does it have some chance of redemption hehe.

proper ridge
delicate wren
#

what you're testing there isn't "can initialise an object"
what you're testing there is "can initialise an object given non-numpy list"

mild flume
#

I need to get a small dock for these laptops that I can use to plug in ethernet

delicate wren
#

so you're testing the conversion

mild flume
#

Drives me bonkers that laptops don't have that port anymore

delicate wren
#

which can (and will) at times fail

mild flume
#

And the wifi connection here is so friggin' bad where I'm at

proper ridge
mild flume
#

I'm the furthest away from our access point in the office as i could be

#

And I'd rather not have to tether my phone

delicate wren
#

Data("abc") is expected to raise an exception

mild flume
#

Wait does pytest do type checking?

#

I wouldn't think so

delicate wren
#

I'd hope not

proper ridge
#

Unless you add errors like I am manually doing.

mild flume
#

Fair

proper ridge
#

A bit of a defensive coding which Mr. Nedbat said not to do, but I think this one is justified?

#

Still a bit hard to distinguish fool-proof vs defensive.

delicate wren
mild flume
#

Remember "Python is a language for conscenting adults". There's only so much protecting you can do/should need to do for the users of your library. If they aren't reading your docs and handling the types properly, that's partly on them

#

Over checking can affect performance

delicate wren
#

neither of Datas, that .pad() was called on, have any assertions afterwards

#

missing assert matrix.padded seems like

#

wait

#

oh

mild flume
#

assert deez_nutz

delicate wren
#

yeah, just call it again

#

after second

#

yeah, assert that it doesn't break it

#

@proper ridge
does .pad() on padded keep the data as is?

#

then make a copy of data

#

and compare afterwards

#

for exact equality

#

coverage isn't good enough metric

#

tests still need to make sense

#

while you're doing that you might also define .__eq__ and .copy for Data if not defined yet

mild flume
#

This laptop dropping WIFI is going to get reeeaaaally old reeeeaaallly fast

delicate wren
#

it's okay but it's not the only thing that tests should be aiming for

#
# how to split these -- that's a separate question
assert Data([1, 2, 3]) == Data([1, 2, 3])
assert Data([1, 2, 3]) != Data([1, 2, 4])

original = Data([1, 2, 3])
assert original.copy() == Data([1, 2, 3])
assert original == Data([1, 2, 3])
#

depends

low jetty
#

whats the point of vector calcs?

proper ridge
low jetty
#
class Vector {
    // Constructor method to initialize the vector components
    constructor(x, y) {
        this.x = x;
        this.y = y;
    }

    // Method to add another vector to the current vector
    add(v) {
        return new Vector(this.x + v.x, this.y + v.y);
    }

    // Method to subtract another vector from the current vector
    subtract(v) {
        return new Vector(this.x - v.x, this.y - v.y);
    }

    // Method to multiply the vector by a scalar value
    multiply(scalar) {
        return new Vector(this.x * scalar, this.y * scalar);
    }

    // Method to calculate the dot product with another vector
    dot(v) {
        return this.x * v.x + this.y * v.y;
    }

    // Method to calculate the magnitude (length) of the vector
    magnitude() {
        return Math.sqrt(this.x * this.x + this.y * this.y);
    }

    // Method to normalize the vector (make its magnitude 1)
    normalize() {
        const mag = this.magnitude(); // Get the magnitude of the vector
        return new Vector(this.x / mag, this.y / mag); // Divide each component by the magnitude
    }
}```
like why did i make this class to do my math for me, i feel like its extra work
delicate wren
#
def test_copy_leaves_original_intact():
    original = Data([1, 2, 3])
    original.copy().normalise()
    assert original == Data([1, 2, 3])
low jetty
#

and i barely end up using it for its intended purpose

delicate wren
#

I bought one because my laptop has very little in terms of ports too

#

only a single USB Type-A

low jetty
ornate knot
#

guys

low jetty
delicate wren
#

on the new computer I have 9 Type-A ports, of which I use 0

ornate knot
#

any clue on how to setup poetry + django ?

delicate wren
#

I'd expect it to be not that different from other poetry projects

#

is there a specific issue?

low jetty
ornate knot
#

basically the structure. Im trying to follow the Django Tutorial. Using its CLI it will set up a structure for you, but then if you try to follow with poetry the structure starts to mess up quickly

delicate wren
#

they do poetry stuff first, and only then run django-admin startproject via poetry

ornate knot
#

okay it seems promising, ty Alisa!

delicate wren
#

@proper ridge class is more common

#

with test-class-per-code-class, since ideally classes should be usable (and therefore testable) in isolation

#

which isn't always the case

low jetty
#

@delicate wren look i got it to work

delicate wren
#

sometimes there may be a test scope that involves multiple classes, modules, etc.

delicate wren
#

does pytest allow inline tests? (inline with the rest of the code)

#

from what I remember seeing with both Python and C# testing, they have tests as some outside module/package

ornate knot
#

@delicate wren Do u use Poetry in your daily basis by any mean?

delicate wren
#

no

#

I've stopped working on Python projects as seriously around the time setup.py officially died, iirc

#

or not "died" just got labelled as non-preferred

#

direct use of setup.py and distutils are deprecated though

#

whereas in 2020~2021 distutils was okay-ish for doing C dependency compilation afair

#

where embed

#

(the title of the page has a question mark at the end, which is not reflected in the URL)

#

the latest Python project, that I work on and which is considerably serious, does not involve me using poetry or whatever else because there aren't really any pypi dependencies to manage there

#

with this being the only mention of versions on Python's side

[build-system]
requires = ["maturin>=1.0,<2.0"]
build-backend = "maturin"
#

poetry seems useful for poetry.lock

#

but now there are other project/dependency management tools that have lock files too

#

pipenv does, pdm does

#

rye too

#

I don't remember which others exist

ornate knot
#
django_tutorial/
โ”œโ”€โ”€ db.sqlite3
โ”œโ”€โ”€ django_tutorial
โ”‚ย ย  โ”œโ”€โ”€ __init__.py
โ”‚ย ย  โ”œโ”€โ”€ __pycache__
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ __init__.cpython-312.pyc
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ settings.cpython-312.pyc
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ urls.cpython-312.pyc
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ wsgi.cpython-312.pyc
โ”‚ย ย  โ”œโ”€โ”€ asgi.py
โ”‚ย ย  โ”œโ”€โ”€ settings.py
โ”‚ย ย  โ”œโ”€โ”€ urls.py
โ”‚ย ย  โ””โ”€โ”€ wsgi.py
โ”œโ”€โ”€ manage.py
โ”œโ”€โ”€ poetry.lock
โ””โ”€โ”€ pyproject.toml
#

does this structure look okay?

delicate wren
#

yes (if it runs)

ornate knot
#

it does, im willing to change the most inner django_tutorial folder into src/

#

that should keep working and should look nice and clean right?

delicate wren
#

depends

#

for importable packages, there still needs to be a directory named the same as the package because of how Python imports work

#

but here it should be okay

#

since you're not making the package for external consumption

ornate knot
#

hum I see, then, maybe this should be better

delicate wren
#

manage.py and pyproject.toml might be mentioning the directory by name

#

.gitignore is missing (if you plan on using Git, Python almost always needs a .gitignore because of __pycache__)

ornate knot
#

im trying to figure this out

delicate wren
#

wait that one wasn't official

#

hmm

#

there is Python gitignore file somewhere

#

idk if Django officially provides one for project templates

coarse hearthBOT
#

Python.gitignore lines 58 to 62

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal```
delicate wren
#

ig the generic Python one is fine since it includes Django-related parts

ornate knot
#
โ”œโ”€โ”€ pyproject.toml
โ””โ”€โ”€ src
    โ”œโ”€โ”€ manage.py
    โ””โ”€โ”€ mysite
        โ”œโ”€โ”€ __init__.py
        โ”œโ”€โ”€ asgi.py
        โ”œโ”€โ”€ settings.py
        โ”œโ”€โ”€ urls.py
        โ””โ”€โ”€ wsgi.py```
#

this looks nice and clean right?

delicate wren
#

should work

ornate knot
delicate wren
#

IDEs sometimes need to be pointed-to src directory for recognising imports

delicate wren
ornate knot
#

well it should be okay for now

#

thanks for the guidance Alisa

delicate wren
#

@proper ridge where is call to isinstance?

#

@proper ridge did you reload the import?

#

hmm

#

error messages take source from file not in-memory buffer, iirc

#

can you restart the kernel?

#

@proper ridge you can't check is something is an instance of, for example, list[int], only list

#

!e

isinstance([], list[int])
coarse hearthBOT
# delicate wren !e ```py isinstance([], list[int]) ```

:x: Your 3.12 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 1, in <module>
003 |     isinstance([], list[int])
004 | TypeError: isinstance() argument 2 cannot be a parameterized generic
delicate wren
#

you have a []d thing inside the union

#

in that type alias

#

how is it defined, again?

#

you need to do isinstance(thing, Collection)

proper ridge
#
from __future__ import annotations

__all__ = ["Collection"]

from typing import (Iterator, overload, Protocol, TypeVar,
                    TypeAlias, Self, runtime_checkable)


T = TypeVar("T")

@runtime_checkable
class Collection(Protocol[T]):
  def __len__(self) -> int:
    ...
  def __iter__(self) -> Iterator[T]:
    ...
  @overload
  def __getitem__(self, idx: int) -> T:
    ...
  @overload
  def __getitem__(self, idx: slice) -> Self:
    ...
  @overload
  def __setitem__(self, idx: int, value: T) -> None:
    ...
  @overload
  def __setitem__(self, idx: slice, value: Self) -> None:
    ...
  def __add__(self, other: Self) -> Self:
    ...
  def __mul__(self, other: int) -> Self:
    ...


# `NestedCollection` is a type alias that represents a collection of elements
# of type T or a collection of collections of elements of type T.
NestedCollection: TypeAlias = Collection[T] | Collection["NestedCollection[T]"]
delicate wren
#

!e

isinstance([], list | set)
coarse hearthBOT
delicate wren
#

hmm

#

surprising

#

!e

print(isinstance([], list | set))
coarse hearthBOT
delicate wren
#

(I didn't know unions are supported)

delicate wren
proper ridge
#

!e

print(isinstance("a"), int | float)
print(isinstance("a"), int | float | str)
coarse hearthBOT
delicate wren
#

-> Self on __getitem__ is wrong

#

it needs to return Collection[T] not Self

#

!e

from __future__ import annotations
__all__ = ["Collection"]
from typing import Iterator, overload, Protocol, TypeVar, TypeAlias, Self, runtime_checkable
T = TypeVar("T")
@runtime_checkable
class Collection(Protocol[T]):
  def __len__(self) -> int: ...
  def __iter__(self) -> Iterator[T]: ...
  @overload
  def __getitem__(self, idx: int) -> T: ...
  @overload
  def __getitem__(self, idx: slice) -> Self: ...
  @overload
  def __setitem__(self, idx: int, value: T) -> None: ...
  @overload
  def __setitem__(self, idx: slice, value: Self) -> None: ...
  def __add__(self, other: Self) -> Self: ...
  def __mul__(self, other: int) -> Self: ...
NestedCollection: TypeAlias = Collection[T] | Collection["NestedCollection[T]"]
print(NestedCollection)
print(NestedCollection[int])
coarse hearthBOT
delicate wren
#

^ another reason why it's wrong

#

!e

from __future__ import annotations
__all__ = ["Collection"]
from typing import Iterator, overload, Protocol, TypeVar, TypeAlias, Self, runtime_checkable
T = TypeVar("T")
@runtime_checkable
class Collection(Protocol[T]):
  def __len__(self) -> int: ...
  def __iter__(self) -> Iterator[T]: ...
  @overload
  def __getitem__(self, idx: int) -> T: ...
  @overload
  def __getitem__(self, idx: slice) -> Self: ...
  @overload
  def __setitem__(self, idx: int, value: T) -> None: ...
  @overload
  def __setitem__(self, idx: slice, value: Self) -> None: ...
  def __add__(self, other: Self) -> Self: ...
  def __mul__(self, other: int) -> Self: ...
type NestedCollection[U] = Collection[U] | Collection[NestedCollection[U]]
print(NestedCollection)
print(NestedCollection[int])
coarse hearthBOT
delicate wren
#

^ only 3.12

#

it will fail

ornate knot
#

well, ce you guys, take care!

delicate wren
#

type alias syntax was added in 3.12

delicate wren
#

time to test

#

!e

from __future__ import annotations
__all__ = ["Collection"]
from typing import Iterator, overload, Protocol, TypeVar, TypeAlias, Self, runtime_checkable
T = TypeVar("T")
@runtime_checkable
class Collection(Protocol[T]):
  def __len__(self) -> int: ...
  def __iter__(self) -> Iterator[T]: ...
  @overload
  def __getitem__(self, idx: int) -> T: ...
  @overload
  def __getitem__(self, idx: slice) -> Self: ...
  @overload
  def __setitem__(self, idx: int, value: T) -> None: ...
  @overload
  def __setitem__(self, idx: slice, value: Self) -> None: ...
  def __add__(self, other: Self) -> Self: ...
  def __mul__(self, other: int) -> Self: ...
NestedCollection: TypeAlias = Collection[T] | Collection[list[T]] # changed to list as an experiment
print(NestedCollection)
print(NestedCollection[int])
coarse hearthBOT
delicate wren
#

hmm

#

so it does propagate

#

Python turns out to be smarter than expected

#

!d typing.TypeAlias

coarse hearthBOT
#

typing.TypeAlias```
Special annotation for explicitly declaring a [type alias](https://docs.python.org/3/library/typing.html#type-aliases).

For example:

```py
from typing import TypeAlias

Factors: TypeAlias = list[int]
```  `TypeAlias` is particularly useful on older Python versions for annotating aliases that make use of forward references, as it can be hard for type checkers to distinguish these from normal variable assignments:
delicate wren
#

ig it takes all the TypeVars from types it has mentioned inside

#

!e

from __future__ import annotations
from typing import TypeVar, TypeAlias
T = TypeVar("T")
U = TypeVar("U")
Test: TypeAlias = tuple[T, U] | tuple[U, T]
print(Test)
print(Test[int, str])
print(Test[int])
coarse hearthBOT
delicate wren
#

how does it pick the order

#

!e

from __future__ import annotations
from typing import TypeVar, TypeAlias
U = TypeVar("U")
T = TypeVar("T")
Test: TypeAlias = tuple[T, U] | tuple[U, T]
print(Test)
print(Test[int, str])
print(Test[int])
coarse hearthBOT
delicate wren
#

order is entirely inferred from inside of the alias

#

!e

from __future__ import annotations
from typing import TypeVar, TypeAlias
T = TypeVar("T")
U = TypeVar("U")
Test: TypeAlias = tuple[U, T] | tuple[T, U]
print(Test)
print(Test[int, str])
print(Test[int])
coarse hearthBOT
delicate wren
#

hmm

#

order is still the same

#

!e

from __future__ import annotations
from typing import TypeVar, TypeAlias
T = TypeVar("T")
A = TypeVar("A")
Test: TypeAlias = tuple[T, A] | tuple[A, T]
print(Test)
print(Test[int, str])
print(Test[int])
coarse hearthBOT
proper ridge
#

!e

from __future__ import annotations
from typing import TypeVar, TypeAlias
T = TypeVar("T")
A = TypeVar("A")
Test: TypeAlias = tuple[T, A] | tuple[A, T]
print(Test)
print(Test[int, str])
print(Test[str, int])
coarse hearthBOT
delicate wren
#

I have the third print for a different thing

delicate wren
#

it just fills in in the order that the thing on the right has them

#

order does matter

#

!e

from __future__ import annotations
from typing import TypeVar, TypeAlias
A = TypeVar("A")
B = TypeVar("B")
C = TypeVar("C")
Test: TypeAlias = tuple[B, C] | A
print(Test[A, B, C])
coarse hearthBOT
delicate wren
#

so type alias there can't have types partially filled in

delicate wren
#

!e

from typing import *
A = TypeVar("A")
type Partial[B] = A | B
print(Partial)
print(Partial[int])
print(Partial[int, str])
coarse hearthBOT
delicate wren
#

!e

from typing import *
A = TypeVar("A")
type Partial[B] = A | B
print(Partial)
print(Partial[int])
print(Partial[int, str, bool])
coarse hearthBOT
delicate wren
#

this doesn't sound right

#

!e

type Partial[T] = int
print(Partial)
print(Partial[int])
print(Partial[int, str, bool])
coarse hearthBOT
delicate wren
#

this is not right at all

#

!e

type Partial[T] = bool
print(isinstance(0, Partial[int]))
coarse hearthBOT
delicate wren
#

!e

type Partial[T] = bool
print(isinstance(0, Partial))
coarse hearthBOT
delicate wren
#

okay so it's just not a type

#

and Python has no clue what type aliases actually resovle to

#

I need an actual language server to test this

#

Pyright/Pylance

hearty heath
#

Hey

#

Just joined

#

ยฏ_(ใƒ„)_/ยฏ

delicate wren
#

@proper ridge type statement defines T

hearty heath
#

type statements are just for type aliases

delicate wren
#

they are quite different

hearty heath
#

You can give an alias type parameters, but any type parameters on the RHS have the be on the LHS

delicate wren
#

for LSPs they might be same, but for the language they're different

#

I broke Pylance I think

#

this type alias makes no sense but Pylance doesn't catch it

#

it just goes "this is not generic"

#

this is perfectly fine:

hearty heath
#

It's a recursive type alias

#

Like imagine you needed to create a type alias for "things that can be converted to JSON" ```py
type JSONable = bool | None | int | float | str | list[JSONable] | dict[str, JSONable]

delicate wren
#

passes strict type checking

hearty heath
#

Oh right

delicate wren
#

type to test

hearty heath
#

But yeah you can add whatever type parameters you want on the left hand side. This was syntax added in 3.12 I think?

delicate wren
#

I think

#

hmm

hearty heath
#

@proper ridge Are you familiar with the new syntax for adding type parameters to functions and classes? E.g. ```py
def foo[T](xs: list[T]) -> T:
return xs[0]

#

Right, I'll find the relevant docs...

low jetty
hearty heath
#

It's a way of constraining the relationship between the different types of the function signature.

delicate wren
#

that includes [[], [[]]]

hearty heath
#

Oh. That's just syntax that was added in python 3.12

delicate wren
#
T = TypeVar("T")

def foo(xs: list[T]) -> T:
    return xs[0]
#

same one

hearty heath
delicate wren
#

[T] on function is just a different way to define TypeVar

hearty heath
#

It's equivalent (roughly) to what AF wrote

delicate wren
#

it should be equivalent type-wise because T is invariant

hearty heath
#

It's a bit of syntactic sugar mostly.

delicate wren
#

more correct:

T = TypeVar("T", infer_variance=True)

def foo(xs: list[T]) -> T:
    return xs[0]
hearty heath
#

With rational etc.

delicate wren
#

!e

def foo[T](xs: list[T]) -> T:
    print(T)

foo([])
coarse hearthBOT
delicate wren
#

!e

def foo[T](xs: list[T]):
    print(T)

foo([])
coarse hearthBOT
delicate wren
#

hmm

#

there is ~T for TypeVars

#

doesn't print the same for new generics

hearty heath
#

Covariant, invariant, and contravariant have a technical meaning when talking about type parameters @proper ridge

#

There's a nice explaination in one of the PEPs

#

Or I could explain it if you like? ๐Ÿ˜„

delicate wren
#

~~```py
def covariant[T](x: T): ...
def contravariantT -> T: ...
def invariant[T](x: T) -> T: ...
def whatT: ...

#

there is a term for the fourth one but I don't remember it

hearty heath
delicate wren
#

this might be wrong

#

I forgot

#

yeah, what I wrote doesn't really make sense

hearty heath
#

Essentially, a generic type G[T] is covariant with respect to its type parameter T if: A being a subtype of B implies thatG[A] is a subtype of G[B].

delicate wren
#

this is closer to reality

def contravariant[T](x: T): ...
def covariant[T]() -> T: ...
def invariant[T](x: T) -> T: ...
def what[T](): ...
#

if those are methods on SomeType[T]

#

(self omitted)

#

Sequence[T] is covariant over T

#

MutableSequence[T] is invariant over T

hearty heath
#

So like, in python, bool is a subtype of int, so the type tuple[bool, ...] is a subtype of tuple[int, ...], because tuple is covariant. I.e. you can pass the former wherever the latter is expected.

delicate wren
#

Callable[[T], None] is contravariant over T

#

Sequence[bool] is Sequence[int]

#

Callable[[int], None] is Callable[[bool], None]

#

yes, contravariance flips subtyping

#

or, merged together:
Callable[[int], bool] is Callable[[bool], int]

#

exclusively owned list is covariant

hearty heath
#

list is not covariant because it's mutable. You can't in general pass a list[A] where a list[B] is expected, even if A is a subtype of B, because you can mutate list[B] in ways that you wouldn't be able to do to list[A] (i.e. you can append a B to a list of B but not to a list of A)

delicate wren
hearty heath
#

Yeah I think that's what you just said/read actually ๐Ÿ˜„

#

Not quite

#

Contravariant means if A is a subtype of B, then G[B] is a subtype of G[A].

#

This I think is only mostly the case when dealing with higher order functions.

delicate wren
#
class Contravariant[T]:
    def push(self, item: T): ...

x: Contravariant[int] = ...
x.push(1)
x.push(True)
y: Contravariant[bool] = x
y.push(True)
hearty heath
#

Like, imagine a function expects be be given another function that operates on Bs As. You could instead pass it a function that operates on As Bs.

delicate wren
hearty heath
#

Let me make an example instead.

delicate wren
#
class Contravariant[T]:
    def push(self, item: T): ...

def test_int(contra: Contravariant[int]):
    x.push(1)

def test_bool(contra: Contravariant[bool]):
    x.push(True)

x: Contravariant[int] = ...
test_int(x)
test_bool(x)
#

you can .push bools because they're ints

#

if it can accept int, it can accept bool

#

therefore all things that accept ints can accept bools

#

whereas something that only accepts bools can't accept ints

#

all bools are ints in Python

hearty heath
#
def silly_function(
    fn: Callable[[bool], Any],
    x: bool,
) -> Any:
    return fn[x]

def negate(x: bool) -> bool:
    return not x

def addone(x: int) -> int:
    return x + 1

silly_function(negate, true)
silly_function(addone, true) 
delicate wren
#

2 can't be interpreted as bool

delicate wren
hearty heath
#

Callable is contravariant w.r.t. the types of the arguments (I think).

delicate wren
#

yes

hearty heath
#

I.e. it's ok to pass a Callable[[int], Any] where a Callable[[bool], Any] is expected.

#

Because whatever you can do with the latter you can do with the former.

#

It's contravariant.

#

Imagine I'm a function

#

The contract I have with the caller of the function is that they will pass a function fn that I can apply to bools

#

If they pass me a function I can apply to ints, I'm fine with that, because bools are ints

#

Nah, because say, as the function, I try to do fn(123).

#

I couldn't do that if fn is Callable[[bool], Any]

#

Because 123 is not a bool

delicate wren
#

does new generic syntax allow specifying variance? (I think I remember seeing it somewhere)

hearty heath
delicate wren
#

it does have bounds and constraint syntax

#

(answer is no)

hearty heath
#

If I'm a function, and I'm being passed a function, all I care about is "what can I do with this function?". I don't mind if the function I was given accepts a broader range of arguments than I intend to give it. @proper ridge

delicate wren
hearty heath
#

If that makes sense ๐Ÿ˜„

delicate wren
hearty heath
#

Because Callable[[int], Any] can be used wherever Callable[[bool], Any] can be used. The former accepts the same set of argument values as the latter (and more!)

rotund bough
#

why is so much programming related to toilet jargon? passing args, streams, flushing, code smell ..

hearty heath
#

So if I asked for a Callable[[bool], Any] and instead I'm given a Callable[[int], Any], I don't mind. I got more than I bargained for.

#

Sorry, I tend to understand better by giving personalities to things ๐Ÿ˜„

hearty heath
#

Oh yeah

#

Erm yeah so contravariant means: A < B implies G[B] < G[A], where < means "is a subtype of".

#

Covariant means: A < B implies G[A] < G[B]

#

And invariant means nothing is guaranteed.

#

The mutability is the weird part. Like when I learned that list is invariant it surprised me, but it makes sense if you think about it and look at a few examples.

rotund bough
hearty heath
#

@worn canopy Can't really hear you

#

Sounds like a bad microphone connection

#

Ah

#

๐Ÿ‘

#

Gotta go ๐Ÿ‘‹ Back in a bit

low jetty
#

is this a decent download sped?

delicate wren
mild flume
#

I'll try to be back on later. Got a whole crap ton of things dropped on me

misty sinew
#

it kinda

#

sucks that I need

#

to wait 3d and send

#

50 msgs to be abe

#

to talk on vc

#

44 msgs to go ig

rotund bough
#

sup

#

ur employer said this mf goin on vacay let's get all of the year's work from him today

#

you'll play only one

#

hell divers

#

workaholic

mild flume
#

@misty sinew Yo

rotund bough
#

use wired conn like a real IT person

#

every IT guy knows wired > wifi

#

your fault for buying featureless laptops

hearty heath
#

Heyy

#

Working late again?

#

Ah right nice

#

Yeah, trying to force yourself to sleep never works ๐Ÿ˜„

#

ยฏ_(ใƒ„)_/ยฏ

#

Ah yes, brick ๐Ÿงฑ

#

Errm, I've spoken like once here I think

#

I'm a bit microphone shy ๐Ÿ˜„

#

plome?

#

Ohh

#

Right yeah

#

Like a self-describing word

#

But I can't remember the word for that

#

Oh I was thinking "autological"

#

Nominative determinism

winged steppe
#

Anyone used streamlit before

sly pond
#

I too love words

#

I don't have one

rotund bough
#

urban dictionary

sly pond
#

I don't put my faith in one source

#

love me some etymology, wherever it may be from

hearty heath
#

Word of the day on Wiktionary is "bisexual lighting" pithink

rotund bough
#

The online etymology dictionary (etymonline) is the internet's go-to source for quick and reliable accounts of the origin and history of English words, phrases, and idioms. It is professional enough to satisfy academic standards, but accessible enough to be used by anyone.

#

pretty sure lighting doesn't have a sexual orientation attr

hearty heath
#

Yeah ๐Ÿ˜„

#

I'm sure this is not a word

#

but ยฏ_(ใƒ„)_/ยฏ

sly pond
#

It's similar to "mexican lighting" from breaking bad

chilly rock
sly pond
#

but for bisexual purposes

#

Showered in golden light

#

In photography, the golden hour is the period of daytime shortly after sunrise or before sunset, during which daylight is redder and softer than when the sun is higher in the sky.
The golden hour is also sometimes called the "magic hour," especially by cinematographers and photographers. During these times, the brightness of the sky matches the ...

hearty heath
#

Very nice

sly pond
#

A beautiful effect, not dreary, IMO

#

Yea, birthdays stop mattering after a while

#

the first few decades are fun

#

I just listen to this song

#

Boo @ the failed embed

#

it was blocked by the uploader for reasons

#

so I removed it

#

play it

hearty heath
sly pond
#

It doesn't

#

so no point in all that space

#

gotta go there to watch

hearty heath
#

Mhm

sly pond
#

Then you installed a Russian keyboard, right?

#

gotta protect against the malware

hearty heath
#

Oh yeah, I think capitalisation differs between languages

sly pond
hearty heath
#

I know in Italian they would say 'inglese' not 'Inglese' for example

sly pond
#

@hoary tide ^^^

hearty heath
#

Many words that are capitalized in English are not capitalized in Italian. These include: the days of the week, the months of the year, proper adjectives, a few proper nouns, and titles such as Mr., Mrs., and Miss.

sly pond
#

Happy Holidays!

chilly rock
#

umm....

#

so I can help with that a little...

#

and yes its pytorch

#

let me go find the website... it hugging something...

hearty heath
#

Terminator 2 is good

#

I haven't seen 1

hoary tide
hearty heath
#

He plays a robot though

hoary tide
hearty heath
#

Nah, James Cameron

hoary tide
#

Yall just forget about the dark knight

chilly rock
#

What is S-mode?

#

There is a lightweight version!?

#

I want that on my phone lol

#

for reading emails.

#

^only for reading emails specifically

hearty heath
#

Nice

#

I generally can't start on work until there's some urgency

misty sinew
#

same

hearty heath
#

It is friday

#

Ah yeah

rotund bough
#

it's friday + 1

mild flume
#

friday++

hearty heath
#

Sounds similar to the post office scandal here

misty sinew
#

sleep tight peep's

hearty heath
rotund bough
#

++friday is faster

hearty heath
#

Lovely singing hemlock ๐Ÿ˜„

#

Apparently he's doing better with undecided voters after the debate ๐Ÿคทโ€โ™‚๏ธ

#

No I mean Biden is doing better sorry

rotund bough
#

let's make a bot to influence the elections ducky_devil

hearty heath
#

Yeah

rotund bough
#

what is polling

#

via sampling?

#

just take a biased sample

#

produce false prediction.. influence outcome

sly pond
#

did someone say rappa?

chilly rock
#

They do... but its unsupported. Youc an request it for testing purpose for windows

sly pond
hearty heath
#

Alright let's not do personal attacks

#

Yeah, let's move on

chilly rock
# hoary tide Ty

I think there are many awesome resources of lists out there... but generally with AI it really depends on what your application. What hugging face is a example list of AI models that easier to search than GitHub. Developed and maintained by AI researchers so they can have heated AI discussions. Lets talk about popular AI to understand why why this is a useful link:
https://huggingface.co/
Rambling explanation about AIs (part 1 of 2):

  1. Pytorch is best because its a broad for complex AI that are based on video and unstructured data. True AI and mostly under this umbrella because pytorch supports non-python AI models.
  2. Google's Tensorflow and Google's Vertix-AI: Tensorflow 2 is generally for text mining and text unstructured data, photo image recognition models, and very unclean structured datasets. The problem with tensorflow is most of the awesome stuff was in tensorflow 1. With tensorflow 2, they added BERT, but stripped out most of the controls for trying to "understand your AI" (Don't get me on Google Rant). Now Vertix-AI is Google quick platform to beat Chat-GPT and is """Tensorflow version 3 devOps IDE"""
  3. Chat-GPT and Microsoft's AI: Let's not kid ourselves--Microsoft owns Chat-GPT. Chat-GPT trained on all of Microsoft's data. Azure ML Studio and Azure's pythonsdk are that """devOps IDE""" of Microsoft AI called Co-pilot.
  4. Facebook's AI: Facebook's prophet has the best for forecasting of any AI model (with only the R-package called modeltime beating it on tests of predicting bitcoin prices). Facebook has an new AI similar to CHAT-GPT called LLaMa2.
#

Rambling explantion about AIs (part 2 of 2): Overwhelmed? Good. Those are just the popular AIs that for all the same problems sets. On ResearchGate... there are over 1000+ organizations with at least 5 AI models all actively doing AI . (THE POINT) .... AI has a huge problem ... Across any industry not only are the packages not standardized anymore both the IDE developing platform is not standard.

Huggingface (like paper's with code) is the solution to that problem. Its a way of sharing the models and standardizing results. So its great as a starting point for AI applications.

hoary tide
hoary tide
chilly rock
#

If its making an AI to talk with there is a better website... than ChatGPT.... the fanfition discords kind of went crazy with ChatGPT.

chilly rock
#

where do youi the Gamer US presidents came from lol... fanfiction. Alot of fanfiction writers.

chilly rock
chilly rock
chilly rock
#

yep now if you look on fanfiction . net for Guido van Rossum you will find there are tons of fanfics where he is like the Bill Gates cameo appearance.

chilly rock
sly pond
chilly rock
hearty heath
#

@mild flume Have a nice weekend dude ๐Ÿ‘‹

sly pond
woven pulsar
#

water is a drug

#

try to live without it

sterile orchid
#

weed

#

awe weed

#

no thank you

#

weed isnt for me

woven pulsar
#

Grenade is a non-food thing that can effect your brain :3

sterile orchid
#

the federation is cool

hoary tide
sterile orchid
#

heat

#

pressure

woven pulsar
sterile orchid
#

area where it takes place

#

ect

#

ect

woven pulsar
#

the default desktop client doesn't allow it

hoary tide
woven pulsar
#

or something

hoary tide
#

xd

woven pulsar
bold mesa
#

more python less debate plz

sterile orchid
#

But what about where did Walter white go

#

Python fun

#

Using R is better

#

Time to make heat map

#

Of a csv data set

sly pond
sterile orchid
#

Sorry thats anaconda

sly pond
sterile orchid
#

Cute dog

#

Whats their name?

#

@sly pond

sly pond
sterile orchid
#

Awe

#

Big feet means they will be giant

sly pond
sterile orchid
#

Are you still fostering

hoary tide
sterile orchid
#

My sister has that camera

#

Great camera

sly pond
sterile orchid
#

Holy thats giant

sly pond
sterile orchid
#

Hobby or profession
?

sly pond
#

hobby

sterile orchid
#

Thats cool

slow terrace
#

millennial
a person born between the early 1980s and the late 1990s; a member of Generation Y.

sterile orchid
#

very few people here

#

making websites and ui ux

#

@sly pond do you android studio

#

or xcode

#

@sly pond when did you start?

#

how big was your portfolio @sly pond

#

before starting

#

very true

#

data science for resumes ๐Ÿค” @sly pond

#

lol

#

i just want 60k ngl

#

awe

woven pulsar
#

blease give

sterile orchid
#

lol i just want apartment

#

and a cat min

#

just something i could say i could die happy

#

id like to build a datacenter in the midle of nowhere be a better person give all my money away

#

die with nothing

#

sounds nice

#

have money but eh

#

fair

#

just a work from home

#

a nice view

#

and coffee is the dream

#

work on data

#

even grunt work id be happy

#

awe so cissp

#

what you do

#

just apartment food and cat

fallen spade
#

hi could anynoe help me with a keysystem im trying to get to work?

sterile orchid
#

key system whats that

fallen spade
#

simply said a system where i generate and store keys

sterile orchid
#

is that scrum?

#

oooooh

#

i know that

fallen spade
#

i just got 2 issues

sterile orchid
#

me toi

sly pond
fallen spade
#

id appreciaye any help :>

#

ah shi i forgot the rest

sterile orchid
#

@sly pond thats the dream

fallen spade
#

the poblem witht the genkey func is that whenever a key is generated the epxiry is already set which is wrong. the expiry should be set when redeemed becaus it would just take the generated date and use that to expire wihtout being redeemed

sterile orchid
#

view and coffee

fallen spade
#

im sorry its kind of a complex system

sterile orchid
#

oh

#

rip

hearty heath
#

So how does the scoring work in olympic breakdancing? ๐Ÿ˜„

fallen spade
#
{
    "test-aEZnWpDsh5CsDATNE9Ya-R0HMfc2kotvDc0Y86KE6": {
        "days": 1,
        "generated_date": "2024-06-29 03:00:33",
        "expiry": "2024-06-30 03:00:33",
        "used": false
    }
}```

the issue here is that i gen a key today and the expiry is already set
sterile orchid
#

oh this is like the steam key thing

#

so do you want an experation time

fallen spade
#

what it really is like i make keys for my customers to redeem to be able to use my bot

#

i store them

#

with necessary info

sterile orchid
#

how for how long?

fallen spade
#

not for a set period of time

#

its for any time

#

for example i run /genkey 1 1 which would give me 1 key for 1 day expiration. the issue now is that "expiry": "2024-06-30 03:00:33", is already set since i today gened a key but that causes an issue since the key should only expire after being redeemed

#

udnerstand ๐Ÿ˜ญ

sterile orchid
#

oh so you want a validation between the account and the key

fallen spade
#

lemme upload my complete file

#

might make things more clear

sterile orchid
#

send me the screen shotty

#

thats actually epic

#

breakdancing in the omlypics

#

that show is funny @sly pond

sly pond
#

Weโ€™re always with you, Mac. Watch this selected scene from the season 13 finale of Sunny.

Subscribe now for more Itโ€™s Always Sunny In Philadelphia clips: http://bit.ly/SubscribeFX

The gang returns, mostly, in the next season of FXXโ€™s comedy series Itโ€™s Always Sunny in Philadelphia. The gang has its hands full as Charlie hopes to have a child...

โ–ถ Play video
fallen spade
#

thats it

sterile orchid
#

i enjoy their gay humor

#

it is

#

its a great way to express yourself

#

LMAO this is my first time seeing this

fallen spade
#

issue is.
i make key with the expiration of 1 day but when i generate it the expiration is set alerady. thats wrong becuase the key should only expire after being redeemed

sly pond
sterile orchid
#

@sly pond you sound a lot like steven west from the podcast philosophize this

#
#

@sly pond

#

okay almost

#

but i think he sounds like steven west

#

then again steven is a bit older

#

i will listen to his podcast now

#

bye everyone have a nice afternoon

#

perhaps night

#

lol

misty sinew
#

Oh shid

#

I came in here to listen to something to snooze

#

Keep talking about programming

#

Stop drinking before you get cirrhosis

#

Boi what

#

Rehab time

#

You sound like you use collab

#

Ok letโ€™s revisit this convo when ur 19

#

Just donโ€™t get shitfaced

#

Youโ€™ll be alright

#

LMao

#

You do the crime you do the time

sly pond
#

1 sec

#

wife just got home

woven pulsar
#

"there are women and children down there, they're all unarmed"
"Gotcha, proceed eliminating them" this is gold๐Ÿ˜ญ

sly pond
#

love it

obtuse mauve
#

I want to make some projects for Web development trough django in python.
So, I will use VS. Code . Again, Someone please give me the idea of installing Django fisrt in the VS.Code terminal , then virtual machine, then MS-SQL (If Needed). And any project name-For Example.

polar oxide
#

hi

ornate knot
# obtuse mauve I want to make some projects for Web development trough django in python. So, I...

Let's see. Firts, get Poetry using pipx.
Create your folder.

poetry init```
Do not install any dependencie.

```py
poetry add Django
poetry run django-admin startproject my_site 

Now you should have something like:
โ”œโ”€โ”€ my_site
โ”‚ย ย  โ”œโ”€โ”€ manage.py
โ”‚ย ย  โ””โ”€โ”€ my_site
โ”‚ย ย  โ”œโ”€โ”€ init.py
โ”‚ย ย  โ”œโ”€โ”€ asgi.py
โ”‚ย ย  โ”œโ”€โ”€ settings.py
โ”‚ย ย  โ”œโ”€โ”€ urls.py
โ”‚ย ย  โ””โ”€โ”€ wsgi.py
โ”œโ”€โ”€ poetry.lock
โ””โ”€โ”€ pyproject.toml

The outer "my_site" folder, you can rename it like you want, in my case its "src", and the inner my_site its the actual name of your project.

wintry sparrow
#

I'm a SixthGen Italian and i dry my ass in the sink

#

My name is Jack Jaconelli, and i drink F Scotch

undone hearth
#

hi hows all

fluid cedar
#

helo

deep niche
#

backend haven ?

celest tide
#

helo

#

what you do in life heiwa

#

nope

#

i can send you my code if you want

ornate knot
#

/// py

celest tide
#

mm nope actually

#

yeah

ornate knot
#

` //

#

py

celest tide
#

/// py like this

ornate knot
#
def try_func():
  return
celest tide
#

yeah ``` from pyresparser import ResumeParser

def extract_skills_with_pyresparser(file_path):
data = ResumeParser(file_path).get_extracted_data()
return data.get('skills', [])

Example usage

file_path = './resume/CV.pdf'
skills = extract_skills_with_pyresparser(file_path)
print(skills)``` py

ornate knot
#
 from pyresparser import ResumeParser

def extract_skills_with_pyresparser(file_path):
    data = ResumeParser(file_path).get_extracted_data()
    return data.get('skills', [])

# Example usage
file_path = './resume/CV.pdf'
skills = extract_skills_with_pyresparser(file_path)
print(skills)
celest tide
#

windows

#

in window

#

windiws

ornate knot
celest tide
#

did you see the error ?

#

i don't even have config.vfg that's the problem

#

cfg

#

i did not understand you im sorry

#

yeah

#

and how could i use them

#

yeah

#

if i return the data you mean ?

#

same error

#

do i have to create a config.cfg or what

#

i don't know what should be in the file actually

ornate knot
celest tide
#

it is still something wrong with config.cfg

#

hwat

#

what

#

yeah

ornate knot
#

spaCy

python -m spacy download en_core_web_sm

nltk

python -m nltk.downloader words
python -m nltk.downloader stopwords

celest tide
#

yeah

#

no worries

#

it's like i used spacy in my other project but i had to specify every pattern for name and email and the skills
i wanted to use pyresparser becuase this liabrary extract them automatically without me specifying what should i extract or specify the patterns

#

okay i donwloaded them and then i try to execute or there is something i should a dd in the code

ornate knot
#
from pyresparser import ResumeParser
data = ResumeParser('/path/to/resume/file').get_extracted_data()
celest tide
#

okay wait

#

mm i gues i have to create a new file called cofig.cfg

#

i had the same error

#

okay

devout ether
#

yo @obtuse valve

obtuse valve
#

yo

low jetty
devout fern
#

I've been ehere less than 3 days

#

so i cant

#

@low jetty

#

oh well

low jetty
#

oooh

devout fern
#

Yep

hearty heath
#

Hello

hearty heath
#

I think it has like a chocolate lining to stop it going soggy? ๐Ÿค”

#

Hey @proper ridge do you still need help with that Docker thing?

#

@proper ridge Could you link to the Github issue?

proper ridge
hearty heath
#

Because it's from an Islamic country?

stuck bluff
#

Rice puddongs are ace.

#

...puddings.

hoary citrus
#

gulab is rose

#

@proper ridge

stuck bluff
#

Rosewater?

hoary citrus
#

yes

stuck bluff
#

Rose essence?

#

Rose rose rose your boat.

proper ridge
#

!pypi qoin

coarse hearthBOT
#

Quantum Random Number Generator.

Released on <t:1713438701:D>.

stuck bluff
#

@viscid shore Sorry for the wrong ping.

#

@proper ridge I'm right here.

#

You said you were looking for the legend.

#

DO IT TO JULIA!

#

@tall hound @craggy jetty @misty sinew @main drift ๐Ÿ‘‹

#

@spice scroll ๐Ÿ‘‹

#

@polar heron ๐Ÿ‘‹

stuck bluff
#

@split epoch ๐Ÿ‘‹

undone hearth
#

hi

#

it is ok

stuck bluff
#

@leaden otter ๐Ÿ‘‹

proper ridge
#

@leaden otter Can you hear me?

leaden otter
#

hi

#

finally

proper ridge
#

!paste

coarse hearthBOT
#
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.

leaden otter
#

it wont run

#

import datetime

def get_next_day(year, month, day):
input_date = datetime.date(year, month, day)
next_day = input_date + datetime.timedelta(days=1)
return next_day

def main():
print("Enter the date:")
year = int(input("Year: "))
month = int(input("Month: "))
day = int(input("Day: "))

try:
    next_day = get_next_day(year, month, day)
    print(f"The next day is: {next_day}")
except ValueError as e:
    print(f"Error: {e}. Please enter a valid date.")

if name == "main":
main()

#

yes it seems correct

#

but when i run this file terminal says there is error

proper ridge
#
import datetime

def get_next_day(year, month, day):
    input_date = datetime.date(year, month, day)
    next_day = input_date + datetime.timedelta(days=1)
    return next_day

def __main__():
    print("Enter the date:")
    year = int(input("Year: "))
    month = int(input("Month: "))
    day = int(input("Day: "))

    try:
        next_day = get_next_day(year, month, day)
        print(f"The next day is: {next_day}")
    except ValueError as e:
        print(f"Error: {e}. Please enter a valid date.")

if __name__ == "__main__":
    __main__()
#

You need to add __ to main.

leaden otter
#

ok it worked

#

but what was the problem in my code

#

AttributeError: module 'datetime' has no attribute 'date'

now i have this error

stuck bluff
#

!d datetime.datetime.date

coarse hearthBOT
#

datetime.date()```
Return [`date`](https://docs.python.org/3/library/datetime.html#datetime.date) object with same year, month and day.
stuck bluff
#

!e py import datetime print(datetime.datetime.date)

coarse hearthBOT
stuck bluff
#

!e py from datetime import datetime print(datetime.date)

leaden otter
#

yes

coarse hearthBOT
leaden otter
#

ok i'll try

#

i think i missed something

#

can you do it again

stuck bluff
#

!e ```py
def main():
print('Hello, world.')

if name == 'main':
main()```

coarse hearthBOT
leaden otter
#

no there is a run python file button

proper ridge
leaden otter
#

ok

proper ridge
#

type python filename.py

#

filename being your file's name

leaden otter
#

[Errno 2] No such file or directory

proper ridge
#

Where is your file?

leaden otter
#

my files name is datetime

#

on desktop

proper ridge
#

Right click on your file and send me the path of it.

leaden otter
#

C:\Users\alium\Desktop\ร–dev\datetime.py

proper ridge
#

In your terminal type python C:\Users\alium\Desktopร–dev\datetime.py

#

!zen

coarse hearthBOT
#
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than right now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!

leaden otter
#

ok i runned it

#

but still i get attribute error

proper ridge
#

Send me the error please.

stuck bluff
#

@vagrant hill ๐Ÿ‘‹

leaden otter
#

Traceback (most recent call last):
File "C:\Users\alium\Desktop\ร–dev\datetime.py", line 21, in <module>
main()
File "C:\Users\alium\Desktop\ร–dev\datetime.py", line 15, in main
next_day = get_next_day(year, month, day)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\alium\Desktop\ร–dev\datetime.py", line 4, in get_next_day
input_date = datetime.date(year, month, day)
^^^^^^^^^^^^^
AttributeError: module 'datetime' has no attribute 'date

stuck bluff
#

!e py import datetime datetime.date

coarse hearthBOT
leaden otter
#

3,12,4

#

3,12

#

i wish i could share screen

proper ridge
#

Type this in your terminal.

py -3 --version
leaden otter
#

Python 3.12.4

proper ridge
#

python

#

Just type python.

stuck bluff
#

@sharp thunder ๐Ÿ‘‹

leaden otter
#

Python 3.12.4 (tags/v3.12.4:8e8a4ba, Jun 6 2024, 19:30:16) [MSC v.1940 64 bit (AMD64)] on win32

proper ridge
#
import daytime as daytime
sharp thunder
leaden otter
#

SyntaxError: invalid syntax

#

to what

proper ridge
leaden otter
#

yes

#

but still invalid syntax

#

i changed the name

#

sakd

#

.py

#

random clciks on keyboard

proper ridge
#
python C:\Users\alium\Desktopร–dev\sakd.py
leaden otter
#

ModuleNotFoundError: No module named 'daytime'

#

it is datetime

proper ridge
#

Change it to datetime.

leaden otter
#

import datetime

def get_next_day(year, month, day):
input_date = datetime.date(year, month, day)
next_day = input_date + datetime.timedelta(days=1)
return next_day

def main():
print("Enter the date:")
year = int(input("Year: "))
month = int(input("Month: "))
day = int(input("Day: "))

try:
    next_day = get_next_day(year, month, day)
    print(f"The next day is: {next_day}")
except ValueError as e:
    print(f"Error: {e}. Please enter a valid date.")

if name == "main":
main()

#

yes

#

yes

#

u are my saviour

#

thanks

#

it worked

#

but can you explain what was the problem to talk like a 5 year old

#

nok

#

nope

#

can you explain to me like im a 5 year old

#

im new to this

#

oh

#

i get it

#

thanks for everything

#

have a good day

proper ridge
#

My pleasure

sharp thunder
proper ridge
#

NO NO NO.

#

You'll get muted for 2 weeks or so.

#

Please don't spam.

delicate wren
#

, as the channel suggests

sharp thunder
obtuse valve
#

today imma code up a caching system for my mcts code

stuck bluff
#

@cinder orbit ๐Ÿ‘‹

#

@round berry ๐Ÿ‘‹

proper ridge
#

rizzle diesel

stuck bluff
#

@misty sinew ๐Ÿ‘‹

proper ridge
#

gobblestone

delicate wren
#

did you make the original class?

proper ridge
#
class Service:
    def __init__(self,
                 api: str,
                 device: str="CPU") -> None:
        if api != "api":
            raise ValueError("API invalid.")
        self.api = api
        self.device = device

    def run(self, circuit: str) -> dict:
        return {"result": circuit}
delicate wren
#

have a shared interface that both original and mock implement

#

you can even formalise it

#

there's more than one method to do mocking for tests

#

are you using the thing that the library provides?

proper ridge
#

Yeah, I'm using unittest.mock.

delicate wren
#

I prefer not having objects be so complex that the only way is to monkeypatch/mock them

ornate knot
#

kay guys, gotta got

misty sinew
#

Byeee

delicate wren
#

one of type-strict ways to do this is:

class Interface(abc.ABC):
    @abc.abstractmethod
    def example(self): ...

class Implementation(Interface):
    def example(self): ...

class MockImplementation(Interface):
    def example(self): ...
#

depends on how complex the behaviour is

#

if I understand correctly, unittest.mock does allow choosing outputs depending on inputs

#

!e

from unittest.mock import Mock
mock = Mock(side_effect=KeyError('unknown input'))
values = {'a': 1, 'b': 2, 'c': 3}
mock.side_effect = values.__getitem__
print(mock('b'))
print(mock('c'))
print(mock('a'))
coarse hearthBOT
delicate wren
#

iirc duckduckgo itself doesn't have a search engine

#

it pulls results from two other ones

#

so it acts like a search engine

#

not anymore