« first day (3119 days earlier)      last day (1823 days later) » 

12:04 AM
rbrb
nothing interesting in this half hour :-)
 
Indeed
 
12:28 AM
Can someone help me? It's been a while since I've been trying to ask for help
-1
Q: Reaction embed and edit_message on discord

Lucas TeschMy edit_message is not working, I need it to edit the embed, and return the embed along with the custom reaction, but it is only returning the embed, and the custom reacton remains the old one. import discord @bot.command(pass_context=True) async def test(ctx): embed = discord.Embed(title=...

 
 
1 hour later…
1:42 AM
rbrb
 
 
2 hours later…
wim
3:38 AM
@EnderLook I already wrote that. pip install readabledelta
 
 
3 hours later…
7:07 AM
humanzie offers methods for displaying a 'human' time difference
 
cbg. Please help to close this as duplicate: stackoverflow.com/questions/55932444/…
 
7:31 AM
woot, copying the contents of .idea/my_project.iml from the one project into all others restored my little green arrows
 
 
1 hour later…
8:39 AM
@U9-Forward you spent 6 messages harassing a user who didn't do anything wrong with the rules. STOP THAT.
23 hours ago, by PM 2Ring
@U9-Forward I know you're just trying to be helpful, but when there are ROs active in the room please let them attend to RO duties.
Please apply that ^ to yourself without the "when there are ROs active" part
Regulars enforcing the rules can work if said regulars know how to do it right. You don't.
 
10:06 AM
hi, can anyone help with saving a csv in pandas? im trying to use the following:
data.to_csv(r'D:\E\24monthimport\backup5.csv', quoting=csv.QUOTE_ALL, index=False)
but this gives an error NameError: name 'csv' is not defined
 
import csv
 
ah great! thank you
 
I suspect it's one of the cases where the formal grammar allows something but it's still a syntax error
I hope it's not something dumb, it'll probably be HNQ given a reasonable answer
 
10:27 AM
Interesting blog: Python at Netflix - primarily about use of Python for various (a heck lot of) stuff at Netflix
 
10:44 AM
is a docstring a double underscore method?
 
__main__ is though if I understand correctly?
 
Method of what?
 
OK I'll explain a little more. You can define a docstring in two different ways:
class Foo:
    """Hello World"""

    def __init__(self):
        pass

Foo.__doc__ = 'Hello World'
 
Why would you ever do the latter?
 
10:48 AM
It's a dunder-attribute, but definitely not a dunder-method
 
Thanks, that makes things easier to phrase :)
I want to ask (maybe even on main site) whether it is bad practice to create a custom dunderattribute.
For example if I wanted to create Foo.__path__ I could do the following:
 
It's usually bad practice, and the usual reason is that you'll never know when you'll clash with a future version of a built-in dunder. Why do you need a dunder?
The special thing about dunders is exactly that they usually correspond to protocols, so you rarely want to define one yourself.
 
To specify a path. Foo.__path__ = os.getcwd() ( I know what the output will do)
 
Why not Foo.path?
 
or Foo.__path for extra privateness or something
 
10:53 AM
"or something" was a nice touch :-p
 
PEP 8:
 
Yeah, it's a styling question really, I could also use a variable
 
> __double_leading_and_trailing_underscore__: "magic" objects or attributes that live in user-controlled namespaces. E.g. __init__, __import__ or __file__. Never invent such names; only use them as documented.
 
Ok that takes care of things
Thank you
 
@Simon If it's for styling, try NOT to use any underscores
 
10:54 AM
> The dunder convention is a namespace reserved for the core Python team to implement their own protocols. Never use the namespace for your own, library-specific things! This defeats the whole purpose. If you need to hide a property, use _attribute or __attribute.
from link
 
11:07 AM
Thank you
@AndrasDeak From what you said there. Just one more option to consider:
import os

class Foo:
    def getpath():
        return os.getcwd()
Foo.getpath.__doc__ = "Returns a path (in this case {})".format(os.getcwd())
print(Foo.getpath.__doc__)
You could dynamically generate documentation
 
Ugh
 
Pointless in most cases (more overhead as well), but it does work
 
What if the cwd changes between def and call?
 
Could it? I just tested it, doesn't seem to change path. Guess it might on some systems
 
you can change it at runtime with os.chdir
 
11:17 AM
^
And a method predicting its return value in the docstring ranges from weird to pointless
 
Yeah, it should just be a constant at that point
 
hi everyone
 
Cabbage
I think it's worth a question on main site. I'll need to think up a better example than os.getcwd() though
There are few cases where it is useful, but in some it might make understanding functions easier
 
There definitely are reasons to generate documentation at runtime - dataclasses.dataclass for example can generate documentation for all the methods it creates (and the class itself, too)
 
It seems to be a useful idea at times. Although there is an issue of performance impact.
rbrb everyone
 
11:32 AM
TIL you can subtract dict_keys from dict_values:
>>> {}.values() - {}.keys()
set()
way to hide a bug in my code, python
 
wait, how would that behave for unhashable datatypes
oh okay, just as i would have expected
 
I was staring at this missing = param_map.values() - values.keys() for a solid 10 seconds before I finally realized "no I'm not stupid, that really makes no sense"
 
@Simon and what is the question?
 
Keys views are set-like since their entries are unique and hashable. If all values are hashable, so that (key, value) pairs are unique and hashable, then the items view is also set-like. (Values views are not treated as set-like since the entries are generally not unique.) For set-like views, all of the operations defined for the abstract base class collections.abc.Set are available
 
11:48 AM
Would view be a derived class of sets in this case?
 
Which leads to the slightly weird situation that the items view can be setlike, even though the values view is never setlike.
 
test = {1: 2,
        3: 1}

print(test.values() - test.keys())
print(test.values() - {1,3})
 
@ParitoshSingh Views are implemented at the C level. I think of them as an alternative "window" into the dict's contents. I'm not sure if they're formally a subclass of set, or what isinstance says.
 
Im not able to internalize the difference in the two lines i wrote above. first one works surprisingly, 2nd fails spectacularly.
also oops typo
test.keys() - {1} #works just fine though
Okay, isinstance is false for both keys and values though(against set). thanks for pointing it out, slipped my mind
 
keys() is set-like after all, so it's no surprise that set-subtraction works. The question is really only why dict_values - dict_keys works
 
11:56 AM
aye
 
>>> {1: 1, 2: 1}.values() - {1:1}.keys()
set()
>>> {1: 1, 2: 1}.values() - {}.keys()
{1}
>>> {1: 1, 2: 1}.values() - {1:1}.keys()
set()
>>> {1: 1, 2: []}.values() - {1:1}.keys()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unhashable type: 'list'
>>> {1: 1, 2: []}.values() - {1:1}.values()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for -: 'dict_values' and 'dict_values'
nothing makes sense
 
Bear in mind that the operator versions of the set operations behave slightly differently to the method versions. The operators are strict, the methods accept any (suitable) iterable, and IIRC none of the methods need to build a set out of the iterable in order to perform the operation. So when you do some_set.union(a), a can be a list or gen exp.
@Aran-Fey Yeah, that one puzzles me too. :)
 
oh, i think they build a set object under the wraps
this came up a couple days back
one sec, let me see if i can find it..
The Question was for symmetric difference though, i wonder if union implementation is different. link to code
i think this is the right section for union? Im still not too comfortable reading through source code. But looks like its happy with the 2nd argument as iterable
 
I don't know where in the source code the magic happens that converts the operator versions into method calls.
 
12:16 PM
@kevin: See this beautiful fractal here reddit.com/r/Python/comments/atffg8/…
 
12:41 PM
cbg for few mins
 
1:05 PM
cbg
Off topic: People who don't tell the school nurse about field trips for entire grades until 30mins deserve worse than people who spoil Marvel movies for those standing outside the theatre.
 
@toonarmycaptain Throw everything you've got in a duffel bag and pray that you have enough Band-aids to get them all back in one piece :)
 
1:43 PM
Are here by any chance some dask users online ?
 
please read the room rules
 
Where ?
 
top right
 
On mobile as well ?
 
that I don't know
 
1:49 PM
@IvoLeist Unfortunately, no.
 
But you can switch the mobile view to the full site view
 
On mobile, you can get to the Info page from the hamburger menu, and it has the URL for the room rules, but it's not clickable. We can't do anything about that.
 
@wim Great!
 
Ok thank you for linking the rules and sorry for the spam! Do I maybe need to rephrase my question that it gets more attention ?
 
@Dodge I know with certainty that if I do that, a kid staying on campus who has an epi pen will need it today.
 
1:52 PM
@IvoLeist Thanks for your understanding. Your question looks ok to me. But it's only an hour old, and it's still fairly early in the USA, so you may get more views on the question over the next few hours.
@toonarmycaptain It seems odd to me that the school allows field trips without informing the nurse before the trip gets the go-ahead.
 
Haha thats a good point anyway thank you for having a look at it.
 
@PM2Ring what's also odd is that we have fire extinguishers and defibrillators mounted on walls in public places across the country but not EpiPens.
 
Quite a few of the room regulars know Numpy to some degree, and there are several who often answer Pandas questions, but I don't recall dask being mentioned here much. But I think there's 1 guy who knows something about it... OTOH, I assume that dask experts on the main site check the tag regularly.
 
never heard dask mentioned here
 
2:07 PM
@PM2Ring ...they're suppose to. Like weeks in advance. I'm a float, so I'm often different places, but they only let my supervising RN know yesterday afternoon, so I only got the message this morning.
@Dodge I'm actually pretty excited that our school district got a Dr to sign off on us having an open prescription for epis (nice yellow box on the wall) and albuterol to use as necessary.
 
@toonarmycaptain I bet you'd be popular if you tried to cancel the trip...
 
Oh, right, epi pens are like what, $600 each...people would be pinching them and/or unnecessarily using them all the time.
 
@Dodge Maybe they're worried that some people will try to get high on the epinephrine.
 
@PM2Ring I've done that once. Well, delayed, not cancelled. I told the principal (reasonably truthfully) that they couldn't leave until I was ready with their stuff, and that there was a decent chance students would need to be hospitalised or worse if they didn't have their medicines (read PreK diabetic who doesn't verbalise she's not feeling good).
 
PreK == pre-kindergarten?
 
2:15 PM
@PM2Ring Yes.
 
I've touched dask once. It doesn't suit my purposes well but I might have a shot at being able to answer a question about it.
Oh... I've looked and maybe not.
 
@toonarmycaptain yikes
 
2:58 PM
hi !
i need help with dateutil parser please
 
3:24 PM
is there a way to know the format of a given date in parser before the string converted into a date ?
 
@HarvesterHaidar Yes, with code.
 
you mean to modify the parser class ?
 
3:35 PM
there's no way to know the format of a date just by looking at it, no
you need to know the format beforehand
or guess
 
3:50 PM
some formats are more obvious and the date they represent can make it easier or more difficult
Hard: 010101
 
@HarvesterHaidar 040404 is what date? DD-MM-YY or MM-DD-YY or YY-MM-DD?
 
easy: 20191231
having multiple dates, you can start to eliminate possible formats until only one works for all your dates
But this absolutely stinks if you have many dates and the varying formats are not uniformly distributed through your data
Or even worse is if you can't trust that there IS just one format
All this said, it is far far... far better to know the format ahead of time
 
It gets even more complicated when you consider that 101010 could be the original Roman calendar with 10 months <- not a non-issue if you've ever tried to analyse old dates from various cultures. Which, thankfully, I've never done programmatically.
46(?) BC was especially fun...15 months and 400+ days, because they were going from one calendar to another and had to make it line up.
 
the dates are valid . i check one step a head
i am looking at parser.parse() when it converts a date and returns it in the one and only format (%Y-%m-%%d)
there must be a way in the code that in some stage only when finding on any side of the separator a number which is greater than 12 to "sense" it is a day
but before the conversion happens , can't i modify the code to tell me which side the day is then the month ,,,,
 
wim
@Aran-Fey well, why not? the analogy would be just subtracting a set of tuples from a set of keys.
 
4:07 PM
a set? why would dict_values behave anything like a set?
and if there's a reason why it does, why doesn't it let you subtract real sets?
 
wim
dict_values is supposed to be set-like, if all values in dict are hashable
why you can't subtract real sets I don't understand. that is a bug imo.
 
...and if there are duplicate values?
 
wim
doesn't matter
ohhhhh
values
sorry I was thinking items
(where uniqueness comes from the key)
I actually have a question about this edge case, let me find it.
 
they're using tuples in the parser class when it comes to %B and $b for example
 
wim
TL;DR making the values object behave set-like would means hashing the values (expensive)
for dict_items it's a non-issue because they are hashed of the dict keys
 
4:15 PM
are they?
>>> {1: []}.items() - set()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unhashable type: 'list'
 
Does that explain why you can subtract .values() from .keys()?
 
nope
 
wim
@Aran-Fey hmm, IIRC it was some sort of key-based hash (but, not exactly the hashes of the keys, of course)
 
@Aran-Fey while {1: 1}.items() - set() does work. Seems to break when you expect it to
 
wim
or I could be smoking crack
 
4:21 PM
just like set([(1, [])]) breaks as we'd expect
Treat it like a set and it attempts to make it a set and if it can't /boom
 
Yeah I incorrectly drew the conclusion that dict_items hashes the values, but in reality that's the set generated by the - operation
 
5 hours ago, by PM 2Ring
Keys views are set-like since their entries are unique and hashable. If all values are hashable, so that (key, value) pairs are unique and hashable, then the items view is also set-like. (Values views are not treated as set-like since the entries are generally not unique.) For set-like views, all of the operations defined for the abstract base class collections.abc.Set are available
Note the bit that says If all values are hashable
 
wim
>>> class SeeHash:
...   def __hash__(self):
...     print("hashed!")
...     return 12345
...   def __eq__(self, other):
...     return False
...
>>> x = SeeHash()
>>> {1: x}.values()
dict_values([<__main__.SeeHash object at 0x7fffe46e5630>])
>>> {1: x}.values() - set()
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-15-bcf334402aa1> in <module>
----> 1 {1: x}.values() - set()

TypeError: unsupported operand type(s) for -: 'dict_values' and 'set'
seems to be hashed at time of use
 
@Aran-Fey Did you figure out your PyCharm testing issues?
 
if you have time to look at this answer i'm trying to apply the second answer but too complicated for me
 
4:24 PM
@Code-Apprentice yeah!
9 hours ago, by Aran-Fey
woot, copying the contents of .idea/my_project.iml from the one project into all others restored my little green arrows
dang, that was 9 hours ago? I still haven't made any progress debugging all of these issues I found...
 
@Aran-Fey huh...but they are all different projects, right?
 
yeah, but there wasn't anything project-specific in it
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
  <component name="NewModuleRootManager">
    <content url="file://$MODULE_DIR$" />
    <orderEntry type="inheritedJdk" />
    <orderEntry type="sourceFolder" forTests="false" />
  </component>
  <component name="TestRunnerService">
    <option name="projectConfiguration" value="pytest" />
    <option name="PROJECT_TEST_RUNNER" value="pytest" />
  </component>
</module>
 
ok, that makes sense
 
some of them were JAVA_MODULEs >_>
 
wim
@AndrasDeak pretty interesting one
 
4:27 PM
so alternatively you could probably just delete the .iml file and open the project again (or maybe you have to create a new IntelliJ project).
 
could work
 
I'm glad that you figured it out
 
4:44 PM
would you kindly have a look at the second answer
https://stackoverflow.com/questions/26238159/guessing-date-format-for-many-identically-formatted-dates-in-python
i'm trying to figure out how to employ this
 
wim
@Aran-Fey want to ask it on main? if not, mind if I do?
 
nah I've got other stuff to do. Go ahead
 
@wim Looks good to me.
 
5:40 PM
cabbage
my last final is in a couple of hours
 
good luck cbg
 
5:57 PM
thanks B)
 
good luck coldspeed
 
thanks piR :)
 
6:28 PM
good luck
 
Good luck
Does anyone know of an ISO certification that applies specifically to software quality?
I've been given some vague indication that my software will be part of an ISO (I assume 9001) audit and that I need some kind of versioning and manuals but then it was just left at that and they couldn't give me more details. I don't really know what is supposed to be in place.
My guess is just that the auditors would be more interested in the purpose of the software considering it's in manufacturing but <shrug>
 
6:57 PM
Mmm, ok, it is a thing
 
7:49 PM
@cs95 I'm sure you'll do well.
 
8:00 PM
@roganjosh sounds like fun
</sarcasm>
 
wim
@Aran-Fey look, a new empty set literal syntax {} - {}.keys()
 
oh wow
I'll stick with set() I think :P
 
(d:={}) - d.keys() might be more memory-efficient
 
aww, SQ is down during their earnings call this afternoon ;-(
 
SQ?
 
8:16 PM
@wim @Aran-Fey @AndrasDeak {*[]}
or {*{}}
 
{*''''''}
 
(s:={0}).pop()
 
{*''}
 
{*''''''""""""''''''}
 
@Aran-Fey that's weird
 
8:18 PM
is it too short?
 
@AndrasDeak see the link
 
I don't see why it should work. On mobile right now.
 
string literal concatenation
>>> {*'a'"b"}
{'a', 'b'}
 
aaaah, I missed the count, thanks
parsed it as 3 + 6 + 3
 
your parser has some bugs in it
 
8:20 PM
yup
 
needs better OCR :P
 
@Code-Apprentice it must be like the matrix :P
 
@Code-Apprentice The more I've looked into it, the worse it seems :(
The company itself, though, gets the accreditation and I'm a contractor, so I guess the burden is mostly on them to make sure they got someone to push their development forward.
 
@roganjosh One of my primary projects requires GxP validation. I get to help with some of the documentation for it. Fortunately I'm not the one preparing the entire thing.
but even so, it makes it so I can't do all of the refactoring that I wish because that entails extra documentation that we don't have the time to do.
 
8:41 PM
@Code-Apprentice so that's...literally a google search for "sq"?
 
@AndrasDeak yes. that typically works for any stock symbol
which is why I gave the link. After my first comment, I was pretty sure that there are some room members who aren't familiar with stock symbols or wouldn't immediately make the connection.
 
unorthodox idea: "SQ (the stock)" ... :P
 
Searching "ISO 9001 software" actually gave me what, I think, was my first 500 error from Google :P
It worked the second time, though. Maybe that's a pass
 
8:56 PM
that's 250 on average
(I know OK is not 0 but I don't know what it is and I'm too lazy to look it up :P)
 
I did have to look it up, but the average is still "success" if nothing else :P
 
9:17 PM
@AndrasDeak 200
 
9:29 PM
Is deleting failing tests an acceptable fix? I mean they don't fail no more if they don't even exist...
 
Yes if you delete your userbase along with your tests
 
wim
10:16 PM
@Code-Apprentice ouch :(
 
 
1 hour later…
11:25 PM
cbg
 
11:52 PM
This time range is pretty quiet
 

« first day (3119 days earlier)      last day (1823 days later) »