« first day (3495 days earlier)      last day (1469 days later) » 

12:17 AM
why dosen't this work
for Titles in soup.select("a.tr-link-a>b"):
if crap or Dont_Need not in Titles.text:
print(Titles.text.strip())
the or mess's it up for some reason
 
FYI a superb reference List of ANSI color escape sequences, for when you want to colorize your terminal (e.g. with colorama or yellowbrick)
 
ok i see
what would I write to fix it though
 
Read the linked questions and their answers?
 
ok nevermind
nevermind again
the code didnt work
 
 
7 hours later…
7:27 AM
@MrPigbot unfortunately we can't help debug code we can't see
@MrPigbot we'll try to get your question deleted so you can get your rep back to chat here. We can try figuring out why "it didn't work" once that happens. You probably have another bug in your code.
I can already see two loops that do nothing except for the last iteration, which is definitely not what you intended
 
@G.Lakshmi kindly don't invite me directly to a room without any prior discussion. Your question (from a sock account) will get better traction on main SO.
 
@G.Lakshmi please don't ask for help here with your fresh questions here as per the room rules.
@wim do you know why your dupe meta got featured?
 
8:11 AM
@smci You want to query resource.RUSAGE_SELF. resource.RUSAGE_CHILDREN are child processes, which does not fit your problem description. Also, .ru_maxrss is the closest to "Memory".
>>> resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
7303168
>>> foo = {a: a for a in range(256)}
>>> resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
7319552
pympler reports size=17512 flat=9328 for the same object, of which size seems pretty accurate barring interpreter/OS details (interning, GC arenas, pages)
not sure how it handles extension types, but comparing it against ru_maxrss should give you a hint whether it's doing something significantly wrong.
 
8:36 AM
cbg
 
Sam
Hi all. Anyone know how to do a symmetric join in Pandas? I've made a little scratch of the problem which hopefully sheds light on what I'm trying to achieve: repl.it/repls/TurboJumpyBases
I could loop over each row and keep track of seen pairs, and at each point do comparisons to see if the set is already covered but wondering if theres a cleaner Pandas-y way
Not sure if the repl updates dynamically but I added my naive implementation of how I can do it: repl.it/repls/TurboJumpyBases
 
 
6 hours later…
2:47 PM
I'm trying to use matplotlib's imshow to plot a heatmap of a 512 by 512 grid of numbers. Is there a way I can force the bit of the image inside the axes have exactly that many pixels, so that no interpolation happens?
 
@OscarCunningham interpolation='none'?
I presume you've looked at the documentation already and it didn't work
 
That's good, but I'd still like it to be 512 by 512 pixels
 
Do you have an MCVE? It should be 512 by 512 pixels.
actually the default is already like that for me
dat = np.random.rand(20, 50)
fig,ax = plt.subplots()
plt.imshow(dat)
 
I think I mean something different for 'pixel'
I want the png image to be literally 512 by 512
Not made up of a 512 by 512 grid of monochromatic squares, each of which is several pixels big
Thanks for the help by the way
 
Yes, that's not what you asked
 
2:54 PM
 
@AndrasDeak omg.... if one ignores the dark coloured pixels... it almost looks like you might have exploded your display picture :)
 
@OscarCunningham I wouldn't try to use pyplot to create a bitmap, that's not the right tool. How about pillow?
 
@erotavlas Thanks, that looks useful
If it doesn't work then pillow looks good
 
unutbu's answer seems reasonable
 
But I actually wanted the axes that matplotlib gives
 
3:05 PM
I have a function taht checks if user is in a database if it is in the db the function returns a sorted dict with 1 key and 1 value
how can i check if the value is false ?
if x.values() == True:
        return True
doesnt work
 
return bool(x) perhaps
Or len(x) > 0 to be explicit?
 
You have a dict like {key: boolean}?
 
I have questions. But busy cooking...
 
@roblox why do you have a sorted dict for a single key:value pair?
 
Getting + discarding might be a waste
 
3:29 PM
@roblox what's the key?
 
wim
3:58 PM
@AndrasDeak no. do you?
 
nope, it wasn't a riddle
I'm not even sure how featuring is organized now...whether via a flag or some meta Q&A or something else.
 
wim
4:54 PM
neither am I. maybe mods vote on the ideas that they think are most important
 
I have a process function that I use to process the data uploaded on server , it fetches the location from database checks if it was processed using isProcessed and starts processing if the value there is 0. I am stuck on how do I keep doing this iteratively and keep getting new value of new location by moving on to the next row once isProcessed is set to 1 .
conn = sqlite3.connect(db)
cur = conn.cursor()
cur.execute("SELECT location FROM uploads WHERE isProcessed=0 order by datetime")
fetched_rows = cur.fetchone()
process(fetched_rows)
above is the function.
 
I'm not quite following your description. So your goal is to run the same query using isProcessed=1, isProcessed=2, ... instead of isProcessed=0?
 
hmm
have you seen the Rookout product?
a live Python tracer...
 
Or do you want to repeatedly run the same query, after the processed data has isProcessed set to 1 and new data with isProcessed=0 is added to the DB?
 
@MisterMiyagi no that will be a different UPDATE query to update the value
 
5:07 PM
was wondering how to effectively build such, they seem to have their own native extensions, but I'd rather see it in pure python,
 
@MisterMiyagi yes this is correct.
I have a table uploads and columns (id, status, isUploaded, isProcessed, location, datetime)
I take in a file then change isuploaded to true, then I select file location from location column and pass to process function after that i set isprocessed to 1, now I want to again go back and check which all other rows say isuploaded=0 so that I can take those locations and pass to the function.
 
Any one know what query syntax uses ~ for a like? Working on some old code and havent seen it before so not sure what reference to look for syntax on
 
i am using cur.fetchone() to fetch one value currently.
 
do you guys know how to run a command line command in jupyter notebook?

>> python -m something arg arg arg etc
 
Wow, got busy in here
 
5:10 PM
@erotavlas add ! before python
 
@AshwinPhadke I seem to be missing what the issue is. Do you know what for and while loops are?
 
ok thanks
 
@MisterMiyagi yeah I am confused as to do this for or while, I am currently considering while is it correct?
 
if you want to do the same thing again and again, that's what the while loop exists for.
 
@AshwinPhadke is there a way to redirect console output to the notebook? (I don't need it, but was just curious if possible)
@AshwinPhadke nevermind it did :)
 
5:14 PM
@erotavlas hehe no problem.
 
@AnttiHaapala Did you find anything on how their module works? If they're for 3.8+, I'd assume audit hooks.
 
2.7, 3.5+
I wanna do something like that too...
 
if they're using set_trace, that's actually pretty quick to set up
 
nope.
bytecode manipulation.
that's actually annoying. If python had a mechanism of doing bytecode manipulation of setting a breakpoint at a line...
bwah.
 
ugh. PyPy's RPython also works via bytecode inspection, and AFAIK it's why they are still stuck on 2.7.
 
5:23 PM
I have an event system where when you register a callback, you can specify which optional arguments should be passed to that callback. Should I require the user to explicitly specify which arguments the callback should receive, or should I auto-detect it with some inspect.signature magic? For comparison:
 
portable bytecode manipulation is a lot of work.
 
event = Event()

# explicit arguments:
event.connect(lambda y, x: print(x, y), args=['y', 'x'])
# automagically inferred arguments:
event.connect(lambda y, x: print(x, y))

event.emit(x=1, y=2)
 
what happens when event.emit(x=1, y=2, z=3) is called?
 
You actually need to specify which optional arguments the event supports when you instantiate it. So it would really be event = Event(args={'x', 'y'}). Passing unexpected arguments to emit is illegal and throws an exception
 
so all connected callbacks must be compatible?
or is event.connect(lambda y: print(y)) valid?
 
5:26 PM
But if z is a valid optional argument for that event, then the callbacks will be executed without any problems. The z simply won't be forwarded to them
that is valid, yes
 
Taking a third option: Callbacks should know which event they are called on and thus be compatible. If not all arguments are desired, *args or **kwargs should be used and discarded.
 
So, the traditional design (:
 
@MisterMiyagi ok figured it out, they actually do use the Google cloud debugging library...
 
Bonus answer: If you want to do any magic, I'd recommend doing all the magic and inspecting the signature.
 
I really want to stick to this system with optional arguments because 1) you don't have to remember the exact signature of all events (like the order of the arguments and such) and 2) it lets you conveniently access the event object, the callback object, and other things simply by passing args=['event', 'callback', etc]
 
5:31 PM
10 hours ago, by Andras Deak
https://stackoverflow.com/questions/61720922/or-statement-doesnt-work-in-if-statement ^
still needs a delvote ^
 
For example, if you want to run a callback only once, you could simply do connect(callback, args=['callback']) and then callback.disconnect() inside the callback function
@MisterMiyagi Alright. So I take it you're not aware of any compatibility issues with inspect.signature magic? Like not being support by PyPy or other implementations?
 
no, Signature inspection works great and is quite useful
in fact, I'd be happy if the ecosystem would use and support it more.
 
alrighty, thanks for the input
 
for reference, everything that uses type hints at runtime technically peeks into the signature
 
hmmm, I hadn't thought of that. Good point
 
5:36 PM
(though it's stored separately)
 
wim
@AndrasDeak why? it's gonna roomba
 
    self._cookie = native.SetConditionalBreakpoint(
        codeobj,
        line,
        condition,
        self._BreakpointEvent)
hehe
there it is.
 
@wim read previous message in chat
 
wim
@MisterMiyagi superfluous lambda spotted
 
OP's confused but the pile of downvotes blocked them from chat
 
wim
5:40 PM
oh, hah, ok
charitable deleting
 
Yup. Thanks.
 
actually there are 2: codeobj = module_explorer.GetCodeObjectAtLine(module, line)
 
@MrPigbot you've got your rep back, you can chat here now. The problem with your code is that it's almost certainly broken. It's not clear what you're trying to do: do you want to say "if the title is not in this file, nor in this file, do something"? Please explain what you want your code to do.
 
@wim in this case actually not, which urges me to give a -1 against magic.
 
6:10 PM
yeaaaahhh, passing print into inspect.signature throws an exception
 
6:32 PM
@Aran-Fey it seems builtins must explicitly provide a signature: s = getattr(func, "__text_signature__", None)
 
6:55 PM
if it goes through we'll need a reasonable broad tag wiki description for
 
irreproducible/"works for me" stackoverflow.com/questions/16931461/…
 
@AndrasDeak umm... tag only edits don't bump but yeah... be careful :p
 
Really? I thought they did!
 
@AndrasDeak Agreed, upvoted, see my comment there (the tag wiki really would need to succinctly distinguish between what is broadcasting vs what is merely vectorization)
 
7:12 PM
@AndrasDeak could be mis-remembering various bits about edits though... so don't sue me if I'm wrong :)
 
I used to remember us wanting tag-only edits not to bump. But it could have changed, and I could be misremembering :)
 
@Aran-Fey but "of course"
 
7:28 PM
@AndrasDeak: since it came up, can you take a stab at defining/ distinguishing between what is broadcasting vs what is merely vectorization, in a language/package-agnostic way (other than "across specific dimension(s) of an array"). Is vectorization merely the simple 1D case of broadcasting? What about when there is shape mismatch and there is vector recycling, like in R? R behavior can and does differ from numpy, R will cheerfully recycle in cases where numpy would throw an exception.
 
wim
I have this "slow-burn" answer that keeps collecting votes somehow and I'm totally confused about why stackoverflow.com/posts/40594754/… . The technique is extremely obscure (using lambda and yield in a list comprehension) and I have no idea how this continues to be useful for anyone.
 
Adding some external few on the -broadcast tag: I don't think the *exact semantics are important for the tag. The difference towards plain vectorisation (which seems to be mostly expanding/polymorphism) are.
 
@smci I don't have a clear-cut idea, especially not one that might be language-agnostic. But anyway to me broadcasting is about expanding the dimensions of arrays with different sizes. Vectorization is an operation on a larger chunk of data in one or more arrays. So to me you can have vectorization with two 1d arrays or adding two 2d arrays of the same shape.
 
wim
it never went HNQ, those votes came in gradually. and it's even a deprecated behavior now. bizarre.
 
@wim Ew. Comprehension + yield is really evil. The kind of evil that aspiring code golfers and 1337 programmers like.
 
wim
7:38 PM
eww is right. but perhaps there is some use case that I didn't know about - people are still finding the Q somehow.
 
there's a similar Q on yield from in comprehensions but it's not garnering as much votes (mostly just the Q).
perhaps munching three "advanced" features of lambda, yield and comprehensions makes yours extra tasty?
I'm under the impression that yield questions fall in a sweet spot of being obscure, useless and interesting. They're challenging enough to pique the interest of graduating noobs, yet answerable enough to attract advanced people.
 
HNQ fodder
 
8:11 PM
@piRSquared @user2357112supportsMonica in case either of you are around sometime and agree with renaming [numpy-broadcasting] to [array-broadcasting], please vote on the synonym. Thanks and sorry for the wild ping.
surprisingly few people have score in that tag, ugh
 
8:31 PM
Isn't that synonym going the wrong way?
@AndrasDeak: It seems like we would want to make numpy-broadcasting a synonym of array-broadcasting, which is the opposite of the current suggested synonym.
 
Yeah, that's what I'd want. Is that not what I'm doing?!
Crap, you're right! Thanks.
But then nobody can suggest a synonym for the other, new tag...guess I'll have to ask a mod after all :/
Do you otherwise agree with the change?
And I can't vote on my own synonym, so I can't downvote it.
@piRSquared please disregard the previous ping; sorry :P
 
8:50 PM
I agree with the synonym you were trying to propose.
 
Thanks :) I'll flag for a mod then, pointing to the meta
 
9:12 PM
I can cancel the syn. then you can try again? :p
it's a bit late in the day for me to look at things properly (quite, quite tired) - so I've cancelled the syn. proposal and if you remind me in the morning - I'll look at it if that's okay
anyway - rbrb for now
 
@AndrasDeak I think ping etiquette is appropriate in general but I trust that you'd not use pings inappropriately. That was a perfectly reasonable use of a ping. Let me know when the synonym is set up the correct way and I'll vote.
cbg room6. working from home on fewer monitors means my python chat window gets demoted to the background )-:
 
9:39 PM
@JonClements thanks for the cancel! I won't be able to suggest the reverse because nobody has enough score in the new tag and I don't want to retag too many things to get around restrictions. That's why I flagged originally (the kind numpeople here could've cancel it on their own). We can get back to it later, thanks!
@piRSquared and thank you :) Due to ^ it will probably not be necessary; either a mod does it or nobody does. Hope things are well!
 
They are as good as I could expect. My family is healthy and we are staying sane (-: Hope things are staying manageable for you.
At this moment, I'm trying to find a place I can drive to to see the comet Atlas.
 
@piRSquared glad to hear that! Yeah, all's fine here :) Considering, of course.
 

« first day (3495 days earlier)      last day (1469 days later) »