« first day (2482 days earlier)      last day (2473 days later) » 

3:00 PM
You should really just drop the idea of "Pythonic" and replace it with "straightforward".
 
^^ so important
 
DSM
Sep 30 '14 at 19:39, by DSM
@Zero: I use "The Pythonicness that needs hours of thought is not the true Pythonicness" sometimes when people are working hard to make their perfectly functional code more Pythonic instead of doing something useful.
 
stop yelling please. It's too early for yelling.
 
user3657941
I was just going to say @Anarch is probably modifying his code to use @Kevin's example
 
3:02 PM
I read it the same way as well and looked it up and got to see his wife's art work and learned about his brother and child... so yeah, I don't know where I was going with this
 
Hmm I think my last message had the opposite of the intended effect
 
@Kevin Sometimes I look at code I wrote the day before with list(map(lambda... and then gut it all and just use a list comprehension.
 
@DavidCullen I am not doing any project , I was just learning Map and lambda and stuff and was trying to do weird things with it.
 
I get sucked into the functional rabbit hole every so often
 
@PaulMcG Same. These days I only use map if I can leave out the list and the lambda
 
user3657941
3:06 PM
Maybe I'm blessed? If I wrote code like that, the other team members would ask me what it did.
 
DSM
I still use map for conversions, map(str, seq) etc.
 
Making code that your coworkers can read is an important yet oft-neglected part of Pythonicness
 
Why would someone use list comp over map?
I mean its far easier
 
Because [x*2 for x in seq] doesn't require you to create a lambda object
 
My favorite principle is "Beautiful is better than ugly." And what some people's opinion of "Pythonic" often makes me nauseous.
 
3:08 PM
And you can't do [x*2 for x in seq if x < 10] with just map
 
It also doesn't invoke a name lookup or function call.
 
so , performance and memory reasons?
 
Performance, memory, code footprint, readability... So basically all the reasons
 
Also, I have finally started to like the standard documentation, i usually resorted to some blog or an alternate source to look up python stuff just because the standard doc looked cluttered.
 
Python’s doc definitely belong to one of the few better language documentations.
 
3:13 PM
But there is also the debate of not immediately jumping to pre-mature optimization
 
Topped just by MDN and MSDN
imo
 
recbg
 
@poke imo django has the best standard doc
 
language
 
user3657941
Yes, Python's documentation is some of the best I have ever used. It can be hard to find the explanation for a parameter, though.
 
3:14 PM
@CoryMadden if all solutions are wrong for your problem in the exact same way, then your problem is probably not what you think it is. Time to put together an MCVE and see where your issue lies
 
I mean its very easy for a beginner like me to just dive in and get what i want.
@poke Ah.. In that case I agree with you..
 
Completely unrelated to any of this, but I was astonished by this last night and I want to share: "just desserts" is actually supposed to be "just deserts".
 
wow, talkative day today here
 
Apparently my interpretation of the phrase as "exactly the after-dinner treats you have earned through your own merit, and no more" is not exactly the intended meaning
 
Yes, because you get what you deserve, not desserve
 
3:18 PM
> Deserts here is the plural of desert, meaning "that which one deserves". "Desert" is now archaic and rarely used outside this phrase.
I have never heard of this meaning before, ever.
 
Never heardanyone saying "it may appear that they're getting ahead by cheating, but they'll get their just deserts in the end."
 
I had to smack down someone on Python subreddit yesterday who used "tenant" when they meant "tenet" - yeesh
 
huh, desert /dɪˈzɜː(ɹ)t/
Go home, English, you're drunk. Again. Admit you have a problem and ask for help.
 
english sucks. it makes no sense
 
@idjaw Go German,
One word for a 10 line sentence
"ihadfishandchipsforbreakfast"
 
3:21 PM
unrelated: this avatar that popped in today looks like the empty husk that Kevin's avatar would leave behind as a skeleton
 
user3657941
What languages do people prefer over English?
 
their own
 
@Anarach Common misconception imo.
@DavidCullen Python.
 
That is actually spoken as "MachensiedertoppendenallesduDeutsch!"
 
@poke Nice one
"Rechtsschutzversicherungsgesellschaften"
 
3:23 PM
I speak a few languages. It's not so much that I prefer a language. It's that english has inherited/appropriated/whateveriated words and the grammar gets really wild.
 
translates to "insurance companies providing legal protection"
 
still not a sentence
 
user3657941
Thanks @idjaw, that was the kind of answer I was looking for
 
what is wrong with , i dont know , "insurance companies providing legal protection"
 
the fact that you think you have a unique objective metric of what counts as "good" in a language baffles me
 
3:24 PM
@Anarach That’s a grammar feature though. You won’t find that word in a dictionary because it’s not a single word.
 
user3657941
I know that English has a lot of idioms and those don't always have equivalents in other languages
 
DSM
Hooray! I no longer have to attend a certain category of support meeting. O:-)
 
@idjaw I wish I was bilingual like many from your area. They started secondary languages too late here.
 
@DSM do you need an alibi?
 
meanwhile, Sanskrit be like, hold my Butter chicken.
 
3:25 PM
I speak like 3 languages I can only read and write one though....
 
@DSM started drinking again?
 
DSM
@poke: :-P
 
haha :D
 
@DSM I'm confused with that face : O:-) what is that O? or is ) the top of the head and - is the hair ?
 
Perhaps German leaves spaces out of some phrases for the same reason that English doesn't start interrogative sentences with an upside down question mark. Which is to say, for natives it doesn't hinder understanding, and if you beg to differ then that's a cultural difference rather than objective truth
 
3:25 PM
head with halo
 
@MooingRawr A hat
 
DSM
AndrasDeak += 1
 
Halo doesn’t work because the perspective should make it a lot thinner..
Like 0:-)
 
Yeah it's definitely a top hat. :P
 
DSM
Did you just talk about the perspective in an emoticon? O.o
 
3:27 PM
LOL i was like why is he greeting everyone in german ,
 
Yes.
 
<] :-) would look like a party hat, (] :-) would look like a toque
 
but some fonts put a squiggle inside the 0...how would that affect the halo property?
 
DSM
halo bling, I guess.
 
haloception perhaps
 
3:28 PM
@AndrasDeak Unicorn with a halo?
 
DSM
The horn wouldn't be in the right place, Mr. Perspective.
 
^
more like "head with sufganiyot hat"
 
depends on the size of the halo?
 
DSM
sufganiyot what now?
 
100 years from now the unicode standard will have complete OpenGL bindings so you can properly describe arbitrarily complicated emoji scenes
 
3:29 PM
Yeah! what is that
@DSM "A deep-fried ball-shaped doughnut, usually filled with jelly or custard and topped with powdered sugar"
 
rb folks
 
@DavidCullen And German has a lot of specific words that cannot be translated into English because English uses the same term for very different things all the time. English is so unbelievable unspecific sometimes..
 
Well the crazy came to Canada. This is concerning.
 
@poke Amen to that!
@poke Actually a lot of languages do that.. english just being the most popular one
 
map (f, seq) or (f (e) for e in seq) ?
whos fast ?
 
3:34 PM
The second one is pretty fast since it doesn't even execute f :-)
 
DSM
Neither does the first. ;-)
 
@Kevin First doesn’t either, map also returns a generator :P
 
cbg
 
so ?
i'm reading on this book, saying that the map is faster
 
Get a new book then, it’s old
 
3:35 PM
may I ask what book you are reading ? and what version of Python it is ?
 
@DSM sufganiyot hat, seen in the first image in the 2015 post-winterbash blog post stackoverflow.blog/2016/01/06/winter-bash-2015-hats-off
 
what makes the author thinks that the map version is faster
 
Please only Well Actually me if my statement is incorrect in both 2.7 and 3.X :-P
 
functional programming in python 3
idk the minor version
but i'm running py 3.6
 
DSM
@marsouf: use timeit to find out! then ask yourself "So by choosing the faster one, I've saved myself 0.3 microseconds each call. It took me fifteen minutes to figure this out. So how many times do I need to call this before I've actually saved any time and not just wasted it?"
 
3:36 PM
what does it mean when we say that a certain lambda expression forms a closure?
 
Aw, I wanted to suggest timeit :-(
 
timeit depends on my platform, i'm asking for a general case lol
or to be more precise, the underground algorithm
 
@Kevin You already wasted your try with that silly answer :P
 
this might be a long day
 
@rogcg My limited understanding is: variables referenced inside that expression will still be resolvable, even if the lambda is accessed from a context where those variables would ordinarily be inaccessible or nonexistent
Consider the example:
>>> def f():
...     a = 23
...     return lambda: a*2
...
>>> f()()
46
 
3:38 PM
a closure is a lambda that is referencing names outside its params
i think
 
interesting.
 
or i'm wrong ?
 
Once we finish calling f and return to the global scope, one might naively expect that a has been collected and can no longer be interacted with. But calling the return value of f shows that a still exists
 
@marsouf tl;dr: Use map when you already have a function f you want to use anyway. Use generator expressions in every other case since they are usually more readable then. Ignore all timing results because those points don’t matter.
 
@marsouf That, too, is part of it, I think
 
3:39 PM
@poke they're reading a book about functional programming with python3...
 
Sooo...?
 
so map is the functional way, right? :P
just not necessarily superior
 
Closures can also be created by regular functions, incidentally. It's not exclusive to lambdas.
And I think there are some corner cases with genexps... I'm foggy on the details
 
@Andras: If you attempt to do Python purely functional, you have already lost anyway. I don’t actually get why one would write a book about it. Half of that is likely lying anyway.
 
Some day it won't be like this
 
3:40 PM
if you can shrink your program into one sole expression, does this make it a pure functional program ?
 
Hey @Kevin Do you have this one in your list of Tkinter quirks? stackoverflow.com/questions/45463841/…
 
@poke yes
 
@marsouf no.
functional has nothing to do with length or “expression” count
 
elaborate then
 
does exec(my_string) count as a single expression?
 
3:41 PM
what makes your python script functional ?
 
You cannot write Python purely functional.
 
DSM
There are many beautiful functional languages. Python is not among them.
 
there's a few words from Guido himself here regarding functional python (the "functional programming" section)
 
print (*('"{0:s}"'.format (''.join (chr (e) for e in (randint (65, 90) for _ in range (randint (3, 4))))) for _ in range (20)), sep = ',')
for example
 
You have certain bits that are functional and that allow you to do some functional oriented things. But you cannot use it for functional programming.
 
3:42 PM
Functional implies no side effects, yes? So the expression [].append(23) would not be functional.
 
this is pure functional no ?
 
@marsouf wow, that's so profoundly deep
 
@marsouf print() is the very definition of imperative programming.
 
nah i'm using print to only print the whole expression to the outer shell
:D
 
something something wild goose chase
 
3:44 PM
@PM2Ring I feel as though I've seen problems before where text is not a valid named argument for some widgets, but I don't think the problem exhibited itself in this way. Quite interesting.
 
DSM
All this said, I do tend to write code in which as many functions are pure as possible and the effects are restricted to interface layers. Makes testing much easier (less to patch).
 
if i hinder my self from using assignments, how pure i'm functional ?
 
That’s not English
 
this might be a naive question, but why do some people care so much about being strictly functional?
 
[].append(23) doesn't use assignments and isn't functional. Therefore, not using assignments is not sufficient to be completely functional in all cases
 
3:45 PM
well i'm trying
@poke
 
@idjaw one of the fads of our times
 
english is not my native english :D
 
@marsouf neither is it poke's
 
@AndrasDeak I feel like powering forward with functional patterns really makes your code unreadable and untestable
 
@idjaw What else to argue about other than tabs vs spaces, PEP8 and being strictly functional!?
 
3:46 PM
But, I'm willing to be taught how I can make it readable and testable.
 
so they are lying to us ?
@idjaw
 
@idjaw and not vaccinating your kid will kill more people than your kid, yes.
 
DSM
@idjaw: wat? My code is easier to test when it's more functional. :puzzled:
 
“they”?
 
@idjaw As I understand it, adhering to functional principles will allow you to be certain of certain desirable properties of your program. For example, "calling this function twice will do the same thing as calling it once" can be quite valuable in certain contexts.
 
3:46 PM
@poke you forgot to mention emacs and vim
 
@idjaw Let’s also add “arguing about what topics to argue about” to the list.
 
@DSM Maybe I'm missing something in my definition?
 
what makes python a good candidate for functional programming ?
 
@idjaw Pure functions are the most deterministic you can get, which makes it super easy to test.
 
it's dynamic typeing ?
 
3:48 PM
@marsouf It’s not.
 
@marsouf what makes you think something makes it a good candidate to begin with?
 
DSM
Every function with state or side effects is harder to test, because both need to be mocked or patched.
 
Functional programming is not universally better than other kinds of programming. You probably wouldn't want to write a purely functional game engine, for instance.
 
6 mins ago, by poke
You cannot write Python purely functional.
 
why not use a functional language for functional programming?
 
3:48 PM
OK....I was thinking of something entirely different. I'm glad I prefaced all this with a naive question :)
 
like...haskell, I hear?
 
DSM
Haskell looks like fun. Rather than trying to write second-rate Haskell in third-rate Python, write first-rate Haskell in first-rate Haskell.
 
I'm going to try to find an example of what I was picturing
 
@Kevin *cough*
 
or second-rate Haskell in first-rate Haskell, depending on skill
 
3:49 PM
Does anyone use a Vim like internet browser and/or vim like browser add-in that they recommend?
 
named tuples over class instances, for a first step into functional programming ?
what about that ?
 
DSM
.. come again?
 
If your program has a lot of mutable state, then changing everything to be functional will probably mean that you're going to do wacky workarounds like pass a monolithic state frozendict in and out of 100% of your functions, and create expensive copies of it with slight modifications instead of just mutating it
 
@marsouf where is this going exactly?
 
to functional programmin
g
 
DSM
3:49 PM
re: "functional" -- you keep using this word. I do not think it means what you think it means.
 
I'm not even involved in your discussion too deep but even I'm growing weary
 
wim
imperative programming is a lot easier to understand for me
 
it means what then ?
 
@marsouf Look it up, maybe?
 
yeah i'm reading through the topic
 
3:50 PM
ugh, my horrendous regex from earlier got starred by somebody - it looks like a game console cheat code
 
wim
but it might be a mistake to say that functional style is "unreadable" or hard to understand, since I'm not practiced in the art
the same way I can't understand Japanese, doesn't mean it's not an elegant and useful language
 
@marsouf Maybe you shouldn’t read a book about “functional programming” in Python, as that apparently gives you the wrong idea about actual functional programming
 
I'm having a hard time finding examples of what I was thinking about....
 
@marsouf are you reading through the topic in the "functional programming with python3" book?
because you shouldn't
 
ok so I'm finding code like this: degoes.net/articles/fp-is-not-the-answer
 
3:51 PM
@PaulMcG I was wondering what that was..
 
as an example of bad functional programming...and that is the closest what i can picture...
 
wim
but I can say this for sure, when people try to write functional style in Python the results are awful
 
bad ???
why
 
@wim one main difference is that learning Japanese will objectively let you speak to 125 million Japanese
 
that's what I'm trying to find as an example @wim
 
3:52 PM
wherever there is lambdas, there is functional programming
lol
 
wim
monads mo problems
 
perhaps the author confuses "programming using functions" with functional programming
it could happen to me too...then again I wouldn't write a book about it
 
@poke Indeed, functional game engines exist, but my perspective is that they are often proofs-of-concept that nobody seriously uses. I acknowledge that this is not an easily disprovable viewpoint, since I can just No True Scotsman any examples you give me.
 
DSM
@wim: cute.
 
@idjaw Well.. give me any language and I can give you an example of someone doing a terrible job with that language. Functional programming, or the choice of a language, does not prevent bad code. You can write beautiful code in almost every language. It’s just that doing functional programming properly will give you a lot of benefits for free.
 
wim
3:54 PM
A classic example of fancy itertools functional approach turning out some unreadable sludge, when compared to a simple and naive pure python implementation — wim Apr 12 '13 at 5:40
 
does the void type exist in functional programming ?
void is pure imperative i think
 
@marsouf maybe
 
@wim but is it webscale?
 
@Kevin I would say this is mostly because functional programming languages are still the odd sheep..
 
@WayneWerner I see what you did there...
 
3:55 PM
xD
 
Data.Maybe "The Maybe type encapsulates an optional value. A value of type Maybe a either contains a value of type a (represented as Just a), or it is empty (represented as Nothing). Using Maybe is a good way to deal with errors or exceptional cases without resorting to drastic measures such as error."
 
let's assume g is a generator and seq is a noisy data source (large) to load
next (g) will trigger the execution of the datasource
in this context, what is the benefit of generators ?
 
:|
Out of curiosity, did you learn vanilla python before trying to learn functional programming in it?
 
what's vanilla python ?
 
Sorry @marsouf, but your messages here appear to be a rather incoherent dump of various misunderstandings. It’s really demotivating to continue talking to you about any of these things…
 
3:59 PM
python itself
the language
using it as intended
 
wim
vanilla python
 
awwww
that's yamming cute
 
Blue eyes white snake!
 
@wim Needs a bit more yellowish. Also little pieces of vanilla beans.
 
wim
4:01 PM
wow, cute animals really collect the stars here
 
And Kevin.
 
priorities
 
@Kevin I had to run, had a meeting. Was almost late.
 
Imagine a cute animal Kevin. That would probably get infinite stars.
 
DSM
Heh.
 
4:02 PM
@poke Annatto is an unnecessary ingredient in vanilla ice cream.
 
huh?
 
@PaulMcG Something escapes me. Only six digit numbers are supposed to match, so how is it that what I did is wrong?
 
@poke are you implying that Kevin isn't a cute animal?
 
That's what makes vanilla ice cream more yellow :P
 
@MooingRawr Either that, or at least that we haven’t seen a picture of him yet.
 
4:03 PM
Kevin is whatever Kevin needs to be
 
usually
@idjaw like KevinScript?
 
Especially KevinScript
I'm still waiting for his final form: KevinScript++
 
KevinScript# ? or maybe #KevinScript++ to fit in with the social norm of #-tagging everything...
 
My final form is only unlocked after the destined heroes defeat my three previous forms.
The second to last one has a very nice choir BGM, can't-miss stuff
 
Can we named the destined heroes - star warriors ?
 
4:06 PM
@Kevin I don't think it is a valid code, the first and last zeroes are alternating digits.
 
@GitGud But you are allowed to have alternating digits, as long as you have no more than one pair of them.
 
> Admittedly I don't know much about the field besides Haskell, but any language less popular than Haskell surely has very little practical value, and I haven't heard of functional languages more popular than Haskell. - GvR
heh.
 
f = lambda x : x
f.__qualname__ = 'g'
g (3)
can anyone tell me what is the benefit of __qualname__ if i'm getting a NameError ?
 
@Kevin Right. I missed that when I read the problem. Thanks.
 
@marsouf That's probably not what it's for
 
4:07 PM
@MooingRawr KevinScript++ 2.7.12
 
@WayneWerner Scala is somewhat popular though
 
any hiphop fans in the room?
 
have you read and grokked that?
 
my first time seeing the link
 
DSM
It's the first google result for "python qualname".
 
4:10 PM
Which is telling, and not in a good way :(
 
it didn't tell me anything new
 
you say "the first google result" as if google results weren't based on your search history :/
 
I swear there was a good meta dupe for "don't post comments linking to your answer under the question", but I can't find it. Re: meta.stackoverflow.com/q/354308
 
Better pattern: try a thing. Doesn't work. Search google for "python <thing>". Read any and all entries on python.org. Read the next 4 relevant looking entries. If you still don't understand, then say, "hey, this is what I've learned, why am I wrong? Or what do I still not understand?"
 
the fact that google results are based on search history doesn't exclude the possibility that every user will find that as first resut
what's with fallacies today
 
4:14 PM
but it's only a possibility, not a guarantee
 
wim
I like the joke in that PEP
Antoine Pitrou is awesome :)
 
It's the first result for me in private browsing, and through Duck Duck Go's !g.
 
wim
(it's in the first paragraph of the rationale)
 
over my head I guess
ah, second-class introspection?
probably over my head
 
wim
that's the one, heheh.
heh.
 
4:17 PM
I suspect that programming reference documents are not the kind of search queries that Google heavily customizes based on past history and/or geodata
 
I don't get it either :/
 
@Kevin I wouldn't be sure about that
aren't their secret coding challenge interview thingies based on programming searches?
 
wim
class A:
    class B:
        # this is the "second class" and it's difficult to introspect
        ...
 
I've also succeeded in pushing some python 3 docs before python 2 ones in my search results, for instance that of itertools
 
Even if you were a herpetologist I'd still expect "python <programming term>" to still give you stuff about the language and not the animal
 
wim
4:19 PM
__qualname__ was added for nested class introspection
if english is not your first language, "second class" also means "not first class" or "bad".
 
@wim Oooh. Now it makes sense.
 
DSM
Yeah, it's "introspection of the nested class is hard" <-> "introspection of the second class is second-class".
 
@Rawing I started googling things for SO questions in private tabs…
I don’t want Google to think that I still cannot remember how to do “variable variables with Python”
 
hahahaha
 
4:25 PM
@davidism I just love everything about that game... Hopefully we will see another Nier game in the near future. Also really good read on that blog
 
IIRC I got my google foobar invitation after I googled something similarly trivial/bad.
 
The article used a really good track at the end, so now I'm listening to that.
 
And it will be what I'm going to listen to at lunch.
Shuji Kohata and that white board drawing is pretty smart.... simple and smart...
 
wim
This article is a nice Introduction to functional programming, suitable for complete beginners
It uses Haskell, sometimes with Python equivalent as an example
 
When in school, whenever I'd tell people I was starting to learn functional programming, they'd respond with, "oh, I don't know C". They thought "functional" meant "functions only, no classes or methods." Which, since we'd only learned classic OOP languages, makes sense.
 
4:33 PM
git stash is so damn useful when working on different things in the same branch that you need to jump back and forth from
I <3 git stash
 
I didn't know that was a thing. I usually have branchs of the same version if I'm working on different parts of said version
 
4:49 PM
Love the stash
Use the stash
 
What would a git-stache do?
 
This tool would have been useful last week when I was reviewing pull requests for RABBIT and it wouldn't let me get a local copy because my current local copy didn't match what was in the repository, so I just shrugged and deleted all of my changes
 
I like gitstachio flavored ice cream
Is rabbit an acronym or are you just shouting its name
 
@KevinMGranger shave it for later. (I definitely stole this joke, don't hurt me)
 
@KevinMGranger Yes, both.
The changes I abandoned amounted to like three lines of near-trivial code but I still bristled a bit over it
 

« first day (2482 days earlier)      last day (2473 days later) »