« first day (3133 days earlier)      last day (1822 days later) » 

wim
7:00 PM
@piRSquared I have a hack for you
In hindsight, I want callable tuples.
(f, g, h)(x) == f(g(h(x)))
 
I like that!
 
At least rename that * to @ in order to signal that it's non-commutative
 
wim
hmm, that would only be a signal to a very niche group of people.
 
(-:
 
7:04 PM
TIL - YARYOLD - Yet Another Roll Your Own Linux Distribution
 
How 'bout YAYAA
Yet another "Yet another" acronym
 
ah, boo, namedtuple field names cannot start with an underscore
 
wim
wat
I swear namedtuple gets weirder every time you look at it
 
was trying to add __call__ to a namedtuple. Of course, then I realized you were talking about regular tuples
 
wim
yeah, you can't really do it without modifying CPython or terrible hacks
 
7:13 PM
why it is always so hard to stop arguing with someone who's stubbornly wrong about something.
6
 
@wim I like that.
@AnttiHaapala Because they're WRONG!
 
There's also a tremendous amount of satisfaction teaching someone not to be the worst
 
^ What Wayne said, but he is more benevolent than I ;)
 
@AnttiHaapala obligatory
 
@piRSquared I did stop, but it feels unpleasant.
especially since this happened in comments, someone who reads that afterwards might understand that I gave up because I was wrong.
 
7:23 PM
It's in the hands of karma now
 
I remember arguing with someone in comments. I realized my folly and deleted my comments. The other party then accused me of deleting my comments for the purpose of making them look bad and crazy arguing with themselves.
 
@AnttiHaapala You can always say "I can see this discussion is going nowhere. I believe you are wrong, but I will leave it to more skilled communicators who may be better equipped to enlighten you."
 
@toonarmycaptain clearly you are a more skilled communicator than me :D
 
@AnttiHaapala Ah, BS, my one true skill.
 
"Enlighten you" I would read as particularly patronising, btw. I would leave it with "we disagree"
 
7:28 PM
@roganjosh That was intentional. It was an argument, right? ;)
 
Sure, but I thought it was one we were trying to leave? :)
 
Mic drop
 
@wim I like the resulting syntax of this better but I'm being bad with my use of globals. How might I improve this?
class Composable(object):
    def __init__(self, function):
        self.function = function
    def __call__(self, *args, **kwargs):
        return self.function(*args, **kwargs)
    def __getattr__(self, other):
        other = globals()[other]
        @Composable
        def composed(*args, **kwargs):
            return self.function(other(*args, **kwargs))
        return composed

@Composable
def f(x):
    return x ** 2

@Composable
def g(x):
    return x - 3

f.g(5)
# 4
 
@roganjosh Yeah, pyrrhic victory, but at least some satisfaction when leaving thusly, the epitome of a cordial exit that leaves the adversary really ticked off ;)
 
7:35 PM
And, unfortunately, there isn't a left getattr.
 
@toonarmycaptain all of the fancy words. That's not a good way to leave it; it shows you've had to turn to sophisticated language for a high ground. Better to leave with just " we disagree" IMO
 
@Aran-Fey but it looks pretty
 
@piRSquared ew no
 
But...
@Composable
def f(x): return x ** 2
def g(x): return x - 3
def h(x): return x * 2
def i(x): return x + 5

f.g.h.i(3)
# 169
 
7:43 PM
I also meant "irrespective" instead of "irregardless" earlier. I fear I won't be able to sleep unless I correct that :)
 
(I think you meant regardless)
 
regex can handle it... re.gardless
 
cbg
 
cbg @alkasm
 
Just because you never sleep, it doesn't mean you get to inflict sleeplessness on others
 
7:46 PM
Is it possible to do "pre-install hooks" with pip?
 
@alkasm hm?
 
wondering if i can have a command run before the normal setup flow
 
wouldn't putting stuff high up in setup.py do that?
or something something wheels?
 
something something perhaps
 
wim
@AndrasDeak if you are happy to distribute sdist only, yes
I don't know any way to do it with bdist, and wouldn't be surprised if it were not actually possible
since the whole point of bdist is to not execute code at install time
 
7:59 PM
I was hoping to have some auto-generated code install when a package is installed, but it would need to be generated at install time, which is kinda dumb now that I think about it
 
wim
you might consider rpm or something
 
better would be to have the stuff the code is generated from trigger new code generation and update the package accordingly
whats rpm?
 
wim
it's a bit more full-featured packaging than bdist_wheel, but it means users would install with yum not with pip
 
yea pass, trying to just make this as easy as possible for a user
 
8:05 PM
We also use a diff package manager..
cool that setup.py supports that though
 
callable tuples
from functools import reduce as r

class C(tuple):
    @staticmethod
    def c(f, g): return lambda *a, **k: f(g(*a, **k))
    def __call__(self, *a, **k): return r(c, self)(*a, **k)

def f(x): return x ** 2
def g(x): return x - 3
def h(x): return x * 2
def i(x): return x + 5

C((f, g, h, i))(2)
# 121
 
Is it safe to subclass tuple? That should be simple enough to (heh) compose.
 
It saves me from performing the reduce myself. Usefulness is questionable.
 
why was i just shown an offensive/spam flag to review?
 
r(c, (f, g, h, i))(2)
 
8:15 PM
In the chat I mean
 
wim
high rep problems.
I forget what the cut-off is but maybe you just passed it recently
just mark them all invalid in the hopes of SO dev removing this stupid "feature"
 
Ok, I'm done with composition. __getattr__ was my favorite until @Aran-Fey had to shout me down (-: After that, I'm happy @wim's hack
 
@wim lol
 
wim
absolutely don't use attribute access for this. since functions have a __dict__, you would be obliged to handle namespace collisions in the function __dict__.
why should function objects really carry around a dict everywhere is left as an exercise for the reader.
 
@wim 10k
 
wim
8:23 PM
checks out
 
@piRSquared I meant having your class have a self._tup which you pass as r(c, self._tup)
 
wim
@AndrasDeak namedtuple is a generates tuple subclass
 
And doesn't it have all sorts of issues?
 
wim
yes
 
or are those unrelated to the tupleness perhaps
 
wim
8:26 PM
I don't know.
I guess they are more related to the code-gen and weird API than the subclassing itself
the actually generated subclass is ok?
 
8:38 PM
@piRSquared all I have to do is create a new account and find a good enough reason to have a CW merge this one to that :p
 
@cs95 I'm sure the reason "To needle @piRSquared" will be sufficient.
What is the term to refer to an operator's order of operations priority?
 
precedence
 
any way to get f*g(3) to evaluate f*g prior to passing 3? I don't like (f * g)(3)
 
Ok, so using __getattr__ has been deemed bad. What about __getitem__? f[g](3)
 
8:48 PM
What's wrong with f(g(3))?
 
f(g(h(i(3))) is why. As opposed to f[g][h][i](3)
my eyes like the latter
 
Mine don't. Like, if you were trying to make functions support all operators like f + g and f << g and f | g then I'd kind of understand... but I really don't see much point in implementing a function composition operator
 
9:07 PM
That's fair. I'm not convinced myself
 
@piRSquared why not just curry the functions? f(g)(h)(i)(3)
See also: Beazley's recent pycon talk on the lambda calculus. Link directly to where he mentions currying: youtu.be/5C6sv7-eTKg?t=1017
 
9:35 PM
alternatively, you can create a function for composition like that ^, e.g.
import functools

def compose(*funcs):
    def compose2(f, g):
        def h(x):
            return f(g(x))
        return h
    return functools.reduce(compose2, funcs)

a = lambda x: x + 1
b = lambda x: x * 2
c = lambda x: x + 5

for i in range(-10, 10):
    assert compose(a, b, c)(i) == a(b(c(i)))
 
wim
WTH? I didn't even see beazley at pycon
I wish I knew he had a tutorial
he didn't do any tech talks afaik
 
yea you missed out, it's a fun tutorial
(i wasnt there, but the video is gr8 of course)
 
wim
dang
 
Beazley's 3 hour tutorials might be my favorite thing in the python community.
 
wim
did he talk about exploding heads? 🤯
 
9:42 PM
Currying would be "fine" but not sure how to coerce non curried functions into curried ones that is less complicated than what we've done. AND, I want that same function to work as it normally should and in a composed way.
 
wim
to get it as nice as you want it needs language changes
(f*g)(3) is as good as it gets I'm afraid
 
(which coincidentally is a pretty nice way to do it anyways)
 
@alkasm also, I've got a notebook set up with those same functional type functions because I think it makes for a cool talk. Still watching
 
wim
go to erlang or haskell or something
 
No, its good enough in Python to expand peoples minds. Think about things differently. Reminds me of my Number Theory Professor asking the class "What is the number '2'?"
 
9:47 PM
thats a string
 
wim
hah
it's the successor of 1.
 
the predecessor of 3.
 
it's the 2
 
the only even prime.
 
the easiest approximation to pi/2
 
wim
9:49 PM
I was going for the peano defn
 
I know
 
yes, yes
 
I'd answer it now: "It is a function that awaits a unit for which to denote that unit one more time than it's predecessor would." Or something like that.
 
wim
academic navel gazing
 
2(dollars), 2(km), 2(C)
 
9:51 PM
what do math professors know about units? :P
I think this comes across as abrasive, but I honestly have no idea how to phrase it nicer. Any ideas?
No, yeah, this being featured is a must. If something like this happens over our heads the least one can do is keep us transparently informed. — Andras Deak 4 mins ago
Talking about the "least one could do" part.
I insist on the message but not on the style, I just can't phrase it more assertively
 
wim
not abrasive just kind of whiney
 
whiney is fine
 
i dont think abrasive is bad in this context anyways, but its not abrasive imo
also, WTH. thanks for linking that, not convinced this really fulfills a strong need...
 
Whether or not abrasive is good or bad is up for debate, but I didn't intend to be abrasive in that comment :)
thanks for the feedback, both
 
anyways the name isnt bad, but I can't wait till a user confuses "reprex" and "regex"
 
10:15 PM
3:14 pi time... time to go. rbrb
 
rhubarb pie
 
10:32 PM
strawberry rhubarb pie is one of my favs
 

« first day (3133 days earlier)      last day (1822 days later) »