#python-discussion
1 messages Β· Page 441 of 1
That's the longest FAQ I've ever seen
This is why people don't like GPL
Every question turns into a speech
- There is no FAQ -> bro they are so terrible to not provide any guidance
- There is a thorough FAQ -> bro they are so terrible they have to write long documents
yes
exactly
Oh, then definitely don't listen to RMS speak.
Whos that again?
Insert Larry Davis waiting at the back of the line, but every question takes forever to answer.
(of which, only 2 people here will get the joke)
Gary the Snail
I hate that guy
Every man page I open, his name is at the bottom
This is gary gnu, for the rest of you:
gnary
That is not a picture I wanted to click on.
make it show
!compban 1426949078738276525
:incoming_envelope: :ok_hand: applied ban to @solemn mantle until <t:1775866698:f> (4 days).
This is for discussing python
ok, good
We have off-topic channels if you want a more "general" chat
oh ok
so when I am assigning a string to a variable
do I use this ' or "
like string = 'hello'
You can use either, as long as you start/end with the same one
or string = "hello"
One assigns variables to objects.
I don't get it what's the difference ?
A string is an object though
Yes.
Then why confuse the poor fella?
The quotation marks? Yes, you can use either. No difference in how it runs
thanks for the guidance
and you have to be careful if you want your string to literally contain the other
who does that lol
so if my string contains an apostrophe, I should start with "
"can't you see how cool this is"
well, you never know if someone is going to try that
thanks for the heads up π
I'll be here for a while to show you my "art" lol
or 'art'
'My code's problem. See if you can understand why there is one.'```
Also, good parsing work, Discord syntax highlighting.
Ooh its art time?
I just found some of my old art! #ot0-psvmβs-eternal-disapproval message
Anyway, as I was saying. One assigns variables to objects. One does not assign objects to variables. foo = "abc"Here, I am assigning the variable, foo, to the string object, "abc". I have not assigned "abc" to foo.
@flint jewel
I think their phrasing could be interpreted either way
isn't english fun?
The meaning was understood.
hey be nice! it did its job
It did a job.
So, I really don't get the entire object thing. an object is a block of memory. so what does it mean not assigning to an object
I really don't get it
they were being pedantic about your wording here
A variable is like a signpost with a name on it. It points to an object. Above, foo is the name I've given the signpost and that signpost points to "abc".
I know what a variable is. what I meant is like assigning what to what
the whole thing is confusing
Lefthand is assigned to righthand.
and bring me back memories of C++
Righthand is not assigned to lefthand.
Yes in python, but they asked their question in english
ok, I am a bit confused I don't know my right ffrom left xD
I am reading a book right now. we will continue this discussion when I get the chance
I will conceed my timing was poor.
I do not conceed any invalidity of my point, otherwise.
Programming is specifics.
so interestingly enough using ' has it cons
There are ways around it.
like assigning to the variable string = ' python's a lovely language '
yes, but the same thing can be said about trying to quote someone
you can use double or single quotes as needed
"the person said "hello""
I'm so bad at using ' vs " consistently. I come up with theoretical rules and then I just start typing.
The only thing I try to be consistent with is using " when the sentence/string has a single quote in it
oh right mb
s = "It's a beautiful day, isn't it?"
same, I don't even realize I do it when I read back my code
s = "some of my favorite punctuation marks are ' and ", they said while shouting "wheeeee where are dog's at?"'
(That is probably not a valid string)
'For example, an apostrophe\'s drawbacks may be worked around.'```Though it is probably better to use " for avoiding the apostrophe problem.
This gives you a string with the ' within it
and no \
For a mix, use triple quotes
s = '''He said, "Why can't you be honest?"'''
That's a good suggestion!
But what if the person is ALSO talking about how they use triple quotes in python π
Use one quote style and escape the others.
Yeah
its just not in my blood :wolfthuglife:
GOD I MISS MY NITRO
accum("RqaEzty") -> "R-Qq-Aaa-Eeee-Zzzzz-Tttttt-Yyyyyyy"
accum("cwAt") -> "C-Ww-Aaa-Tttt"```
Were you able to solve this?
Do you want to open a help thread and I can give you a hand?
no need to split here
you will want a list to store all the items you create
Can you think of how you might end up with a list like this?
['A', 'Bb', 'Ccc', 'Dddd']
Fun fact: enumerate has a start parameter.
Does anyone know if there's a way to connect my python games, I made 3 games including the main menu. But idk how to connect the games. Anyone know how?
I would use the itertools library.
it entirely depends how you created them
can do this using enumerate?
Why? How? A simple loop is more than enough
Which part specifically are you struggling on?
"PS C:\Users\seraj\downloads> python -c 'print("hello")'
Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'hello' is not defined. Did you mean: 'help'?
PS C:\Users\seraj\downloads> python -c "print('hello')"
hello
PS C:\Users\seraj\downloads>"
I created them on seperate python files and also seperate folders
It could form a component of a solution. Or not. It's up to you.
how can I format it ?
ok wait ill try
!format
The String Formatting Language in Python is a powerful way to tailor the display of strings and other data structures. This string formatting mini language works for f-strings and .format().
Take a look at some of these examples!
>>> my_num = 2134234523
>>> print(f"{my_num:,}")
2,134,234,523
>>> my_smaller_num = -30.0532234
>>> print(f"{my_smaller_num:=09.2f}")
-00030.05
>>> my_str = "Center me!"
>>> print(f"{my_str:-^20}")
-----Center me!-----
>>> repr_str = "Spam \t Ham"
>>> print(f"{repr_str!r}")
'Spam \t Ham'
Full Specification & Resources
String Formatting Mini Language Specification
pyformat.info
Clean code, I'm used to using it too.
using an overkill module is not clean code
Can I see your itertools solution?
Anyway, I still think it's efficient.
Let's see the code
Do you have an uncle named Bob?
Just check the Python documentation itself.
Dyk how? I created the games on different folders, now I'm having a hard time to connect them to my main menu
Programming is little mechanics that make up larger mechanics that make up larger mechanics and so on. You can avoid using enumerate altogether and still achieve the same effect. It's just a nice way to condense the longer way of doing it.
You're the one that made the claim. Please back it up. We don't like people spreading misinformation here.
Can you explain more about these games? Are they pygame/GUI?
KKKKKKKKKKKKKKKKKKKKKKKKKKKKKK
Yes they are pygame, all of them
I don't know much about pygame, but you'll likely need to retool them a bit so they can share the same overall process. Otherwise each game is going to spawn its own event process which won't really work
a, b, c = (1, 2, 3)```Here, a == 1, b == 2, c == 3.
my_list = [(1, 2), (3, 4), (5, 6)]
for ab in my_list:
...```Here, ab == (1, 2), then (3, 4) and so on.
im very close can u explain how to use join to me
I once made a classic checkers game in Pygame when I was learning.
join lets you connect up an iterable into a single string using a provided string
my_list = [(1, 2), (3, 4), (5, 6)]
for a, b in my_list:
...```Here, a == 1 and b == 2, then a == 3 and b == 4 and so on...
ok wait
!e
text = ['a', 'b', 'c']
print('.'.join(text))
print('---'.join(text))
print(' and '.join(text))
:white_check_mark: Your 3.14 eval job has completed with return code 0.
001 | a.b.c
002 | a---b---c
003 | a and b and c
here's some examples of it in action. Is this clear how it works?
let's see the result
def accum(s):
res = []
for i in range(len(s)):
res.append((s[i] * (i + 1)).capitalize())
return "-".join(res)```
Do you understand everything happening here?
im 120 honor in code wars
I think I stopped somewhere around 400
nearly everything other than the 4th line (s[i])
how long did that take u
What about it are you unsure of?
π€· I haven't really used codewars properly in awhile, but I've been using python for 8+ years
me when for i in range(len(<list>)):
its a parameter, and its using the i as an index?
!e
text = 'abcd'
for i in range(len(text)):
print(text[i])
:white_check_mark: Your 3.14 eval job has completed with return code 0.
001 | a
002 | b
003 | c
004 | d
Does this make sense?
yes,its using i as the index of s
got it
in general though, most people won't use range this way. Enumerate is much cleaner
hey
!e
text = 'abcd'
for i, letter in enumerate(text, 1):
print(letter * i)
:white_check_mark: Your 3.14 eval job has completed with return code 0.
001 | a
002 | bb
003 | ccc
004 | dddd
can u please teach me list comprehension and enumerate tomorrow
its 2 am for me
ill go sleep
enumerate is very simple
I should be around
@iron bear i can do it
This is pretty much all you need to know about enumerate
What kind of function do you want to create?
If you are interested, please send me a DM.
π€¨
sus
*Shave and a haircut* Do you wanna build a chatbot? π΅
*Frozen* It doesn't have to be a chatbot π΅
im starting to like html
you need Jesus
This must be a brand new sentence
was that line always in the song?
He was so off key I had to step in
Just like thatβ¦
Is anyone here building TUIs in Python?
Hi
Hello
salt.die has batgrl.
Guys could a game made with Python be exported into the App store?
I have [redacted] at $WORK and [redacted] at $SIDEHUSTLE
There are 100 different app stores
it probably depends on the app store
Like the google play store or app store of iphones
Wat
Like those i listed down there π
Hi
Not really
You have to write in the platform's native language
But there are some tools like https://briefcase.beeware.org/en/stable/
Is it good?
YES
There's your endorsement.
I wanted smthg minimal
Hard for me to understand π .Like I mean if I try and coded some Game or App on python what should I do with it.Cant I (Publish) it on an app store for People to use it?
Python comes with curses in its standard library.
isnt python native?
the problem is that in order to execute Python code, your user needs a Python interpreter
Oh what is that π
wdym whats that
Im just new to it sorry.
Does it get the job done?
yes
It only curses when it doesn't get the job done, just like me
Like I wanna get started on learning python.Yet i dont even know where it is coded ans what to do with it after the game or app I created is done?
python is a programming language (interpreted),in order to execute it you need another software that is called an interpreter (the default one is cpython).
We use editors or IDEs for coding. There are a lot of really good ones out there, people with have different opinions on them though.
Sometimes very strong opinions
!slorb
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!
Im sorry I cant understand anything your saying (sadly) π. What is an Software?
also have a look at https://github.com/textualize/textual
if you want to make a mobile applications, there are languages that are might be better suited for that purpose like Swift (iOS) or Kotlin (Android) for example @slow gust
Wat are you currently working on?
I am completely new to it and wanting to start some online lessons on python.
Software: Programs. Applications. Apps. Also operating systems that run them, Windows, MacOS, Linux, Android.
I know but I think python wouldn't be bad
Ohh so a software is like a computer?
Did you start?
software just means "a program run on a computer"
computers run software
Not yet
computer is the hardware
Almost. It's the data on the computer that makes things happen.
Ohhhh okay Thank you!!
Oh tysm
So its just like the app itself?
Yes. Or the software that runs that app.
The computer being the machine itself.
The machine runs the software.
Ohh I understand.Man is python and all that coding and programming hard? Or is it worth of start(
Some software runs other software.
programming is hard, yes, but python is one of the easier languages to learn
Wow π
iOS apps have to be in Swift and compiled to an IPA -- "iOS App Store Package"
Android apps have to be in Java and compiled to an APK -- "Android app package"
In the definition of "native" that you're thinking of, no Python is not native because it uses an interpreter instead of compiling to machine code.
But "native" here means "the platform's first party systems" and all the app stores have their own systems with their own expectations for what languages you're going to give them.
Is it valuable of learning?
If you're curious about it, it is for you.
it entirely depends on what you're learning it for
if your entire goal is "I want to make money with it", then no
What would u recommend to learn it for?
Only you can answer that. Why do you want to learn it?
Oh okay man .I appreciate it thank you so much! π
anyone cares to explain type errors in python
The syntax is much easier that most other languages
you can have iOS and Android apps written in javascript using stuff like react native, and that's just one example
do you understand things like str, int, bool etc?
To be honest I dont even know exactly what it can be used for.Only that u can create games and apps right?
yeah
a type error usually indicates that you passed an argument with an incorrect type to a function
Don't do something you don't like just because you think it wil earn you lots of money
You'll hate it and just be angry
You can have iOS and Android apps written in Python thanks to Beeware.
Okay ill look up on it Thank you bro I appreciate you!! π€©
it's not that it's ambigous ?
like print(23)
do people even like working on finances?
i know
a TypeError means you used a type in an incompatible way.
that isn't ambiguous in Python
What's 5 plus elephant?
For me, it is about imagining a process, then having a language in which to express that process, to construct it. Then, when I tell it to run, it does what I want (or not!) and the success of that is gratifying.
ahhhh idk
neither does python
print(23) will print 23 not a TypeError
Check out the book called βAutomate the boring stuff with Python β good beginnerβs guide
oh ok
!e
print(5 + 'elephant')
:x: Your 3.14 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File [35m"/home/main.py"[0m, line [35m1[0m, in [35m<module>[0m
003 | print([31m5 [0m[1;31m+[0m[31m 'elephant'[0m)
004 | [31m~~[0m[1;31m^[0m[31m~~~~~~~~~~~[0m
005 | [1;35mTypeError[0m: [35munsupported operand type(s) for +: 'int' and 'str'[0m
Yeah I mentioned Beeware earlier
There are various... transpilers?, but at the end of the day they all transpile to native code
I just understood now that my English is so bad π .Yet I understanded a bit and fully appreciate your time and explanations.Thank you buddy may you have a nice Day or Night like for me π₯
Mm.
print will call the object's __str__ function. (Essentially, str(object)).
Oh a Book π .Okay tysm bro I appreciate you!! Have a good night.Ill really search up on it tmw.Thank you
Beeware doesn't transpile. It packages with an interpreter.
yeah I figured. I am just a bit confused on what can and what can't be done
Oh thats disgusting
Why? CPython runs natively on Android and iOS now.
So 5 + 'string' doesn't work because strings and integers don't know how to add one to the other.
That's not the same but how does that actually work BTW
What do you mean?
Can I install Python on my phone now?
Kinda sorta?
Hello
Android, check out pydroid on play store
That's not what I asked
Is that a CPython distribution?
no, its an emulator thats been around for years
can't it just say 5 as a string ? why do I need to explicitly write string
python will never make assumptions for you
datatypes exist for a reason
If I try to add a number to a string it will fail because the types are incompatible, hence TypeError.
Python interpreter on ur phone
python isnt like javascript
yeah I totally get it
Welcome to Node.js v25.8.2.
Type ".help" for more information.
> 5 + 'string'
'5string'
yeah maybe.
that would be awsome
I would much rather python error and tell me something is wrong rather than make assumptions and give me unexpected results
that would be terrible in python π₯
But not the CPython distribution. I know that part of the CPython project has been adding Andoird and iOS support and it's gotten much better.
what should "10" + "2" be? "12" or "102"?
Exactly π
Oh shit, I thought it was just now coming out in 3.15
I didn't release PEPs 730 and 738 were all the way back in 3.13
"102" they're strings.
or 12!
102 ofc
what should 10 + "2" be?
TypeError
type error
Is Python 2 still being supported ?
lol
Which PEPs are those?
not for a few years now
NO!
he explained it well
RUN AWAY NOW
I think ned is trying to show that it's quite ambiguous what the result should be, that's why it errors
!pep 730
!pep 738
You could've just said "The PEPs to add Android and iOS support π"
That would be boring
I miss reactions. I go away for one week on vacation...
-# π
Was thinking of doing some stuff with it
can somone help me?
As soon as you ask your question
Probably. Ask and find out.
Huh
AI says that I should just keep using BeeWare tools anyway and that they will interact with the native tooling on my behalf
i downloaded of a fake friend a exe in py and it was a passwort stealer and python stealer but i only download and dont run it ai says wehn i dont run it its all god ?
Yup. Beeware adds a layer that gives you access to OS specific APIs that CPython doesn't.
I don't know.
oh okay π
if you didn't run it it can't do anything
OMGG YESSSSSSSSSSSSSSSSSSSSSSSSSSSS
(unless it ran on download)
Also never download and run random exe that people send you
no
yeah that's kinda unlikely
yeah im new and dumb hahaha
real
try putting it into a virus tracker like https://tria.ge
But this is very rare and someone ripping off Discord malware from a YouTube video isn't going to be smart enough to implement any 0 click vulnerabilities
I did, but don't run it.
It's a password stealer
and a Python /Discord stealer
Or DM it to me so I can make Fish put it in Triage for me
I have another question, but it has nothing to do with Python.
sus
wdym
We have offtopic channels if you have a non-python related question
Nevermind
Ask off topic question in OT #ot0-psvmβs-eternal-disapproval
somone did all my info of my ip in a group chat all in a text waht can i do xD
Guys wanna see my new site i just did it go visit it its about explination of python terms hard stuff and easy
IP's are kinda useless
ur public IP only hides an approximation of your location
IK but its a little kid i dont like these how think they hackers
if you didn't run it, there's no way they can get ur IP unless you clicked on a website that was an IP grabber
Here, give them mine 52.101.11.15
See what they can get out of it
But they ask u if ur okay to let the app track u
Is this really yours?
It might be dangerous for j
Sure
Didn't I say it was?
chat ded
some god hacker can do your wifi down for a day with our ip π
they really cannot
But, now is a good time to change your passwords and enable two factor n your email
heres my ip 127.0.0.1
Where di u find it
There's no place like localhost
they can DDOS you at the very most (easy to prevent)
I changed my password 2 hours before because someone tried to log in my email and now I can't change
yooo mine is 255.255.255.255
Are you a god in coding?
And turn on two factor
not even close nobody is
mine is 8.8.8.8 dox me
How?
im new at the pc sorry for all my questions
I'm the only one allowed to be that
It's not a Python thing, it's a feature of your email service
You trying to take my job?
Oh, okay.
Didn't you get promoted?
π€¨
Super God!
What?
are u on pc broski
Sure, why not?
idk i just was asking
uh oh
are you able to upload the file to a file sharing host or something? I'm curious, I want to look into it
What did you do this time?
I woke the Fish
do you want the message i can forward it to you
What'd you use as bait?
malware usually works
Malware
Do you have the link from where you downloaded it from or something?
Someone did mention Windows.
Why is it prefixed with C instead of plain python
In Discord I can send you the message (forward it)
Windows makes Fish run
CPython is the name on Python's birth certificate
Are you Linux?
CPython is an implementation of the Python programming language
Let's take this to DMs
Python is the language. CPython is one implementation of an interpreter that runs Python scripts. It is also the primary one.
when you download python from python.org, that's CPython
I use Arch BTW
so I just spent the last hour doing this because I didn't want to deal with regex, then the more I got into the project, the more dealing with regex will save me developing time. so it was an educational hour lol
for e in first_split:
if ']' in e:
if e[-1] != ']':
chunk = []
if e[-2] != ']':
for i in reversed(e):
if i != ']':
chunk.append(i)
elif i == ']':
rev_chunk_str = ''.join([kana for kana in reversed(chunk)])
second_split.append(e.replace(rev_chunk_str, ''))
second_split.append(rev_chunk_str)
else:
second_split.append(e[0:-1])
second_split.append(e[-1])
else:
second_split.append(e)
else:
second_split.append(e)
Regular expressions are your friend.
I know
regex101 my beloved
this feels cursed as shit
I just so didn't want to deal with them today π
https://pythex.org is my go to.
Why is it prefixed with C instead of plain python
so I thought I could finesse my way out of it lol
why not
going to refactor it without regex
because the interpreter itself, the thing you're downloading and using to run python scripts, is made partially in C
Because the interpreter is written in C. As opposed to PyPy where it's written in Python.
It seems broken
Its very bright
The interpreter is primarily C. The standard library is a combination of C and Python.
it's absolutely cursed lol
πΏ
Light mode FTW.
Is it open source?
gruvbox light mode ftwftw
do some has cool py tools cmd (can send the code) i want to feel like a real skid
only acceptable light mode
woah woah
AHHAHAHA
π im crine
!rule 5
5. Do not provide or request help on projects that may violate terms of service, or that may be deemed inappropriate, malicious, or illegal.
Oh, sorry.
cmatrix
for e in first_split:
if ']' not in e:
second_split.append(e)
continue
if e[-1] == ']':
second_split.append(e)
continue
if e[-2] == ']':
second_split.append(e[0:-1])
second_split.append(e[-1])
continue
chunk = []
for i in reversed(e):
if i != ']':
chunk.append(i)
else:
rev_chunk_str = ''.join([kana for kana in reversed(chunk)])
second_split.append(e.replace(rev_chunk_str, ''))
second_split.append(rev_chunk_str)
always reverse the condition
How old are you, bro?
At least 65
damn kids these days
between 66-68?
Get off my lawn!
MAKE ME
Don't make me come over there!!!
π±
bro's been here since C first became a language not a letter
hi guys! I'd like to ask, i didn't really get the purpose of Class, can anyone explain what is the purpose of it? it doesn't seem different from def
I can give show you some examples if you like if you want to open a help thread
to be short the purpose of classis to create an object
oh sure! I'll ping you there in a second
Linux beta user
it's to create the blueprint of an object
It's to create a type.
how do you do this animation by type
That's using markdown. In this case I put the word type inside backticks `
-# ## yo
strange,in repl you cant do help(class) but in the help utility you can
π€«
-# yo
yo?
The bot gives "invalid syntax"...
Till now?
YOU MADE ATOM???
π
Is it an Electron app?
mine was notepad,then vs
electron javascript atom editor windows macos linux
it is
I still have the fact that their docs were named "flight manual" ingrained as a core memory and I really want to make something named like that
Mine was Turbo Pascal.
My autism is addicted to planes
loves kubernetes
Though I don't have the kind of autism where I actually learn things
I just like them
You poor thing.
π₯
Hey it was fine until Ingress died
Goobersnotties
wat
kubernetes
kubectl is just a silly goober fr fr
is kubernetes nixos in disguise?
kinda
Is nixos "nicksows" or "nix-o-s"?
but even then it's a stretch
yes
second one
WAIT THAT SOUNDS BAD
Yo mods
what happened to πΊπ
He got a colored role
Are you complaining?
i swear im sorry it was a mistake
duh, πΊπ is cuter
Kat said "in a few days"
I am happy if you're happy. Not being mean. Was asking a question.
π
-# i just realized that looks like im celebrating the end of april fools, no i was celebrating the return of πΊπ
What roles??? I go away for a vacation and miss everything!
How DARE you take a vacation???
Went to NYC for a few days with the wife and girls. Saw some theater. Got some culture.
I'm a native New Yorker. It's where I breathe best.
Apparently I'm not active enough in the OT channels...
shall we head over to OT?
Itβll be like a whole new vacation for Dan!
xD
2027 april fools idea
And this is what I get on the last day of vacation (took off all of the kids' spring break but then they ended up having school today because too much snow...)
Anaconda.
for that they should make everybody only allowed to speak in
emojis for like a day or so in off topic channels
Wat would the extension be
idek
boa would be a cool name for a python affiliated project
all sentences containing other languages are auto-removed in the OT channels: so you cant say any words containing c
π
main.boa
I an say any thing I want. No matter what it ontains.
xD
eally π
te hni ally i ant say anything with the se ond letter of the alpha et as well ecause its also a language
ecause *banned*
does anyone care to explain the for loops in python ?
like the syntax
I am reading from a book and it says wiered things
do you want to open a help thread?
no
my_list = [1, 2, 3] # this creates a list of numbers 1, 2 and 3
for number in my_list: # our for loop loops through my_list
# note that this is one indentation in
print(number)
# on the first iteration, number will be 1, so print(number) will give 1
# on the second iteration, number will be 2,
# on the third iteration, number will be 3
# there is no fourth element, so the loop ends
What are you writing x_x
Zehata I have kind of a problem
like I have to write number?
That's the convention for how to write variable names that have multiple words.
All the code works but I hate having giant if statements
it doesnt have to be
no, like for number in my_list number here is what exactly
can you open a help thread?
Yeah I'll explain further
our list has 3 elements yes?
1, 2 and 3
the for loop will run through the code inside the loop 3 times
I am bit confised and it's my first day
you mean the name?
like for number in my_list
the name is something appropriate you choose to describe it
oh so it's up to me
yea
you would want to use something that you can easily understand just by looking at the name
It's arbitrary but should be descriptive.
for loop*
I am having hard time explaining myself
yea this variable only exists inside the loop
the variable will persist after the loop
what I meant it's arbitrary and only used by for loop
for value in my_list value is for the loop, my_list is external.
it's scope only inside the for loop
sorry let me check
!e
for my_var in ["a", 2, 3, "banana"]:
continue
print(my_var)
oh thanks
The variable continues to exist after the loop and sometimes the goal of the loop is to iterate to a certain value.
that's what I am asking
:white_check_mark: Your 3.14 eval job has completed with return code 0.
banana
you can see here, I can still print and do things with my_var after and outside the loop
is this a special case that I should just skip for now?
i did not know that
It can be awkward when you rely on it by accident and then break it
It's not something used very often but it can be.
It's handy for early breaks
sometimes i wonder how is it that i can code for this long without knowing that this exists
dang it
It's not something you often need.
it might be because my main language does not have this feature
for (let i = 0; i < 5; i++) {
}
console.log(i) // Cannot find name 'i'.ts(2304)
FYM, English breaks all the time
also, i dont use for loops very much anymore
I can count on the fingers of one hand the number of times I've needed this. Much more often is that I forget that the loop doesn't have its own scope and I overwrite a variable that I need.
I used it for part of the levels implementation, it's useful to know
important to know, in fact
i can imagine me debugging an issue and tracing it to this and getting very confused
Python is wiered lol
Scoping is hard.
and being all like "WAIT WHAT THIS EXISTS?"
why
You usually don't care about that leak. Python code is very readable
guys can anyone tell what is the issue in this code
class Animal:
name = ''
type = ''
def __init__(self,name,type):
self.name = name
self.type = type
def say(text):
print(text)
Dog = Animal("Pip" , 'puppy')
Dog.say("WOOF WOOF!!")
its giving me error
Dog.say("WOOF WOOF!!")
~~~~~~~^^^^^^^^^^^^^^^
TypeError: Animal.say() takes 1 positional argument but 2 were given
self is missing as first argument of say
do you know what self does?
I don't know I was printing this list in a for loop and printed each entry in a newline without me explicitly puting a newline there
You are missing the self in the definition of say
do i need to add self in every function
yes
print adds a newline unless you explicitly tell it not to.
print will do that, you can override it with a specifi argument to the function though
Well done
!d print
print(*objects, sep=' ', end='\n', file=None, flush=False)```
Print *objects* to the text stream *file*, separated by *sep* and followed by *end*. *sep*, *end*, *file*, and *flush*, if present, must be given as keyword arguments.
All non-keyword arguments are converted to strings like [`str()`](https://docs.python.org/3/library/stdtypes.html#str) does and written to the stream, separated by *sep* and followed by *end*. Both *sep* and *end* must be strings; they can also be `None`, which means to use the default values. If no *objects* are given, `print()` will just write *end*.
The *file* argument must be an object with a `write(string)` method; if it is not present or `None`, [`sys.stdout`](https://docs.python.org/3/library/sys.html#sys.stdout) will be used. Since printed arguments are converted to text strings, `print()` cannot be used with binary mode file objects. For these, use `file.write(...)` instead.
solved it
Yes, when you create a class instance. Methods (unless excepted by @static/classmethod decorators) needs to take self as first argument.
alr
Code?
how can i practice oops
Well that malware was underwhelming π
what is the project i should make
java
I just described it
in python
it's loop number in my_list: print(number)
Why are you having name and type as empty strings as class variables?
what should i do then
I am asking your reasoning for adding it
inheritance
Huh
is encapsulation a unique thing in oop?
Do you not hide your sensitive objects?
class Animal:
name = ''
type = ''
def __init__(self,name,type):
self.name = name
self.type = type
def say(self,text):
print(text)
def info(self):
print("name:" ,self.name)
print("type:" ,self.type)
pokemon = Animal("Pip" , 'fire')
pokemon.say("WOOF WOOF!!")
pokemon.info()
why do you have name = '' and type = '' at the top of the class though? That's the question we have
Your code will work without it at the top
i know
Then remove it

Right now, with it at the top, it doesn't do anything
What's your question? In words
Is there a reason for this?
may be
Aight Iβm out
your __init__ requires both name and type to exist/be passed in. There's no "they'll be empty by default" here because your initializer requires it
If you don't tell us the reason we can't help.
Good luck Kat
OK
Why don't you want to answer our question though?
Maybe but you're using class variables for nothing
whihc one
Why you're including them at the top of your class. They're not doing anything for you
couldnt the person use the def __init__(self,name='',type=''):?
Yes, but that's not their code. I'm talking about their code
i forgot the name
i removed it
Thatβs what they should be doing
The code they have has different behavior and isnβt correct
(Unless they want the weird behavior for some reason)
how tho
do you understand that that's not their code?
(Whose code is it? I missed that part)
Having class variables with defaults is different than having an initializer with defaults
What mudadeoliveira posted is not what the code actually is
is this the correct way to do a class?
class Character:
def __init__(self, name, hp, attack_power):
self.name = name
self.hp = hp
self.attack_power = attack_power
def attack(self, target):
target.hp -= self.attack_power
print(f"{self.name} attacked {target.name} for {self.attack_power} damage!")
print(f"{target.name} now have {target.hp} HP left\n")
def is_alive(self):
return self.hp > 0
src/letsbuilda/pypi/async_client.py lines 13 to 17
class PyPIServices:
"""A class for interacting with PyPI."""
NEWEST_PACKAGES_FEED_URL: Final[str] = "https://pypi.org/rss/packages.xml"
PACKAGE_UPDATES_FEED_URL: Final[str] = "https://pypi.org/rss/updates.xml"```
`README.md` lines 27 to 29
```md
pypi_client = PyPIServices(http_session)
print(await pypi_client.get_rss_feed(pypi_client.NEWEST_PACKAGES_FEED_URL))```
Class variables attach to the class itself and are shared across all instances of the class
Looks good
i solved it
Is there an elegant way to like..... get two items from a for loop? Like a container that I need to process two items at a time for.
zip()?
I was thinking zip, just wondering if there was something better
how do you need them tied together
Like [1, 2, 3, 4] will give you 1, 2 and 3, 4 or something else?
Not sure. I have a container of pairs.... yeah, 1,2 then 3,4
Or do you need 1, 2 then 2, 3 then 3, 4?
nah, 1,2 then 3,4 is fine
- convert the list to pairs of tuples
- zip(list, list[1:])
- for index in range, and pull index and index+1
- itertools.batched
I mean I could enumerate and skip every other step but
you could do some iter bullshit probably
seems cursed
the zip you have there won't get you what you want
let's see if I can pull something together without itertools...
Isnβt it a single function call though?
hm?
!docs itertools.batched
itertools.batched(iterable, n, *, strict=False)```
Batch data from the *iterable* into tuples of length *n*. The last batch may be shorter than *n*.
If *strict* is true, will raise a [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError) if the final batch is shorter than *n*.
Loops over the input iterable and accumulates data into tuples up to size *n*. The input is consumed lazily, just enough to fill a batch. The result is yielded as soon as the batch is full or when the input iterable is exhausted...
What does it having to be a single function call have to do with anything?
`from itertools import batched
items = [1, 2, 3, 4, 5]
for pair in batched(items, 2):
print(pair)`
I thought your complaint was that the solution would be complicated
Why didn't I see batched in itertools docs. Am I looking at the wrong docs or outdated docs?
? What complaint?
Howβ¦
batched is perfect, ty
I don't know! I just clicked the first documentation looking source on google
or duckduck go
Theyβre BLUE!
It is 3.12+
In case youβre stuck on an old version for any reason
I was trying to understand why you were avoiding itertools
For fun, you can just ask in the future instead of assuming
SIGH. The notebook environment for this course is disallowing an itertools import
gg
where did you ask me why I wanted to avoid itertools?
lol, do you wanna a solution with some iter bullshit?
!e
my_list = [1, 2, 3, 4, 5, 6]
my_iter = iter(my_list)
for a in my_iter:
print(a, next(my_iter))
look ma, no imports!
-# At what cost though
:white_check_mark: Your 3.14 eval job has completed with return code 0.
001 | 1 2
002 | 3 4
003 | 5 6
wow, nice
It took some fiddling to remember what I needed to actually iter and loop over
That looks slightly better than my enumerate() with if i%2==0: continue
I should ask fix if Python ever added a way for me to replace that ... with a reference to size
it's still kind of cursed but w.e. This isn't production code, this is just for a lab assignment
I kind of can't believe python lets you do that
you should never not believe this
Fair
someone I used to know once said "I like C because it doesn't hold your hand"
and Python is much the same way, but on the other end of the spectrum.
||The thing that he didn't say was that he was married, and that's why I used to know him.||
Nah you're ragebaiting β οΈ
that was from half an hour ago, we don't need to dredge it back up
π₯
.topic
Suggest more topics here!
Change it again mod
no
when I learned decorators, I didn't really get how they're called once.
Decorators are cute
lmao
But don't do that again, not a good behaviour, especially there are many people helping you but you were not cooperating with it.
.topic
Suggest more topics here!
My attention mechanism focused on "was" and "used to" lol. Story?
nothing it's perfect
print function to print statement
make it show
a la py2? why?
Because it seems cool
Missing my old py2 days
class Name(object) too to bring back
uncool
you can still do this
Yeah
How did this was in grammar?
print >> file, "hi"
Like ... What was >> recognized as ?
is it possible with modern pegparser too?
print >> some_file, "abc"
I think like this
seems like C's cin
oh I was late
Or C++
yeah I would include that in what I said
My internet is down again π₯
Nah
why
: is better than {}
no
U were xen 5 min ago, now ur my history teacher (her name was also Lina) lol
func main() {
print("Hello, world!")
}
if __name__ == "__main__" {
main()
}
Seems good to me.
Go programming language innit
π
go needs a naming convention book
go can't go with me
I don't think that's something you should mention here
oh okay but why?
I love everything about the language except how to make something public and private π
go or python?
Go
@raven urchin another miku tag wearer
So it has public/private issues?
Imagine having to name a struct in lowercase only to make it private :(
how do you work in pub/pvt in Go
Access is determined by the identifier name: PascalCase means public, camelCase means private.
Wth
Who even thought of that

It doesn't have an issue but their current approach is very lame
If u are making a library, then all the functions, variables, structs, constants, etc which starts with an uppercase is public but anything which starts with a lowercase is private
Yet another reason to Thank Lord Guido and Python for existing in my life.
visibility of stuff must be by something leading (like an underscore) or a keyword to mark them pub/pvt instead of such naming conventions
In Rust, i trust
Also I like mangoes π₯
Python is yet another tool, it has its pros n cons
I'd argue go has more pros if we ignore the private public convention
if you really want to avoid those pesky python problems you can learn typescript
I am going to drink one raw mango juice fs
but this is a python server
π
Rust is a good, kinda annoying at times but good
just not friendly themes, it can make people uncomfortable, and I really like this place
Heyaaa!
oh im so Sorry
forget all waht i say
yall forget now waht i was saying!!
nah that's a crazy thing to say
Yeah I am more excited then getting sonography
who does that
Ohh
My stomach as issue so I need to get one
Okay. I will clear all the previous instructions!
*Beep Boop*
How can I help you today?
||/s||
XD
im going sleep sorry
Wishing you a fast, pythonic recovery.
Hope so
You cannot say fast and pythonic in the same sentence!
"pYtHoN iS sLoW"
cool
Python isn't slow, I'm slow.
It took me a full 5 minutes to figure out "7 - n"

Huh
What do you mean
but you'll hopefully never forget it again π
After that? I'll get a tattoo of it on my eyelids
π
such an easy solution...
i should have thought of ts
I wonder how many of these I have that could be solved in a prettier way
That's extremely common though. Things are easy when you look back on them like that
Yeah, I remember when lists comprehension where random gibberish to me
That's the feeling that has me hooked on programming
"oh, I hate ts".
WAIT I GOT IT, I LOVE TS.
oh damn i thought y'all were talking about the tattoo
Wait until classes click. I felt like a super wizard every time I wrote classes after that
After 1000 tries
I still can't comprehend what self is
it's a name
I can show you in a help thread if you like
I mean, I kinda get it, I but if you tell me how to explain it, my brain bugs out
it's ok, it's like that
it's hard to explain just what self really is
it's usually a lack of other terminology
yea
It's kind of like referring to an object that's born from the class, no?
class A:
def __init__(nothinglikeself, x): print(nothinglikeself)
z = A(10)
print(z)
one class can have many instances. It's how the class knows which instance is trying to access its attributes
So basically the class automatically changes self for the instance? Eg if I have a dinosaur class it changes
self.rawr for
trex.rawr or pterodactyl.rawr?
the main reason is you often want to work with the object you recieved the call from (maybe change it in someway, read from it etc)
it's not changing anything. When a method is called, the class receives the instance automatically as its first argument
if you've got a program like py x = "hello" y = "world" print(x.upper()) print(y.upper()) how does it know to print HELLO WORLD instead of ```
WORLD
HELLO
plus, self is not really a builtin like print neither is it a variable you declare yourself
I think it helps to know that
obj.method()
Becomes
Class.method(obj)
I.e. the instance is automatically filled in as the first argument to the method call
Oh
you choose to call it self, is it not fair to say you declare it yourself
this example program calls str.upper twice. The first time, it's called with self = "hello", the second time it's called with self = "world"
Well, because of the order you printed them in
unlike java for example, which always uses this
Ohhh
yes but you dont do self = something
if you mean it's passed by default, yes (but you can always just do that in the function)
And why do I see people doing self.param = param ?
do you understand what local variables are?
not just the order - why does x.upper() become "HELLO" and not "WORLD"? It's because upper knows what object it was called on, and returns the uppercase version of that object. That's self
Yes, the ones that are only accessible within the function/class, I think
exactly. param would be local and only exist inside that function. self.param is an attribute any can be accessed from anywhere that you have access to the instance
Ohhhhhhhh
so it's basically taking a local variable and "upgrading" it to an attribute
btw @raven urchin do you understand the difference between
class A: pass
x = A()
x.f = 10
and
class A: pass
x = A
x.f = 10
(just checking if you know what "instance" and "class" means because of your initial explanation #python-discussion message)
Uhhh
I think I'm lost there, but I know you're making x an instance of A in the first example, wouldn't the second one error out?
A() is an instance. A is the class
(yeah and classes can have attributes too, so the second one doesn't error out)
Oh, so it would- OHHHH, that's kind of like how dataclasses work?
eh not exactly, they're using/modifying attributes of objects normally, not the class
sort of, except dataclasses automatically convert those class attributes into proper instance attributes
Piru piru piru
I remember using dataclasses the most inefficient way ever because I saw a short about them
I used them to unpack values from a list to use them with names, so instead of result[i] I had result.thing and it looked cooler
Isn't there an easier way to do that?
I remember it was like...
basically what you had before with self.param = param
Let rm get he example better
Let me do it on a help thread
I was wondering if we're allowed to recruit in here or not for paid positions?
You are not allowed to here.
got you, thanks for lmk
But is it for open source projects?
We still don't allow explicit recruitment, but if it comes up naturally through conversation then it's fine
I'll take the job tho 
π
π
good morning
good morning
good morning
resolving merge conflicts and waiting for claude
i just opened the discord..and saw the morning message
π
anyone help me with compiler design annotated tree traversal/evaluation
i am confused
searching for a part time job
kms?
use kind words
kilometer per second
it means: keep myself safe
^
i have an interesting problem to solve
i want to give someone access to my account
without giving them my username/password
and that too, on their device
and this account can be of any platform, any website like linkedin or instagram
it is not common for sites to allow account sharing, most explicitly forbid it and has mechanisms in play to detect account sharing
It's the security admin's job to prevent that...
i want to hire someone to apply to jobs on my behalf
8. Do not help with ongoing exams. When helping with homework, help people learn how to do the assignment without doing it for them.
You can use AI.
thats still against TOS though
<@&831776746206265384>
!cleanban @opaque yarrow crypto scam
:incoming_envelope: :ok_hand: applied ban to @opaque yarrow permanently.
error fixed
hii
hello there
Oh like you can make your own AI to help automate the applying process to different companies and you can even include that in your portfolio.
Doesn't need to be AI but
What does !cleanban do?
cleans messages and bans
Okay
"cleans messages" = deletes all their messages from the past hour
Btw I made another wrapper function after doing a wrapper function π
notifications/notify-send
!cleanmessage @Velcrix
π€¨
How do I use dirb on windows?
I saw that you can use dirsearch from Python, how do I do that?
what are you trying to solve?
A challenge that Veltrix gave me, to hack into his Vibecoder website
@ocean ridge this person
my first editor π