#python-discussion

1 messages · Page 564 of 1

crisp jay
#

the one with the r prefix?

austere crow
thorn anvil
#

Hello

dry yacht
austere crow
thorn anvil
austere crow
dry yacht
steel whale
#

just wrote an aimbot for osu

austere crow
#

thats cool

#

was it hard to write?

dry yacht
#

and against their ToS

craggy trench
#

are you planning to make it into a semi sentient existential crisis causing AI

steel whale
#

no yes idk

opal gull
steel whale
#

no-ish

austere crow
steel whale
#

yes

terse mauve
steel whale
dry yacht
grave tree
#

is osu even multiplayer?

opal gull
#

Osu ruins lives

terse mauve
steel whale
#

thru leaderborads and rooms which use leaderboards

austere crow
terse mauve
austere crow
#

XD

grave tree
grave tree
#

it's like you want to be banned or something

steel whale
austere crow
#

maybe he just wrote it for practice

steel whale
#

oh well, im gonna play some brawlhalla

#

got i hate qwerty

grave tree
# steel whale who would want *that?*

I am being very serious here that your conduct over the past many, many weeks has put you on thin ice. I can only warn you so many times before you just get removed from the server.

grave tree
steel whale
grave tree
steel whale
#

you wanted to do that though
anyway we could throw this under a rug

tame raptor
#

yoo do i do lists or if statements first

cerulean ravine
hybrid nebula
#

I should write reverse pyinstaller

#

packaging an EXE with a Python x86 emulator and windows API interface

steady rain
#

Just use docker

hybrid nebula
steady rain
#

But you're welcome to join me

vale wasp
#

For a second I thought it was run Windows in a Docker container.

viscid hinge
#

click, typer, cyclopts or fire fort a CLI tool?

brisk gazelle
hybrid nebula
viscid hinge
steady rain
hybrid nebula
rotund steppe
#

im so confused on interpreted language vs compiled. Interpreted language is executed line by line whereas compiled is translated into machine code before running right?

steady rain
autumn forge
#

it is hard to categorise languages as being either interpreted or compiled

rotund steppe
autumn forge
#

most languages you think of as being "interpreted" will have a compilation step

#

for example, Python compiles to Python bytecode

steady rain
terse mauve
autumn forge
#

(although, this is an implementation detail of CPython, but that isn't really important)

steady rain
rotund steppe
#

maybe 2, if i were to give it a rating

steady rain
#

I'd say it's not worth wracking your brain over right now

vale wasp
#

Is worth me wracking my brain over?

autumn forge
# rotund steppe maybe this is it

probably. You're right to say that interpreted languages are executed by a separate program -- the interpreter -- whereas compiled languages are compiled to machine code and executed directly by the processor. I take issue with the "line by line" thing, but I suppose it is helpful to understand the uhh... philosophical difference

rotund steppe
#

thanks!

grave tree
#

interpreted vs compiled is more of a spectrum. It depends on the context of the conversation and there also isn't a binary answer.

Some interpreted languages might still have a compilation step in the form of JIT

#

It also depends on the definitions of "compiled" people are working with

#

some people have a very narrow definition, others a broader one

vale wasp
autumn forge
#

it gets complicated, and introductory courses will often provide a simplified view because it isn't worth introducing a load of confusing concepts just for a more technically correct definition

steady rain
rotund steppe
grave tree
vale wasp
grave tree
#

The bytecode compilation is not what I was talking about

viscid hinge
#

SOMEONE please help me pick a cli tool for my CLI note taking app. Click, typer or cyclopts

grave tree
#

I like cyclopts the most out of those options from what I've tried

vale wasp
steady rain
#

I like typer and have never used the others. I have no opinion on the other two

grave tree
#

although I only tried typer for the briefest of minutes

viscid hinge
grave tree
vale wasp
#

I don't know Cyclopts. I've found Typer to be easier to implement than Click whereas Click is more fully featured.

vale wasp
vale wasp
grave tree
steady rain
#

The one time I saw code that used click, there were lots of stacked decorators, and I didn't like that

viscid hinge
vale wasp
granite wyvern
vale wasp
charred tusk
#

Oh is that what DMs are for?

granite wyvern
viscid hinge
#

apparantly "Cyclopts is what you thought Typer was"

grave tree
# granite wyvern Can you guys please bicker in DMs?

I'm just trying to clarify what I'm saying, since from my perspective Dan is responding to something I did not say. But I will drop the subject. I do think it's important to clarify misunderstandings for onlookers though.

autumn forge
#

I'd never heard of cyclopts, but I just read the readme and it looks pretty cool

steady rain
#

We don't need to suppose that they're fighting. Both of them are level headed and they're just trying to reach mutual clarity

grave tree
#

Preocts recommended me cyclopts. Very much prefer it over click

granite wyvern
viscid hinge
autumn forge
#

I might try it out the next time I need a CLI interface. Usually I just hack something together with getopt

vale wasp
granite wyvern
charred tusk
autumn forge
#

ugh, "CLI interface" 🤦

viscid hinge
grave tree
vale wasp
charred tusk
viscid hinge
granite wyvern
vale wasp
viscid hinge
#

yeh yeh there wont be just add, Thanks everyone!

charred tusk
#

It would be very easy to know it

fleet harness
#

Does anyone know the best places to learn python? I’ve been trying codecademy for a few days but was wondering if there were any better ways to learn python.

swift sparrow
#

We have a list of resources here that we recommend. What don't you like about codecademy?

#

!learn

edgy krakenBOT
fleet harness
#

It kind of feels like flashcards that I’m using to study for a test 😅 I was wondering if there were more interactive and hands on ways to learn python

swift sparrow
#

write, test, break, adjust

fleet harness
#

so making my own things based off of what I learn?

swift sparrow
#

yes and even just playing around with the code to make sure you understand it properly

fleet harness
#

ohh ok 👍

#

thanks 🙏

swift sparrow
#

if you look at cs50p from the links above, it's a great course and it does include problem sets that you can work through

fleet harness
#

Alright, thank you

swift sparrow
#

np!

tame raptor
#

why is list max 5

shrewd plinth
#

Codeacademy I have good things to say about, but sometimes the material is out of date or isn’t as in depth as I’d like.

swift sparrow
shrewd plinth
#

For Python I mean. Took their courses and were decent but I think still Python 2 assumed

tame raptor
# swift sparrow it's not?
car_brands = ['chevrolet', 'ford', 'chrysler' , 'dodge' , 'ram']
car_brands.append('buick')
print(car_brands[6])
tame raptor
#

its an error

#

oops

swift sparrow
#

the last index of a list will always be len - 1

#

10 things in the list? last index is 9

#

472 things in a list? last index is 471

tame raptor
#

what you think

car_brands = ['chevrolet', 'ford', 'chrysler' , 'dodge' , 'ram']
car_brands.append('buick')
car_brands.append("cadillac")
print(f"My dad's first car was a {car_brands[6]}.")
#

holy progress

swift sparrow
#

so car_brands[-1]

tame raptor
#

the 4th line is not true my dads first car a Dacia

tame raptor
#

you dont like 7?

swift sparrow
#

but sometimes -1 is really useful when you might not be sure how big the list will be

#

"I want the last element no matter the size of the list"

tame raptor
#

ill keep it in mind so last number = -1

#

and -2 is before last

swift sparrow
#

exactly

tame raptor
#
car_brands = ['chevrolet', 'ford', 'chrysler' , 'dodge' , 'ram']
car_brands.append('buick')
car_brands.append("dacia")
print(f"My dad's first car was a {car_brands[-1].capitalize()}.")
#

see how cool that is

swift sparrow
#

I do

tame raptor
#

i put capitalize hella niche

swift sparrow
#

quite commonly used*

tame raptor
#

i like coding man

ocean whale
#

What about reference the book? It explains very clearly!

tame raptor
#

this is some fun shit

swift sparrow
#

it's a good feeling when you get it right

cerulean ravine
ocean whale
#

for bleath

tame raptor
#

bleach?

ocean whale
#

yeah, you have just discuss the python commands?

swift sparrow
#

What book are you referring to?

ocean whale
#

there are many, for example, "Introduction to python programming",

swift sparrow
#

People come here to ask questions and discuss things though

#

If we all just stuck to our books and didn't talk to each other, this would be a very quiet place

unborn lagoon
#

It's already quiet enough with the rise of "the thing"

swift sparrow
ocean whale
#

ok, i got it

unborn lagoon
tame raptor
#
anime = ['naruto', 'one piece (garbage)', 'dr stone', 'one punch man', 'bleach']
anime.append('jujutsu kaisen')
print(f"{anime[-1].title()} is my favorite anime, but i also like {anime[-2].capitalize()} and {anime[-4].title()} =).")
#

!run

ashen jungle
#

where do you guys place imports from typing? (not in alphabetical order with the order standard lib packages, i assume)

quasi shuttle
#

i ususally go typing imports

std library imports

3rd library imports

current project imports

unborn lagoon
ashen jungle
#

but top or bottom both seem good

shrewd plinth
#

I cause chaos by importing from typing before I use each type ||/s||

ashen jungle
#

does isort still separate std lib, 3rd party, and project imports?

unborn lagoon
#

Yes, that's how PEP 8 does it.

ashen jungle
#

that sounds reasonable too then

tame raptor
swift sparrow
quasi shuttle
#

does isort have any special case for typing imports?

tame raptor
swift sparrow
granite wyvern
unborn lagoon
tame raptor
ashen jungle
swift sparrow
tame raptor
#

Themselves

granite wyvern
# ashen jungle like, alphabetical, or otherwise in the middle of std lib imports?

Just alphabet with the stdlb imports. Eg:

from contextlib import contextmanager
import os
from os import fstat, pread, SEEK_SET, SEEK_CUR, SEEK_END
import mmap
from stat import S_ISREG
import sys
from threading import Lock, Thread
from typing import List

Third party imports separately below, then package internal imports below that if relevant.

swift sparrow
#

!e

anime = ['naruto', 'one piece (garbage)', 'dr stone', 'one punch man', 'bleach']

print(anime[3], anime[4])
edgy krakenBOT
swift sparrow
#

you can just use a comma to print multiple things

#

if you want another list of those 2 anime, we can use slicing

#

!e

anime = ['naruto', 'one piece (garbage)', 'dr stone', 'one punch man', 'bleach']

print(anime[3:5])
edgy krakenBOT
cerulean ravine
cerulean ravine
granite wyvern
rare gazelle
#

i put from typing first

tame raptor
ashen jungle
tame raptor
#

I’m defending Homer’s relative

cerulean ravine
ashen jungle
#

i have been separating them anyway

rare gazelle
ashen jungle
#

because of personal preference

cerulean ravine
ashen jungle
#

if i use an autoformatter that puts it in with the other std lib imports, though, i won't stop it

cerulean ravine
ashen jungle
#

i'm having fun trying new things like ruff and ty (i've never used type annotations before)

ashen jungle
rare gazelle
#

i do it the same way, more or less, but from first, then import

ashen jungle
rare gazelle
#
Imports are always put at the top of the file, just after any module comments and docstrings, and before module globals and constants.
Imports should be grouped in the following order:

Standard library imports.
Related third party imports.
Local application/library specific imports.
You should put a blank line between each group of imports.
quasi shuttle
#

shameless utm_source

ashen jungle
#

wasn't that text written before typing existed though?

granite wyvern
#

Why would typing be spcial?

rare gazelle
#

i looked at django, pandas, flask

#

flask is import then from

#

isort seems to do import then from

#

in the pep8 page i didn't find anything in that regard, just that paragraph

final hollow
#

I put my typing imports in a TYPE_CHECKING block

rare gazelle
ashen jungle
# granite wyvern Why would typing be spcial?

i guess a couple things different between it and other packages are that it doesn't affect how the program functions, and that you might generally import it in every module in a project that has type annotations

trim valley
#

hi

final hollow
#
from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from typing import Literal
trim valley
#

have you guys used pygame

ashen jungle
swift sparrow
ashen jungle
trim valley
#

could you try out my game?

rare gazelle
#

you wouldn't be able to do instance checks or anything like that (with those types)

swift sparrow
final hollow
rare gazelle
#

the default is False

rare gazelle
final hollow
rare gazelle
#

🤔

quasi shuttle
final hollow
#

That's why I defer annotations

rare gazelle
final hollow
#

Right. And I don't use the typing module during runtime typically. If I were to, then I would move it outside of the type checking block. In fact that's what I do in one of my files where the typed are required at runtime

rare gazelle
#

TYPE_CHECKING's value is False at runtime, and True to type checkers

final hollow
#

I know that

rare gazelle
#

uh alright then

#

i wonder if you'd analyze the typehint at runtime what would happen

final hollow
#

I don't do isinstance checks against stuff in the typing module typically. If I needed to, then I would move the typing import outside of the type checking block so I could use them at run time. I also defer annotations. I do this so I can use new typing features in older Python versions without needing to use typing_extensions. This works, and I've tested it against each Python version in ci

rare gazelle
#
from __future__ import annotations

if TYPE_CHECKING:
    from collections.abc import Callable

def a(b: Callable):
    ...
    
from typing import get_type_hints

print(get_type_hints(a))
#

it errors

#

name 'Callable' is not defined

rare gazelle
#

you can get the name in annotations, but not the real type

tame raptor
#
vegetables = ['celery', 'tomato', 'broccoli', 'onion']
del vegetables[1]
print(vegetables)

I forgot tomatoes are "fruits"

rare gazelle
#

i wonder whats the reasoning behind TYPE_CHECKING to begin with

#

SupportsKeysAndGetItem for example

rare gazelle
#

whats the need for this _typeshed

spice hill
#

oh

#

uhh

stray field
#

For importing types that aren't real

spice hill
#

something something Conway's law

stray field
#

Typeshed types don't exist at runtime, hence needing to import with typechecking

rare gazelle
#

i understand that, the question is why

final hollow
#

I really wish they implemented TYPE_CHECKING being in builtins without needing to import

rare gazelle
#

you can make them real types

stray field
#

Py3.15 lazy imports will probably remove the need for it

spice hill
# spice hill something something Conway's law

People maintaining typeshed are a different set from people maintaining Python, and typeshed moves at a somewhat independent pace. So it could just be that people don't want to bother arguing about including these things in Python at runtime

stray field
final hollow
spice hill
#

Yeah, I think it's a bit silly to have imports from typeshed. Just vendor them into your program/stub

tame raptor
#

so .pop( ) is the same as [-1]?

stray field
#

No

spice hill
#

pop removes the item from the list

tame raptor
#

the last item ?

rare gazelle
#

not a very good design in my opinion

rare gazelle
swift sparrow
rare gazelle
#

if TYPE_CHECKING:
    from _typeshed import ...

is a common pattern

#

so get_type_hints can't be 100% reliable

#

since it can error... a situation i didn't think of

#

the whole idea of if TYPE_CHECKING is weak design choice in my opinion

#

perhaps i should try to stop using it at all

#
from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from _typeshed import ...
jagged belfry
rare gazelle
#

the type doesn't exist in runtime, therefore it can't be resolved

jagged belfry
#

Note

If Format.VALUE is used and any forward references in the annotations of obj are not resolvable, a NameError exception is raised. For example, this can happen with names imported under if TYPE_CHECKING. More generally, any kind of exception can be raised if an annotation contains invalid Python code.

#

Yeah, I'm just not going to argue about that whole thing

#

It's not worth it

#

IMO the design is fine.

#

Assuming you can construct proper values from type structures in real time is not as simple as it sounds

rare gazelle
#

if the type exists at runtime you can grab it

jagged belfry
#

Linear execution is fundamentally exclusive with cyclic type definitions. You can't have both

#

Unless you want to run a resolver of some sort (and/or re-execute module imports with TYPE_CHECKING on), there's not much you can do here

rare gazelle
#

not sure what u're saying

#

when TYPE_CHECKING is on, that block doesn't get executed in runtime

jagged belfry
#

The purpose of TYPE_CHECKING is twofold:

  • to break cyclic dependencies introduced by types referencing types defined after them
  • to avoid importing heavyweight typing instances when not required
rare gazelle
#

class SupportsKeysAndGetItem(Protocol[_KT, _VT_co]):
    def keys(self) -> Iterable[_KT]: ...
    def __getitem__(self, key: _KT, /) -> _VT_co: ...
#

whats cyclic about it

jagged belfry
#

...nothing?

#

I said what the purpose was, not what everyone uses it for

rare gazelle
#

then why its in _typeshed

jagged belfry
#

idk ask their devs

#

I'm just saying

edgy krakenBOT
jagged belfry
#

there's trucks and cars. You have to pick one. TYPE_CHECKING allows you to selectively decide "I want a car"

zealous lion
#

maybe we'll see it in 3.16

jagged belfry
#

The rest is down to the implementer

stray field
rare gazelle
#

yet it can be problematic

ashen jungle
#

not to change the topic, but how do you all document module variables?

rare gazelle
jagged belfry
#

Module variables as in globals or module variables as in constants

stray field
worn sage
#

someone hire me bro

rare gazelle
#

we dont hire people in here

#

this server is not for such purposes

ashen jungle
jagged belfry
edgy krakenBOT
#

9. Do not offer or ask for paid work of any kind.

jagged belfry
ashen jungle
stray field
#

Its not standard, but Pyright supports it

worn sage
stray field
#

And mkdocs

jagged belfry
#

Comments are more standard, I believe, if only because I've seen them more

rare gazelle
#

well, i dont do any of this, so i dont know

ashen jungle
ashen jungle
stray field
#

There's also annotaed docs. ```py
x: Annotated[Literal, Doc("")]

shrewd plinth
rare gazelle
ashen jungle
#

now i'm curious if pycharm recognizes any docstrings for module variables actually, i'll check

shrewd plinth
#

Maybe I just need more sleep, but I'm not sure what you mean by module variable in this context

stray field
ashen jungle
rare gazelle
#

from what it seems, only unalivejoy example is supported

ashen jungle
stray field
#

I think Ty supports it too. Not sure about jedi or pylsp or rope

rare gazelle
#

and i didn't know about it, its new to me

pulsar spear
#

Hello

shrewd plinth
# ashen jungle a constant would be a fine example, yeah

I don't think there's a universal suggestion, but I've seen some strategies to just use a regular """ """ afterwards, do a # comment before, or make it part of an enum so docstring shows up but imo that can be a bit misleading

rare gazelle
#

hi there

ashen jungle
#

pycharm does support triple quotes as docstrings for module variables 🎉

shrewd plinth
#

Yay!

#

Just make sure that whatever doctool you're using (if you're using an autodoc tool) is compliant with it

rare gazelle
#

Annotated is also a fine solution

stray field
#

Not enough for the pep to be accepted

ashen jungle
stray field
#

Don't.

ashen jungle
#

oh

stray field
#

Use zensical instead

#

!pip zensical

edgy krakenBOT
#

A modern static site generator built by the creators of Material for MkDocs

Released on <t:1778337329:D>.

rare gazelle
stray field
#

!pep 727

edgy krakenBOT
ashen jungle
stray field
#

Yes

#

And the new mkdocs maintainer has plans for 2.0 to remove plugins

#

(Lovelydinosaur)

rare gazelle
#

uh

ashen jungle
tame raptor
#

is c a good first lang

robust ledge
ashen jungle
#

so there may be a high chance i will try zensical

steady rain
swift sparrow
rare gazelle
tame raptor
fiery yarrow
swift sparrow
shrewd plinth
#

There are benefits to learning C as a first language, but it is pretty rough.

final hollow
ashen jungle
tame raptor
#

i dont have time to learn py after school i open codium and its already 10 pm

stray field
rare gazelle
tame raptor
#

ima need to lock in this weekend

steady rain
ashen jungle
rare gazelle
#

you're not invested in mkdocs yet right haha

rare gazelle
ashen jungle
shrewd plinth
#

The benefit to learning C first is that in academia going for a CS degree often has you learning the fundamentals and building up, and C is a language that does not abstract all those fundamentals away, so it's useful in that regard.

That being said, there is a lag/delay time between you learning to code and actually being able to create something meaningful.

I think, to gain and keep interest, first language should be something else but C is a good language to use when you're actively learning about CS fundamentals.

fiery yarrow
rare gazelle
shrewd plinth
#

But don't tell them that you're using other autotooling, they might get jealous and it leads to drama

ashen jungle
robust ledge
shrewd plinth
#

Sphinx is... fine.

steady rain
robust ledge
shrewd plinth
#

omg did I ping him too >.>

steady rain
#

you didn't. replies only ping the person you're replying to.

robust ledge
#

!learn
Any language will do, @tame raptor . Python has a lot of resources available if you don't already know what you want to do. Other languages don't have as much support there.

edgy krakenBOT
shrewd plinth
#

Is that a new thing?

shrewd plinth
#

Because they certainly used to

fiery yarrow
ashen jungle
steady rain
shrewd plinth
#

I still remember the Lemon fiasco

steady rain
#

yeah, that was fucking hillarious

rare gazelle
robust ledge
#

Objectively hilarious.

shrewd plinth
#

So hilarious. It's still pinned

steady rain
#

maybe I should reenact it but with 420k people instead of 90

chilly whale
#

C's not the worst first language, but it's not great. It does a terrible job of helping you figure out why your program isn't working.

shrewd plinth
#

There are definitely worse languages than C to learn first

chilly whale
#

oh, absolutely. But there are definitely better ones

shrewd plinth
#

ASM, stuff that only works for mobile, etc

#

Yeah, no disagreement here.

rare gazelle
rare gazelle
shrewd plinth
#

Only admins had everyone ping permissions, so a new user tried to ping everyone, but lemon responding telling them to knock it off DID ping everyone

fiery yarrow
tame raptor
#

@robust ledge fyi while i was in class i was like i cant wait to go back home to hop on codium

steady rain
shrewd plinth
#

You can still see the massive spike in people leaving the server

chilly whale
shrewd plinth
#

when looking at historical data

ashen jungle
shrewd plinth
#

Learning C is like.... you already know you like programming and want to stick with it

#

So I guess I'm in the "not first language" camp

rare gazelle
#

🤣 🤣 🤣 🤣

shrewd plinth
#

If you don't know if you'll like mario kart, don't play against the person that tries way too hard to humiliate you for your first game

#

and C will humiliate you

shrewd plinth
#

That said, if you already know C, you can ramp pretty damn quickly to other programming languages. The C -> Python ramp was remarkably smooth

#

although switch/match case still trips me up

tame raptor
#

what is pandas

shrewd plinth
#

The best animal

#

and best data science library

#

and a 3d gaming library that I've never used

robust ledge
final hollow
shrewd plinth
#

pandas live their lives with wild abandon

shrewd plinth
#

sp[hinx for most modules, then for the important stuff I just did it myself

#

directly

rare gazelle
ashen jungle
#

don't forget that pandas are bears. and how you would react if you saw any other non-panda bear.

shrewd plinth
#

How many members left the server the day Lemon pinged everyone?

steady rain
#

I'd have to ask joe

shrewd plinth
#

Pandas are my spirit animal. Or fursona. Whichever is more politically correct

#

Their experience just resonates with me

#

just randomly falling from trees, eating shit as they go down slides, etc

rare gazelle
tame raptor
#

is python docs a good way to learn py

shrewd plinth
#

I would not recommend C# as a first language

steady rain
robust ledge
edgy krakenBOT
shrewd plinth
#

I do think python is a really good first language. Because it shortens the friction between trying out programming and actually being able to see something that you've made

#

But also.... it becomes obvious if you've only used python to program when you're discussing CS fundamentals

chilly whale
shrewd plinth
#

That is true, the error messages tend to be more helpful

chilly whale
#

don't underestimate the value of seeing a traceback automatically when your program has a bug

shrewd plinth
#

Yeah

robust ledge
#

It also has an absolute massive community to support learning. Project idea, tutorial, and the like.

#

"What do I program" is a question that can be tough for those interested but without a clear goal.

fiery yarrow
#

the worst part, i think, about using c or c-like languages is the absolute garbage support for basic data types.
"uh hi, how do i make a string? also i want to know how long it is"
"turn back now, dear newbie. there is no path forward but to suffer. such is the way of the c strings"

tame raptor
robust ledge
tame raptor
shrewd plinth
#

I think I just.... my "problems" with python are similar with my problems with vibe coding, it helps people make things where they have no idea what's happening or how it works. Having to work with people like that can be frustrating when they're also stubborn.

robust ledge
tame raptor
#

idk waht to build

robust ledge
fiery yarrow
shrewd plinth
#

I'm not trying to be gatekeepy. But it is genuinely frustrating working with someone who looks semiqualified on paper but has no idea what they're doing and refuses to learn.

tame raptor
#

so 2 sources of learning

robust ledge
tame raptor
#

!learn

edgy krakenBOT
rare gazelle
charred tusk
#

Yo Preocts, wanna feel like you're back on helpdesk again?

rare gazelle
#

i guess i dont really have an answer for this one, since Python wasn't my first language

robust ledge
robust ledge
shrewd plinth
#

Maybe it's more of a problem how these languages are taught? Idk

rare gazelle
#

programming didn't really sit in my mind until i learnt C, my second language i guess

charred tusk
tame raptor
charred tusk
#

Did someone publish something about that book?

shrewd plinth
#

Honestly, early in my life I sort of just tried like..... every language. Then engineering academia forced Matlab, then cs courses forced C, then a job I got forced python, lol.

slow rivet
#

Personally I think python then rust is a really good order, because as discussed python is a very good intro. And rust introduce you to the concept of lower level memory management, but still with actual good abstractions

charred tusk
shrewd plinth
#

I might pick up rust. But also, C is still incredibly valuable to know

fiery yarrow
rare gazelle
#

the simplicity of C makes it a very good language to learn

#

i wonder what happened to A and B \s

shrewd plinth
#

To clarify, I'm speaking most specifically to the job market

fiery yarrow
#

asm is simpler than c ya know

shrewd plinth
#

There's one position in my industry that is looking for an algo dev who knows both Python and C++ (in the life sciences) and I've gotten literally 20 recruiters reaching out to me about the same position

#

It's ridiculous

robust ledge
dusty ember
rare gazelle
shrewd plinth
#

Yeah, like... how good a programming language is I consider somewhat separate than how hireable it is

dusty ember
# manic osprey simplicity?

it's a really small language with not a lot of features (which is why it's simple). doesn't necessarily mean it's easy, though.

rare gazelle
#

i found C to be very useful for that

rare gazelle
shrewd plinth
#

Maybe one day I'll think of languages outside of the direct context of how much it contributes to finding a job, but today is not that day.

dusty ember
#

apparently unis used to teach their intro to programming courses in lisp

#

it'd be cool to bring that back

fiery yarrow
shrewd plinth
#

I think either b or vb was my first language

rare gazelle
shrewd plinth
#

like decades ago

rare gazelle
#

b stands for basic?

granite wyvern
shrewd plinth
#

Yeah

#

I learned it at a summer camp

#

That summer camp was so fun because they had bought starcraft and you could play starcraft in daycare after the lessons were done

granite wyvern
#

Then at uni Pascal and C and Bourne shell. Then other things....

dusty ember
rare gazelle
#

C isn't an acronym though

final hollow
#

Probably Racket then

shrewd plinth
#

I coded pid controllers in ASM. It was a fun challenge, but I don't think a particularly like.... usable skill

dusty ember
shrewd plinth
#

like it was educational and is a cool flex

tame raptor
#

whats a good vs code theme

shrewd plinth
#

The class that had you doing systems stuff in ASM was a masochist class most people failed, lol

dusty ember
shrewd plinth
#

pid controllers with essentially 0 latency was pretty intense from a physics perspective

dusty ember
fiery yarrow
#

asm might be too low level, but coding PID controllers is hardly unusable

shrewd plinth
#

Oh, agreed

rare gazelle
#

too low level is the definition i guess

rare gazelle
#

also, asm is very different than any other language i know

dusty ember
shrewd plinth
#

My point was that ASM is not the optimal language for it. You can code faster in C and the memory/speed is not meaningful enough to suffer through the pain

rare gazelle
#

no common syntax, no common attitudes

final hollow
#

I don't have the required physics or math to know how to program a PID

shrewd plinth
#

Honestly, it's sort of misleading to describe ASM as a single language at all

dusty ember
shrewd plinth
#

Writing in ASM was slow

rare gazelle
#

asm is never fun, stop lying

fiery yarrow
#

yeah i'm with mtn here. i've done asm. meh

shrewd plinth
fiery yarrow
#

the worst type of typo 😔

shrewd plinth
#

Doing PID in ASM was mostly useful as an exercise in understanding how they worked, how registers worked, etc

final hollow
#

SMB and other NES games were programmed entirely in 6502 ASM

dusty ember
rare gazelle
fiery yarrow
#

heyyo ult: as asm fella, thuri has asm question:
MOV SRC DST or MOV DST SRC?

shrewd plinth
#

Are you trying to bring back the nightmares

fiery yarrow
#

i'm trying to judge you

tame raptor
#

@dusty ember you know ball this theme is nice

dusty ember
shrewd plinth
#

I haven't touched ASM since academia

#

I didn't see much sunlight when I was taking that course. So much time in the lab from early morning to when the sun was already down

rare gazelle
shrewd plinth
#

ASM is lower level than pretty much anyone will ever need in the modern day

dusty ember
rare gazelle
#

yea, i guess

fiery yarrow
#

alas, ult of chaos shows not knowlege but wisdom, and avoids answering the trap question 😔

fiery yarrow
grim hatch
dry yacht
grim hatch
#

It could be an eye-opening experience

shrewd plinth
#

I really hated group coding projects in college because I wound up doing them all myself

#

I mean it was fine ig, I got the grade

viscid hinge
#

what level of type checking do you guys run?

dusty ember
rare gazelle
#

alright, cya guys, thank you for the conversation, was fun

shrewd plinth
#

I worked with ARM in academia, but found that most jobs these days that mention microcontrollers are talking about the intel/x86 architecture

full rune
#

!!!

viscid hinge
#

my project worked fine, but as soon as i turned on type checkin gholy it didnt like what i was doing lol

fiery yarrow
shrewd plinth
#

The answer is that I flipped over the assembler manual and looked up the syntax it needed 😂

dry yacht
# shrewd plinth I really hated group coding projects in college because I wound up doing them al...

That particular one I just mentioned was actually pretty okay. We were a group of 3, one of the guys was a friend from school who started with me, the other guy was a random, but tbh the random was probably the best of our group.

Unfortunately my friend apparently had a pretty shitty implementation. About 1-2 years after the assignment I took the code, and re-wrote his part in pure, relatively naive C, and it was about 50x faster overall :/

charred tusk
spice hill
#

isn't dst := src the way it works in high level programming languages?

shrewd plinth
spice hill
fiery yarrow
shrewd plinth
viscid hinge
# spice hill Did you have type annotations in the project? Were you running with less strict ...

its was OFF before but the project was running fine. Its very small and basic. But i turned it onto basic and had to fix some stuff like add the str and int to body and tags:

    @classmethod
    def dict_to_note(cls, d: dict):
        return cls(
            id=d["id"],
            title=d["title"],
            body= str(d.get("body")),
            tags= list(d.get("tags")),
            priority= str(d.get("priority")),
            creation= str(d.get("creation")),
            done=d.get("done", False),
            pinned=d.get("pinned", False),
            archived=d.get("archived", False),
        )

though tags is still giving me Argument of type "Unknown | None" cannot be assigned to parameter "iterable" of type "Iterable[_T@list]"

spice hill
fiery yarrow
viscid hinge
shrewd plinth
#

I admit that I still have to lookup the order things come in for a lot of module functions that require two arguments. 3 or more is fine, it's when it's just two that I'll sometimes get it mixed up

#

Is it sane to use typing as like.... annotation more than enforcement?

#

I mostly just want docstrings to be clear and obvious

#

and signatures

spice hill
# viscid hinge ohhh, so its just for like, cleaner code? im a bit confused

The three main reasons people use type annotations:

  • prevent certain classes of bugs
  • precisely document interfaces of functions/methods/classes
  • allow for better refactoring and navigation
    For example, in this method you're passing d.get("tags") into list(). d is a dict[Any, Any], so d.get(<str>) is of type Any | None. The value can be None, but list() only expects an iterable, not None, so this is a type checking error. (and it happens to show a real problem that will happen at runtime)
#

The main downsides:

  • you need to learn the type system -- the model of python that type checkers understand. It gets quite complex and the resources for learning it from scratch aren't great
  • you might need to adjust a lot of bug-free code because your type checker doesn't "understand it" (since it has a limited number of supporte dpatterns)
  • you might not like to clutter the code with annotations if you don't like them aesthetically
shrewd plinth
#

Yeah, I'm in category 2. I don't really use type annotations when I'd be using lots of Nones or Anys or whatever that just isn't clear

viscid hinge
#

thanks fix error thatys great info. For now, and this project ill keepo it off. I guess it can be project dependant

spice hill
shrewd plinth
#

But then they have to keep you employed so that you can answer questions about the code, guaranteeing your job security ||/s||

brisk gazelle
grim hatch
#

Cause it's gonna warn you

fiery yarrow
#

not having sufficient and correct type hints can induce a ton of warnings/errors if type checking features are turned on

#

you can always turn them off, of course

quasi shuttle
#

i dont think anybody should be making new python code without type hints

cerulean ravine
#

it's ok to write code without type hints. the real problem is writing type hints but not checking them.

quasi shuttle
cerulean ravine
cerulean ravine
ashen jungle
#

you might want to allow them to be used with normal python numbers, but also numpy arrays, and also other kinds of arrays (tensorflow, etc.), or maybe arbitrary precision numbers, or symbolic objects like in sympy

quasi shuttle
ashen jungle
#

(in my case, protocols might help, but they weren't perfect either)

cerulean ravine
swift sparrow
#

my IDE is going to call me out on type clash issues anyways

quasi shuttle
swift sparrow
#

I'm in the same camp as ned. Of course they will improve the program, but it's not like code without it is unusable/unreadable

ashen jungle
#

in general, i'm still a bit confused on how to reconcile duck typing and type hinting in python

ashen jungle
harsh field
#

i need help with a project a friend made for me but gave me the source code to, i don't know to use it.

cerulean ravine
swift sparrow
quasi shuttle
harsh field
cerulean ravine
swift sparrow
#

Why would your friend give you code that you don't know how to run without instructions?

pallid garden
#

perhaps the instinct stems from other languages you know

swift sparrow
#

What does the code do?

gray siren
#

Hello

quasi shuttle
pallid garden
#

i struggle to write javascript nowadays

dry pike
#

see that's where you went wrong

pallid garden
#

same for python without type hints

dry pike
#

you have to write typescript

#

why struggle to write javascript when you don't have to write it at all!

pallid garden
#

typing has become such an essential part of my programming habit

quasi shuttle
pallid garden
#

just let me use typescript

dry pike
#

just write typescript then delete all the typescript parts after

quasi shuttle
#

i actually started writing jsdocs in js code and hoping my ide would give atleast some typing info when i was calling things

dry pike
#

yeah I have done that before

quasi shuttle
#

typescripts typing system sounds really cool, but i dont think ill ever get to use it

pallid garden
#

using the typing info

#

though i guess that probably speaks as to how messy i am as a programmer

quasi shuttle
#

everyone makes silly mistakes

pallid garden
#

i genuinely think that it would be easier for beginners if you help them set up their lsp properly first

ashen jungle
# cerulean ravine you reconcile them by using type annotations that describe how the thing will be...

say the function is

def add(x, y):
    return x + y

i think i'm confused on where to draw the line between:

  • the most general type hint, which i think is using x: Addable, etc., where Addable is anything that supports addition, and which i believe will flag the same arguments that would cause errors at runtime
  • and something more restrictive, which would indicate what the function author intends x to be (e.g. something number-like but not a string)
harsh field
#

if anyone could help me use this source code thatd be awesome

swift sparrow
pallid garden
harsh field
swift sparrow
#

yeah we're not going to help you with malicious code even if your intents are good

pallid garden
#

i think if you have to preempt with that

#

you already know the answer

swift sparrow
#

!rule 5

edgy krakenBOT
#

5. Do not provide or request help on projects that may violate terms of service, or that may be deemed inappropriate, malicious, or illegal.

harsh field
#

thats not against any tos.

brisk gazelle
#

@harsh field It seems you have been met with a refusal. Sorry, it was right there. 😁

swift sparrow
#

That's not really something someone with zero python experience will be able to do. We're happy to point you to some beginners resources though if you'd like to learn more about python

quasi shuttle
#

well

pallid garden
#

it's nice having a mod in the convo

#

you dont even have to ping

brisk gazelle
harsh field
swift sparrow
#

!ban 1501644635565592676 asking about malicious code and unacceptable messages to another member

edgy krakenBOT
#

:incoming_envelope: :ok_hand: applied ban to @harsh field permanently.

swift sparrow
pallid garden
#

how do i make a nuclear bomb?
we dont help with that
ok can you teach me how to create tritium, that's not against the rules

#

back to python

quasi shuttle
#

writing malware in python is an interesting take

swift sparrow
#

"my friend gave me this code" is usually slang for "I downloaded sketchy code online"

pallid garden
#

writing malware in python is an interesting take

ashen jungle
swift sparrow
#

nothing makes me happier than when I'm working with a new library and it naturally accepts pathlib objects

ashen jungle
pallid garden
#

i mean... internal functions can also be more general, if the function works for children objects, right?

ashen jungle
pallid garden
#

like objects of classes that extends some parent class where the function is meant to operate on the parent class

#

idk if im making sense

#

i havent written python in a few weeks

lilac shore
#

Hii

cerulean ravine
pallid garden
#

but like the author could have this idea as a guideline to help make them decide how to type the function

ashen jungle
#

in my case, i'm thinking of a mathematical function again, like add(a, b). if it's only used internally and always with floats, the type hints for a and b could be float. but if it's part of the public API, you might not want to restrict others to only using it with floats

lilac shore
#

what's going on everyonee

cerulean ravine
ashen jungle
quasi shuttle
ashen jungle
fiery yarrow
swift sparrow
#

"anything that implements __add__" typehint

ashen jungle
pallid garden
#

rust reference!!1!1!!1!1!

fiery yarrow
swift sparrow
#

I think I just won't typehint and save everyone the trouble

chilly whale
#

surprisingly

fiery yarrow
pallid garden
ashen jungle
ashen jungle
fiery yarrow
#

one of the downsides of lambdas, too 😔 can't put in type asserts

pallid garden
#

proper closure when

fiery yarrow
#

try-except expressions when

pallid garden
#

everything-is-an-expression when

chilly whale
#

no one has ever proposed syntax for lambdas that allow more than 1 expression that ever got much community buy-in

quasi shuttle
#

pythons lambda syntax is horrible anyways

ashen jungle
fiery yarrow
#

sometimes i wonder if adding lambdas would be rejected if they weren't already in

ashen jungle
#

i think the current syntax would be rejected, at least

quasi shuttle
#

theres probably a few justifiable cases, but the current syntax makes them sufficiently obnoxious that they arent used much else anyway

pallid garden
#

python 4: removed lambdas

fiery yarrow
#

key= my beloved

pallid garden
#

i personally dont use lambdas

fiery yarrow
#

how does it feel having never called sorted or .sort in your entire life

chilly whale
#

a quick, unscientific grep for lambdas in the stdlib finds just shy of 2500 of them

#
$ git grep 'lambda.*:' **/*.py | wc -l
2436
quasi shuttle
fiery yarrow
#

Results for any search with code search are restricted to 100 results (5 pages)
bruh
why does github add a magnificent feature before severely restricting its use and then crippling it firGun

#

istg if the slop floodbots are ddosing the code search 😡

quasi shuttle
chilly whale
#

I don't really know what you mean by that...

#

they're used whenever you have a function that needs to be referenced at only one place and whose body is a single expression

quasi shuttle
chilly whale
#

Python would use list comprehensions or generator expressions in that case instead, typically

quasi shuttle
#

yea ig im just trying to express my dissatisfaction with how hard it is to express some functional concepts in python

spice hill
#

It's weird how "functional programming" somehow encompasses two pretty unrelated ideas, immutable data and passing functions around as values a lot

quasi shuttle
#

i wasnt a fan of functional programming until i had to parse csv data and turn it into useful results, the interface for just doing things to lists is amazing

sour flicker
#

hey guys

#

how can i learn python?

swift sparrow
#

If you're new to the language, we have some beginner resources here you can check out

#

!learn

edgy krakenBOT
rugged barn
#

In Python, what's the single most trivial way of quickly numerating all directories which $USER has permissions to?

#

Stressing on quickly

#

I'm thinking subproc + find, but is there anything cheaper and just as quick?

#

Well, "quick".

lost lagoon
rugged barn
#

That... sounds like a bad idea, and rather expensive
Which I'm trying to avoid

lost lagoon
#

Or you could ask the OS for the info about the files especially the permissions

#

You can easily get those information

rugged barn
#

...Okay? Directories have permissions and one could find out, but you're still not answering my question

#

I'm crawling through a very large HDD + NFS.
So, I'd like to minimize syscalls + stat calls

#

Naive approach has been running for the past thirty minutes and I don't have the time to wait that out

inland karma
#

good morning!

chilly whale
#

what did you settle on?

rugged barn
# chilly whale what did you settle on?
import os
from concurrent.futures import ThreadPoolExecutor, as_completed

def scan_dir(path):
    subdirs = []
    try:
        with os.scandir(path) as it:
            for entry in it:
                if entry.is_dir(follow_symlinks=False):
                    subdirs.append(entry.path)
    except (PermissionError, OSError):
        return []
    return subdirs

def crawl(root, workers=8):
    results = []
    queue = [root]

    with ThreadPoolExecutor(max_workers=workers) as ex:
        while queue:
            futures = [ex.submit(scan_dir, p) for p in queue]
            queue = []
            for f in as_completed(futures):
                subdirs = f.result()
                results.extend(subdirs)
                queue.extend(subdirs)

    return results
inland karma
#

kinda looks like iterdir with an concurrent executor

#

how does it compare?

quartz fulcrum
#

eivl....the project ,that is given to me, is very overwhelming

rugged barn
#

It's pretty much that, though Google says os.scandir is much cheaper than iterdir

inland karma
#

if you count what? sys calls?

inland karma
rugged barn
#

And regular Python overhead, yes
os.scandir apparently returns you a DirEntry straight from the OS dir stream, and said objects cache metadata from readdir

#

entry.is_dir skips an entire stat call

quartz fulcrum
inland karma
#

what happends if you try out ProcessPoolExecutor or InterpreterPoolExecutor instead?

rugged barn
#

That would be a great question, I don't know

swift sparrow
inland karma
rugged barn
#

I suppose it might be worse?

#

Or the same.

quartz fulcrum
#

maths

inland karma
swift sparrow
#

so make something related to that. Some sort of equation solver or maybe even a visualizer

#

Think of something that you might personally find useful

rugged barn
#

Yeah, it's strictly I/O

quartz fulcrum
#

okay ..i will try

rugged barn
#

I suppose it would win out if I was doing anything other than enumerating them

inland karma
#

when i did the 1brc i tested with multiprocessing pools and threadpools and found expected results during the whole process

rugged barn
#

Say, hashing or parsing

inland karma
#

the 1brc is all about parsing text

grizzled sinew
#

heya everyone

#

are there people here who are in university right now?

rugged barn
#

Several of us

grizzled sinew
#

i am actually out of ideas
i want to make some tool for my uni people cuz its very easy to advertise it
like there are already alotof them like attendence tracker cgpa tracker
i was working on a ranking based website of leetcode but someone else did it before me
now i am looking for ideas
does ur uni have some amazing tool? plz do tell

terse mauve
grizzled sinew
terse mauve
terse mauve
grizzled sinew
grizzled sinew
#

i see

ashen jungle
#

tracks how much time or how often you spend asking chatgpt or ai

grizzled sinew
ashen jungle
#

was it the final?

grizzled sinew
#

yup

#

finally my sem is over

ashen jungle
#

🎉

#

good luck tho

molten heron
#

Hey guys!!
Can you tell me what to do first DSA or OOP

ashen jungle
#

welcome

ocean ridge
ashen jungle
#

as far as i know they're both great to know

velvet trout
#

Yo chat

ocean ridge
grizzled sinew
velvet trout
molten heron
# ocean ridge Whats ur aim?

Right now I'm in a transition phase between college and exams so I'm self learning python. I have a firm grasp on the basics ... But I'm not able to decide between OOP and DSA .

Aim: I want to become an AI/ML engineer

molten heron
ocean ridge
velvet trout
grizzled sinew
molten heron
velvet trout
molten heron
#

Thank you guys!!

velvet trout
#

You're welcome 1.616255e-35

ashen jungle
velvet trout
#

meters is implicited for readability xD

molten heron
#

Where you from??

velvet trout
#

i am from Terra

peak relic
#

Anyone from Gaia?

molten heron
#

Neh

raw bramble
#

why is …e29 and things used rather than scientific notation with … * 10^whatever

spice hill
raw bramble
#

also m/s rather than ms^-1

sacred charm
#

hey guys

raw bramble
#

ms^-1 just looks better, and ms^-2 is better than m/s/s

sacred charm
spice hill
fiery yarrow
#

ms⁻¹ is not better, and nobody would actually do m/s/s. instead m/s² or, if one must avoid exponents in any form, something like (m/s)/s

spice hill
#

ms⁻¹ is better if you need to fit the text in one line

#

uhh no ignore me

fiery yarrow
#

m/s oh hey look a single line

spice hill
#

yeah, I was thinking that m/s in text refers to the vertical m/s

fiery yarrow
#

of course, if you really want to be chaotic, eschew metres per second for metre-hertz

raw bramble
#

I feel it is justified to be annoyed by kph meaning kilometres per hour

#

I can understand it on road signs, but why not km/h elsewhere

#

Or kmh

spice hill
raw bramble
iron remnant
#

How many lines do professional swe’s write/modify in a work day?

fiery yarrow
#

m^3 / (kg s^2) what horrors

spice hill
#

For some reason our road signs never mention the unit of speed. Only for distance, weight, and frequency

#

if the sign is for a speed limit of 60 km/h, it just says 60

fiery yarrow
#

are they many (any?) countries for the which the speed may be in more than a single unit

velvet trout
#

ducky_concerned y'all should standardize

spice hill
#

so that you don't forget which unit is used

fiery yarrow
#

near the border, twould be wise to have units, sure

swift sparrow
#

I think there might be a sign right after crossing the border that says something like "Alert, the road signs are now in mp/h"

spice hill
#

probably

#

apparently different parts of Canada have slightly different signs, according to Wikipedia

#

um

narrow garden
#

hello

raw bramble
#

(And beer)

jagged belfry
granite wyvern
#

Out here speed limits in km/hr are encircled with a big red circle. (They're all km/hr here anyway now, but the convention dates from the cutover.)

#

Unfortunate embed. There's another pic on the page itself a little lower down.

fiery yarrow
#

rip to eso i guess

news organisations such as Reuters and The Economist require "kph"

blissful sequoia
#

hello

pallid garden
#

unstoppable car

hot glen
#

i stopped python for like 2 months

#

i think i forgot everything

swift sparrow
#

welcome back 🙂

hot glen
#

my pc broke

hot glen
#

was a problem with the motherboard

#

got it replaced

orchid lily
#

😮

hot glen
#

is 64 gb ram nvidia quadron k2200 and intel (r) xeon (r) e5 1650 v4 good

#

thats my new setup

swift sparrow
#

You don't really need powerful specs for python

inland karma
hot glen
#

decent

#

then whats good

hot glen
spice hill
#

Where did you get that CPU?

inland karma
#

old cpus are still not slow, but they tend to use more power than somthing produced now

spice hill
#

actually, it's only 3 years older than my CPU. i forgot how time works

#

64GB of RAM is good though

inland karma
#

im getting a new desktop later this year

slender urchin
#

This year has been kind of lack luster in terms of hardware releases

inland karma
#

except for the annoncement yesterday you mean?

#

AMD Ryzen PRO 9000 Series

slender urchin
#

We'll see
The ones that recently released are a couple % faster at like double the price

inland karma
#

ill have to wait and see and compare it with the threadripper pro

orchid lily
#

how did this chanel specifically made for PYTHON TALKS turn into the channel where we talk about CPUs 💀

inland karma
#

so for some python workloads, having a good cpu makes sense if you have to use python

near knot
#

pip install poop

granite wyvern
inland karma
#

so more in regular driving speed

#

some good old german engineering 😄

#

im personally dont like that we measure distance/time for cars

#

i find the inverse beeing much better

oak oyster
#

The ram is a huge overkill and prob only new ish part in the pc

jagged belfry
#

64 gigs of ram is 64 gigs of ram

slender urchin
#

What is your goal with that pc?

jagged belfry
#

If your webserver is python you can do a lot with that

inland karma
#

yeah, ram is never overkill, it depends what you use it for

jagged belfry
#

Hm.

#

How much ram does my webserver currently use...

#

about 40 meg per instance, of which there's 6, for my api

inland karma
#

only 40

jagged belfry
#

and 9.6mb for my rust engine I serve my blog from

inland karma
#

uvicorn?

jagged belfry
#

yes

inland karma
#

its such a great written piece of software