« first day (3606 days earlier)      last day (1341 days later) » 

12:55 AM
Hi
How do I check if an image has rectangle shapes or some other stuff?
 
 
5 hours later…
6:02 AM
cbg, can anyone tell me if the second for loop is normal in python or should I stick with the first version?
from pathlib import Path
paths=['/root/folder','/home/folder','/home']

for path in paths:
    path=Path()
    # do Path object operations with path

for path in map(Path,paths):
    # do Path object operations with path
 
6:34 AM
both are fine
 
 
4 hours later…
10:40 AM
@Kevin Coming back to your question on Dict[..., Union[...]] after digging a little into typing theory. It seems the problem is that mypy uses unification for type inference. Loosely speaking, that means it decides "this unknown type is a <known type>" – e.g. a = 3 "a's unknown type is a integer" and a: int = foo "foo's unknown type is a integer".
It doesn't use bi-unification, which loosely speaking means "this unknown type is at least a <known negative type> and is at most a <known positive type>".
That, apparently, doesn't play well with Invariance of mutable containers (dict keys/values) and Unions of multiple types (int or str).
Basically, it has to decide that a) "3 is a int" or b) "3 is a Union[int, str]", it cannot say "3 is at least int". So assigning 3 to an invariant ("exact") Union[int, str] only works when mypy decided for b.
Case b) pretty much only happens when you tell mypy explicitly, or in a direct assignment immediately after creating a thing. So d[k] = 3 works because mypy knows it needs "3 is a Union[int, str]". Doing any intermediate steps locks mypy into "3 is a int" and that's it.
Now I just need to build a MCVE demonstrator because none of what I just blurted out is properly documented...
 
11:36 AM
@JonClements always
 
11:48 AM
Is there a way to seek pointer in python stdout in terminal?
 
@Janith Can you clarify what you are trying to do? Are you looking to find a memory address written to stdout? Are you trying to file.seek on the file-like stdout?
 
@MisterMiyagi trying to manipulate printed stdout output..... but,it says stdout is unseekable...
 
You cannot go "back", once something is written to stdout it's gone from your control.
That's because stdout is a stream, not a proper file.
Depending on your system, you can use control characters to instruct whatever is reading your stdout to go back for you.
E.g. \b is a backspace on most terminals.
 
12:04 PM
\b is not working with \n
 
you might be looking for ANSI escapes or curses
 
Hi, can someone tell if a *b *c is equivalent to a.__mul__(b, c) in python?
 
It's not.
It's equiavlent to a.__mul__(b).__mul__(c), give or take descriptors.
 
thanks for confirming @MisterMiyagi
 
Either way, Expression.__mul__ being just def ...(self): is wrong.
 
12:10 PM
a*b*c is a.__mul__(b).__mul__(c)
oof, my internet is awfully slow today
 
Same here. :/
Blame it on chat. \o/
 
yep, I forgot "other" thanks @MisterMiyagi
 
@MisterMiyagi why "\r" is not working in terminal?
 
What do you mean it's "not working"?
 
ok.it is ok.....
is there a way to go back to previous line in stdout ?
 
12:28 PM
Did you take a look at the ANSI and curses links?
 
I am still reading on wiki page......
 
For reference, there is no such thing as "go back to previous line in stdout", because there may very well be no previous line. As a trivial example, consider stdout being redirected to /dev/null.
Don't focus on stdout, but on whatever thing you actually want to control – e.g. a terminal very well has a concept of "previous line", and may be fed/controlled from stdout.
 
12:58 PM
What GUI maker is best to use for non-commercial applications? I am looking at PyQt5 but i'm not sure how the licensing works and whether there is some kind of restriction in terms of usability. Tkinter looks a bit bad in terms of how their form looks and i'm hoping there is some functionality to ease the GUI making like Qt designer
 
1:38 PM
@Pherdindy not an easy one to answer. Once you skip the commercial side, I think most restrictions fall away
I'm not sure there is any restriction on PyQt for that anyway. I'll have to re-check the license
It's ok for commercial use anyway. What's your concern?
 
2:43 PM
Hello, How can i change the container/master of a tkinter widget?
I try: widget_name.config(master=...).
Error unknown option -master
 
 
2 hours later…
4:37 PM
@roganjosh Just wanted to make sure that PyQt5 could be used properly even without any paid license. Was just concerned I would spend time to learn how to use it then find out I had to pay a huge amount to get access to some essential feature for my non-commercial use
@roganjosh So far the only thing I found was something about sharing the code to others using PyQt5 as well but will have to take a look at that
 
 
1 hour later…
5:53 PM
Hello, if i have a variable a="Label" how can i create a tk.Label() widget?
Conditional if i suppose.
 
label = getattr(tk, a)()
 
I am having a strange issue now
I have not been able to track down the root cause
my observation is:
I have a long dict of lists, equivals, then I do:
d = dict(ChainMap(*[dict.fromkeys(y,x) for x , y in equivals.items()]))
which seems to take very long
if I interrupt it, it says keyboardinterrupt
however, sometimes it does not only say keyboardinterrupt, it says:
KeyError, followed by KeyBoardInterrupt
the KeyError referred to a different key everytime I run & interrupt it so far
any idea what is causing this? or am I just not patient enough, and this line really takes very long?
 
6:42 PM
I waited it out, it does complete. It takes an awful long though.
 
That would probably be significantly more efficient if you dropped the ChainMap and just called dict.update a bunch of times instead
result = {}
for value, keys in reversed(equivals.items()):
    result.update(dict.fromkeys(keys, value))
Something like that
 
7:36 PM
There is no reference in effbot of configuring tkinter OptionMenu: http://effbot.org/tkinterbook/optionmenu.htm

Where can i found the available parameters?
Also what's the difference between optionmenu and combobox ?
 
7:58 PM
@Pherdindy it's possible that they layered some other functionality on top. I don't think you have any concerns just using PyQt
 
8:20 PM
I keep forgetting that <> was valid syntax in Python and not just an Easter Egg :/
 
 
3 hours later…
11:09 PM
Your opinion on whether this is [cv-pls]? No debugging details/MCVE/code-writing request but got an answer anyway stackoverflow.com/questions/63662308/…
...wall of code "does not work"
 

« first day (3606 days earlier)      last day (1341 days later) »