« first day (4162 days earlier)      last day (1008 days later) » 

06:57
Hello I am new to browser automation using selenium and i'm having a tough time finding the elements I need. When using the "Inspect Element" feature of chrome, there are not much identifiers that I can use such as ids. And the identifiers seems to be shared between several items and indicates verb-like texts rather than nouns. For example: "next-menu-item-text" and "next-overlay-wrapper".
Those look like classes from a css framework
In the devtools there doesn't seem to be any information for the link of interest from html -> body the next one is already unusable with "div.next-overlay-wrapper.opened" as the class and so on
Any leads on which reference I should take a look at?
07:36
@JonClements Just stumbled over one of your answers while playing with my dupe hammer. Do you think it would make sense to include the linked rationale as a quote in the answer itself?
07:50
@Pherdindy you could try selectorgadget to find what query it constructs to select the element you need chrome.google.com/webstore/detail/selectorgadget/…
@hugovdberg Thanks a lot will check it
@MisterMiyagi it's a nice way to construct a big library anyway, or didn't you mean lines of code? ;-)
although it might not even be a bad idea, just maybe each in a seperate branch and not include them all in the final product.
Interesting. Armin has been playing with rust it seems
I've not yet watched the presentation, just got a "worlds collide" moment when it came up on YouTube :)
08:11
@hugovdberg It's just my background rambling. Lately, I've come to be fed up by libraries that avoid having an opinion and just dump a ton of options at users for them to figure out the mess.
Hi there! What do you use to make a web framework (bottle, flask etc.) communicate with workers queue? I often see Redis, but aren't there even more lightweight solutions?
Raw sockets are pretty lightweight...
What do you mean by lightweight here btw? I would consider Redis pretty lightweight, but as a service it has a decent sized footprint (if you're trying to run on limited resources like disk)
There's also ZeroMQ that might suit
08:40
@roganjosh I want to install the minimum number of tools, so it would be good if I can avoid having a Redis server
@MisterMiyagi wow... nearly 10 years ago!? Feel free to go for whatever if you think it's beneficial
08:54
@MisterMiyagi How would you do this?
@JonClements Done! throws Jon a treat
09:12
Cbg
How can I activate a virtual env on login on Ubuntu 20.04? I thought a source in the bashrc would be enough but that doesn't work. SO only tells me to make a simple alias, but I want it to happen automatically
ah it was the .zshrc
Is there an equivalent of Redis but 100% in python?
I mean not a redis client (pip install redis), but rather an in-memory server 100% written in Python?
any reason you dont want to use redis? It is a good tool and fulfills all you requirements, besides well you not wanting it.
@Basj I wouldn't. I either do self-contained services or stuff like batch systems.
Queues are probably a wheel that is not worth reinventing, either.
@Hakaishin Just out of curiosity. In the past I've been able to replace many tools by 100% python lightweight solutions and it was interesting
FWIW, if you want to build something like that for fun and pleasure... I'd start by having a dedicated Python process that a) has a worker pool and b) exposes a socket to receive tasks.
That should be a few lines of code. You'll mostly be working on the socket part to roll out your own communication protocol.
09:27
@MisterMiyagi And that is fun(interesting and you learn a bunch)/not fun(it's hard and has potential pitfals) at the same time. Plus you are basically reinventing the wheel. But it's the first thing I did in my current company and overall I would say go for it if you don't have any deadlines :D
@Hakaishin Yes it's sometimes interesting to reinvent the wheel, but for non urgent projects, I agree with you :)
I don't think reinventing the wheel is actually a bad thing, as long as you are mindful that a toy is not fit for production. It's how you understand how wheels work, and are prepared to fix the important ones when they break.
Yep totally agree
When you use redis with Python, r = redis.Redis(host='localhost', port=6379, db=0); r.set('key', 'value'), are the values necessarily strings?
or can you also use Python objects without the need to serialize? r.set('key', {'a dict': 'foo'}); d = r.get('key') # returns a Python dict!
Just try it. :P
@MisterMiyagi I don't have redis installed, and on windows it's not as easy as apt install redis, but you're right, i should try :)
09:38
Ah, found it...
> redis-py 3.0 only accepts user data as bytes, strings or numbers (ints, longs and floats). Attempting to specify a key or a value as any other type will raise a DataError exception.
Thanks!
09:55
It can also be really interesting to see how people solved problems you also had while building your own implementation
Is there an equivalent of atexit when an asyncio loop shuts down? My Fried Google only gives hits for running asyncio tasks when atexit runs, but not anything for cleanup of asyncio runs.
10:12
Ugh Microsoft and Outlook in general are so .... I have an issue and now I'm trying to contact support to fix the issue, but getting help in itself turns out to be an issue. And both issues claim that certain buttons are in certain places to do X or get help, but they are not, now I have 3 issues... **** Microsoft
@MisterMiyagi I don't think so, although you might be able to abuse shutdown_asyncgens() to achieve it
async def cleanup():
    try:
        yield
    except:
        print('exit')

async def main():
    async for _ in cleanup(): break
    ...  # do whatever
Something like that
10:29
Is it scary that this seems like a sensible thing to do?
Woah it took me 1hour to sync my work account with my phone...
@MisterMiyagi Like I said... we're still in the stone age
We make do with what we have ¯\_(ツ)_/¯
I'm close to asking on SO main about it, so I'm definitely desperate.
since I hang out in room6 SO shrunk to 70% room6, 20% hnq and 10% SO
I wonder how big other rooms are and how many active users which rooms have. I'm sure one could make a cool looking graphic about these things across SE
10:56
@MisterMiyagi you want to run an asyncio loop after it exit (like when you do atexit) or something else? if it's the former, this could work
With the built-in socket, how to receive just a message? should we care manually about END-OF-MESSAGE, send the length etc.?
@NordineLotfi No, I want to cleanup code when an asyncio loop exits. Just like atexit runs cleanup when the interpreter exits.
ah, gotcha
I only used asyncio recently but never tried to use it with atexit hmm
@Basj A TCP socket just provides streams, it has no concept of messages. You have to roll out your own protocol on top. Common approaches are to add separators or to prefix "messages" with their length.
@MisterMiyagi Would you have an example?
@Hakaishin Yes I just read this one a few minutes ago, but here MSGLEN is a constant, and it doesn't seem to handle messages of variable length
Basically you are gonna have to have two things in sockets, fixed sized messages, which tell the receiver how many bytes you are gonna get and then the next message can be variable(the length you just told the client in the previous message how long it's gonna be) length. Then fixed sized again and so on
This bothered me at the beginning, but you really do have to have a fixed sized message as part of the protocol, be it only to tell how long the next variable msg is gonna be
then on the listener you have a loop which either waits fixed sized bytes or the previously received variable amount of bytes. If you receive less or more something is wrong and you abort and go back to the last safe point
Exactly. You want to send the message length in a well-defined format, like "little endian unsigned 32 bit integer", then the actual message.
You can use struct to cram huge numbers into a tiny "header" message.
@MisterMiyagi is that what you had in mind?
Has someone mentioned websockets yet?
11:07
@MisterMiyagi Hmmm ok, so I really need to reinvent the wheel :) Is there a ready to use higher-level messaging in built-in Python? Without third party tool?
There's xmlrpc, but I'm not sure if I can recommend it
Not that I know of. If it's just about messages, that one is easy enough to build yourself.
What's missing from sockets+protocol really are the convenience things like recovery, persistency and load balancing.
Just sending messages is a loop of a few lines of code.
Yes I'd like to avoid to do the low level protocol for message length etc.
@Aran-Fey That's your responsibility, I think. :P
@NordineLotfi No, I need to destroy some non-coroutine resources. Practically, destroy some caches queues.
Those are bound to the event loop, so they break when the event loop is gone.
multiprocessing.connection seems like a higher level messaging system, is that ok?
from multiprocessing.connection import Listener
listener = Listener(('localhost', 6000), authkey=b'secret password')
while True:
    conn = listener.accept()
    while True:
        msg = conn.recv()
        print(msg, listener.last_accepted)
11:12
It is simple enough to recreate them, but the tricky part is to remove them at an appropriate time.
What do you think about this ^ + a thread for each new client (to avoid blocking)
@Aran-Fey I botched that, it doesn't work
Looks good. Just check that it's part of the documented API and things should be fine.
I can successfully run some synchronous code when the loop shuts down, but I can't await anything
That would actually be fine in my case.
11:21
Actually, you can successfully await some things, like asyncio.sleep(0)
@ChrisP I don't use Qt, but doesn't it have something suitable in its standard widgets? I guess it's nice to customize the appearance of your GUI; OTOH, it's easier for users to understand your GUI if it sticks to the existing standards. Does your image have to be a PNG? Or can you use a SVG, eg
Turns out I was overcomplicating it. This is all you need.
That one waits for the cancellation to wake it up?
Yeah, is there something wrong with that?
No, just wanted to understand it.
Hm, come to think of it, it's probably not that difficult to install the cleanup hook either. Since one has to manually register the cleanup functions anyway, that would be a good point to add the hook to the event loop.
Right... now all I need is a punny name...
11:48
@Basj Fair enough, although it's pretty easy. Here's an example in one of my old answers, although it's not as streamlined as it could be because it's designed to work on Python 2 & 3. stackoverflow.com/a/51332745/4014959
12:11
@MisterMiyagi is a weakref to the cache an option in this case? (I have little to no experience using async, so I don't know if it's even possible)
Looks like I didn't search thoroughly enough: asyncio-atexit is a thing.
@hugovdberg Hm, a weakref to the cache wouldn't work. A weakref to the loop would, at least on CPython.
shakes fist at the maniac enforcing PyPy tests
@MisterMiyagi you mean the mirror?
Indeed. MirrorMiyagi, my nemesis!
12:40
How to find rotation of a image compared to template using SIFT? Also how to find rotation of a particular feature in image compared to the same template feature? Draw keypoints is suppose to show rotation but image I am working with is too low res to actually see the rotation and some hard numbers which can be compared will be helpful.
12:56
@user541396 I don't feel like diving too deep right now, but in general this lecture series might be quite useful for you: files.ifi.uzh.ch/rpg/teaching/2016/06_feature_detection_2.pdf Part 2 which I linked here is specifically about sift
 
1 hour later…
14:24
Hello, I have a column with "Names" like PAULCHRIST, all have the same last name CHRIST, but the first names change. I want to split the text in "Names" and put it in two columns "firstname" and "lastname".. I tried df[['first', 'last']] = df['name'].str.split(' ', 5, expand=True) but it doesnt work.. can someone help?
if the last name is just CHRIST, then you can just put that as the last name... is the last name for everyone really CHRIST?
Is the name really like PAULCHRIST, i.e. without any separator to the last name?
@ParitoshSingh good idea, true and works. thanks
I have another similar question:
I have a bill they paid in "bill", such as 0.0148USD. Now I want to split the "bill" column in two columns "amount" and "currency". It's always USD. How can I do this?
look at your last question. then look at your current question. do you see something similar happening?
(also, i am kind of...surprised that everyone has the last name christ. i did not expect that, and i am a bit worried....)
I know it's the same structure, I just don't understand the syntax to split the numbers from text and put it into two different columns in the same DF
14:34
the point is, you can't split from the start, because the part that's fixed is at the end. this isn't a syntax issue so much so as a logical one.
@Baobab the combination of simplicity of the question and the fact that this seems to be building a rudimentary payment system seems worrying
It's like a doctor asking, how again do I do a colonoscopy? :D
Together with everybody being named CHRIST, I smell Ponzi scheme :D @Baobab don't worry I'm just joking
so what i'd suggest is just using slicing, since you know the lengths of things from the end.
sorry guys I'm just a noob in python, I google everything 3 times before asking here, but it's just hard to understand for me
Just to be sure: Are you sure that "the end is always the same" constraint you can rely on, or is it merely for a test data set?
14:39
@PM2Ring Would you have an idea about the speed of this built-in socket? stackoverflow.com/questions/71410848/…
I find it strange it's so slow
@MisterMiyagi for this dataset it's really always the same.
But it would be great to have a more general rule in case this changes one day, for example in EURO
@Basj sopython.com/chatroom Please don't post questions here in the first 48 hours
Oh sure no problem
(I was just curious because we spoke about that earlier, but no problem)
@Baobab Well, it's hard to say for the Names in general since the format you have shown has no separator between the parts of the names.
15:07
@Basj I have no experience with Multiprocessing, so I'll let MisterMiyagi handle it. (But what he says about the timing makes sense to me).
@Hakaishin It's borderline, since it relates to earlier discussion from before the question was created. OTOH, to prevent parallel discussion, anything that needs saying should be said on the question page, not here in chat.
Is there a good dupe for someone doing await asyncio.create_task(...) in a loop and wondering why tasks run one after the other?
16:09
@MisterMiyagi maybe related
@Basj when using multiprocessing, you'll probably have different result depending on your OS, just fyi
also consider trying the threading module too and see if there any speed difference, I believe there might be some :)
also, the way you benchmark this (eg: using time.time) wouldn't be enough if you want to know how fast it send/receive, so consider trying something like that
 
7 hours later…
22:52
Cbg
Hmmmm would it be better to have if foo.x == 'b' and foo.y > 2 and foo.z in z: and later elif foo.x == 'c' nd foo.y > 2 and foo.z in z: or to have a basic if at the beginning like
if foo.x == 'b':
    if foo.y > 2 and foo.z in z:
        ....
        ....

elif foo.x == 'c':
    if foo.y > 2 and foo.z in z:
        ....
        ....
Or is there some other better way to write this code
Hi, I have written a python module called mis.py. This module has a function called connect(string). In my main code (main.py), I call mis.connect(string). If I invoke main.py by using python.exe main.py every works fine. However, if I directly cally the main bytecode using python.exe main.pyc then I get an AttributeError: module 'mis' has no attribute 'connect'? Any idea?
@DelriusEuphoria no point in adding an additional level of nesting if there's nothing inside the outer conditional block that isn't inside the inner one as well.
If you're worried about readability you can consider defining those conditions ahead of time: needs_frobnication = foo.x == 'b' and foo.y > 2 and foo.z in z; if needs_frobnication: ...
Ah that makes sense
I asked because I get this weird feeling that there is a better way to write this because second part of the conditions are same for both
@Anthony Why are you even executing a .pyc file?
But I guess it is better to not introduce nesting when there is no need of it at all
@Aran-Fey Exactly my thought
23:03
@DelriusEuphoria I didn't notice that. So you can reverse the order of the ifs
if foo.y > 2 and foo.z in z:
    if foo.x == 'b':
        ...
    elif foo.x == 'c':
        ...
Oh, thats neat
@Aran-Fey my crystal ball says "obfuscation for the user/client"
Thanks Aran :)
Took the words out of my mouth
23:06
I also wondered why Anthony was executing a pyc file so perhaps we're each other's long lost twins
A happy family reunion indeed
We also both breathe air to survive. The resemblance is uncanny
The reason is I don't want to keep the script on the machine where I install the code
Is it not possible to use a decompiler and get back the py file?
it always is
Python is very deeply rooted in open-source, and "distribute my code in a way that users can't reverse engineer the original python code (or equivalent)" is a very tough cookie
23:16
I agree with the decompiler comment, but for now the policy is to leave bytecode and I don't know how to get around the AttributeError. Thanks in advance
I Gotta run to a meeting,.. will read comments afterward. thanks
I can't repro the problem
23:45
Use py2exe, or just give up.

People who care enough are going to steal your source either way
Spend more time making good software
and selling it as a web service :P
you can do all kinds of ridiculous hoopy froopy to try and hide your source but Andras is 100% on the money
unless, and not necessarily even then, it's behind a network or other type of transfer, someone is going to get access to your source
see: twitch
My experience: if you have to hide things for hilarious reasons, just use py2exe or similar
can someone still get your source? 100%
heck someone can just decompile your ELF binary or whatever
(there are actually several tools that will cheerfully turn .NET or or Java executables into code. Sure you'll be missing comments and maybe useful variable names, but...)
@AndrasDeak--СлаваУкраїні does that still work? Last time I tried I think it had been removed or something
Never actually tried it myself. No idea.
23:55
@Aran_fey, thanks for trying.

« first day (4162 days earlier)      last day (1008 days later) »