« first day (2594 days earlier)      last day (2362 days later) » 
00:00 - 17:0017:00 - 00:00

5:01 PM
@AndrasDeak Nope. This is similar to that one the other day where the OP wanted to initialise a class attribute using a list comp. As soon as you're inside a new scope (eg inside a listcomp or decorator) you can't see the class attributes anymore.
 
new Morse guy got Larsoned
 
CbG all
 
@PM2Ring ah... thanks
 
cbg Area :D
 
(-:
 
5:02 PM
Oh sorry. I meant to say area-of-a-circle, too many mathematicians in this room, don't wanna step on some weird line
 
Did you just assume his shape? What if he's an r*sqrt(pi)-sided square?
 
@MooingRawr Could be a rectangle of sides r and pi*r :)
 
okie I yield, I give up, can't please mathematicians
 
Or a sphere of radius r/2
 
cbg Area it is then...
 
5:04 PM
Laurel....
 
next thing I know, people will tell me not to assume it's an Area formula as it could be: .... :D
 
no mathematicians here, only us standard nerds
 
and to that I will blame our education for hammering pi r ^2 to be an area of a circle :P
 
@user2357112 This is one of those situations where it'd be handy if Python had macros... OTOH, he should just write more Pythonically. :)
 
I want to distribute a machine learning library pyRSquared
 
5:07 PM
go write one :D
 
DSM
5:19 PM
Lunchtime cabbage for all.
 
cbg
 
cBG dsm
 
cbg
 
Umm... wonder if you could decorate the class (the equivalent of change_docstring = True) then use decorators to tag the methods, then update the doc strings of methods... but if you've got the ability to modify the class by introducing decorators on its methods anyway - not seeing much of a point...
 
MCVE? Cuz I'm lost (-:
 
5:28 PM
recbg
 
I'm not a fan of my last comment. To be clear, I am lost. I think I sorta know what you're getting at and I'm curious to know what you're getting at. But seems like an MCVE required for that would be more ... well idk. Apologies, babbling.
 
DSM
@PM2Ring: you're probably asleep, but when you get this, d'you read any French? The cellular automata conversation from earlier reminded me of something I was distantly involved in a few years back.
 
@DSM My French is a little rusty, but I did it for 5 years in high school.
@JonClements Or maybe some metaclass magic? I wrote a simple answer that just makes change_docstring a global, but the OP's gone quiet.
 
5:45 PM
def change_docstrings(cls):
    for k, v in vars(cls).items():
        if callable(v) and hasattr(v, '__add_to_docstring'):
            v.__doc__ += v.__add_to_docstring
            del v.__add_to_docstring
    return cls

def add_to_docstring(text):
    def func(f):
        f.__add_to_docstring = f.__doc__ + text
        return f
    return func

@change_docstrings
class Example:
    @add_to_docstring('(additional)')
    def example(self):
        """something here"""
Then you're isolating the scope out of a global and doing it during class construction and just tagging the methods
(I'm still not sure I see the point of any of it but... the above seems to work)
 
DSM
@PM2Ring: then if you get a chance, have a look at this, which talks about the surprisingly fun structure of a digit-based system dreamed up by a creative number-loving amateur of my acquaintance. The French isn't too bad (although some of the jargony words you might have to look up). I didn't try it myself but I figure google translate should do a decent job.
 
Also - doesn't have to worry about any signatures or bound/unbound methods as you're purely decorating a function object and you can decorate the class if you want the function decorators to be honoured...
 
So you wanted this?
Example.example.__doc__

'something heresomething here(additional)'
 
Although yeah - you could do a meta class - but since it's conditional - and I quite like class decorators for simpler things... seems to work for me...
@piRSquared we're talking about stackoverflow.com/questions/47439594/… here...
 
ty (-:
 
5:52 PM
Although it does seem I've just done a remake/variation of stackoverflow.com/questions/3885459/… ummm
 
@DSM I can (sort of) read that. But I'm familiar with Eric Angelini's Life digits, and there's a Python script that comes with Golly containing Eric's font that lets you easily make patterns using them.
There's a brief intro in English here: pentadecathlon.com/lifeNews/2007/03/life_digits.html
 
DSM
@PM2Ring: ah, then you know of Eric. The article describes something a little different from the original stuff there (this is his c. 2010 work vs. his c. 2007) work. I'm partial because I found some of the first "vaisseaux" in the 2010 variant. :-)
 
I'll definitely read the PDF you linked earlier. I remember being amused and surprised when I first encountered Eric's Life digits, but I haven't really played around with them very much.
 
6:26 PM
@PM2Ring well, I made a couple of changes and answered with what I came up with... I still really want to know why they're doing this though
 
@JonClements Looks good to me. But yeah, it's a bit of a mystery why they want to do this. But the OP said that in the real code he'll be doing more than merely changing the docstrings, so I guess the docstrings are mainly a way to be able to tell whether a method is in its original state or is wrapped, and his main concern is to be able to enable or disable all the method decorators in the class via a single class attribute. So hopefully he'll find our techniques an acceptable alternative.
 
Kind of nice in a weird way to write a class decorator - even if I don't get why :)
plus I got the word cabbage in - I should get bonus points :p
 
6:49 PM
Hi everyone! Just got 20 reputation :)
 
afternoon cabbage
 
cbg code :D
 
wim
dumb trick: using things as decorators that weren't intended to be decorators but can be decorators anyway
>>> @str
... def foo():
...     pass
...
>>> foo
'<function foo at 0x7fffe30f6400>'
>>> foo()
TypeError: 'str' object is not callable
brb I'm searching for a diabolical use case of this in the inspect module ...
 
Do I even want to know why?
 
wim
7:10 PM
oh I was answering some stupid question about the Python decorator "contract" and OP seems unwilling to accept "there's no such thing" as an answer
 
How do I run a setup tools entry point from source?
 
pip install -e .
 
106
Q: Contrived homework questions

Matt BurlandLooking at this question got me thinking. A lot of people post homework question / programming assignments on Stack Overflow and that's fine if they make a legitimate effort (the linked question, not so much) and need help. But my concern is that a lot of homework questions are deliberately contr...

:(
this needs a thousand upvotes
 
wim
apparently I have already starred and upvoted it
But I don't remember it, will read again :)
 
there was just again a question in in that I don't know how to do X, then a suggestion in comments and guy answers "but I cannot do X because the professor didn't teach us it yet"
 
wim
7:18 PM
wow, my favourite answer there is sitting on score of -26
 
well of course
now at -25
 
wim
I immediately downvote any question with arbitrary restrictions that don't have any believable explanation about the restriction
it's not healthy for the site for those deliberately sub-optimal approaches to be hanging around in the search results
 
If people come across this and blindly use the solution without reading everything properly, that's their loss and there is nothing we can do about it. In your example pretty much every response has been "don't use a switch, use the built in method", I imagine the same applies to all of these kind of questions — Joe Jul 28 '14 at 13:58
 
wim
@JoshuaBarnett the whole point of the entry point is to run it from the shell, not from source
intentionally posting bad advice like ...
 
7:40 PM
@AnttiHaapala Commented. And then I noticed how old it is. Oh well. My comments are still relevant.
 
DSM
@vaultah: just as I was about to wield!!
 
:P I would say "vaultah'd", but that sounds weird
 
wim
fun way to make an ellipsis
>>> ....__new__(....__class__)
Ellipsis
 
DSM
#sillypythontricks
 
7:48 PM
@wim I answered a question about that back in August, from an OP with a track record for asking oddball Python internals questions stackoverflow.com/questions/45640690/contract-of-a-decorator
@wim I don't think we should ban or delete those questions (assuming the question isn't simply a no-effort dump), but maybe we do need a way to clearly mark such pages so that people realise it's a classroom-golf question, and not the sort of code that goes in a program that's trying to follow best practice.
I think most of us would agree that it's often necessary for a teacher to impose some unrealistic restrictions in homework questions: if the assignment is about using switch, the students need to use switch. But we often see questions where the restrictions are so extreme that the resulting code bears little resemblance to what a good coder would feel comfortable writing, and one has to wonder how long will it take for these students to develop a sense for what real code looks like when all they ever see is this classroom-golf code. — PM 2Ring 17 mins ago
 
@wim code that doesn't work in Py2 :D but i dont know why that would work in Python 3 ohhhh ... is an actual thing in Python.... :\
 
@MooingRawr The ellipsis object was added mostly for the benefit of Numpy. But that's not the 1st time Numpy's had an effect on mainstream Python: we can also thank Numpy for extended slicing.
 
DSM
And for the terrible name of @, more's the pity, but my complaints about it are probably tiresome by now.. :-/
 
8:05 PM
Well hello there.
 
Missus scared me big time. "[Talking about things that are going to happen on Thursday] But that's not tomorrow, today's only Tuesday" O.O
 
wim
@PM2Ring that is literally the same oddball OP ... LOL!
see the "Linked question" on the right about more contract decorator stuff
 
that user used to frequent here
to the point that he's on my ignore list
he had a habit of trying to map java-like concepts directly to python by any means necessary
 
@wim Rightio. BTW, but I guess you already tried this:
g = lambda x: x
@g(lambda fn: lambda *args, **kwargs: 'hello world')
def foo():
    pass
 
wim
cheating
 
8:18 PM
I think you're placing arbitrary restrictions. ;) But it'd be nicer if Python had a built-in identity function that I could use instead of that g.
 
wim
@AndrasDeak ah .. a java weenie .. that would explain a lot of things
 
@wim To the point of "All languages are just Java written in a funny way"
 
wim
I can see how the "no rules" language design of python could seem kinda barbaric to someone coming from such a formal language as java
@DSM PEP to rename __matmul__ to __email__ ?
 
__whirlpool__ because readability counts
 
wim
yeah, I also want a built-in identity function and also use lambda x: x for it occasionally :'(
 
8:28 PM
...at least I was told many years ago that @ is also called a whirlpool, but I see no hint of that now that I google
the source was Hungarian so perhaps it was lost in translation
 
wim
it's on my TODO list to make a Python lib where
user@domain.com < 'hello!'
will literally send an email "hello!" to user@domain.com
 
but why?
 
wim
just for fun
and to learn about import hooks
 
oh and syntactically that would be matmul, right?
 
wim
you would need, import hooks, overridden comparison operators, __matmul__ and descriptors
 
8:31 PM
OK, I figured the ones that I'm familiar with
> Also has numerous nicknames, including snail, arabesque, monkey, curl, cabbage, twiddle, twist, a-twist, strudel, vortex, whorl, whirlpool, cyclone, ape, cat, rose.
so I wasn't misinformed ^
CABBAGE!
 
cbG
 
next time I'm saying hi with @
 
>>> from unicodedata import name
>>> name('@')
'COMMERCIAL AT'
 
@wim if you accomplished that task, you'd have broken several other things within that scope. At that point, would it not be simpler to do MyEmailer('user@domain.com') < 'hello!'? I can appreciate the fun aspect though. And maybe my comment is obvious and hardly your point of even thinking of it. Now that I'm thinking of it more... I want to know how to do that too.
 
@PM2Ring yeah that I found pretty quickly
 
8:36 PM
That was the name I first learned, before I'd heard of email.
 
me too
(except the email part)
 
When I was a kid, Email meant these guys: en.wikipedia.org/wiki/Email_Limited
 
in Hungarian "email" (pronounced phonetically) meant a kind of enamel (but I only learned this as an adult i.e. after a decade of email)
 
8:57 PM
Reading stuff by overexchange tends to remind me of the Fish Licence sketch.
 
wim
9:09 PM
well, that settles it. __commercial_at__.
 
9:28 PM
Inspired by wim, and brought to you by weird metaclasses: pastebin.com/cS1KK02X
 
waaaaat
 
what am i reading user o.o
 
An implementation for sending email with syntax like To: recipient@whatever.com, except for the part that would actually send the email, because I figured any attempts to test that would just get spam-filtered unless I did a lot of reading on email deliverability.
 
9:44 PM
It gets as far as building the MIME message.
 
Really impressive nonetheless
 
really impressive lol
 
wim
10:02 PM
@user2357112 no pastebin at WimCorp :(
 
Yeah, I think you mentioned that before. I don't remember if you mentioned any other services that would work, though.
I would have put it on Ideone or something, but I don't know any such service that supports Python 3.6, and I think variable annotations are 3.6.
 
wim
–1 for Zed Shaw — wim 1 hour ago
4 upvotes and counting .. praise the meta effect
 
10:15 PM
pretty weak attempt at pitchforking
 
@
 
DSM
"I have written a code but it doesn't work as I would have liked" <- haven't we all..
And with that, end-of-day rhubarb!
 
rhubarb.
 
10:46 PM
I'm web scraping today.
Anyone know some good sites for first attempt?
 
Not Google :D
something government might be a good choice, especially NASA
 
How about Wikipedia?
Oooh NASA can I do it on theirs?
 
11:40 PM
next(cbg)
@cᴏʟᴅsᴘᴇᴇᴅ I don't know if you saw this stackoverflow.com/a/47430171/2336654 but I totally borrowed that recipe you posted yesterday
 
00:00 - 17:0017:00 - 00:00

« first day (2594 days earlier)      last day (2362 days later) »