« first day (4311 days earlier)      last day (621 days later) » 

2:03 AM
Oh, heh, yeah, sometimes years later coming back to old answers by self, ends up being like yeah that should have been dupe hammered
 
2:38 AM
stackoverflow.com/questions/50816228 duplicate; I messed up and called it not-reproducible at first (I thought OP was just misinterpreting the result of the file reading, but OP really does want to convert)
 
 
6 hours later…
8:48 AM
cbg
 
 
1 hour later…
10:01 AM
Hi folks! I am currently tasked with binning a bare-bones, in-house migrations tool and replacing this with a proper migrations library.

Coming mostly from other languages I am not sure what all the options are but Alembic seems to be one common choice, and we are using SQLAlchemy. If there are other choices worth considering I would love to hear about them.

I played with Alembic and generally speaking it will do the job. However I am not crazy about the fat that the `alembic_version` table just contains one column called `version_num` which stores migration ref values; e.g: 525d62b9a5fe.
Okay, that comment is a bit long — apologies. I'm not sure if this would make a good SO question or not. If so, I would be happy to post. Thoughts welcome, and thanks!
 
damn all that just to ask "hey guys how can I store the date-time of a migration in an extra column with alembic?"
 
Better for a question to be too long rather than too short :-)
 
true, it saves a lot of back and forth questions
 
Apologies if it's too verbose @PeterT — I thought context was important. Maybe not.
I'll ask a question — seems like it could be useful.
 
@DarraghEnright don't worry about it, more information is always better as long as the point is still there
 
10:11 AM
you don't need to apologise, you did nothing wrong. I was just giving my random opinion
 
in particular, XY problems are easier to dig down into when you explain the context
 
Thanks folks.
Oh... before I toddle off — am I right in assuming Alembic is the go-to choice for migrations in Python?
 
From my small amount of experience, yes
 
Cheers @Kevin. Seems that way!
 
stackoverflow.com/questions/10973766/… We deserve a much better canonical for this.
No idea what's going on in the actual question text here. It looks like an improperly distinguished quote from the documentation, and then "how does this one line of code help with solving a problem?" out of nowhere, with no context for where that line of code comes from, or why it would help with solving the problem
and nothing to relate it to the general theme
 
10:25 AM
Cherry on top: they're quoting the 2.7-specific documentation
"the result [of map] is always a list." -- Not any more it isn't :-)
 
Also, why doesn't anyone seem to know that map accepts multiple iterables (*args) and implicitly zips them?
the documentation quote even covers that part! and then there are six answers, only one of which even tries to use multiple iterables, and only gets around to it at the bottom without really highlighting it
sigh
 
I didn't know about multiple-iterable map for a year or two. The reason was some combination of 1) never seeing anyone else use it that way; 2) not reading the documentation closely enough; 3) reading about it in the documentation and saying "oh neat, I must remember that for next time" and then forgetting about it
 
I mean, IMO if a tutorial mentions map at all it would be irresponsible not to talk about how that works (since there are relatively few reasons to prefer it over a list comprehension, and that's one of them)
 
Yeah. Sadly it's tough to instill responsibility in a crowdsourced project like SO.
 
10:41 AM
@KarlKnechtel No idea what that question is even asking. I've brushed up the formatting a bit but I'm seriously considering to close vote.
 
11:20 AM
@KarlKnechtel do you have access to sopython common questions? Your recent work seems like it should probably be documented there
the "canonical canonical" for backslashes seems to be sopython.com/canon/2/why-do-backslashes-appear-twice (which has two linked canonicals)
if not, several of the regulars here can give you write access (I'm not one of them though)
 
 
3 hours later…
Yen
1:58 PM
hi
 
Yen
class Name(admin.ModelAdmin):
   model = models.Name
    def get_readonly_fields(self, request, obj=None):
        if obj:
            return self.readonly_fields + ("name", "id")
        return self.readonly_fields
 
close enough, thanks
Do you have a question about that code block?
 
Yen
i am trying make readonly field, after saving, but with this code all the fileld become read only , if i could check the rows have value that rows , only that rows will be only read only.
 
I don't really understand your question, but then again I don't know MVC frameworks. What is this, django?
 
Yen
2:04 PM
may i share a link
 
Yen
1
Q: Django Read Only Fields ,if there is any value

YenI wrote this code to make read only field, but i want to make an exception that if there is value then that row will only readonly , and if there is not any value the it will be editable, model.py class Name(models.Model): name = models.BooleanField(default=False) id = models.BooleanField...

i asked this question , few weeks ago
 
OK. Django-savvy people here will have a chance to look at your question and try to understand it. In the meantime, I noticed that your indentation is also all over the place in your question. You should stick to a 4-space indent, and make sure that your example code in the question resembles your real code. The code blocks in your question would refuse to run because of syntax errors.
 
Yen
sure please , i will remember that, after pasting the code the code become indentation changed.
 
Yeah, it can be fickle. Before posting your question you have a preview below the edit box, it helps if you check there. Alternatively, you can use triple backticks as "code fences" to denote code blocks (on the main site; this doesn't work in chat). So you can just paste your code, and put ``` before and after it, and it will become a code block without touching indentation. And you can edit your question even after you posted it.
 
2:48 PM
This time I'll go ahead and post the pastebin first in case anyone can help from just my comments: pastebin.com/UcbwPWTq
Basically, the T's that are chosen are still within 2 streambits of other T's. Why is this, if I explicitly check if they're in a +-2 range of the other previously chosen T's
 
@Catyre plus_or_minus_two_off is a list of ranges, and you are checking if a single int is in there.
presumably you want to check if the int is in any of the ranges
 
OIC
 
alternatively, instead of ranges, use a flat list of indices, or a set if the order doesn't actually matter
 
I was under the impression that something like [range(1, 4)] would expand to [[1, 2, 3]], but I'm not sure where I got that idea from. What do you mean by "flat list of indices"
 
Flat indices would be [1, 2, 3]. And yeah, I also don't know where you got that impression from.
If you don't have to keep track of order and the groups of indices, only the bag of excluded values, you should use a set and add the new values to that.
 
2:54 PM
Wishful thinking i suppose :P
 
dragonball level wish
>>> s = set()
... s.update(range(2, 5))
... s.update(range(3, 6))
... s
{2, 3, 4, 5}
@Catyre side note: [[1, 2, 3]] would also not work the way you are using it.
 
Ah yes I see. in line 21
it would need to be a list of all the ranges together for that if to work as expected
 
Not sure what you mean.
 
as in [1, 2, 3, 4, 5, 6] not [[1, 2, 3], [4, 5, 6]]
answered my own question ^
Thanks for the help once again @AndrasDeak--СлаваУкраїні, I got it working (except for an infinite loop in the code now that rand_streambit is never not in plus_or_minus_two_off after a few runs through the loop. I can fix this myself though). The guys active and helpful in this chat are doing the lord's work
 
3:31 PM
boto3 has got me questioning my sanity. Even down to the most fundamental things you might want to do it just goes off on one. "Can you tell me what's in this directory please?" "Sure, I'll recurse every single directory I find, though. Oopsie, I can only hold 1000 items so I've truncated it. Wanna see? Just call .get('IsTruncated'); it's that simple! Can I introduce you to my brother list_objects_v2?"
 
I am having problem with the following code -
It should print the yes message when clicked yes and No message when clicked No. But it isn't happening. What should I do?
Its always returning in the No message
 
Without proper indentation, there's no way to tell
 
Okay, okay, sorry. I forgot that. Here is the dpaste link -
https://dpaste.com/2M6Q3JH8E
 
Ugh, last second edit broke the ping
 
3:42 PM
replace global retValue with nonlocal retValue
 
Ok trying ..
Ya, it worked!
Any explanation on that?
Please
 
Well... the retValue variable you're trying to change isn't a global variable. With global retValue you create a new (global) variable, but then you return the value of the retValue variable that's local to askYN
 
3:58 PM
Well, I want the window that pops up to be like the dialog windows that open (like the filedialog or the messagebox <- expecially). How can I do that. I wasn't able to find any working answers from the web.
Similar in the sense that they open at the centre of the existing window and over it and not as a separate window.
For sake of some clarity -
In my operating system, there is auto-tiling. When the root window opens messagebox.askyesno(), it opens over the existing window at the centre. But, when I open a Toplevel, it opens up as a separate window in a separate tile! What can I do to resolve that?
 
tkinter has ready-made "save as" file dialogs, etc, if you're looking for that kind of thing
 
No, I wan't something similar to toplevel to work like that so that I can place my own widgets over that.
 
Ok. I thought so, but I figured I'd put the link out there just in case
 
@Kevin I visited that page around 20 min ago :)
I am trying to make my own yes/no windows like messagebox, but I need to place my own widgts.
 
Ok, reasonable. I don't think I'm familiar with auto-tiling. I'm pretty sure you can tell the new window where it should open, but I don't know if the OS will understand the windows are related.
I will also put this link out there: docs.python.org/3/library/…
 
4:11 PM
Auto-tiling, like there is on the POP-OS
Trying to do something like that
in tkinter
 
Can't say I'm familiar with POP-OS, sorry. I'm willing to read up on it, if there's documentation.
 
Ok, just see this
Something like this is happening
 
Ok.
 
I want that window to be at the center of that big window
Like tkinter.messagebox dialogs do
 
Ok. I think I understand.
I wonder if subclassing Dialog would help... I'll play around with that
 
4:16 PM
Please, I am unable to work with simpledialog.dialog to return value
 
My initial impression is they've made tmux for guis youtube.com/watch?v=-fltwBKsMY0, that's kind of neat.
 
Here is something that I tried with simpledialog.Dialog but lost hope -
https://dpaste.com/F292XMWSM
It always prints the yes message
 
4:33 PM
Hmm. It's a bit tricky. I think it won't let me run the dialog's mainloop without also running the root's mainloop.
I certify this problem as officially Difficult
 
Did you try this - dpaste.com/F292XMWSM
 
I'm trying something similar. I can tell just by looking at that code that if YNDialog(parent = master): will always be considered True, because YNDialog is a class, and class instances are always considered True in a boolean context unless you go way out of your way to specify otherwise.
It's so way out of the way that I don't even know how to do it. So I can't recommend it.
 
ok
thanks for considering all of that
Now, I think I would have to do some workaround of keeping some frame inside the window.
@Kevin is that a good idea?
or can't say?
 
Here's something that works on my Windows machine. Try it and see how Pop-OS likes it. dpaste.com/56DMPFS4R
I had 95% of this written when I declared the problem Difficult. Took me a while to notice that body is supposed to return something.
 
That works!!
But how?
What's that making it work?
OK. I think I got it.
You didn't return anything at all. You saved that value in self.ret_value and accessed that after the window was destroyed.
Thanks!
I think that I will be making that project available on my github under LGPL or MIT once the prototype is complete.
And concept is proved.
 
5:06 PM
Ok. Feel free to use any or all of my code and license it as you see fit.
 
5:17 PM
@Grasshopper What exactly where you trying to achieve
 
A custom equivalent of tkinter.messagebox that I can use with my theming.
 
@Grasshopper Ah, you will have to create and adjust the widgets yourself tho
 
Now that the basic bones are there, I think adjusting the style and such will be relatively easier
 
I don't see tkinter's theming as very predictable and also wanted few widgets like outlined button and outlined entry box. So, am creating a very small library to address my mentioned issues to ease out simple desktop gui application with tkinter.
 
tkinter is rarely accused of being beautiful
 
5:28 PM
for sure :P
 
But its in alpha now. My experience with tkinter hasn't been very good when trying to do deep stuff so can't say if I would succeed. But the starting reaults seem promising (after first widget was successful)
 
Whenever anyone comes in here and says, "I know there's a straightforward way to do this, but I wish to control every aspect of it from top to bottom", I 100% support that motivation
 
You can see an outlined button in one of those images I posted :)
 
I'd say tkinter is very true to itself
 
If I had the time to control every aspect of my computing experience, I totally would.
 
5:31 PM
Changes wallpaper
 
[I take 1d4 mental damage]
@Grasshopper If you're interested in getting really deep into tkinter, it may be worth looking at the tk and tcl docs: tcl.tk/man/tcl8.6/TkCmd/contents.html. tkinter can do anything that tk/tcl can do, although the syntax might be awkward and poorly documented.
I think 99% of users can accomplish what they need without ever looking at the tk/tcl documentation. But perhaps some valuable tidbits of arcane wisdom lie within.
 
But tk/tcl can't do rounded corners! Can it?
Its the first think that makes me not try tkinter to great extent.
And the poor documentation is the second most prevaling factor. :(
 
Hmm, I'm not sure about rounded corners. You can make parts of your window invisible, but I'm not sure if that works on the border.
And I'm also not sure if wm_attributes('-transparentcolor', '#abcdef') works on any OS other than Windows. I've never tried.
 
Thats difficult and I think if I had to do that much, instead of going deep into tkinter and learning so much, I would try pyGObject or less probably pySide/pyQT
 
Valid. Right tool for the right job.
 
5:44 PM
That would be easier and equivalent amount of learning would help reap greater benefits.
I haven't switched because tkinter is still sufficient for me till now. I am so used to it that its best when I want to do prototyping.
@Kevin 🤘👍
 
I think sometimes people criticize tkinter in front of me in the hopes that I'll say "No! It's not bad, just misunderstood. Take my hand and I'll show you all of the wonders of tkinter". But nah. It really is a bit bad. I have inspected the warts quite intently.
 
Yes, a BIT bad. 🤏
I think that was suitable and written well according to its time of initial days. But you see, how much GUI needs have changed from that time.
Its just been dragged so much that it has broken parts 💔 and poor documentation just doesn't let you have gutz to fix it.
And lastly, since newer frameworks have arrived, why would anyone jump into fixing that much. Simple.
 
6:00 PM
There are limits on what you can and should do regarding low-level GUI stuff with Tkinter / Tk. Remember, Tkinter has to run in a relatively sane & consistent way on a bunch of different OSes and in conjunction with various window managers. With low-level tinkering you may be able to achieve some result on your system, but it may behave differently on other systems. So that gets tricky to test properly.
> Typically, applications communicate with window managers by providing them with hints; they can ask to be a certain size and at a certain position, but ultimately if the WM decides to put the window somewhere else (e.g., because the user moved or resized it) then there's nothing that the app can do about it. Nor should there be anything that the app can do about it; the user should be in control after all.
 
6:24 PM
The user should not be in control because I should be in control. Bend the knee, users, I know what's best for you.
 
@PM2Ring *low-level tkintering
 
I almost wrote that. :)
An example of what can happen when devs decide to take a GUI control away from the users: meta.stackexchange.com/q/368973/334566 Some of us were not very happy, especially those of us who mainly use the network via phone.
 
In truth, I am wary of using wm_attributes since it comes with few guarantees. That said, I think it's probably OK to break out of the tkinter sandbox so you can play in the Tk sandbox. One is basically syntactical sugar for the other.
If you're dying to store your globals in tcl's big table of globals, then have at it
@PM2Ring I resent any and every top bar that I encounter on any website.
In the Before Times, I could read text on a web page, and when I got to the last line visible on my screen, I could press "page down" on my keyboard, and it would scroll exactly enough to put the line I was reading at the top of the window. But now that top bars are everywhere, it scrolls exactly enough to put the top bar on top of the line I was reading, and the one following that.
 
6:40 PM
That's annoying. It (almost) implies that the top bar is more important than the actual page content. I tolerate useful top bars, if they aren't intrusive. But sticky top bars are an abomination. Especially when they eat up 10% of the screen area.
Some people developed various workarounds for the sticky SE top bar. But of course the devs changed stuff without warning, so the workarounds stopped working. Fortunately, it was easy enough to fix them, but incidents like that are not great for company - community relations.
 
Every six months or so I have to devise a userscript for Twitter to delete whatever annoyance they've added or made harder to detect. Most recently was a "you can't scroll any farther unless you create an account" window, plus some dark magic to erase the scroll bars.
Especially weasely is the way they worded it to imply that it was a technical limitation beyond their control, rather than a tactic to increase market share.
 
Yeah, that's really annoying, although a few weeks ago I somehow managed to see more by some random combination of scrolling & refreshing.
I used to merely dislike Twiiter, now I actively despise them.
 
If a news site tells me I have to make an account to see an article I'm only mildly interested in reading I tend to become more interested in trying to break their paywall than the article itself. I imagine this is a common dev experience.
 
But at least they've resolved the Hanlon's razor dilemma: they aren't merely incompetent, they are actually malicious.
@0x263A Maybe, unless you're on a phone, where browsers don't normally have dev tools.
 
6:58 PM
I used to be able to banish the popup by clearing my cookies. Not so any more.
I was just about to offer to share my user script, but I just remembered it's on the laptop whose boot sector I kinda deleted.
I'm 75% sure I can recover it, but I must not go in unprepared.
 
The most entertaining "hack" is that often those media companies load the entire article in one html blob so you can just copy and paste everything into the blank firefox new tab page and read it there. But I concede being on mobile makes it more difficult.
 
This non-userscript approach may be of use: I never saw any popups when I scrolled through twitter's search results. So I could browse unbothered through a user's tweets just by searching for "from:the_user_name" and sorting by latest.
I think the search page will stop after like 300 tweets or so, but that one is more plausibly a technical limitation. An anti-DDOS measure, perhaps.
 
7:16 PM
I wonder if it would be possible to design a website that replicates the functionality of common dev tools, using only HTML/JS. Then a mobile user could go to the dev tool site, enter twitter.com into the site's "Target page:" field, and it would show the page source and the DOM tree etc etc.
 
7:27 PM
I think that might have some problems due to cross-site security issues.
Ir should be able to do static HTML analysis. But running JS from another page may get tricky.
 
Yeah. I figured, if anything's going to make this impossible, it will be a cross-site-something-something.
 
Finally the expected result! :)
I removed the titlebar from the dialog because I didn't find it worthy to be kept.
 
JS can be weird. It's easy to display the contents of some URL in the current tab, or a new one. But just getting the text content of a page & reading it into an array of lines requires complicated XMLHttpRequest stuff, or async code using Fetch. I played with Fetch a few weeks ago. Sometimes it worked, sometimes it didn't. I guess it might be easier to experiment if I did that stuff on a desktop, not in SageMathCell on my phone. ;)
 
Think - You can prevent entering yes or no just by clicking on the x button.
Thats it
 
> The chunks that are read from a response are not broken neatly at line boundaries and are Uint8Arrays, not strings. If you want to fetch a text file and process it line by line, it is up to you to handle these complications.
 
7:44 PM
Sounds like my sockets-based projects.
Just because the client sends a 5000 byte packet, don't expect to receive a 5000 byte packet. You might get 2500 bytes in one packet and then 2500 in another. Or 5000 one byte packets. or five packets with sizes 4096, 512, 256, 128, 8.
No encodings allowed. If your data can't fit in a uint8 array, it's too fat for the Internet. Try mailing a flash drive instead.
 
 
1 hour later…
8:52 PM
@Kevin Through experience, we learn :P
 
9:41 PM
@Grasshopper "A quick brown fox has jumped over the lazy dog" twitches uncomfortably
 
9:59 PM
It took me way too long to realize that that sentence isn't a perfect pangram :(
 
10:18 PM
@Kevin just implement __bool__? (__nonzero__ in 2.x)
 

« first day (4311 days earlier)      last day (621 days later) »