« first day (3353 days earlier)      last day (1819 days later) » 

00:12
Quite interesting! I very rarely use "salad language" here
unless it is also unicode laden and full of emojis
00:23
It is neither of those
It is also optional
 
2 hours later…
02:47
Hey guys...new here. Thanks for being supportive - are learner questions welcome here? Maybe a dumb question..
Yes!
but please don't binge ask these questions. I also used to be a learner even though I had approximately 1700 XP
before becoming less active for around 6mo
 
4 hours later…
06:46
Hi Guys Anyone can help me how to scrape data using Python selenium "driver.find_element_by_link_text"
I an trying to extract data from booking.com
 
2 hours later…
08:39
@wim I facing some issues on vscode after upgrading to it.
08:52
@Code-Apprentice using yield in an async def function creates an asynchronous generator function, just like using yield in a def function creates a generator function.
asynchronous generator functions create asynchronous generators, which have anext, asend and athrow instead of the regular generator methods.
these methods create awaitables. so gen.send(foo) becomes await agen.asend(foo).
@Code-Apprentice unless you write your own event loop, async coroutines work just like regular coroutines. You only to call the a<something> method instead of <something> and await the result.
otherwise, you need to do the await manually -- i.e. use agen.asend(input).__await__.send(signal). The regular event loop ceremony (exhaust the __await__ instead of sending once) applies.
my bad, that's just agen.asend(input).send(signal).
@wim a=[];a.append(a) for thing = a
a={};a[1]=a;thing=a
10:12
@MisterMiyagi You know an awful lot about async and I know from past discussions that you work with pretty big data sources. I'm curious if you have a cool example of what you're using this for? A lot of data processing would typically go through numpy or pandas, for example, where I'm not sure you'd have any choice about asynchronous functions
 
2 hours later…
 
1 hour later…
13:22
Which is the best close target? Yet another asking from a new user wondering why f = open(<relative path to file>) gives Errno 2: No such file in directory. There are already 6778(!) questions matching Errno 2: No such file in directory relative path ...
...Ideally answers should mention "...might not be the directory the Python script is in or that you think you're in, if you're using an IDE"
None. It's a debugging question with not enough info
I could make it even more complicated by trying to run it from a Flask app; you'd have no way of knowing that I did that if I just posted that line of code, but it will change the relative paths.
14:01
@roganjosh ? It's simply a relative path error and user is presumably not running in the directory they expect they are. I wouldn't call print(f'current directory is: {os.getcwd()}')debugging. Do we really need 6779 junky variants on the same thing... seems unnecessary.
We don't need junky variants, but you're not gonna be able to stop those questions coming in. The question should just be closed
@roganjosh Uhuh. You're suggesting closed-as-debugging-help, not as duplicate?
That's my suggestion, yeah. I think it's more effort than it's worth to hunt down a dupe
Hi. Is there any way to optimize this: for p1 in profile1:
for p2 in profile2:
if set(p1) & set(p2): ?
@MisterMiyagi that's what I was trying to do but couldn't in a single expression. Not even asspressions.
@MikaelKen please see our code formatting guide for chat and practice in the sandbox if necessary
what are your p1, p2 objects like?
@AndrasDeak (lambda a:a.__setitem__(1,a)or a)({}) works as an expression, if that's the constraint
they are lists of lists and im trying to find common elements in all those
like [[a, b], [c,d]] and [[d, f], [a, f] so it will show me a and d
@MikaelKen what do you mean by "optimise"? algorithmically or raw performance?
14:59
@MisterMiyagi that was my impression, but it's not very exact
performance
@MikaelKen the only style improvement I can think of is for p1,p2 in itertools.product(profile1, profile2): to get rid of a level of indentation
@roganjosh I'm not doing any major data analysis these days, but it wasn't ever numpy/pandas to begin with. I'm doing Grid computing for the LHC crowd -- async is really nice for highly concurrent middleware that runs the actual analyses of our end users.
@Jarrod welcome. To know what's alright and what isn't here, please see our local room rules :)
@MisterMiyagi neat!
@MikaelKen consider converting your lists to sets beforehand. You currently have some n^2 set creations when n would be enough.
@roganjosh We're also using async for simulating our infrastructure now. This is double-neat because we can run the core components of the real middleware in the simulation.
15:14
Very interesting. I assume it's working like a broker and passing off CPU-heavy work to other processes and aggregating results?
Kinda. We're working on overlay batch systems, which means we have a broker that deploys brokers on top of other brokers. It makes sense in the context.
I'm just kinda curious about whether I'm missing a trick because I've never been compelled to use async.... but that can easily just come from not knowing its advantages :)
The major appeal is that it is a) highly scalable and b) easier to debug than threads. You really want the latter if most of your work force has no formal programming training.
That makes a lot of sense. Thanks :)
 
2 hours later…
17:09
@TheNamesAlc One of my good friends just watched is, and it's not good at all. I now know the "plot twist" and it makes no sense. Just forewarning you :)
wim
wim
17:22
@MisterMiyagi good idea, but you have to do it in an expression!
cbg
trying to dockerise a flask app (in one docker) and have a celery task executor (in another) in docker-compose. Flask takes a file upload and sends file location to celery.
Cannot share files between flask and celery. Am I doing something wrong?
wim
wim
17:43
@Aran-Fey could shave it down to 38 type('',(),{'__repr__':'0'.__str__})()
not sure if the "build your own type" idea will be able to get any smaller
My solution is 30 chars btw. But I'm not sure if it's optimal!
I'm making my first web scraping project in Python and I need to collect 300+ pages of data. They are all sorted in the same way "https://example.com/?page=0" I need this zero to rise first to 1, then 2, then 3. Can anyone direct me what to look for on Google?
18:03
@wim (lambda a:a.append(a)or a)([]) is the shortest I could come up with at 30 chars
@Pijes looks like regular "string formatting"/"format strings" should suffice
@MisterMiyagi Thank you
you will want to do this in a for loop that covers the range you desire
@Pijes Just use an f-string in a for loop, eg:
base = "https://example.com/"
for page in range(300):
    url = f"{base}?page={page}"
@PM2Ring Thank you. I will try this
@wim (id:=bool(id)^1) at 16 chars, plus the desire to hit myself.
18:45
@PM2Ring Thank you again. Awesome solution
Sounds like you should be looking at extracting elements that either will give you the number of pages so you can loop or elements that contain an href to the following page though @Pijes :)
19:38
Updated my day 18 part 2, I think I have now rid myself of manual solutions
 
2 hours later…
wim
wim
21:14
@MisterMiyagi mine was view spoiler
@MisterMiyagi wow! how does that even work?
I thought there might be an improvement using walrus, but couldn't figure one out
16 chars is short .. I wonder how small the lower bound has to be before brute-forcing the rest of the space becomes feasible
@wim It uses := to create an expression with non-constant value, exploiting that builtins do not need defining. The first time, bool(id)^1 is bool(<function>)^1 == True ^ 1 == 1 ^ 1 == 0. The asspression then shadows id. The next time, bool(id)^1 is bool(0)^1 == 0 ^ 1 == 1.
can you flip bools with ~?
21:29
no :/
only numpy bools :P
they behave like 0 and 1.
>>> ~True
-2

>>> ~np.bool_(True)
False
and 1- is as long as ^1
wim
wim
@MisterMiyagi very clever, well done
(a:=[]).append(a)or a brings mine down to 21 ...
21:45
ah, that's it
But is this to be assigned to the name thing? I can't see how to use Miyagi's id like that
wim
wim
no
miyagi's works
Can you show me complete with the test?
wim
wim
it's like find a sequence of source code XXXXX such that eval(repr(XXXXX)) == XXXXX returns False
wim
wim
I don't know a better way to explain it, we seem to be lacking a noun for "sequence of characters"
wim
wim
doesn't work
I already tried it
wim
wim
del nan and try again?
ah...I thought that repl was clean, sorry
in any case I was going to walrus this one
(nan:=float("nan")) 19 chars :/
21:52
yup, just tried it
wim
wim
hmm yep
that's what I was going to try when I realized that I don't understand the name binding part
wim
wim
maybe there is a shorter way to make nan than float("nan")
if only 0/0 worked :P
wim
wim
>>> float('inf')*1j.real
nan
^ hmm, that's weird
oh
21:55
no, complex inf is complex nan
wim
wim
it's inf * 0 isn't it
oh, that one is
I might be thinking of something else
(nan:=1e999*0) is 14 chars \o/
hmm, I may have misread something a while back
>>> np.complex128(1+2j)/0
/usr/bin/ipython3:1: RuntimeWarning: divide by zero encountered in cdouble_scalars
  #! /bin/sh
(inf+infj)
I thought that was a nan + nanj
wim
wim
hoooo
>>> eval(repr(OSError())) == OSError()
False
22:01
eh
wim
wim
9 chars
Warning() too
too late for this one then:
>>> eval(repr(0));False#)) == 0));False#
False
wim
wim
hahahh
underhanded
I was trying to abuse this originally:
>>> str(KeyError(0))
'0'
but it doesn't work with repr
@AndrasDeak eval(repr(False))#)) == False))# :P
right!
that even works outside a REPL
wim
wim
22:09
I'm surprised how much crap is in sorted(list(Exception.__subclasses__()), key=lambda e: len(str(e))) within an IPython REPL
never peek under the duck tape
wim
wim
False))# <-- 8 chars
surely the rest can be brute forced...
94 letters + punctuation + digits. Some punctuation can be forgotten, but that's still a lot of options per character
Pro tip: use 0<0 instead of False to not waste precious bytes!
now we're talking
wim
wim
22:15
6 chars
that reminds me of the guy using tabs instead of spaces to reduce code size. Those were the times...
wim
wim
unbelievable .. I was thinking improving on 16 would be impossible
@wim well this is underhanded
22:31
Hahaha, the brute forcer wins
wim
wim
that doesn't work?
yeah, derp (deleted)
wim
wim
the other one doesn't either
oh poop, you're right
let me try to salvage it...
too bad, it would've been so nice
I don't think I can fix my brute forcer then :/
I guess I can special-case these false positives
by the way, there is an unhack'ier solution: eval(repr(id(-9))) == id(-9)
only works on CPython, though only works after previous builtin carnage
alright, eval(repr(id([]))) == id([]) works on PyPy :D
bless you, fuzzy garbage collection specification!
damn you, CPython speed hacks!
shakes fist
23:27
Hey guys! May I ask a question that I am not clear about the merge sort algorithm?
How many merges the algorithm would need to apply on a 9 length long list? Is it 9 since the algorithm has to break all the numbers in individual lists (to contain only one element) and then merge them all together, hence 9?
I don't know if my question is confusing, but what I mean is how many merges would the merge sort algorithm need to perform in order to fully sort a 9 in length list containing numbers? Would that be 8 (n - 1), or 9? I'm not quite sure...

« first day (3353 days earlier)      last day (1819 days later) »