« first day (3296 days earlier)      last day (1643 days later) » 
03:00 - 21:0021:00 - 23:00

wim
3:59 AM
@Kevin regarding gist.githubusercontent.com/kms70847/… ... you shouldn't have an __init__.py in the project root. i.e. the directory which has the setup.py in it should not have an __init__.py adjacent.
 
4:27 AM
FWIW, one of the Google guys involved with the quantum supremacy thing is a Stack Exchange member, and a regular in the Physics chatroom, Daniel Sank. I expect that he'll be posting info about it when he gets a chance.
 
 
1 hour later…
5:36 AM
@wim I'll assume that's a rhetorical question. ;) I discovered that he doesn't appreciate being corrected in comments when I was still fairly new to SO. Just post a competing answer. I wouldn't call him incompetent, exactly, but he does spread a lot of misinformation.
@AnttiHaapala Yes. It's called FPE: Format Preserving Encryption; that Wiki article has expanded quite a bit since the last time I read it.
@Skyler Yes. See my previous message to Antti. Here's an example using a Feistel network: stackoverflow.com/a/51429458/4014959 You may be able to use something simpler & faster if you don't need the output to be very random. Or you could reduce the number of Feistel rounds in my code to get a small speed increase.
 
jie
6:06 AM
有人吗?
 
@jie the gallery underneath the room description on the right shows who is currently in the room, but I'm guessing there is nobody here who can read your language
 
6:21 AM
Hi, @jie. I guess you are just saying hello, but on the English-speaking parts of the Stack Exchange network we are supposed to use English. Moderators don't like it when they can't read stuff. :)
 
Rob
ಠ_ಠ
 
jie
ok
 
6:45 AM
@Code-Apprentice Simple shortcut file that links to a web address. For example:
[InternetShortcut]
URL=fileinfo.com/extension/url
 
jie
what this?
 
@jie Reply to an old reply. Was looking for a MIME type for a URL file.
 
jie
@akinuri not familiar with it
no one want to talking?
 
7:09 AM
@jie It's still early for the Europeans, and very early (or very late) for the Americans. So the chat room is quiet at this time of day.
 
7:20 AM
@akinuri That's just text, so text/plain is ok. If the URL isn't plain 7 bit ASCII, you should also specify the encoding used. Really, URLs should be plain ASCII, with any non-ASCII chars percent-encoded, but these days just about everything should handle UTF-8.
 
7:30 AM
Yay! The PIL / Numpy bitmap bug has been fixed (allegedly). See stackoverflow.com/a/50134667/4014959
 
@PM2Ring Nope :) I have a chrome extension and it was using data:text/plain for downloading a file, and I could set custom extension in the filename (i.e. .url), but not chrome doesn't respect the extension in the filename, so I had to change text/plain to something more related to URL files. This is the previous code:
chrome.downloads.download({
    url      : "data:text/plain;charset=utf-8," + encodeURIComponent("[InternetShortcut]\r\nURL=" + activeTab.url),
    filename : stripInvalidChars(activeTab.title) + ".url",
    saveAs   : true,
});
now*
 
jie
@PM2Ring ok, my clock here is PM 3:42
 
I've checked the media types on iana.org, but there doesn't seem to be a type for Internet Shortcut (URL file).
 
7:48 AM
@akinuri You didn't say this is for a data URI. ;) I think that looks ok, but I haven't played with data URIs for a few years. I mostly use base64 on my data URIs so I don't have to worry about special characters.
@akinuri I also checked IANA before my 1st reply to you.
Are you expecting Chrome to open that .url file & navigate to the URL it contains? Or do you just want it to save the file?
BTW, that code looks suspiciously like JavaScript, not Python... ;)
 
8:16 AM
@PM2Ring Haha. I know :) My chrome extension didn't work as expected yesterday, and was in a hurry to fix it. Problem was related to MIME types and this was the most crowded room then. Guilty :)
 
8:34 AM
When sklearn.model_selection.train_test_split has been used (with the shuffle option being the default True), is there a way to say where(in which one of the two splits) each row has ended up?
 
9:33 AM
cbg, all
 
@aderchox looking at the docs it doesn't seem like there's a way
 
@wim I wouldn't mind some gossip on that. Always wondered what the problem was with making it official in 3.6 -- seeing how there appear to be basically only CPython and PyPy these days.
 
10:17 AM
Not wanting to send a bad message to other implementations?
 
10:34 AM
14 hours ago, by Andras Deak
no MCVE, or no repro https://stackoverflow.com/questions/58548284/how-to-multiply-list-items-together-in-python/58548316
still needs that one vote ^
 
got it
 
thanks
 
11:05 AM
I'd like to avoid doing so much work with quotes and shift keys (to get :) when defining a dictionary. Is there a more elegant alternative to this:
def d(**kwargs):
  return kwargs

print(d(x=1, y='hi')) // {'x': 1, 'y': 'hi'}
I could lambda it, but I don't think that's any more elegant, although it would be a single expression and wouldn't pollute the namespace: (lambda **k: k)(x=1, y='hi')
I'm hoping there's some syntactic sugar I'm not aware of
my specific usecase is a json api, that often has 1-nested objects
ideally I'd have something like send_response(success=True, msg='hi', meta=(time='some time'))
 
@towc d = dict?
dict(x=1, y='hi')
 
damn
foiled again, thanks
 
no problem
But you can't have non-string-valued keys that way. Just for completeness' sake.
or non-identifier-valued keys, to be precise
 
that's fine, it ends up in json anyway
 
yup, I figured
 
11:35 AM
@AndrasDeak just wondering which ones these actually are. PyPy is conformant, Jython seems stuck in 2.7 and IronPython already had some strange peculiarities for builtin types last time I checked.
 
Where's micropython?
 
as much as I like MicroPython, it is far, far away from being compliant.
 
I see
 
hm, interestingly enough dict is not among the builtin types that differ in micropython.
 
12:05 PM
@wim Thanks, edited. Now that it's letting me modify gists again, I guess I should go back through the transcript and figure out how I should be capitalizing the project and module name, too
 
cbg
 
12:36 PM
I posted a "unit tests I need someone to write" list on the pyparsing wiki yesterday for new contributors to work on. Is there a simple and lightweight way to convert these to a to-do list so that multiple new people don't work on the same test? Preferably using some GitHub feature I haven't seen yet. And that does not require adding them the dev team, or opening up the wiki to public updates (which would be the simplest, but I just checked and I don't see where to do that either).
 
I thought wikis could only be publicly editable
 
After two minutes of googling all I could find was github.blog/2013-01-09-task-lists-in-gfm-issues-pulls-comments, which is neat, but appears to just be fun syntactic sugar on top of editing an issue description. So this probably falls afoul of "must not require special permissions"
The nuclear option is to go outside the github ecosystem and make a google doc where people can call dibs on tests
 
or a trello board
 
12:51 PM
Or a Fight Club
 
@PaulMcG the github project board won't do?
it's a kanban
 
Kanban? I think that guy goes to my Fight Club.
 
your fight club is better organized than ours, we just do free-for-all
 
@Arne Thanks, this sounds promising. @Anarach from yesterday who was looking for a project to pitch in on can by my guinea pig test subject
(How do you strikethru text again?)
 
---triple dash---
 
12:56 PM
strike
it was a lie!
 
I'm going to wager it's actually triple dash
 
Mhm, triple dash got it
 
it's still in the chat faq/help
 
I'd be tempted to write a userscript that makes buttons for all markup options, but that would simply replace some "how do I strikethrough again?" questions with "where can I get Kevin's userscript?" questions without reducing the frequency
 
1:01 PM
@PaulMcG There is some simple automation you can do with it as well, like moving issues to the "in progress" column when an assignee is added and to the "closed" column when it was closed. I'd also suggest signing the project up for the github actions beta, which can handle more fine-grained things
just for curiosities sake, do you have an IRC or something like that where I can idle in just in case I was considering to contribute?
 
There is a pyparsing subreddit
Which I would love to see get more traffic
 
thanks, I'll take a look
 
I've picked up a couple of active contributors lately, helping me with some major refactoring and code cleanup and Py3 upgrading/Py2 bottom-of-shoe-scraping
After it being just a personal project for so long, its taking some getting used to
 
The problem is someting else then I initially thought
 
I agree with the final commenter that the main problem is that your first two rows have a different format than all the other ones. 07-10-2019,12:45:17 and 07-10-2019,12:45:00 use hyphens, and all the other ones use slashes. If that's the source of your problem, I don't know if there's much point in reopening the post, since it might just get closed as a typo instead
 
1:11 PM
It's not my question. I want to answer the question, the last comment is mine
I think the solution is to first mask the first two rows, and append them back later when converting to datetime with different format.
 
Oops, I misread it, then
If you have an answer ready to post, then I'm satisfied that the question is answerable. Voted to reopen.
Unrelated topic:
thanks a lot guys. The only information I have is — Carsten D 1 min ago
Poetry.
 
@Kevin Yes just answered it. Thanks for reopening
 
1:27 PM
@Kevin :) I suspect that the timestamp is an unsigned 32 bit int, which narrows it down to 2 choices.
 
I'm writing a brute forcer that tries all combinations of signedness/endianness, but it's failing because datetime.datetime.fromtimestamp(-86443904) gives me an OSError
I'm guessing this means it's out of range. I wish there was a "parse anyway even if it can't possibly fit in an actual POSIX timestamp" parameter I could set to True.
Oh well, I'll just catch and print a warning. pastebin.com/cYsPxhFy shows that no possible combination gives a datetime anywhere close to the present
I'll go into maximum overrustle if the OP says "oh, I just made those numbers up. My real data is <insert two ints here that give a sensible datetime>"
 
1:57 PM
OP acknowledges that it's strange for the timestamps to be a hundred years in the future, and that there's something fishy with their data. As long as they're not making it up themself, I'm good with that.
 
Hi, could anyone look at this question? stackoverflow.com/questions/58553577/…
 
I can't troubleshoot very extensively, because my firewall won't let me access the target site, but my advice is: try saving or printing response.content somewhere so you can manually verify that it looks like what you expect
For example, if it turns out that there's no element with the class form-control ng-pristine, then that explains why you're getting None. Then you can look at the rest of the page for additional clues. Divs containing error messages, that kind of thing
 
@Kevin A 32 bit unsigned int timestamp with millisecond precision can only cover 7 weeks. Pity the OP can't give us any more info about the sensor...
 
Hmm, true. Just for good measure, I'll add a precision field to my brute forcer. I get a lot of datetimes within 7 weeks of 1970 Jan 1, just as you say. So we're still nowhere near the present
 
2:16 PM
cabbage
Super pleased with myself: couldn't work out how to restore double-click functionality with my scripts, so I wrote a bat file to launch the one that I was aiming at.
 
@Kevin It's not that kind of timestamp. It's more like the counter on old audio & video tape players. It possibly resets itself to zero when it's rebooted.
OTOH, that doesn't explain why both 16 bit fields are currently negative, unless it's been running for a month or so.
 
I wouldn't expect the actual information to be a signed number at all.
 
2:34 PM
If it's a "relative" timestamp with millisecond precision, then the smallest positive interpretation I've found, 2163792122, corresponds to 25 days 1 hour 3 minutes and 12 seconds.
 
2:45 PM
Unrelated topic. I occasionally see questions like "how come print(x,y,z) has a different result than a = x,y,z; print(a)?" and it makes me wish there was an argument-concatenating function that behaved identically to print except it returned the string instead of printing it.
Then we could say "just change your code to a = compose(x,y,z); print(a)" and be done with it, without having to explain the semantics of parentheses-free tuple literals for the Nth time
"Just change your code to print(*a)" is cheating, obv
And impractical besides, since explaining argument unpacking is even more fraught then explaining tuple literals
 
Well, newbies have to learn about tuple literals, and about arg unpacking at some stage. ;) But yeah, I did find it odd when I first started on Python that it didn't have an equivalent to sprintf. OTOH, I was rather shocked that print was a statement instead of a function. That seemed like a large step backwards.
 
Maybe the next time the devs have a backwards-incompatible version schism, they can change str() to take an arbitrary number of arguments and concatenate them together. encoding and errors will have to become keyword-only args.
Or, hmm, that's just kicking the can down the lane, since you still have to do str(*a) that way...
Unless you do a = str(x,y,z) from the beginning. But then we'll get questions like "how come a = str(x,y,z) has a different outcome than b = x,y,z; a = str(b)?"
 
You'd also want a sep arg. But then you're virtually cloning print. You might as well just write a wrapper around print that uses a StringIO or a BytesIO for the file arg...
 
import io
def sprint(*args, **kwargs):
    out = io.StringIO()
    print(*args, **kwargs, file=out)
    return out.getvalue()
Python devs, please add this to the stdlib
 
3:03 PM
@Kevin Yep, like that. :) Although you may want to filter out file if it's in kwargs.
 
I hoped that the explicit file arg would overwrite any file arg in kwargs, but now that I try it out I see it crashes with got multiple values for keyword argument 'file', so yeah I guess I better filter.
 
Or just catch that error and raise a different one.
 
3:19 PM
Maybe it is a timestamp. We now have a lot more bits, more than enough for 2 timestamps...
-1720 -1292 -476 -744 -1752 -1404 -492 -752 -1824 -1360 line separated which should result in a current date in ms — Carsten D 16 mins ago
 
I found a question on the main site that I think I can solve with pyparsing. I just need to define a rule equivalent to 'an IDENTIFIER is one or more characters other than any of "{}[]:,"'
pp.OneOrMore(pp.NotAny("{}[]:,")) doesn't do it, I think, as it's been running for a minute or so without a result
 
> NotAny - a negative lookahead expression, prevents matching of named expressions, does not advance the parsing position within the input string
Yeah, you'll be waiting for a while (:
I think you want CharsNotIn('{}[]:,')
 
Thanks, that helps. CharsNotIn gives me sensible looking data.
 
Geez, I turn my back and you guys start diving right into my backyard pool!
Compare with Regex(r"[^{}[]:,]+"), I think this will be slightly different - should skip leading whitespace, for instance, whereas CharsNotIn doesn't
 
3:35 PM
The main site question is stackoverflow.com/questions/58561257/… and OP wants to parse mangled JSON that doesn't have any quote marks. By hijacking pyparsing's json example, I've gotten as far as pastebin.com/s6uiA1Lu. Now to make it into a collection of regular dicts and lists and strings.
 
I think results.asDict() might do a lot of that for you
 
I think it gives me exactly what I'm looking for :-)
Well, maybe not exactly.
{'source': 's3', ' aws_access_key_id': 'myaws', <rest of data goes here>
                  ^ problem
If I exclude spaces with jsonString = pp.OneOrMore(pp.CharsNotIn('{}[]:, ')), I get a ParseException. Hmm
Maybe there's a "strip whitespace" parse action I can use...
jsonString = pp.OneOrMore(pp.CharsNotIn('{}[]:,')).setParseAction(lambda s, l, t: s.strip()) good enough, time to ship
Whoops that just gives me one big string, time to unship
 
I think you might want to swap jsonString | jsonNumber <- those two. I think that'll parse numbers as strings, since every number is also a valid string
 
Ok, I'll do that.
Ah, I guess setParseAction should return a list...
Ok, posted for real this time. But alas, the accept has already been claimed by a regex approach
Oops, OP edited their input string and now I have to support set literals
Uhhhh. This is a little harder than parsing quoteless JSON now.
 
3:59 PM
If it invalidates any existing answers, just roll it back to the old version
 
I added jsonSet = pp.Group(LBRACE + pp.Optional(jsonElements, []) + RBRACE).setParseAction(lambda s,l,t: set(t[0])) and I think that does the needful
The other positive-scoring answer uses ast.literal_eval so I think it was already able to handle sets
My work here is done. Kudos to PyParsing for eventually producing a functional solution even though I only read 1% of its documentation.
Very few third party libraries reach such a high bar :>
 
4:44 PM
I'm reading someone's code
What does this part do?
class Vector:
	"""
	A generic 3-element vector. All of the methods should be self-explanatory.
	"""

	def __init__(self, x=0, y=0, z=0):
		self.x = x
		self.y = y
		self.z = z

	def norm(self):
		return math.sqrt(sum(num * num for num in self))

	def normalize(self):
		return self / self.norm()
...
	def __iter__(self):
		yield self.x
		yield self.y
		yield self.z
My focus is on the normalize function, but I have included everything necessary to understand what the author included
Normalize returns self over the square root of the sum of the squares of the x, y, and z coordinates, but what is that bare "self"?
It's not "sum(self)" or anything.
 
I don't understand what you don't understand, since you clearly understand that for num in self loops over the coordinates
 
I understand the denominator of the return value of normalize()
But I do not understand the numerator
Precisely because it is not iterated over
 
Does the class have a __div__ or __truediv__ method? I don't think that line makes sense otherwise
 
...oh.
def __truediv__(self, other):
return Vector(self.x / other, self.y / other, self.z / other)
 
You might already know this, but "normalize" in the context of vectors means "find a vector with the same direction as this one, but with magnitude 1"
So that might give you an idea of what the code's trying to do
 
4:53 PM
I don't. I wanted to read the source of a raytracer to find out what a raytracer does.
 
oh, I was looking at norm instead of normalize
 
On the other hand, I just now learned how to use iter
 
if a ray tracer could chuck wood like a wood chuck could... oh... wait... wrong one :p
 
It's sort of like that one story where a guy proves himself to be from the future using a proof of some troubling theorem that can be easily understood and cross-checked in just five or so lines
Kevin, when you say "find a vector," do you mean make a vector? Or look for an already existing one?
 
"Find" in the sense of "derive mathematically". In programming terms, you're making a new one.
 
5:02 PM
Cool
Thanks
 
"some troubling theorem that can be easily understood and cross-checked in just five or so lines" -- reminds me of the real-life anecdote of the mathematician who spent like ten years trying to find the two factors of a very large semiprime. He finally finds it, and he publishes his proof, which is just "<a lot of digits> * <a lot of digits> = <the very large semiprime>"
Ten years to solve, thirty seconds to confirm correctness
 
The number of people who want to use type annotations for things that aren't types is too dang high
"what's the annotation for a list with exactly 4 elements", "how can I annotate that the object has to have an x attribute"
 
I agree that that is not what type annotations are for, although I understand the desire for something like type annotations, which would be able to do that
 
static typing is just half-assed contract programming
 
5:17 PM
the collections.abc module is already kind of a concession in that direction. Hashable isn't a real type, it's just another way of saying "the object has a __hash__ attribute"
(big oversimplification but you know what I mean)
 
anyone got film suggestions?
over dinner
any genre
even conference talks
 
I was gonna say "I want to eat your pancreas", but then you said "over dinner"
so.. probably not
 
not that good looking :/
 
that's a great name
 
@towc not sure... I'm just having a poke around netflix myself... might just be boring and go for some Star Trek stuff
 
5:21 PM
oh, maybe I should get started on that procrastination train
I've never watched any star trek
and there's so much material
but I don't want the procrastination train :/
@JohnnyApplesauce I really don't recommend trying to learn what a geometry-heavy algorithm does by reading source, unless it's very heavily commented
 
Yesterday I enjoyed the coherent half of Netflix's Sound & Fury. The more abstract chapters I could have done without.
 
heh... stepping down as mod appears to have been a rather weird way of getting 3 gold badges on MSO... also until anyone else ruins it, a rep of 107,107 is kinda funky
 
is IT any good if I haven't read any of the novels or watched the first movie?
 
Road Warrior-esque hero journeys through the wasteland on a righteous mission --> good
anonymous figure skateboards through an empty Tokyo picking up vintage toys --> uh, ok...
Robot sprints through an abstract void and gets an elaborate hat --> you lost me.
 
@JonClements oh wait I just noticed. What happened?
is this about reinstating Monica?
 
5:26 PM
@towc not sure - haven't seen IT... it's actually one of my favourite King books
 
Hello everyone! This is my first time using python Chat
 
welcome!
 
thank you!
 
@towc nothing to do with Monica, no... just something I've felt for years and it seemed like while not the best of times to do so, it was as good as any (ref: [meta.stackoverflow.com/questions/390525/…)
 
those 4 off-topic votes though...
 
5:30 PM
oh, sad to hear. How many mods are left anyway?
like, 2?
:P
 
I am not sure if this is the right place to ask, if not so sorry. I am having a difficulty converting a matrix to a vector, here is my question(stackoverflow.com/questions/58562141/…) can anyone help me?
 
@towc lol... nope - you've still got 21 :)
 
@Kevin From en.wikipedia.org/wiki/Frank_Nelson_Cole On October 31, 1903, Cole famously made a presentation to a meeting of the American Mathematical Society where he identified the factors of the Mersenne number 2^67-1.
During Cole's so-called "lecture", he approached the chalkboard and in complete silence proceeded to calculate the value of M67, with the result being 147,573,952,589,676,412,927. Cole then moved to the other side of the board and wrote 193,707,721 × 761,838,257,287, and worked through the tedious calculations by hand.
Upon completing the multiplication and demonstrating that the result equaled M67, Cole returned to his seat, not having uttered a word during the hour-long presentation. His audience greeted the presentation with a standing ovation. Cole later admitted that finding the factors had taken "three years of Sundays."
 
@Verbamore We usually like to impose a waiting period of a day or so before allowing question solicitation, but I think we can let this one slide.
 
too bad nobody took a photo of the board :/
 
5:35 PM
@PM2Ring Exactly the anecdote I had in mind :-)
@Verbamore Can you include the contents of the csv in the question? I'd like to play around with the data
 
sure, thank you @Kevin
 
In Ancient Times, the moderator of the C_Echo on FidoNet was named Fred Cole. I wondered if he was a relative of Frank Cole, but I never got around to asking him.
 
5:49 PM
@Kevin
I just added a drobbox link
 
Ok, thanks. For future reference, if it's a really small file, it's fine to just paste the contents straight into the post
 
@Aran-Fey close and reopen? Are there enough 3k+ users here now?
 
<- one
 
6:05 PM
Ok, voted
 
thanks
 
Number of times this year I've tried to solve a pandas problem by iterating over each row, only to discover that I have no idea how to do this: 4
 
@Kevin Just got back from lunch - intuitive client-side API was a big part of my goals for PP, glad it made sense to you (sadly, this may mean that we think alike...)
(sadly for you, I mean)
 
I assume row iteration has been hidden in the locked filing cabinet behind the door marked "beware of leopard" in the subbasement whose staircase was removed, because anyone using pandas for an actual sensible purpose avoids python-level loops like the plague that they are
I was surprised when my PyParsing solution didn't crash on the input s = "{1, [2,3,4], 5}", and instead returned a set containing two ints and a pyparsing.ParseResults. But AFAIK the code works fine if a set contains only strings, and that's really the only logical use case anyway, so I'm going to file this under "undefined behavior"
 
6:23 PM
@AndrasDeak Open
 
thanks
 
I was busy reading the comments on Heather's latest: meta.stackexchange.com/q/336731/334566
 
Hmm, s ='{a: {b, [1,2,3], c}}' runs and returns {'a': {'c', 'b', ([1, 2, 3], {})}}, but s = '{b, [1,2,3], c}' crashes. Now I'm double surprised.
Might need to actually read the manual for this one.
 
6:37 PM
@PM2Ring good one, I've only seen the letter from them so far
 
6:49 PM
python amazon-elastic-beanstalk waitress hug <- probably the craziest combination of tags I've seen so far
 
Ok, now that I've actually read the manual, I'm pretty sure I'm not using setParseAction for its intended purpose
 
@Aran-Fey it's nicely ambiguous because python + amazon sounds like rainforest, but amazon + waitress sounds like feisty lady
 
I'm guessing there's no easy way to determine which rule is being matched by a ParseResults, since the rule name only exists as a Python variable name
 
if only this were matlab ;)
 
What do you call when you assign and write an expression at the same time, like a += b?
 
6:55 PM
I usually go with "augmented assignment"
 
> augmented arithmetic assignments
 
I was 66% right :>
 
well, they are augmented assignments, I think you got 100%
are there non-arithmetic augmented assignments?
 
@Kevin ([1, 2, 3], {}) is the repr for a ParseResults containing ints 1, 2, and 3, with no internal names. I feel this detail is necessary to represent the content of a PR, but it causes no end of confusion/consternation when people think they some got a tuple containing a list and a dict. Also, due to PR's "am I a list? or a dict? or a namespace?" multiple personality disorder.
"It's a floor wax!" "No, it's a dessert topping!"
 
@AndrasDeak >>= isn't exactly arithmetics.
 
7:03 PM
OK, full quote:
> the augmented arithmetic assignments (+=, -=, *=, @=, /=, //=, %=, **=, <<=, >>=, &=, ^=, |=)
 
I like that there's a smiley at the end
 
isn't >>= division by 2?
 
@PaulMcG Makes sense. I was only really confused for a few seconds when I thought "wait... How do I have a list inside this set?", before I came to the conclusion of "it's probably actually a hashable object that only looks like a list", and that turned out to be the case.
 
@AndrasDeak You were thinking >>= 1 but you wrote >>=. Or maybe you meant "division by 2**n"
 
ah, right
 
7:06 PM
@AndrasDeak binary |=, I choose you! throws syntax ball
 
Or maybe you were thinking >>= would be a cool lying-down-robot emoji
 
no, I despise upside-down emoticons ;)
 
oh, nice, this pitfall is linked from the data model docs
I don't think I've ever seen the FAQ section of the docs...
 
Man-wearing-small-monocle emoji: °/.
Looks better in proportional font
 
7:14 PM
If I have two PyParsing rules that appear in the same context and are capable of returning identical ParseResults, what's the idiomatic way of telling them apart? As a concrete example, my json-with-sets parser had the rules:
jsonArray = pp.Group(LBRACK + pp.Optional(jsonElements, []) + RBRACK)
jsonSet   = pp.Group(LBRACE + pp.Optional(jsonElements, []) + RBRACE)
And the results for either one would be a list of elements.
 
When you say "tell them apart" you mean "tell which one a given ParseResults came from", correct?
 
I believe your first cut at setParseAction was correct, to return a set. Returning a true Python list from a parse action has always been problematic, since internally, a returned list is always converted to a PR. We just had this conversation on a posted GitHub issue, and I think I came up with a decent resolution involving a PP code change.
 
@PaulMcG q.o why not just use a q ? or a p.o
 
Because I liked the degree character
And if you changed your chat name to that, it would cut down on the tag notifications
 
@AndrasDeak Yeah. I think what I'd really like is some kind of ParseResults method that returns the rule instance, so that myParseResult.get_rule() is jsonArray if the result came from a jsonArray
 
7:29 PM
Hi folks, quick question. How do I make a grid in vector space?
I have two vectors, u and v
and I'd like to form the set of all a*u+b*v, where a and b both range over, say, np.arange(0,1,10)
ideally in the most 'python-y' way
i.e. I'd like to avoid any explicit loops and just let it do its own thing
 
@E.P. a,b = np.mgrid[:10, :10]
or np.ogrid if you can use broadcasting
but if you want to do this with actual vectors you need one more dimension...
2 dimensions for the a/b grid and 1 more dimension for the vector space
 
u and v are 2-dimensional vectors
 
I'm thinking:
points = []
for a in range(10):
    for b in range(10):
        points.append(a*u + b*v)
 
so my final target will have shape (10,10,2) or similar
 
u,v = np.random.rand(2, 2)
a,b = np.mgrid[:10, :10][...,None]
res = a*u + b*v
 
7:32 PM
I guess you could do for a,b in itertools.product(range(10), 2): if you're really averse to nested for loops but it won't be any faster
 
u and v are shape (2,), np,mgrid[:10, :10] is shape (2,10,10) which gets reshaped to (2,10,10,1) which gets unpacked to a and b of shape (10,10,1) which is broadcast compatible with shape (2,), hence (10,10,2) shape of the result
 
wim
@Kevin not a bad idea, actually a script that just made the markup that the rest of the world uses work in SO chat (e.g. ~strike~ ). oh yeah and DISABLE the __dunderbold__
 
@wim on input or for reading messages from others?
 
@AndrasDeak that seems to work
how can I adjust the spacing?
 
the latter would be like mathjax userscripts which get confusing if you don't have them
 
wim
7:36 PM
@AndrasDeak no mutating input in typing into the chat box
 
say, a and b ranging over np.linspace(0.0,1.,50)
 
@wim OK, that makes sense
 
wim
dunderbold is always a mistake in Python related discussions, and **stars** work for bold
 
@E.P. np.mgrid is a helper. You can use np.mgrid[from:to:step] with real integer step to get arange-like behaviour, or with imaginary integer step to get linspace-like behaviour
>> np.mgrid[:10]
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])

>>> np.mgrid[:1:10j]
array([0.        , 0.11111111, 0.22222222, 0.33333333, 0.44444444,
       0.55555556, 0.66666667, 0.77777778, 0.88888889, 1.        ])
 
@AndrasDeak OK, good to know
 
7:37 PM
or you can just use np.meshgrid and plug in any iterable as *args
but the reshape trick won't work with np.meshgrid
(you could use np.reshape outside meshgrid to the same effect)
@AndrasDeak correction: most sequences
 
@AndrasDeak This works the best, I think.
Many thanks.
 
no problem
 
wim
hooray my PEP 345 change went in
I feared it would take a month of deliberations, but it only took a day
 
345 sounds conspicuously made-up
 
wim
7:53 PM
@AndrasDeak it was added in 2013
 
I never said it's not my fault for never having seen it :P
 
wim
I saw it a while ago, but not soon enough. I've now linked it in my 2012 question ...
There's some awful stuff in that faq, like the example code for removing duplicates from a list
 
> How do you make an array in Python?

Use a list:
["this", 1, "is", "an", "array"]
suspicious
 
wim
heh, yeah.
Next question, how do you make a list in Python? --> Use a collections.deque 😂
 
or a lisp list which is right there (arbitrarily nested 2-tuples)
seems quite practical
 
wim
8:00 PM
if you like toenail clippings, sure
 
@Kevin jsonArray.addParseAction(lambda t: t.__setitem__('rule', 'jsonArray'))
 
wim
@MisterMiyagi So, the gossip ..
There was a core developer who was strongly opposed to dict ordering becoming a feature of the language
And actually they wanted the opposite (dict shuffling by default, to prevent people from accidentally relying on ordering)
 
8:18 PM
That's crazy. How can a core dev not understand the python design philosophy well enough to understand how unpythonic shuffled dicts are? Having one (well, as few as possible) data structure that does it all is exactly what makes python python
 
wim
most of the other core dev disagree with this - because they are pragmatic, dict ordering is useful and dict shuffling may actually even slow down the dict
but I guess someone (guido?) thought it would be more tactful at the time to make dict ordering 'provisional' feature and see how it works out in practice, rather than to disregard other opinion directly
 
something something Guido disregarding other opinion
 
wim
anyway, it was discussed a bit earlier here
 
wim
8:44 PM
What's with all the homework dumps from users with glam profile pics lately. I hope this is not another bizarre SE voting experiment.
 
female profile pics? I think repeat offenders like to use female avatars because that way often people are nicer to them
 
yeah, that's not a new thing
 
wim
speaking of profile pics - sock or coincidence? stackoverflow.com/q/58565100/674039
 
definitely a sock
 
wow...
but no votes or accept, so perhaps it's an honest mistake
socks aren't inherently illegal
 
wim
8:57 PM
guess the output
__import__("os.path").dirname("a/b")
 
I won't even try something as straightforward-looking as that
 
wim
LOL
 
huh
 
I call your bluff and say "a"
 
wim
bzzzz
 
8:59 PM
yeah, what Andras said
 
03:00 - 21:0021:00 - 23:00

« first day (3296 days earlier)      last day (1643 days later) »