« first day (3614 days earlier)      last day (1317 days later) » 

raf
7:20 AM
@MisterMiyagi seems no mod has checked my issue yet. :(
 
8:12 AM
@raf I don't we've had any active mod presence in the room since you raised this. It might be worth raising a custom flag on your latest question to ask someone to look into it - Meta just jumps on "why was I banned?" questions
 
 
1 hour later…
9:22 AM
Ugh, presumably spurred on by just making it on the HNQ they've decided to cross-post on SO :(
 
9:46 AM
Really doesn't seem to fit SO.
Wondering why they made it to HNQ though, the review doesn't seem that useful.
 
HNQ is a strange beast
Although, a HNQ on Physics has led me to a Fermilab video telling me that my understanding of why light bends in different media is apparently wrong
 
Hello
 
I am trying to add some text in the frame but in the output I am getting a frame only.

The program is not showing any text in the frame in the output. Can anyone help me out?

code -

from tkinter import *
root = Tk()
root.geometry("730x544")
f1 = Frame(root, bg="grey", borderwidth="6", relief=SUNKEN)
f1.pack(side=LEFT)
label_f1 = Label(f1, text="File\n\nEdit\n\nSelection\n\nTerminal\n\nHelp",
font="comicsansms 7 bold",
fg="white")
label_f1.pack(pady="400", padx="60")
root.mainloop()
Thank you
 
10:01 AM
Note that we have a formatting guide for chat. You can't actually mix plain text with block code formatting in a single message. However, I think your post is clear enough. Unfortunately, I don't know tkinter though, so it'll have to be someone else to help you :)
 
Hey i used ctrl+k but it did not work for formatting.Why is that so?
 
Well, it did, it just applied it to your whole message. That's why we have the guide I linked
 
@TanishSarmah I think the padding is applied on both sides, so your window isn't large enough for the label to be visible. It has 400 pixels padding on the top and the bottom, but the window is only 544 pixels high
 
@Aran-Fey ok i reduced the 'pady' and now i can see the text. Thank you!
 
I have it in the back of my mind that you were asking for something to be added to sopython/canon @MisterMiyagi ? I think I saw it in passing and it's not showing in search now. Or, I imagined it :P
 
10:20 AM
@roganjosh Lol turns out i did break it the other day :/ had to go again with the database transfer froms tart
 
Ouch :/ All sorted now, though?
 
@MisterMiyagi HNQ is automatic crap. If something doesn't fit, leave a custom mod flag and they can kick it out from there
 
@roganjosh Yeah all sorted with that part now lol just trying to run through nginx config atm lol Setting up a server is rather complicated to understand
but learning a lot on tracing back errors through this
 
nginx is complicated, full stop
 
yeah right now facing an error that stating it cannot find the ssl certs, however i thik that may be my path or something as I can see them there when searching manually just got to figure a way to check the user and that in cmd (#google)
Actually quick one if I have the following path on my cmd line: vagrant@ubuntu-xenial:~/Mega/certs$ if running nginx would the path be ssl_certificate /home/ubuntu/Mega/certs/cert.pem; or ssl_certificate /home/vagrant/Mega/certs/cert.pem; or ssl_certificate /home/vagrant@ubuntu-xenial/Mega/certs/cert.pem;
This is the line where the error is occuring which leads me to believe it isnt finding the cert.pem in the certs directory, meaning I am sure the user may be wrong
 
10:29 AM
@roganjosh Yeah, it was about annotating builtin containers. Can dig it up later on.
 
@Kwsswart my suspicion is option B but I'm not the person to help with Linux really
 
@roganjosh I tried option b earlier which allowed nginx reload to take place but when checking via 192:168:33:10 it let to 502 bad gateway
 
@Kwsswart pwd will tell you "this" directory
 
Wouldn't it be 192.168.33.10:443?
 
where a given program might be looking for anything depends on the program itself
@Kwsswart yeah that's just nonsense
 
10:37 AM
Also, I've really only got bad gateway when the app wasn't listening I.e. I've pulled down the gunicorn server that nginx forwards to
 
@roganjosh Using that above came with 400 hmmm interesting
 
10:55 AM
@roganjosh See this chat message. The linked Q seems suitable for "How to annotate the type of container elements" or more generally "How to annotate generic containers"
 
Ok, thanks. I'll have to have remind myself how tags work on sopython. It looks like they may be "arbitrary" to some extent, so do you have suggestions on what would help you find it? Type hinting is not really my strong point (though I guess type-hint is one such tag :P)
 
type-hint, annotation should fit, as well as typing and generic
 
What is the best resource of learning Python online?
 
the docs are both worthwhile and often overlooked...
 
This room also maintains a list of good tutorials
which also includes the docs. they really are good
 
11:06 AM
@MisterMiyagi done and thanks for the suggestion
 
I was learning through w3school
 
@Exception I have found the cs50 course a good intro course man
 
Always thought realpython is for advanced
 
@roganjosh Thanks!
 
While statement has else block.. WOW!!

I strongly believe most of us use it for logging purpose to indicate that loop has ended.
i = 1
while i < 6:
  print(i)
  i += 1
else:
  print("i is no longer less than 6")
 
11:13 AM
@Exception IIRC w3schoool has a bad reputation with some people due to a perceived tendency to recommend antipatterns.
@Exception for loop has the same else clause. I usually use them for defaults in linear scans. Not a common pattern, though.
 
What do you mean by in linear scan?
Instead of adding private keyword in front of function name python has __ . Well, that is interesting.
 
@Exception Searching something by sequentially checking things. E.g. "get the least-used cache with enough space for X", when the thing to search through is already sorted.
 
Got it.
 
11:49 AM
Personally I like this syntax which looks similar to do{}while(); loop
print(a) if (b > a) else print(b)
 
@Exception no
If you like that use perl
conditional expressions where you discard the actual expression are an antipattern
 
It is not exactly similar but it looks similar when you come from the background of do-while
 
like list comprehensions with side-effects
 
Please avoid using expressions that do not produce values. Prefer print(a if b > a else b) or use an if statement.
 
Woah! I just learned new way of if statement in Python
 
11:53 AM
Note that ... if ... else ... is not an if statement.
 
 
2 hours later…
1:48 PM
Long time no see everyone! (It has been a billion years, honestly.) I have a quick question that I can't seem to find a reasonable answer for anywhere. In medias res: let's say you are a library developer and your library depends on a handful of SQL tables. As the library developer, you want to give the option to your library's users to create those predefined tables in their own databases.
As it happens, you'd like to use SQLAlchemy and SA's declarative base (i.e. the declarative class-based definitions) to define your tables. Unfortunately that Base metaclass created by the declarative_base function is created by your users, so you can't have it at the time of implementing your library.
Now of course you can use Python's dynamic nature to define classes on-the-fly and provide some function to your users so they can "create" the necessary tables at the time when they create the declarative base. But then they either have to be careful when it comes to the order of imports, or they may have to plug the resulted table-classes somehow back to the library.
Either way, it does not seem to be a robust, elegant, nor a convenient way to do this. So my questions are: 1. is this an XY question because actually multiple bases or some other trickery could be used to make my second question redundant or this is not the right approach in the first place then I'm interested in the correct way of doing this, 2. if indeed a single declarative base is needed for SA to work reliably then how to achieve what I described above?
 
Isn't that just a config parameter that your library needs at runtime?
 
Might as well be, what do you have in mind?
 
Much like matplotlib has multiple backends, you can get the connection string as some config to be specified at import time (or, maybe not like matplotlib at all, since I never looked at their actual implementation, but that's the behaviour I've been shooting for in my side project)
 
If I understand correctly, you want your library to create those tables immediately when it's imported? In that case, why not decouple that from the import and simply give the users a function they can call to create the tables?
 
@Aran-Fey That's what I suggested in 3rd paragraph ;)
 
1:55 PM
Oh, right
 
Alembic itself requires the user to set some things up with CLI before you can use the library. I'm not sure it's unreasonable to make people use some kind of init argument before using the library
 
@roganjosh Does not sound unreasonable, if SA itself has the limitation of not being able to handle this sort of decoupling
 
I actually faffed with this kind of thing for days. That was my conclusion; but there are far better programmers than me
 
@roganjosh Don't beat yourself up, it is not a matter of being "a better programmer", SA (and ORMs in general) introduce waaaaay too much magic into the code making it nearly impossible to use them properly without a definitive knowledge of all the implementation details.. which defeats the purpose of higher level abstractions in the first place.. but hey, everyone uses them, so who am I to question their relevance? :see_no_evil:
 
2:19 PM
TBF I'm not even sure if the declarative base needs to be the same.. Maybe it is only the session maker that needs to be shared?
 
I'm 78.2% sure that your models need to inherit from a common Base
 
Hello
 
But even that is up in the air because I'm going off what Alembic can detect automatically. I suppose you could set it more definitely
 
In Qt5 How can i position some frames in the top of ScrollArea (Layout Vertically)
I try to do this in QtDesigner.
 
@roganjosh That's exactly what I thought -- hence I'm in this pickle
 
2:23 PM
I mean with Layout vertically the frames are spaced.
 
@roganjosh even for alembic you have to define what you do with the Base / Base.metadata in env.py
 
Can someone explain the problem for the ORM-avoiding folks? How are people going to use XYLib without having imported their XYLib-using classes?
 
@PeterVaro I'm gonna back out at this point, just because I'm totally dissatisfied with what I came up with so I don't even want to begin making suggestions that might sway sensible results
 
@roganjosh so maybe I could get away with a separate base, by providing access to it for the library users? (I wouldn't like that though..)
@roganjosh Either way, cheers mate, I appreciate the help so far
 
I look forward to someone answering the question I didn't ask but kinda wanted to :P
@MisterMiyagi in my case, I wanted a library with classes that have an optional persist argument on the methods, which would write things back to a database of their choosing via SQLAlchemy. As the library grows, more tables will be needed, and they'll probably be recorded via migrations in alembic. It's not possible (I think) to just take a connection string and ensure the database is up to date, cleanly
On import, at least. It requires some intervention
No, please see the room rules. You should wait 48 hours before bringing questions to chat
 
2:34 PM
ahh im sorry
 
Although, I seem to remember that I tried to get too clever with what I was trying to do, failed, and that's why that project is now on the backburner :P
 
Hello
 
hello...
(suspicious username :P)
 
Why so?
 
nothing, nothing ;)
 
2:43 PM
I feel like I should get this but it's going right over my head
 
<cough> Java </cough>
 
you need more coffee :)
 
that's probably true
 
@roganjosh So basically dynamically adjust the backend layout as the class structure expands?
 
its been a while since I've been here. I thought you were saying that because I've changed my username since then
 
2:47 PM
@MisterMiyagi pretty much. But you can't use build_all() if you wanted to drop fields from a previous release; it requires a migration history and running that needs to be better than just "You downloaded a new version, let's swap things around in your db"
At least, that was my end result of considerations. Even if I could force such a thing on import, I probably shouldn't
 
@CupOfJava StephanS?
 
yeah
 
I see
 
it's been about a year
I think
 
yeah, almost exactly
 
2:49 PM
anyways how have you been?
 
same old, same old
 
@roganjosh I'm torn between considering this an interesting problem worth solving, or time sink that could work well-enough by smugly pointing users at the docs. :P
 
yeah, same
if I remember correctly, you're a data scientist, right?
 
So far, my attempts at transparent persistence have failed spectacularly. So I'll leave it at considering this an interesting problem worth solving by someone else. :P
 
I kinda sawed off the database side and made it so you had to pass the database object to the app factory
 
2:53 PM
@roganjosh Naiive question: I take it you can't just wrap your db connection/init with code that checks up-to-dateness, drawing migration history etc, which you'd purposely be storing to be useful for this purpose?
 
@toonarmycaptain if you find a neat way to do that, then do let me know :) We don't even know if the app is being run with the same backend each time
 
@roganjosh My suggestion would be simply to persist data about what backend the app is being run with. Also querying whether you mean neat as in tidy/elegant or neat as in cool/innovative.
 
This is getting into my "being too smart" territory where I eventually got bored. And I mean "neat" as in tidy/elegant
Anyway, this was never my original question, I've just inherited it :P I had scheduled some time bashing my head against a wall to look into this some more
 
@roganjosh My guess would be to store the history in the db itself, then write a wrapper that will bootstrap bringing it fully online by looking at that data, applying whatever migrations are needed, then connecting the main app to the db. I'm thinking of that db object I showed you, and how I'd retrofit this ability to that.
 
Yeah, I just took a second to look at it and I'm not getting any "clean" ways to do it. give me a minute to get another cup of java and maybe I would figure something out by then
 
3:05 PM
@toonarmycaptain just force the user to re-init or complain loudly
 
But as you've correctly said before, I don't know enough here yet to know why what I'm saying is hard lol
 
It's pointless storing the history in a db that might not be their backend next run
alembic will store its own version if you keep working with the same db, though
 
uuuuuuugh, spending nearly a day on a stupid firewall setting. Apparently Windows decided to have an own section for allowing and not allowing pings coming from VM, compared to normal PCs. So my test with the other laptop showed it can't be the firewall, so I went on a goose chase after OpenVPN configs, which actually were all right, but damn networking is confusing. venting off
 
@roganjosh I prsume the point would be that whatever db is used, it has appropriate data to determine what migrations are necessary. Am I missing something, like arbitrary dbs will be needed that have never been connected to the app before? :s
 
@toonarmycaptain the latter. I might upgrade from SQLite3 to Postgres. But what if I never pass a db connection string to the library in the first place? If all the options are the default persist=False, then it need never consider the db in the first place, so what migrations would I run? It's... not easy to figure out
 
3:12 PM
@Hakaishin I am able to relate xD
 
That's why I think it's easier to hack out the db connection as a separate object and then pass to the app factory, if I choose
 
that's weird
Was that you or chat.....
 
Chat duplicates messages on lag every now and then
 
lame
 
It has happened to me about 10 times before xD
 
3:15 PM
@roganjosh I've got a db on my machine right now that I presume would not be compliant...so yeah, wrapping/validating first would seem like a good option there.
 
 
1 hour later…
4:22 PM
In what case does it happen that no matter what you change in the script the script still executes lol.
 
Depends. Are your changes breaking changes?
And what constitutes as "executes"?
@AshwinPhadke You're being unclear as usual
 
Any case where the script is loaded into the interpreter and in memory?
 
I m so confused myself that I deleted the entire code from the script and it still executes and throws error.
@AndrasDeak This time even I am out of words
@roganjosh How do I check that.
I am using VSCode
 
@AshwinPhadke I'm not. Stop the script with ctrl + C and try run it again
 
@roganjosh I did a lot of times.
 
4:25 PM
This is silly. Delete any .pyc files
 
@roganjosh let me try
 
I kinda expected a ping after having done that
 
we still don't know what they mean by "execute" so I wouldn't spend too much effort trying to find evidence of demonics possession
 
Wife Swap gave very compelling evidence that the tumble drier was possessed. I'm very unsure after that point
Probably Java
 
@AndrasDeak I mean the usual python startthis.py
 
4:30 PM
Take a look at the output of cat startthis.py and check if it matches the code you see in your IDE
 
crystal ball: they didn't save the file in the IDE after "deleting it"
 
4:44 PM
@Aran-Fey Yes it matches, I double checked the path of the script, I also double checked the import statements where I am importing some modules that I am calling.
 
Then I'm out of ideas (disregarding things such as demonic possession)
 
@AshwinPhadke how are you importing and calling modules when you deleted all your code?
 
@AndrasDeak Not all I only deleted the code from one of the import, I have three code files that I import in one so I deleted code from one code file which obviously then shouldn't run the entire thing , but it does on top of that ir executes the statements from the code I deleted so I checked whether if I was incorrectly importing same file fom some other folder but no it is not the case.
 
sure
 
To skip importing and mismanaging, I directly copied the functions in the file I want instead of importing from some other file but the function call doesn't hit
Here is python file 1 : pastebin.com/FYWiUxQe
Here is python file 2 : pastebin.com/ZdKNrGqb
AFAIK there shouldn't be any problem to call the ` download_model(model_name, pbtxt_name)` function but it doesn't and directly skips to line 47 without doing anything from line 40-46
41-46*
because it does execute line 40
Let's skip the function call too, but it should atleast show those print statements right?
 
4:56 PM
Are you sure it's importing the correct file? Take a look at file2.__file__
 
@Aran-Fey do you mean if name = main ?
 
No, I mean does print(file2.__file__) point to the same file that you're looking at in your IDE
 
@Aran-Fey It is the same file
 
So today was fix your Internet day for me. I've had two incoming fibre connections for a while (two different providers, but both provisioned by OpenReach, so much for redundancy). Because old building basement, wifi between the two halves of the house was impossible, so I put a mesh in.
 
The problem is with wget , it doesn't give you an output if it doesn't download a file and just skips everything
What are some other options for file downloads?
 
5:12 PM
Today I had a contractor install an Ethernet cable (through two outside walls) between the two "halves" of the house, and during rerouting of the existing ADSL cable my speed has gone up from ~25Mbps to ~70Mbps. I am one happy bunny.
 
@holdenweb did you fix then?
 
Nope, I just had the guy relocate the ADSL connection, which meant rewiring the socket. Clearly the installing engineer did a less than perfect job. Suddenly the Internet feels like it should again (but faster!)
 
Good for you, more to do.
 
@AshwinPhadke scp and rsync
But both require login creds from the source machine, unlike wget, which just pulls from an HTTP server.
 
Here I have posted the problem I found : stackoverflow.com/questions/63781888/…
@PaulMcG I want something that can download directly
can urrlib work in my case??
 
5:32 PM
Yes, you can use urllib.
That's pretty much what wget does anyway.
wget hasn't been updated since Oct 2015. Looking at that code, only about 10% of it is actually for the download, and about 1/3 of it is to implement the progress bar. Look at the wget.py file that you get from installing it, and pull out the download() method and tailor to your own needs.
 
@PaulMcG Even i was checking that , I couldn't even find the code, it seems that it is of no use. It is morestrange how it works for one and not for other
 
Go to pypi.org, search for 'wget', this will show its project page. Download the source, you'll get a wget.zip file which contains the source and a README.txt.
But it would also be good for you to learn where Python files get installed in your system. (Google searching for this info is left as an exercise for the reader.)
 
Yeah foound that, the source has a check to see if the .tmp file exists or not before even starting to download. It was not written to help it seems
 
5:57 PM
Hey everyone, what's the standard way to do async network requests in the latest Python?
looks like aiohttp
 
6:41 PM
Still requests-futures?
 
7:00 PM
I'm importing a variable like so from application import foo, where foo is an instance of FooBar. But MyPy complains about any reference to foo as having the type of Any. How can I typehint this variable so it knows foo is of type FooBar? Trying to typehint using foo: FooBar = foo or using comment typehints just causes the error "misplaced type annotation". Thank you.
 
7:20 PM
@crypticツ In application, where you define foo = whatever, try foo: FooBar = whatever
 
7:32 PM
@AshwinPhadke OK, what I really don't understand is the determination to use wget when the resources you need to download could, being HTTP resources, more easily be downloaded with requests or some less sane HTTP library, which is sometimes called an XY approach to problem solving.
You ask about wget when the real requirements is to download HTTP resources, no?
Apologies if I am misinterpreting.
@roganjosh What's its relationship to requests?
@crypticツ Can you add a type declaration (I never thought I would type those words about Python) for foo at module level?
Python is morphing into Algol.
 
@holdenweb I'm quite tempted to say "none". All I know is that you can batter an API with it because I use it on myself. There may be a link, though
I think it's just a library written to try immitate what requests did to urllib
There is also grequests but I broke that. More than happy to be corrected on the best libraries for async requests if things have moved on :)
 
8:17 PM
Looks like it still maybe aiohttp, then. Unless someone knows better?
 
Reading this (note, some popups) suggests it might not make much difference. I'm half tempted to set up a test case myself but I don't know what a fair payload is as a response, to behcnmark them
For a start, I'd probably use gunicorn which means putting it on Ubuntu and bridging the ports, and then I have to decide what to return. Maybe empty strings?
I think that's a bit poop because I feel like I should be making the caller do some work to check on a server that's actually doing something
 
8:34 PM
randomly throw them a 403 in 10% of requests
 
I think that's gonna derail both approaches :)
A sleep of 0.1s +/- 10% wouldn't be awful, I guess
 
9:04 PM
What is the html equilevant of QTextBrowser?
iframe or tinymce or some rich html text editor?
 
No idea what a QTextBrowser looks like. Should there be an equivalent?
I'm currently faffing with setting up a decent benchmark for the timings of asyncio vs. requests-futures and I've come to realise that I miss the chaotic life I used to lead :D
 
9:21 PM
Like testing async implementations isn't chaotic ...
 
yeah... but... but...
 
Wrong kind of chaos?
I remember working on the pybench code back in the day. That taught me a few things.
 
Dev
Confused about how python round the numbers
>>> print(round(54.5))
54
>>> print(round(51.5))
52
 
I think I'm just too tired to make sure I do a good job. I might be better switching to computer games now
 
Dev
why 54.5 is not rounding off to 55
while 51.5 is rounding off to 52
 
9:32 PM
it rounds towards the even number
 
Dev
Thanks @Aran-Fey
Wondering, how can we make it round off to next number, whenever the number is in decimal
 
@Dev you mean always round up? You might need math.ceil.
just make sure it does what you want for negative numbers
You can 1. round toward even, 2. round toward zero, 3. round away from zero, 4. round toward -inf, 5. round toward inf
most of these are not "round" in the traditional sense
 
Dev
The hanks @AndrasDeak
 

« first day (3614 days earlier)      last day (1317 days later) »