#voice-chat-text-0
1 messages ยท Page 127 of 1
AF and me?
Yeah
does this account for .. not being allowed?
!e
import math
not_dot = 1
n = 3
print(sum(
not_dot**(n-k) * math.comb(n-k+1, k)
for k in range(0, math.ceil(n/2))
))
@vocal basin :white_check_mark: Your 3.11 eval job has completed with return code 0.
4
AAA
AA.
A.A
.AA
.A.
!e
from functools import cache
not_dot = 1
@cache
def count_not_dot(n):
if n < 0:
return 0
elif n == 0:
return 1
else:
return not_dot * count_any(n - 1)
@cache
def count_any(n):
return count_not_dot(n) + count_not_dot(n - 1)
print(count_any(3))
@vocal basin :white_check_mark: Your 3.11 eval job has completed with return code 0.
5
@stuck furnace your code seems to give smaller numbers than it should
I don't even understand what this is supposed to do
actually a fun dynamic programming problem tbh
this can be rearranged into dynamic programming
i mean, i would say yours is already dynamic programming
just not written bottom up
Yeah it's wrong: range(0, math.ceil(n/2)) should have been range(0, math.ceil(n/2) + 1).
!e
import math
print(
sum(
sum(
37**(n-k) * math.comb(n-k+1, k)
for k in range(0, math.ceil(n/2) + 1)
)
for n in range(2, 32+1)
)
)
@vocal basin :white_check_mark: Your 3.11 eval job has completed with return code 0.
359388417161078316195213428595622487100369137948995
numbers match now
I got mixed up because I wrote it down the mathy way first (with the big sigma) and that includes the upper bound
Yeah I prefer AF's
tbh, I might have seen this solution earlier
we had similar questions in school
but I forgot most of it
1 instead of 37 is a common special case
it might be coming through
but not a lot
First time writing a proper readme please rate
https://github.com/JacobMonck/calico
still need to add some badges
and license but for the most part it's good
I'd expect docker compose up --build to be instead
docker compose up --build
(as a block)
though
maybe not in this case
because other two steps can't be clearly defined as specific cli actions
reference
(just a typo, ig)
why isn't the first one enough?
non-Linux Docker
maybe works
https://docs.tritondatacenter.com/public-cloud/instances/docker
ohh thats goood
The details are vague, but Detective Meese will have to find out who assualted Mr. Perry. Will he be able to put the pieces together and find the culprit?
Be Sure To Subscribe to Studio C โบ https://goo.gl/ppFsJP
Bring on the laughs! Sketch comedy for everyone. Watch Studio C on YouTube.
Top 15 Most Viewed Studio C Videos: http://goo.gl/0pCAH...
@peak copper go to code/help
studio c , all brand new to me
The Scott Sterling stuff is absolute gold
๐ก๐คบ
ohh no tootsi pop reference - 1 , 2 , 3
hi
Yo, how's it going
Not too bad, and yourself?
Eh, doing alright. Ready to be home and relaxing.
I hope you have a good night
yes, [] for generics now
with inferred variance
allegedly
already discussed here some time ago
it's better than yesterday
shorthand for TypeVars
It's fairly natural because it matches how you use the type.
Python Enhancement Proposals (PEPs)
So like instead of doing ```py
class Foo(Generic[T]):
...
x: Foo[int]
you can dopy
class Foo[T]:
...
x: Foo[int]
variadic types often require 2-3 TypeVars with different variance
if they, for example, have factory methods
Yeah it can really slow you down.
typing makes it simpler for me
typeless code takes me more effort to read
But because it's optional, if you can't figure out the right way to type something, you can always just leave the types off.
# whats the difference than something like this
def foo(bar: int) -> int:
return 2 * bar
It would be nice if Discord had an automatic Korean translation feature, but then again, it might not improve your English skills...
Compared with?
def foo[T](bar: T) -> T:
return 2 * bar
what we are talking about from pep 0659
Ah right
def tuple_of_two[T](element: T) -> tuple[T, T]:
return element, element
needs bounds
no it's not
polymorphism
one of the types of it
why would it be enforced
it does not impact runtime in any way after its parsed unless you pull the annotations out of the functions
@mortal burrow you're thinking of different polymorphism
As long as you don't do anything to the objects that can't be done to their bounding type, you're good.
this does not need to change behaviour based on the type
if it was something like Rust, it would have to, but not completely
this is true for Java/C#/Python
generics in such languages don't need defining a function for each type
ahh
An object's type tells you that it has certain methods and attributes. Any sub-type of that type should also support those same methods and attributes, and they should behave in a compatible way.
whereas in C++/Rust, you do define function per each type
because different types have different sizes
from discord.commands import Option
C++ has more reasons for it, specifically that it's not the most sane and user-friendly language
where did you get this code from?
chat gpt 
well, of course it's meaningless then
GPT is designed to make stuff up
it didn't
it gaslit you into thinking it worked
a
!d typing.TypeVar
class typing.TypeVar```
Type variable.
Usage:
```py
T = TypeVar('T') # Can be anything
S = TypeVar('S', bound=str) # Can be any subtype of str
A = TypeVar('A', str, bytes) # Must be exactly str or bytes
``` Type variables exist primarily for the benefit of static type checkers. They serve as the parameters for generic types as well as for generic function definitions. See [`Generic`](https://docs.python.org/3/library/typing.html#typing.Generic "typing.Generic") for more information on generic types. Generic functions work as follows:
quite verbose
but not necessarily for worse
being able to specify variance explicitly is useful
same for bound
Provided to YouTube by DistroKid
Your Stupid Face ยท Kaden MacKay
Your Stupid Face
โ Kaden MacKay
Released on: 2022-06-11
Auto-generated by YouTube.
@whole bear @whole bear Now duet.
what?
making aforementioned Factories threadsafe
I feel as though there miiight be something missing. Just a thought
I could be wrong.
it's Rust and it's fast
for python and threading, omg would stand for "oh my GIL"
source for that thing was generated in less than 50ms
#voice-chat-text-0 message
gtg ๐
despite each small line involving at least a couple of allocations/deallocations
back to meme names for commits
the big question now is whether I should make every Factory parse-able
is the repo public?
not yet
i will be back
!code
cloc --force-lang="Rust",ae src/
cloc --force-lang="Rust",ae ./compiler ./lib
BRB
not a backronym
(always was initials for this name)
!stream 373160837151719424
โ @lime vale can now stream until <t:1683339806:f>.
!stream 559903350024568833 20m
โ @verbal zenith can now stream until <t:1736136969:f>.
this sucks i cant talk lmfao
gtg
!voice
Canโt talk in voice chat? Check out #voice-verification to get access. The criteria for verifying are specified there.
ุชุญูู ููู ุนุฑุจู ููุง
Hey ๐
Wait what time is it where you are? ๐
I haven't used Java since university.
It's essentially Python but: curly braces, mandatory static typing, and everything has to be in a class for some reason.
Hello
Yeah we can hear you @acoustic marlin 
Sorry no
If you have a question, you could ask in #web-development
@acoustic marlin 
Or claim a help channel: #โ๏ฝhow-to-get-help
๐
Canโt talk in voice chat? Check out #voice-verification to get access. The criteria for verifying are specified there.
def write(pit, data):
pit0 = open("Pits\Pit - a1\Pit-000.txt", "w")
pit1 = open("Pits\Pit - a1\Pit-001.txt", "w")
pit2 = open("Pits\Pit - a1\Pit-002.txt", "w")
pit3 = open("Pits\Pit - a1\Pit-003.txt", "w")
pit4 = open("Pits\Pit - a1\Pit-004.txt", "w")
pit5 = open("Pits\Pit - a1\Pit-005.txt", "w")
pit6 = open("Pits\Pit - a1\Pit-006.txt", "w")
pit7 = open("Pits\Pit - a1\Pit-007.txt", "w")
pit8 = open("Pits\Pit - a1\Pit-008.txt", "w")
pit9 = open("Pits\Pit - a1\Pit-009.txt", "w")
pit10 = open("Pits\Pit - a1\Pit-010.txt", "w")
pit11 = open("Pits\Pit - a1\Pit-011.txt", "w")
pit12 = open("Pits\Pit - a1\Pit-012.txt", "w")
pit13 = open("Pits\Pit - a1\Pit-013.txt", "w")
pit14 = open("Pits\Pit - a1\Pit-014.txt", "w")
pit15 = open("Pits\Pit - a1\Pit-015.txt", "w")
pit16 = open("Pits\Pit - a1\Pit-016.txt", "w")
pit17 = open("Pits\Pit - a1\Pit-017.txt", "w")
pit18 = open("Pits\Pit - a1\Pit-018.txt", "w")
pit19 = open("Pits\Pit - a1\Pit-019.txt", "w")
pit20 = open("Pits\Pit - a1\Pit-020.txt", "w")
pit21 = open("Pits\Pit - a1\Pit-021.txt", "w")
pit22 = open("Pits\Pit - a1\Pit-022.txt", "w")
pit23 = open("Pits\Pit - a1\Pit-023.txt", "w")
pit24 = open("Pits\Pit - a1\Pit-024.txt", "w")
pit25 = open("Pits\Pit - a1\Pit-025.txt", "w")
pit26 = open("Pits\Pit - a1\Pit-026.txt", "w")
pit.write(data)
hello
def write(pit, data):
pit0 = open("Pits\Pit - a1\Pit-000.txt", "w")
pit1 = open("Pits\Pit - a1\Pit-001.txt", "w")
pit2 = open("Pits\Pit - a1\Pit-002.txt", "w")
pit3 = open("Pits\Pit - a1\Pit-003.txt", "w")
pit4 = open("Pits\Pit - a1\Pit-004.txt", "w")
pit5 = open("Pits\Pit - a1\Pit-005.txt", "w")
pit6 = open("Pits\Pit - a1\Pit-006.txt", "w")
pit7 = open("Pits\Pit - a1\Pit-007.txt", "w")
pit8 = open("Pits\Pit - a1\Pit-008.txt", "w")
pit9 = open("Pits\Pit - a1\Pit-009.txt", "w")
pit10 = open("Pits\Pit - a1\Pit-010.txt", "w")
pit11 = open("Pits\Pit - a1\Pit-011.txt", "w")
pit12 = open("Pits\Pit - a1\Pit-012.txt", "w")
pit13 = open("Pits\Pit - a1\Pit-013.txt", "w")
pit14 = open("Pits\Pit - a1\Pit-014.txt", "w")
pit15 = open("Pits\Pit - a1\Pit-015.txt", "w")
pit16 = open("Pits\Pit - a1\Pit-016.txt", "w")
pit17 = open("Pits\Pit - a1\Pit-017.txt", "w")
pit18 = open("Pits\Pit - a1\Pit-018.txt", "w")
pit19 = open("Pits\Pit - a1\Pit-019.txt", "w")
pit20 = open("Pits\Pit - a1\Pit-020.txt", "w")
pit21 = open("Pits\Pit - a1\Pit-021.txt", "w")
pit22 = open("Pits\Pit - a1\Pit-022.txt", "w")
pit23 = open("Pits\Pit - a1\Pit-023.txt", "w")
pit24 = open("Pits\Pit - a1\Pit-024.txt", "w")
pit25 = open("Pits\Pit - a1\Pit-025.txt", "w")
pit26 = open("Pits\Pit - a1\Pit-026.txt", "w")
pit.write(data)
ยดยดยดpy
sdf
ยดยดยด
print(f"you have ${money}!")
def write(pit,data): pit1=open(pit,data) return pit1 write() pit1=input('insert the derectory') pt2=input('insert the way you want the file to open w r o a: ') write(pit,data)
if n== pit1:
!e
print("True")
def write(pit,data): your code return write() n=input('insert the derectory') write(pit,data) if n=='pit1':
def write(pit, data): pit0 = open("Pits\Pit - a1\Pit-000.txt", "w") pit1 = open("Pits\Pit - a1\Pit-001.txt", "w") pit2 = open("Pits\Pit - a1\Pit-002.txt", "w") pit3 = open("Pits\Pit - a1\Pit-003.txt", "w") pit4 = open("Pits\Pit - a1\Pit-004.txt", "w") pit5 = open("Pits\Pit - a1\Pit-005.txt", "w") pit6 = open("Pits\Pit - a1\Pit-006.txt", "w") pit7 = open("Pits\Pit - a1\Pit-007.txt", "w") pit8 = open("Pits\Pit - a1\Pit-008.txt", "w") pit9 = open("Pits\Pit - a1\Pit-009.txt", "w") pit10 = open("Pits\Pit - a1\Pit-010.txt", "w") pit11 = open("Pits\Pit - a1\Pit-011.txt", "w") pit12 = open("Pits\Pit - a1\Pit-012.txt", "w") pit13 = open("Pits\Pit - a1\Pit-013.txt", "w") pit14 = open("Pits\Pit - a1\Pit-014.txt", "w") pit15 = open("Pits\Pit - a1\Pit-015.txt", "w") pit16 = open("Pits\Pit - a1\Pit-016.txt", "w") pit17 = open("Pits\Pit - a1\Pit-017.txt", "w") pit18 = open("Pits\Pit - a1\Pit-018.txt", "w") pit19 = open("Pits\Pit - a1\Pit-019.txt", "w") pit20 = open("Pits\Pit - a1\Pit-020.txt", "w") pit21 = open("Pits\Pit - a1\Pit-021.txt", "w") pit22 = open("Pits\Pit - a1\Pit-022.txt", "w") pit23 = open("Pits\Pit - a1\Pit-023.txt", "w") pit24 = open("Pits\Pit - a1\Pit-024.txt", "w") pit25 = open("Pits\Pit - a1\Pit-025.txt", "w") pit26 = open("Pits\Pit - a1\Pit-026.txt", "w") pit.write(data)
leenode
def write(pit, data):
f3 = open('text.txt', 'w')
f3.write(pit + ": " + data)
f3.close()
write('pit0', 'true')
def write(pit, data):
f3 = open("Pits\Pit - a1\Pit-000.txt", 'w')
f3.write(pit + ": " + data)
f3.close()
write('pit0', 'true')
:incoming_envelope: :ok_hand: applied timeout to @turbid sandal until <t:1683372347:f> (10 minutes) (reason: duplicates spam - sent 4 duplicate messages).
The <@&831776746206265384> have been alerted for review.
lol rip
lol i tring to help
!voiceverify
!e
code
!eval [python_version] <code, ...>
Can also use: e
Run Python code and get the results.
This command supports multiple lines of code, including formatted code blocks. Code can be re-evaluated by editing the original message within 10 seconds and clicking the reaction that subsequently appears.
The starting working directory /home, is a writeable temporary file system. Files created, excluding names with leading underscores, will be uploaded in the response.
If multiple codeblocks are in a message, all of them will be joined and evaluated, ignoring the text outside them.
By default, your code is run on Python 3.11. A python_version arg of 3.10 can also be specified.
We've done our best to make this sandboxed, but do let us know if you manage to find an issue with it!
@jade salmon #media-processing message
code
Hello Everyone
Hey guys
@meager onyx ๐
Mic no worky.
I usually DM since nobody looks here.
Lol
I don't understand why we don't use the integrated channels.
How so?
But aren't we talking abt integrated chanells
ah
Oh mah bad
sorry
.
I'm 18 ik that
I used to use it for ingame voice chats via mc
or proximity chat
mr herman
is 35
hmmm
vimax?
hii
@wind raptor can i have perms for streaming
Don't have a verification.
@somber heath could I stream me working on my python discord bot
what ?
i don't have a verification
It's valid.
okay
Ayo kids ?
You were already in it.
Nope
ah
But the thing is voice verification idk how long will it even take
@jade salmon chillout... it's a little too fitting.
oh
I get it iget it
Wait what are the other requirements?
Dam bruh ๐
Alr alr alr .....
which command??
ah
Ale alr
i got it
!voice
Canโt talk in voice chat? Check out #voice-verification to get access. The criteria for verifying are specified there.
got it
48 = 2โ 2โ 2โ 2โ 3 = 4^2โ 3
what are u guys working on?
wow
??
korean homework
ok
?
(include (quote readers))
(setq memory-null? (lambda (x)
(nth (asm (mov eax x)
(cmp eax 0)))
3))
(declare (reader-macro (char ')) (lambda (c)
(read c)
(list (quote quote))))
(setq + (lambda (x y)
(asm (quote (mov eax x)
(mov ebx y)
(add eax ebx))))
(car *cpu-registers*))
(setq < (lambda (x y)
(nth (asm (mov eax x)
(mov ebx y)
(cmp eax ebx)
(jge fail)
(jmp success)
success
(cmp eax eax)
fail
(cmp eax ebx)))
3))
(setq 1-100 (lambda ()
(setq next 0)
(setq count 0)
(tagbody
next
(if (< count 100)
(progn (+ count 1)
(goto next)))
end)))
(setq nth (lambda (lst index)
(tagbody
next
(if (< (car lst) index)
(progn (setq (car lst) (cdr lst))
(goto next)))
exit)))
(setq memory-null? (lambda (x)
(nth (asm (mov eax x)
(cmp eax 0)))
3))
(setq null? (lambda (x)
(eq x nil)))```
i don't think that..
why?
Oh i guess i can talk now
umm..
Ima talk in few mins
Ayo sus?
zzzzz
Wow
haaaa
Dam dam
no
Yesh
i love kernighan style
Ngl I'm trying to still process my mind - cuz me a beginner ๐ฐ oof
Meanwhile compiler:- try whatever u want i will just give error ๐ฅฒ
https://soundcloud.com/plxstic-tm rate soundcloud profile 1-10
imma turn o nvideo game ost's
they're kinda too good to focus too
idk why
but they do sum for my adhd
Which lan is this mate ๐ค
hello
No that was a code example for Scheme 48
I'm simplifying square roots rn.
Algebra
cause dropout. LOL
And what's "scheme 48"?
!
I have never seen this type of code earlier ๐
Us bro ๐ฅฒ
Nah u know mane, i still don't know nun and what to do
Hey, I am new in this field. I want to learn the basics and advance level of python. Does anyone have any suggestion where can I learn python for free?
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
Can anyone tell me how they started their journey and how they improve themselves
sololearn's courses aren't good
same for w3schools
both sites seem sub par
I see
specifically for:
-- factual errors
-- incorrect/incomplete definitions/details of some concepts
-- answers lack formatting (one big example is the question where one answers is "None" instead of "None of the above"; and, given that there's no way to tell None and None apart on that site, this is quite confusing)
w3schools is quite general
they try to offer tutorials for everything
(that doesn't always end up well)
official Python tutorial is more reliable and up-to-date on most of the topics
https://docs.python.org/3/tutorial/index.html
though it lacks interactivity
@lofty crater what do you mean by extended?
adding new options during runtime?
usually that would involve something other than enum
for the following reason
suppose you have two separate pieces of code:
- uses the enum and handles all the possible cases
- adds new value to the enum
this results into first part becoming incorrect
second part breaks the second part
the "contract" of an enum is that it's exactly one of the options provided
how do you use the enum?
if the task you're trying to solve is:
do something based on the type of the value
it's probably better to factor out that behaviour into a method
or something equivalent to a method
you can look into how SQLAlchemy does the table names thing
it doesn't use a separate method but it does use a field/attribute for each type
though, given that it's Python, everything happens during runtime
there are static constructors in languages like C#
not compile-time but works
@turbid sandal
simulator not interpreter
window manager?
what process scheduling approach does it use?
@turbid sandal in file_handle.py you can use a loop/dictionary/set instead of copy-pasting the code
read-write implementations shouldn't be that much different
generally, avoid copying the code that many times
repository name's too long
everything before the name itself could be in the description/readme instead
@civic zephyr what encryption?
what algorithm?
@turbid sandal no, there are provably unbreakable algorithms
for example
!d operator.xor
operator.xor(a, b)``````py
operator.__xor__(a, b)```
Return the bitwise exclusive or of *a* and *b*.
simplest and most robust encryption
except for lack of MAC
@civic zephyr so, you mean asymmetric, right?
@turbid sandal this is obfuscation not encryption
doesn't fit modern standards in any way
just use something like RC4
unless you make RSA, the corporation, very angry, it's fine to use
it's so incredibly easy to write
@glad sandal
x
brb
What y'all talking about? @spark kettle
@glad sandal
@glad sandal so do you really like open source idea?
y'all ghosting me ๐ข
@civic zephyr is the tkinter question related to task scheduling or layout?
what do you use for clearing the frame?
why not destroy the frame in its entirety instead and replace it with an empty one?
iterating over frame.winfo_children() seems fine too
like race condition
(I'd just do this because it's simpler)
another thing why this will be simpler:
certain layouts are updated only on adding children not on destroying children
I don't have DMs on
(and I won't enable them for larger servers)
produce a minimal working example which doesn't contain proprietary information
```py
```
or
```python
```
class MyFrame(Frame):
def __init__(self, root):
"""Constructor method"""
Frame.__init__(self, root) # Frame class initialization
self.init_container() # initialize all widget containers
self.cart = (
SmartCart()
) # initialize SmartCart dict object - key = Item object item selected, value = quantity
self.welcome() # start the application
self.data = StringVar(self, "Subtotal: 0.0") # Associated with subtotal label
self.root = root
def init_container(self):
"""Initialize widget containers"""
self.quantity_entries = [] # qunatity entry list
self.states = (
[]
) # holds state if selected/not i-th list item holds selection for i-th item
def clear_frame(self):
"""Clears the previous frame"""
print(self.winfo_children, len(self.winfo_children()))
for widget in self.winfo_children():
widget.destroy()
def exit_application(self):
"""Exits the program"""
self.root.destroy()
def welcome(self):
"""1. Welcome window - refer spec file for details"""
self.clear_frame()
Label(root, text="****Welcome to Instant Cart!****", background="gray70").pack(
side=TOP
)
# your code here
Button(root, text="Start Ordering", command=self.shop_by_category).pack(
side=TOP
)
# Start Ordering: Button โ start the program, command
Button(root, text="exit the program", command=exit).pack(side=BOTTOM)
# Exit Application: Button โ exit the program, command = exit_application
root = Tk()
root.title("Instant Cart") # set window title
# your code here
# create a myframe object and layout
window = MyFrame(root)
# call mainloop
root.mainloop()
@midnight agate no, I don't go for the helper role
why is the MyFrame.welcome using root instead of self.root?
currently trying to figure out why self.data isn't showing up in self.winfo_children()
ah, it's a variable not a widget
where does MyFrame's .pack get called?
does MyFrame or any of its children ever get displayed?
it shows
text
button
button
right?
these aren't children of MyFrame
they are children of root
in welcome
change all root to self
in __init__
add self.pack()
looks like you didn't change to self for the exit button
no
you still have root there
apparently
previous implementation repeatedly called welcome
which created buttons as children of root
therefore those buttons weren't children of self
that's why they weren't cleared
you could've just created the buttons only once
right now self.welcome() gets called repeatedly
it should probably be named something different then
reset given that it does both clear and setup
!paste
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.
it defaults to py
Password protect links using AES in the browser.
Password protect links using AES in the browser.
@vocal basin :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 | print(*{}.items)
004 | TypeError: print() argument after * must be an iterable, not builtin_function_or_method
whereas
Butter, salted|Dairy|2.99|lb
Butter, whipped, with salt|Dairy|3.99|lb
Cheese, american|Dairy|4.99|lb
Cheese, cheddar|Dairy|5.99|lb
Egg, white|Dairy|1.99|dozen
Egg, brown|Dairy|2.99|dozen
Egg white|Dairy|3.99|Oz
Buttermilk|Dairy|2.99|lb
Chocolate Milk|Dairy|2.00|Gallon
Milk, reduced fat, 2%|Dairy|1.99|Gallon
Milk, whole|Dairy|2.99|Gallon
Yogurt, nonfat|Dairy|2.99|lb
Yogurt, whole|Dairy|2.99|lb
Apples|Fruit|3.99|lb
Oranges|Fruit|2.99|lb
Banana|Fruit|1.69|lb
Grapes|Fruit|3.99|lb
Blueberry|Fruit|4.99|pint
Strawberry|Fruit|3.87|lb
Pineapple|Fruit|1.99|each
Raisins|Fruit|3.99|lb
Cauliflower|Vegetable|1.99|lb
Brocolli|Vegetable|1.99|lb
Spinach|Vegetable|1.99|packet
Baby SpinachCauliflower|Vegetable|2.99|lb
Beet|Vegetable|1.99|lb
Bell Pepper|Vegetable|1.00|each
Carrots|Vegetable|2.99|lb
Potatoes|Vegetable|2.99|lb
Onions|Vegetable|1.69|lb
Tomato|Vegetable|2.99|lb
Whole chicken organic|poultry|4.99|lb
Whole chicken|poultry|2.99|lb
Thigh chicken|poultry|2.99|lb
Breast chicken|poultry|2.99|lb
Chicken ground|poultry|2.99|lb
Turkey breast|poultry|3.99|lb
Beef Chuck|meat|2.99|lb
Beef Patties|meat|2.99|lb
Ham|meat|2.99|lb
Salmon, Atlantic|seafood|4.99|lb
Salmon, Sokeye|seafood|5.99|lb
Shrimp, raw, tail on|seafood|5.99|lb
Shrimp, raw, tail on|seafood|5.99|lb
Tilapia|seafood|2.99|lb
!e
print(*{}.items())
@vocal basin :warning: Your 3.11 eval job has completed with return code 0.
[No output]
this produces an error
for k, v in self.items:
one of
items() not items
.
Item is missing __eq__ and __hash__ implementation
seems like subtotal is using k.get_price
which would imply that Items are used as keys
to use something as a key in a dictionary, it needs to be hashable
!e
class Example:
...
{}[Example()] = None
@vocal basin :warning: Your 3.11 eval job has completed with return code 0.
[No output]
oh
I guess it works sometimes
now
the actual issue would be
!e
class Example:
...
print({Example(): 0, Example(): 0})
@vocal basin :white_check_mark: Your 3.11 eval job has completed with return code 0.
{<__main__.Example object at 0x7f47990a00d0>: 0, <__main__.Example object at 0x7f47990a0110>: 0}
two values aren't equal by default
!e
class Item:
def __init__(self, name):
self.name = name
def __repr__(self):
return f"Item({self.name!r})"
print({Item("apple"): 0, Item("apple"): 0})
@vocal basin :white_check_mark: Your 3.11 eval job has completed with return code 0.
{Item('apple'): 0, Item('apple'): 0}
!e
class Item:
def __init__(self, name):
self.name = name
def __repr__(self):
return f"Item({self.name!r})"
def __hash__(self):
return hash(self.name)
def __eq__(self, other):
if isinstance(other, Item):
return self.name == other.name
else:
return NotImplemented
print({Item("apple"): 0, Item("apple"): 0})
@vocal basin :white_check_mark: Your 3.11 eval job has completed with return code 0.
{Item('apple'): 0}
now, it treats two items with the same name as equal
in a real, app, I'd expect there to be a separate id field for each Item
if you're guaranteed to create each object no more than once, then the current implementation is fine
command=self.welcome()
should be without ()
checkbutton = checkbutton(...)
should be
checkbutton = Checkbutton(...)
whereever you have Text=, it should be text= instead
yes
that's why partial
packing with anchor will also fail
because grid
can't mix grid/pack
I got it to this point
PyCharm/VS Code show most of the errors
this is CE not paid
in particular, this happens with subtotal's layout
btw, SmartCart.subtotal doesn't return anything
hi
why do you have en dash in comments?
instead of -
Button โ exit
^
this en dash, not -
not as visible as em dash
but it stands out anyway
this is very much against pep8
!pep8
PEP 8 is the official style guide for Python. It includes comprehensive guidelines for code formatting, variable naming, and making your code easy to read. Professional Python developers are usually required to follow the guidelines, and will often use code-linters like flake8 to verify that the code they're writing complies with the style guide.
More information:
โข PEP 8 document
โข Our PEP 8 song! :notes:
Use non-ASCII characters sparingly, preferably only to denote places and human names.
obfuscate
I also changed COMMAND= to command= everywhere
which of the button should it happen on? "Dairy"?
or before that?
I didn't finish laying it out
self.root -> self
in Label call
Label(self, text="Choose Category", background="gray70")
grid should be called on self.dairy_button
partial doesn't have grid
maybe there shouldn't be a self.dairy_button at all
just
Button(
self, text="Dairy", command=partial(self.start, Item.dairy_items)
).grid(row=2, column=5)
you can't do grid inside Button
at least via the .grid method
you'd still have to assign it to something
to a variable, for example
Button(
self,
text="Dairy",
command=partial(self.start, Item.dairy_items),
).grid(row=2, column=5)
welcome to the newline hell that is my mind
not, it's not the convention
^^
@civic zephyr
I think something like this would look clearer
def subtotal(self):
return sum(item.get_price() * quantity for item, quantity in self.items())
for subtotal
k is item
v is quantity
but this one uses concrete names for what keys/values represent
it's a generator comprehension
sum's parentheses do the job
!e
print(sum(x ** 2 for x in [1, 2, 10]))
@vocal basin :white_check_mark: Your 3.11 eval job has completed with return code 0.
105
adding and squaring are interleaved in this example
how operations are ordered in that example
1 * 1
0 + 1
2 * 2
1 + 4
10 * 10
5 + 100
oh, no, it actually does 0 + 1
corrected
get next item
add to total
get next item
add to total
get next item
add to total
first addition is missing in some implementations of sum
for example, if you implement sum using reduce
specifically, reduce without a starting value
height= not set
no
not grid
you have width=2 on the text field
you need to add height=something too
another thing you're missing is row += 1 at the end of the loop
for item in current_items:
...
row += 1
grid is easier there, I think
this
+=
inside the loop
and checkout is just missing .grid call
no, you don't need to do that
just use the current value of row with some offset
like it's already done in the code
row
row+1
row+2
row+3
it seems reasonable to have price at column 2
because it's already about prices
all the bN = assignments are unnecessary
use textvariable=self.data as the comment says
you will need textvariable functionality later
self.data.set(str(self.cart.subtotal()))
Label(self, textvariable=self.data).grid(row=row, column=1)
instead of this
the purpose of textvariable is the following:
later, when you add something to cart, label's contents should be updated
and, instead of managing complex callback logic, it's simpler to just bind the label to the variable instead
Use enumerate instead of += stuff
no
yes
semantically incorrect
value of row is used after the loop
thatโs fine
Ok I correct myself
Will be undefined if the loop doesnโt run through at least once
there are actually two separate places where row is used
one should be enumerate
another shouldn't
but do you redefine row at the non-enumerate part
how will you handle the logic if row before the loop started at non-0?
.get is only for dictionary?
In the screenshot, it was defined to start at 0
For any mapping maybe
Donโt quote me on that
that's not an answer.
It is
It is known to start at 0, and does not vary by the screenshot
Thus it is fine
it's not known to start at zero.
there might be additional elements before the list
row = ???
for index, item in enumerate(current_items):
... self.states[index]
row += 1
what
get()
Why are you using index in the for loop header instead of row
because values that are used in self.states[here] must start at zero
for row, item in enumerate(current_items):
can row = 0 before the loop be removed then?
yeah
you're wrong. think again.
I'm completely not wrong
!e
for index, value in enumerate([]):
pass
print(index)
@vocal basin :x: Your 3.11 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "/home/main.py", line 3, in <module>
003 | print(index)
004 | ^^^^^
005 | NameError: name 'index' is not defined
๐ซฃ
and I asked
do you redefine it later?
and no response on that yet
jay u are speaking with chatgpt mastered edition
I know about this, and I commented on it earlier
๐ค
I missed the "do", sorry
no, it doesn't redefine
so it uses the ending value?
it uses the value
and if each element takes up two rows?
self.states[] shouldn't happen the first place, actually
unless you want to say that the screenshot from before is wrong
I'm only basing my code on what I've seen in the screenshots
IntVar() should be stored in a variable
then appended to states and used as variable in Checkbutton
accidentally same
no?
row=0 at the start is an accident
you can specify the start of enumerate
there just happens to be nothing before
!e
for i, x in enumerate("abc", start=3):
print(i, x)
@kindred granite :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | 3 a
002 | 4 b
003 | 5 c
there is actually a solution that's better than either of those two
Hello
refactor always better than bandaid
you're refactoring towards incorrect use of enumerate
it's not incorrect ๐ข
self.states[row] is the same IntVar right?
should be logically
err think that was a comprehension question for them, my bad
!e
from itertools import count
rows = count()
row = next(rows)
print(row)
for element in ["a", "b", "c"]:
row = next(rows)
print(row)
row = next(rows)
print(row)
@vocal basin :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | 0
002 | 1
003 | 2
004 | 3
005 | 4
I think this would make sense
self.statuses.append(int_var)
checkbutton = Checkbutton(
..., variable=int_var
)
most situations don't involve row = next(rows)
it's necessary in only one or two places
- elements
- subtotal
other usecases are just .grid(row=next(rows)) on one line
int_var = IntVar()
not quite
you were making a new IntVar in your highlighted line
which you now aren't
yes, those two should be separate
one is for selecting
another one is for quantity
generally, use of values defined during iteration isn't a good practice
in almost any context, whatever, that's in for <here> in, would be treated as (re)defined in a loop not just assigned in a loop
figuring out what code, that's shadowing/redefining variables in such a manner, does is harder, so not a very good way to refactor
there is a way to, in some sense, elevate status of the (parts of) the loop's scope to the outer scope: for-else
for i, _ in enumerate(...):
...
else:
i = ...
!d dict.setdefault
setdefault(key[, default])```
If *key* is in the dictionary, return its value. If not, insert *key* with a value of *default* and return *default*. *default* defaults to `None`.
and in statically typed languages it's just not going to compile
!e
d = {0: 1}
print(d.setdefault(0, 2))
print(d.setdefault(3, 4))
print(d)
@vocal basin :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | 1
002 | 4
003 | {0: 1, 3: 4}
why not this?
cart[i] = ...
oh
@jade salmon it's allowed within reasonable limitations
it's a dictionary, not a list, right?
is self.quatity_entries a dictionary?
why is it ever out of bounds?
amount of appends is sufficient
tl;dr of the code
for item in current_items:
self.quantity_entries.append(IntVar())
for i in range(len(current_items)):
self.quantity_entries[i]
it's not going to fail
this is in different methods
and, yes, zip
"reasonable limitations"
I think zip is actually a specific class, or the return type of it is
!e
print(type(zip))
print(type(zip()))
@vocal basin :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | <class 'type'>
002 | <class 'zip'>
what I meant
just like groupby and others
@civic zephyr you need to call .get() on the variable
(or else you get the unhashable type error)
variable in tkinter sense
!e py names = 'Aaron,', 'Sally', 'Peter' ages = 20, 19, 17 for name, age in zip(names, ages): print(f'{name} is {age} years old.')
@somber heath :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | Aaron, is 20 years old.
002 | Sally is 19 years old.
003 | Peter is 17 years old.
cart[self.states[i]] = ...
^^^^^^^^^^^^^^ unhashable
cart[self.states[i].get()] = ...
^^^^^^^^^^^^^^^^^^^^ hashable
!e
for tuple_ in zip('Aaron,', 'Sally', 'Peter'):
print(*tuple_)
@vocal basin :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | A S P
002 | a a e
003 | r l t
004 | o l e
005 | n y r
!e
a = "abcdef"
b = "ghi"
for t in zip(a, b):
print(t)
for t in zip(a, b, strict=True):
print(t)
@kindred granite :x: Your 3.11 eval job has completed with return code 1.
001 | ('a', 'g')
002 | ('b', 'h')
003 | ('c', 'i')
004 | ('a', 'g')
005 | ('b', 'h')
006 | ('c', 'i')
007 | Traceback (most recent call last):
008 | File "/home/main.py", line 6, in <module>
009 | for t in zip(a, b, strict=True):
010 | ValueError: zip() argument 2 is shorter than argument 1
Unequal lengths aren't an issue. itertools.zip_longest can be another tool to use.
yes
!d itertools.zip_longest
itertools.zip_longest(*iterables, fillvalue=None)```
Make an iterator that aggregates elements from each of the iterables. If the iterables are of uneven length, missing values are filled-in with *fillvalue*. Iteration continues until the longest iterable is exhausted. Roughly equivalent to:
strict=True I believe would only be useful if you want to catch the error and do something else
Sure.
(was not sure about the fillvalue name)
roughly equivalent to:
left us hanging ๐ข
!d itertools.count
itertools.count(start=0, step=1)```
Make an iterator that returns evenly spaced values starting with number *start*. Often used as an argument to [`map()`](https://docs.python.org/3/library/functions.html#map "map") to generate consecutive data points. Also, used with [`zip()`](https://docs.python.org/3/library/functions.html#zip "zip") to add sequence numbers. Roughly equivalent to:
```py
def count(start=0, step=1):
# count(10) --> 10 11 12 13 14 ...
# count(2.5, 0.5) --> 2.5 3.0 3.5 ...
n = start
while True:
yield n
n += step
``` When counting with floating point numbers, better accuracy can sometimes be achieved by substituting multiplicative code such as: `(start + step * i for i in count())`...
why nested list?
to make it key, there is .get()
but that doesn't look like what you're trying to do
that's the thing: this is not calling .get on a dict
it does it on IntVar
no
self.states[i] is IntVar
cart[items.get()]
remove this
I doubt that it's going to be logically correct in its current state
cart is used somewhere instead of self/root
I saw and fixed it but I don't remember where
in main, yes
there's Label(cart) or something similar
cart is incorrectly used as a parent somewhere
remove .cart there
also
it should be
self.data.set("Subtotal: 0.0")
to change the displayed value too
this is where it's changed
and it auto-sets the displayed subtotal
yes
just copy the previous call to .set
self.data.set(str(self.cart.subtotal()))
something like this
should probably make a separate method for this
to avoid copying code
and to make changing it easier
what do you mean skips over?
only shows the last element?
probably missing row += 5 or something
also
looks weird that exit button is inside the loop
!voice
Canโt talk in voice chat? Check out #voice-verification to get access. The criteria for verifying are specified there.
or even this whole thing
well, if .set() is never called, that's expected
what's the question
when does it appear?
when i run the code
the key shouldn't be items.get()
quite sure it should be current_items[i]
because items.get() is always 0 or 1
I think it should've never been a list in the first place
especially a list, as field on the frame, looks not very correct
v.get()
I may be back later
can you please help me
all good thanks for helping anyway
can you help me please
@lavish rover
@verbal zenith
@vocal basin thanks for the help again, I was t able to finish it but I submitted it anyway
hey hi bois what's going on ?
@civic zephyr is it Tkinter?
@upper mirage
My vengeance shall last seven generations.
No problem. You don't have to apologise.
I'll often just drop out of a call, myself, when I need to.
I thought you just DCed is all.
vengeance is mine, saith the Lord
Yoink.
@somber heath Hello
what
It's what you say when you steal something so it becomes an authorised taking.
An exclamation that, when uttered in conjunction with taking an object, immediately transfers ownership from the original owner to the person using the word regardless of previous property rights.
@dapper prawn ๐
yoinking vengeance, apparently
zip it
no
yeah
no
why not
Do u think he is hot?
cuz he's extremely hot
o
He's about 36.5ยฐC
holden wrecks and boiling diesels
yeah yeah
steam in forty-five degrees
๐
what

ok so?

mate

what the fuck are you doin?
ok?
Print("hello")
print*
Count= +1
ok?
Import time as t

Why did u send these pic?
def !party is idiot:
๐ณ
print("!party is idiot")
!party_is_idiot()
def parzi_is_an_idiot():
...
brb
A
Ajsh
Ddddhd9s
Var1 = "hello"
Var2 = "see you"
Response = input()
If Response == Var1 or Var2:
print("see you")
else:
print("fuck you")
yuendemu
@fresh charm ๐
hello haha
@idle wave ๐
!voice
Canโt talk in voice chat? Check out #voice-verification to get access. The criteria for verifying are specified there.
@peak dome ๐
@plush valley ๐
@nova prawn Cisco?
Cisco networking?
u talikn bout this cert?
okok
@vocal basin Hello?
yeah
me?
I never worked as a networking engineer
If u wanna be a networking engineer
i sugget to get this certification
"Cisco Certified Internetwork Expert" or in my op
i really like the " Wireshark Certified Network Analyst"
https://www.wcnacertification.com/
https://www.cisco.com/c/en/us/training-events/training-certifications/certifications/expert/devnet-expert.html
The WCNA Certification (formerly called "Wireshark Certified Network Analyst") Program Information - Created by Laura Chappell for the Protocol Analysis Institute, Inc. Network analysis certification for troubleshooting, optimization, and security/network forensics.
Are you studying Cyber sec?
@junior ermine wassup
damnit where do u see the paparazi
parzi
p
a
r
z
i
@junior ermine
there is copilot
Listen to me
or Amazon's version of it
I doubt I'll ever use any of these anyway
@somber heath where are you from?
but I can see how Copilot actually helps people, unlike GPT
uhmmm
yeah?
actually no
if u have a problem with your code
i wasnt talking to you
Would you like to guess or shall I tell you?
but you never get what was the problem
uhmmmm, ok
Copilot isn't built for it
therefore, having a more limited scope, it's more stable and reasonable
but the people use it to solve their problems
Uk?
London?
shit
Hold on
Us?
Au?
oh wow
it would be pun-worthy to reply to "Au" with a gold medal

how deep "from scratch"?
im starving
most solutions involve sampling at least at some point
why do u have a pizza and a dish of pasta in ur bio?
pineapple is a verb
we dont talk about that shit shh
pineapple pizza
pineapple spaghetti
for the second one
is he a sparrow?
a pigeon
stalking you
auoo
why ya laughing? @junior ermine
alr alr alr
and the speed of the pigeon?
That pigeon is talking on ur back ๐ก
hardly more than 40 I think
good

