« first day (3747 days earlier)      last day (1184 days later) » 

5:04 AM
The phyton misspelling gets me for some reason. Screening some candidates on LinkedIn for a backend position, one of the rejected one replied with this (and kept repeating it somehow) asking for update (we already notified via email)...
 
 
1 hour later…
6:29 AM
I have a filters dict
I am trying to insert/update from args ---
since python 3.7.1 I am getting key error
for key, value in args.items():
filters[key] = f"`{value}`"

Snippet of what i am trying to do
 for key, value in args.items():
    filters[key] = f"`{value}`"
filters = {a:'lol'}
 
6:47 AM
sorry something else caused the error :p
 
7:17 AM
@shad0w_wa1k3r first time i hear of someone misspelling it...
 
cbg
 
cbg :D
 
7:33 AM
Anything fun happening in the Python world?
 
I was raging while trying to solve algorithm problems (because cant solve some of them) for getting warm for interviews. Then I found out the problem. I may or may not solve the problems but this is not the problem. The problem is, most of the algorithm websites (for ex. hackerrank) have terrible English and can't describe the problem properly. Communication is very very important fellas. I found out this when I found out a website that has a clear description.
 
7:49 AM
That's probably the most important thing to learn from such challenges.
 
@Mikhail It's been calm lately. the most exciting thing I saw this week is that some prominent names in the packaging community talk about the uselessness of semantic versioning for everything except huge projects, with many adopters of zer0ver in the process. so look for CalVer to gain some more traction beyond pip.
 
@Alper when this happens to me, I usually head over to the dicuss tab and if it is a common issue there is already a thread explaining it better
 
Taking a quick look at zer0ver over there, it seems like it just prepended a 0. to the same versioning system that we currently have, does it not? I don't see how this fundamentally altered anything
At that point the 0. might as well not be there.
 
@Arne not sure if joking
 
Haha. I didn't want to say it outright, but im with Miyagi on this one :P
 
7:55 AM
oh, zerover is a joke for sure, and is used to shame big projects who are too chicken to bring out a version 1.x
 
my sarcasm-detector-v0.2.3 says there's a 50% chance people don't get the joke and wear the badge proudly
 
Now that Arne succinctly described what the aim of zer0ver is, i've decided that im all for it!
 
Just pushed it to our internal chat... puts on the fluffy hat of shame
 
8:39 AM
Hi, from this answer stackoverflow.com/a/19389957/6086913, any() & all() will not iterate over the remaining elements if "True" is found
i tried
multiples_of_6 = (not (i % 6) for i in range(1, 8))
all(multiples_of_6) # results False
list(multiples_of_6) # results [False, False, False, False, True, False]
why the all() didnt stop at True? and/or list(multiples_of_6) gives the remaining of elements of the generator?
 
all stops at False.
 
obviously, all can't stop at True, it has to stop at False
 
Note that your first element not 1 % 6 is False.
 
8:55 AM
ok, so list(multiples_of_6) gives the remaining un-iterated items , got it thanks
 
9:10 AM
welp, seems like I have a weird issue
import sys
import re
l = {'aa':'a', 'ab':'b', 'ac':'c', 'ad':'d', 'ba':'e', 'bb':'f', 'bc':'g', 'bd':'h', 'ca':'i', 'cb':'j', 'cc':'k', 'cd':'l', 'da':'m', 'db':'n', 'dc':'o', 'dd':'p'}
old_address = (' ').join(re.findall('.{1,2}',sys.argv[1]))
new_address = ''.join(l[p.upper()] if p.upper() in l else p for p in re.split(r'(\W+)', old_address))
print(new_address.replace(" ", ""))
this should work, but doesn't
no error either
BUT if i replace l = {} with a smaller/different one, then it work? It's kind of weird but there no error...
btw, the test string is this:
acbbabddacdbacdbacadadadacadadcbacdbab
 
if p.upper() in l <- think about it
 
Would be nicer if you can also give context about what you were trying to do. but, p.upper() in l would always be False, your dictionary here has only lowercase keys. So i'm not sure why you expect it to work
There's one golden rule. If it doesn't work, it doesn't work, and you've made a mistake. The code doesn't lie (there can be exceptions ,but it's better to assume you made a mistake first and foremost, or you'll be unable to see past what you think you wrote)
 
@Aran-Fey but this can't be coming from there? I literally copied that from another file i had that was working...just changed l to different values hmm
 
lower-case values instead of upper-case values?
 
@Aran-Fey yeah, they were lower cases
the working one just had this:
l = {'11':'1', '00':'2', '01':'3', '10':'4'}
as difference
and the fact there no error is very weird too
that*
 
9:26 AM
those are neither lowercase nor uppercase
which means they will work. Unlike lowercase keys
 
@Aran-Fey what do you mean? so i can't use lowercase letters as keys??
o-o
 
Look at the keys in that dict you posted
what's the lowercase of '11'? what's the uppercase of '11'?
and there should be no error because the code is doing exactly what it's supposed to do. That is, take an operation if and only if a key matches in the dictionary. Only, you need to pause and take the time to realise that none of your keys will match as-is
 
You can use lowercase letters as keys, but then what happens if you try if p.upper() in l?
 
@Aran-Fey nothing? it doesn't match any of the keys?
 
would that explain why your code doesn't work?
 
9:28 AM
@ParitoshSingh but isn't 11 already lowercase?? sorry if I'm confused
@Aran-Fey I guess? the part where there was numbers worked, but not the letters version i showed earlier...
@ParitoshSingh any ways to make them match? or do i need to use a different data structure maybe?
 
@NordineLotfi well. sure, you can say it's already lowercase... a lowercase on something that's already lowercase works just fine though. but then..if you're saying it's already lowercase..then i'll focus on what's the uppercase of ''11"
@NordineLotfi This is what we call a "logical" error. It's like typing 2 + 2 and then complaining that you wanted the result of 5 + 5. You have to write 5 + 5 to get the result of 5 + 5. You need to take a pause and understand: you've explicitly written code here that is different from what you wanted to do.
 
@ParitoshSingh there no uppercase of 11?? or do you mean the value of the key?
@ParitoshSingh but the number version i posted does work. It's the version with letters as keys where it doesn't
 
@NordineLotfi I simply mean, "what happens when you take the string "11" and do a .upper on it.
 
oOOOOOOOOO
I GET IT
THANK YOU
 
@ParitoshSingh having a 0.* version is actually a lot worse than being redundant, as it effectively means that there is no public API, and any version may introduce breaking changes. So the list of shame at zer0ver isn't just "look at these people doing something silly", it's "look at these people doing something dangerous, borderline malicious"
 
9:33 AM
Makes sense, i actually remember being introduced to pandas and finding myself "uneasy" with the notion of "no stable release". That was my knee jerk interpretation of their version number at the time
 
I still haven't forgiven the greenlet people for casually breaking OpenStack multiple times. They finally went on 1.0 now, after 14 years of 0.*!
 
@Arne I can't even imagine when python will be 4.0. Will feel weird to be honest
 
@ParitoshSingh It completely depends on the project of course. Some just don't introduce breaking changes
 
.. in which case they obviously should just release 1.0. But hey, baby steps. developers are a skittish people, no use being too pushy.
 
9:38 AM
oh yeah, wanted to ask too
how do i change the part where the "step" are specified? so that i can use something like sys.argv[2] instead of changing/hardcoding it in the file:
(' ').join(re.findall('.{1,2}',sys.argv[1]))
the '.{1,2}' part i mean
do i just use a variable or?
wait, nvm, found how to do it
 
9:57 AM
@NordineLotfi pro-tip: l.get(p.upper(), p)
@NordineLotfi and () is redundant there
@NordineLotfi and there's absolutely no reason to get so excited
 
@AndrasDeak Thanks, I'll try it :)
@AndrasDeak Yeah i know :D Just left it there from another script
@AndrasDeak wasn't my intention! was just because i was confused and took a while to understand thanks to the hints i received...
 
@NordineLotfi is that the RE you are actually using? Isn't that just adding a space every 2 characters?
 
@MisterMiyagi yes, but in each line of text separately
 
yeah it is :)
I didn't knew how to match every N character and changing them, so i used whatever worked since I'm just prototyping/testing stuff
 
Is that the intention? Probably not
 
10:12 AM
@Aran-Fey it kinda is, i mean at least the result match my expectations (for now...)
 
@NordineLotfi without regex you could use a grouper sopython.com/canon/14/splitting-a-list-into-even-chunks
assuming you want to work on subgroups all of length n
 
@AndrasDeak that's a good idea yeah :o Thanks!
didn't know sopython had a list of common questions either...only checked it for the salad vocabulary and the chatroom rules
the more you know
 
10:43 AM
we mostly use it for close voting duplicates
 
Hi can anyone help me with a beginner level problem?
I'm trying to get the green percentage of a image. Manage to get the values for one image
But just not sure how to do it for a entire directory fill with images
My main directory is ("./Picture/*jpg")
 
@Lobsterman please see our code formatting guide to chat and practice in the sandbox if necessary
That's also a bit much code so it might overall be easier to post the code in a code paste site and link it here. But for future reference please consult the formatting guide.
 
@AndrasDeak Oh sorry. Will do
 
10:59 AM
no worries
 
Strange. "get amount of green in image" makes my deja vu sense tingle.
 
In here or on main?
Jan 14 at 11:31, by Lobsterman
Need to calculate each picture of a directory green percentage and create an excel containing set values to be displayed in a geospatial map
 
@Lobsterman Do you know how to do some other, simpler task "for a entire directory filled with images"? Say, "print the name of each image for an entire directory filled with images"?
 
Jan 14 at 11:42, by MisterMiyagi
@Lobsterman You might want to take a look at pathlib and the Path.glob method.
@Lobsterman please review your earlier discussion here ^ and make sure you're asking new things rather than making the kind people here repeat themselves
@Lobsterman So the answer is 1. turn your existing solution that works for 1 image into a function for ease of use, 2. use the help you got 4 days ago to implement a loop over all image files (I'm certain SO main also has a few answers for this problem, 3. apply your function to each file.
 
@MisterMiyagi I ask this before a week ago. sorry for the repeated question
2
Q: Need to find a way to calculate the G pixel percentage

LobstermanI need to calculate the amount of green pixels in a given picture for a project. I already found a way to generate the green part of a image. Just need to find a way to calculate the green percentage of the given image. And how do you loop it for a image directory? Here's the codes that I have ga...

I posted the question on stack overflow. I hope it's clearer
 
11:07 AM
@Lobsterman for what it's worth the answer you got there is terrible
@Lobsterman what you've been asking is clear, the problem is that you've already been told to do and you're asking the same thing without any sign of improvement thanks to the help you got.
 
11:27 AM
I love this community, lots of people might lose their job if StackOverflow doesn't exist. It is a fact.
Developers are real bros!
While other professions declare war on each other for available seats, we make seats for some other people because we are a union. This is a really different aspect to look at it.
 
Unless they insist on using emacs, you mean.
 
11:45 AM
Or tabs. Or windows.
 
cbg, is deepcopying the root node of a linked list enough to duplicate a linked list? I have an MCVE but I will link it if what I asked needs one
I tried deepcopying only the root node, and printed the ids of the copied root linked list and original root node linked list and they are different, so is my assumption correct?
 
you compared only the ids of the root nodes or all nodes in both lists?
 
@python_user to be sure I'd iterate both linked lists from start to end in parallel, checking link1 == link2 and link1 is not link2. Assuming you don't have tricky objects such as numpy arrays.
 
no the whole list, here is the MCVE pastebin.com/Mzu4PfSm
 
either way, deepcopying is always enough to create a duplicate of anything
 
11:51 AM
@AndrasDeak its just integers, I was doing a code site challenge and I wanted an easy way to make a copy of a linked list
@Aran-Fey I was not sure this also applied to custom classes but its cool it does
 
@python_user seems good to me. Just drop the whitespace from default argument definitions
 
I take that back
>>> deepcopy(deepcopy) is deepcopy
True
 
@AndrasDeak thanks, yeah sure, I guess this will also apply to binary trees then
 
user14663859
Hi
 
Dec 15 '20 at 14:44, by python_learner
@AndrasDeak I recently forced myself to do what you said not to do :/, glad I can stop it
You need to force harder ;)
 
11:57 AM
@AndrasDeak laurel, I stopped using spaces when calling a function, definition is still muscle memory
 
@Aran-Fey Copying plain cannot work for some other things as well, e.g. the number 1. Everything value-ish does not have a proper identity in the first place, so copying is not a useful concept.
 
@Aran-Fey Looks like it may be smart enough to not make unnecessary copies.
from copy import deepcopy

a = 6849
temp = [9000, 9001]
temp2 = deepcopy(temp)
print(temp2 is temp) #False
for i in range(len(temp2)):
    print(temp2[i] is temp[i]) #True
 
@Aran-Fey I tried with some normal function and it was also true (foo:=lambda:None) is deepcopy(foo) (I dont do this, just to explain that it does return True:) )
 
ick, i may been using discord too much.
 
12:05 PM
while I am now aware that what I asked works, how does python know to deep copy? I mean how does it know the nodes are linked?
 
the copy and pickle module both have some extensive explanations.
basically, Python knows how to copy the builtin types, and classes are just collections of builtin types.
Plus magic voodoo sauce.
 
alright, I will check that out, laurel, I knew there was some magic for builtins, "classes are just collections of builtin types." makes it easier to abstract
 
Gello
*Hello
 
@RunningChild please don't ask for help here with fresh questions on the main site as per our rules
@RunningChild hello. You can edit/delete messages for 2 minutes in chat :)
 
oh
okay.thanks.
 
1:04 PM
This might seem like a bit a stupid question, but If I have two datatypes A and B. A is intuitive for humans to input B is better numerically. Now I create objects in my main function which internally use type B. I am wondering where to do the conversion? My file is getting kinda large(~700) lines and I think of cleaning it up a bit by splitting things into multiple files. Now do I do the conversion from A to B in 1) the main function 2) a random converter function 3)in the constructor of class?
 
Doing it in the constructor should be fine
 
you might want to have an alternative constructor as a classmethod. that's very flexible.
 
Kinda hard to say without knowing specifics though tbh. For example, if A is str and B is int, then writing a class that accepts '3' and automatically converts it to 3 is just... no
 
@Aran-Fey it would go into this direction, not so simple, but yeah I would accept inconvenient type A in the constructor, which somehow rubs me wrong, but I'm not sure why
@Aran-Fey I feel the same way, but could you specify your reasoning more?
 
It's essentially because there is no good reason to ever pass a string that looks like a number into anything. Just use a real number. If the class needs a number and you give it a string, then most likely you did something wrong. So basically it's a matter of evaluating whether automatically converting from A to B would be convenient, or more likely to hide accidental mistakes
 
1:16 PM
I'm confused first you said constructor should be fine, now you say the conversion should happen outside. Which is it?
the conversion takes about 50lines, so it's not as easy as calling str("42") just to give context
 
@Hakaishin Depends on what A and B are. If this had been a n00b asking this question, I would've prodded them for more details, but I trusted you to know for yourself if doing it in the constructor would feel... off
 
1:45 PM
If the code is taking 50 lines or so, then i do think it shouldn't be dumped in the open. Even if you call the code in the constructor or the main, it makes sense to me that it should be put in a function for sure. So, the real question then: do you want to force your users to enter B, force them to enter A, or give them a choice. This probably is the real question you need to resolve.
 
I know I want them to enter B, because measuring B is much easier than A. The question is really where to do the conversion. Yeah I agree, right now it's "in the open" which well, it's ugly and not so easy to extend
 
If you want them to enter B, i'd just hardwall it. If you dont mind forcing users to enter B, then you can explicitly reject A and give a useful message about the input.
I'd rather work with a clean API and be bit by it once upfront, rather than work with an API that accepts anything and be bit by it multiple times in unexpected ways.
But yeah, this call is yours to make
 
If you choose not to allow A in the constructor, you can still consider a factory method like MyClass.from_A(...)
 
Good point, but I can tell you users can't even input B. As said measuring A is kinda simple, converting it to B is hard and they would have to do it by hand. We are talking about a physical measuring process of distances and angles, they can't just guestimate B, while they can do that for A.
 
Or even a B.from_A(...)
 
1:53 PM
Ahh. That makes it seem like i'd simply want to accept A, if i want my userbase to be actually able to make use of my API
 
I recommend Aran's B.from_A(some_a). You generally want the constructor itself to be simple so that you can programmatically create objects as needed and __repr__ roundtrips are cheap.
 
that's a great suggestion too, the from reminds me almost of the pandas read_csv or read_excel style of reading stuff
 
Good idea
 
@ParitoshSingh no need for pandas: int.from_bytes, float.fromhex etc ;)
 
Gotta love python's consistent naming scheme
 
1:57 PM
haha
 
half credit for chain.from_iterable
 
I hope log.warn gets deleted next release, it's always above warning in autocomplete
 
 
1 hour later…
3:19 PM
Hiiiii,
Have you ever implemented the Excess-Mass or Mass-Volume curves in Python? I can't find nothing, i have to evaluate an unsupervised anomaly detection model
 
3:41 PM
If I have objects which I want to publish in a pub/sub system. Do I give the object to the publisher class or the other way around? Like writing obj.publish() Looks neat, but maybe it makes more sense to have publisher.publish(obj). It feels arbitrary and I wonder if you guys had this problem and have some experience which one makes more sense or if it doesn't matter
Realizing some flaws in the code and doing a good amount of refactoring, makes me ask these silly fundamental questions, but who knows maybe they are not silly
 
4:01 PM
recbg
@Hakaishin so if you have a manuscript of a book do you tell the manuscript that it should publish copies of itself, or would you suggest to the publisher that they could make some copies of the book?
 
Yeah, that's also the way I went, makes more sense. But I think I also saw some apis do foo.publish()
 
also, instead of having x that has method called publisher, most of the time i'd just have
a consumer function that takes an object to publish.
i.e. a consumer :D
"stop writing classes"
 
???
 
Well, I saw the video and I kinda disagree, but it also depends on the language. I'm programming in C++ atm, that's why the examples arabstract, I don't want to anger the room :P
 
4:06 PM
@Hakaishin ok... then you've failed already.
 
Tbf, the video makes a lot more sense in python imo
 
You're basically writing OOP in a language that does not support OOP :D
 
C++ doesn't support OOP? Didn't know you were this edgy
Could you elaborate what it is missing?
 
about everything. It has all the cargo cult of OOP with none of the benefits :D
 
we, too vague to discuss
 
4:09 PM
122
Q: So what *did* Alan Kay really mean by the term "object-oriented"?

Charlie FlowersReportedly, Alan Kay is the inventor of the term "object oriented". And he is often quoted as having said that what we call OO today is not what he meant. For example, I just found this on Google: I made up the term 'object-oriented', and I can tell you I didn't have C++ in mind -- Alan Kay, OOP...

>OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things. It can be done in Smalltalk and in LISP. There are possibly other systems in which this is possible, but I'm not aware of them.
> Alan Kay has argued that message passing is more important than objects in OOP, and that objects themselves are often over-emphasized. The live distributed objects programming model builds upon this observation; it uses the concept of a distributed data flow to characterize the behavior of a complex distributed system in terms of message patterns, using high-level, functional-style specifications.
 
What is "message passing"?
 
@Aran-Fey it is the central principle of Object Oriented Programming
 
cool, but what is it
 
@Aran-Fey basically __getattr__. You don't access methods or fields or whatever. You send a message to an object.
 
Oh, just realized there's a wikipedia page for that
 
4:18 PM
@Aran-Fey a "method call" in simplest case...
 
Atleast in my experience this leads me to send around a bunch of data from one place to the other, whereas with objects I can store configuration in them and then really just pass the data to them that changes
 
Method calls only? Normal functions don't count?
 
@Aran-Fey they certainly may!
so you have an object called dog and you send it a message telling it to bark and it does something. Maybe sends something back.
that is OOP.
... or maybe it says "418 I am a teapot"
 
Why do I have to pass it a message? Why can't it just have a method bark, with data saved in one of it's fields?
 
@Hakaishin because object oriented programming is not about calling a method and having data saved in fields. Those are not important.
with C++ all you can do is call a method, and save data in fields :D
and then you can call it "OOP"
 
4:24 PM
again, why do I have to pass it a message? How is that better?
anyways I'm heading home, I might hear you out later, have a nice evening everybody
 
one idea of smalltalk, python, etc is that you can modify a running program for example. With C++ there is only so much you can do... it cannot have any new behaviours that weren't compiled in the beginning.
 
So let me get this straight, calling a function is a form of message passing, which is the core principle of OOP, but calling a method is "not important"? I'm gonna need an explanation here
 
no. The important thing is that we've got actors and we can send them messages and they decide independently what they will do with those, during runtime.
In C++ all this is decided during compilation time before you even started the program.
so in Python you can for example code an AI, something like ...
x = Simulator(y)
where then you some messages to x (i.e. call methods), and then it sends them to y... and learns in the process and could mimic y and actually make a complete model of the internal functionality of y etc...
that's OOP :D
well in C++, the first problem is that you cannot compile it. End of story.
heck even Java is much better. At least there are some mechanisms like during runtime you can get the interface of the y given, and then you can use some bytecode assembly tricks to mock a similar interface.
 
So it's only OOP if you can introspect stuff at runtime? Sorry, but this is getting more outlandish by the minute...
 
4:45 PM
yes!
that was the definition of OOP.
then came Bjarne and was like "I KNOW HOW DIS DAN"
> C++ was a preprocessor to C: the “classes” were program code structuring conventions but didn’t show up as objects during runtime.
so things where Python is not very OOP are the CPython stuff...
like... "hey you're not a real string you know?!"
 
5:40 PM
Hmm anyone experienced with synology dsm?
It seems that somewhere between now and last October the python package was updated from 3.5 to 3.8.
But apart from that (which would be just good news) it also seems pip stopped working on synology, and now python3 -m pip whatever gives "module pip not found".
Any hints how I can solve this? Without potentially breaking the system....
 
module pip not found sounds like a general problem, not related to that package you mentioned
are you by chance on Linux and updated your python3 version? several distros ship python3 without pip.
 
Hmm anyone experienced with synology dsm? Yes :P
I notice python updated between now and october from 3.5 to 3.8
Synology dsm is a linux distro, but for 3.5 and 2.7 it did include pip :/
So i'm afraid pip was removed on purpose and adding pip might break the server
BUt there the line sudo python3 -m pip install --upgrade pip fails under the error "module pip not found"
 
did you run step 2 first?
 
6:04 PM
yes and it says "module ensurepip not found"
Basically it seems the python version has become "batteries excluded" and many modules seem missing.
 
So, if you really want to you can use pip's own get-pip.py to pull in pip
But if your OS is actively preventing you from having pip and offers no easy way around, please consider twice before forcing pip on it.
 
Yeah well, I'd wish to have an easy way to let the OS use its own version of python - and me in userland my other version of python... Not having pip is kind of dealbreaker to use python..
 
6:21 PM
Well, why don't you install your own version of Python, then?
Using the system python is generally error prone.
You can fetch Python directly from python.org
 
6:42 PM
@AnttiHaapala this is gold
I hope the guy who wrote the code of the tool I am currently developing watches this video before lmao. I don't blame them because they started it 20 years ago but hey, I started with a huge spaghetti code with Form1.cs which has 17k line of code in it.
 
7:35 PM
Looking through this OOP discussion, I really start to wonder what the purists hope to achieve by sticking to the strict definition
 
 
1 hour later…
8:57 PM
unpopular question: is Python 3.9 maybe giving problems to so many packages? I keep seeing posts that end up with the solution of downgrading to Python 3.8
 
9:26 PM
Question is whether it's worse than usual
 
9:57 PM
@AnttiHaapala Whats wrong with youtu.be/o9pEzgHorH0?t=457 ? Why is everyone laughing?
 
Because he's explained earlier that a class with only one method should be functions, and lo, here is such a class in the wild (though names were changed to protect the guilty).
 
Tbh that's not even a bad class
 
@Arne sure
 
@holdenweb Oh, now I get it :p
@Aran-Fey Even I felt that.
 
@AnttiHaapala I think so, tried out all possibilities that day.
 
10:05 PM
@Aran-Fey Surely you jest.
 
No. Even if you really have an API with only a single endpoint (and thus a single function other than __init__) it still makes sense to model it is a class rather than an endpoint(api_key, ...) function
 
Guys any ideas on resetting the AUTOINCREMENT of sqlite database? After you have deleted a row from the middle. Nothing in the site is from python and couldnt find anything understandable. Any idea?
 
Chances are, you're gonna call that endpoint more than once. So you might as well write a class that stores the API key instead of forcing people to use partial
Besides, literally every API wrapper ever is implemented as a class
 
@Aran-Fey that is extra bad class
 
@Aran-Fey I'm going to walk away from this one, it's too late and I need my beauty sleep.
 
10:13 PM
Okay, the design with that call function is awful. There should be nice methods for all API endpoints. But you can't tell me that this class would be better off as a function
 
clearly it shoud be a function with an attached .register attribute that stores the api_key in a mutable default argument
 
@AndrasDeak :D
@Aran-Fey how about a closure
 
I can't even tell if you're serious anymore ._.
 
I am serious. I can't tell if you're serious
 
How would you make that code better with a closure?
 
Oh sure, instead of taking the key as an argument we're just gonna hard-code it
That's definitely equivalent
 
@Aran-Fey you'll use a closure.
 
No, no I won't
You're telling me I should save the api key in a closure variable instead of as an attribute of an object?
 
well why'd you want it in attribute, so that you can change it? :d
so that you can access it from the attribute?
 
1) Because it lets you access the api key from the outside
2) Because I anticipate that my class will have more than just one single method in the future
3) Because it's standard to implement API wrappers as classes
4) Because a class instance is pickleable/serializable, unlike a closure function
 
10:34 PM
[OK, I am going to bed after this]
 
*popcorn*
 
cbg
 
1) Would you suggest an accessor method? :P
2) YAGNI
3) That is no reason to gold-plate a design.
4) But that depends on the pickled instance's classes being importable - that might or might not be practical, but it depends on some concept of infrastructure that assumes unstated requirements.
 
Even if I agreed with the 4 points above, that still wouldn't make the closure solution better than the class solution. Any reason why I shouldn't do it with a class?
 
5) Nobody expects the Spanish Inquisition.
6) This was a conference talk intended to both educate and entertain, so some license should be permitted.
7) This is a matter on which reasonable people should be able to disagree without further consequences.
'G'night [dUCks out]
 
10:54 PM
Is... Is Aran-Fey objecting more than me?!
 
I'm the only one objecting here, everyone else seems to be functioning and closureing
 
he's object orienting
 
I thought I held a position as chief Grump
 
kevin'd
 
:)
 
10:57 PM
@roganjosh I thought that was Haapala :p
 
@CoolCloud It is now, but for reasons I don't fully follow
 
The best part is that a year ago, Antti was still writing code like this
 

« first day (3747 days earlier)      last day (1184 days later) »