« first day (4363 days earlier)      last day (578 days later) » 

7:47 AM
Hello!
Does the __del__ method execute when I overwrite an object?
Like, does the method on the object that is being overwritten execute?
Can't test it right now :p
 
7:59 AM
__del__ is executed when the object is destroyed, i.e. when the last reference to it is dropped
If it is executed at all. Python doesn't exactly guarantee that. For example, when the program exits, CPython often doesn't bother calling __del__
 
8:48 AM
Hi
 
9:41 AM
@Warcaith How do you overwrite an object? I guess you're talking about what happens when you assign a new object to a name that's already bound to an object. As Aran said, if the old object has no other references, then it becomes eligible for deletion, but Python may not actually call its __del__ method.
Here are some good resources on how Python's data model works:
Oct 17, 2019 at 8:44, by PM 2Ring
@djsmiley2k Have you seen and Facts and myths about Python names and values by Ned Batchelder? Also see Other languages have "variables", Python has "names" for a briefer version of the same stuff, with cute diagrams.
 
 
2 hours later…
11:47 AM
@NordineLotfi Neat find, thanks. I don't mind too much that it wasn't originally written in English, since the interface is by-and-large well-translated. I wouldn't have noticed at all if the "cursor" dropdown didn't have an initial label of "请选择" ("please choose")
And I'll award bonus points for being the fastest of all the software you mentioned, in terms of time elapsed between "Kevin learns of the existence of the tool" and "The tool produces valid Python code". It was about fifteen seconds. Compare to, say, pygubu, where it took me twenty just to find the installation instructions.
 
12:19 PM
@Kevin You're welcome :D I just thought you might have liked it since we both mention tkinter a lot, so yeah. Anyway, I tested them all, I think? I couldn't make visualtk.com work (at least the web version), but I think the github version (which might be github.com/xlvecle/Visual-Tkinter-for-Python) probably work better, but I didn't test it yet. pygubu doesn't support exporting code (AFAIK) and only support using it through the module itself.
I tried a couple ones from activestate/sourceforge and they seems decent. Page works but only with Place geometry, but found another one that worked with grid, so that's nice. it's this one: sourceforge.net/projects/spectcl
I think there many other ones on github and Sourceforge (and some on googlecode) that I didn't check yet though.
additonally, I learned of the tkinter module dnd for drag and drop, which I found that I could create buttons/widget that can be dragged around and undragged to act normally which could enable me to reproduce how they work, even slightly.
 
That visual tkinter github has an English README that describes it as a plugin for VB6. I don't think it's related to the web tool.
 
hmm, I thought it was, since it was in the first couple of hits when I used "visualtk.com github" as search term
you're right though, on closer look even the GUI has nothing to do with it
 
1:08 PM
morning cabbages, folks! how was everyone's weekend?
 
Wrote some code, lazed about, did a favor for a peer which earned me a favorable number of brownie points. Above average.
 
noice! solid!
 
I'm trying to design a language where the average program will use eval several times
But the real fun is when your program uses its own custom version of eval. This is all incredibly dangerous, of course.
 
that sounds like a highway to the dangerzone. I can't wait to find out how you blow up the world :P
 
1:59 PM
Hey guys I am in the process of building a docker file to run our integrations tests on. Now we use setup.cfg with install_requires but docker needs: RUN pip install -Ur requirements.txt how would I go about not having the requirements duplicated once in setup.cfg and once in requirements.txt? is there a better way then to duplicate them?
 
@Hakaishin don't know, but is this related?: stackoverflow.com/questions/72236497/…
 
Why can't docker run pip install my_project instead?
 
2:22 PM
@Aran-Fey because I want to have a base image which I can pass to our gitlab ci/cd pipeline which then installs the newest sources, because the requirements will be quite stable and thus in the image, the source package will be installed each time using the pipeline
@NordineLotfi it's related but doesn't really answer my question. I already know I will use a multilayer docker image, it's more about how to merge requirements.txt and setup.cfg
 
@Hakaishin hmm, I think this one might be related and perhaps give a possible solution: stackoverflow.com/a/16624700/12349101
the only cons is that this force anyone who set this up to use pip, but that's probably not a problem here, given the context
 
@NordineLotfi yeah, I was just reading that, seems to be a good choice
hmm but it doesn't filter env marks
 
@Hakaishin env mark? can you give an example
 
wrong link, now it's right
 
2:37 PM
found this comment under the link I posted: stackoverflow.com/questions/14399534/…
I guess you could also do that? Also that may explain why env marks aren't parsed, but I'm not too sure about that
 
3:06 PM
Crazy idea: pip install my_package followed by pip uninstall my_package, then you're left with just the dependencies ¯\_(ツ)_/¯
 
3:19 PM
or maybe install requirements in a virtualenv, pip freeze that, save that to a single archive (eg: tar) and use that a wheel and install that on each.
I did that once on machine that didn't have pip installed (nor any internet connection)
 
@Aran-Fey the point is I don't want to copy the whole package into the image, but just prepare the deps for later. I will keep you posted on what we decided to do
 
It'd probably help if I understood docker
 
 
4 hours later…
7:37 PM
Interacting with non-programmers is hard sometimes... on one hand you have people who think "Adding X feature should be easy, right?" and on the other hand you have people who don't dare ask for the tiniest changes to the code ("I can change that if you want, it literally only takes 20 seco-" "No no no, it's fine, don't bother")
Maybe I'll write an article that illustrates what programming is like
 
8:06 PM
@Aran-Fey Could I get an autographed copy?
 
Best I can do is a digital signature, i.e. a "— Aran-Fey" at the bottom
 
8:23 PM
How do you guys handle exceptions? Like, if I have a class that tries to open two different files, do you just skip the try/except and let the user handle the error? I don't see the meaning to catch the OSError, just to raise it again to the user, haha.
And moreover, how do you guys figure out what types of exception can be thrown by different libraries? It's kinda hard sometimes to find documentation for this.
 
Good libraries document their exceptions, but yeah, it's often overlooked
 
An example is this that I saw:
def divide(a, b):
    try:
        return a / b
    except ZeroDivisionError as ex:
        raise ValueError('The second argument (b) must not be zero')
Like, why would you even do that? (This was from a tutorial)
By letting the user catch the ZeroDivisionError by themself, the error gets a lot more clearer.
 
Arguably the whole function is pointless
Generally speaking there's nothing wrong with catching an exception and turning it into a different kind of exception
 
@Aran-Fey Yes, it is pointless of course, but I've seen similar things where try/except is used too much.
def open(self):
    self.file_1.open()
    self.file_2.open()
How would you write exception for this kind of method?
Let the end user catch the OSError or not?
 
Probably just let it bubble up to the user, yeah. But depending on the context, catching it and re-raising it as something else can absolutely make sense
 
8:33 PM
Alright, thanks for the answers! :P
You're always my go-to person with these kind of weird questions ;)
 
@Warcaith Generally, if you don't know how to handle an exception... then don't. The worst case with this scheme is that the caller/user does not know either, so nothing is lost.
 
9:17 PM
If I have a method "def log(item)" that people will use to log items to a testing framework, would it be good to have a Obverser/Subscriber/Event pattern inside this method that fires the items to different sources, like a HTMLWritter, Logger, Database etc.?
Or is there any other pattern I should check out? :)
It gets so messy to do each of these things in the single method.
 
An event-based design is one option. Another option might be something like logger.attach(HtmlWriter('foo.html'))
(...which is arguably also an event-based design, but let's not go there)
 
logger.attach uses the Python logging method, right?
My HTMLWriter is pretty custom and uses different HTML files to speed up re-generating the final document. I'll look into the logger.attach to see if it supports these kinds of things.
I want the user to be able to only log specific objects of type "ClassA", "ClassB" etc., so I don't know if logger.attach is suitable for that :p
 
I made that function up
 
Aaaaah...
I really like that, it much clearer than the event based solution.
And will probably work better, actually! :)
 
9:50 PM
 
10:00 PM
Do you know the name of this pattern @Aran-Fey?

logger.attach
 
Feb 11 at 23:03, by PM 2Ring
@hello If a function knows exactly how to deal with an exception, it should do so. Otherwise, it should let the exception bubble up, until it hits a layer that does know how to handle it. If no layer knows, then let it bubble up to the user, preferably in the form of a nicely presented error message &/or log entry, not as a raw traceback.
Jul 17, 2015 at 12:55, by PM 2Ring
In accordance with the ancient programmer proverb: Never test for an error condition that you don't know how to handle.
 
@PM2Ring Thanks for the feedback!
 
10:42 PM
we need an Art of War Code
 

« first day (4363 days earlier)      last day (578 days later) »