« first day (3118 days earlier)      last day (1837 days later) » 
00:00 - 15:0015:00 - 23:00

3:16 PM
cbg
 
3:29 PM
ugh
>>> Path(path='foo')
PosixPath('.')
thanks, pathlib
 
@Aran-Fey What's its __str__ look like?
 
laurel
did you have any luck with the contextvars yet?
 
@PM2Ring '.'. No clue what it does with its keyword arguments.
@ParitoshSingh Well, I found out they don't work with generators, so I stopped working on it. Does that count as "luck"?
 
@ParitoshSingh I used to hand-wave my way past "from pyparsing import *" with "do this first since you won't know what classes you'll need for your grammar, and be sure to go back later and clean it up", but now I've decided to follow the numpy (np), pandas (pd), matplotlib (plt), etc. style and co-opt "pp" as the preferred pyparsing module prefix - "import pyparsing as pp".
 
3:33 PM
@Aran-Fey well, it only accepts positional arguments
I.e. path segments
 
well, evidently it accepts keyword arguments as well :/
 
Wow, argparse is very easy (in my simple use case anyway). I just wrote a little script to convert a/all data files from my app to a new format.
 
Yeah, I did a lightning talk on it at PyTexas,... oh wait, you were there...
 
@toonarmycaptain I've toyed with click - that wasn't too bad either for really simple thingies
what with dataclasses and contextvars I really should get around to building 3.7 at some point and have a "fun" time...
 
3:55 PM
anyone have a favorite site to load up a 3d file for printing?
 
wim
4:06 PM
click is awful
 
wim
@AndrasDeak huh, I didn't know he was an active scipy dude. Author/maintainer of trio.
@RobertGrant For practical purposes, it's a decent approximation. In some precarious situations, a module can be instantiated twice (once with name "modulename" and once with name "__main__" (and it's usually a bug)
 
@PaulMcG I was indeed. ;)
 
wim
This (modules being like singletons) is not really a property of the module itself, but more a consequence of the fact that import statements look up for an already exec'ed module sitting around in sys.modules. So, ehh, it's not really like the singleton design pattern at all (which would mean the class itself has to intercept instantiation).
@AndrasDeak Still bad. Might be OK if used within an __init__.py, which is otherwise empty or sparse.
 
4:22 PM
@JonClements I thought click was more for pretty CLIs?
 
wim
@AndrasDeak and so what? it's not the reason star imports are bad. there are tonnes of names sitting around in builtins anyway that you don't always need. in practice, it's bad because you can't easily see a modules dependencies and you can't as easily tell where a name my_whatever_func has come from.
 
@toonarmycaptain never used it for "pretty", and in fact some of the command lines I need to do argparse is better, but for some simple stuff, just decorating functions and stuff, is so much simpler using click...
 
@PM2Ring I suppose I'm feeling prickly about the topic because twice in the last month I've seen questions like "How come from PIL.ImageTk import PhotoImage followed by from tkinter import * makes the PhotoImage class behave in a way not prescribed by the Pillow docs?"
(They were asked in a rather more obfuscated fashion that required more than fifteen seconds of thought, but that was the core idea)
 
@wim at least I thought he was. I see him all the time on the mailing lists. But now that I checked he isn't among top contributors. He's #14 on numpy though. And he authored the matmul PEP and things like that, which probably threw me.
@wim that would imply that a single star import per module is OK :P
 
wim
ah. the PEP is lacking a discussion/selection of possible names for the new magic method (__matmul__ was a dumb name imo)
@AndrasDeak it is OK (sometimes)
 
4:32 PM
Can someone do me the favor of explaining to OP what to do when someone answers their question... thx stackoverflow.com/a/55905763/2336654
 
@JonClements I didn't realise it could do that stuff, I had looked into it for it's keypress, coloured text, paging etc
 
wim
tell me a better way to do this without a star import.
It respects whatever upstream PyYAML decides is their public API. And it keeps oyaml namespace up to date with PyYAML even if the latter changes.
 
@wim see:
2 hours ago, by piRSquared
It's a dodgy business to try to make green beans aware of tools but advise against using certain tools unless it is "appropriate".
There is a time and place. I think oyaml shows an appropriate use.
 
wim
I think some people saying "star imports are bad" are coming from a place of parroting what they've heard from others, rather than from practical software development experience.
@PM2Ring well said.
 
@Kevin Right. I knew there was a common example of a Tkinter name clash, but I couldn't remember what it was. That one's particularly insidious because of the close relationship between the PIL PhotoImage and the Tkinter one.
@wim Thanks.
 
wim
4:38 PM
Except that you didn't include my use case (namespace merge) in your 3 legitimate ;)
 
@wim Fair enough. My #2 case is just a simple & common name merge scenario, I didn't think about more complex scenarios like your oyaml thing.
 
wim
yes 2 is the most common/basic use case seen in the wild
 
@PaulMcG Did you happen to cover testing in your lightning talk? :p
 
wim
@piRSquared I'm not sure what the sentiment here is - it's dodgy because you shouldn't mention the tool at all? or that you should mention the tool, unqualified, and charitably assume user can decide if theirs is appropriate usage?
 
Sometimes "use X when appropriate" is the only knowledge you can transfer because the remaining wisdom has to be acquired through painful experience
 
4:51 PM
"A star imports can be used to merge namespaces. If you don't know what that means, you don't need it".
 
I've seen the term "metis" used to mean the kind of knowledge that can't be taught, only learned. It refers to the greek titan of magical cunning.
 
@wim I mean it's tricky. There is a balancing act between informing what tools are available and advising when those tools should be used.
 
Whenever a querent asks "I've read the tutorial and I know every syntactical element of the language. What now?", I think "go forth and acquire metis by means of blood, sweat, and tears" but this is not what they want to hear I think
 
Teaching "when" is a lot more difficult
 
4:54 PM
I'm of the opinion that teaching "when" is literally impossible.
 
Oh, I think stuff like merging namespaces can be taught. It's just pointless teaching it to a raw newbie who's not in the position to start writing multi-module libraries.
 
You may as well try to measure the perimeter of England
 
Chaos will ensue
 
Uh... and ANSI escape sequences, so you need some POSIX
 
thanks PM <3
 
wim
4:58 PM
@Kevin must be the root word (or same root word) of "metier". and maybe "meticulous"
 
Windows users interested in running projects with ANSI escape sequences may wish to pip install colorama, which magically makes command prompts compatible
 
@WayneWerner Coincidentally, a couple of my threading answers use ANSI control sequences, eg stackoverflow.com/a/45164619/4014959
 
Nice!
 
Thanks!
 
wim
@PM2Ring neat (upvoted) but the question doesn't really deserve it
 
5:04 PM
@wim It was mostly an excuse for me to practice using threading. :)
 
wim
every time I need something like this (multiline progress) I can't bring myself to hack it together like that but I also can't bring myself to learn curses
always ends up on the "later" backlog
 
I don't mind doing that low-level ANSI stuff. It takes me back to the old days. :) But even though I've been using ANSI codes for decades I always have to look up what letter does what, apart from the "m" style & colour sequences.
I also like doing stuff related to timers and countdowns. It was more fun on the Amiga, though, directly interfacing with its precision timing hardware. But you can get reasonable results on modern hardware with Python, eg stackoverflow.com/a/51390651/4014959
 
I love ANSI escape sequences
@wim curses is just ANSI under the hood. And requires you to have curses installed (which you probably do, but might not)
@PM2Ring Oh man, that's super cool. I've noticed that timing isn't always precise
 
5:22 PM
ANSI escape sequences plus non-blocking keyboard input detection is a serviceable way to write a quick-n-dirty roguelike. I think many newbies would have a fun time playing with them if they knew what they needed to install and import.
 
@piRSquared they have a question with an accepted answer from 6 days ago, so they are aware of the feature
 
@WayneWerner Precise timing is tricky with multitasking systems. :) But as you see, it's not hard to get fairly precise. Mind you, that timing info was generated on a machine with a fairly constant task load.
 
@AndrasDeak /-: thx for looking
 
I never bothered to learn curses. Raw ANSI 's always been good enough for me. But I never tried doing a huge program with it. That could get messy. :)
 
My experience with curses, which admittedly is pretty small, is that it's not an awful lot better than some threading + ANSI
which is why things like blessings and urwid exist
 
5:29 PM
@PM2Ring a company I worked at, the client always insisted they wanted a time stamp as the ID
 
DST?
 
well, it's a fairly useless primary key :p
 
Mmmmm, get a good leap smear on your bagels
 
cbg y'all
 
5:37 PM
cbg!
 
been out for a little while as I was moving. but now im back with a new job!
should probably update my SO profile...
 
@alkasm congrats :)
 
Pineapple
 
old avatar, new name :P
congrats on the job
 
updooted my profile.
@AndrasDeak yeah. Not sure why I never had "alkasm" here in the first place. It's my public coding-related things moniker in the first place (github, reddit, linkedin, and it was my profile shortcut here too, just not my display...)
 
5:43 PM
@toonarmycaptain I did not. I focused just on the definition of custom arg types.
 
It was actually SO (specifically, from Joel on Software) that got me to started using my real name.
My only problem is that I never realized my github waynew handle could be "way new", rather than "Wayne W"
 
@WayneWerner Oh well, I guess that's better than the haphazard adjustments that were done to keep clocks in synch with mean solar time prior to the adoption of UTC. See "GMT according to many radio time signal broadcasts starting in 1956" at ucolick.org/~sla/leapsecs/timescales.html
@JonClements True. :) And using a local time with DST instead of using UTC can be downright dangerous, or at least very messy, as I've mentioned before chat.stackoverflow.com/transcript/6?m=31580808#31580808
 
I'm gonna smear my seconds like my gran pappy taught me to.
 
6:02 PM
There was some article that talked about how Google has their official time servers - appliances that are probably designed to take into account the theory of relativity
they use GPS and all kinds of other fun and excitement, to give an official Google Time
 
I used to use my real name online - pseudonyms on FidoNet were highly duscouraged, if not downright forbidden, although I don't know how you'd police that. But in the early 2000s I joined a science forum attached to the ABC - Australia's government TV & radio network, which forbade the use of real names. So I've been using PM 2RIng in most online spaces ever since.
 
@WayneWerner inb4 Google gets its own time zone (Google Universal Time)
 
I wonder if they account for how fast I'm driving and differences in simultaneity for people in different frames of reference
 
My pseudonyms started off in online games, and I was never brave enough to use those for stuff like SO.
Or maybe the time has come to rise again as DeathInBathrobes ...
 
@piRSquared No, but they do have to do relativistic compensation for the GPS satellite speed (special relativity), and for the height of the satellite (general relativity). There are some numbers & formulae here: physics.stackexchange.com/questions/1061/…
 
6:16 PM
when I failed miserably at killing people in CS I'd go by MarshmallowBullets
 
6:49 PM
Anyone have any idea what could be preventing Pycharm (technically IntelliJ with the python plugin) from showing those little green "run" buttons next to my unit tests? They show up as expected in 1 of my projects, but are missing in all others
^ those things
 
@Aran-Fey nuh-uh but you remind me that I should probably use PyCharm for more than I do.
 
yeah, having so many features at your fingertips is pretty nice
if I couldn't start a debugger at the press of a button I'd still be using print-debugging ¯\_(ツ)_/¯
 
7:07 PM
Some one posted some Python Practice labs from some website anyone remeber that link?
 
Nothing comes to mind. If you can recall the exact phrasing, you might be able to find it with the search bar in yonder upper-right corner
 
7:30 PM
This question looks like they suffered as much as me trying to watch the latest episode on my phone
 
I could give up and just write the whole program for this guy and it would be ten times easier than explaining what I want him to do
 
@alkasm congrats :)
@Kevin I wasn't following the comments sorry, I just mean the selection of pictures :)
 
wim
who needs metaclasses when you have __new__? github.com/hynek/structlog/blob/19.1.0/src/structlog/…
see github.com/hynek/structlog/commit/… for the inspiration (call stack overhead is expensive in Python)
 
convenience of syntax?
 
people who expect type(TimeStamper()) == type(TimeStamper()) to be true, I guess
 
wim
7:38 PM
heh.
 
I've never had a need to use metaclasses though... I've barely had a need to use class decorators to do a few bits
so while I know what's going on and how it works... just never really needed any of 'em for common tasks
I doubt most of my production code even has a function decorator
 
wim
@JonClements who's a good boy!
 
I've never used metaclasses, possibly because I abandon OOP entirely as soon as it becomes a remotely burdensome abstraction
 
I'm guessing @property doesn't count?
 
wim
you are paying $0 in decorator tax 👍
 
7:42 PM
if it's useful - then use it... but well...
 
If @property is a metaclass or somehow metaclass-adjacent, then no it doesn't count.
 
if it was "that useful" - it'd be builtin
@wim woof woof!? :p
 
wim
what the most useless builtin? probably credits().
 
Python has some "black magic" when you know it... so you can make it pretty much do what you fancy given some caveats... knowing and doing are different things though
 
inb4 "eval and exec have overall negative utility and are therefore worse than useless"
Also inb4 "oh come off it, eval and exec have valid use-cases or else they wouldn't be in the language"
inb4 "[sounds of physical struggle between the above two posters]"
 
wim
7:47 PM
@Aran-Fey hilariously, I never noticed that was a run button
mindblown.gif
 
can't blame you. IntelliJ has so many buttons...
 
wim
did you override the test discovery regex? or did you neglect to name the test test_something ?
 
quit() is the most useless builtin because you can't quit the Python life
10
 
I have no idea where the test discovery regex can be changed, and the tests are discovered just fine if I run a pytest configuration - they just don't have their little green arrows for whatever reason
i.e. pytest recognizes them as tests, but IntelliJ doesn't
 
wim
ugh, when you run the tests with these buttons pycharm uses the wrong working directory (which screws up coverage reporting). annoying.
 
7:54 PM
@Aran-Fey Do you have the directory marked as "Test sources root"?
assuming your tests are in a directory...
 
I tried that, but it didn't help. In the 1 project where it works, the directory isn't marked as Test Sources Root.
 
ok...I'm just making some guesses here
another random suggestion: close the project and reopen it
 
You must join the IntelliJ development team and trick them into fixing the bug
 
reopening didn't do anything. I noticed a detail, though: There's a .pytest_cache folder in the tests directory of the project where it works, while the other projects don't have that cache folder
 
@Aran-Fey that sounds like a pytest thing, not an intellij thing. But intellij might use it if it is there.../shrug
@cs95 my boss threatens to set the pay scale based on lines of code written and jokes that I'd then have to pay him because of all the refactoring I like to do
 
8:28 PM
@Code-Apprentice because of integer overflow? :p
 
Am I going nuts or have all the answers misunderstood this question and gone FGITW? All of them are just dropping data to nan; shouldn't there be some consideration for a trend here and perhaps filling in data with some kind of interpolation/trend?
 
"What I would like to do is remove the 'M' or account for it somehow" they clearly don't know what to do either
unclear
 
That would have been unclear, and I did suggest that they needed to think about how they wanted to deal with that (I was on a phone then). But all 4 answers made the decision for them and, IMO, incorrectly
 
wim
pycharm has "invalidate caches and restart" menu option that makes weird bugs go away for a few days before coming back
 
@cs95 No, because his refactoring reduces the line count.
@Code-Apprentice Any code monkey can add more lines of code, but it takes intelligence to improve code and reduce the line count. So you should get paid at least twice as much for removing a line as you do for adding a line. :D
 
8:45 PM
@wim nothing like an IDE that generates intermittent bugs of its own...
 
@AndrasDeak So that's why you dislike Spyder. It's too consistent with the wonky behaviour.
 
8:59 PM
@PM2Ring Ah. I was thinking of counting the diff. Still a positive number :)
 
9:31 PM
# Any idea why days are wrong in this function?
from datetime import datetime, timedelta
def format_duration(seconds):
    if seconds == 0: return "now"
    d = datetime(1, 1, 1) + timedelta(seconds=seconds)
    t = [t for t in (
            ("year", d.year + d.month // 12 - 1),
            ("day", d.day + ((d.month % 12 - 1) * 30) - 1),
            ("hour", d.hour),
            ("minute", d.minute),
            ("second", d.second),
        ) if t[1] > 0]
    first = ", ".join([
                " ".join((str(a), m + "s" if a > 1 else m))
 
Why the datetime(1, 1, 1) +?
You seem to be computing the "duration" from a date, rather than a time interval?
Or I guess some of that might make sense because the length of the year depends on when you're asking it...so why relate to (1, 1, 1)? In other words, I don't get what you're trying to do in the first place.
 
My goal is to transform a number of seconds into readable time in the format year(s), day(s), hour(s), second(s). But you have right, I did that wrong, I'll check it. Thanks
 
It can't be over any reasonable period
 
What if there is a leap year? You're already going over 4 years, so there's a decent chance
 
9:42 PM
@roganjosh For the purpouse of the task, years has 365 days... always.
 
Plus, it looks like you're approximating months?
 
@roganjosh The task doesn't need months, only years, hours, minutes and seconds
 
@EnderLook also months, I take it? Because then you can just decrement with each large unit.
 
But you have ((d.month % 12 - 1) * 30) - 1)
 
Compute divmod 365 to get the year -> divmod 30 of the remainder to get the month, etc
without months it's even less ambiguous, then you only need worry about leap years and leap seconds
 
9:44 PM
@AndrasDeak Oh, you have right. I had forgotten about divmod
 
and the timedelta will compute a day + seconds decomposition for you, if you wish to use that
 
9:55 PM
@EnderLook the datetime library - while it's better than most inbuilt date/time handling libraries for various languages isn't great... you can do a lot with it... if you want to do serious time/date handling though, I tend to go with the 3rd party dateutil lib
the other day I was trying work out how the heck you do "+2 days" in plain JS...
 
@JonClements Thanks for the advice, but it was just to complete this kata in codewars. I just advance to kyu 5! Now I will translate it into Javascript and then C#!
 
@EnderLook enjoy :)
 
Thanks!
 
If you ever work out how to do (datetime.now() + timedelta(days=3, hours=5)).strptime('%Y-%m-%d') please let me know
 
10:07 PM
@smci I couldn't resist:
Sorry, I can't help right now, but I'll be back. — PM 2Ring 33 secs ago
 
yeah, let's not
 
10:36 PM
@cs95 because of a net decrease in the total number of lines of code in my PRs
 
00:00 - 15:0015:00 - 23:00

« first day (3118 days earlier)      last day (1837 days later) »