« first day (4030 days earlier)      last day (901 days later) » 

12:09 AM
@Kevin Hi, I need your help, could I get your email address?
 
 
3 hours later…
2:52 AM
cbg guys
 
 
2 hours later…
4:57 AM
Hello everyone, I am creating a button which when clicked removes all labels from frame. It works, however I want to remove all labels except ONE. Is there a way to exclude 1 specific label from this? thank you.
def clear(self, cont):
for tk.Label in second_frame.place_slaves():
tk.Label.place_forget()
Also, after I clear the labels, I want to be able to re-place them again, however since I have made the forgotten I am getting the error message: TypeError: 'Label' object is not callable
 
 
2 hours later…
7:00 AM
@Minbutt Don't use names like tk.Label as loop targets. It will replace the actual tk.Label type with whatever the loop iterates over.
Use a local name, e.g. for label in second_frame.place_slaves(): instead.
 
7:37 AM
I'm still surprised people bother with tkinter instead of just wiping out some flask or django. Is there a benefit to tkinter compared to a website? I mean html, css is horrendous, but atleast it's better than learning whatever tkinter is using
 
Documentation question: I have an abstract class. I have to document both the public user interface, as well as some internal parts that you need to know to implement it correctly. How should I organize this? Should the docstring only explain the public API, and everything else should be written in the actual docs with sphinx?
 
Think about redesigning it :D If I need to know class internals/privates to be able to use it, it sounds like the interface is not good enough.
 
Obligatory question: Why are the implementation details of an interface/ABC relevant in the first place? Is it information for subclassing?
 
Yep, "docs for people who instantiate the class" vs "docs for people who implement the interface in their subclass"
 
@MisterMiyagi Thank you I changed it from tk.Label to label and I can place labels again, however, they are being placed around the forgotten one, and cannot seem to be placed where the forgotten one originally was. It's like the label is still there but invisible. Is there a solution to this?
 
7:42 AM
I usually target docstrings at people just using things, and the full docs at people doing development. So public API in the docstring and everything else in sphinx seems good.
@Minbutt I assume you might have to re-pack the layout. But I have little idea of the tkinter specific parts.
 
Alright, thanks
@Minbutt Umm, you're using place though? You can literally set the exact coordinates where the widget should appear. If the widgets don't show up where you want them to, that must be your own fault somehow.
 
Oh I see, I now realise it is because each time I place, the y value increases by a certain amount, so If a place something, forget it and the place another thing, it will still be being placed underneath the forgotten thing. hmm
I must figure out a way so that everytime I press the clear button the increasing y-value goes back to 0
 
8:01 AM
@Aran-Fey you've got OOP wrong. Sorry for that.
 
And surely you're going to explain why or how, right? Right?
 
@Minbutt As others have already mentioned, it's generally better (and easier) to use grid or pack, rather than place. OTOH, there's a neat trick that you can use on a placed widget to toggle its visibility: set its width & height to zero. The answers here: stackoverflow.com/q/3819354/4014959 discuss various other ways to hide & unhide Tkinter widgets. That's an old question, so the code is mostly Python 2, and so it has import Tkinter instead of import tkinter
 
@Aran-Fey abstract classes wherein you need to conform to some existing conventions are just brain dead. If you need to document it to get it right, then it is overly complex already.
use interfaces, composition
 
How does that remove the need for an explanation?
 
> I once attended a Java user group meeting where James Gosling (Java's inventor) was the featured speaker. During the memorable Q&A session, someone asked him: "If you could do Java over again, what would you change?" "I'd leave out classes," he replied.
 
8:04 AM
And what's the difference between an abstract class and an interface anyway?
 
I am still trying to figure out how to save using Json, I am currently getting this error: raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) . Does anyone know what this means?
 
@Aran-Fey The fragile base-class problem
 
@Aran-Fey An interface doesn't provide default implementations. There's no code to inherit.
 
Does "interface" merely mean a convention? Like, a contract?
 
8:08 AM
well, yes, and no,
 
@Minbutt It sounds like you've got saving and loading mixed up. Your save function should be encoding Python objects to JSON, your load function should be decoding JSON to Python objects.
 
you can use the Python abstract class as an interface...
 
specifically in python
 
but the point is if people talk about abstract classes vs interfaces then I think they get sth wrong
 
:53351512 def show_entry_fields():

   f = open("name.json", "a")

   f.write("Name: %s" % (nameentry.get()))

   nameentry.delete(0,END)

def openJson():
    #pass
   with open('myJson.json', 'r') as f:
       value = json.loads(f.read())["entryVal"]
       'name'.set(value)

def saveJson():
    #pass
    with open('myJson.json', 'w') as f:
        currentVal = json.dumps({"entryVal":'name'.get()})
        f.write(currentVal)
@PM2Ring this is what I currently have.
 
8:10 AM
At least collections.abc is comfortable providing default implementations for many things, not just the interface part.
 
Ok, I think I get it. The thing is, I'm actually using both "extends" and "implements". You can pick whichever you prefer. Want to implement all 5 features manually? Subclass MyABC. Want to implement only 1 feature and have the rest implemented for you? Subclass MyHalfImplementedABC. So no, I'm not doing OOP wrong.
 
@Minbutt Note that json can write directly to a file via json.dump. Using json.dumps only to then push it to a file is a waste.
 
@MisterMiyagi I have a text entry which assigns whatever is entered in to it to a text variable called 'name'. A button then has a command which configures a label to be 'name'. I am trying to save 'name' to Json file so that when application is closed and reopened its still there.
 
@Minbutt There are some strange things in that code. Eg, 'name'.get(), which raises AttributeError: 'str' object has no attribute 'get'
 
@Minbutt That's nice.
 
8:31 AM
Sorry to interrupt this chat: Green bean here, I have 2 questions: Do we really need to add the cabbage words to every message like substitute every sorry to sprout?
 
@VScode_fanboy No. Salad language is optional, not required and we hardly use most of it.
 
@PM2Ring Noted.
My second question is: Does any online python editor gives the same functionality of the standard VScode + python extension?
 
I haven't found any yet.
 
@MisterMiyagi I have considered various notebooks, an website by Google, of course vscode.dev but also found nothing.
 
@Aran-Fey Ok, in hindsight, that wasn't a good argument. Or not an argument at all. My OOP was indeed correct, with some classes that are just an interface and some that have a bit of code. But I got myself confused about documentation - for some reason I switched from describing the class (like "this function does X") to telling you how to implement the functions (like "when you write function Y, don't forget to Z").
But Z is still part of the public interface, so I just have to rephrase that to "function Y does Z" and my problem is solved.
 
8:45 AM
@VScode_fanboy absolutely not
 
@Minbutt Let's break this problem into simpler pieces. Forget about Tkinter, for the time being. First, create a minimal program that can load & save a simple dict using JSON. When you've got that working properly, then it'll be relatively easy to add it to your Tkinter program.
 
Hey guys, how can I set or replace a url param of request object and return an relative url with all the old params and with the new page? in Django

    def set_page(self, page=1):
        request_ = self.request

        request_.GET._mutable = True
        request_.GET["p"] = page

        return request_.path
 
request_.path only returns a path without any params
 
9:07 AM
@AndrasDeak Noted, can you check chat.stackoverflow.com/transcript/message/53351718#53351718 ? I am considering github.dev.
 
I already have
 
@AndrasDeak You replied to me? then, noted.
 
Yes
 
@AndrasDeak noted
 
To put it less subtly: you don't have to read (read: just don't) bother random people with your questions. Just ask, and whoever wants to answer they can.
@VScode_fanboy no, that's a useless tag. But closed questions aren't worth editing.
 
9:15 AM
@AndrasDeak Ok, noted.
@AndrasDeak Noted.
 
I mean the tags are valid but very niche. They're being abused here.
 
@VScode_fanboy That is VSCode, as far as I can tell.
 
@AndrasDeak (first "read" is superfluous)
 
Does anyone know what is the proper way to have a TypeVar of a Callable with strict-mypy? It looks like ParamSpec does not work, and strict mode means MyPy doesn't infer things. Playground
 
@AndrasDeak you are telling that the general meaning is correct but only for the relate questions can be the tags added? by abused you mean wrongly used?
 
9:22 AM
Yup. Read the respective tag descriptions.
 
@MisterMiyagi I heard that it is a online version (and code runnable opposed to vscode.dev) but I have some problems.
@AndrasDeak I read before coming, just to be sure, also [if you can/want] ping me otherwise I will miss your messages.
 
I usually don't ping when I'm replying to the message right above mine.
I'll try.
 
I feel like iI have seen this question stackoverflow.com/questions/69611677/… asked about 10 times in chat here xD
 
@MisterMiyagi ParamSpec isn't fully supported by Mypy yet, there's an open issue about it 😕
 
@VScode_fanboy Sorry, I have no idea what "6 digit crap" means, nor the rest of that.
If you want to use something like VSCode, I recommend to use VSCode.
 
9:31 AM
@Kwsswart yes, same user
Ignore it
 
@AlexWaygood Yam. So going back to Any it is, then. :/
 
yeah can't help anyway
 
@MisterMiyagi yeah. I think this is the best that's currently possible mypy-play.net/…
 
@PM2Ring Yes I have already created a simple application using Json which saves a label from a text entry, however I am still struggling to apply it to my application.
 
@AlexWaygood Any seems unused
 
9:35 AM
@AndrasDeak using an ellipsis for the parameters is preferable to Any, as Any can only represent a single parameter, whereas ellipsis in a Callable can signify "any number of parameters of unknown types"
"preferable"... Well, better for this use case, if I understand the use case correctly
 
@AlexWaygood but then you don't need the import
 
@AlexWaygood That just crashed MyPy. ^^
It chocked trying to infer something a few layers deep. :/
 
@MisterMiyagi oh that's fun
@AndrasDeak indeed. Left over from an earlier experiment in the playground.
@MisterMiyagi can I see how you're using the typevar?
 
@MisterMiyagi 6 digit crap = this issue, and the rest is that I am very lazy to go to my email box and get the verification code from github and enter it.
 
@AlexWaygood The crash is triggered on this usage: "AssertionError: Binding for function type variable not found within function". I guess it expected me to parameterize the use as well.
 
9:47 AM
Right, yeah, for that kind of usage you'll have to have the return type as Any rather than a TypeVar R, since there's no support for higher-kinded TypeVars currently ☹️
You can currently only bind a TypeVar to another TypeVar if the TypeVar it's being bound to is itself already bound... If that makes sense
 
Afraid it does. ^^
 
On a happier note: this baby just got his first bugfix merged into cpython!
 
Yay!
 
10:03 AM
@AlexWaygood congrats
 
10:24 AM
@AndrasDeak thanks!
 
 
2 hours later…
12:22 PM
morning cabbages, folks
 
12:51 PM
Does anyone here maintain an app that is managed with CI/CD on GitLab and deployed in a Docker? I have a sample data set and some Jupyter Notebooks that are version controlled in the GitLab repository but cannot figure out how to have them copied to the Docker container when the app is rebuilt.
I thought of having the Docker clone the repo each time but that brings in a bunch of extra files and did not work in the initial attempt
 
I won't be able to help with the specific question, but "brings in bunch of extra files" sounds weird. Git cloning is a very specific thing. It gives you the files in the repo. The obvious solution is to not have those files in that repo, or live with them being there for CI/CD. And "did not work", as you know, is not very helpful.
 
@AndrasDeak When I say "extra files" it clones the entire repo so, readme, gitlab-ci.yaml, Dockerfile, etc. and I just want a single directory. "Did not work" in this instance means the cloning of the repo produced nothing in the filesystem of the container once deployed, although no error was thrown in the build.
 
the former one sounds like a non-issue to me, and the latter sounds like a docker issue that should be looked into
 
I guess this is the answer but don't understand it yet.
@AndrasDeak The extra files are not a terrible problem, no
 
1:16 PM
does anyone know why Firefox flags iframe as a clickjacking threat, but not <object> when I use each to embed an external website (completely different domain, etc) on a webpage?
 
@Dodge usually you just have a Dockerfile that has a bunch of COPY my_file.py / statements. does that match so far?
 
1:35 PM
@Arne Well my latest attempt was to use ADD but I think my problem is that I'm putting things off in space and that's why they don't show in the instantiated container.
I'll report back after this latest build finishes :)
@Arne so RUN mkdir .myfiles and then ADD sample_data .myfiles does not throw an error during the build output (log or whatever you call it) but using find . -name myfiles in the container produces nothing. The directory I made and copied to is nowhere to be found.
 
can you paste the file into a bin and link it here?
 
yes, i don't think there is anything proprietary there
 
2:35 PM
Hmm, Firefox updated and now I don't know how to get to my greasemonkey userscripts. The addon is installed, but the toolbar button is missing.
 
how about right click on toolbar, "customize toolbar"?
 
That opens the "customize firefox" tab, as usual. Usually there's a monkey face icon among the choices available, but not today.
 
ah
any chance it was moved to a double-right-pointing-chevron icon at the end of the toolbar?
 
I have also looked at the text labels of each icon, just in case the greasemonkey team chose a more dignified icon. Doesn't seem to be the case
My double-right-pointing-chevron toolbar icon is also missing.
 
Mine too, for what it's worth. I think it only shows if something's in there
Have you tried turning it off and on again?
 
2:43 PM
I've tried dropping some miscellaneous things into the chevron menu, just to ensure it is non-empty. Once I exit the customize firefox tab, I don't see any obvious way to access those items.
 
huh
you need to press "done" when you're done editing
bottom right corner on linux
 
I don't know if it gives you access to the userscripts, but usually you can open an addon's settings from the "add-ons and themes" menu
 
From that menu, I can get to a details page where I can set "allow automatic updates" and "run in private windows". I think every addon has those settings.
 
I wasn't joking with the restart though.
 
It's been like this since before my last reboot, I think. But yeah I'll restart
 
2:49 PM
restarting firefox only for what it's worth
 
You clicked "manage", right? Usually there's also an "options" button there, but I guess the Greasemonkey devs were lazy
 
Well, at least I found where the "overflow menu" is. It's on the right end of the bookmarks toolbar, which I usually have hidden. It has the miscellaneous items I dragged onto it, but not the monkeyface
 
If there's a bookmarks toolbar I have it disabled
My setting for it is "only show on new tab" but nothing is shown on a new tab. Oh well.
 
I sure do love it when a UI element is disabled with no indication of why
 
@Dodge and which files do you need in the container? just the content of the folder my_files?
sorry, work interrupted my attendance here
 
2:53 PM
Hey all! I have a small doubt regarding changing index of a DataFrame.
Code:
A1 = "SELECT * FROM student"

q1 = pd.read_sql(A1, con=con)

df = pd.DataFrame(q1)

print(df)

df1 = pd.DataFrame(q1, index = range(1,21))

print(df1)
Output:
    roll_no       name stream
0         1   Abhinash    MPC
1         2      Aditi    MEC
2         3    Alekhya   BiPC
3         4       Amit   CEIP
4         5   Anuhitha   BiPC
5         6       Hari    MPC
6         7        Jay    MEC
7         8      Kiran   CEIP
8         9     Madhav   CEIP
9        10    Manohar    MPC
10       11      Manoj   CEIP
11       12       Neha    MEC
12       13      Pawan    MEC
13       14       Ravi    MPC
14       15     Ritwik   CEIP
15       16  Samraddhi   BiPC
 
@Aran-Fey Yeah, I clicked "manage". Can you name an addon that definitely has an "options" item? If I install it, then I'll be able to tell whether 1) greasemonkey was lazy; or 2) I somehow enabled "don't show options anywhere" baby mode
 
@RandomPerson side note: df1 = df = ... will not change the original dataframe bound to the name df
@Kevin I couldn't find an options menu for GM here. Then again I haven't looked at other addons.
 
@Kevin Tampermonkey :D
 
OK, I can't see one anywhere so perhaps I'm looking for it in the wrong place
 
Go to about:addons and click the ... next to the addon of choice. Not all addons have it though, like I said
 
2:56 PM
I got the chevron menu to appear. I added a ton of miscellaneous icons until they couldn't all fit on the screen. The ones on the right automatically go in the chevron menu. Monkeyface is not among them.
 
@Aran-Fey ah, got it. GM devs are lazy.
 
Installing TamperMonkey... If this works and GM is still broken, I'll just switch. I don't have much brand loyalty, just inertia.
 
TM is nice :)
 
@AndrasDeak sorry. that was a mistake. I edited the message. Still the output is same..
 
 
3:00 PM
Well that's freaky
 
@RandomPerson Why are NaN values there in df1?
 
I'm guessing options is supposed to be there. So the blame falls on the mysterious Baby Mode, rather than GM's laziness
 
I don't presume you made any changes to your userchrome.css?
Made some buttons invisible that you didn't intend to?
 
Not recently >_>
 
@RandomPerson your index has 1 too many items
 
3:05 PM
Ah, at the very least I now see a Tampermonkey icon in the Customize Firefox menu. This solves the problem at the top of my XY stack, although many mysteries remain unanswered.
We did it, gang! Kind of.
 
ah, no, it's not that
I think the new index is looked up on the old index
old 0 is discarded and new 20 is missing
Isn't there a reindex() or reset_index() method?
 
ah bitten once again by premature optimization
 
Ok, alert("Hello world") works but not console.log("Hello world")... Unless there's a super special tampermonkey-specific console that shows only the messages that this specific script shows. I would pay a pretty quatloo for that.
If I increase tampermonkey's logging level, then my logs show up in the usual place. I guess that's fine, the super special console I was imagining probably wouldn't be all that cool anyway... [I disconsolately kick a tin can down the sidewalk]
When life deprives you of grapes, make absence-of-sour-grape-ade
 
3:23 PM
@RandomPerson I'm sorry, but I'm not seeing a question
You mention NaN values, but they don't seem to exist, and I'm not sure of the motivation for this particular re-indexing either
Ok, I can see the NaN now. I didn't realise a giant code block was still embedded in chat
It also means that I have absolutely no idea on what that code is supposed to do
 
4:02 PM
@roganjosh I just wanted the index to start with 1 and end with 20.
 
For what reason?
 
Fortran cross-compatibility
 
roll_no already has that property. Set that as the index
 
@AndrasDeak I don't think so. There are 20 rows in the query output and the index is a list which has 20 numbers..
roganjosh, I don't want to set roll_no as index.
 
@Arne Just the content of the directory in my repo called "sample_data" my current attempt is COPY sample_data /app/myfiles. (app) is where the container is mounted. The weirdest thing is that I run RUN mkdir myfiles without issue on the build but that directory is not found when searching through a terminal interface on the Jupyter Notebook UI once deployed.
 
4:05 PM
and I have no clue why the values of the roll_no column are displayed as float values because of using custom index.
 
@RandomPerson because nan is float
 
import pandas as pd

df = pd.DataFrame({'a':[5, 6, 7]})
df.index = df.index + 1
print(df.head())
 
@roganjosh side note: += ;)
 
@AndrasDeak oh.. ok. Thanks for the info!
 
Lol, yeah, I was shooting for efficiency of the foot-gun :D
 
4:07 PM
Sorry if this is obvious to the pandas-savvy, but does "set roll_no as the index" mean "mark the roll_no column as the index column" or "copy the values from the roll_no column into the index column"?
 
Footguns can be highly effective in freestyle melee situations
@Kevin former
 
@Kevin it will mark it as index column
 
Not obvious though, I bet
 
Given my example, @RandomPerson, what question are we answering?
 
4:09 PM
but why is 1st row of SQL table not displayed in df1?
 
Other than "should I execute SQL through pandas?" in which case, the answer is "no"
 
@roganjosh I am sorry. I didn't get your question.
 
It what a hypothetical question to show that I wouldn't execute SQL through pandas
 
@RandomPerson beyond what I already told you?
 
so you prefer using a cursor?
 
4:11 PM
Yes
 
I'm quite curious about "I don't want to set roll_no as index". Is there some scenario where doing this would lead to bad output or a crash? Is the technique aesthetically displeasing? Is it forbidden by the requirements of the assignment?
All of these are valid justifications IMO. Knowing which one it is might usefully narrow down the possible solution space
 
roganjosh, but I want the data to be stored in DataFrame. if I use cursor, the contents of the SQL table will be displayed as lists :(
 
Well that simply isn't true. Please show that code
 
Otherwise we end up in a difficult situation similar to:
querent: hello, I need to add two numbers. How should I do that?
me: I recommend the addition operator: `x = y + z`
querent: nah. What else you got?
 
All that pandas is doing is wrapping the nested list that is returned. And pandas isn't exactly stable, so I'd rather call the df constructor separately from the library that I use to query the db
 
4:15 PM
>>> select_movies_query = "SELECT * FROM movies LIMIT 5"
>>> with connection.cursor() as cursor:
...     cursor.execute(select_movies_query)
...     result = cursor.fetchall()
...     for row in result:
...         print(row)
...
(1, 'Forrest Gump', 1994, 'Drama', Decimal('330.2'))
(2, '3 Idiots', 2009, 'Drama', Decimal('2.4'))
(3, 'Eternal Sunshine of the Spotless Mind', 2004, 'Drama', Decimal('34.5'))
(4, 'Good Will Hunting', 1997, 'Drama', Decimal('138.1'))
(5, 'Skyfall', 2012, 'Action', Decimal('304.6'))
 
df = pd.DataFrame(result, columns=[item[0] for item in cursor.description])
 
what is the meaning of [item[0] for item in cursor.description]?
 
That won't work if you iterate the cursor. It's a generator, so you'll exhaust it and get an empty df
 
[item[0] for item in cursor.description] is actually (at least to me) pretty bizarre. The DBAPi says something about it having to return 7 values (IIRC) of metadata, the first item being the column name. I've never needed more than that value
In any case, it gives you the column names to construct the df
 
4:21 PM
🆗
 
hello friends,
In django, I am getting error, ['“2021/10/11” value has an invalid date format]
 
What is the template code?
 
when I submit form it's automatically adding '“”'
how can I remove it?
 
As in, the HTML/JS
 
in html value="2021/10/11" but getting it in view with double quote
 
4:28 PM
You'll need to give the relevant code (probably in gist or dpaste)
 
Might be helpful to check the browser's Network developer tool, so you can examine the exact format of the form data being submitted
If the weird quotes are present, it's the web page's fault, or the user's. If the weird quotes aren't present, then it's Django's fault, or perhaps a prank-loving web traffic node
Inserting quotes into random packets just to make life more interesting
 
Fun fact: Kevin doesn't lock his doors, and leaves all windows wide-open. Ain't nobody gonna box him in :P
 
I cannot be contained, despite my wishes to the contrary
Oh to fit snugly within a unit cube
 
My current theory is that there's a yet-undiscovered species of birds that are just trying to bury quotation marks to weather them over winter. We probably shouldn't disturb that
 
These so-called "smart quotes" are an evolutionary offshoot attempting to gain dominance over their mundane cousins. Like everything else, they'll probably get outcompeted by a carcinized relative. The shape of quotes are already quite well-adapted for pinching.
 
4:43 PM
in python
how to make regular expression to remove '“2021/09/27” all quote?
 
Does it have to be a regular expression? s = s.strip( <a string constant containing both kinds of smart quotes>) seems easier
I didn't type out the actual string constant there because my environment converts smart quotes to dumb quotes when I least expect it
 
@NIKHILCHANDRAROY how about we don't have it in the first place? We would be able to see if there's a coding error if you posted an MCVE
 
Yes that too
 
5:29 PM
>>> class A:
...     pass
...
>>> class B(A):
...     pass
...
>>> class C(A, B):
...     pass
...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: Cannot create a consistent method resolution
order (MRO) for bases A, B
 
the forbidden jutsu
 

« first day (4030 days earlier)      last day (901 days later) »