« first day (3493 days earlier)      last day (1448 days later) » 

12:12 AM
(but of course others might)
@ihavenoidea huh, not a single maintainer/contributor on that comment thread. Pretty worrying. Then again if I understand correctly it's about tensorflow+keras, so it might be non-trivial where the leak is.
 
12:43 AM
I'm using this at work starting on Monday! github.com/willmcgugan/rich
 
12:55 AM
Im trying to identify a selector and having issue with it for BS4...
 
Is there a free alternative to "Read the Docs"? From what I understand they don't offer privacy in their free version. Meaning, whenever you upload something it's necessarily visible?
 
 
2 hours later…
2:56 AM
@AndrasDeak Very droll...
Can anyone here give me a tl;dr opinion on semantic web? Whatever Happened to the Semantic Web? 9/2018
One comment: *"Yeah, semantic web really hacked the brains of academic-facing bureaucrats. It fell into this giant gap between what administrators don't know about business and what they don't know about technology... a gap big enough to shove every utopian idea about "an effortlessly integrated, data driven society" into.*
*There's no such thing as "right" way to represent any given data stream, just ways that are more or less suitable to specific tasks and interests. That's why HTML failed as descriptive language (and has become fine-grained-formatting language), and it's why symantic web
 
3:57 AM
i am trying to implement the strategy design pattern in python and i'm unsure how to load my strategies
i've thought of 2 options:

1) in the __init__.py file, manually import every strategy class so i have access to it

from .strategy1 import Strategy1
from .strategy2 import Strategy2
...
2) loop through every file in the directory and dynamically load the classes
option 2) allows me to add additionally strategy classes without having to update the init.py file, however i don't know if this is a good strategy
 
4:16 AM
Why not put them all in the same .py file? There is no rule (unlike in say, Java) that requires classes to be in separate files.
 
4:45 AM
well scalability might be of concern. what if we have 100 strategies? we'd have 100 classes in a single file
maybe scalability is the incorrect word to use
readability
 
You could auto generate the init.py file from the filenames, if you've got them in separate files, right?
This should be straightforward if your classes have the same name or some consistent relation to the filenames.
 
generate the init.py?
i thought we just include it in the directory to make the directory read as a module
import os
import importlib
import inspect
import sys
from dataparser.parser_interface import ParserInterface

def load_parsers():
    parsers = []

    dir_path = './dataparser'

    for file in os.listdir(dir_path):
        if file[-3:] == ".py" and file != "__init__.py":
            importlib.import_module("dataparser."+file[:-3])

    for class_name in ParserInterface.__subclasses__():
        parsers.append(class_name())

    return parsers
 
@roganjosh That question looks fine to me, so I wrote an answer. :)
 
i have a list of parsers in the /dataparser directory and i just loaded them via importlib
 
Yes, but rather than manually adding each import, you could write a script that runs through the filenames in the directory, and writes an __init__.py with all of the corresponding imports.
 
4:57 AM
i see, but you would have to rerun the script whenever you implemented any new strategy classes
with this solution i'm able to just add the parsers to the directory and be done with it
but i'm unsure if there's a better way to do this
 
Fair enough :) Maintaining is surely easier than manually creating 100+ imports.
 
 
1 hour later…
6:21 AM
@RobertCalove how often will you add a strategy, and how many do you expect?
 
well this is for a coding challenge for interview
one of their requirements is "seamless addition of new parsers"
 
Okay. In that case it totally does not depend on best practice but what kind of shop you are interviewing for. If they want clever h4ckz, go with the dynamic submodule discovery/import. Otherwise, I'd pick explicit imports - writing one import line per class is negligible compared to writing the class itself.
 
thanks!
 
by the way, you probably want to construct the path based on __file__, not some relative path (which is relative to the cwd, not the script).
 
6:54 AM
thank you!
 
 
1 hour later…
Hii,
I have some doubts on python regex.
I'm using re.search using the variables(var1 and var2).
(re.search(rf"\b(?=\w){re.escape(var1)}|{re.escape(var2)}\b(?!\w)", s, re.IGNORECASE)
is that possible to search(re.search) both var1 and var2 values, instead of using or(|) operator.

question link: https://stackoverflow.com/questions/61680523/using-multiple-variables-with-regex-in-python
 
What exactly does "search both var1 and var2 values" mean? Call re.search twice, once with var1 and once with var2?
 
okay thank you!
 
8:13 AM
are you looking for all occurences of var1 and var2?
in that case, use re.finditer with your initial pattern.
 
im searching this in a excel sheet.
i need something like, if both val1 and val2 values present in a cell #do something...
i have to use regex because it may contains any alphanumeric in excel cell.
need to know whether var1 and var2(both) present atleast once
 
yeah, call re.search twice
 
sure, thank you
 
erm, if those are strings we are talking about, "var1 in s and var2 in s" should work.
 
8:30 AM
that only gives the same result if you ignore the word boundaries, the lookarounds, and the re.IGNORECASE :P
 
how to impute missing value for categorical data type for building ml model
 
so i can use the if condition like this,
`if (re.search(rf"\b(?=\w){re.escape(var1)}\b(?!\w)", s, re.IGNORECASE)) and (re.search(rf"\b(?=\w){re.escape(var2)}\b(?!\w)", s, re.IGNORECASE)):`
 
yeah
 
thank you so much
 
I don't think those lookaheads do anything useful though
(?=\w){re.escape(var2)} fails if var2 doesn't start with a word character
 
8:38 AM
okay
 
and \b(?!\w) fails if var2 ends with a non-word character and is followed by a word character
 
@PM2Ring amazing, thanks :)
 
@roganjosh No worries. :)
@MisterMiyagi Hammered
 
9:15 AM
@RobertCalove How will you find which parser is needed? Or is this the case where every parser needs to be run until a match is found, or where every parser needs to be run and longest match is found? Use __init_subclass__ in the parsers to have them add themselves to a parser list, or use __subclasses__() on a common base class to find all the parser classes (only finds immediate subclasses, so if there is an inheritance hierarchy among the parsers, then you'll need to do a recursive wrapper).
 
 
1 hour later…
10:18 AM
@PM2Ring I've gone through that answer several times. I'm super-impressed with your ability to get into my thought processes on that one. At some point I'll write up my ears-popping-in-train-tunnels question that we spoke about here a year or so ago, but I get a bit nervous with Physicists :P
 
10:28 AM
I tried spinning up a virtualenv via the cmd in my vscode, but no matter what i try to do with pip i get this error
Could not fetch URL pypi.org/simple/pip: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
 
@Skyler there's a good number of hits when you search for that error, including this
 
the link you sent is deaad
 
The link works fine for me. What do you get?
 
that's weird, second time it worked...
 
It's not specific to VSCode but it shows some flags that you could set when downloading
 
10:33 AM
the github issue post gave a few commands, as well as a similar stackoverflow article i looked at
commands ggenerally returned the same message
and since I'm doing this for my windows system most of the non-pip options are unlikely to also work
looking at that article you sent
yep, still getting that same error from the article you posted and the different suggestions given in the github issue he follows back up on
 
@roganjosh Thanks. I vaguely remember you asking about black hole density a while back, and I just threw a bunch of stuff together that I thought was relevent. :) Your ear-popping question should be ok, as long as it looks like a conceptual question. The homework policy on Physics.SE is pretty strict. See physics.meta.stackexchange.com/q/714
 
Seems like it might be related to some changes on pips side, hadn't been really doing python dev on my windows for last month stackoverflow.com/questions/49943410/pip-ssl-error-on-windows
 
@Skyler well, you could update pip but my impression from the few answers I came across suggest that the issue is on the client side, either with not having administrator privileges or being behind a firewall etc. (though the error doesn't really suggest that)
 
10:51 AM
This is a verbose trace of whats going on pastebin.com/qQrfKBD1
 
Ok, so you have conda. This looks relevant
 
@PaulMcG hi paul i have read the two link you sent me about set but there is nothing on & ?
 
11:15 AM
@Hassan Those links were specifically not about Python, but sets in general. The link to the Python sets (and their & operator meaning) is in this message.
 
@MisterMiyagi thank you will have a read now
 
11:30 AM
def __eq__(self, other):
    return self.__class__.__name__ == other.__class__.__name__ \
        and self._name == other._name
^ the stdlib is a gold mine for bad code, unbelievable
 
please say that's some obscure platform-dependent piece that is hardly used
is it tkinter?
 
it's tkinter
It's the __eq__ for tkinter variables
 
Heh
 
now I'm wondering if there is any code out there relying on this borked behaviour...
 
I'm gonna be optimistic for once and guess there isn't
 
11:38 AM
hm, then cleaning up that mess might be a better waste of time than the current SO feed...
I'm always wondering how these things survive, before remembering that I can't be arsed to submit PRs either.
 
11:51 AM
@MisterMiyagi i got it & return the mutual element between the sets
@MisterMiyagi so & in my function return the mutual element between person1 and person2
 
I'm so confused by the last parts of this answer, particularly the last line of code. I don't get what Jinja does there, at all. They're suggesting, I guess, that background= is deprecated, but then they change the jinja pattern
 
@PaulMcG i think i have figure it out & in my function returns the mutual element between person1 and person 2
 
Is Jinja doing anything there at all in that last line?
 
@Hassan That's correct. Sets are optimised for such operations and can perform them quickly.
 
@MisterMiyagi thank you guys for making me understand, it took some time but got there at the end
 
12:04 PM
nm, I understand now
 
@MisterMiyagi any better now mate ? Set mutual to neighbours this will create the set for person1 and person2, then return the friends that set person1 & person2 have in common, then return the length of mutual.
 
I thought writing a wrapper library for tkinter would be convenient ("I only need to implement the annoying stuff once"), but now I find myself liberally sprinkling calls to update_idletasks() around the code until it somehow magically makes tkinter behave the way I need it to behave
 
This might be a language problem. The individual pieces make sense, but as a whole they don't quite fit. What do you mean by "Set mutual to neighbours", "the set for person1 and person2"? Both person1 and person2 are not sets. The neighbours of person1 and person2 are sets.
@Aran-Fey Have you considered wrapping tk (or whatever slumbers beneath tkinter) directly?
 
No, I've sunk too many hours into this already :D
 
12:36 PM
if you do reimplement it, please call it tinker
 
@MisterMiyagi Mutual is assign to neighbours in friendship, this will return the set of friends that person1 & person2 have in common, then return the length of mutual.
 
probably language problem
 
@MisterMiyagi ignore the previous one, Mutual is assign to neighbours in friendship, this will return the sets of friends that person1 & person2 have in common, then return the length of mutual.
 
@Hassan I don't really understand what you're trying to say. It's not exact. If I didn't know what you were talking about I wouldn't understand the algorithm, for instance.
then again I haven't been following the story too closely
 
12:53 PM
@AndrasDeak ok i wanted to know the initial insight of the common function that @MisterMiyagi made for me
@AndrasDeak should i post it
im not sure if im getting mix up as paul said i couldnt Initialise mutual
 
No, thanks, I can look it up
 
@AndrasDeak so im allittle confuse how to assign mutual now as @MisterMiyagi said i cant use set mutual so now i have use assign?
 
I guess I'm confused too
I'll defer to Miyagi and Paul who know exactly what they've been discussing with you
 
@AndrasDeak what would your initial insight be for the common function?
 
I don't know what the "common function" is, and I don't know what you've been meaning by "initial insight".
 
1:00 PM
Hi all, first time being in the stack overflow chat
 
@Raevel hello
 
Is there a Neural Network chat?
 
I think someone tried starting a machine learning room a while ago, but I'm not sure that took off. You can also look around at chat.stackexchange.com for other sites on the network
 
FWIW, we are also neural networks ;-)
 
oh ok, thanks!
 
1:14 PM
Yeah... think there's been a few attempts over the years for a ML room but I don't remember one ever actually sticking around for long...
 
Anyone here a mod? I keep seeing a user posting mildly unpleasant comments on virtually every new contributor's question
 
@NicolasGervais then can you raise a flag please?
 
the guy posted over 12,000 comments in a year
upon investigation, the guy receives a TON of downvotes
a few times, he lost like -15 reputation in one day because of bad answers
 
okay... no need to give any details here nor do further investigation... please just raise a flag on one of their comments so I can identify privately what user you're referring to
 
ok thanks, give me one moment
 
1:19 PM
I'm sure the company's Unwelcoming Terminator 2.0 will handle it
 
@AndrasDeak it depends... I think it might only be half way through the phone book trying to find his friend Sarah Connor...
 
OK @JonClements I flagged something, let me know what you think
Do let me know if I am rigthly concerned by that, or I should disregard it in the future. I just think that it contributes to the site's reputation as unfriendly.
 
There are well-known veteran curmudgeons whom you can't do much about. They sometimes get suspended for a week or a year. In any case the only thing you can do is flag for a moderator (or just flag each comment as unkind or abusive as necessary).
 
1:35 PM
@Nicolas Thanks for being concerned. Note that you won't necessarily get direct feedback but it'll be looked in to. If I might add though, while I appreciate you're trying to help, perhaps given your concerns, the comment you made on the post you flagged was best not left - I think it's perfectly fine, but sometimes it's best to not draw attention to yourself and just flag
 
My goodnesss, I got a bit worried that I make a lot of comments but apparently I've made less than 11k in my SO lifetime. 12k a year is extreme :O
 
ha, I've got exactly 4000 comments total right now
 
@Andras well apparently, there's 7,350 of 'em but... shrugs :p
 
About 1,000 of these 12,000 comments are like "don't forget to use snake_case" lol
 
@JonClements including deleted I guess
 
1:48 PM
I feel there's a pun to be had between Saiyan and "sayin'" when we're talking about 1000s but I daren't try make it work
 
@NicolasGervais I've marked your flag as helpful... looking at history - the mods are well aware of the user so errr... yeah... you've done what you need to and we'll see what happens moving forward - without targeting the user, if you happen to notice such comments again, just flag accordingly and further evaluation can take place etc...
@NicolasGervais meh... that's just rubbish... everyone knows it's "ssssnake_cassssse"... :)
@AndrasDeak yeah
 
2:13 PM
Thanks for taking it seriously. That being said, have a great weekend!
 
2:26 PM
@JonClements hmm, almost half my comments are deleted. Wonder what that figure would be without welcomification measures
 
@NicolasGervais Thanks for helping! Have a great weekend too - thank you! Feel free to drop by whenever, we're a friendly bunch that love Python stuff!
 
@AndrasDeak 7,350? :P
 
2:41 PM
@AndrasDeak I think you will have deleted a lot of them yourself? You don't strike me as particularly grumpy on main to have them reported
 
Well, I leave a lot of comments on stuff that gets roombaed, those definitely get deleted. Not sure about manual ones...I do delete a few but rarely. I used to leave helpful comments to lazy or confused askers which can probably be seen as unfriendly, especially these days.
although I do try to go out of my way not to be hostile toward most users
I've seen plenty of harmless-looking comments of mine disappearing into the void for no obvious reason, those were probably all stray unkind flags
I don't like walking on eggshells and sugarcoating criticism, so I'm not exactly "welcoming" by today's standards
 
@AndrasDeak you're more than fine - don't sweat the small stuff
 
Oh, and I often harrass users who leave answers when they shouldn't. I do that less these days...I just downvote
 
I personally don't even bother. It came to the fore a few days ago when someone downvoted my answer because it didn't solve their unrelated problem that I'd never seen, and yet asked me for help. I'm not shocked that my comment was deleted, but the sentiment stays.
 
@JonClements I'm not worried or anything, just explaining the situation :) Thanks though!
I figured if I were being problematic I'd get a warning sooner or later
 
2:50 PM
remember though, that a comment that is deleted vs looks deleted are completely different things
 
I only know that self-deleted comments are different from non-self-deleted ones
 
there's that but also, but let's say for instance you had 10 comments on a post, but that post got deleted, the comments wouldn't show up in your history - however if the post got undeleted, they'd come back
 
Ah, I see what you mean. Yeah. But for all intents and purposes if I don't see it it's deleted :)
 
if those 10 comments did actually get deleted - then you'd not see them even if the post got undeleted
 
but I get it; it's more precise to call them invisible
 
 
1 hour later…
4:03 PM
@Hassan - you are getting closer. What are the two sets and how are they found? What set operation (set operations were described in the second mathisfun link) is done on them to find the set of friends they have in common? You must use the name of this set operation to get full marks.
 
4:33 PM
@PaulMcG ok thanks mate i will have a look and try figure it out, also the beginning bit mutual would assign be fine or set or initialise ? im getting a little confuse
 
wim
 
5:38 PM
wat
can't tell if joking or completely mad
 
@Hassan - It is useless to comment that you are assigning to a variable, or computing its length, those are plain to see. It is like commenting x = 1 with "# assign 1 to x" or "# initialize x to 1". "Assign" vs "initialize" is not important, the fact is you are just commenting the obvious. Or size = len(list_of_things) as # get length of list_of_things. This is just clutter. The things that are important to comment are those things that are not plain.
Please just answer the two questions in my previous post, and forget about assigning or length. Your comment will be something like "# find mutual friends by _____________" (fill in the blank, describing the two sets and the set operation to be done)
Another approach that might help would be to research what that '&' operator does. You will find it in the link I sent earlier on Python's set type and what operators it supports.
 
 
1 hour later…
wim
6:58 PM
@MisterMiyagi unfortunately not joking stackoverflow.com/…
 
Anybody custom spam flagged them yet?
 
7:25 PM
@wim oh my. looking at some of them did not help my trust in humanity.
 
any field will have crackpots
since nobody said anything I'll flag them
 
wim
8:04 PM
flag as what tho?
they didn't do anything wrong afaik
 
Same as you, except 24/40 answers advertising aggressively
 
8:42 PM
@wim They're using ther Q&A to spam their URL repeatedly. It's trying to boost their SEO by creating legitimate-looking backlinks.
Hey what memory package do people use to get accurate (deep) memory-usage data, rather thansys.getsizeof? Or manually measuring memory used by each attribute and summing them.
I see some references to pympler. Is it used much?
 
AMC
@NicolasGervais I was getting concerned, that description sounded familiar, then I checked the rep tab and remembered that there seems to be little correlation between the quality of some of my answers and the amount of downvotes they receive.
 
9:44 PM
@PaulMcG hi paul this was really helpful, the set operation we are using is Intersection as we need to find the mutual friends between person1 & person2, the neighbour function create a set returning back the friends they have in common
@PaulMcG the & sign is use to reteive the elements from person1 and person2 that have friends that are link to each other
 
Ok, you have gotten much closer, I can help you clarify the rest. The neighbour function itself just returns the friends of person1 and person2, each as a set. It is the '&' intersection operator that is actually finding which friends they have in common.
 
@PaulMcG find mutual friends from the neigbour set of person1 & person2 which will intersection the sets and return the mutual friends they have in common.
 
10:00 PM
person1 and person2 will each have a neighbour set, won't they? You make it sound like there is just one neighbour set. Also cut "and return the mutual friends... etc." Just focus on the sets and the intersection operation.
 
@PaulMcG no there will be a set for person1 and person2 as we call neigbour for both so in total 2 sets. then the & will show us the friends they have in common.
@PaulMcG neighbours will return the friends of person1 and person2 as sets, then the ‘&’ intersection operator will find the friends they have in common
 
Ok, I think you've pretty much got it now. Out of curiosity, how do you compare this approach with your original scan of all nodes in the graph? For instance, what if each person only had one or two friends, but the graph contained millions of persons? Bonus points: how would you add person3? or person5 thru person10? And get the friends that they all have in common?
 
10:21 PM
@PaulMcG thats a good question paul lol, keep using & would not be efficient, so im guessing creating a set to put all of them in
@PaulMcG yeah im actually really curious for the answer to that
@PaulMcG also thank you for all your help and being patient with me
 
It wasn't easy
 
10:40 PM
@PaulMcG lol i can imagine but you been soo helpful thank you
 
10:57 PM
what exception should be raised if a property is a tuple of 4 items max and an adder method is adding the 5th?
RuntimeError ?
 
ValueError?
Side note: is it not weird to have a tuple "with varying size"?
 
What do you get if trying to unpack the wrong number of items from a tuple?
Actually, tuples being immutable, you can't really "add a 5th"
 
@AndrasDeak it gets updated (*last_state, new_item). type hinted like this Tuple[type,...]
 
So you might internally keep the items in a list, but have the property report the values as a tuple.
Will keep callers from messing with your internal list
 
@aderchox I'm hearing "yes, it's weird"
 
11:01 PM
@AndrasDeak :D
 
length of a container is not type information
 
@AndrasDeak (sorry) I don't know which question it's answering... :/
@PaulMcG how can I unpack the wrong number of items from a tuple? unpacking unpacks all items, right?
 
a, b, c = (1, 2, 3, 4)
 
aha!
 
11:30 PM
Hello, this is my first ever message in a StackOverflow chat xd
 
hello
 

« first day (3493 days earlier)      last day (1448 days later) »