#voice-chat-text-0

1 messages · Page 99 of 1

raven path
#

which one best nextjs or expressjs

gilded vector
#

freecodecamp any good?

wary haven
#

you can build everything with any framework, so just look for mastery something, I would go to nextjs

warped raft
#

hey @somber heath

#

just have a look now

#

on the readme

craggy breach
#

`javac Main.java`

somber heath
#

@hoary kayak👋

rugged root
lucid blade
#

waves

scenic quiver
#
def decor(func):
    def wrap():
        print("============")
        func()
        print("============")
    return wrap

def print_text():
    print("Hello world!")

decorated = decor(print_text)
decorated()
lucid blade
#

going to do some shopping bbl

scenic quiver
#

!e

def decor(func):
    def wrap():
        print("============")
        func()
        print("============")
    return wrap

def print_text():
    print("Hello world!")

decorated = decor(print_text)
decorated()
wise cargoBOT
#

@scenic quiver :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 | ============
002 | Hello world!
003 | ============
scenic quiver
#

What is the role of wrap here?

rugged root
#

So wrap is the functionality or other things you're wanting to do to the decorated function

scenic quiver
#

!e

def decor(func):
        print("============")
        func()
        print("============")

def print_text():
    print("Hello world!")
decorated = decor(print_text)
decorated()
wise cargoBOT
#

@scenic quiver :x: Your 3.11 eval job has completed with return code 1.

001 | ============
002 | Hello world!
003 | ============
004 | Traceback (most recent call last):
005 |   File "/home/main.py", line 9, in <module>
006 |     decorated()
007 | TypeError: 'NoneType' object is not callable
rugged root
#

The point of the other version (the function within a function), is that you're returning a function

scenic quiver
#

I would like to know the reason for the error. I see the output here in 2nd code but the error is added

gilded vector
#

like the game Rust?

scenic quiver
rugged root
#

So note the difference between the two decor functions:

def decor(func):
    def wrap():
        print("============")
        func()
        print("============")
    return wrap

def decor(func):
        print("============")
        func()
        print("============")
craggy breach
rugged root
#

Yep

#

When you don't have an explicit return in a function, you're returning None

#

A function/method always has to return something

scenic quiver
#

!e

def decor(func):
        print("============")
        func()
        print("============")
        return 0

def print_text():
    print("Hello world!")
decorated = decor(print_text)
decorated()
wise cargoBOT
#

@scenic quiver :x: Your 3.11 eval job has completed with return code 1.

001 | ============
002 | Hello world!
003 | ============
004 | Traceback (most recent call last):
005 |   File "/home/main.py", line 10, in <module>
006 |     decorated()
007 | TypeError: 'int' object is not callable
scenic quiver
#

!e

def decor(func):
        print("============")
        func()
        print("============")
        return 1

def print_text():
    print("Hello world!")
decorated = decor(print_text)
decorated()
wise cargoBOT
#

@scenic quiver :x: Your 3.11 eval job has completed with return code 1.

001 | ============
002 | Hello world!
003 | ============
004 | Traceback (most recent call last):
005 |   File "/home/main.py", line 10, in <module>
006 |     decorated()
007 | TypeError: 'int' object is not callable
scenic quiver
#

🥲

rugged root
#

So things like integers can't be "called"

scenic quiver
#

So, we use wrap to return wrap?

rugged root
#

Yep, we return a new function

#

decorated ends up being wrap

#

But still called decorated

scenic quiver
#

Means we return everything present inside the function?

#

Like func, information present inside print

#

..etc.

rugged root
#

Yep yep

#

It's a prepackaged, new function

#

Kind of like an object from a class. All that functionality is bundled into the new function

#

The benefit is that we can add functionality or consistency on a function

scenic quiver
#

Got it!

#

!e

def is_even(x):
    if x == 0:
        return True
    else:
        return is_odd(x-1)

def is_odd(x):
    return not is_even(x)


print(is_odd(17))
print(is_even(23))
wise cargoBOT
#

@scenic quiver :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 | True
002 | False
scenic quiver
#

What's the use of doing like this? What's the difference will it make if I simply put if x%2==0: return 'Even' etc.?

rugged root
#

There really isn't a point in this case

grand plover
#

HE IS MY FATHER

#

well dowloanding some aws courses

scenic quiver
#

Aws interesting!

#

I recently got certified as AWS cloud practitioner

grand plover
#

i think a good for an

warped raft
#

Bye @somber heath

grand plover
#

IT guy to have a Aws certification

warped raft
#

bye @rugged root

scenic quiver
#

Yeah, AWS is interesting!
EC2 Instances, Load balancer.. etc.

rugged root
#

All the devops stuff scares me

scenic quiver
#

I am not into devops, i am into data science only! Looking for people who can help me in SQL

#

Via voice chat discussions

amber raptor
somber heath
#

Edith Piaf is the shit.

rugged root
#

Haven't heard of vsPY before

#

Okay, NORMALLY there aren't streams in here....

#

This ah...

#

Yeah

craggy breach
#

you don't need global current_color, colors

rugged root
#

They do

#

They're modifying index

craggy breach
#

I didn't include index

#

in my msg

#

they can leave it as only global index

#

yes

rugged root
#

Maybe have colors as COLORS just to show it's not changing

craggy breach
#

you are not reassigning what current_color refers to

#

yep, you're modifying current_color not reassigning

grand plover
rugged root
rugged tundra
rugged root
#

I have no idea

#

But I love it so much

rugged tundra
#

Conan

somber heath
#

I've said it before. I like bees.

grand plover
#

i dont like bees

#

it bite

#

and hard

grand plover
#

well my english is to littler in order to express what ever i want to express

rugged root
#

Bees are great

#

Wasps on the other hand

#

Wasps are assholes

craggy breach
#

bees are important

#

really important

somber heath
#

"It belongs in a museum!"

#

Nick's OS.

craggy breach
#

TempleOS

rugged root
#

Yeah that's what I heard

grand plover
#

xd

rugged root
#

Walking from his car

grand plover
stuck furnace
#

👋

grand plover
#

gaming in linux very horrible

#

that vine app is horrible too

#

oh true the steam app for linux is there

#

which is suppose to make gaming in linux much more easy

somber heath
#

If more people used Linux, more devs would target it.

#

So if we want Linux games, we've got to use Linux.

#

Or, perhaps more the point, to not use Mac or Windows.

#

But to each their own.

amber raptor
somber heath
#

I don't disagree.

grand plover
#

i will keep using linux for hacking mean while i wait for the good gaming in linux

amber raptor
#

It’s not going to happen but Linux desktops need all Linux UI devs to pick a single distro and stick to it.

grand plover
#

the rabbit hole regedit vocabulary

amber raptor
stuck furnace
#

Apparently doors are really hard to get right 😄

grand plover
#

i good project might be to do a windows game emulador for linux

amber raptor
grand plover
#

i will try it much more later

#

google lost a lot of money

#

but still have the same amount of client

#

the lost money because all the unsucefull projects they made

#

plus the made google map for free

pallid hazel
#

@rugged root got a min for some selenium help 🙂

earnest quartz
craggy breach
#

lol

swift pumice
#

👋🏼

scenic quiver
#

Hi

#

!e

class A:
  def method(self):
    print(1)

class B(A):
  def method(self):
    print(2)

B().method()
wise cargoBOT
#

@scenic quiver :white_check_mark: Your 3.11 eval job has completed with return code 0.

2
scenic quiver
#

Intersting! So, we can even define classes without __ init __

craggy breach
#

sure

#

it looks up the inheritance chain to find it tho

somber heath
#

!e ```py
class A:
def init(self):
print("Hello, world.")

class B(A):
pass

B()```

wise cargoBOT
#

@somber heath :white_check_mark: Your 3.11 eval job has completed with return code 0.

Hello, world.
craggy breach
#

!e

print(dir(object))
wise cargoBOT
#

@craggy breach :white_check_mark: Your 3.11 eval job has completed with return code 0.

['__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__']
somber heath
#

!e ```py
class A:
pass

A()```

wise cargoBOT
#

@somber heath :warning: Your 3.11 eval job has completed with return code 0.

[No output]
craggy breach
#

A inherits from object

#

hmm

somber heath
#

!e ```py
class A:
pass

print(A.mro())```

wise cargoBOT
#

@somber heath :white_check_mark: Your 3.11 eval job has completed with return code 0.

[<class '__main__.A'>, <class 'object'>]
scenic quiver
#
class A:
   def __init__(self,n):
      print(self.n)
   def method(self):
      print(1)

class B(A):
  def method(self):
    print(2)

B(5).method()
craggy breach
#

!e

class Sus(type):
    def __init__(self, *args, **kwargs)
        del self.__init__

class A(metaclass=Sus):
    pass


A()
wise cargoBOT
#

@craggy breach :x: Your 3.11 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 1, in <module>
003 |     class A:
004 |   File "/home/main.py", line 2, in A
005 |     del A.__init__
006 |         ^
007 | NameError: name 'A' is not defined
craggy breach
#

welp

scenic quiver
#

!e

class A:
   def __init__(self,n):
      self.n=n
   def method(self):
      print(1)

class B(A):
  def method(self):
    print(2)

B(5).method()
wise cargoBOT
#

@scenic quiver :white_check_mark: Your 3.11 eval job has completed with return code 0.

2
scenic quiver
#

!e

class A:
   def __init__(self,n):
      print(self.n)
   def method(self):
      print(1)

class B(A):
  def method(self):
    print(2)

B(5).method()
wise cargoBOT
#

@scenic quiver :x: Your 3.11 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 11, in <module>
003 |     B(5).method()
004 |     ^^^^
005 |   File "/home/main.py", line 3, in __init__
006 |     print(self.n)
007 |           ^^^^^^
008 | AttributeError: 'B' object has no attribute 'n'
scenic quiver
#

What's the issue?

craggy breach
#

what it says

scenic quiver
#

!e

class A:
   def __init__(self,n):
      self.n=n
   def method(self):
      print(self.n)

class B(A):
  def method(self):
    print(2)

B(5).method()
wise cargoBOT
#

@scenic quiver :white_check_mark: Your 3.11 eval job has completed with return code 0.

2
scenic quiver
#

!e

class A:
   def __init__(self,n):
      self.n=n
   def method(self):
      print(self.n)

class B(A):
  pass
B(5).method()
wise cargoBOT
#

@scenic quiver :white_check_mark: Your 3.11 eval job has completed with return code 0.

5
scenic quiver
#

Got it

#

So, we need to initialise value using self.value=value first and then we can use it to print right?

rugged root
#

Yep

#

Otherwise it's not bound to the object

scenic quiver
#

Cool

#
class Shape: 
    def __init__(self, w, h):
        self.width = w
        self.height = h

    def area(self):
        print(self.width*self.height)

class Rectangle(Shape):
    def perimeter(self):
        print(2*(self.width+self.height))
    #your code goes here
    

w = int(input())
h = int(input())

r = Rectangle(w, h)
r.area()
r.perimeter()
#

How does Rectangle class know about self.width and self.height?

craggy breach
#

Cuz it inherits from Shape that gives it those attributes upon initialization

scenic quiver
#

I see

craggy breach
#

you sure?

lucid blade
#

and there's this ...

#

a local guy from my home town ... https://youtu.be/watKJpSMS6s

This Electrician from Wolverhampton rigged his van with 1000v to stop tool thieves.

Previously he has had over £5000 worth of tools stolen so he took things into his own hands!

Remember to like, comment and subscribe!

Check out our top 10 videos here https://bit.ly/3y65crl

Facebook - https://bit.ly/3y1GgkS
TikTok - https://bit.ly/33zNSNy
Tw...

▶ Play video
scenic quiver
#

!e

class Shape: 
    def __init__(self, w, h):
        self.width = w
        self.height = h

    def area(self):
        print(self.width*self.height)

class Rectangle(Shape):

    def __init__(self,w,h):
        super().__init__(w,h)
    def perimeter(self):
        print(2*(self.width+self.height))
    #your code goes here
    

w = int(input())
h = int(input())

r = Rectangle(w, h)
r.area()
r.perimeter()
wise cargoBOT
#

@scenic quiver :x: Your 3.11 eval job has completed with return code 1.
:warning: Note: input is not supported by the bot :warning:

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 18, in <module>
003 |     w = int(input())
004 |             ^^^^^^^
005 | EOFError: EOF when reading a line
rugged root
#

Can't do inputs in the eval

#

Gotta use hard coded values

#

(specifically for the one here)

scenic quiver
#

!e

class Shape: 
    def __init__(self, w, h):
        self.width = w
        self.height = h

    def area(self):
        print(self.width*self.height)

class Rectangle(Shape):

    def __init__(self,w,h):
        super().__init__(w,h)
    def perimeter(self):
        print(2*(self.width+self.height))
    #your code goes here
    

w = 10
h = 8

r = Rectangle(w, h)
r.area()
r.perimeter()
wise cargoBOT
#

@scenic quiver :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 | 80
002 | 36
rugged root
lucid blade
rugged root
#

Hnnnngggggg. I want to code something, but I can't really work on the Mahjong thing while I'm at work

#

Hard to justify gaming looking windows

lucid blade
rugged root
#

Riichi Mahjong

gentle flint
#

ah

rugged root
#

4 player game

craggy breach
#

w/ GUI?

#

what lib?

gentle flint
#

I'm looking for a chinese competition rules mahjong multiplayer game

rugged root
#

It'd be done in Godot

#

Which is the problem at the moment, I do most of my coding at work

#

Harder to justify coding when I'm doing it in a game engine

craggy breach
#

use pygame-ce

lucid blade
rugged root
#

@jaunty lintel 143564484970151936

#

Whoop, sorry random person

#

!stream 143564484970151936

wise cargoBOT
#

✅ @upbeat leaf can now stream until <t:1678724608:f>.

upbeat leaf
knotty dock
#

@somber heath are you here?

somber heath
#

I am.

zenith radish
knotty dock
somber heath
#

No.

#

Is there something you'd like to ask?

knotty dock
#

yes yes

#

ive got a query

scenic quiver
#

SQL query?

knotty dock
#

how when your defining a function can you format a variable with no value into it but you cant when its just a normal string

#

i know its probably pretty basic but im struggling on the logic behind it

rugged root
#

I'm not quite following what you mean. Are you meaning having a default value?

knotty dock
#

yh

#

wait

rugged root
#
def my_function(user_string=""):
  ...

Something like that?

knotty dock
#

yesss

#

but they done it without the question marks

#

i mean quotation

knotty dock
#

doesnt a variable have to have a value in order to print

zenith radish
lucid blade
rugged root
grand plover
#

amd and intel might start a fight for the faster cpu in 2024

knotty dock
rugged root
#

Ah yeah. That'll fail if they don't pass anything

#

It'll complain about expecting an argument and not getting one

lucid blade
#

def hello(greeting = ""):

knotty dock
#

is that just defining the varaible in the function

#

or adding value

#

however you say it

grand plover
#

its should return 0

#

i guess

#

o probably it should return none or null

lucid blade
#

@knotty dock if greeting is not provided it will use "" as the default string

somber heath
grand plover
#
def hello_func(greeting):
  return "hello" + '{} Function.'.format(greeting)

print(hello_func('HI'))  
tidal shard
somber heath
grand plover
#

ie def hello_func(greeting):
return "hello" + '{} Function.'.format(greeting)

print(hello_func('HI'))

somber heath
#

Or

#

no

#

I read it as the other way around.

craggy breach
#

also f strings 🙄

somber heath
#

I don't know.

#

It's open to interpretation. (re: dice)

grand plover
#

i just tryed to return a string so it does not give an error

somber heath
#

Knife fraud. I never thought I'd see the day.

knotty dock
craggy breach
#

return "hello{} Function".format(greeting)

paper karma
#

wow the bot prevention on this is pretty solid

rugged root
#

Hmm?

grand plover
#

the easy way to reset the greeting function is making greeting = to none, like def hellofunc(greeting = ""):

grand plover
#

i a noob a python and my example is wrong

#

i will try to improve my example

knotty dock
#

print(hello_func('HI'))
how is it printing hi when there is no value for greeting?

#

thats what i dont get

lucid blade
#

because your passing it

#

call the function like this

#

hello_func()

grand plover
#
def hello_func(greeting):
  ''.format(greeting)
  return greeting

print(hello_func('HI'))
#

this might work

lucid blade
#

instead of passing ("hi")

rugged root
#

@upbeat leaf Can you try turning Krisp back on?

grand plover
#
def hello_func(greeting):
  "".format(greeting)
  return greeting

print(hello_func("HI"))
rugged root
#

We're getting breathing noise now

knotty dock
#

i think im just being stupid

knotty dock
#

i know the code works

#

i just dont understand how it does it

grand plover
#

ahhhhhhh

knotty dock
#

so if i need to replicate it later on i wont be able to

lucid blade
#

@paper karma welcome 🙂

grand plover
#

.format(greeting) do make the variable greeting to none

#

i guess

#

but it is a function that return greeting

craggy breach
#

just use f strings

return f"{greeting} function."
paper karma
lucid blade
#

😉

paper karma
#

I'm trying to remember where to go for this google email verification thing for self hosted emails lol

knotty dock
#

so when you put an unknown variable into a function and return it . it gives it value

#

@grand plover

grand plover
#

when you use the return the variable next to the return will be returned, the return can return a variable or an array

#

you can only uses the return with a function

knotty dock
#

do

#

thank you for helping btw

#

i forgot to say

grand plover
#

that code should return the "hello"

#

and the greeting should be ignore

#

on that code

knotty dock
#

so is it kind of pointless to put the .format(greeting)

grand plover
#

yes

knotty dock
#

ahh

#

does the code still work because youre not formating anything into the {}

grand plover
#

it should give a error because the variable is empty

knotty dock
#

thats what im saying but it doesnt

grand plover
#

but then the code will reset the variable

#

to none

#

and the return will return none

#

what does format do?

knotty dock
#

i thought it put whatever was in the bracket into the {}

molten pewter
grand plover
#

so yes greeting will go to the {}

#

it is call interpolation

#

can some one else help gilzene

#

i am noob

knotty dock
#

and because it has no value is that why hi will go in place of the {}

craggy breach
#

what's the issue exactly?

knotty dock
#

idek at this point ngl

rugged root
#

Start from the beginning

knotty dock
#

okay.

rugged root
#

The original thing posed was:

def hello_func(greeting):
  return "{} Function".format(greeting)

print(hello_func("Hi"))

Or something like that, right?

knotty dock
#

yes

#

that code works

rugged root
#

In some cases

#

!e

def hello_func(greeting="Yo"):
  return "{} Function".format(greeting)

print(hello_func("Hi"))
print(hello_func())
#

It won't work in the case of no argument

#

Now, you can MAKE it work by adding a default

knotty dock
#

is that what the 'hi' is

#

a default

rugged root
#

!e

def hello_func(greeting="Yo"):
  return "{} Function".format(greeting)

print(hello_func("Hi"))
print(hello_func())
wise cargoBOT
#

@rugged root :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 | Hi Function
002 | Yo Function
rugged root
#

In this case, that's what "Yo" is

#

This means that if there are no arguments passed, it'll just use the "Yo" instead

knotty dock
#

okay

rugged root
#

This helps us prevent errors about not passing enough arguments

#

Now, that can also be an empty string

knotty dock
#

just one thing

#

how does the .format() part work

rugged root
#

It works in a couple different ways. The most basic way is that it will look for any {} curly braces, and fill those slots with the arguments passed to .format(), in this case greeting

#

As an example:

knotty dock
#

thats what confuses me

rugged root
#

!e

ham = "pork"
eggs = "spam"

print("I love {} and {}".format(ham, eggs))
wise cargoBOT
#

@rugged root :white_check_mark: Your 3.11 eval job has completed with return code 0.

I love pork and spam
rugged root
#

Now, we can do another thing with it

knotty dock
rugged root
#

Honestly this is why I just prefer f-strings

knotty dock
#

you had to give the variable value before you could put it in format()

rugged root
#

!e

ham = "pork"
eggs = "spam"

print(f"I love {ham} and {eggs}")
wise cargoBOT
#

@rugged root :white_check_mark: Your 3.11 eval job has completed with return code 0.

I love pork and spam
knotty dock
#

so how is it just allowing it in ef hello_func(greeting):
return "{} Function".format(greeting)

rugged root
#

Same result, much clearer as to what goes where

#

So before the value is actually returned, .format() executes

#

THEN the new string, the one where you put the new values in, is passed out of the function

#

return has the lower priority

#

So it'll only actually return the value once everything on the right has resolved itself

paper karma
#

@lucid blade I may jump down to cloud for a bit

knotty dock
rugged root
#

It's not a waste to me

#

I love teaching

knotty dock
#

ah alright thank you

#

i just dont quite get

#

you see in your first example

rugged root
#

Right

knotty dock
#

you didnt need to preset greeting to anything

knotty dock
#

you put ham= 'pork'

#

i dont get how

grand plover
#

appaerently the format pass the greeting to the {}

rugged root
#

!e Let me rework that:

def breakfast(meat, other_meat):
  return f"I love {meat} and {other_meat}"

print(breakfast("ham", "bacon"))
wise cargoBOT
#

@rugged root :white_check_mark: Your 3.11 eval job has completed with return code 0.

I love ham and bacon
knotty dock
#

yh

rugged root
#

So when you pass something as an argument (in this case "ham" and "bacon"), those values get caught by the parameters of the function definition (in this case meat and other_meat)

#

That's kind of equivalent to meat = "ham" and other_meat = "bacon"

knotty dock
#

ah okay

#

so you're pretty much filling in the space

rugged root
#

Exactly

#

In the order that you pass them

knotty dock
#

thats what i was confused about

rugged root
#

Sometimes you just need it explained in just the right way

knotty dock
#

yes mr.hemlock thank you alot

#

i was honestly baffled

rugged root
#

Any time! Like I said, I love teaching about this stuff

#

!code @whole bear

wise cargoBOT
#
Formatting code on discord

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

For long code samples, you can use our pastebin.

pure elk
#

very carefully

stuck furnace
#

breakfast('Hemlock', 'his dad jokes') 👀

rugged root
#

❤️

pure elk
#

I identify myself as a crab hidden beneath human skin behind a computer

rugged root
#

"Whelp, I can only use two of these fingers at a time. Curse you hidden claws!!!"

rugged root
#

Dude my hands are really shaky

nimble lark
#

yoi

#

no one in the game dev help channel is online

#

can someone help me

pure elk
#

damn, is that a recent thing?

I remember my vietnam vet buddy, we'd go shooting together, he had the shakiest hands tho. still had pretty good aim tho

nimble lark
#

wtf

pure elk
#

heya @lucid blade

lucid blade
#

🙂

pure elk
rugged root
nimble lark
#

im making a game

#

where

#

its just like space shooter

#

exept planes and shit

#

i got all the movement and spawning of enemies however i cant make either shoot bulletes

#

im using pygame btw

#

idk how to actually ask you guys the question cause idk what wrong with my code

pure elk
#

CoTangent, join the vc

#

@lucid blade said he may have some code for that

nimble lark
#

alr

lucid blade
#

^ there's code for projectiles in there somewhere

knotty dock
#

Mr. Hemlock

lucid blade
rugged root
#

Oh good, my headset is borked

pure elk
#

oof

#

thanks @lucid blade ur awesome

rugged root
pure elk
#

yaaay

knotty dock
#

its not to important as i understand it now

rugged root
#

Oh fair enough

knotty dock
#

but it why can you not put

nimble lark
knotty dock
#

' ' --- into the breakfast(meat, other_meat)

rugged root
#

So as in

#
def breakfast(meat, other_meat):
  return f"I love {meat} and {other_meat}"

print(breakfast(meat, other_meat))
pure elk
#

truuuuuuue, all banks are sketchy

knotty dock
#

yh like wa

#

h

#

what is the rule that doesnt allow you to replace the meat and other meat with ''

#

' '

#

they both mean nothinh

nimble lark
#

whats with the raindbow logo

#

for discord

#

server

craggy breach
#

not quite a rainbow

#

looks like glitter to me

rugged root
#

!e So you could do:

ham = "pork"
eggs = "spam"
meat = "bacon"
other_meat = "chicken"

def breakfast(meat, other_meat):
  return f"I love {meat} and {other_meat}"

print(breakfast(ham, eggs))
print(breakfast(meat, other_meat))
wise cargoBOT
#

@rugged root :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 | I love pork and spam
002 | I love bacon and chicken
craggy breach
#

eggs could be considered a future meat, yeah

rugged root
#

Well played

rugged root
#

So this goes into something called "scope"

#

There are technically two separate sets of meat and other_meat

#

There is the one that's outside the function (often called the global scope), and the one in the function.

#

We'll look back at this example as reference:

ham = "pork"
eggs = "spam"

def breakfast(meat, other_meat):
  return f"I love {meat} and {other_meat}"

print(breakfast(ham, eggs))
#

So when we pass the arguments into the function, they're caught by the parameters. meat = ham and other_meat = eggs, right?

knotty dock
#

yh

rugged root
#

!e But what if we try to reuse meat and other_meat outside of the function?

ham = "pork"
eggs = "spam"

def breakfast(meat, other_meat):
  return f"I love {meat} and {other_meat}"

print(breakfast(ham, eggs))
print(meat, other_meat)
wise cargoBOT
#

@rugged root :x: Your 3.11 eval job has completed with return code 1.

001 | I love pork and spam
002 | Traceback (most recent call last):
003 |   File "/home/main.py", line 8, in <module>
004 |     print(meat, other_meat)
005 |           ^^^^
006 | NameError: name 'meat' is not defined
rugged root
#

We can't do that. meat and other_meat only exist within the scope of the function

#

Once the function is done, they get thrown away

#

Now we can see that we can use the same names as those outside the function (which is called shadowing), but the actual variables from inside that function are gone

knotty dock
#

ok that makes sense

#

or something like that

#

or more like while l == pork

#

is it like the l

#

as its temporary

#

and only exists inside

#

maybe im not making sense

rugged root
#

Yeah not fully following

#

In Python, if statements and the loops (for and while) do not have their own scope

#

So for i in range(5):, i will still exist after the for-loop completes

knotty dock
#

oh okay

rugged root
#

That isn't necessarily the case for all languages, but in Python, those variables stick around

#

HOWEVER

knotty dock
#

so i couldnt use i after

rugged root
#

Oh you can

#

!e

for i in range(2):
  print(i)
print()
print(i)
wise cargoBOT
#

@rugged root :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 | 0
002 | 1
003 | 
004 | 1
rugged root
#

Did the middle print just to make space

#

You can use i after it, but it's typically not recommended to do so

knotty dock
#

alright makes sense

#

thank you thank you

rugged root
#

Happy to help

#

Actually I wonder if that behavior is in the Python specification or if it's just an implementation detail...

#

Just me musing, sorry

craggy breach
#

also list comps and gens have their own scope, which causes some trouble sometimes (mentioning cuz it's basically a for loop)

knotty dock
#

whats an implementation detail

rugged root
#

So the Python interpreter that we normally use (the one you get from python.org) is known as CPython

#

It's written using the C language, hence the name. It's from the Python Software Foundation, it's their standard example of how you can implement the language.

#

Now, there are other implementations in other languages, although none are as fleshed out or commonly used as CPython

knotty dock
#

little bit dumber pleas

#

what does implementation mean

#

lmao

#

is it the same thing in real life as it is in code

rugged root
#

Things like Jython (Python interpreter written in Java) and IronPython (Python interpreter written in C#)

knotty dock
#

ah okay

#

pythons actually pretty interesting ngl

amber raptor
#

Both of those have poor support

rugged root
#

True

knotty dock
#

what would you recommend to do to get better

rugged root
#

But it's just examples of what I mean

#

Hmm

#

Going over some of the resources if you haven't already

#

!resources

wise cargoBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

rugged root
#

And just futz around, look into things that catch your interest, try them, break them, try them again

#

Ask questions

craggy breach
rugged root
#

True

knotty dock
#

okay nice nice @rugged root you should be a teacher irl

#

better than any of the ones i had

rugged root
#

Maybe someday, who knows

knotty dock
#

actually miss macmillan was pretty cool

#

yh

rugged root
#

@floral anvil Sorry, only just saw your message. Check out the #voice-verification channel. That'll tell you what you need to know about the voice gate

mild quartz
vocal basin
#

@mild quartz doesn't RNA actually have a higher density than DNA?

mild quartz
#

why?

vocal basin
#
  • Thymine is larger than Uracil
    (is DNA just better packed than RNA even despite that?)
#

forms being submitted are usually post requests

#

@slim edge don't paste multi-line scripts into REPL

#

if you want a hacky solution, there is one

#

what are you using for input?

#

input()?

slim edge
#

Yes exactly input()

vocal basin
#

so, if you want your program to take multi-line input, you need some way to tell it where it ends

#

for example, you can end the input when you have "\n\n"

#

or on EOF

#

depending on the usecase

knotty dock
slim edge
#

When pasting the multi-line text into the console then it jumps over to the next input() without possibility to add "\n\n"

vocal basin
vocal basin
slim edge
#

If i have
ABC
DEF
In my clipboard, then pasting that into the python-console, it's going to jump over the next input()

vocal basin
slim edge
#

Okey, what is the preferred function?

vocal basin
craggy breach
#

you can do sth like

lst = []
while True:
    user_input = input()
    if user_input == "end":
        break
    lst.append(user_input)

result = "\n".join(lst)
print(result)

to get multiline input
user has to type end and press enter to exit

slim edge
slim edge
vocal basin
slim edge
slim edge
slim edge
#

The second input() i can add any kind of word to

vocal basin
slim edge
craggy breach
#

I made that example specifically for multi line text input

vocal basin
lament barn
#

hi guys someone can help me in a python issue?

craggy breach
#

sure

lament barn
#

hi

#

yeah so

#

i ahve this problem when i try to install a module idk if the module does'nt existe at all if yes can you help me replace the code to be functional

craggy breach
#

sure it's not called colorplus?

lament barn
#

idk can u confirm?

craggy breach
lament barn
#

idk can send you the code to check it if u want

#

can we in this channel send files?

craggy breach
#

it's not on pypi

#

so uhh, yeah, you can't install it like that, mby you have a wheel for it?

lament barn
#

no

craggy breach
lament barn
#

oh probably to be honest im not a dev i just simply trying to find help on this problem that i struggle on for 1 week

#

but we can't make screenshare this could be useful to be efficent

craggy breach
#

mhm, yeah, just do pip install pyfiglet

#

and the module will probs be named sth different but yeah

lament barn
#

the code is here

#

what's the format to send it like a .txt?

#

but in color on this channel?

craggy breach
#

you can use a pasting service for that

#

I'm not sure what code you want to show tho, since the issue is that you don't have a module in your environment

wise cargoBOT
#

Hey @lament barn!

You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.

lament barn
#

this is the code

craggy breach
#

I'm not sure what to do with it

lament barn
#

it's a checker that check some numbers

craggy breach
#

ok, still no clue what you want me to do with it

#

and the code's too long

slim edge
still shell
#

hello

paper karma
#

what's poppin' bud?

scenic quiver
#

!e

class Rectangle:
    def __init__(self, width, height):
        self.width = width
        self.height = height

    def calculate_area(self):
        return self.width * self.height

    @classmethod
    def new_square(cls, side_length):
        return cls(side_length, side_length)

square = Rectangle.new_square(5)
print(square.calculate_area())

wise cargoBOT
#

@scenic quiver :white_check_mark: Your 3.11 eval job has completed with return code 0.

25
scenic quiver
craggy breach
#

evaluates to Rectangle.new_square(Rectangle, 5)

#

or sth like that?

scenic quiver
#

Based on what I see, we are trying to just add new values in place of width and height by using class method which is helping it to calculate area for other shapes. Is my understanding correct?

#

I didn't understand cls and why do we return cls?

craggy breach
#

cuz it's Rectangle

scenic quiver
#

Are we returning a class?😮

craggy breach
#

cls inside that method is Rectangle, you can literally replace it with Rectangle when returning, same thing

digital latch
#

Hello

#

anybody can help me

craggy breach
#

mby

scenic quiver
#

!e

class Rectangle:
    def __init__(self, width, height):
        self.width = width
        self.height = height

    def calculate_area(self):
        return self.width * self.height

    @classmethod
    def new_square(Rectangle, side_length):
        return Rectangle(side_length, side_length)

square = Rectangle.new_square(5)
print(square.calculate_area())

wise cargoBOT
#

@scenic quiver :white_check_mark: Your 3.11 eval job has completed with return code 0.

25
craggy breach
#

okay, not quite what I meant

craggy breach
#

cuz now it's no different at all

digital latch
#

anybody know how to fix thí

#

this

craggy breach
#

!e

class Rectangle:
    def __init__(self, width, height):
        self.width = width
        self.height = height

    def calculate_area(self):
        return self.width * self.height

    @classmethod
    def new_square(cls, side_length):
        print(cls is Rectangle)
        return Rectangle(side_length, side_length)


square = Rectangle.new_square(5)
print(square.calculate_area())
wise cargoBOT
#

@craggy breach :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 | True
002 | 25
scenic quiver
#

Wow

#

So, this classmethod above is doing this job right?

#

i mean '''@classmethod'''

craggy breach
#

yeah

scenic quiver
#

Cool

scenic quiver
#

!e

class Pizza:
    def __init__(self, toppings):
        self.toppings = toppings

    @staticmethod
    def validate_topping(topping):
        if topping == "pineapple":
            raise ValueError("No pineapples!")
        else:
            return True

ingredients = ["cheese", "onions", "spam"]
if all(Pizza.validate_topping(i) for i in ingredients):
    pizza = Pizza(ingredients)

wise cargoBOT
#

@scenic quiver :warning: Your 3.11 eval job has completed with return code 0.

[No output]
scenic quiver
#

!e

class Pizza:
    def __init__(self, toppings):
        self.toppings = toppings

    def validate_topping(self):
        if self.toppings == "pineapple":
            raise ValueError("No pineapples!")
        else:
            return True

ingredients = ["cheese", "onions", "spam"]
if all(Pizza.validate_topping(i) for i in ingredients):
    pizza = Pizza(ingredients)

wise cargoBOT
#

@scenic quiver :x: Your 3.11 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 12, in <module>
003 |     if all(Pizza.validate_topping(i) for i in ingredients):
004 |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
005 |   File "/home/main.py", line 12, in <genexpr>
006 |     if all(Pizza.validate_topping(i) for i in ingredients):
007 |            ^^^^^^^^^^^^^^^^^^^^^^^^^
008 |   File "/home/main.py", line 6, in validate_topping
009 |     if self.toppings == "pineapple":
010 |        ^^^^^^^^^^^^^
011 | AttributeError: 'str' object has no attribute 'toppings'
... (truncated - too many lines)

Full output: https://paste.pythondiscord.com/opidepiral.txt?noredirect

somber heath
#
@staticmethod
def valudate_topping(topping):
    if topping == "pineapple":
        raise ValueError("No pineapples!")
    else:
        return True``````py
def valudate_topping(self, topping):
    if topping == "pineapple":
        raise ValueError("No pineapples!")
    else:
        return True```
#
class MyClass:
    pass```
#
class MyClass:
    pass

MyClass()```
#
class MyClass:
    pass

instance = MyClass()```
#

!e ```py
class MyClass:
def greet(self):
print('Hello, world.')

instance = MyClass()
instance.greet()```

wise cargoBOT
#

@somber heath :white_check_mark: Your 3.11 eval job has completed with return code 0.

Hello, world.
craggy breach
#
instance.greet()

is the same as

MyClass.greet(instance)

sometimes helps

#

sry

#

I mean, you were gonna say that anyways, so I sort of interrupted your flow mby, idk

somber heath
#

!e ```py
class MyClass:
def whoami(self):
print(self)

a = MyClass()
b = MyClass()
a.whoami()
b.whoami()```

wise cargoBOT
#

@somber heath :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 | <__main__.MyClass object at 0x7f0c1fe38410>
002 | <__main__.MyClass object at 0x7f0c1fe38450>
scenic quiver
#

So, you are creating 2 instances a and b which are objects and using them to call the methods. Object is calling the method and not the class in the above example right?

#

Is and equals?

somber heath
#
is
==```
#
MyClass.whoami(a)
a.whoami()```
scenic quiver
#

I cannot hear anything

somber heath
#

!e py a = [] b = [] c = a print(a == b) #True. a refers to an empty list. b refers to an empty list. print(a is b) #False. a refers to a different object than b refers to. print(a is c) #True. a refers to the same object that c refers to.

wise cargoBOT
#

@somber heath :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 | True
002 | False
003 | True
somber heath
#

!e ```py
class MyClass:
def is_self(self, value):
print(self is value)

a = MyClass()
b = MyClass()
a.is_self(a) #The a in the parentheses is given as value. The a left of the . is given as self.
a.is_self(b) #The b in the parentheses is given as value. The a left of the . is given as self.```

wise cargoBOT
#

@somber heath :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 | True
002 | False
somber heath
#
MyClass.is_self(a, a)
MyClass.is_self(a, b)```Essentially, but we don't write it this way.
#

!e ```py
class MyClass:
def function_or_method(self):
pass

instance = MyClass()
a = type(MyClass.function_or_method)
b = type(instance.function_or_method)
print(a)
print(b)```

wise cargoBOT
#

@somber heath :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 | <class 'function'>
002 | <class 'method'>
somber heath
#

When using classes, we generally want to be calling the method of an instance of a class, not the function of the class.

scenic quiver
#

!e

class Pizza:
    def __init__(self, toppings):
        self.toppings = toppings

    @staticmethod
    def validate_topping(topping):
        if topping == "pineapple":
            raise ValueError("No pineapples!")
        else:
            return True

ingredients = ["cheese", "onions", "spam"]
if all(Pizza.validate_topping(i) for i in ingredients):
    pizza = Pizza(ingredients)

wise cargoBOT
#

@scenic quiver :warning: Your 3.11 eval job has completed with return code 0.

[No output]
somber heath
#

!e ```py
class MyClass:

@staticmethod
def static_method():
    print('Hello, world.')

instance = MyClass()
instance.static_method()```

wise cargoBOT
#

@somber heath :white_check_mark: Your 3.11 eval job has completed with return code 0.

Hello, world.
somber heath
#

!e ```py
class MyClass:

def static_method():
    print('Hello, world.')

instance = MyClass()
instance.static_method()```

wise cargoBOT
#

@somber heath :x: Your 3.11 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 7, in <module>
003 |     instance.static_method()
004 | TypeError: MyClass.static_method() takes 0 positional arguments but 1 was given
somber heath
#

!e ```py
class MyClass:

def static_method(self):
    print('Hello, world.')

instance = MyClass()
instance.static_method()```

wise cargoBOT
#

@somber heath :white_check_mark: Your 3.11 eval job has completed with return code 0.

Hello, world.
somber heath
#

No longer a static method, though.

#
class MyClass:
    def method(_):
        print("Hello, world.")```
scenic quiver
#

!e

class Pizza:
    def __init__(self, toppings):
        self.toppings = toppings

    def validate_topping(self,t):
      self.t=t

        if self.t == "pineapple":
            raise ValueError("No pineapples!")
        else:
            return True

ingredients = ["cheese", "onions", "spam"]
if all(Pizza.validate_topping(i) for i in ingredients):
    pizza = Pizza(ingredients)

wise cargoBOT
#

@scenic quiver :x: Your 3.11 eval job has completed with return code 1.

001 |   File "/home/main.py", line 8
002 |     if self.t == "pineapple":
003 | IndentationError: unexpected indent
somber heath
#
class MyClass: #Creating a class
    pass

instance = MyClass() #Creating an instance (object created from the blueprint that is the class) and assigning a variable to it.```Instantiation.
warped raft
#

!e

    def __init__(self, toppings):
      self.toppings = toppings

    def validate_topping(self,t):
      self.t=t

        if self.t == "pineapple":
            raise ValueError("No pineapples!")
        else:
            return True

ingredients = ["cheese", "onions", "spam"]
if all(Pizza.validate_topping(i) for i in ingredients):
    pizza = Pizza(ingredients)```
wise cargoBOT
#

@warped raft :x: Your 3.11 eval job has completed with return code 1.

001 |   File "/home/main.py", line 1
002 |     def __init__(self, toppings):
003 | IndentationError: unexpected indent
scenic quiver
#

Finally, I wanted to actually get this! Got it now

#

!e

class Pizza:
    def __init__(self, toppings):
        self.toppings = toppings

    def validate_topping(self):
        

        if self.toppings == "pineapple":
            raise ValueError("No pineapples!")
        else:
            return True

ingredients = ["cheese", "onions", "spam"]
if all(Pizza(i).validate_topping() for i in ingredients):
    pizza = Pizza(ingredients)
wise cargoBOT
#

@scenic quiver :warning: Your 3.11 eval job has completed with return code 0.

[No output]
glad steeple
#

@somber heath You should change your about me

#

covid 19 is over

somber heath
#

No.

glad steeple
glad steeple
#

Covid is dead

#

We are free

#

@somber heath tell me one country

scenic quiver
#

!e

class Pizza:
    def __init__(self, toppings):
        self.toppings = toppings

    def validate_topping(self):
        

        if self.toppings == "pineapple":
            raise ValueError("No pineapples!")
        else:
            return True

ingredients = ["cheese", "onions", "spam","pineapple"]
if all(Pizza(i).validate_topping() for i in ingredients):
    pizza = Pizza(ingredients)
wise cargoBOT
#

@scenic quiver :x: Your 3.11 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 14, in <module>
003 |     if all(Pizza(i).validate_topping() for i in ingredients):
004 |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
005 |   File "/home/main.py", line 14, in <genexpr>
006 |     if all(Pizza(i).validate_topping() for i in ingredients):
007 |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
008 |   File "/home/main.py", line 9, in validate_topping
009 |     raise ValueError("No pineapples!")
010 | ValueError: No pineapples!
glad steeple
#

@somber heath Pardon me.

scenic quiver
#

I got it! Thanks for the explanation opalmist.

glad steeple
#

@somber heath Covid is dead to me

#

All things are passed away

#

behold all things are become new

#

@somber heath can u hear me?

somber heath
#

!voice @stark coral

wise cargoBOT
#
Voice verification

Can’t talk in voice chat? Check out #voice-verification to get access. The criteria for verifying are specified there.

glad steeple
#

@leaden comet Hi

somber heath
#

@brittle silo👋

glad steeple
#

@craggy breach Can you see this?

stark coral
#

oh i can write messages

#

magic

glad steeple
#

@somber heath Did I do something wrong?

stark coral
brittle silo
somber heath
#

@vale quartz👋

glad steeple
somber heath
#

Okay, so. Property decorator.

scenic quiver
#

!e

class Pizza:
    def __init__(self, toppings):
        self.toppings = toppings
        self._pineapple_allowed = False

    @property
    def pineapple_allowed(self):
        return self._pineapple_allowed

pizza = Pizza(["cheese", "tomato"])
print(pizza.pineapple_allowed)
wise cargoBOT
#

@scenic quiver :white_check_mark: Your 3.11 eval job has completed with return code 0.

False
somber heath
#

@unborn glen👋

#

setters, getters, deleters

unborn glen
somber heath
#

!voice

wise cargoBOT
#
Voice verification

Can’t talk in voice chat? Check out #voice-verification to get access. The criteria for verifying are specified there.

unborn glen
#

alright thx

brittle silo
#

!e
print

wise cargoBOT
#

@brittle silo :warning: Your 3.11 eval job has completed with return code 0.

[No output]
somber heath
#

!e ```py
class MyClass:
def init(self):
self._v = 10

@property
def value(self):
    print('Getter')
    return self._v

@value.setter
def value(self, v):
    print('Setter')
    self._v = v

instance = MyClass()
print(instance.value)
instance.value = 20
print(instance.value)```

wise cargoBOT
#

@somber heath :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 | Getter
002 | 10
003 | Setter
004 | Getter
005 | 20
brittle silo
#

!e
class Color:
def init(self, red:float, green:float, blue:float):

wise cargoBOT
#

@brittle silo :x: Your 3.11 eval job has completed with return code 1.

001 |   File "/home/main.py", line 2
002 |     def __init__(self, red:float, green:float, blue:float):
003 | IndentationError: expected an indented block after function definition on line 2
somber heath
#

!e ```py
class MyClass:
def init(self):
self.value = 10

instance = MyClass()
print(instance.value)
instance.value = 20
print(instance.value)```

wise cargoBOT
#

@somber heath :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 | 10
002 | 20
brittle silo
#

!e
class ColorValueError(Exception):
def init(self, message='< Maximum -> 255, Minimum -> 0 >'):
self.message = message
super().init(self.message)

class Color:
def init(self,red:float, green:float, blue:float) -> float:
if(red > 255 or green > 255 or blue > 255):
raise ColorValueError
if(red < 0 or green < 0 or blue < 0):
raise ColorValueError
a = Color(255,255,255)

wise cargoBOT
#

@brittle silo :warning: Your 3.11 eval job has completed with return code 0.

[No output]
brittle silo
#

!e
class ColorValueError(Exception):
def init(self, message='< Maximum -> 255, Minimum -> 0 >'):
self.message = message
super().init(self.message)

class Color:
def init(self,red:float, green:float, blue:float) -> float:
if(red > 255 or green > 255 or blue > 255):
raise ColorValueError
if(red < 0 or green < 0 or blue < 0):
raise ColorValueError
a = Color(255,255,255)
print(a)

wise cargoBOT
#

@brittle silo :x: Your 3.11 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 12, in <module>
003 |     a = Color(255,255,255)
004 |         ^^^^^^^^^^^^^^^^^^
005 | TypeError: Color() takes no arguments
brittle silo
#

!e
class ColorValueError(Exception):
def init(self, message='< Maximum -> 255, Minimum -> 0 >'):
self.message = message
super().init(self.message)

class Color:
def init(self,red:float, green:float, blue:float) -> float:
if(red > 255 or green > 255 or blue > 255):
raise ColorValueError
if(red < 0 or green < 0 or blue < 0):
raise ColorValueError

def get_info(color:Color):
return color.red, color.green, color.blue

a = Color(255,255,255)
print(get_info(a))

wise cargoBOT
#

@brittle silo :x: Your 3.11 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 16, in <module>
003 |     a = Color(255,255,255)
004 |         ^^^^^^^^^^^^^^^^^^
005 | TypeError: Color() takes no arguments
brittle silo
#

!e
class ColorValueError(Exception):
def init(self, message='< Maximum -> 255, Minimum -> 0 >'):
self.message = message
super().init(self.message)

class Color:
def init(self,red:float, green:float, blue:float) -> float:
if(red > 255 or green > 255 or blue > 255):
raise ColorValueError
if(red < 0 or green < 0 or blue < 0):
raise ColorValueError

def get_info(color:Color):
return print(color.red, color.green, color.blue)

a = Color(255,255,255)
print(get_info(a))

wise cargoBOT
#

@brittle silo :x: Your 3.11 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 16, in <module>
003 |     a = Color(255,255,255)
004 |         ^^^^^^^^^^^^^^^^^^
005 | TypeError: Color() takes no arguments
brittle silo
#

!e
class ColorValueError(Exception):
def init(self, message='< Maximum -> 255, Minimum -> 0 >'):
self.message = message
super().init(self.message)

class Color:
def init(self,red:float, green:float, blue:float) -> float:
if(red > 255 or green > 255 or blue > 255):
raise ColorValueError
if(red < 0 or green < 0 or blue < 0):
raise ColorValueError

def get_info(color:Color):
return print(color.red, color.green, color.blue)

a = Color(255,255,255)
print(get_info(a))

wise cargoBOT
#

@brittle silo :x: Your 3.11 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 17, in <module>
003 |     print(get_info(a))
004 |           ^^^^^^^^^^^
005 |   File "/home/main.py", line 14, in get_info
006 |     return print(color.red, color.green, color.blue)
007 |                  ^^^^^^^^^
008 | AttributeError: 'Color' object has no attribute 'red'
somber heath
#

!e ```py
class MyClass:
def init(self, a, b, c):
self.a = a
self.b = b
self.c = c

instance = MyClass(1, 2, 3)```

wise cargoBOT
#

@somber heath :warning: Your 3.11 eval job has completed with return code 0.

[No output]
brittle silo
#

!e
class ColorValueError(Exception):
def init(self, message='< Maximum -> 255, Minimum -> 0 >'):
self.message = message
super().init(self.message)

class Color:
def init(self,red:float, green:float, blue:float) -> float:
self.r = red
self.g = green
self.b = blue
if(red > 255 or green > 255 or blue > 255):
raise ColorValueError
if(red < 0 or green < 0 or blue < 0):
raise ColorValueError
def get_info(self):
return print(self.r, self.g, self.b)

a = Color(255,255,255)
print(get_info(a))

wise cargoBOT
#

@brittle silo :x: Your 3.11 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 19, in <module>
003 |     print(get_info(a))
004 |           ^^^^^^^^
005 | NameError: name 'get_info' is not defined
somber heath
#

!code

wise cargoBOT
#
Formatting code on discord

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

For long code samples, you can use our pastebin.

scenic quiver
#

!e ```py
class MyClass:
def init(self):
self._v = 10

def value(self):
    print('Getter')
    return self._v

@value.setter
def value(self, v):
    print('Setter')
    self._v = v

instance = MyClass()
print(instance.value())
instance.value = 20
print(instance.value())```

wise cargoBOT
#

@scenic quiver :x: Your 3.11 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 1, in <module>
003 |     class MyClass:
004 |   File "/home/main.py", line 9, in MyClass
005 |     @value.setter
006 |      ^^^^^^^^^^^^
007 | AttributeError: 'function' object has no attribute 'setter'
somber heath
#

!e ```py
print('Hello, world.')
print('Goodbye.')
``` @brittle silo

brittle silo
#

!e
class ColorValueError(Exception):
def init(self, message='< Maximum -> 255, Minimum -> 0 >'):
self.message = message
super().init(self.message)

class Color:
def init(self,red:float, green:float, blue:float) -> float:
self.r = red
self.g = green
self.b = blue
if(red > 255 or green > 255 or blue > 255):
raise ColorValueError
if(red < 0 or green < 0 or blue < 0):
raise ColorValueError
def get_info(self):
return self.r, self.g, self.b

a = Color(255,255,255)
print(Color.get_info(a))

wise cargoBOT
#

@brittle silo :x: Your 3.11 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 18, in <module>
003 |     a = Color(255,255,255)
004 |         ^^^^^^^^^^^^^^^^^^
005 | TypeError: Color() takes no arguments
scenic quiver
#

!e ```py
class MyClass:
def init(self):
self._v = 10

def value(self):
    print('Getter')
    return self._v

instance = MyClass()
print(instance.value())

wise cargoBOT
#

@scenic quiver :warning: Your 3.11 eval job has completed with return code 0.

[No output]
scenic quiver
#

!e

class MyClass:
    def __init__(self):
        self._v = 10

    def value(self):
        print('Getter')
        return self._v

instance = MyClass()
print(instance.value())
wise cargoBOT
#

@scenic quiver :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 | Getter
002 | 10
brittle silo
#

!e
class ColorValueError(Exception):
def init(self, message='< Maximum -> 255, Minimum -> 0 >'):
self.message = message
super().init(self.message)

class Color:
def init(self,red:float, green:float, blue:float) -> float:
self.r = red
self.g = green
self.b = blue
if(red > 255 or green > 255 or blue > 255):
raise ColorValueError
if(red < 0 or green < 0 or blue < 0):
raise ColorValueError
def get_info(color:Color):
return color.r, color.g, color.b

a = Color(255,255,255)
b = Color.get_info(a)
print(b)

wise cargoBOT
#

@brittle silo :x: Your 3.11 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 6, in <module>
003 |     class Color:
004 |   File "/home/main.py", line 15, in Color
005 |     def get_info(color:Color):
006 |                        ^^^^^
007 | NameError: name 'Color' is not defined
somber heath
#

@brittle silo If you're going to post a bunch of code, could you please use the Discord codeblock markdown?

brittle silo
#

oke

somber heath
#

Thanking you.

#

!e ```py
class MyClass:
def init(self, value):
self._var = value

@property
def var(self):
    return self._var

@var.setter
def var(self, value):
    self._var = value

@var.deleter
def var(self):
    self._var = 0

instance = MyClass(5)
print(instance.var)
del instance.var
print(instance.var)``` @scenic quiver

wise cargoBOT
#

@somber heath :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 | 5
002 | 0
somber heath
#

If you ever wanted to use it.

#

Personally, I think it's janky, but eh.

#

@torn marsh👋

#

!voice

wise cargoBOT
#
Voice verification

Can’t talk in voice chat? Check out #voice-verification to get access. The criteria for verifying are specified there.

somber smelt
somber heath
#

Is low poly the same thing as depressed parrot?

#

High poly, well...

#

.topic

viscid lagoonBOT
#
**What is the most useless talent that you have?**

Suggest more topics here!

obsidian dragon
#

.topic

viscid lagoonBOT
#
**What is your favourite color?**

Suggest more topics here!

pallid hazel
#

todays hell in py.noobs life.. different pandas series canceling out each other... doh

somber heath
#

@eternal plume👋

#

@open loom👋

open loom
#

hey

somber heath
#

!voice

wise cargoBOT
#
Voice verification

Can’t talk in voice chat? Check out #voice-verification to get access. The criteria for verifying are specified there.

open loom
#

I'm new to coding ,,, would love to get some guidance from you regarding the same

#

exact roadmap regarding solidity

#

it is used to build smart contracts on blockchain

#

but nvm

#

tell me more about python if you can pls

somber heath
#

!e ```py
class A:
pass

class B(A):
pass

b = B()
print(isinstance(b, B))
print(isinstance(b, A))```

wise cargoBOT
#

@somber heath :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 | True
002 | True
open loom
#

LOL not rly

#

one sec

#

Solidity is an object-oriented programming language for implementing smart contracts on various blockchain platforms, most notably, Ethereum. It was developed by Christian Reitwiessner, Alex Beregszaszi, and several former Ethereum core contributors. Programs in Solidity run on Ethereum Virtual Machine.

#

but nvm tell me more about python if you can pls

#

like an exact guide or roadmap towards python

somber heath
#

!resources

wise cargoBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

somber heath
#

Corey Schafer's Youtube, playlists.

open loom
#

thanks a bunch

somber heath
#

@fallen gust👋

#

@willow spoke👋

obsidian dragon
#

.topic

viscid lagoonBOT
#
**How many years have you spent coding?**

Suggest more topics here!

craggy breach
#

.topic

viscid lagoonBOT
#
**Who is your favorite Writer?**

Suggest more topics here!

somber heath
#

Hey Maro. Hey Fury. Also, heya Kimchi.

#

I know how to tie my own shoelaces.

#

So many shoelaces.

#

Seriously. I've lost count.

#

@strange jolt👋

rugged root
#

The master suppression techniques is a framework articulated in 1945 by the Norwegian psychologist and philosopher Ingjald Nissen. These techniques identified by Nissen are ways to indirectly suppress and humiliate opponents. In the late 1970s, the framework was popularized by Norwegian social psychologist Berit Ås, who reduced Nissen's original...

obsidian dragon
brittle silo
#

!voice

wise cargoBOT
#
Voice verification

Can’t talk in voice chat? Check out #voice-verification to get access. The criteria for verifying are specified there.

willow spoke
#

In the history of artificial intelligence, an AI winter is a period of reduced funding and interest in artificial intelligence research. The term was coined by analogy to the idea of a nuclear winter. The field has experienced several hype cycles, followed by disappointment and criticism, followed by funding cuts, followed by renewed interest ye...

warm jackal
warm jackal
vocal basin
#

there's also ChatGPT playing chess

brittle silo
#

!voiceverify

rugged root
somber heath
#

Barefoot running...sounds okay until you get stuck in the foot with something.

little citrus
#

PS D:\JOB\BENbot> & C:/Users/User/AppData/Local/Microsoft/WindowsApps/python3.10.exe d:/JOB/BENbot/app.py
Traceback (most recent call last):
File "d:\JOB\BENbot\app.py", line 2, in <module>
from discord_slash import SlashCommand
ModuleNotFoundError: No module named 'discord_slash'
PS D:\JOB\BENbot>

wise cargoBOT
#

Hey @little citrus!

You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.

little citrus
#

pip install -U discord-py-slash-command

rugged root
#

py -m pip install -U discord-py-slash-command

little citrus
#

Python 3.11.1 (tags/v3.11.1:a7a450f, Dec 6 2022, 19:58:39) [MSC v.1934 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

rugged root
#

quit()

#

py -3.10 -m pip install -U discord-py-slash-command

#

Hmm, yeah I think they changed it

#

Yeah, they swapped it

#

py -m pip uninstall discord-py-slash-command

lucid blade
#

yo 🙂

rugged root
#

py -m pip install -U discord-py-interactions

#

Hey old man

lucid blade
#

haha 😄

#

you forgot the grumpy part

vocal basin
#

new discord.py includes slash commands and interactions

#

without any extra stuff

#

@little citrus what discord.py version are you using, again?

#

it's better to use storage that's built for backups, journaling and synchronisation

#

Nextcloud has some of that
(and it has CLI interface)

#

there was a breaking change in voice API recently

rugged root
#

What as the change?

molten pewter
#

👁️ ➡️ 🏋️‍♂️, 👋

rugged root
#

You have to go?

#

Yes he does

#

Later Fury

molten pewter
#

☮️

vocal basin
# rugged root What as the change?

I think we've identified the issue in JDA. It seems like the UDP discovery changed the response from 70 to 74 bytes. You have to send and receive 74 bytes instead of 70.
https://github.com/Rapptz/discord.py/issues/9277#issuecomment-1450472138

GitHub

Summary initial_connection method coroutine never returns resulting in failing to connect to a VC Reproduction Steps Call and await connect() on an instance of VoiceChannel. Details on getting an i...

lucid blade
somber heath
#

Garfield Minus Garfield.

#

!e py text = '''Apple Pear Orange Guava''' result = text.split('\n') print(result)

wise cargoBOT
#

@somber heath :white_check_mark: Your 3.11 eval job has completed with return code 0.

['Apple', 'Pear', 'Orange', 'Guava']
somber heath
#

You can drop the '\n' but I like to be explicit.

#

Fuck.

craggy breach
#

if you drop it, you get a space split

rugged root
#

!stream 559903350024568833

wise cargoBOT
#

✅ @verbal zenith can now stream until <t:1678807416:f>.

somber heath
#

!d str.split

wise cargoBOT
#

str.split(sep=None, maxsplit=- 1)```
Return a list of the words in the string, using *sep* as the delimiter string. If *maxsplit* is given, at most *maxsplit* splits are done (thus, the list will have at most `maxsplit+1` elements). If *maxsplit* is not specified or `-1`, then there is no limit on the number of splits (all possible splits are made).

If *sep* is given, consecutive delimiters are not grouped together and are deemed to delimit empty strings (for example, `'1,,2'.split(',')` returns `['1', '', '2']`). The *sep* argument may consist of multiple characters (for example, `'1<>2<>3'.split('<>')` returns `['1', '2', '3']`). Splitting an empty string with a specified separator returns `['']`.

For example:
rugged root
#

!d str.splitlines

wise cargoBOT
#

str.splitlines(keepends=False)```
Return a list of the lines in the string, breaking at line boundaries. Line breaks are not included in the resulting list unless *keepends* is given and true.

This method splits on the following line boundaries. In particular, the boundaries are a superset of [universal newlines](https://docs.python.org/3/glossary.html#term-universal-newlines)...
somber heath
#

I forget about that one.

#

Is it new?

craggy breach
#

doubt

#

idk, mby it wasn't in like py 2

somber heath
#

Huh. 3.2.

#

I should try to force myself to use it more.

#

Who was asking about splitting up a string?

craggy breach
#

void

somber heath
#

Because you might do things differently if you were reading this string in from a file.

#

Text file objects are iterable.

#

It can save you from reading the whole file into memory at a time.

#

and more than just calling a different method, it does also do the assignment

#

!e ```py
print(10.0 // 2)
print(10 // 2.0)
print(10 // 2)

wise cargoBOT
#

@somber heath :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 | 5.0
002 | 5.0
003 | 5
warm jackal
rugged root
#

Neat

vocal basin
#

!d functools.total_ordering

wise cargoBOT
#

@functools.total_ordering```
Given a class defining one or more rich comparison ordering methods, this class decorator supplies the rest. This simplifies the effort involved in specifying all of the possible rich comparison operations:

The class must define one of `__lt__()`, `__le__()`, `__gt__()`, or `__ge__()`. In addition, the class should supply an `__eq__()` method.

For example:
vocal basin
# wise cargo

@verbal zenith
this is fine to auto-fill those methods in some cases

somber heath
#

!d slice

wise cargoBOT
#

class slice(stop)``````py

class slice(start, stop, step=1)```
Return a [slice](https://docs.python.org/3/glossary.html#term-slice) object representing the set of indices specified by `range(start, stop, step)`. The *start* and *step* arguments default to `None`. Slice objects have read-only data attributes `start`, `stop`, and `step` which merely return the argument values (or their default). They have no other explicit functionality; however, they are used by NumPy and other third-party packages. Slice objects are also generated when extended indexing syntax is used. For example: `a[start:stop:step]` or `a[start:stop, i]`. See [`itertools.islice()`](https://docs.python.org/3/library/itertools.html#itertools.islice "itertools.islice") for an alternate version that returns an iterator.
somber heath
#

!e py text = 'abcdefghijklmnop' print(text[5:])

wise cargoBOT
#

@somber heath :white_check_mark: Your 3.11 eval job has completed with return code 0.

fghijklmnop
vocal basin
#

A being worse than B doesn't mean B isn't bad

severe vigil
#

yo, can someone help me with a hardware thing?

#

i have question

rugged root
#

Possibly. What's the question?

#

Hey Maro

severe vigil
#

i want to make a program to maintain my battery live between 20 - 80%

#

but i want to keep my laptop plugged in but not charge

tidal shard
severe vigil
#

so i want to know if i can keep my laptop plugged in but not charge

somber heath
#

That would be very hardware-specific as to if that would be a possibility at all. I would expect that you wouldn't be able to govern the charging like that.

#

What's the model of laptop?

severe vigil
#

i have a macbook so i was hoping i could do it software side

#

macbook is very harsh with hardware stuff

somber heath
#

If Apple doesn't give you a way to do it in the OS, you're probably SOL.

#

@severe vigilHm. I am seeing options for it being listed.

severe vigil
#

i think i found something

#

called coconut battery

somber heath
#

"Optimised battery charging"

#

in Ventura.

severe vigil
#

oh really?

#

go on...

somber heath
severe vigil
#

thanks very much 🙂

lucid blade
somber heath
#

Mandalorian in a Karen wig.

knotty dock
#

hello

#

does anyone know why i get a type error for this def agedif(solidarty):
if not 0 <= solidarty <= 20:
return 'invalid number'
else:
return'solidarty'

#

that code doesnt work

craggy breach
#

wdym?

knotty dock
#

?

#

TypeError: '<=' not supported between instances of 'int' and 'str'

#

i get a type error

craggy breach
#

solidarity is a string value

knotty dock
#

wdym?

craggy breach
#

try if not 0 <= int(solidarity) <= 20:

somber heath
#

For clarity, you could cast solidarity to int prior to doing the ternary expression.

knotty dock
#

how did you know this was right?

#

and why does it work

craggy breach
#

because the error message told me, also follow Opal's advice

somber heath
#
a <= b <= c```a is less than or equal to b AND b is less than or equal to c.
knotty dock
#

?

#

is this for me

somber heath
#

!e py 5 <= '123'

wise cargoBOT
#

@somber heath :x: Your 3.11 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 1, in <module>
003 |     5 <= '123'
004 | TypeError: '<=' not supported between instances of 'int' and 'str'
knotty dock
#

i dont understand?

somber heath
#

You can't compare numbers and strings.

#

You have to do a conversion.

knotty dock
#

i never made solitary a string

#

solidatry

craggy breach
#

is it user input?

somber heath
#

How are you creating solitary?

#

Or whatever it's called.

knotty dock
#

with def

somber heath
#

Post your code.

#

!code

wise cargoBOT
#
Formatting code on discord

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

For long code samples, you can use our pastebin.

somber heath
#

If it's too long, use pastebin.

#

!paste

wise cargoBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

knotty dock
#

'''py

#

oops

somber heath
#

` not '

#

~ key

#

Above tab.

knotty dock
#
     if  not 0 <= int(solidarty) <= 20:
         return 'invalid number'
     else:
         return solidarty```
#

thats it

somber heath
#

What calls this function?

#

Also, you shouldn't mix your return types unless it makes semantic sense to.

#

If you give your function something your function knows is wrong, you can raise an exception.

#

You'd then deal with that exception outside of the function.

#

You can worry about that later.

#

How are you creating solidarty?

#

Initially.

knotty dock
#

with the def

#

i dont understand your question

#

how i am creating it is in the code above

#

thats my knowledge of functions in on code

somber heath
#

The object that you give to the call of agedif.

#

The argument.

#

How are you creating the argument?

knotty dock
#

ah

#

yh

#

youre right

#

that was the problem

#

thank you

#

how did you know?

#

what made you know that was the problem

#

was it cause thats the only thing it could of been

somber heath
#

Experience. Once you solve enough of the same sort of problem, you get to learn how to walk back from where the problem happened to the origin of the problem.

craggy breach
#

Also the error messages are usually pretty specific about what and why happened, learning to read those would help you a lot

knotty dock
#

i thought it was a problem in the making of the function because of where the error was

#

!resources

wise cargoBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

craggy breach
#
import subprocess


subprocess.Popen("pause", shell=True)
print("hi")
somber heath
#

@ocean whale@willow spoke👋

#

@unique scroll👋

knotty dock
#

are you saying i didnt need to use else

somber heath
#

!e ```py
def func(value):
int(value) #Let's say func expects value to always be an int.

try:
func('abc')
except ValueError:
print('Caught')```

wise cargoBOT
#

@somber heath :white_check_mark: Your 3.11 eval job has completed with return code 0.

Caught
somber heath
#

This is just an example, and there are times when you'd use try/except within the function.

#

But if the function semantically should always have value as an int, then it might make sense to handle the exception outside of the function.

#

!e py things = [1, 'abc', 5.5, 5+2j] for thing in things: try: print(int(thing)) except (ValueError, TypeError): pass #Let's ignore ValueErrors and TypeErrors

wise cargoBOT
#

@somber heath :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 | 1
002 | 5
knotty dock
#

ngl i get it lowkey

#

im just not on the try , except, pass

somber heath
#

Yeah, you don't have to worry about this straight away.

knotty dock
#

only know if , else, elif

somber heath
#

Just showing you so you can remember it when you see it again.

#

@cobalt tiger👋

knotty dock
#

alright kl kl thank you

somber heath
#

pass is what you write when you don't want to write anything but you have to because it expects you to

#

!e ```py
def func():

print('Hello, world.')```

wise cargoBOT
#

@somber heath :x: Your 3.11 eval job has completed with return code 1.

001 |   File "/home/main.py", line 3
002 |     print('Hello, world.')
003 |     ^
004 | IndentationError: expected an indented block after function definition on line 1
somber heath
#

!e ```py
def func():
pass

print('Hello, world.')```

wise cargoBOT
#

@somber heath :white_check_mark: Your 3.11 eval job has completed with return code 0.

Hello, world.
somber heath
#

@whole bear We can't hear you clearly.

#

You'll need to speak more loudly if you expect us to hear you.

#

@whole bearYou're sort of just rambling. Are you okay?

#

OH.

#

Well, I don't know about the best.

#

It's...not going in a very nice direction at the moment.