#python-discussion
1 messages ยท Page 554 of 1
meh that should be enough to finish up the classes
and im good enough to finish the rest i suppose
im installing pycharm, what checkboxes should i put on?
the ones that you want
honestly, regarding the bool conversation:
what you think about:
if bool(x):
...
to be valid, but:
if x:
...
to be invalid
but what are reccomended
idk what they do
I'd imagine the default ones are recommended
which ones are you unsure of?
timeit also accepts a string that it execs
are those the same?
the "crete ascociations"
i cant even use jetbrains stuff due to my trash hardware
These are the same, as long as you didn't redefine bool
def sort_the_inner_content(words):
word=words.split()
newlist=[]
for i in word:
j=i.split()
x=sorted(j,reverse=True)
newlist.append(x)
return " ".join(word)
sort_the_inner_content("sort the inner content in descending order")
what does the full thing say?
yea but i dont like using a string... oh i see what you mean, to pass globals only when using a string
exactly
.py, .ipynb, .yaml, .yml, .md, .txt, .json
i see
Ok, so that updates your OS so if you double click a .py file (or any other of those extensions), it will open it in pycharm
ok ty i will check .py
j = i.split() just gives you back a list containing a single element (i)
since i is already a result of .splitting on words, further .splitting on it can only result in a one-element list
and because of that sorting j does not really do anything
finally, what you're returning is " ".join(word), and the word list was never modified, so you get back the input again
var = bool(input("True or False?"))
that may not do what you think
, /
__/ CHAIR!!!
| |
That will evaluate to True or False depending on the length of what has been entered, assuming the builtin names haven't been futzed with.
Well, the righthand will evaluate to that.
The line as a whole is an assignment statement and doesn't evaluate to anything because it's not applicable.
how is issuperset implemented? i assume it doesn't care if the lengths are the same
hi everyone,
good morning!
i am back to learning
say the length is greater or equal, is it just:
all(map(a.__contains__, b))
?
If you input True Then the variable var will hold a boolean value of True
Objects/setobject.c line 2405
set_issuperset_impl(PySetObject *so, PyObject *other)```
C ๐คฎ
alright let me C....
The same is true of entering in False.
Yep
bool("False") == True
Though variables don't hold the objects to which they refer.
They do
how?
They're named signposts. Not containers of those objects. They're proxies.
nonempty strings are always truthy
print("Welcome to python")
i see... so its basically what i said
if the other is set though, it does issubset (i wonder why?)
because it's enough to implement only one of {sub,super}set, and define the other using that implementation
when both are sets
i see
would be nice if not NotImplemented would return NotImplemented
Wouldn't that be Implemented?
its a special case that makes sense though
I mean, I know the Python correct evaluation, I'm just making a joke of it, but...
Hey @lime sage!
```py
print('Hello, world!')
```
This will result in the following:
print('Hello, world!')```
'''
the correct Python evaluation being -- nothing, it's an error to use NotImplemented in a boolean context (since 3.15)
` not '
how do i do a code blcok
backticks, not single quotes. they're usually the key above Tab.
the ```
~
`
key
def __init__(self, number, suit):
if number > 10:
number = 10
self.number = number
self.suit = suit
mycard = card(10, "daimonds")
print(mycard.number)
print(mycard.suit)``` im new to python is this good
it's making it more explicit... i guess its fine... didn't know they changed the behavior
```py
...
...
...
```
yep, a good use of classes.
PEP 8 is the official style guide for Python. It includes comprehensive guidelines for code formatting, variable naming, and making your code easy to read. Professional Python developers are usually required to follow the guidelines, and will often use code-linters like flake8 to verify that the code they're writing complies with the style guide.
More information:
- PEP 8 document
- Our PEP 8 song! :notes:
I would do:
self.number = min(number, 10)
it's ai-enhanced diamonds
ow ow ow caffeine migraine ๐
@honest cradle not a bot, just a regular here who appreciates seeing someone who's making the effort.
what are "specials"?
i heard claude is better for coding help
oh same! I almost posted about it in off-topic
drinking a 473ml redbull at 8pm was not a good idea
It's decent, though it can fluctuate. They're under no obligation to maintain any specific model for the user. I have found that a github subscription offers pretty reasonable access to a selection of models as well as github
My synapsis were just feeling a bit frayed so I decided to have a day off. Hopefully it's not to persistant
honestly I have no idea what you mean
Where can i learn filesystem UI/UX design? I want to add some style and better experience using it. Maybe there is nothing to think about and somewhat copy windows design
we were talking about caffeine migraine? For me it's normally a withdrawal symptom
filesystem UI/UX?
wdym? like if you were building your own OS, how would you organize the filesystem hierarchy?
no I mean the words you said
like a file explorer?
I do got a video sample that i could show but if im allowed to upload it somewhere here or i can post on yt and share a link if im allowed
you can share links yeah
spun out I guess? third eye blind wrote a whole song about it
gime me a sec, im not sure about how its called its sort of file explorer and sort of file system
i don't want to stay behind in tech things...
Can someone explain how codex works...or give a n example
is dijkstra really most efficient
no, see A*
well, also depends on your goal
to find the shortest distance between 2 nodes
ty
A* is better if you just care about the path between two specific nodes
Dijkstra will give you the shortest path between one specific node and all other nodes
Here it is
It does work similar to file explorer but it has more functionality that fits for my app desires
it's a bit confusing where one is at any point
like am I looking at boxes or categories (and what's the difference) or questions
file explorers have a location bar to tell you where you are at all times
usually
Instructions unclear, accidentally used supermassive black hole search.
the good ones do, at least
Well as it, its not FileExplorer app its Leitner System app, im allowing to create directories to sort things out and i create directory with suffix .box to know if you can run it
funny thing, I first started the sentence with "most", then deleted it because I felt like it was too much hedging.
Its just a prototype at this stage but i want to explore my options forwards
anyway @bronze dragon is right, you should include a location bar
Noted
one interesting thing
if not iterable: is useful also when handling iterators
if iterable: means that maybe the iterable is empty, maybe not
but if not iterable: means that the iterable is empty for sure
if not iterable:
...
else:
...
could be a reasonable pattern
I also for quick prorotyping use menu bar to do the work but i feel like it can get annoying to move mouse there so maybe adding some shortcuts or like right click dropbox windows have might be good
I feel I'm missing some context here.
i wasn't aware that iterable was an attribute of anything by design
we talked about bool coercion before
oh right
I like bool coercion
is this a desire featured of iterables you're descriing?
iterator is always truthy, filled iterables are always truthy as well, so you can't know by if iterable if it's full or empty
but if not iterable is only right for empty iterables, so you can know by that the iterable is empty for sure
Right. The truthy thing is for containers like lists and sets.
and thus this pattern could be useful also for iterators
The tricky bit is that on mahy iterables you can't know if it's empty without calling next(). Because the iterable may be a generator whose yielding is ependent on stuff.
So it's not something which can be implemeneted in general.
the thing is it doesn't matter
So is there a good way to learn UI/UX without just searching what works and copying? Copying ofc with the understanding whys and whats
you can still gain the knowledge of when it's empty for sure
I'm not really part of this conversation but num iterables is when someone usually brings up len()
thats the thing, you dont need to check len
Not without trying to consume something from it.
of -> when it's empty for sure
if not iterable would only enter if it's empty for sure
the else would mean, maybe its empty, maybe not
huh ? wdym ?
how would u "copy" UI/UX
its the equivallent to the pattern:
if isinstance(iteralbe, Collection) and not iterable:
...
else:
...
equal to
if not iterable:
...
else:
...
That'd be nice. But it's a magic test which can cannot work without causing the iterable's cogs to turn.
other than just looking at what is there and making it on ur own app
What kind of question is that? By copying...
Anyone using napari ?
UI / UX is a general term , you said " i wotn copy without understanding " , what is there to understand is my question 
like , "this website has a navbar , they make it collapse when the screen resizes" , like thats just a fact , u just make the same thing in ur app or u dont ๐คท
Hii cuties
you basically dont need the isinstance check... in other words
Well why the specific element is in this place and not this? Why did they place it there? Why does this element important?
shit i repeated xD
Why do you ask?
the elementaryOS HIG is a good and practical read about some fundamentals of UX design (even if one doesn't always agree with their conclusions): https://docs.elementary.io/hig
you also have books and blogs. I have read, for example, Bruce Tognazzini's blogs on design a lot. this post is good to start with: https://asktog.com/atc/principles-of-interaction-design/. Bruce was one of the first UI designers at Apple way back in the day. I like this a bit more than the eOS HIG.
Welcome to the python server, you'll probably get a more agreeable response if you choose intellectual attributes to compliment though.
Thank you
I want to know how to start contributing in it, what do i have to learn or understand
Im Rust Developer
Reading the contributing guide would be a good first step. https://napari.org/stable/developers/index.html
What brings you to this neck of the woods?
Ai ml
we have 2 channels where they're discussed extensively https://discord.com/channels/267624335836053506/366673247892275221https://discord.com/channels/267624335836053506/1492906383748632746
I'm pretty sure you can do ML in Rust. https://www.smartcorelib.org/
What interested you to do it in Python?
this channel is appropriate for any general topics though
I can't imagine rust has a library that's as mature as pytorch, it really is a very nice library
I guess if they wanted to, they could mix Python into their Rust with PyO3.
And that should give them the added advantage of using pytorch... I think
Wow never heard of this before
Can I use my Education PyCharm for Personal Non-Commercial Projects or is it limited to just educational work?
pycharm has a free teir, I doubt anyones going to care what you do with python that's non-commercial
Probably? I canโt imagine even if they had a rule how they would enforce it
i'm sure jetbrains has some nice features in their pro model but a hobbyist is not part of their target paying demographic, definately respect any comercial contracts though
I was just wondering as I have a student lisence and it has all the pro apps
which is just sat there
JetBrains IDE licenses for students are strictly for non-commercial educational purposes
Heyayyaya wsup my gayss andd straightttttt kidsss
so if I were to upload the code I made personally like a personal project to github I plan to make no money from it, I would be breaking the terms
not appropriate
Why not vscode
Mah bad ๐๐
I don't like VSCode
also a code editor is a personal preference
If I had pycharm pro access I'd probably want to at least try it but tbh I could see it being an issue down the line when I had to switch or pay
a code editor is a personal preference
Maybe? That is from the "can I use it for work" faq, but the language does suggest it.
But also you can argue any personal non commerical project is educational as you're practicing python
Either way I highly doubt they will care
Im giving you alternatives to PyCharm if you're worried about pricing or licensing
would it be worth reaching out to someone at JetBrains to further query?
doesn't cursor consume tokens?
I am not worried about either, I am happy with the free tier. I am just wondering as I have a student lisence for it laying about
Im sure you can write code without needing to use AI
thought that was cursors whole gimmick though
They do
I have used the free tier for months
then thats just vscode
does random.choices with weights work with decimal weights? E.g. random.choices([1,2],[0.5,1]) makes 2 twice as likely as 1?
!d random.choices
random.choices(population, weights=None, *, cum_weights=None, k=1)```
Return a *k* sized list of elements chosen from the *population* with replacement. If the *population* is empty, raises [`IndexError`](https://docs.python.org/3/library/exceptions.html#IndexError).
If a *weights* sequence is specified, selections are made according to the relative weights. Alternatively, if a *cum\_weights* sequence is given, the selections are made according to the cumulative weights (perhaps computed using [`itertools.accumulate()`](https://docs.python.org/3/library/itertools.html#itertools.accumulate)). For example, the relative weights `[10, 5, 30, 5]` are equivalent to the cumulative weights `[10, 15, 45, 50]`. Internally, the relative weights are converted to cumulative weights before making selections, so supplying the cumulative weights saves work.
No need to contact jetbrains lol
If you care about it sure, you can always ask their support.
The weights or cum_weights can use any numeric type that interoperates with the float values returned by random()
yes
(that includes integers, floats, and fractions but excludes decimals)
not decimals?
doesn't answer my question...
also
Weights are assumed to be non-negative and finite
Then why are we allowed negative weights?
You should use the license if you have no reason to save it for later
Personal, non-commercial projects that are not for profit and are purely for learning or experimentation are allowed. Yeah I am guessing I can
this just came from the AI bot
๐
but u are not using decimal , u are using float
oh yeah right
and I can upload the code to github as long as I use the built in tool
you can upload to github with any tool that has git. not limited to pycharm
I really donโt think they would care, and I think the ai is also hallucinating on this one
i dont think jetbrain will care at all unless ur project starts to make some money or gets popular or something
It probably is
No
what can this mean ? Step 8
Now, you want to create a string that displays the employee's age.
Start by creating a variable employee_info and assign it the result of concatenating:
the full_name variable.
(a string consisting of the characters is preceded and followed by a space.)
first_name = 'John'
last_name = 'Doe'
full_name = first_name + ' ' + last_name
address = '123 Main Street'
address += ', Apartment 4B'
employee_age = 28
free educational licenses are to be used strictly for non-commercial educational purposes.
So, so long as you aren't making money with it or doing it for work (and you are a student), you may use the student version
Once you become not-a-student you can use their community version for similar non-commerical purposes, but it doesn't come with the Pro features.
like how you concatenated the first name and last name for the full name, do the same for the employee info but to concat the age too
The license is exclusively there so that companies have to pay and open source does not
also they say u should have a space before and after ur string
what is the is doing here
full name is age
"John Doe is 28" is what I assume the expected output
What are you working with here? Overall goal of the code?
ah ok
Is this from freecodecamp?
freecodecamp employee info generatot
Yea I figured
yeah just want a certificate
Employee info generator?
yeah
You wanted to generate fake data?
um not really ?
Its part of the lesson on how to handle string data.. Basic stuff
Ohh got it
If I planned to make money, I would just use something like Zed or VSCode
Then I would assume you're fine
employee_info = full_name + 'is' + employee_age
this should not work right
as the employee_age is a int
needs spaces around is
The full license is here https://www.jetbrains.com/legal/docs/toolbox/license_educational/
yeah i think they didn't mentioned to add the employee_age yet
IANAL but to me only this line is important:
which step are you on atm?
(B) You may not:
(vi) use the Product for any commercial purposes.
The rest of it is boilerplate ( you may not share with others, you may not disassemble, you may not re-sell, etc )
its the step 8
Have you learned formatted strings? It'll prevent type errors like that
Or you can just str(employee_age)
employee_info = full_name + ' is ' + str(employee_age)
print(employee_info)
this dont seem to work
Yep like that
oh ok. Dont add employee_age yet. Just full name and then the is with spaces around it
ah ok
Type error? Or?
system dont accept it
The platform?
Just follow the instructions. It says to assign full name and the " is " and thats it
freecodecamp
Damn
๐
tysm
Just make sure to follow the instructions and you'll be fine
ah ok i was thinking beyond โ
they should have introduced the f strings for that ..
slowly... but surely...
Concatenating many strings using + and converting numbers using str() can get messy and hard to read.
Python 3.6 introduced f-strings to solve this. By adding the letter f before the opening quote, you can put variables and expressions inside replacement fields represented by curly braces {}. For example:
they just did it now lol
at step 13
Lol
Yes, thats why I asked haha
Also at scale, for things like making full name, or full address components, pandas is pretty good and will scale beyond formatted strings once you get to that point
i hope so , i am just doing ts to get the certificate
But what will you do with this certificate.
Ya for the certificate alone idk
idk but my mom wants that
come on
Certificates have arbitrary value to others, but if its for yourself and getting a feeling of accomplishment, then its good
Yeah I guess.
yeah it will look like aprove to smthin idk
Maybe to HR ppl, they care
Very few certificates they care about tbh
certificates for basic courses are an anti-signal if anything
Lol true.
freecodecamp certificate is not good ?
For a job? No.
"Introduction to Python" esque-certificates would probably render an anti-signal.
i cannot imagine going for an interview with that also lol
yeah its not a sin ..
It doesn't hurt your application if you have something stronger to off-put it.
Like everyone and their mother probably has that same certificate, you need something to differentiate yourself from the next person.
OooO
what can that possibly be ?
I'm still figuring this out myself twin. ๐
It wont get you to the interview in the first place tbh in this job market. Entry level positions are dwindling, hiring is stagnant, too much uncertainty cause of AI
good projects, genuine contributions, prior actual experience (internships and such also count)
Agreed.
have you ever done internships?
Find a job role you want, match what the job role generally asks.
I have made some contributions in github and made some projects ..
yeah
Also if youre trying to go the data route - kaggle datasets will do nothing.
Certificates are like a coughing baby compared to the hydrogen bomb that is real-world experience.
oh so you guys get placements often?
Everyone and their moms and their moms mom have done kaggle projects
Lol.
I didn't get them through the placement system, I got it outside. I have friends who did that though
Certs can be good to get a start for learning, but it is not 'Get a Cert, get a job!'
Oh alright. You are free to do freelancing there? or are there any regulations? I know some friends of mine who do freelancing while in college
Get a degree, get several certs, do several projects =/= get a job, but its a step forward
no regulations against it.
alright. you are in iiit hyderabad right?
do other colleges generally prohibit it? how do they enforce it? 
no. the University of Hyderabad.
Oh alright. How did you get into it? JEE?
yep
Define employee_code as 'DEV-2026-JD-001'. After that, create a variable department and assign it the slice of employee_code from index 0 to 3. Then print department to the terminal.
whats the requirement
employee_code = 'DEV-2026-JD-001'
department = employee_card[0:3]
print(department)
ii am doing it right yeah ?
but why it dont accept
no luck
Eh.
look at your variable names, employee_code, or employee_card?
which step?
employee_code and employee card
16
you accidentally wrote card
ah jesus
employee_code = 'DEV-2026-JD-001'
department = employee_code[0:3]
print(department)
this should work ^
ha we all make typos ๐ญ
yeah it did
you need to pass 12th I guess? if you mean what the percentile cutoff is generally, I wouldn't know... you can see statistics about that online. the national admissions system (JoSAA) publishes what was the last rank that got into any particular university.
yeah good luck finding the terminators ๐
Oh kk
Are there multiple IITs
Are they all as good
no, of course. the older ones have more established infrastructure, deeper alumni networks, more funding, better professors, etc.
Ah I see
When people talk about making IIT is the goal a specific one?
@sacred charm wait how old are you? You said your mom wanted you to do it?
ah he is into online freelancing things ...
i am 15
varies. they generally mean "any one of the old IITs", but they may be fine with the newer ones. or they may be aiming for a specific one due to personal factors like how close it is to them, whether they like the city, maybe particular areas that a single one specializes in, etc.
its not like that i have learned multiple libraries like tkinter and pyqt5 i think i will learn them too one day
Numpy/pandas are data libraries
You'd need to understand a lot of statistics, linear algebra to some extent, ideally have an idea of databases and SQL
ultra nerdy stuff ..
You only need the python to learn GUI frameworks really
Its where Python has its most competitive advantage compared to other programming languages
Python is strong for scripting and data
but the C and C++ talk directly to the hardware and are considerd fast ?
The majority of the libraries in Python like NumPy and Pandas run under heavily optimized C/C++/Fortran code
Python just calls them in a way less boilerplate, safer, and user friendly way compared to those languages
thats why it is easy to learn , while being fast ..
And thats why people dont use C/C++/Fortran instead of Python for things in the data ecosystem
Fortran?
Except for very niche circumstances, custom approaches, high volume and high performance needs, or research grade things
NumPy uses BLAS/LAPACK for the linear algebra functionalities which is from Fortran
i cannot get to understand this :
Interesting
pow(): raises a number to the power of another or performs modular exponentiation.
Youโre right
i have a unfinished github i found thats a good idea if anybody wanna help finish it using ai or smth
oh whats it ?
Numpy also provides a nice way to call fortran subroutines from Python code which can be handy
calculates crypto tax, there is not a single free site that does this so its kinda crazy imo
and its python code too
I guess what you don't get is the "modular exponentiation" bit?
ah crypto stuff ...
yeah i dont understand the pow() function fully
wym
pow(base, exp, mod=None)
Equivalent to base**exp with 2 arguments or base**exp % mod with 3 arguments
Some types, such as ints, are able to use a more efficient algorithm when
invoked using the three argument form.
see the base**exp % mod bit.
i dont know much about crypto
that's what "modular exponentiation" means.
how do i found somebody that does any channel here to find help?
Like the tax you'd owe the gov't for various crypto transactions or something else?
create a channel in #1035199133436354600
Cryptocurrency or cryptographic?
yes basically all countries have crypto tax (governments) and somehow there is not a single free site not kidding
most countries have crypto tax*
so if i give pow(2,2) it will be 2**2 ?
currency
Well taxes can get very complex, so that makes sense. Have you filed your own taxes before?
ah well let me try then
crypto no cuz its expensive buying these sites and i found a github that needs a little polishing
i have deadline tho
i gotta file my taxes latest june smth
ah thanks its just a way to do exponential calculations or it have any other options ?
the mod option is there.
and thing is the group that made the github was like 5 years ago but they are crazy coders
it lets you calculate base**exp % mod more efficiently than just doing the exponentiation then the mod
we could have been done it using 2**2 but why we did the using pow ?
they work for crazy startups
whats the speciality
At least from the US perspective, the tax code is a nightmare and it's not straightforward to calculate the tax you'd owe on crypto. The tax prep software can handle it, but it depends on what the rest of your tax form looks like for how much you'd actually owe
As said, mod
% mod meaning the remainder ?
a local project with git can still use the files from gitignore, right? just that it doesn't look at the changes there
yes, a lot more efficiently
yes
Yup
gitignore is just about what gets staged (and eventually committed/pushed)
like 2 to the power divided by remainder of mod ?
the files themselves still exist
challenge: calculate 2 ** 1000000000000 % 3
The project can use the files, git just doesn't track any changes to them
in sweden its fairly easy i think just that my python isnt that good and no turtorial that teaches me how to make this (understandable)
but the github looks good tho
Oh 1 ?
I might just switch to codeberg at this point because GH has lost a lot of my trust
pow(a, b, c) = a ** b % c but you never actually have to calculate a ** b
Yep
ah i get it first the exponent gets remainded* by the exponent right ?
Go ahead!
join us
what?
(a ** b) % c
first it do exponent % mod right ?
no
then why that ?
wdym?
You get the result another way
whatever , i got the idea ...
why do i keep running into weird quirks of the typing system 
Gonna make a new set of operators
<(*-*<)
(^*-*^)
(>*-*)>
everyone have cats except me ...
(v'-'v)
i wish fix was here ๐
freecodecamp is actaully fun and simple
is it best python turtorial?
i had a little python but forgot a lot
even languages which allow defining operators usually dont allow having ( ) in them
I finally understand all the AI generated async code in my codebase ๐๐๐
i dont know if if you have any prior experience in python even little its best
The math or esp Numpy have a lot of extra math utilities if you wanted more math stuffs for your own use
that will be def overkill
๐ฅง = yummers
what is this ? ฮป
Lambda. Could mean a lot of things
a lot of thing ?
Means something in math, something in stats
multinational symbol
And its the symbol for lambda (the Greek letter for L)
And lambda functions are like one time/single use function
Anonymous functions
final_bill = running_total / num_of_friends
print('Bill per person:', final_bill)
each_pays = round(final_bill)
print(f'Each person pays: {each_pays}')
and the heading : Use the round() function to round final_bill to two decimal places and assign the result to a new variable named each_pays.
Finally, use print() to display the string Each person pays: followed by a space and your each_pays variable.
With that, the bill splitter workshop is complete.
it dont work ...
i think you're supposed to round to 2 decimal places, but by default round rounds to an integer
how to do that ?
!d round
it has a 2nd parameter for the amount of places to round to
round(number, ndigits=None)```
Return *number* rounded to *ndigits* precision after the decimal point. If *ndigits* is omitted or is `None`, it returns the nearest integer to its input.
For the built-in types supporting `round()`, values are rounded to the closest multiple of 10 to the power minus *ndigits*; if two multiples are equally close, rounding is done toward the even choice (so, for example, both `round(0.5)` and `round(-0.5)` are `0`, and `round(1.5)` is `2`). Any integer value is valid for *ndigits* (positive, zero, or negative). The return value is an integer if *ndigits* is omitted or `None`. Otherwise, the return value has the same type as *number*.
For a general Python object `number`, `round` delegates to `number.__round__`.
^
lambda you're kind of a typing enthusiast, right?
ah thanks i didn't paid attention on the time i was learning that
did you know that kinds are the types of types
You could also round the formatted string so you only round what you print and not the actual values, but its probably not what youre being asked for
and i am not kind
yeah , they are asking for ..
death
a death sentence
why are the two returns treated differently by pyright
@dataclass
class Foo:
x: int
class FooCollection(NamedTuple):
foo1: Foo
foo2: Foo
foo3: Foo
foo4: Foo
def order_foos(foos: list[Foo]) -> FooCollection:
match foos:
case [Foo(x=1) as f1, *f, Foo(x=4)]:
# Expected 4 positional arguments
return FooCollection(f1, *f, None)
# no squiggles
# return FooCollection(*[f1, *f, None])
Mhm just use the round function
it can just round 5.89 to 6 ?
that will be not accurate
my assumption would be that since list has a single type for all elements, you get a union and then you unpack that union into all params
oh wait thats another thing no thats not what you're asking
list doesnt have a size in the typesystem so it just assumes it will match, sort of an optimistic thing to not cause errors in "real code" and cause people to rewrite to check length
You choose how you want to round it
oh yeah ..
there could be a special case in the typechecker for unpacking list displays
but
there just isnt so
for tuples the size is known in the type so that shouldnt happen
Round(whatever, 2) - rounds to two decimal places
hmm switching to exploded tuple still has the same complaint as the no-list version
on-hover says that the match wildcard f is list[Foo]. i wonder if pyright thinks that FooCollection is getting only 3 values (or maybe even 2 for an empty list?), or some unknown giant number 
what can this possibly mean ? : In Python, every value has an inherent boolean value, or a built-in sense of whether it should be treated as True or False in a logical context. Many values are considered truthy, that is, they evaluate to True in a logical context. Others are falsy, meaning they evaluate to False.
you can do bool(x) on almost all values in python
and things like if and while do it implicitly
When we can't?
logical context meaning if x
when __bool__ = None or raises error
NotImplemented, or Numpy arrays, for example
why this is true ? ```py
print(bool('Hello')) # True
That's sad
numpy arrays i think don't like being booled
all nonempty strings are truthy
Non empty strings are true
Bhardwaj told this in morni g
Empty strings are false
Even str() -> makes an empty string
strings are sequences of characters, a sequence is truthy if its not empty
ah ok so evry occupied string is truth ?
Yeah, its the truth of the universe
and this ```py
print(bool('')) # False
The ultimate reality
is false right
Yes
"occupied" is a strange word to use there 
yes
my minds remember simple words ..
not augmented assignments ...
i will never remember that ...
is "non-empty" not simple enough?
it confuses me just ,,
what else is false

in non or empty idk
empty -> False
is not empty -> True
print(bool(False)) # False
print(bool(0)) # False
print(bool('')) # False
my_str = "False"
0 is false, 1 is true
childish concept
how is that childish ๐ , thats just how computers work
ok so uh
it seems like typecheckers assume that a *args of types of variable sizes fits all the missing args right away
so if you have any arguments after it - they're extra
Binary is all 0s and 1s

is_citizen = True
age = 25
print(is_citizen and age) # 25
Nothing is childish
this confuses me ?
def take_4(_0: int, _1: int, _2: int, _3) -> int:
return _0
def unpack_list(xs: list[int]) -> None:
take_4(*xs) # assumes that it will match, works
def unpack_fixed_tuple(xs: tuple[int, int, int, int]) -> None:
take_4(*xs) # for tuples it can check exactly
def unpack_variadic_tuple(xs: tuple[int, ...]) -> None:
take_4(*xs) # like with a list
def unpack_list_inbetween(xs: list[int]) -> None:
if len(xs) == 2:
take_4(0, *xs, 3) # too many? what
def unpack_fixed_tuple_inbetween(xs: tuple[int, int]) -> None:
take_4(0, *xs, 3)
def unpack_variadic_tuple_inbetween(xs: tuple[int, ...]) -> None:
take_4(0, *xs, 3) # doesnt work
if len(xs) == 2: # this actually narrows the tuple type so it works
take_4(0, *xs, 3)
I don't eat children in dish
you should , they are in your basment
even with a len check
lol

so for my example of
case [Foo(x=1) as f1, *f, Foo(x=4)]:
return FooCollection(f1, *f, None)
``` it sees FooCollection as getting *6* values instead of the required 4?
more like 5
because f(0, *xs) works, it assumes len(xs)==3
911 , whats you emergency ? there are childs in a guys basment
*args: int or explicitly is Unpack[int]
How about **kwargs or wait is Unpack for **kwargs?
Thunder breathing - 11th form
Nuke this guy
age = 19
``` is this truthy ?
there is only 1 form ...
keep a repl open and do bool(x) on things
and non-zero integers are truthy
ah ok
so * of variable sized things is supposed to be the last argument for some reason
weird
i wonder if that's noticed and intended behavior
regardless, this discovering of yours has greatly simplified the MRE:
def foo(a, b, c, d): ...
foo(5, *[10, 20], 40)
i love simple meal ready to eats
watch the trilogy movie i think he has 11th form self made
Non zero integers are True
like zenistsu only have 1 form
thanks i am now completely broken its enoughtlearning today
Isn't that simple
i should work on my project now ..
it is
Yeah do that, i learnt much more from doing projects and doing something i like
anyone have um sya 1920x1080 screen ?
i am working on a youtube automator .. which requires the comment section screen coords
mine have 1280x1024 screeb
so i want the 1920x1080 screen coords
guys, I dont get bottom up dynamic programming ๐
bcz its the res most ppl have
isnt this against TOS ?
it dont work as a bot
which spams
it is for creators who want to automate replying their comments section
as you can see here : https://github.com/sarimgamerop-cloud/Intelli-Comment
do you get top-down dynamic programming? you start with the "big problem", and express its solution as doing something to the solution of a smaller problem, and that chains until you get to the smallest problem
bottom-up changes the order in which you start subproblems to start at the smallest problem, and have the solution to the next problem depend only on the solutions to already solved, smaller problems. then you chain that "next solution" until you get to the one you want
wait, so you just reply to comments with LLM slop?
I think your viewers will notice, lol
i dont care , i just thought it will be fun, without thinking twice .. just learning
you could have fib(n) start with fib(n-1) and fib(n-2), that'd be top-down (usually recursive, with memoization)
or you could start at fib(0) and then fib(1) up until fib(n), thats bottom-up (usually iterative, with an explicit table for the results)
okay that actually helps because I somewhat understand the top-down DP (like with recursion). Do you think I should try to get better at top down stuff and finding recurrence relations and stuff before I move onto bottom up DP
so like solving fib(1) and then using that to solve fib(2) until fib(n) is that what you mean?
yes
well
you can use fib(0) and fib(1) to solve fib(2). all of the things you already solved, not just the previous
what way are you referring? The recursive or the iterative one?
ok
the iterative version I think bc its the bottom up dp approach correct me if im wrong
you'll need to find the recurrence relations in both bottom up and top down, bottom up just requires you to also find an iteration order
yeah, in both cases you're expressing 1 solution as depending on others
set's lt, gt, is actually not very correct, typing wise
its an interesting concept with NonImplemented, maybe it's type correct
on eq when NonImplemented is returned no error is raised when doing ==
on lt for example, an error is raised on NonImplemented when doing <
you dont need to typehint that you're returning NotImplemented
>>> { 1 } < { 1, 2 }
True
technically, lt accepts any object, just like eq
yet it's typehinted as accepting only AbstractSet
object has no __lt__, so no
i'm talking about set's lt
no, im saying that there is no reason for __lt__ to accept an arbitrary object
__eq__ accepts an arbitrary object because its part of object
object.__lt__ doesnt exist, so some_cls.__lt__ is free to typehint it as accepting whatever
Well... that's just a nature of the language, i.e. you can typehint it, but typehints aren't enforced
there is set.__eq__
def __le__(self, value: AbstractSet[object], /) -> bool: ...
def __lt__(self, value: AbstractSet[object], /) -> bool: ...
def __ge__(self, value: AbstractSet[object], /) -> bool: ...
def __gt__(self, value: AbstractSet[object], /) -> bool: ...
def __eq__(self, value: object, /) -> bool: ...
thats what i said, yes
When did lambda say there wasn't?
i dont understand what u're saying
what i'm saying is that lt is accepting every object as well
then what you're saying is wrong
< raises an error
but lt isn't raising an error
it might return NotImplemented though
but eq might return NotImplemented as well
the only difference is that on eq NonImplemented there is no error raise, on lt there is
NotImplemented is not reflected in the typesystem at all
(when doing == and <)
when you return NotImplemented in lt of set, the error raised if u use < automatically
does anyone know kivy?
Not for some time.
im not sure why are you mixing up runtime with typing
what are you actually saying?
def f(x: int):
print(type(x))
f("abc")
prints:
<class 'str'>
```despite me type-hinting it as `int`.
Whereas now I get an error:
```py
def g(x: int):
if not isinstance(x, (int,)):
raise NotImplementedError
print(type(x))
g("abc")
because there is no actual error raising inside lt
yes there is
as a flat function, it raises no error, it could be written exactly like eq
yet eq accepts all objects, lt accepts only abstract set
what is a "flat function"?
< vs lt
__eq__ accepting object is the result of it being part of the object protocol
there is not much reason for "1" == 1 to typecheck, its just Liskov Substitution
object.__lt__ does not exist, so each class is free to define the argument type to __lt__ as specifically as it wants. typeshed defines it to be the one that will actually work at runtime, to prevent more errors statically
< is just synatical sugar for __lt__
its not
well, you might think of it like this
but < is different than __lt__
it handles NotImplemented, and reflaction
reflection*
@distant garnet Is there a question forthcoming? ๐
on NotImplemented it raises an error (in set, for exmple)
yea but you could define eq then to accept only abstractset
Dude i wanted to start kivy development like im in high school , my OOPS is weak though any tutorials or vids you can recommend
you cant, liskov substitution.
then why not making lt accept all objects as well
since it technically does
object.__lt__ does not exist
i mean, in set's lt
!beginner I'm well versed in the basic concepts. I can take you through them now if you like.
Here are the top free resources we recommend for people who are new to programming:
- Automate the Boring Stuff โ an online book (also available to purchase as a physical book)
- Harvardโs CS50P course โ video lectures (slides and notes provided) with exercises
- Python Programming MOOC 2026 course โ text-based lessons with exercises
- Corey Schafer's YouTube playlist
For a full, curated list of educational resources we recommend, please see our resources page!
OOPS, as opposed to Kivy, whuch I haven't touched for a long while.
because its not useful. why allow code that will error in practice?
it doesn't error, thats the thing
it returns NotImplemented
lt does not error, but < will
yes, but lt isn't wrapping < or reflecting on it
its the other way around
relying* not reflecting
if you think of lt as a function for itself, why it needs to care about <
you're proposing to allow code that will error in 99.9999999% cases just because some single person might implement Cls.__gt__(set)
dunders are fundamentally related to their operators, it does not make much sense to consider them separately. people dont use lt as a function directly.
if the error would get raised inside lt, then fine
but since it doesn't, and it never errors on any object
so you say the typehints of lt should be the typehint of <
yes. the name is bound right away, its just that the value will only reify when accessed
NotImplemented is assignable to all types, just like Any
yea but maybe when you return NotImplemented you think about what would happen then
Oh nice
and base your type hints on that
too much headache tbh
I guess i will copy this behaviour too in my PEP 562 implementation for pre 3.15 versions
i'd prefer people to not write insane dunders
currently i just impl dunder getattr and don't fill in dunder dir
maybe it'd be better if NotImplemented wouldn't exist to begin with
Keeping it easy and readable ๐ :
class Composition:
def __init__(self, f):
self.f = f
def __rshift__(self, g):
def wrapper(*args):
return g(self.f(*args))
return Composition(wrapper)
def __call__(self, *args):
return self.f(*args)
@Composition
def compose(*args):
return args[0] if len(args) == 1 else args
@gleaming knoll whats your take on this
maybe yeah
lhs could explicitly call the respective dunder of the rhs, if it wants to allow it to implement the operation
it can get complicated
i've made a pipe class
its pretty long
say you want to connect pipes together, or disconnect, etc
Other than .po and gettext and json/yaml/toml, what else do y'all use for text translations? And do you keep key by english words or by a prefix + N where N is an integer starting from 0
when you think about all the combinations its a big head ache
what if you wnat to add a function to the start, what if to the end, and all that bbullshit
i've also made pipes immutable, and hashable
i was trynna make a parabola jump but i fumbled ```py import pygame
pygame.init()
screen = pygame.display.set_mode((1280,720))
clock = pygame.time.Clock()
running = True
dt=0
player_pos = pygame.Vector2(640,360)
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
fade = pygame.Surface((1280, 720))
fade.set_alpha(100)
fade.fill("purple")
screen.blit(fade, (0, 0))
pygame.draw.circle(screen,"red",player_pos,40)
keys = pygame.key.get_pressed()
if keys[pygame.K_SPACE]:
if player_pos.y < 720:
for i in range(1,100):
x = i * 0.1
y = x * x
player_pos.y -= 300 * dt * y * 10
if keys[pygame.K_s]:
player_pos.y += 300 * dt
if keys[pygame.K_a]:
player_pos.x -= 300 * dt
if keys[pygame.K_d]:
player_pos.x += 300 * dt
pygame.display.flip()
print(player_pos.x,player_pos.y)
if player_pos.x < 0:
player_pos.x = 0
if player_pos.y < 0:
player_pos.y = 0
if player_pos.x > 1280:
player_pos.x = 1280
if player_pos.y > 720:
player_pos.y = 720
dt = clock.tick(60)/1000
pygame.quit()```
Hey @thorn mist!
Make sure you put your code on a new line following py. There must not be any spaces after py.
Here is an example of how it should look:
```py
print('Hello, world!')
```
This will result in the following:
print('Hello, world!')```
Like, a wrapper around this?
https://man7.org/linux/man-pages/man2/pipe.2.html
its my own thing, i dont wrap anything
i was inspired by Mamoun, from this server, he also had an implemention for it (but mine is completely different)
couldn't that lead to recursive spirals?
(he called it pipe)
if both dont implement it yeah
maybe it would need some kind of context tracking
i haven't published my implementation, but there's a thread of it at its early stages, that i opened in here
Can you explain what a "pipe" in your context is (or how it differs from the
unidirectional data channel that can be used for interprocess communication
)
composition basically
Mamoun called it pipe
out of respect, i used that name as well
ah, I see. Yeah, it massively confused me that you called that "pipe" ๐
that thread is no where near the final implementation, but it represents the idea
uh its what he called it
ok, thanks
it gets pretty messy
getting it to work well with typehints
and all the possible combinations
hmmm, I guess if I were to name it and I had to include the word "pipe" I'd call it "pipeline"
well... thats fine i guess
he called it pipe, so i called it pipe
i guess its the answer to this python question that sometimes pop, of something recently i'm proud of, or maybe, was really fun to work on
it would be cool if you could partially apply each piped function
like P = pipe; P(a, 1, 2) | P(b, 2) | P(c, 3), where a, b, and c all take 2 positional arguments
not sure what u're saying
like, a "binding" pipe?
ah my example makes no sense, edited it
is that
c(b(a(1, 2), 2), 3)
#
_0 = a(1, 2)
_1 = b(_0, 2)
_2 = c(_1, 3)
?
yes
aaaah
helloworld("print")
maybe you could do this with a decorator instead...py @piped def a(x, y): ... @piped def b(w, z): ... a(1, 2) | b(2) | ...
that would be nasty
but to get the actual value you'd need to (a(1, 2) | b(2)).value then
which kind of sucks doesnt it
jast write ze fokin temporaries
python is not a place for your awesome composition pipelines
When I've done things like this each pipeline stage is an object wrapping a function. Typically with a mode indicating how it handles the stuff coming down the pipleine - one-to-many, batches etc.
@granite wyvern can you help me in the thread..
yes just reading it now
you can use partial
in my version pipes can be connected and disconnected, combined in whatever way
but if you want to use a function with given argument you can pass a partial
note that it'd work only with keywords
because partial can't do partial(x, ..., 1,2,3,4)
def partial_mod(function, *args, **kwargs):
@wraps(function)
def function_wrapper(*additional_args, **additional_kwargs):
function_args = []
function_kwargs = kwargs | additional_kwargs
additional_args_iterator = iter(additional_args)
for arg in args:
if arg is not Ellipsis:
function_args.append(arg)
else:
function_args.append(next(additional_args_iterator))
function_args.extend(additional_args_iterator)
return function(*function_args, **function_kwargs)
return function_wrapper
you can use this for it
now it can (since 3.14 I think)
uh
yeah there's a new Placeholder object you can use there
every function i write eventually goes to the garbage i guess
see the bit about Placeholder
ew
well, you can use a different name i guess
Placeholder as _
from functools import partial, Placeholder as _
remove = partial(str.replace, _, _, '')
message = 'Hello, dear dear world!'
remove(message, ' dear')
That's a very dismal sentence.
_ as a name is very liable to get overwritten
you're better off doing _ = Placeholder just before using it, if you really want
you mean _ = Placeholder
its basically the same
yeah yeah
or: your idea was useful enough to be added to the standard library (albeit in a slightly different way)
x as _ or _ = x
well... i guess what i did is still relevant for < 3.14
although i like the _ solution, i might use that as well
_ = ... is also neat not gonna lie
os.path.basename() faster than Path().name?
how much?
!d timeit
Source code: Lib/timeit.py
This module provides a simple way to time small bits of Python code. It has both a Command-Line Interface as well as a callable one. It avoids a number of common traps for measuring execution times. See also Tim Petersโ introduction to the โAlgorithmsโ chapter in the second edition of Python Cookbook, published by OโReilly.
ipython?
i dont like combbining os paths with Path
i ain't combining, am picking either
i'm saying that you should pick what you already use, if you use Path stuff then use Path
class Command(Parameter):
def __init__(
self,
name: str | None = None,
*,
aliases: str | Sequence[str] | None = None,
parse_mode: ParseMode | None = None,
subcommand_required: bool = False,
) -> None:
self.name = name or Path(sys.argv[0]).name
Path() will probably be used for root-level command which is usually once
IPython has special magic for it (%timeit for a single line, or %%timeit for a whole cell)
but the timeit module exists independently of IPython
Ooohhh
(Path is normally considered slower than os)
Ruff says use Path and i like pathlib, so ema use that unless i find performance issues
yea i think thats the correct route to go with
Obviously i can shh ruff
(you wont find performance issues)
Owo
I mean,... Os isn't even a built-in, you gotta import, so yeah i wouldn't find issue importing pathlib
yea
i think that if you dont face performance issues (and as lambda said, u won't, normally at least) picking pathlib is better for all cases
there is no need for this "normally"
I don't like having such a verbose name with keyword or containing in it, although its the most concise and clear enough name i have got, do you guys can suggest me better name over specifier_or_option ?
def remove_option(self, specifier_or_option: str | Option, /) -> Option:
if isinstance(specifier_or_option, str):
try:
option = self._specifier_to_option[specifier_or_option]
except KeyError:
exc_message = f"Option with specifier {specifier_or_option!r} not found"
raise ValueError(exc_message) from None
else:
option = specifier_or_option
try:
self._options.remove(option)
except ValueError:
exc_message = f"Option not found: {option}"
raise ValueError(exc_message) from None
for specifier in option.specifiers:
del self._specifier_to_option[specifier]
return option
makes sense
spec_or_opt
still or in it
there is no application that you would run that does anything meaningful, such that when profiled, you'd find Pathlib().name taking such a significant amount of time such that even if os.path.basename was faster, it would be worth switching to it
altohugh spec might refer to spec..
Yeah
I also have marked it as pos-only
what does a specifier look like?
'-a''--foo'
just say option then
i think that if you go fully pathlib, or fully os, there could be a difference where hundreds of thousands of files are involved
Is this my chance to use NewType ?
option: str | Option, that is
you must have this or?
maybe make 2 functions?
remove_specifier remove_option
fundamentally the "specifier" also just represents an option
so there's no user-visible need to distinguish it from an Option object
hmmm, but option: Option is also used in lots of places. Won't that knowledge collide with the user?
why not just calling it option yea...
in those other cases, why not also accept a specifier string there?
make it the same in all those places
i am afraid they would think its about concrete Option than a str lol... Is it okay
either all supporting str and not, or just Option in all
you should aim for a consistent interface unless there is a strong reason to only take Option in some places and take str | Option in some
I don't think those places have knowledge of specifiers but i will check it out
the typehint exists for that
What from typing would be appropriate for making a typename Specifier instead of str
type Specifier = str ?
NewType(str)?
eh, if you make it a new type it would be more confusing IMO
And would be great if it can talk about prefixes such as - and --
a class that wraps or subclasses str
str seems too generic lol
like I hover over it, I see Specifier | Option, that doesn't immediately tell me that yeah Specifier is actually a str
you're right
yea if its just str i'd use str
unless I already know that issubclass(Specifier, str)
I feel like i am making a bad designed code lol
but its cool to be remove without double funcs lmao
mates is tehre a chat here where I can ask for an opinion? I dont want specifically help with something but to understand a concept for jupyter notebooks
the naming is less cool
or, just take Option, and have a user-visible way to get_option_by_specifier
ask here
you can also create a function for the common work if you want
thanks mate, aight so Im new to python comin from C++, C# languages that I used for game dev.
I had this class that Im using Jupyter notebooks, but I treated it like a normal IDE. When i try to break my code in smaller pieces, nothing works not even if i try to boot like 4 lines of code. So I am confused
def _remove(whatever):
...
def remove_a(x):
...
return _remove(x)
def remove_b(y):
...
return _remove(y)
can you clarify what you mean by "nothing works"? do you get an error, or something?
each cell has to be a valid "file"
you cant split up one function into 2 cells, for example
well, they can rely on state from other cells since they are running in one interpreter, and they can even be ran in non-linear order
each cell has to be independently syntactically valid
yeah i get a huge error, so like
If i tried to run
#file will be provided please correct the right path to use
# used pandas documendation
file_path = r"FAT - SF6 Frame Data.xlsx"
xls = pd.ExcelFile(file_path)
# check the sheet names and keep the ones with Normall in
move_sheets = [name for name in xls.sheet_names if "Normal" in name] ``` just these lines I still get error if i press ctrl + enter
when I work in a notebook, I rely heavily on "restart kernel and run all code"
please show us the actual error, just saying "error" doesn't give us nearly enough information to actually help you.
what is the error
https://pastebin.com/XSG8wMyv its huge sorry dont wanna cover the whole chat
ImportError: Missing optional dependency 'openpyxl'. Use pip or conda to install openpyxl.
do you know what a dependency is?
ye
^the error message itself is at the bottom of the stacktrace, always check it first
I assumed that because it worked for my VS codium for another class
it woukld be all tehre
Hm
(im on cachyOS if it matters)
did your other class require you to open an excel file?
no
every program is different
ah right I did this thing before in windows
it doesnt matter
now it makes sense why
you will get the same error on windows
ye i mean i must have installed it there
why cant you install it on the machine you are currently using
as shamefull as this is to save I didn't actualyl read the error because it was so huge I thought soemthign is broken
i mean... it is scary
we are but veterans who are used to slaying scary monsters /jk
just usually don't get errors so I was so confused even from 4 dialogue lines haha
one of the most important skills is to be able to extract information from huge errors/texts even if you don't fully understand them.
learn to skim.
but you aright
the most important attribute is courage to read the error message... /hj
I get like a morbid curiosity. like I wonder what I screwed up to get that big of an error.
as my high school math teacher used to say for calculus problems: "take a deep breath and integrate"
we got this ! thank you mates i split it on just my functions and I can see it working now that Im trying to load it cell by cell
this also helped a lot thank you
๐
Where where else is if TYPE_CHECKING: used outside indenting typing-only import stmts?
do type checkers read or mutate this constant?
type checkers dont run your code. they just assume TYPE_CHECKING: Literal[True] even though at runtime its False, for the purposes of static analysis that means that the if branch is reached and else is unreachable
You got me 

type checkers never make use of this attr?
they do
how so and when
^
TYPE_CHECKING is False at runtime, but True for typecheckers, a trick
i mean they just assume, but do they ever import it? Do anything with it other than blind faith that its True? lmao
no, static type checkers dont run python code at all.
never thought about the else...
very weird
That is very vague at second part of the sentence, "but True for typecheckers, a trick"
so you can do:
if not TYPE_CHECKING:
anywhere, and it'd be ignored for all type checkers?
๐คฏ
it makes me wonder that ... do they set it to True? or the python itself?
yes
๐คฏ๐คฏ๐คฏ
Wonder if ruff yells at if not TYPE_CHECKING
or typecheckers

maybeb it'd say this condition never enters
type checkers keep a mapping from qualified symbols to types
the symbol "typing.TYPE_CHECKING" is given the type of Literal[True] (its representation in terms of the internal structures used in the typechecker). that does not involve running python at all. its just internal state of the typechecker
warn for that
Code is not analyzed because condition is statically evaluated as falsePylance
yea
if not TYPE_CHECKING:
print("hello")
static type checkers dont run your code
they analyze it, statically
for a static type checker, TYPE_CHECKING is considered True at all times
but at runtime, TYPE_CHECKING is False
yo bro, please no spamming
i know your ign is spammer and it might be hard for you
try to resist the temptation
๐โ๐ฟ i am good human beinggg dw
๐
Who said to run my code, i am just saying if it just imports from typing module to check the constant
"import typing" is "running python code". type checkers dont do that.
So a blind faith, it doesn't even bother importing TYPE_CHECKING, i see
type checkers dont run your code
/Assumption
TYPE_CHECKING is a constant, located in the typing module
you can imagine a typechecker as a function Graph[ModuleName, AST] -> Sequence[Error | Warning | Info]
i thought if a type checker is written in python so it could just import it and check it lol
there is no reason for it to check it, its defined by the spec that typecheckers should treat it as True

i see
What's the difference between "oh" & "i see" i use them interchangeable to say "oohhh is that so ..."
i mean, if it were to check it, it'd find that its false, which defeats the point
I thought they set it for themselves lol
so you did think they run the code?
Won't typing.TYPE_CHECKING makes the indented code inside it unreachable always? Or typecheckers/linters special case it?
the whole point is that its special cased
ign?
they do qualified_names_to_types["typing.TYPE_CHECKING"] = WhateverStructureTheyUseForRepresentingAType.Literal(True)
so when analyzing a program which has if TYPE_CHECKING: in its source code, the analyzer assumes that the branch is taken, even though at runtime its not
xD
Thanks guys
Now back to code
in game name
in game name
too much water
from games
Specifier = NewType("Specifier", str)
type OptionLike = Specifier | Option
then i can just do:
def def remove_option(self, option: OptionLike, /) -> Option: ...
What do you say?
I already have cliargparse/hints.py for OptionLike to be putten into
why not give the user a way to get_option_by_specifier and then only use Options everywhere in your interface
i think this is clean
or in Option's init accept a specifier
or a class method from_specifier
there is strlike i think, reminds me of it
PathLike also
I don't find it good to split tbh...
it also makes easier for user since they're used to str and option concrete
Or maybe i am being biased lol...
i gotta think more
splitting what?
yea PathLike
Two methods to remove option
How is that

what I suggested would only have one method
tell me, if there is options_or_specifiers, can it have 1 option and 1 specifier inside it?
This code i mean
i see, 1 option or specifier, not an iterable
Huh
I don't get it
i remembered it as remove_options my bad
Iterable[A|B] vs Iterable[A]|Iterable[B]
(those are not equivalent)
remove_option(option_object)
# or
remove_option(get_option_by_specifier("--option"))
is what I mean
Does variance make it equivalent or something
eitherway, what bharadwaj suggested is that it'd bbe only Option
it's more orthogonal. it's plausible to me that users would like a way to go from specifier to option generally even outside the context of remove_option.
no, neither covariance nor contravariance nor invariance
and there'd be a way to create an Option from a specifier
ohhh, get_option() only takes specifier so your design is good and possible but again remove_option can itself find option of that specifier since they're defined under same class