« first day (4401 days earlier)      last day (769 days later) » 

05:02
Hi. Can someone help me out with Stable Diffusion? Or direct me to the chat room for that. Thanks
 
6 hours later…
11:20
Wait, Python 3.11 is officially released already?
yeah
since a week or so. curious how stealthily that goes by if no controversial feature is released
The changelog looks pretty tame indeed.
11:37
I haven't kept up with new releases... I should at least figure out how the match statement works
I only figured enough about match to know when I'm gonna need it, and the day hasn't come yet
Once I figure out what it does, I imagine I'll use it about as frequently as the walrus operator. Once a week or so.
12:15
I'm usually more excited about old pythons dying than new pythons being born. In 7 months 3.7 will be dead, which will unlock... let's see... uh... positional-only arguments, I guess
Exciting stuff
12:33
We're still on Python 3.6 here... :/
12:49
3.6 will be the new 2.7 for a while imo. We are also on 3.6. Probably switching to 3.11 next year
13:05
Hi can someone help me with python and selenium webscraping.
ask it's the only way to find out
So i am trying to scrape the prices of items form this webiste
website*
but each prince has a different xpath so i cannot traverse through it and store it in a list.
13:22
Then don't use xpaths. Find something that all prices have in common. Like a class="price", for example
using a class as the locator returns an empty string
empty list*
Well, then either selenium is doing something wrong or you're doing something wrong
Here is the webiste
website*
for i in range(1,55):
try :
productname=driver.find_element('xpath','//*[@id="lpBloc"]/li['+str(i)+']/a/div[2]/div/span').text
product_name.append(productname)
except:
print("none")

try :
productprice =driver.find_elements('class name','priceLine')
productprice= product_price.find_element('class name', 'price priceColor hideFromPro').text
product_price.append(productprice)
except:
print("none")

print(product_price)
I even tried nesting through parent to the siblings
I guess you can't pass multiple class names into find_element at once
13:39
@Aran-Fey I can only pass 2 classes at one in find_elements
find_elements() takes from 1 to 3 positional arguments
I doubt the 3rd argument is a class name though
The docs are not helpful, but most likely it only accepts 1 class name. If it accepts multiple, then most likely as a list
yeah it only accepts one class name
but I can nest or go to the child using this
productprice =driver.find_elements('class name','priceLine')
productprice= product_price.find_element('class name', 'price priceColor
i can store the xpath in a variable and then search for its following siblings with the same variable.
but that only returns me a single element
I don't understand what you mean, but I think you're shooting yourself in the foot by using xpaths. I would loop through all li children of the ul id="lpBloc".
In there you can find the product name with class="prdtTit" and the price with span class="price"
13:54
Yeah I will just use following and preceding siblings
something like this
for item in driver.find_elements('xpath','//*[@id="lpBloc"]//li[@data-sku]'):
productname=item.find_element('xpath','.//span[@class="prdtTit"]').text
product_name.append(productname)
productprice=item.find_element('xpath','.//span[@class="price priceColor hideFromPro"]').text
product_price.append(productprice)
and then append everything in
14:07
@Ayush.S hey, I know that website :) I think I could help with that, let's see
You may have an easier time experimenting with xpath if you do it directly from the browser console. document.evaluate("xpath string goes here", document);. I assume JavaScript's xpath syntax is identical to Selenium's xpath syntax.
This might save you some time e.g. not having to start up selenium and reload the page every time you want to try a new query
As for whether you're shooting yourself in the foot by using xpath to begin with... I think it can do what you want, but I also think you can also get what you want without using xpath, and perhaps with less frustration
Yesterday I had a very painful crash course in xpath. A field in my database stores XML, and I needed to extract data from that XML in order to put out the fire raging in the production server. Oracle has a couple approaches to reading XML, and xpath seemed like the least arcane, from the perspective of a developer with zero experience in any of the approaches
I think you would benefit from using bs4 too since it would give you more options for parsing/finding elements. As you probably already know, you can also use class="price priceColor hideFromPro" or go recursively from data-sku= where the id of the product sold is, down to what you want (eg: name of the product, etc)
It took a dozen prototypes and a dozen confusing pages of documentation, but the final result is relatively simple: select EXTRACTVALUE(XMLType.createXML(my_xml_field), '//info/widgets/widget[@name="blue deluxe"]/@numspokes') numspokes from transaction_history
Things that were not apparent at first: The existence of the methods createXML and EXTRACTVALUE; the meaning of "//" and "/" and "[]" and "@" within the xpath string; whether xpath understood quote marks; whether Oracle has sane string escaping syntax in case xpath required apostrophes for quotes; ...
Let's say each of these eight mysteries took twenty minutes to solve apiece
14:44
jesus, burn it
15:08
If I burn xpath to the ground, then I'll have to use Oracle's custom xpath-like language, which I'm sure is riddled with bugs and poor design decisions
scary to think that xpath is the saner option
Anonymous
15:42
Is there any way to merge @overload and @singledispatchmethod?
Don't think so
stackoverflow.com/questions/74284943 duplicate of stackoverflow.com/questions/74159912; the question asker is also a duplicate user of the accepted answer, which is plagiarized from an answer to another of their questions
Do we have any mods around nowadays? I normally wouldn't ping them, but I've been mod flagging duplicate users of that person for a month now and it's still happening.
16:05
Design question. I have a function rotate90(img, n=1) that rotates an image by n*90 degrees. Functionally, rotating 4 (or 8, or 12, etc) times is a no-op. But if I add a if n % 4 == 0: return img then the behavior is inconsistent, because it sometimes returns a copy of the image and sometimes not. Any recommendations how I should handle this?
I'm thinking of adding a force_copy=True parameter, but that kind of seems like overkill for such a simple function...
16:28
Why would the user care if it's a copy or not?
Most of the time in python I don't think about if what I do with objects gets me copies or not
If it's the underlying arrays, couldn't you just call .copy() in that case and then always assert that it returns a copy?
Assuming that every other rotation automatically returns a copy
I could, I'm just not sure if I should
I would too
Given that I think most sensible users would know that such rotations are a no-op I assume n = 4 situations come from a dynamic calculation in the code itself for them to even be calling the function, in which case I guess that adds to the chance of them being bitten by the variable behaviour
@Hakaishin That's kind of a tough question. But surely I have to assume that some users might care. And I think being inconsistent could easily lead to bugs that would be infuriating to track down
16:36
i'd vote consistency, if you return a copy, always return a copy. dont have the param
if someone really cares about performance for a no-op they'd add the logic as an optimization step themselves i'd argue. it should be their responsibility to not call something they dont need if it comes down to it
Just push the responsibility of writing if n % 4 == 0: on the user, huh. I guess that's acceptable
Statistically, being inconsistent has a much higher chance of leading to me being murdered by an angry user than being slow (because of copying), so that's a plus
...and by "plus" I mean it's an argument for copying. I'm not suicidal, I swear
 
1 hour later…
17:47
hey all, can anyone suggest anything for my question stackoverflow.com/questions/74281067/…
it was posted almost 2 days back, maybe a couple hours more, but I doubt it would get answered
also open to suggestions related to how I can make it "more MCVE" ? I am assuming setting up a postgres DB to test this is bit of a stretch?
18:05
SQLite is a reasonably ok proxy for postgres depending on the case. It also packs its own weirdness at times, though, so it's not always appropriate
I would have used SQLite, but I do not think it supports JSON columns, and my question is related to a JSON query
i mean, json is just a string, so you could always store it as a blob
That's a good point :(
@ParitoshSingh I think postgres allows you to query it as JSON?
i see, that sounds handy. yeah sqlite has no understanding of json itself
postgres lets you do json querying, yes
if you are asking why am I storing a json in a db, I do not have an answer
18:22
postgres json querying is supremely helpful
the fact that someone uses that makes me feel better for making a terrible choice
I just hoped sqlalchemy magic would make it easy, turns out, it does not work well with nested models
If anything, I suspect it would make it much harder because I don't think it generalises across RDBMS, so I'm not sure how much support is even baked in. It's not something I've dabbled in, though
Unfortunate typo. Freud would have had a field day with that one
from knowing that it exists 2 days back, I can say it supports most of what you would expect, likes of searching, slicing
oh we have a database schema that needs to be ultra-flexible by design. So this was the sanest way I could think of how to do this
a guy at my workplace was pushing for mongodb, its good for json data is his claim
18:34
That's kinda what it was designed for (kinda)
we just ended up with postgres as we did not want to move our models from sqlmodel (we recently moved from sqlalchemy models to sqlmodel)
If you're using postgres solely for JSON then I also question that design choice. I think support was basically added so you could have JSON in one field of, like, 50, not have it as the primary design
he's not wrong. But if you have other relational fields, you might wanna reconsider the tech choice. I'm not a mongo expert by any stretch of anyone's imagination, so I'm curious on the outcome here
I don't know whether postgres can add a primary key to anything in the JSON body. Mongo would allow something similar to that, at least by adding indices into unstructured documents
But I'm also not a Mongo expert
it is just a single column, we have 10 such tables, I am partially skeptical about mongo, it has a great presence in the MERN stack community, a lot of tutorials promote that (at least it did when I was in college), so it is kinda shoehorned in places where it should not be
I am not sure how much truth that is for the others here though
18:59
@NordineLotfi sure thank would be great
thanks'
 
2 hours later…
21:19
*puts on a black hat* Today I'm wondering what happens when you send HTTP requests with incorrect Content-Length values. Testing this with httpbin simply hangs without ever producing a response. Could you overload a server by sending a bunch of nonsensical requests like this?
(Code, for my fellow black hat wearers: requests.post('http://httpbin.org/post', headers={'Content-Length': '99'}))
I'm now also wondering how many web devs are benignly looking over, smiling at the little script kiddie's curious antics
 
1 hour later…
22:29
@Aran-Fey probably. I reversed an payload body limit on an internal server. But it sounds like a perfectly good attack vector
It doesn't work for my purposes to limit the payload size but, if the endpoint was exposed, you'd screw me

« first day (4401 days earlier)      last day (769 days later) »