« first day (3843 days earlier)      last day (1104 days later) » 
02:00 - 19:0019:00 - 00:00

2:54 AM
cbg, more of a general programming question, how important it is to know how to debug without inputs? eg : an online code test that only shows your 4 test case but does not show you how much you actually pass
 
 
2 hours later…
4:34 AM
any advice on if statements?
my code hasnt been working. here it is:
if input("REPL URL: " + repl_url + " | REPL HOST-TIME: " + repl_hosttime + ", Are you sure you want to start?") == y:
  print("Starting Proccess..")
 
 
3 hours later…
7:50 AM
TIL that SQLAlchemy ships with a Space Invaders game written in SQL
 
8:02 AM
cbg all, is there anyway to get a key a dictionary by using value? Given that all value is unique inside the dictionary.
 
Not without iterating
The canonical is here
Actually, I suppose that's canon for a slightly different question, but possibly the most useful
 
Hmmm okay, my idea was reversing the key,value and then indexing by value.
But what if the value occurs to be same at some point. Anyway ill take it from here, thanks
 
If you have duplicate values then it will indeed be a problem. You could use a defaultdict and append the various matching keys to a list or something, but that might not make any sense depending on your context
 
8:38 AM
Oh
 
8:50 AM
@Jerry What's y? And what exactly means "hasnt been working"?
 
9:05 AM
cbg
Can anyone point me in the direction of how to decode response.certificate so it's able to be passed to json?
 
9:21 AM
What is response.certificate?
You kinda at least need to tell us the library, let alone what the certificate is
 
9:48 AM
I'm pretty sure it's under HtmlResponse but more broadly it's a part of scrapy
 
Well you can easily figure out it it's a scrapy.http.Response by just calling type(response). But I'm going to be no use to you here
 
oh, I know the types, it's just converting them. Thanks anyways
 
Lol
 
...
 
Does SO have a discord server?
 
10:09 AM
@cs95 no official one
 
11:00 AM
@roganjosh Is that a thing? Are there different kinds of undefined behavior?
 
No idea. I just thought that python always gave guardrails so you couldn't, for example, index something out of range
Unless I was poking with cython, I didn't think it would be possible for system-crashable things to crop up so I was curious whether tkinter really does remove certain protections I've come to rely on
 
Anyway, I'm not sure. I know tkinter isn't thread-safe, but I have no clue what can happen if you multithread it
I googled it and apparently there's also something called "unspecified behavior". So maybe it's actually not undefined behavior at all. I don't quite grok the difference between the two
 
@Aran-Fey well UB has a very well-defined meaning in C. There could probably be UB as in C and UB as in "race conditions might happen".
UB as in C can wipe your hard drive if the compiler so chooses. Race conditions probably can't.
 
 
1 hour later…
12:20 PM
Is the system as bad as I think? I can't really see a way to effectively deal with the problem if people start posting questions that use eval but are actually genuine. I'm also now quite surprised that SO isn't being flooded with this
 
@roganjosh not sure what you're asking
 
In this case, it seems the question was innocent. But I couldn't know that beforehand because I wouldn't know how to dissect it as it was. What stops hackers just posting questions in this format without false positives/negatives?
 
Nothing stops them, and innocently posting malware is still harmful. If there were a way to ban such code I'd be OK with false positives where people generate payloads from b64-encoded strings on purpose.
 
If you look at the current footfall on the python tag... SO is a pretty big vector for this kind of attack?
 
Not really, because the average SO user is not as gullible as the avarage internet user. Probably not worth the effort for infiltration. There's still the "for the lulz" factor but trolls we have on SO tend to be more of the "lol I made you waste your time" kind.
I'd find it more likely that script kiddies post answers that do harm, because someone looking for answers is more gullible than someone looking for questions to answer.
 
12:31 PM
That is so crushingly true
Well, there's still the aspect of people trying to get FGITW that may run things
I'm almost tempted to set up a sock and post a question that sends something to my server so I can get a count. Knowing my luck, I'd end up being stripped of my white hat and banned for it :P
 
I wouldn't be too surprised if this meta led to a small uptick in this regard
 
12:46 PM
Indeed, and my musings won't help in that regard, but the footfall in this room is minuscule compared to main and meta
 
yeah
 
What are some of the domains that coroutines shines the most
 
1:41 PM
servers or any interface with lot of waiting around
think of high throughput needs in any situation where the individual task itself is not very bulky, usually IO bound
 
Does it really shine?
 
I never understood async for network IO instead of threads, I should probably time it and see how it goes, both is faster than the normal but when to use what is something I dont know
 
2:10 PM
@roganjosh im trying to find a different resource that compared connections lost/timed out, but havent been able to find it yet. meanwhile, you can see this benchmark suite
i dont know why, but the site it being a bit dumb by default. you have to click filters and select python as language to see python frameworks in the benchmark
 
It's been discussed many times in the room and I'm literally down to "well MisterMiyagi finds it useful". Other than that, I'm out
 
oh for sure, im in the same club too :P i'm essentially going to keep the fact that it's there in the back of my mind, but until i need it, i'm probably going to stay away
for what it's worth though, fastapi itself was very promising when i messed around with it. it was just...nice to work with
the issues arose when one of my colleagues had python 3.6 and they tried to use the code we wrote. lesson learnt: if you're doing async, there's rough edges in the initial python versions, for all intents and purposes i wouldn't recommend async in python 3.6
 
I haven't worked with fastapi but I suspect I need to
 
free docs! can't complain :P
 
2:37 PM
found another great article, more like a cautionary tale on benchmarks in this context of sync vs async. link
the main theme is definitely clear, don't assume sync is better or async is better, it would vary drastically from your use case
 
Theoretical problem I came up with thirty seconds ago: A graph is "connected" if you can travel from any node to any other node. You have a connected graph G, with N nodes. You want to divide G up into K subgraphs, each having a particular number of nodes. These numbers are given in list A, with A[i] being the size of the `i`th subgraph. It is guaranteed that K <= N and len(A) == K and sum(A) == N.

Is it always possible to divide up G, no matter what G and K and A are?
 
i mean, i could always put 1 node in one subgraph :P
er...let me see if that makes any sense at all in context of your question
subgraphs dont need to be connected? if so, i dont see what the issue is. or is there an assumption they they must be connected
 
Oops, yes. connected subgraphs.
 
yep, makes sense. okay
im thinking of a 4 note graph, shaped like a Y.
you give the condition of 2 and 2, and it will fail your criteria
 
Hmm, I think you're right. I just found a similar counterexample myself.
 
2:46 PM
it's because a single joint is connecting 3 points.
 
Same fundamental concept of yours, the single joint is in too high demand
Ok, good work team! Another problem busted
Extra challenge: devise an algorithm that can determine whether a particular G/A input has a solution
 
I can't work out what you're working on
 
that extra challenge sounds very interesting. i imagine it will be rather tough to verify
 
Theres a lot of crossover into my daily life, but what are you trying to solve?
 
Approximately half of the problems I've been presenting this week are related to NGU Industries, a game centered around building a factory by placing various producers and consumers on a finite square grid (with occasional impassable obstacles).
 
2:50 PM
An actual game?
 
Yes, it's a real game. Free to play on steam!
 
Oh. Then I'm probably the worst person to be involved. My thoughts are going to be crippling depressing
 
The factory I'm working on now requires Iron Mines, Iron Bar producers, and Iron Cog producers. Placing units on the map is slightly easier if I can click-drag my mouse around the map without lifting it to place all tiles of one kind in a single connected blob. Determining blob placement that satisfies click-drag laziness is isomorphic to dividing the graph of the map into K=3 connected subgraphs.
 
laurel. I think the game has established itself as broadly np hard, don't worry. (or so I suspect, but i wouldn't dare try to prove it)
 
Hi guys, kinda stuck here for a while. I have a dict with keys as id and values as readings(int), so when I want to take the maximum readings and get the corresponding id. What could be the approach? My original approach was switching the key and values and then using max() and then indexing with returned max value but that would create replace repeated keys value pair with new ones.
Hmmm thinking about it now, I think filter might be of some use?
 
2:55 PM
For this particular input it's almost impossible not to find a solution with human-achievable levels of lookahead. The maps generally have plentiful edges between nodes, and there are very few "joints" of the kind that have flummoxed the case Paritosh and I found.
But later in the game I'll have K=50ish, and I'm curious if connectivity can be guaranteed (or at least easily proven to exist / not exist) in that case
 
@CoolCloud just to clarify, are you saying you want all keys that match the max value of readings?
 
I'm thinking something like max(d.items(), key=lambda kv: kv[1]). But Paritosh reminds me that this only gives one maximum-having key, which is perhaps undesirable if ties can exist.
 
The dictionary would be of the form {'123':152,'164',532} and now I want higest item and its key, so 532 as and 164 to be outputted.
 
{'123':152,'164',532, '202':532} what happens in this case?
 
Backing up the XY hierarchy for a second, if you want a dictionary whose values are all integers, then there's a good chance that collections.Counter can save you work one way or another. It even has Counter.most_common, which seems to match what you're looking for here
>>> import collections
>>> c = collections.Counter("please count the letters in this sentence and tell me the most common letter thanks")
>>> c.most_common()
[(' ', 14), ('e', 13), ('t', 12), ('n', 7), ('s', 6), ('l', 5), ('o', 4), ('h', 4), ('m', 4), ('a', 3), ('c', 3), ('r', 2), ('i', 2), ('p', 1), ('u', 1), ('d', 1), ('k', 1)]
>>> c.most_common(1)
[(' ', 14)]
>>> c.most_common(5)
[(' ', 14), ('e', 13), ('t', 12), ('n', 7), ('s', 6)]
(still not effortless to find ties, but oh well. Maybe throw in groupby too for that?)
 
3:03 PM
grin i was thinking of a simple two step approach, but i didn't want to reveal it straight away. find the max, and then find all keys that have that max as their value.
 
Counter also inherits from dict, so you can look for things the hard way if you really ant
>>> max(c.items(), key=lambda kv: kv[1])
(' ', 14)
@ParitoshSingh Yeah, that's a good way to do it. I think it even has better performance than anything involving iteration through most_common(None)
Unless they're doing something terribly clever to presort results... I'll peek at the source
 
iirc most common invokes a heapsort when called
 
That rings a bell
Yep, we talked about this a couple weeks ago. I was looking at github.com/python/cpython/blob/… at that time.
 
@ParitoshSingh Well it was part of a question given to me this morning, I am not sure what would be, I think it would output both the id? Like (164,202) ?
 
I think you're doomed to fall into the slower branch unless you know ahead of time how many values are tied for highest
 
3:11 PM
yeah, and finding that information would take time where we can simply just find the results
 
Yep :-)
 
The question was to get the id and readings from user and then store it. And find the highest, then the lowerst along with their ids
 
@roganjosh I used one of our SO discussions a week or 2 ago to do a FastAPI learning exercise. It was the case where one of our green beans wanted to have access to a MP Queue from another Python program. I generalized that to a REST server managing multiple named queues, and wrote it up here. Also some Docker bits, so that deploying such a server would be easy to do, assuming you are already Dockerized.
 
whats green beans?
 
My guess is "newbies"
compare to the American English idiom "greenhorn"
 
3:13 PM
My other crazy idea was to change the format, {id:{reading:id}} so I could reverse it? and then apply max on it to get the reading, but dictionary comprehension gave me unhasable type: dict error. Basically I messed up the competition :P
 
oh interesting
@CoolCloud hopefully without sounding rude, i think you're overengineering things. i suspect this may be because you're trying to think of the solution in terms of python codes/functions before just pausing to think what a logical approach to finding the answer would look like.
 
Reversing the dict does sound like a valid approach, but yeah it's overengineered here
 
Also, sometimes its better to just divide a big task into smaller steps, instead of worrying about trying to get everything at once
 
@ParitoshSingh I did want to think logically too, but then the time was less then. And I ended up overcommitting. I'm still thinking though
 
i'd actually not even heard of greenhorn before, though i feel like i might have and then forgotten about it
 
3:17 PM
@MisterMiyagi y is clearly a variable.
 
I really dint want to ask here, and wanted to figure it out on my own. I just cant seem to find any other suitable methods of storing the items than dict, problem occurs at max/min only.
 
the format was incorrect.
 
>>> c
Counter({' ': 14, 'e': 13, 't': 12, 'n': 7, 's': 6, 'l': 5, 'o': 4, 'h': 4, 'm': 4, 'a': 3, 'c': 3, 'r': 2, 'i': 2, 'p': 1, 'u': 1, 'd': 1, 'k': 1})
>>> chars_by_count = {}
>>> for k, v in c.items():
...     chars_by_count.setdefault(v, []).append(k)
...
>>> max(chars_by_count.items())
(14, [' '])
 
Anyway I guess I will try some more thinking here. and get back, thanks :D
 
Dict reversal: success
 
3:17 PM
huzzah!
 
If there are ties, it outputs something like (2, ['o', 'a'])
 
@CoolCloud prompting suggestion. if you're interested in the min/max only, then do you really need to make and store results in this dict?
oh its salad!
 
@ParitoshSingh Oh also I need to display the results .
 
@CoolCloud statement still applies. what is "results" here :)
 
3:19 PM
And it was mentioned in the question to store in array, even though I used dictionaries :p
@ParitoshSingh All the id and readings
 
oh! ah okay, that dict itself is not an issue at all. (well, unless the question asks for an array. then it is :P)
 
@ParitoshSingh Yeah I'd say the term is gradually becoming more obscure as the cowboy lifestyle fades out of American pop culture awareness
 
Let me try to implement kevins solution
 
It was already kind of corny in the 90s, who knows what Today's Youth would think of it
 
3:25 PM
@Jerry It's clearly not clear what value said variable points to.
 
Malicious Compliance solution: first, detect if a tie exists for the maximum. If so, raise ValueError, because the requirements specify that the input has a maximum. Then, use whatever approach you want that doesn't check for ties.
 
@MisterMiyagi so you could put y in the statement without an error.
 
@Kevin Kevin, I really wish I knew this back then. It pretty much does the job.
 
I'm glad you like it, but I'll reiterate that this way is overkill :-D
 
malicious compliance round 2: throw the lexical max result for maximum, and then state that it wasn't specified what criteria should be used for maximum.
 
3:28 PM
"What does it even mean for one number to be 'greater' than another? I personally think they're all great"
 
perfect!
 
@Kevin Wait why are we using a counter? This can be dont with a normal dict too right?
 
@CoolCloud it was used to create dummy data essentially, i believe.
 
Yeah. As long as you don't call any of Counter's special methods, then it behaves identically to a dict
 
Okays, thanks for helping mate, as usual :D
 
3:30 PM
"special" meaning "not implemented by dict". So most_common, subtract, that kind of thing
 
@Kevin Kay, got it
 
which just goes to show, even most common amongst us is special.
philosophy intensifies
 
@Jerry I think MisterMiyagi is hinting that you should provide a MCVE so we can determine exactly what problem you're experiencing. If you trust us to just assign whatever value we like to y, we might get it wrong and see a different error than what you're seeing.
 
Apparently, it's solved (only saw that after asking), so no need to drag this on further.
 
Oh, in that case, cool.
 
3:33 PM
One thing I don't like about Counter.most_common, it does not handle ties.
>>> from collections import Counter
>>> Counter("AAABBBCDEF").most_common(1)
[('A', 3)]
 
Agreed. Give us a group_all_ties argument or something ;_;
While we're at it, do that for max and min too
 
sign me up for that as well
 
How would that work?
 
perhaps a bool parameter for max or min, if True, give me all values that match the max criteria, that kind of deal. same for counter. give me groups in decreasing order from most common to least
 
I'm thinking something like d = {1: 2, 3:2, 4:0}; max(d, key = d.getitem, group_all_ties) gives [1,3]
 
3:38 PM
And what if values are iterables?
 
the key param still works as usual.
 
Return list or list of lists or ...
 
list of "whatevers" i think\
 
How can you tell what you got back, one ir more values?
[1, 1, 2, 2, [1, 2], [1, 2]] etc.
 
>>> ctr = Counter("AAABBBCDEF")
>>> import operator
>>> key_fn = operator.itemgetter(1)
>>> ctr_items = list(ctr.items())
>>> ctr_items.sort(key=key_fn, reverse=True)
>>> list(next(itertools.groupby(ctr_items, key=key_fn))[1])
[('A', 3), ('B', 3)]
 
3:40 PM
doesn't matter to me, right? if i want all matches for my max case for example, i dont care if it's 1 or many.
oh no, i think it should be consistent. if i pass that parameter, it should always be a list of whatevers
even if it's a single item list
 
@PaulMcG OK, tuple vs list I guess...
@ParitoshSingh that makes sense too
I'll allow it
 
All Python problems can eventually be solved using groupby
 
creating a terminal game in python: 😅
lol my computer has a way to use autocorrect
 
@AndrasDeak yeah, i wasnt even thinking about an output similar to one you showed, it should definitely not mix types based on whether the result has 1 or many
 
Agreed
 
3:44 PM
so it didnt even come to my mind what issue you were seeing, oops
 
any ideas ^?
 
Lasers
 
when given a bomb and a menu, you naturally always spam the bomb first. was that the question?
 
>:) Lasers
@ParitoshSingh yes. but no.
 
This is what I had in mind for a tie-identifying max. It always returns a list, even if there isn't a tie.
 
3:52 PM
i think that past me was a bit hasty when he said we should use lists. for the sake of consistency and meaning, i think tuples will be better
but i didnt bother correcting myself at the time
 
kevin, you are 32 reputation away from 69420.
 
Nice B-) B-) B-)
Too bad I couldn't hit it on 4/20, alas
 
lol
 
@ParitoshSingh Ok, works for me. I only didn't do it because it didn't occur to me.
I like immutability in return values.
(where reasonable)
 
kevin, howd you develop kevinscript? what programming language?
 
3:55 PM
Python. The source is available somewhere in my github.
The only problem with making an optional group_ties argument for max is that you can no longer guarantee that max(whatever:List[x]) returns an x instance. When group_ties is True, it returns a List[x] instead.
It's quite easy for a human to look at the code and guess what type the return value will have, but it's still not quite gold-star level type strictness
 
true, hmm
 
ah
i have tried to develop many languages with lexer
never worked
 
I have tried to develop many languages with (and without) lexers, and all but one of them never worked :-)
 
i suppose i dont really see it as a problem when i write functions, but perhaps builtins can and should be put to stricter norms? Not sure what the convention is here
 
@Kevin F for respect
 
3:58 PM
I have a nagging feeling that we already have builtins that aren't gold-star level type strict :-)
the stdlib can't even enforce consistent naming style, what hope do we have for actually important code quality standards ;-)
 
ill be in my math room trying to make a bot
 
Rad, bots are fun
 
:hard to make it sign into an account tho
 
Yeah in my experience authentication is the most fiddly part
 
"stackoverflow developer portal"
should allow bots for rooms in a simplified way. like tokens, and stuff.
 
4:01 PM
I needed the help of an off-duty moderator to figure out the requirements for SO chat login, plus an ample amount of peeking at the source code for the existing CapricaSix bot
 
i actually will need that source.
 
I would love a simplified bot-friendly login process, but new chat features are always in "we'll get around to it eventually" mode, so I make peace with having only the janky features available to us now
Our spinoff bot's source is at github.com/sopython/rabbit FWIW, although you can probably get all the wisdom you require from Zirak's repo
 
ah
ok thanks
 
I did clone Kevin script way back to try it. Waiting for my schools to end :p
 
I had no idea about chat.. Nice.
 
4:05 PM
hi aartist
 
Hi Jerry, I am learning Pandas, How do I categorize the functions by returning types?
 
As in, "how do I view all functions in pandas that return, say, a DataFrame?"? That would be a cool feature, I wonder if their documentation site has something like that.
 
I am not experienced with "pandas"
 
Kevin, exactly.. you got it right.. I am building the list.
for example: tuple is returned by df.shape
 
i want to invite people to my room, but dont because its sorta advertising/
 
4:08 PM
My idea is that when working with different type of objects, It would provide a smoother working practice.
 
Well, if anyone gets curious, they can find all rooms you own by viewing your profile page. Easy!
 
Kevin: Thanks for mentioning another cool feature..of chat.
 
anyone have any luck installing pyenv+numpy+pandas on apple silicon. Asking for a firned
 
@aartist, I don't know if it's possible to find the return types of all of pandas' functions just by looking at the module object. Maybe you could download the pandas HTML documentation (available at pandas.pydata.org/docs/pandas.zip), and try to scrape the values out of that.
 
Kevin: Thanks for mentioning that. I am currently building such list, based on my programming practices and my own code base.
..as an idea of progressive learning.
 
4:14 PM
Ah, so this is what chat is...
 
Lots of visitors today :-) Welcome
 
But if I can build programmatically, that would be cool to..
 
@inspectorG4dget no personal experience on apple silicon, but i'd say give the anaconda ecosystem a try. relevant readSounds like theres something called emulation mode that needs to be used
 
ahh frig! thanks
 
I'm trying to get the Talkative badge lol
 
4:16 PM
Lots of new visiors
visitors-
my spelling.
 
Lots of new visors
 
yes. visi-ors is how people from england say visitors
 
@inspectorG4dget yeah, one downside of being on the bleeding edge, you might get cut. :P
 
Clicking randomly around the pandas source code, I see that they're relatively good at annotating the return types of their Python functions. So those are relatively easy to extract with ast or something similar. I'm more worried about the functions implemented in C...
 
I don’t know how to load an image from my phone 😕
 
4:17 PM
lol
 
If they all just return PyObject pointers, then figuring out the type of that object is as hard as solving the Halting Problem
 
thinking of making a package so you can install and automatically connect to the multiplayer servers through the terminal
 
@M-Chen-3 If you join the Sandbox room and post ten messages there, I think I can find the time to star them :-)
 
"updates come randomly to fix bugs and to make gameplay better"
 
Lol
 
4:21 PM
Feature request: use the conventional spelling "Ogre", or alternatively, add additional backstory that explains what ogors are and how they differ from ogres
Ogors: ten times as mean as an ogre, and eleven times as ugly
 
alright lol
 
@Jerry you can also stop low-key spamming here
 
😅
 
My pic link is in regards to kerning
 
4:23 PM
Kevin: Thank you, that may give some clue to, Now I have to program it..
 
.heic, now there's an image format I haven't heard of before
 
Could you see it? I shared an image from phone to google drive and that’s what happened
 
Yes, I can see it. Wikipedia tells me Firefox has "experimental" support
 
What's the best way to study module codes? I am currently not able to understand the structure, how it is setup.
 
Here it is again, if anyone was having trouble
 
4:28 PM
only a couple days back i was introduced to kerning thanks to the chat here. and now this..this is painful to witness
 
@aartist I usually just read the reference from beginning to end, but I guess that's not a fun approach for a huge library like pandas
Much more achievable for the stdlib modules
@ParitoshSingh Please, donjtopoUs is trying its best ;_;
 
my last daily message: pynomite will be getting an update
 
Hi all (or should I say cabbage?), does anyone have experience with calling libraries that include ctypes interfaced C++ code? I'm getting SystemError: null argument to internal routine occasionally, what would be the best way to debug this?
 
@ParitoshSingh There used to be a website keming.com for bad kerning fails, many having do with the word "flick" in unfortunately chosen fonts.
 
4:32 PM
When the ctypes-interfacing lib I'm using fails, my approach is to google the error message and pray that they've already patched it for the next release, and have a workaround in the meantime. I acknowledge that this is not generally useful.
 
Thanks. That was the worrying reply I was hoping not to get haha... I don't really want to delve into the source!
Unfortunately, it's a stochastic optimisation library...so it only happens 'randomly', making it a pain to figure out.
 
> SystemError: Raised when the interpreter finds an internal error, but the situation does not look so serious to cause it to abandon all hope.
Hmm! Pretty rare when the sign over the gates of hell tell you not to abandon all hope.
@TimJim I don't suppose you could give a static value to random.seed to force it to act deterministically?
 
Haha, I saw that! It also didn't fill me with confidence...
 
Kevin: How about writing a similar library ( not in content, but in structure), on my own. That may give me idea. What tools python provides to begin with.
 
@Kevin
 
4:36 PM
@aartist Yeah! I think that would be most educational.
 
That's a good idea.
Oops, sorry - skipped a line
 
If the library uses its own RNG independent from Python's builtin one, you might have to dig a little deeper to gain control of it
Sometimes they're nice enough to have a public interface for doing so
 
Looks like they pass in numpy's Generator(MT19937()) so there's hope yet!
 
@TimJim start seeding and find a seed that produces the issue, then it's reproducible
 
Thanks, @AndrasDeak As in, set a fixed value?
 
4:43 PM
Yes, one you control. Change the value until you have the error. And then you have a deterministic case. It might still be painful (and might need 1e6 iterations for the error to happen), but it will be reproducible which is step 1 for debugging.
 
I've never understood the use of seeding
By now I should have the Talkative badge
 
Well, most RNGs need a seed in order to kickstart their algorithm. Often they'll simply grab one themselves (using a time.time() call, for example) if you don't specify one explicitly. So you don't often need to call seed() yourself.
 
Ok, thanks for the hint!
 
Calling seed() yourself is most useful for 1) guaranteeing deterministic behavior during debugging, as seen here; 2) providing a seed value that's harder to guess by bad guys
 
Tim Jim: you can use random_state variable at some places, to generate the same numbers again.
 
4:47 PM
A sufficiently determined adversary could, in principle, gain hidden information about your program state by running a second instance of your program with a seed value equal to the time that the real program started up. So he could peek at other player's hands in a poker game, for example.
But if your online poker game seeds its RNG by XORing the current timestamp with the number of red pixels returned by your private webcam that's pointed at a lava lamp in your server room... He's not going to be able to guess that one.
 
It's going to be a pain to reproduce, and I suspect at the end of it, it's going to be some mismanagement of passing pointers or something
 
Yeah :-)
 
@Kevin I saw some documentary about a company that points a webcam at a wall of lava lamps or something like that!
 
Hehe, I was thinking of that same company
 
Ah, that was the one! Pretty cool stuff, though they could have picked a more energy-efficient method tbh xD
 
4:52 PM
i thought of having a bulletproof glass wall and put a ton of the stuff (is it lava?) into it.
 
but I wag my finger at them for keeping the lava lamps in the lobby, where anybody can see them. An adversary simply needs a couple million dollars of high end recording equipment to capture their precious entropy
lava wouldn't stay fluid at room temperature for very long. I think they usually contain wax.
 
mm.
 
> A formula from a 1968 US patent consisted of water and a transparent, translucent, or opaque mix of mineral oil, paraffin wax, and carbon tetrachloride.
The modern formulation is a "trade secret", so for all we know it does have lava in it
 
How can I control what is said when using sys.exit? Currently it says in red text: repl process died unexpectedly
 
I don't remember specifically, but I'm sure there's a way. Check the documentation for the sys module.
Online REPLs might override that kind of thing, though, so try to test on your local machine first
 
5:01 PM
oh, i'm just gonna use a function and returns
 
Yeah I often find that exit() is more work than it's worth unless I really need the python executable to terminate with a specific exit code
 
@Kevin i often think it should have been a regular builtin instead of importing somthing but I don't mind
btw how have you been, kevin 👀?
 
Strangely, exit() is available in my builtins, even though it's not listed in the documentation. Call it implementation-dependent I guess.
 
you mean in kevin script? that's good
 
5:09 PM
No, in Python
 
umm. That is very strange.
 
it is for me too
and so is quit()
 
here when I even try os._exit() pycharm yells at me saying it's a protected member of the module.
 
@PSSolanki Not bad. Slowly descending into covid-avoiding isolation madness. Another two or three years of this and it might start to affect my productivity.
 
Hopefully it won't be that long. It's been rough for sure
 
5:15 PM
@Kevin If anyone is actually wondering about the question, ive made a repo with my new solutions.
 
I admit a mild curiosity
 
Well the 2nd question is what I have uploaded so far though. The first one was a mess T_T
 
Messes are most educational
 
You'd only look for a better solution if the first one is a mess -_-
 
@Kevin I mean it was a mess for me :p
 
5:25 PM
Anything that makes you go T_T will teach you something, even if it's just "I should be 1% more cynical about the world"
 
@Kevin True that, i never knew about setdefault till now
I've updated with the first question now :P
I mean we just had 1.5 hrs to do these 2 questions. I think it is low? I mean even if we use a terminal instead of a GUI it seems like it requires more thinking.
 
setdefault is a fun little method, although you basically never need to use it if you're willing to import defaultdict
I am usually not willing.
 
Hmmm @roganjosh did mention about using defaultdict in the morning when I initially asked the question.
 
I think I could make non-GUI answers to those with a comfortable amount of time to spare, but writing a GUI can take me a very long time indeed
Effectively infinite if I can't use google
 
It takes me 2 hours to decide if I should go with #fff or #000 for the bg color 👀
 
5:30 PM
@Kevin Well I found out the mistake that I overcommited myself to GUI with python and when it comes to knowledge about loops and algorithms I'm pretty mediocre, so I have to work on those now
@PSSolanki True that
@Kevin But this took me less than an hour, given that the logic was already made when the terminal version was made
 
random question, is there a mobile app for these chat rooms? maybe even for SO itself?
couldn't find any when I tried
 
@PSSolanki I did search for it, only found SE and not SO
 
I remember a few people here saying they are using their phone to chat. (think it was roganjosh - but a long time ago). Not sure what application is that?
 
Browser prolly
 
:D
i like how that didn't come to my mind at all
 
5:36 PM
:p
 
6:14 PM
Yeah, in the rare instances where I come here mobile-ly, I just use my phone's browser
I don't think Pi ever actually asked his kerning question. I bet he's chatting and hang gliding at the same time or something
An updraft took him above the cloud layer, which is a beautiful once in a lifetime experience, but also there's no wifi
Or perhaps the question was implied, "here is a picture of a sign with strange kerning [, doesn't it bring you pain?]"
 
6:29 PM
@PSSolanki yeah, browser. There might be an app but all SO/SE apps are unmaintained as far as I know
 
6:42 PM
@CoolCloud for I am Josh, knower of stuff and things. Occasionally. <has no idea what this discussion is about>
 
02:00 - 19:0019:00 - 00:00

« first day (3843 days earlier)      last day (1104 days later) »