« first day (2861 days earlier)      last day (2102 days later) » 

12:17 AM
@wim synonym
@piRSquared Is this "closest without going over"?
 
yes
 
500
I am sooooo close to bronze badges on and
 
12:34 AM
omg i feel so dirty. I held OP's hand and put in an if/else that I shouldn't have stackoverflow.com/a/51867991/2336654
 
12:48 AM
@piRSquared I don't know why that question is tagged as pandas
(meaning I know the OP says he wants to put it into a dataframe but I don't think he even imported pandas)
 
lol, shoot first ask questions later. For OP and me.
 
1:44 AM
hello
if an assignment sets up a python=3.6 virtual env, can I do the same while having python 3.7 installed on my machine?
 
yes
are you using anaconda?
well if you are, I think it's
conda create -n my_env_name python=3.6
the you should be able to follow that up with
conda activate my_env_name
It may even be helpful to name the environment something useful
conda create -n p3.6_assignment_1 python=3.6
 
2:02 AM
exactly
so it doesn't matter if I have 3.7 installed instead?
it's backward compatible with all the 3.x ?
 
It will figure out what you're missing and populate that environment with what's needed
 
k ty
 
Let's Golf consider the string t = 'GetYourKixWithRoomSix' what is the most succinct way to toggle the case of every other character?
My entry
''.join([tup[i % 2] for i, tup in enumerate(zip(t, t.swapcase()))])
# 'GEtyoUrkiXWItHROoMSIx'
 
wim
2:41 AM
n=len(t);((t+t.swapcase())*n)[:n*n:n+1]
 
cabbage
 
cbg
 
Nice one @wim
 
2
Q: JAVA: how to change the value of Math.PI

b4904878I'm lead developer of a scientific app. We have a new requirement from accounting that pi=3.14. But in JAVA Math.PI=3.14159... I tried changing it with reflection. But it seems that doesn't work, some of the libraries we call still use the old value of pi. For example when we integrate 1/(x*x+1) ...

 
wim had a complete brain rewiring... you don't invent these things, they spontaneously explode in your mind!
 
2:50 AM
Who knew that accountants can redefine all of mathematics?
 
Accountants rule the world!
I am in shock!
 
what's next, maybe 1+1=3?
 
makes me unhappy
 
@piRSquared You can shorten that to ''.join([c,c.swapcase()][i%2] for i,c in enumerate(t))
Not as short as wim's but at least much better memory wise
welp, memory doesn't matter in code golf
 
3:02 AM
that's nice too. Got chores to do. Will noodle while I work.
rbrb
 
@wim Nice. I think you can drop the n*n.
@Code-Apprentice Surely they're trolling...
 
@PM2Ring seems likely
 
wim
3:43 AM
@PM2Ring how so
 
4:16 AM
@wim Why is map(arr[0].__rtruediv__, arr) a bad non-list comp way of solving the "divide each element of list by its first element" problem?
I mean, I read your comment, but I didn't understand what it had to do with the problem here
 
wim
4:34 AM
OK, so if the question were "How to divide each element in a list of integers by first element", then your answer would be "just a solution which doesn't generalise"
But since the question is "How to divide each element in a list by first element", and a list of integers is given as an example, then I think your answer is strictly speaking incorrect.
arr[0].__rtruediv__(x) is not a good substitute for x/arr[0]. Does that help?
 
So then the solution would be to convert everything to float so that float wins out over everything.
 
wim
No
why should floats have anything to do with it
it doesn't have to be a list of numbers at all
pathlib.Path instances, for example, implement division.
 
do you really think an OP citing an example list of integers will hope that an answer should also work for Pathlib instances?
I get where you're coming from, and the rtruediv answer is flaky at best, but at the same time one shouldn't optimise for world peace when dividing numbers. Or maybe that's just me
Anyway, it's flaky, so I'll delete it.
I don't want to edit my answer into a lambda
 
wim
I don't like lambdas either. But in this case, the lambda is better.
 
@wim Sorry, I can't do arithmetic. :)
 
wim
4:46 AM
>>> Path('/usr') / 'local'
PosixPath('/usr/local')
>>> 'local'.__rtruediv__(Path('/usr'))
AttributeError: 'str' object has no attribute '__rtruediv__'
 
@PM2Ring hah, I just tried dropping n*n as well and yeah, it did not work (-:
 
wim
Also, @coldspeed, downvoting one of my answers in retaliation because of a missing space between k,v? Really? I thought you were more mature than that.
 
I wouldn't call it... retaliation, but ya know you're always doing it to me... so I wanted to return the favour once :p
 
wim
I'm not always doing it to you ..
I would never downvote someone for PEP8 alone
 
Well, not always, but I'd say almost every question we both answered
run that with 674039 and 4909087
 
wim
4:53 AM
Unless I left a comment on them, the DVer probably wasn't me.
 
pep8 is really the extreme of nits, but I've seen worse ;-)
 
wim
I did downvote that one because honestly this code looks like one of Ajax's crazy one-liners
 
recbg
 
wim
@coldspeed OK - I ran the query, did you?
 
@wim That's harsh... at least this fits into the 80 char width limit :p
 
wim
5:01 AM
this was the tally:
no answer from you 5 (showed up in query results due to comments)
I haven't voted: 3
I downvoted, with comment: 1
I upvoted: 2
 
Sorry, I couldn't have known about the "i didn't vote 3" part, because I recall a lot more dvs than 1. Well, there are a couple others that probably weren't listed because the comments have been removed. I also deleted a couple of my answers in the past.
I take back what I said
 
are we done yet?!
 
wim
I'm done
 
:d good
 
 
2 hours later…
7:06 AM
cbg
 
cbg @AndyK
 
@ReblochonMasque o\ Monsieur Reblochon
 
long time no see
 
@ReblochonMasque yeah. I was around, lurking. Busy as leaving my current job in about 3 weeks-ish time, moving back to Paris and starting a new gig there.
 
I see, I've been away for a while too.
Are you French @AndyK?
 
7:17 AM
@ReblochonMasque yep
 
Alors bonjour. :)
@AndyK What are you going to do in Paris?
 
7:30 AM
@ReblochonMasque python dev :)
 
ok, cool - your own company, or working for someone?
 
7:43 AM
@ReblochonMasque working for someone, as starting paid dev
it took me 5 years of personal projects to catch the eyes of recruiters
 
cool - wishing you all the best in this new adventure.
 
@ReblochonMasque thank you :)
 
brief cbg
 
8:00 AM
cbg @JonClements
 
8:19 AM
@JonClements o\
 
9:15 AM
Hey guys
 
cbg
 
cbg
 
 
3 hours later…
12:47 PM
Is it a bad idea to have module variables in you library code that are parsed from yaml?
pro: no need to pass the file path around and parse it in >5 different functions. con: importing the module may potentially raise an error
 
You could parse it once and pass the config object/dictionary wherever you need
 
like in the proper singleton pattern?
 
Under what circumstances would importing the module raise an error? If it's just "if the user opens up my project directory and deletes the .yml file, or types gibberish into it", then you don't protect yourself from errors by using a non-yaml approach, because the user can just as easily delete your .py files too
 
@Kevin pretty much that, yeah
i thought "the user might break the part that relies on the config, but the other parts are still fine."
but now that i think about it, the whole module is useless if the config is not there
also, I might not be aware of some vague rule like "don't have code execute while loading a module that isn't builtin types."
 
devil's advocate: There is a certain category of user that is confident enough to modify configuration files, but not code files. So by adding configuration files to your project, you make it more likely for users of that one category to mess with your settings, and potentially forget a closing quote mark or something, thus breaking the program
 
12:58 PM
> certain category of users
that would be me in 6 months
 
I think this category of users is pretty well acquainted with the idea of "I'll change this and see if it breaks anything, and revert those changes if so" so we shouldn't be too concerned with protecting them from themselves
The best thing to do for them is to make sure that program breaks in an obvious way, and to make it so that changes aren't irreversible
if registration_key not in config: print("can't find key! You must be a filthy software pirate. Executing punitive measures."); delete_hard_drive() is bad, for example
 
.. I can only promise to try
But yeah, it's super straight forward in my case.
 
raise Exception("The yaml is donked up, please fix it") will do in a pinch
 
wall_of_shame["can't write yaml"][user.name] += 1
 
1:14 PM
there are 10 types of people: those who do not understand binary, those who do, those who realized that this joke was in ternary and those who anticipated that it will contain an off-by-one error.
 
Is python's with statement totally same as java's try-with-resources? I am new to python
 
@RahulJain totally not.
 
can you point out some differences? Glad that I asked it or I wouldve started to assume something incorrect
 
@RahulJain try with resources requires the resource to be autocloseable; it will call AutoCloseable.close() at the end.
Python's is much more complicated.
 
python also calls ._exit_
oh ok. I will read about it more by myself then
 
1:16 PM
so: Python calls __enter__ - within the block, and the given name, if any is bound to the return value of __enter__
the __exit__ on the other hand, can suppress exceptions too...
try-with-resources can be implemented with that, but so can so many more things.
 
ummm.. but they are both used for the same purpose right? (the auto close thing after exit)?
 
for files it pretty much is "try-with-resources" but it is just because these classes have __enter__ and __exit__ methods that behave so.
no.
for example, in unittest module, there is assertRaises
 
oh. so I have came across with files only, maybe thats why I am thinking like that. Thanks buddy.
 
it is not used for anything like. it just checks that the code throws a given exception, and then suppress it - throwing AssertionError if another exception was thrown or none was thrown.
you cannot do this with autocloseable. nothing like :D
 
@RahulJain side note: calling a stranger "buddy" comes across as a bit weird
 
1:27 PM
hallo
 
\o cbg
 
@AndrasDeak didn't know that, Sir
 
for the record, sir is weird too :D
 
@AndrasDeak that was on purpose, if you really took that seriously. kbye :P
 
plenty of people really call others sir on SO, so I never assume someone's joking
 
1:30 PM
now don't block me from the chatroom.
@AndrasDeak try joining javascript room then
 
DSM
1:51 PM
Itertools-badge cabbage for all!
 
badge!?
oh phew... a bronze one... was wondering how far along you'd got answering one of my favourite libs :)
 
DSM
I've been sitting at 97/100 votes for what feels like forever.
 
dammit... I don't even have a bronze... weeps
 
DSM
As an aside, I noticed yesterday that the badge symbols for aviation are little planes. That's adorable.
 
yeah... some sites have quite nifty badge symbols :)
how the heck have I only got 27 score in 10 answers for itertools!?
that's abysmal :(
 
DSM
2:00 PM
Bad luck, I guess-- maybe you always use itertools to answer but you don't get the tag..
 
itertools was designed to be memory and tag score efficient
 
Lifehack: edit the itertools tag into every question that you answer
 
@AnttiHaapala my most controversial answer :)
 
DSM
My next tag is "sorting". Am I an expert in sorting? :thinking_face:
 
2:01 PM
^No! your first priority should be the tag
 
@Kevin Does it actually update the tag score retrospectively, or only for votes following the edit?
 
Lifehack
 
Start editing these
SO search user:1252759 is:answer score:1 "itertools" -[itertools]
 
DSM
Now, now. We can't go adding a tag just because it's used in an answer unless the question is inescapably bound up with it.
 
Good place to start looking
 
2:19 PM
@DSM ummm... apparently I've got a gold in list which is always interesting and it's apparently more rare than python and it just looks really odd if I dupe close a post and that turns up as the badge used...
 
Lifehack: remove tags from questions you answer so you don't get weird gold badges
 
1. Why would you want to avoid 2. I think you can only get one.
 
You have earned the "willfully misunderstanding messages" badge
It's made out of gallium
 
@DSM I'm just glad meta.stackexchange.com/questions/268288/… got implemented...
I find it really helpful that a gold badge is shown; users find it more acceptable if a question was closed as a dupe by an expert in the tag, rather than by a community moderator. — Martijn Pieters Jun 26 '17 at 11:54
^^^ that summed up why I asked for it in the first place in a sentence :)
typical Martijn :)
 
Martijn. Always Martijning.
 
2:26 PM
s'pose the clue's in the name there? :)
 
2:50 PM
@piRSquared I did get nice score of for davidism and ilja with that ;)
 
there should be a meme for "The moment you go to answer a question only to realize the Ninja already has an answer for it"
 
Not a meme per se but we do define kevin'd
 
cabbage
 
cbg
 
Ah, there's that familiar terror as I stumble upon a "how did this ever work?" bug
 
3:02 PM
mmmm....leftover homemade soup (one of the few foods that taste better the next day)
 
Not sure which explanation I prefer: "none of your users have ever tried to use this feature" or "your users tried it, then shrugged when it didn't work, because your product is so buggy that they assume that features not working is the default state and not worth kicking up a fuss over" or "it once worked, but stopped, because we live in a fundamentally chaotic and unpredictable universe, from which logic and reason is a flimsy defense"
 
DSM
I just had a terrible moment when I thought that a Very Important Number hadn't been being updated for a month, but it turns out it's just using yesterday's number, and the choice to use yesterday's and not today's was a business decision made before I was put in charge of these Numbers. #tgiaf
 
that giaf in tgiaf made me read gaf and think something very different at first
 
....I don't know what tgiaf stands for but you don't want to know what I translated it to in my head
 
it's a mutated tgif
 
3:07 PM
the f was not Friday
 
Hmm I suspect this bug only happens when the semi-deprecated reticulate_splines_old gets called. reticulate_splines and reticulate_splines_new exhibit different behvaior. Which is a problem, because they're all supposed to do the same thing
 
you forgot to port all the bugs to the newer versions
 
DSM
HugeGo does more spline reticulation than any other large company I've heard of.
 
The next person to say "I know, I will write a new spline reticulation method and use it to replace all the previous ones" will be struck with a large herring
Because invariably they'll replace half of them, then discover that actually the business logic gets a little thorny in a couple places, and they decide to temporarily* keep reticulate_splines_old where it is until they can hammer out the precise requirements
 
Question about the naming convention: Is it policy to increment the number of 'really's or have a version number?
 
3:15 PM
The words every developer dreads: "So we have some legacy code, ....."
 
print(*[f"reticulate_splines_{'_'.join(['really'] * v)}_old" for v in range(5)], sep='\n')

# reticulate_splines__old
# reticulate_splines_really_old
# reticulate_splines_really_really_old
# reticulate_splines_really_really_really_old
# reticulate_splines_really_really_really_really_old
 
Just follow the naming convention of your versioning system.
reticulator_final_v4_mod
 
@JGreenwell In all honesty, what would you think if you walked into a job for a company that has existed for more than 10 years and they didn't have legacy code?
 
I might do a happy dance
 
speaking of legacy, I was pointed to this neat-looking module that lets you use python constructs in fortran github.com/ylikx/forpy
 
3:19 PM
Because you've found a unicorn
 
Also I'd pinch myself and then check my pulse
"Welcome to developer heaven!"
 
you wouldn't typically want to go to python assuming you're using fortran for a reason, but I wonder if it could be worth/easier to outsource, say, input parsing to python
 
@AndrasDeak I actually know of someone who is doing basically that
 
is there a proper way to contract three words in english? "you would have" -> "you'd've"?
 
you'd'ven't
internet alternative: youd of
 
3:22 PM
you'dn't've
 
@piRSquared sorta
 
DSM
I say "I'd've" and "You'd've" in speech. Sounds casual but fine to my ears ("you'd've" seems slightly more casual for reasons I can't explain.)
 
Interesting... I'd have just gone for "you'd have"...
 
cabbage
 
Language is fascinating and aggravating
cbg
 
3:26 PM
you'd've would make me double take...
 
"I'd have..."
 
only person I've heard using the I'd've was my Uncle from UK (though I always thought that would be spelled "I'd have" and he was just dropping the "h"s like usual not that it was considered a word/slang)
 
DSM
Note that I'd only say "I'd've gone if I could have", not "I'd've only nine doughnuts left if I gave you one, so no."
 
as far as I know that's an invalid use case for "I've" too. At least "I've three apples" sounds weird to me.
 
DSM
Let's see.. "I've finished five and I've two left" doesn't sound that bad to me, although I admit I'd probably say "I've got two left".
 
3:31 PM
have is present tense so "I had finished five and I have two left" or "I'd finished five and I've two left"
 
I think that's probably why English is supposedly one of the "harder" languages - there just aren't any easy rules to learn and they're not always applied consistently anyway...
 
has is way harder than have/had though (has is present perfect & past perfect)
 
DSM
Eh? I'm not looking back at a distant past. I'm in the middle of marking exams. Five are done: I have finished five. There are two remaining: I have two left. "I had finished five" would be more like "I had finished five when the phone rang."
 
oh, in that context you'd be correct or you are correct or.....now my head hurts
 
Room 6 - for Python, Salad and for when one can't be bothered to attend a chat room in EL&U :p
 
3:36 PM
LMNOP
what are we talking about?
 
when I do check out that site (don't think I've signed up yet though) - there's a few questions and answers that have made me go "oh wow... I did not even think of that)
 
3:47 PM
@DSM Learned from you (or unutbu >.<) stackoverflow.com/a/51880762/2336654
 
… and then there are these days where I hit the rep cap without even doing anything xD
 
^ 1st SO World Problems
 
Absolutely
 
wim
we are the 99%
 
It’s very funny though because there are days where I have no chance of getting it, then there are these days where I have good progress over the day, so I can spend a bit of time pushing out new answers to eventually hit it.. and then there’s today 🤷
 
wim
3:54 PM
@Arne make sure you use yaml.safe_load. otherwise it's basically an eval.
 
@wim seriously? You'd have thought that'd be the default and you'd explicitly pass safe=True or trusted=True or similar?
 
wim
don't get me started..
maintainers tried to fix it (renaming yaml.load to yaml.danger_load and renaming yaml.safe_load to yaml.load)
 
Did it work...?
 
wim
4:09 PM
PyYAML was assigned CVE-2017-18342
 
safe loading is for cowards
 
wim
v4.1 was released to PyPI fixing the CVE
 
@AndrasDeak I load pickle files in Python with root privs just for a laugh :p
 
wim
then one of the original yaml authors suddenly reappeared, reverted the commit, deleted the v4.1 release from PyPI and complained that teh change went in without his knowledge
 
@JonClements Following sudo pip install with a random package from pypi?
 
wim
4:11 PM
this guy has not been maintaining pyyaml for years, and apparently not maintaining it since either (no commits to master for over 6 weeks now)
 
@wim that sucks
 
wim
the python guys that were trying to help (donald stufft and ian cordasco) basically said, ok, forget it we can not maintain this library
 
Poor users
 
I think there's two main yaml libs for python though on pypi aren't there?
 
wim
yes and they are both dumpster fires
 
4:13 PM
How do people not on any lists learn about this? (Rhetorical...)
 
The change to 3.7 was a hot mess. I think we are sitting on a beta release of pyyaml right now.
 
wim
which is one of the reasons why the python community is moving towards TOML instead
 
@wim meh... .ini files - who ever needed more than those anyway :p
 
One that i think has the safe load as default.. but now i better check again
 
I'd rather something safe load and baulk at me rather than just trust a possibly 3rd party config...
 
4:14 PM
@wim pep to include a toml parser in the standard lib, or is the spec still not done?
 
Guess who has already been using PyYAML’s SafeLoader back in 2011.
 
wim
@JonClements exactly
 
I could see an argument (I'd understand but not agree with it) that you're really only ever going to use your own configs - so why does it matter... but still...
 
PyYAML: putting back the YAM in YAML
6
 
wim
Look at the reactions on the revert github.com/yaml/pyyaml/pull/194
 
4:25 PM
oh right... worked out why my SQL query from a cluster has taken so long...
 
apparently it makes sense if you query the right table and not the transactions table
 
> Exploitable use of it has been out there for 12+ years.
good thing simple default passwords have never been exploited
 
wim
And it was exploited, ruby community got burned hard by it blog.rubygems.org/2017/10/09/…
basically every rubygem compromised
Python community was just lucky, really, that using yaml for config is not popular - were using .ini and ConfigParser
 
oooh, that was that? Nice(... in a very not nice way)
 
4:31 PM
So, what's stopping people from forking the project and making better technical decisions?
 
wim
nothing really
but how are you gonna change the whole world to install your fork instead of pip install pyyaml?
 
just hack their installations using malicious yaml files
 
umm... anyone ever tried pickling a 112gb DF ?
 
wim
ruamel.yaml was a PyYAML fork originally, IIRC, but it has it's own set of problems
 
Maybe do what Pillow is doing - keep pushing updates while the original project grows ever dustier
 
4:35 PM
tempted to try it, but I've killed the process to get RAM back and lo' and behold... 2.3 seconds to get 875k rows I was after to start with :p
think my tired head should get some sleep before I even attempt an update statement :p
 
Hi, anyone here knows an article that shows some real basic example of how to use itertools.groupby please?
 
wim
Perhaps. The pyproject.toml is pretty much official now, so the only people who might have cared enough (PyPA) are looking elsewhere
 
@RenanCidale that are different from the official documentation that gives examples?
 
yes, Unfortunately I'm pretty stupid and the whole concept just doesn't get inside of my head :(
@JonClements and thanks for answering ;)
 
no worries... just try and explain what you're struggling with maybe?
 
4:38 PM
preferably with specific examples that confound you :)
 
wim
The PEP 518 basically says PyYAML is a dumpster fire (paraphrasing).
 
people will be glad to help out if they know how to do so... if you've read the official docs and don't grok certain bits - then try and explain that...
 
I guess pillow has an advantage over the hypothetical pyYAML fork in that there isn't a newer sexier technology that's draining away their developer base.
 
wim
If only JSON allowed comments it probably would have been "good enough" for config files in the first place
 
@wim I've often found the demjson library useful for some corner cases - can't remember if that can pretend comments are an option or not... but it's a more flexible parser than the builtin
 
4:44 PM
never could understand why JSON doesn't allow comments (yes I know the official reason, it just never made sense)
 
Subtle Transformer: Alters the question in comments with no other comments.
 
like a 4th of the JSON I process has a field like _comment which are meant to be ignored (or had to be cleaned cause the user assumed comments with standard // or /**/)
 
KSON will fix the comment problem, and much more
 
@JonClements thanks, so, I have file with 137,000 lines containing [{}, {},{},{}]. {'OBS_VALUE': '3.7686', 'FLOW_BREAKDOWN': 'IMPLNG', 'REF_AREA': 'AE', 'TIME_PERIOD': '2015-08', 'ASSESSMENT_CODE': '3', 'ENERGY_PRODUCT': 'NATGAS', 'UNIT_MEASURE': 'M3'} . Main goal is to groupby REF_AREA first, than inside of each group, filter depending on diferent values. There are 15+ of value type, ENergy product 3 different Value, TIME Period goes monthly UNIT Measure has 4 Values. And so on.
 
@RenanCidale sounds almost like you should be looking at pandas if you're going to be numerical work...
 
4:49 PM
@JonClements exact, but I can't use anything that isn't standard library
 
@Kevin Expected release date?
 
and it has to be 2.7 python
 
@RenanCidale well... you've got collections.defaultdict available then...
 
@piRSquared The 0.1 release is out now. There's no specification and no implementation, but if you show me a string I can tell you whether it's compliant KSON or not
 
DSM
If someone is in a situation where he has to use only 2.7 and stdlib, he should concentrate his efforts on escaping that pit first, IMHO..
 
4:52 PM
empty string: no
{}: yes
[/* I've got a lovely bunch of coconuts */]: yes
[//here they are standing in a row]: yes, but only on prime numbered days
 
Can we specify the epoch
or prime numbered day of the week?
month?
 
@jon
@JonClements would you mind going a little bit more in details about your answer please?
 
you can edit/delete messages in chat for two minutes
 
The epoch is in relation to the last time I sneezed. It updates often.
 
@RenanCidale check out the example here and in the documentation. This will likely be you're best bet if you cannot use pandas or 3 (mostly pandas)
 
4:58 PM
Do you have a photic sneeze reflex
 
I do
 
I don't
 
@RenanCidale possibly - possibly not. Are you aware of how collections.defaultdict works - have you taken a moment to read its documentation if not?
 
doing that now.
 

« first day (2861 days earlier)      last day (2102 days later) »