« first day (3946 days earlier)      last day (985 days later) » 

12:41 AM
Irreproducible/ no MCVE/ needs clarity stackoverflow.com/questions/68581778/…
 
12:52 AM
closed
 
1:11 AM
cbg
 
 
4 hours later…
5:21 AM
@Kevin I can't tell if you were being flippant, and I looked at your code, but csv is not regex-friendly. Ad-hoc parser should beat it.
@AlexandreMarcq Be careful not to spread misinformation. Assuming you mean France, “commercial prospecting” meaning scraping publicly available website data to obtain individuals’ contact info for purposes of selling such data to third parties for direct marketing purposes is banned since 2020. So e.g. the 2021 mass scraping of LinkedIn API contacts is illegal.
..But (AFAIK) (commercial or non-commercial) scraping for other purposes is not explicitly banned. So scraping public, government, org, NGO data etc. should be fine.
 
Unless those sites themselves forbid it
 
5:37 AM
why is scraping frowned upon so much? even if the site has API, it still has to serve the requests one way or other right?
 
Because it puts large strain on the servers (most of the work serving the page is thrown away, API endpoints can have dedicated servers etc.), and often the API needs access tokens for a fee: if you want to use data someone already gathered, pay for it.
 
I can't find a good canonical duplicate for stackoverflow.com/questions/68660415/… ... any hints? I'd think re.DOTALL would be a very common answer
but nearly all the duplicate candidates I have looked at are more advanced, often with questions about the differences between re.DOTALL and re.MULTILINE
I guess we should have the collected set of common regex newline questions in a single entry on sopython.com
 
@tripleee good idea
 
@python_user also if you use a dedicated endpoint they have better ways to see what you are doing and maybe control your behavior if you are unduly straining their servers
they can't really throttle individual users on the public web site even when they are under attack
 
5:52 AM
@AndrasDeak No, Aleandre was talking about what is (criminally) illegal under French law, not banned by TOS.
 
ok that makes sense, thanks guys
 
6:37 AM
@smci That's what I was talking about but didn't know anyone would pay that much attention, so didn't phrase it properly I guess
 
6:53 AM
hi, does anyone happen to know how to iterates the dictionary and iteratively print out the keys of its sub-dictionary?
 
@FrederickHong just like that
for subdct in dct.values(): print(subdct.keys())
 
@AndrasDeak Thank you. How about recursively? What if I don't know how many levels there are in the dict?
 
7:10 AM
@FrederickHong then you'd probably use recursion
 
7:42 AM
cbg
 
 
1 hour later…
8:52 AM
Does somebody understand why ValueError: signal only works in main thread? I only find ways to fix it, but I wonder why it was defined this way
 
Portability. Not every OS allows signals in child threads.
The old Python2 signal docs hinted at that with "only the main thread can set a new signal handler, and the main thread will be the only one to receive signals (this is enforced by the Python signal module, even if the underlying thread implementation supports sending signals to individual threads)."
 
 
1 hour later…
10:12 AM
All: please aggressively close the weekly/daily flood of questions asking how to do a random training-test(-validation/holdout) split on a dataset. Today's was Split randomly a list into 3 independent lists, last week's was Sampling a DataFrame in n groups. Star this if you're tired of seeing these reaskings.
@MisterMiyagi Really? Which OSes don't allow signals in child threads?
 
@smci Apparently, Windows. I honestly never bothered finding out.
 
@AlexandreMarcq No worries. I'm curious about legitimate use-cases of scraping (of public data, not contacts to spam) and related laws and ToS provisions. LinkedIn is in the news a lot these days Threat actors scrape 600 million LinkedIn profiles and are selling the data online – again
@MisterMiyagi Ah
 
Python has a broad range and history of OS'. I wouldn't rule out that the restriction is historical these days.
 
Python must ensure that it keeps working on KevinOS
6
 
user16280768
10:34 AM
Illegal instruction (core dumped)
 
user16280768
How to resolve this issue I tried TensorFlow 1.5.0 even after I faced this error
 
Not running any Illegal instruction might help.
 
Miyagi has absorbed his 8-ball
 
● Signs point to yes.
 
laurel
 
 
1 hour later…
12:03 PM
can anyone tell me an example of Mixin in the analogy of a Vehicle class whose subclasses are TwoWheeler and FourWheeler?
I can not understand the concept of mixins
 
Mixins are SelfDriving
 
ok, I will try to relate with this, thanks
 
I don't really get it either, but I would say mixins are base classes that have to be used in combination with some other base class, and alter the behavior of your class.
For example, the socketserver module has the base classes UDPServer and TCPServer, and the mixins ThreadingMixIn and ForkingMixin. You can instantiate a regular UDPServer or TCPServer just fine, but alternatively, you can subclass it together with a mixin to alter the behavior of the server.
 
I am right now trying to understand Aaron Hall's stackoverflow.com/a/36222493/12502959 answer which explains that
the moment I saw that they should not be instantiated my mind started to think about Abstract Classes
then I went on a search for mixin vs abstract class and ended up 5+ tabs on this :/
 
As with many named software patterns, I think it helps to just forget about them. Mixins aren't concrete things, not even concrete concepts – someone invented the term to describe the clever things someone did.
 
12:22 PM
tbh I dont have a need for mixin, I am just starting to write a new code, thought if I could stuff mixin somehow
 
mixin is basically someone going "oh composition is nice" and then completely mixin (ha) it up with inheritance instead
 
knowing python's inheritance, mixins are probably a great way to make your life interesting
 
one website I referred, said its a sane alternative for multiple inheritance source : residentmar.io/2019/07/07/python-mixins.html
 
alternative is a weird choice of word, considering im pretty sure mixins are multiple inheritance. (though fair warning, i've never coded one up. classes can stay away from me forever for all i care)
also, blocked article. that's fun.
 
Mixins are an alternative class design pattern that avoids both single-inheritance class fragmentation and multiple-inheritance diamond dependencies. that lead me to make that statement, but I just can not find some one that explains it with basic examples
 
12:32 PM
> Even though KDEPlot uses multiple inheritance, it has only one true parent class: Plot. Every other class it inherits from is a mixin (by convention, mixins in Python end in "Mixin")
 
I miss the days, were Vehicles and Animals were used to teach OOP ;(
 
And that's exactly how mixins shouldn't be used. There is no reason why you have to inherit from Plot there - the mixins should do that for you. They should be ABCs, not mixins
Why do class KDEPlot(Plot, HueMixin, LegendMixin, ClipMixin): when you could do class KDEPlot(HuePlot, LegendPlot, ClipPlot): instead? Makes no sense.
 
I am just going to close that tab then, thanks :D I stayed away from medium articles thinking that these standalone webpages are better but guess not
Aran Fey you should probably get back to your tutorial site ;)
 
Nah, complaining about other tutorials is easier than writing your own (:
 
do you have any answer related to this on your old Account?
 
12:38 PM
@Aran-Fey hmm, actually this is surprising to me, because i've often heard mixins in the context where they expect you to have one Base Class you inherit from
@python_user perhaps check this
 
@python_user Not really. I have one answer that briefly talks about mixins, but like I said, I'm not entirely sure what they're supposed to be, and so I was pretty much just writing what I thought was correcting and hoping that I'm not embarrassing myself.
 
@ParitoshSingh i mean, i say often, but ive barely seen mixins a total of two times or something
 
@ParitoshSingh will check now, melon
 
@ParitoshSingh Right, mixins have to be used in conjunction with some parent class. But I'm saying that mixins aren't the best solution for this particular problem.
 
or any problem (:
 
12:41 PM
ah gotcha gotcha. yeah, let me get my pitchforks
 
I learned about them in an interesting advanced C++ class, they seemed really powerful and useful. But also too arcane
 
(possible rant alert) Im currently in the phase of my life where im just wondering why OOP ever became as huge as it did, and mostly just disliking it from afar. Perhaps once i have gained more experience i'll start to appreciate it more, but for now, i find most advanced classes and everything that comes with them tend to be nice "ideas"..until you actually code it up. and then it's "nice looking code" that "seems" like a good idea...and that's it.
 
Yeah, they're definitely arcane. The line between mixins and ABCs or cooperative base classes is super thin
 
it's so many layers of indirection that when you actually want to know how something works you have to trace it back through a pool of classes that just add noise to the task as a whole.
the problem is, "on paper" it just sounds like such a good idea. perfect abstractions, we say.
 
tell me about it, I still couldn't convince the other programmer to stop using getters and setters in python, because it just looks cleaner...
 
12:45 PM
Hmm, I personally don't have much of a problem with OOP. It's not perfect, sure, but I don't think you could invent a programming paradigm that doesn't have to make some sort of tradeoff
 
OOP became so big because of Java and because there it's needed more. But in other contexts like Python it's not needed that much
 
They're using mixins where I work, it's nice to know that I can assume they don't know what they're doing :P
 
@AlexandreMarcq oh nah nah, mixins are a valid pattern, paradigms tend to invoke opinion. don't take our word as gospel here :)
@Aran-Fey This is unfortunately very true. i am perfectly happy with simple classes, i just find myself disliking complex hierarchies really
 
The idea of dropping OOP reminds me of the time when I tried to switch from python to kotlin. I went from "kotlin is so much better than python" to "wait a minute, kotlin also has huge problems, they're just different problems" real quick
 
unrelated, but I remember Aran Fey mentioning going to Java to get a job, so do you work there?
 
12:49 PM
No, I'm still putting that off, because Java :D
 
@ParitoshSingh That seems like a strange reason. Given the MRO, if all "mixins" inherit from a baseclass then you don't have to.
 
@MisterMiyagi are mixins commonly written by inheriting from a baseclass? Im not well versed with this area
 
@ParitoshSingh I have to say the alternatives seem like even more of a letdown. :P
 
im perfectly happy to accept that the code bases i saw were not good examples of how mixins "should" be used
 
@ParitoshSingh They aren't, but for cases as the KDEPlot thingy cited by Aran they might as well be.
If a Mixin assumes to be used with classes of type X, it should just inherit from X itself.
 
12:52 PM
ah yep, gotcha. yeah, don't worry, i have my pitchforks with me now for that specific example
 
that is why they have already blocked you from that webpage ;)
 
! they were on to me.
before even i was.
 
Glad to have someone have me back up on this. I generally know what I'm doing when it comes to programming, but at the end of the day I'm still just a self-taught hobbyist, so sometimes I worry that I'm spouting nonsense
 
Hey guys! I'm new
 
I don't know if this is strictly what you would consider a Mixin but I use this one over a number of different classes in my code. Every job/delivery/pickup/shipment is a class with times, as are shift hours, break times etc. There's a lot of places where I need to convert between human-readable time and solver time, but I know every object that cares about this will have these methods
 
12:54 PM
@ParitoshSingh I have this nice pitchtorch mixin to sell...
 
@EasyWayCoder Hi! As you can see we're kind of in the middle of a heated conversation, but don't hesitate to speak up if you have a question or something to say
 
Hello EasyWay Coder
 
@roganjosh If the mixin methods don't depend on self, I just put them in some module as functions these days.
 
@Aran-Fey Haha
 
But I do see there is some advantage in every object just shipping with the tools it needs.
 
12:58 PM
@EasyWayCoder cbg
 
dpaste .org is blocked. :'(
 
class TimeMixin:

    def to_solver_time(self, problem_start_time, time):
        problem_start_time = dt.datetime.strptime(problem_start_time,
                                                  '%Y-%m-%d %H:%M:%S')
        time = dt.datetime.strptime(time, '%Y-%m-%d %H:%M:%S')
        diff = int((time - problem_start_time).total_seconds() / 60)
        if diff < 0:
            raise ValueError("Time slot cannot be before Problem start")
        return diff

    def from_solver_time(self, problem_start_time, time):
 
ah yep, i think that should count as a mixin for sure. And as someone who has seen mixin only twice in the past, im naturally the perfect authority on this subject.
 
rbrb guys, will catch up on the discussion later
I just thought of a question after seeing roganjosh's code, so I will ask then and then leave
since he does not seem to use self a mixin with a staticmethod is bad idea?
 
I think my intention when I first wrote it (6 months ago now) was that it would make use of self but then it started needing to handle some other things (like Shifts which have a linked start and end time, unlike a delivery which has a start_time + int(duration) so it ended up being less clean. I don't see why it couldn't be a staticmethod really
 
1:19 PM
and when you reach that stage, you just ask why it couldn't be helper functions in some module :P
 
Mmmm, maybe. I think it's ended up giving a pretty clean interface since I'd have to import those functions all over the place or make them globally available
 
yep, fair enough
 
To clarify, I don't really feel strongly either way. But I don't find it an anti-pattern used like this
 
aye, me neither. and im the perfect authority on the subject after all
 
:P
 
1:23 PM
@AndrasDeak A challenging task, because I keep intentionally changing the API in the hopes that I will prove Python to be Turing-incomplete
 
is it just me or is this really unreadable? At least at a glance, I have to look up how this works, which seems annoying for a simple if else: foo != -1 ? 3 : 1
 
@Hakaishin it's unreadable for non-C* programmers
it's as readable as a if b else c for non-Python programmers
 
I have enough C experience/trauma that I can understand it readily
 
I learned C in the first semester of undergrad. Final project was a warehouse program using linked lists. Haven't really used C since. And it's perfectly readable to me.
 
Just don't ask me what a ? b ? c : d : e does
 
1:29 PM
Also, it's used in Java
 
Yeah, most "mainstream" languages have ternary expressions, and many of them use that exact syntax
Count how many weasel words I used there to make my statement unfalsifiable
 
1:44 PM
i count 3, did i miss any?
 
Nice work. "most" and "mainstream" and "many" were the ones I intentionally employed. There may be others that my subconscious added in for me
(Today's pet peeve: people that interchangeably use "conscious" and "conscience")
Current status: now in minute 20 of getting Oracle to do the equivalent of value.partition("-")[0]
 
Should be easy with regex?
 
2:00 PM
"easy with regex"... I understand each word separately, but I've never seen them in that order before
;-)
But yeah. I might go with REGEXP_SUBSTR(value, '[^-]+')
 
The hardest part is figuring out the signature of REGEXP_SUBSTR -.-'
 
2:16 PM
just look up the docs, duh
 
2:30 PM
@AndrasDeak I think linked lists were my worst experience so far with C, somehow the lab was days before the lecture so we had no clue of what that even was
 
We were well prepared for the task, yet its futility was clear to us
 
Coding tasks for the final exam to be delivered in handwriting?
 
2:47 PM
Built my lovely, shiny new API with no guidance from the future user... just with the notion that "the incoming payload will surely be in JSON format. I mean, it has to be, right? I just need the infrastructure in place and I'll just tweak the code once I knew the actual body structure from the customer.". Turns out, XML. I 👀 are 🇷 an 1️⃣ idiot 🤪.
This is why I'm not a betting man
 
I wonder if pypi has a handy xml to json converter you could use.
 
There seems to be this approach but I'm not sure about my validators now
 
@Kevin I'm decently sure that's not possible. :/
 
It doesn't have to be perfect, it just has to look like it works, or look like it's broken but not my fault
 
TODO: Publish Python package that solves the Halting Problem in 50% of cases.
 
3:02 PM
At least 50% of the time it'll be right every time
 
"Guaranteed to be up to 100% not even wrong!"
 
haha funny we have the opposite problem, we export json and the consumer(that's the word) :D expects xml
 
3:17 PM
For now, I'm going to pretend this hasn't just happened and keep ploughing on with my own example. I have 4 internal server APIs to hook together so I'll worry about this another day. <la la la la la, I can't read you email>
 
3:53 PM
@roganjosh you can use the (yet to be implemented) everything_to_everything() converter at the interfaces, but otherwise use JSON internally :P
@MisterMiyagi we had mid-terms, but yeah. Syntax errors would cost you points.
 
In the throes of my current grump, it'll be an XML --> JSON converter on my side and I'll just return JSON. "Soz guys, it's just not possible for us to return XML... guess you'll just have to write a converter on your end. K thx bye" :P
It's a frustrating situation where the customer has refused to let me speak to their dev team until we have demonstrated that we have something working, so I had no choice but to take a stab-in-the-dark. I backed the wrong format :/
 
how is that your fault, again?
 
It isn't. But it will be if the API isn't in Alpha by October
 
API that accepts JSON is alpha :P
 
The contract is, let's say "pricey", for them and it'll be a lot of devices making the API call. I don't think I have a leg to stand on if I try to push this back on them :P
One day you, too, may experience the joys of customer work. You'll love it!
 
4:07 PM
I hope not
I expect not
 
"Hello, I'd like to order one physics, please, without photons but with extra gravity. I'll come pick it up in 10 minutes"
 
@AndrasDeak Missing semicolon on page three, illegible ink blob sixteen. D:
 
pretty much, except one in 20 people use fountain pens here :P
 
@Aran-Fey Would you like fermion fries with that?
 
If I get neutrino nuggets, can I get the Big Bang deal?
 
4:14 PM
Unfortunately, we're still uncertain if the Big Bang deal really happened
 
That's just because no one can decide whether it should be served with meson mayonnaise or kaon ketchup!
 
@Aran-Fey I'm sorry, but that's not what your other institution down the road is offering. I'll just go there, then
 
The machine is broken anyway
 
FWIW my boss was an Astrophysicist and the other person in my "pod" (kinda like a work group) has a PhD in Astroparticle Physics. I'm surrounded :/
Maybe they hired the Engineer as a pet or something
 
What's so astro about those particles anyway
 
4:21 PM
I'll be sure to ask him for you
 
 
1 hour later…
5:43 PM
Something's really wrong
 
many things are
 
>>> test_list = [1, 2, 3]
>>> new_list = test_list[:] # shallow copy
>>> test_list[-1] = 4
>>> test_list
[1, 2, 4]
>>> new_list
[1, 2, 3]
The shallow copy wasn't modified.
 
Well yeah, that's the point of a copy
 
It's a shallow copy. It's supposed to be modified.
 
Why would a copy be modified? If it's modified, it's not a copy
 
5:47 PM
Because we only created a shallow copy of the original list, new_list still contains references to the original child objects stored in test_list.
 
A shallow copy will reflect changes made to objects inside of the list:
original_list = [{}, {}]
copied_list = original_list[:]

original_list[0]['foo'] = 3
print(copied_list)  # [{'foo': 3}, {}]
 
1, 2 and 3 are int objects inside of the test_list...
 
But you never modified them. You took one out and put another one in. You modified the list, not the int.
 
@JossieCalderon hint: ints are not mutable
You're not mutating the values in a list unless you're doing mutating_function(lst[i]) or lst[i].mutating_method().
(including potential dunders triggered by syntactical sugar, like += for a mutable container)
 
6:10 PM
Situation: I have a python library that I'm maintaining versioned releases of. All API changes are back-compatible but evolving pretty quickly. They produce a payload for a Java API that I'm also maintaining, which is also back-compatible (when I update it shortly). But it's obviously super-easy to get the two out-of-sync as a user if you only update 1 of them. Presumably I shouldn't match their version numbering (Python --> 0.2, so Java also gets a 0.2 release); or should I?
Is there a neat way to manage this?
 
first switch to an XML format
 
How about adding a version number to the payload?
 
The Java component isn't a JAR or something that I could distribute with the Python library. The Java library is a separate service that you can pick when you create the docker container
 
@JossieCalderon Even if the objects were mutable, item assignment replaces them. It does not modify them.
 
Ohh, so the ints have different addresses, so of course the values changed.
But if I have a list of a list, then the inside list objects can be changed because that address remains the same
 
6:13 PM
@JossieCalderon fun fact: depending on what you're saying, the ints have the same addresses
 
Duh, why didnt someone tell me that before thinking
 
@Aran-Fey Nice! I like this a lot; super-simple
 
assuming the ints are all different values Andras, but good point
 
@JossieCalderon It wouldn't be an educational experience otherwise. :P
 
that address remark actually makes me worried that you don't understand the point after all
 
6:14 PM
address is the same thing as a reference, isn't it?
 
I don't understand those words
 
You can think in terms of addresses if you want, but as far as python is concerned, objects don't have addresses. That's not a concept that exists in python
 
address is the object's location in memory and reference is using that object's address to manipulate the object
"address" in python means some integer, like a name tag, for an object
 
That's a CPython implementation detail
 
The first sentence yes, the second sentence, no
 
6:25 PM
It looks like i could handle the incompatibility by making sure the python library sets its __version__ in the header and doing something like this with supported calling code versions. Thanks again for the suggestion
 
@JossieCalderon I came here not to be bullied with this kind of vocabulary :(
 
@JossieCalderon Addresses and references are entirely an implementation detail. Other implementations will freely make up ids as they please. For example, in PyPy every int/float of the same value has the same id and under the hood many numbers are tagged pointers – meaning they "are the location" itself in your description.
 
What kind of jargon is "tagged pointer"?
 
6:48 PM
It certainly beats cddddr in terms of cromulency.
 
sometimes I wonder if we speak the same English, Miyagi
 
I went out for a pub dinner and I'm currently holding a pint of cddddr. Perfectly cromulent.
 
Hm. A pint would certainly help.
Or four.
 
Convert my XML to JSON and I'll happily mail you 10 :P
I'm not sure you like cider over there <waves hands meaning outside of England>, though
In fact, it's probably an insult to receive a pint of anything produced in the UK :P
 
There are a lot of things I don't remember about my last pint in the UK, but it was certainly not for a lack of taste.
At least not on the side of the locals, that is.
 
7:08 PM
Sounds like a successful visit :)
 
10/10, drink again!
@AndrasDeak I'm just speaking with a slight lisp at times, that's all.
 
7:37 PM
Pet peeve of the day: Websites with video players where the scroll wheel controls the volume
 

« first day (3946 days earlier)      last day (985 days later) »