« first day (2881 days earlier)      last day (2290 days later) » 
00:00 - 18:0018:00 - 00:00

00:37
@jpp can you please post link to the newer question? So the rest of us can follow this discussion about both questions, titles and answers.
01:10
i dont have linux installed right now, but can you doubleclick .py files to run them there?
(if python is installed)
@Null yes...if you do a few things. First, you have to change the permissions on the file so it is executable using the chmod command. And you need a "shebang" line at the beginning of the file to tell Linux what python interpreter to use.
01:53
my first attempt to print a matrix
a,b=1,0
c,d=0,1
print('|',a ,' ', b,'|')
print('|',c ,' ', d,'|')
02:31
Hello!
I am new to python and I am getting a strange error in my code.
Here is the error:
Traceback (most recent call last):
File "main.py", line 7, in <module>
from game_utils.camera import *
File "/Users/yooogle/Desktop/PowerArcade-O-Matic/FirstGame/game_utils/camera.py", line 23
else:
^
SyntaxError: invalid syntax
I know it says my syntax is wrong, but I checked the code and everything appears fine. Any ideas?
post the code, if it is long use pastebin or the like
also you could try your luck in codereview (a SE site)
I dont think the first part of your message sent through
nvm. it did. I was just confused
i think u miss some "(" or ")"
but thats just a guess
02:47
cabbage
cabbage
dang. Cabbage beats all
lol u where right. I got confused by all the ')' that I lost count. Thanks
@joeldesante glad i could find the failure :)
lol. yes
the failure is right
funny because i searched like 2 hours ago after pygame
but at the moment i cant download it
03:21
You cant download pygame?
03:57
Hey there.
I don't think it's worthy of a question but does anyone have some good intermediate resources on multiprocessing in Python?
Essentially if I hit a problem in a child process created with Pool() I want it to exit the parent process immediately. Currently it only gets raised when all the other processes finish
Bc at the moment I can be waiting hours only to discover that half the processes failed...
 
1 hour later…
05:07
@ashgetstazered how do the child processes fail?
@ashgetstazered should the parent process know, it can close, terminate and then join
05:38
re-cbg
06:23
cbg
is there any DRF equivalent api framework for flask + mongo ?
I want to use some advance features of DRF like throttling, ip blocking etc...
07:26
cbg all
hi
What is the process for integrating sentiment analysis in a CRM? What I am searching for is a system which analyzes the customer comments or reviews using the CRM and finds out the customer sentiment on the services provided by the system or company or a product.
07:51
@AkhilAlexander that's a pretty broad question
These things take months or years to build up
@roganjosh that's not my senior said
Well then perhaps they should be giving you more support in implementing the system
This is absolutely not straightforward stuff
07:58
I don't mean any of that in a rude way, it's just not something we can really set up in a chatroom and if you get it wrong it will work against you
@AkhilAlexander You're in luck, I wrote my thesis on that
Apparently I lied :P
ok i understand ,anyway i have to finish it with in weeks ,need to find a solution ...do u have any links???
If you know python, this paper should give you something you can implement in a couple of days
@Arne I worked for a major retailer and they ploughed months into this kinda thing and were still refining it. Is it really a case of a couple of days?
It was also a product recommendation system so I guess that added complexity
08:02
If your domain is similar enough and your requirements aren't too harsh, yes
@Arne ya , thanks
@Null codereview doesn't do debugging. Read this codereview.meta.stackexchange.com/questions/5777/…
@roganjosh I implemented something like that for a retailer in a month or so.
But it was a startup, and I could do what I want. Integrating it into an existing system will probably take a lot longer.
No idea what they were doing then, it was a project in the team I was working with but I wasn't involved. Vehicle routing was my game :)
08:06
@Arne I love this chatroom!
@roganjosh I also like vehicle routing
@AndrasDeak didn't know :) also cabbage
It's a PITA. If only customers could be reasonable people :P
lol tell me about it!
@Aran-Fey seems clear to me. Just grossly confused
08:10
Let me read that again...
Thinks that try == if
Oh, that makes sense. Still lacks a mcve, but fine
Not that it'll help anyone ever
Could be closed as brain fart I guess
@shuttle87 the worst was doing it for a startup in Dubai. No address system and customers would scream at drivers to go 20+km from where they actually asked for something to be delivered. You start to wonder why you bothered with the fancy algorithms :P
it's interesting I get contacted from time to time about this type of thing and I notice that a lot of solutions implicitly encode various regional factors into their systems without realizing it
08:15
I'm curious what you mean?
So for example I worked on something in a remote area in Australia, the european system assumed that people could always get back to the depot within 1 day. This makes sense when you can drive across a country in 2 hours, we had things travelling 15 hours in one direction
Or your example of needing fuzziness about the delivery locations and times
Ah ok
Or local regulations being different, etc etc
My system was beyond fuzziness. The company needed to just empower drivers to say "screw you" but they had a "wall of shame" if they didn't deliver a certain percentage of their parcels
The company either needed to decide it wanted efficiency or was going to bend over backwards for customer service. In the end I had to bail
Dubai is an interesting one though because their road system means that 10m accuracy in GPS could put you on either side of a dual carriageway and there are no turning points, so 10m could end up being 10km out :P
Interesting
Yeah that's exactly the kind of important local knowledge I'm referring to
08:28
I'm curious whether you roll your own algorithms or use a library?
Combo of both, often make some sort of solver backend that uses CPlex or Gurobi or something open source like minizinc and then do a bunch of piping data in and out of it
Been a couple of years since I was in the middle of all that but I likely have a job coming up soon with my company that is in that space
I really like those types of puzzles
Interesting, I've not heard of minizinc, I shall have to research that one :)
I managed to get lunch breaks into jsprit. That's my contribution to open-source :)
That problem kept me awake for 3 weeks
@roganjosh thanks for contributing to that!
@roganjosh minizinc.org
Interesting that you use generic constraint solvers. I've not been able to conceptualise forcing my problems through them
Might be a lot simpler problem, say you have 5 warehouses and you are only transporting things between them
This is much simpler than a completely generic transport logistics situation
08:41
Makes sense
user4229770
09:05
@abarnert Hi, maybe You have any books to suggest about software architecture ?
09:25
stackoverflow.com/questions/52181417/generate-a-random-number Clear duplicate. For some reason the link has 6 upvotes and only my close vote
@roganjosh hammered
Cheers!
09:45
If I have a function that takes a file path or a file object as input, what's the nicest way to write that function correctly? (i.e. use a context manager if the input is a file path, but no context manager if the file is already a file object)
def read_file_data(file):
    def do_stuff(file):
        return file.read()

    if isinstance(file, str):
        with open(file) as file:
            return do_stuff(file)
    else:
        return do_stuff(file)
^ Current solution
inb4 "who cares, just use a context manager in both cases"
Was just about to say that... Specifically use a nullcontext, where necessary.
Oooh, that'll be handy
Heh, the 2nd example in the docs is in fact your use case exactly :)
self.confidence_in_google_skills -= 5
09:55
Have a +5, it's not that long ago I run into that accidentally.
You can't google for which you don't know it exists
It is known.
That "which you don't know it exists" reminds me of the SQL equivalent for a FORALL quantifier: NOT EXISTS x ( NOT p(x) ), which is a pain to reason about every time.
And that reminds me of writing SQL queries with 5 levels of nesting for Uni homework *shudder*
(Though to be fair there was probably a smarter way to write those queries)
Apparently my more secure clone of the pickle module doesn't like my fancy OOP units:
class Config:
    def __init__(self, max_upload_speed: units.megabytes/units.seconds):
        self.max_upload_speed = max_upload_speed

load(dump(Config(0)))
# DeserializationRefused: Attribute "max_upload_speed" should be megabytes_per_second, but is int
Looks like I know what I'll be doing the next 4-5 days! Hooray!
10:42
@AndrasDeak Cloud Atlas reference?
cbg
What am I talking about, it's a GOT reference. Shame, shame, shame.
 
2 hours later…
13:11
I am new in Python. Which editor I have to use for development?
Hello.
You don't have to use any specific editor. But you do have quite a bit to choose from.
Quite a few of us here tend to lean towards using PyCharm.
I think we compiled a list already in our page.
yup. Here you go @AkashPatel -> sopython.com/wiki/Python_IDEs
@idjaw Thanks.
no problem.
@AkashPatel If you are looking for something at work, and there is a budget for it, I would suggest proposing spending money on the IntelliJ license. You get the full suite of features. Even if you think you might not need it because you are mainly working in Python, you'll be surprised how many other features you think you should have out-of-the-box that you don't get with a purchased PyCharm license
I would at least do a proper comparison between IntelliJ and PyCharm to ensure you make the proper choice between the two if this is a work-based purchase.
if this is personal use, stick with PyCharm.
Or any other one of those editors in the list.
13:37
hello(dest="SO Python chat")
answer = "https://stackoverflow.com/questions/4675728/redirect-stdout-to-a-file-in-python/48870616#48870616"
question("What's wrong with this answer ? I love it: ", answer)
afternoon cbg
Morning cbg to all. I was once told "If you're the smartest person in the room, then you're probably in the wrong room." It dawned on me yesterday that during the time I'm in this chat room I'll never have that problem, unless I'm the only one here :)
I have definitely left companies for that reason. If the bar is low enough that I can trip over it, it's probably not a great place to work.
Hey, I've got a server running a python background process, now "quite" often after 3-4 days of running the process "halts", as in it still runs but it doesn't do a thing anymore. If I attach strace to redirect the output to a new shell the output is empty. This runs inside an (alpine linux) docker, can I attach a debugger to the process? - Or even kill the process and just see what line the python function crashed on?
If I restart teh python process it works happily so I can't just do that.
doesn't it produce any logs?
@W.Dodge It's a really nice feature of this room =)
the knowledge I absorbed by simply being here..
13:52
absolutely
mainly ways to write complicated oneliners, but others things as well, I'm sure
Anyone want to earn some easy rep by telling me that this is a horrible idea and I shouldn't be doing that?
'Cause that's the conclusion I arrived at after thinking about it for more than 10 seconds
Do I need to read more than the title?
'What is the legal way to break into a bank?'
@Arne Not really, no
I'll try to understand it
13:55
@Arne nope, and the "main loop" has a logger (which writes to file and console) inside it which I noticed has stopped after some time
So I'm wondering on what function it breaks.
14:09
\o cbg
@paul23 Can you simply do python my_script.py &> log_everythin.txt ?
The last line should be the stacktrace
or is it a more complicated error, e.g. an infinite loop or something?
@Arne uuuh the script is already running, starting a new one doesn't give the problem, and it must be an infinite loop somewhere, the script never "exits".
Nor does it throw an exception (at which case the server would catch the exception and handle it)
Shouldn't the server then also handle a timeout?
and restart the underlying python process?
Well... no, it's a background service in the server that is supposed to keep track of all changes to an external database (the external database doesn't fire an event when a change occurs though, so it just keeps checking all data), and on a change some event is fired.
=/
I'd be tempted to say it's an architectural issue, then
14:15
The "outer loop" should log a "keep alive + status update" into a log file, I notice the log file is ~10GB is size and then it just stopped no more logs and I also notice it doesn't reflect the updates anymore.
really dumb question.. is the file just too big?
yet the process is still "running" and no exception is thrown (any exception, even catched ones are logged to the log file).
yeah, that's it from me, I have no clue
Is there a "too big" for python's logging module?
But if I could attach a debugger/force an exception/stacktrace this would be immediatelly visible
no, just the underlying file system. But if it's still logged to, that shouldn't be the issue
14:18
@Arne Well the logging also stops
ah, then I misread one of your earlier comments
Do you use the stdlib python logger?
Then you could try replacing the filehandler with a rotating file handler, first of all
in case it's a file size issue, that should avoid it
and it's a good idea in general
@Aran-Fey That question is way above my meta-programming skill level, sorry
That's alright, I'll post my own answer telling myself how stupid that is
=D
If I learn something interesting, I'll upvote it
14:26
The reason is actually really simple: If you change the signature, it's not a functioning metaclass anymore. You simply cannot use it as a metaclass, because that'll just throw an error.
class Class(metaclass=MyMeta):
    pass

# Traceback (most recent call last):
#   File "untitled.py", line 15, in <module>
#     class Class(metaclass=MyMeta):
#  TypeError: __new__() takes 1 positional argument but 4 were given
So in the end it's really just a stupid way to write a class factory
But there's no way to simply see the a stack trace of a running python process? - Or force an exception?
not that I know, but I might be wrong. I mean, kill -9 python_PID will force an exception..
correction: using kill does not force an exception. TIL.
14:41
Would pdb work for that? If you're not catching an exception, then you might not get the post-mortem debug available, I guess.
Hi guys...how would you find a disabled input text using selenium driver ?
<body style="text-align: center;">
<div class="style_list" data-target="T9339">
<div class="style_item" data-stocknum="T9339"> Code:
<input value="LWBATOP-PK" disabled="disabled"><br>
I need to get the input value text :)
@paul23 this looks interesting for your purposes il.pycon.org/2016/static/sessions/john-schwarz.pdf
@Andie31 You can use a css selector: input[disabled="disabled"] should do it.
I'll read that soon, I now accidentally killed the process so it now "works again" for a few days :(
@Aran-Fey I tried driver.find_element_by_css_selector(input[disabled="disabled"]) no luck :( am I formating it correctly ?
14:49
Feeling sad that something works
Well, you need quotes around input[disabled="disabled"], otherwise it's a syntax error
I tried pyrasite, which crashed the moment i hooked that up to the python application, and in crashing it also crashed the python script.
Yeah, doesn't look like it's been updated in a few years, not sure how well it supports newer python/libraries
@Aran-Fey driver.find_element_by_css_selector("input[disabled="disabled"]") gives me still syntax error :(
'course, you need to use different quotes. 'input[disabled="disabled"]'
14:55
@Aran-Fey ahhhhhhh that what is was !
input:disabled should work if you have a decent selector engine
ok, but it prints now bunch of : <selenium.webdriver.remote.webelement.WebElement (session="d0bedc6b7fae289264053f7be0808e16", element="0.9652430426341598-1")>
or input[disabled] if it only handles attributes
I need to get that LWBATOP-PK as text
Sounds like you need to read the WebElement documentation.
14:57
@paul23 If it's stuck in an infinite loop, you can try kill -2 python_PID to return to some outer loop that does a Pokemon Except
.. which will usually exist in a server application
Not as rare as Legendary but Stellar feels pretty good
@Aran-Fey @ThiefMaster I tried driver.find_element_by_css_selector('input[disabled]').text :( no luck
@piRSquared congratz! =D
That QA sure paid off..
@Andie31 Sorry, but I can't solve every little problem for you. If you want to work with the web, you need to learn how it works. An element's text is completely different from the element's attributes. You have to understand what you're doing if you want to be productive.
i need some help in qt designer ??
does anyone know qt designer ??
15:06
@Arne thx (-:
@piRSquared It's really impressive. Gives me motivation to write some for all those ML questions that pop up like mushrooms.
You should
@Aran-Fey no worries, all good, thank you anyway ! I'll read that WebElement documentation and try to solve my problem. Have a great evening gents !
15:22
cabbage
15:51
TIL the guy from super considered harmful likes to call unknown constructors with arbitrary arguments
> That misconception causes people to make two common mistakes.
>
> 1. People omit calls to super(...).__init__ if the only superclass is 'object', as, after all, object.__init__ doesn't do anything! However, this is very incorrect. Doing so will cause other classes' __init__ methods to not be called.
That topic is really old, it still talks about old-style-classes
But how is that an indication that he likes to call unknown ocnstructors with arbitrary arguments?
That's what using super().__init__(...) in a class that inherits from object will do (in case of multiple inheritance)
Uh, so? That's not "special" in any point
class Foo(object):
    def __init__(self):
        super().__init__()

class Bar(object):
    def __init__(self, x):
        super().__init__()

        self.x = x

class FooBar(Foo, Bar):
    pass

FooBar()
# Traceback (most recent call last):
#   File "untitled.py", line 15, in <module>
#     FooBar()
#   File "untitled.py", line 4, in __init__
#     super().__init__()
# TypeError: __init__() missing 1 required positional argument: 'x'
Of course you call the init, otherwise multiple inheritance won't work.
15:58
No, that's backwards. Multiple inheritance doesn't work because you called super().__init__(...).
But python has cooperative multiple inheritance. Objects trees are supposed to work together (this works nicely with the "we're all adults here").
If you don't call super().__init()__ not all parent's constructors are called.
If you blindly call super().__init__(...) in your constructors, then nobody can ever use your class with multiple inheritance, because you end up passing wrong arguments to the other parent class's constructor
So you only call super().__init__ if your base class is not object.
uh no, since it means that if class A has parents B & C which are both derived from a common ancestor (object), then only C (Or B)'s constructor will be called (from A's super() call), the other branch won't be called.
So you'll have to call against object or make another "common ancestor" that all classes will derive from.
And that's a good thing, because that allows you to call each parent constructor individually and pass the correct arguments.
wim
wim
@Aran-Fey I think you're not quite grokking it yet
16:03
@Aran-Fey no, since it doesn't allow dependency injection.
wim
wim
Since you don't know who "everybody" is ahead of time (maybe you're mixed in with 3rd-party code), then you (and they) must cooperate.
And by manually calling the parent's constructors you'll have all the problems of C++'s multiple inheritance, defeating the whole idea of the MRO.
wim
wim
you don't know where you will appear in the MRO, and you have no way to know this ahead of time (unless you have a time machine that can tell you about all the code that will be written in the future which inherits you)
call unknown constructors with arbitrary arguments is a part of cooperative inheritance, it's a necessary evil.
Ok, but what's the point of injecting anything between my class and object?
btw I'm all for not ever using positional arguments in constructors. Especially once you start using inheritance it becomes impossible to use them. (As you noted)
16:06
Calling `super().__init__` in a class that inherits from object does two things:
1) It enables dependency injection between that class and `object`
2) It prevents multiple inheritance with two base classes that aren't designed to work together
wim
wim
@Aran-Fey as paul23 mentioned, dependency injection is one example
OrderedCounter, discussed in this room recently, is an example of dependency injection which only works because of super - an OrderedDict (which is a subclass of dict) gets "injected" as the storage backend for a Counter in place of the regular dict which Counter would otherwise inherit.
if you have an hour of spare time I'd really suggest listening to youtube.com/watch?v=EiOglTERPEo
I've watched that, but maybe I should watch it again
it's quite a easy to follow, yet explains the advantage of cooperative multiple inheritance very well (better than I could), and on top of that it's easy to listen to.
wim
wim
I hate on java devs a lot but really good java guys are the boss of this stuff. It's not as widely used in Python.
16:10
But isn't always calling super().__init__() half-assed support for dependency injection? Shouldn't you be calling super().__init__(**kwargs)?
java has multiple inheritance?
@Aran-Fey well yes?
So every constructor that doesn't have **kwargs is inherently incorrect? That's 99.9% of all python code ever written
@Aran-Fey It is incorrect if you use it in a multiple inheritance tree.
And since I don't know how my class will be used, I have to assume that it will be used in a multiple inheritance tree
If "you can inherit from this" is part of the interface then indeed I feel you should use keyword arguments.
wim
wim
16:13
@paul23 no, they do the same thing with interfaces
@Aran-Fey You can make part of the API of your class that it can't be inherited from, or only single inheritance. That's not strange in the programming world at all.
But then not calling super().__init__() isn't incorrect either. That just means my class doesn't support cooperative inheritance. The interface of my class is that you have to call each constructor individually.
Similarly that we have the idea that members starting with _ in the name are supposed to be private and shouldn't be changed when code uses this class. That's also just part of the api
@Aran-Fey Calling each constructor individually leads to problems by itself, but not calling super().__init__() is indeed a way of saying 'don't inherit from this'.
wim
wim
@Aran-Fey Was 99.9% of the code you've written needing to support cooperative inheritance? It's a design decision and YAGNI most of the time ..
@wim to be frank, using "keyword arguments instead of positional arguments" isn't only a "YAGNI" decision, since having applications where half the constructors use keyword arguments and the other half uses positional (or even a mix) I consider really confusing.
So changing to keyword arguments later isn't trivial and one might very well do it from the start (I consider keyword arguments better anyways).
16:19
So, bottom line, nothing really matters
Too late, my time has come...
wim
wim
@paul23 you're quite correct, but you would have to rewrite most of the stdlib too if you wanted to be consistent
Put an airpod in my head. I push play and now it's said...
wim
wim
Python never forces you to do everything 100% correctly - instead it gives you all the tools needed to hack around other bad code
monkeypatch to your hearts content
16:29
@wim What do I do if I'm a perfectionist? :/
wim
wim
I dunno, change to lisp or something
wim
wim
It's a double edged sword. You end up with a very flexible ecosystem, most anything is possible, anything can be hacked until it's working or usable. And you end up with some very messy tooling because people just implement their features, patching upstream if necessary
I have this answer where I recommended not calling super().__init__ if you're inheriting from object. Should I change it?
16:49
> When you use it on methods whose acceptable arguments can be altered on a subclass via addition of more optional arguments, always accept *args, **kw, and call super like super(MyClass, self).currentmethod(alltheargsideclared, *args, **kwargs). If you don't do this, forbid addition of optional arguments in subclasses.
^ wot
If you always forward all of the arguments, you'll get object.__init__ takes no arguments at the end, won't you?
@Aran-Fey object is at least no reason to not call super().__init__()
The same problems you see can happen with any arbitrary class
Yes, but the difference between object and other arbitrary classes is that object has a fixed interface that nobody can change
If your arbitrary class dictates that I have to call super().__init__, then ok, so be it. But I don't think object dictates anything of the sort.
IE: I have A, and B derives from A. So B calls super.__init__(**kwargs), now a user of this api also derives from A, making class C. And he makes class D that derives from both B and C. now B's super call (when originating from D) will go to C -- thus the same problem occurs, where you cannot be sure what super() is actually calling when designing B
Calling parents directly is considered bad design though, since it opens a large can of worms when deriving from a class that does this.
So you shouldn't suggest that.
The difference is that the author of B chose to inherit from A. With that design decision in place, it's true that further child classes of B have to follow some rules. But inheriting from object is no choice, it's mandatory.
yes, but it doesn't matter, it doesn't do anything
If you do want your object to not be derived from, just say so and then people are on their own if they do.
16:59
But if it doesn't do anything, what reason do I have to call its methods with super()?
So it can be derived from
And supporting inheritance (by a user of your library) without supporting multiple inheritance is not the way I would suggest to go, as it violates least astonishment rule in python.
Ok, sorry but this theoretical discussion isn't doing anything for me except giving me a headache. I need some practical examples if possible
Take these two classes that don't use super(). What's wrong with them? In what scenario would using super() make your life easier?
class Foo:
    def __init__(self, f):
        self.f = f

class Bar:
    def __init__(self, b):
        self.b = b
Nothing is wrong, they just "can't be inherited from" in the purest form. (shouldn't inherited from).
Why not, though? I don't get it
Because if say I have now 2 more classes
    class Baz:
        def __init__(self, val):
            super().__init__(**kwargs)
            self.val = val

    class Foobar(Baz, Foo):
        pass
Baz's init won't be called.
wim
wim
17:10
don't call it Bar too, LOL
And since you can't know for sure how the inheritance tree works you shouldn't inherit from it at all (otherwise inheriting from the simple inheritance might cause problems later on).
I think you've got the parent classes backwards
Foobar() will call Baz.__init__, which will then call Foo.__init__
when it inherits from multiple classes first the last one in the row is called
Or am I mistaken there? - then to show the problem make the class class Foobar(Foo, Baz)
Yes, it's left-to-right in python
The the problem shows in class Foobar(Foo, Baz) - but point still stands, you need to be constantly very very careful anywhere in your inheritance tree if you don't cooperate in a class.
17:14
Ok, so I would say it's a good thing that Baz's constructor won't be called. Foo and Baz are two completely independent classes that have nothing to do with each other. Calling each of their constructors individually is much cleaner and safer
Which is contrary to the python paradigm, as you shouldn't explicitly call parent classes.
What would you do if Foo.__init__ and Baz.__init__ had a parameter with the same name?
@Aran-Fey cooperative
But they can't cooperate because they're completely unrelated classes that have never heard of each other
wim
wim
@Aran-Fey you lose features this way
when using super you don't know that parent are proxied to immediately, there might be more siblings in the mro in between
17:17
What features do I lose? Dependency injection?
@Aran-Fey Then indeed you shouldn't use inheritance but use composition
I can't whip up a minimal example here which actually makes use of multiple inheritance and still is trivial to look at...
@wim Why would anyone inject a sibling between Foo and object though? What's the point?
see the youtube video earlier about pesticine dough factory :P
the truth about python multiple inheritance is that it just cannot work :D
even C++ multiple inheritance is sketchy at best but it is pretty much resolved at compile time...
But also in the case you get a diamond shape inheritance anywhere in your tree you'll have to use super() to prevent the "base" of the diamond to be called twice. Now consider I inherit from foo, as well as A, where A inherits from B & C and B & C both inherit from foo again.
Now to prevent foo.init to be called multiple times you'll have to use the MRO, which means super() which means that by not calling super() in your foo class your inheritance tree stops at that point.
17:24
... and the super() has the problem that it can call a class you'd never have heard of
@AnttiHaapala python, because it is resolved at runtime, is so much cleaner.
Due to the capability to dynamically create the MRO, and thus preventing the same constructor to be called multiple times.
so only at runtime your users would notice this because in your unittests you never considered that they'd actually combine A and B.
yup
17:26
multiple inheritance should have never happened.
RE: Gosling: "even single inheritance a mistake"
"at unit test I never considered people would change variable "a._this_is_private" directly, now it breaks everything"
inheritance is part of tha pi
tha pi is the best
wim
wim
@AnttiHaapala that's a feature, not a problem :P
wim
wim
if you've heard of all the other classes involved, you don't need super in the language in the first place
17:29
> So lets add some other animals. I like Penguins. So lets add a Penguin. Hmm, where do we put it? A Penguin is Bird right? But well, a Penguin can't fly even the fact that he has wings. So we put it under Fish right? Because a Penguin can swim. But wait, a penguin can also walk. So actually we need a new subclass once again! Oh damn...

> Okay, now we have to implement Flying Fishes. Oh damn, that think can swim and fly? Crocodiles that also swim and walk? And now we also want to implement the "American Dipper". What is an American Dipper? Oh seriously? A bird that "flys" under water or be
@paul23 It's true that some methods can end up being called multiple times, but how often is that really a problem? I would, once again, actually consider this a good thing. Imagine you have two classes A and B who both happen to inherit from C. Now if you create a subclass that inherits from both A and B, you may end up with an undesired diamond. If neither A nor B use super, both of them will work correctly. But if they do use super, A might end up calling a B method incorrectly
wim
wim
Inheritance is not perfect. But it's damn useful. Perfectionism is the enemy of progress.
Inheritance is way more work than most of its proponents realize.
wim
wim
How did you get all this technical debt? I inherited it!
17:32
It's like a slightly more compartmentalized form of monkey patching, with many of the same dangers.
I guess the question my philosophy hinges on is "Does it ever make sense to inherit from two unrelated classes?"
If the answer to that question is "no", I'll start using super everywhere
ahoy tharr! many cabbages all around. How's everyone doing?
there are 2 forms of bad subclassing of others code: either the class author has intended the class to be subclassed and that's a bad api design. or the author has not intended the class to be subclassed and you're subclassing it anyway.
cbg @inspectorG4dget
cbg @AnttiHaapala. How's life treatin ya?
life gave me manflu followed by stomach flu and then as I had gotten used to them, this afternoon it took them away.
and you :D
17:35
woohoo! glad they flew away ;]
I'm still working on that monstrosity of a PhD... also dealing with family not really understanding what it takes
anyone know of a way to create an instance of multiprocessing.Queue and then change the maxsize parameter after creation?
@Aran-Fey counter and dict for ordereddict does that I think?
sounds bad :d
Alright, I need to take a break from the discussion to make dinner and do other real life stuff
@inspectorG4dget I'd use unbounded and figure another way of doing the bounding on top of it
@AnttiHaapala possibly beyond my XP. Could you show me an example of how something like that might work?
This is what I'm doing right now
q1, q2 = [mp.Queue() for _ in range(2)]
q2 = mp.Queue(maxsize=1)
17:40
self._sem = ctx.BoundedSemaphore(maxsize)
it goes into the semaphore initialization :F
so you'd need to monkeypatch the semaphore... ... which will be shared over the fork ... or sth...
ahhhh! much thanks. I looked but couldn't figure out where that param went
i.e. you cannot really do it...
... or you "can" but...
it's very "FFS!". Because in reality, I'm creating many queues (2 in the above example), and am altering just a couple of them to restrict the maxlen. Looks like I'll have to just recreate them
Much thanks @AnttiHaapala
rhubarb folks! I go back to the dank existence that is grad school
00:00 - 18:0018:00 - 00:00

« first day (2881 days earlier)      last day (2290 days later) »