« first day (3575 days earlier)      last day (1362 days later) » 

12:44 AM
@roganjosh I used to have one - I'll see if I can find it (fyi: cookies are allowed for all kinda things under GDPR - but you have to get the person to opt-in as far as I remember)
 
They are (I think) allowed without consent in certain circumstances, as I commented on that answer. After that, it gets murky and it's already well past my bedtime so I'll have to pick it up tomorrow. I'm just listening to Charlie Brooker telling me how broken things are - it gives me strength :P
 
heh...its complex to be sure
lol...Is it bad that I saw the new Meta post about Python and immediately thought "which one?"
I've seen like 12 people gaining point after point based on bad answers or FGITW answers to bad questions (not a new thing). And though I think I know which one this is talking about (certainly a more serious case then normal) its all part of SO and has been for years
 
 
6 hours later…
7:02 AM
this seems absolutely crazy, but I don't know enough Pandas to tell them what to do instead stackoverflow.com/questions/63166771/…
 
7:31 AM
It seems to me that when the instance variable is assigned then __setattr__ of the class is called, and when the class variables are assigned then __setattr__ of the metaclass is called, am I wrong?
But It also seems to me that I am wrong because when I call object.__setattr__(self, name, value) while setting the attribute of instance, I didn't get any error. but when I do the same while assigning the class variable to the same function in metaclass, I am getting: TypeError: can't apply this __setattr__ to type object
If anyone's there I can give an MCVE.
 
7:46 AM
@tripleee oof
 
@iaeliyen MCVE would be useful.
There are some edge-cases when metaclass methods are not invoked, and they aren't readily apparent (read: the spec does not clearly define them).
 
Please see this: pastebin.com/zeyKc96U
By the way, I am not entirely sure what I'm doing.
 
8:05 AM
Works without an error on CPy3.7 for me.
You do realise that A.__setattr__ doesn't actually set anything?
 
but, print(B.r) raises Errors.
@MisterMiyagi exactly, that's what I am asking, how to set something with that?
 
Both __setattr__ methods should call super().__setattr__(name, value).
class A(type):
    def __setattr__(cls, name, value):
        print("From metaclass: ", name)
        super().__setattr__(name, value)

class B(metaclass=A):
    def __setattr__(self, name, value):
        print("From class: ", name)
        super().__setattr__(name, value)
 
I see, thanks.Now, I think my problem was something else.
By the way, where obj.level1 = classmethod(lambda : 'hi') this would be stored?
 
stored, yes, just not sensible to use.
 
where obj is an object of some class Class
 
8:11 AM
A classmethod needs to take at least one parameter to receive the class. obj should also be a class object, not an instance, to be invoked as a (class) method – unless you really want to just store it.
 
I think I should tell you the full task: I want to simulate a final-like class, where hidden variables remains hidden in sub-classes, nothing gets modified(something can be added(like method or variables(of instance or class), but they should not be reassigned)
I'm able to do the latter(forbidding reassignment upto significant portion) but failing on some wierd cases, like:
Final = build()                                     #Final is the original final-like class
obj = Final()
obj.level1 = classmethod(lambda : 'hi')
Final.level1 = 'Whoops!'
I'm not able to forbid this(by raising errors).
 
Which of the two should raise the error?
 
later, because it is reassignment. (initially level1 was not there, it was assigned first time in line 3)
The problem is when I do this: obj.level1 = classmethod(lambda : 'hi'), then level1 the __setattr__ of Final(or equivalently of B of pastebin code) gets called, and consequently it gets stored in the __dir__ of the same.
 
but obj.level1 = ... does not assign to Final, it assigns to an instance of Final.
Final would have to know about all its instances to later detect the conflic.
 
Are you saying that last two lines are completely unrelated?
(Yes, and I was affraid of this)
What classmethod decorator is doing?
 
8:24 AM
A classmethod is a method (aka "callable on the class") that receives the class instead of the instance when invoced through the instance.
Commonly, it means a classmethod receives cls instead self.
See the docs.
 
I've been reading the docs since morning. :D
Isn't that add some property to the class instead of the instance?
> A class method can be called either on the class (such as C.f()) or on an instance (such as C().f()).
Please note that I've no idea what I'm doing.
 
8:41 AM
@iaeliyen Repeating this is not helpful. :/
Do you have any idea what I'm telling you?
Like any method, a classmethod must be set on the class, not the instance.
Since calling a classmethod passes in the class, not the instance, it can be called on the instance (like a regular method) and also in just the class (since an instance is not needed).
 
@iaeliyen so you have said twice now. Whether or not that's true, it's not a valid reason to have someone spend a good deal of time explaining things. Please be mindful of MisterMiyagi's time and the effort he's putting in. It may be best to re-read what's been said and take some time to research it further
 
 
2 hours later…
10:40 AM
@roganjosh thanks for your wonderful advice.
 
can someone tell what wrong with docstring and function signature
 
@Programming_crazy Please see the code formatting guide.
 
To be honest, it took me way to long to figure out that coding signs are the secondary symbol of the key... I used to copy-paste the signs from guides for quite some time before I got too annoyed and finally was willing to spend 10 minutes to figure out what I was doing wrong - turns out, I didn't press shift. :D
 
11:08 AM
Opinions please: I'm expecting my web form to give me a list such as ['Product 1', 'Product 2'] and, given that the form is populated by pre-defined dropdown options, anything other than that working or an empty list is an alarm bell. Even so, looking at my own code, the all-or-nothing list comprehension looks smelly to me, similar to side effects. Am I being paranoid or is it genuinely an anti-pattern? It's code for my portfolio so I'm perhaps overthinking
for i, machine in enumerate(current_app.config['MACHINE_NAMES']):
    product_list = self.req.getlist(f'machine_{i}_products[]')
    try:
        product_list = [int(item.split()[1]) for item in product_list]
    except Exception as e:
        print(e)
 
@roganjosh what exactly is your concern or the alternative?
 
I mean, I did find this which I find more gross
 
if it's code for your portfolio you should probably worry more about using print for logging :P
So I think the issue might not be the "all-or-nothing list comp", but rather the "except Exception"
 
Oh, I'm not too fussed about the catch-all exception atm :P (but, yeah, no print). It just seems a bit ugly when I look at it that I know I have exception-prone code and I'll just dump the whole list if it happens
 
@roganjosh I'm generally averse to recovering from failed assumptions. If your assumption is that the input must be a list of whitespace-separate words, then your app (or at least that request) should go down in flames when that assumption does not hold.
limping on with violated assumptions is rarely a good idea.
 
11:13 AM
Well... you're the one who supplies the input, right? From a form. So in a sense you could even assert that the fields are in the right format, and no exception should happen. In other words you could have a test that verifies this, and not check it in your prod code. Does that make sense to actual software devs?
 
@AndrasDeak No, I'm not. This is for my website V2.0 that I'm also publishing the code for openly on github. So, the levels of hysteria about injection attempts is ramping up, given that the source code of the site is openly available
 
Well, you can also explicitly sanitize your input in that case.
pass a template of 'Product {int}' or whatever and check it against your input
modules like parse could probably help with that
you can even raise specifying the invalid key
 
@roganjosh Just to be sure: Encountering an invalid input means your application state has been corrupted, is that correct? How else could invalid input show up in those pre-defined options?
 
@MisterMiyagi it could only happen via tampering with the HTML (as far as I can think ahead). My concern is just whether dumping a full list-comp into a try/except looks sloppy. In the case of an actual exception, I'd really rather the whole app didn't burn as you suggested - I'll just give an "Aha, I've caught you meddling" message
@MisterMiyagi you can see something similar on the live version if you put something non-numeric into the forecast table
 
Take option b), burn the request, then.
 
11:27 AM
Given that everything other than the list comp is what's generated the feedback, I suspect that I was just being silly worrying about wrapping a list comp in a try/except :)
 
Once you know that some of the information has been meddled with, how can you know that the remaining information hasn't been meddled with? In other words, what's the advantage of recovering the other parts?
 
@MisterMiyagi exactly my thoughts. I just didn't know whether it appeared a bit amateurish to be dumping the whole payload
 
If you're unsure how it comes across, just add a comment that makes it clear you pondered this properly. Make sure to sassily imply it is obvious to everyone but total loonies.
"As can be trivially shown, this is the safest approach."
 
Well, not just looks but maybe was. I very rarely get any feedback on my code other than SO answers so I wasn't sure whether it would be expected that I had some elaborate mechanism to handle an individual input... when all I want to say to the user is "bubye"
@MisterMiyagi love it. I shall do just that. Thanks :)
 
11:48 AM
Perhaps return a fake loading screen that never returns. Maybe a progress bar that approaches the end as 1/t.
 
The ultimate troll: "Windows is searching for a solution"
 
@roganjosh Consider using partition instead of split, and... an asspression?
product_list = ['Product 1', 'product 77', 'multiple_spaces  42', 'malformed',  'mal formed 100', '']

parsed = [int(item_no) for item in product_list if str.isdigit(item_no := item.split()[-1])]
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "<input>", line 1, in <listcomp>
IndexError: list index out of range

parsed = [int(item_no) for item in product_list if str.isdigit(item_no := item.partition(' ')[-1])]
parsed
[1, 77, 42]
Or just write a safe_int method that does a try-except around return int(s) or returns None, and then change the condition in the list comp to if (item_no := safe_int(item.partition(' ')[-1]) is not None)
parsed = [item_no for item in product_list if (item_no := safe_int(item.partition(' ')[-1])) is not None]
 
That's the kind of lateral thinking that spooks me when the backend validation is fully published :) I'm quite happy to assume that any failed parse is an attempt at injection. The user experience may suck in corner cases, but so be it
 
12:28 PM
@LinkBerest but my question was asking specifically about SRL (Semantic Role Labeling), not "What NLP flow in general?"
 
12:42 PM
@DarthV No, but if you just look at the source it should be obvious.
 
12:56 PM
@roganjosh Separate issue, the list comprehension is fine, but it's bit clunky and ugly to keep doing [int(item.split()[1]) for item in product_list] every single time you want to access the first field. Can't you store config['MACHINE_NAMES'] as a list, in the first place?
 
I could shove it into a global, and it would be refreshed on an app reload, but I just don't like it. I don't think my objection is any stronger than "I don't like it", though, so it's a fair comment
Ah, hold on, I think there's crossed wires
@smci I don't know a better way to pull the data out of the form from this
But I'll fully agree that it's clunky
 
1:44 PM
cbg all
 
2:23 PM
@smci The one that starts with G in that list is pretty good at that task (if that is the only task to be completed)
 
2:45 PM
@LinkBerest Google Cloud NLP API? Uhuh, that's what I'd heard. I was also asking for an open-source stack that does the equivalent (at least for some domains e.g. legal-document, SEC-filing, pharmaceutical), but the answers to that seem very fragmented and incomplete.
..at least in Python. Java APIs are more advanced in this area
 
no from my list Gensim
That's one of those libraries I want to look into more but just haven't had a chance (covid tripled my work so all my research opportunities had to be pushed back)
 
3:39 PM
@LinkBerest Sorry, no, and you've misunderstood the question. Gensim doesn't do SRL (Semantic Role Labeling); I've given the link three times already, if you don't know what the term means, at least skim the article. SRL means labeling the roles in a sentence(/document), this goes far far beyond simple POS tags and parse-trees, it invariably also requires interfacing with a knowledge base/ontology plus NER...
 
I understand the term. Gensim doesn't offer it out of the box but it is within the paper the person who made it wrote (though I will admit I use a bunch of Java APIs for this type of classification due to Spark)
 
...For example, take today's NYTimes headline "G.D.P. Figures Reveal Record Decline of American Economy" and run it through Allen NLP's Semantic Role Labeling Demo
 
So beyond that one - I don't know of any open-source, python tool for that (or at least not a great one)
 
I'm feeling like I'm majorly overcomplicating something. Is there a shorter way to do this?
map(lambda x: x(), iter_of_callables)
 
fwiw: I heard the same with Google Cloud APIs but I haven't used them myself
 
3:43 PM
...if we don't know what "GDP figures" means and that they relate to "economy", then the sentence is as meaningless as any other: "Noun-phrase Noun Verb Adjective Noun <of> Adjective Noun"
@LinkBerest uh I already named both Allen NLP and Stanford Core NLP ; also people mention Senna NLP which us under non-commercial license.
 
Though thinking about it I don't know if Gensim was the only tool used in that paper (might have been a spacey, Keras, Gensim mix for this type of operation)
 
@LinkBerest Gensim is for LDA and word-vectors, is all I've ever heard. Not SRL, domain-specific NER, etc etc.
 
Also I didn't see your self-reply until this morning (if I had I wouldn't have replied because I don't have anything really to add to that - its basically the same that I found) - what I get for just glancing through the transcript
 
@LinkBerest Yeah no worries. Allen NLP looks quite nice. Try out that demo...
 
AllenNLP I've used but not for this task - it works pretty well for me :)
@smci ah, found the paper. It was my misremembering - Gensim was used but not as part of the SRL portion. Sorry about that
 
3:51 PM
@LinkBerest No worries. Appreciate the response.
 
Too much work with too many tools sometimes my brain explodes :)
 
@LinkBerest Right. I recently found out (while trying to cook up some multilingual NLP examples) that the last few years of MacOS releases have been messing with support for 'eo_'/ Esperanto locale. Hey does anyone know some curse words in Esperanto...
 
....I hate working with Apple (I have no basis on this other than I do it just enough that I think "this is Linux" but then remember its not)
 
@MisterMiyagi If each element in the iterable shares a common parent type that implements __call__, then perhaps map(the_parent_type.__call__, iter_of_callables). It's probably not good OOP design though.
 
3:56 PM
Yeah, I've been working on multi-lingual subjects within my research for years. I'm more on the signal processing and architecture building side now but still get to play with Spanglish every once in a while
 
@LinkBerest My reaction is simply that Apple have mindblowing amounts of money, and there's no competitive reason not to continue supporting 'eo' locale, so just do it already guys...
 
when it comes to signal processing - I hate Chromebooks. They have the weirdest default file types for audio/video capture
 
@Kevin Sadly, they're a mix of functions, methods, partials and objects. I've tried mapping object.__call__, but that did not work.
 
Yeah, I was toying with that and I don't think object's call is defined in the right place for that to work
 
@LinkBerest Oh, cool, what NLP stack do you use for Spanglish? 'Taglish' (Filipino-English) is also interesting - Filipino news articles are like a 4+-language creole of English, Tagalog, Spanish, Jejemon (Filipino textspeak) and occasionally other stuff (e.g. Japanese, Hindi)
 
4:00 PM
Jun 8 '16 at 2:12, by JGreenwell
yeah, that doesn't work with stuff like Spanglish (no documented rules means it is hard to create corpus). One has to first analyze for semantic extensions then analyze the sentence structure to determine grammar, build a coordinate structure, etc....basically at this point I'm building my own corpus and CFG
^ I did not realize how long I had been working on this problem (its one that keeps causing other problems which I solve - write papers etc on those - but never quite solve the "BIG" problem)
 
@Kevin I guess good old apply would get me 90% there. Not willing to touch py2 to find out, though.
>>> map(apply, (int, float))
[0, 0.0]
Curse you, Py2, with your working code!
Couldn't resist to try... :/
 
@smci I do use Allen NLP for that (and several of the other ones I mentioned earlier). A lot is NLTK based simply because I still need to change it to Spacey or other tools though
Future me regularly hates past me for the code I wrote
 
I'm surprised that apply is completely gone from Python 3. I figured it would be squirreled away in functools like its brother reduce
 
@LinkBerest Online internet-user creoles are like the ultimate ephemeral/drift case: noone can "solve the "BIG" problem", you simply come up with a dynamic model that you retrain (daily/weekly/monthly, depending on your resource budget). For example one common trait in Filipino showbiz articles is giving 'portmanteau' names to Filipino showbiz couples (like 'Kimye' and 'Bennifer' in English). That's going to defy NER unless you learn it...
 
also, I want to smack myself for that old answer (its not 100% wrong but I was off on a enough things with that explanation that I annoys me)
 
4:04 PM
Facebook gave some interesting talks about their NLP, in 2019.
 
@smci yep - and that keeps the funding coming (also why I moved into the signal processing side more - was a lot of opportunity there)
 
@LinkBerest Sorry, but there's a queue for the time-machine... to coin a paradox :S
 
yes, yes. I remember I was banned because last time I ended up slapping myself twice and then Fizzy had to fix time
Anyway, a man can dream and its better to have a near impossible dream that keeps teaching you new stuff than a dream that is easy to achieve and teaches you very little :)
 
@LinkBerest Uhuh. What's your favorite book by Philip K Dick or other author?
 
Asimov - anything in Second Foundation
though in reality its I cannot pick a favorite - it changes all the time based on my mood. currently reading A Hat Full of Sky to kids and enjoying that (Pratchett)
 
4:19 PM
@LinkBerest <3 Tiffany Aching books
 
they are really awesome (not just as kids book)
 
Tiffany Aching is a fictional character in Terry Pratchett's satirical Discworld series of fantasy novels. Her name in Nac Mac Feegle is Tir-far-thóinn or "Land Under Wave". Tiffany is a trainee witch whose growth into her job forms one of the many arcs in the Discworld series. She is the main character in The Wee Free Men, A Hat Full of Sky, Wintersmith, I Shall Wear Midnight and The Shepherd's Crown. Tiffany grows up over the course of the series, from nine years old in The Wee Free Men to being in her late teens in The Shepherd's Crown. == Works == Beginning with The Wee Free Men in 2003, the...
 
but no spoilers, I haven't read all of them yet :P
 
I haven't read the last two yet (waiting to read it with the kids at this point)
 
@Kevin I'm sure an SO question would recommend using pandas.
 
4:29 PM
I mean pandas are so cute - why wouldn't you use them everywhere?! ;P
 
It's all about the honey badgers
I mean... pandas are cute, but they suffer one critical flaw - they're not honey badgers
 
if I ever invent a cool library, I'm gonna name it Narwhal
 
4:50 PM
pandas are cute.
 
@LinkBerest I feel we may have left a cool joke hanging so I'll bite the bullet: why?
 
I like narwhals - their cool
 
Oh, well at least that's settled :P
Similar to "I like turtles" became the turtle library
 
hmm...I was just going to edit this question to have a Python tag - and fix horrible title but now I just think I should close it
 
 
2 hours later…
6:52 PM
hi, is it possible to search for questions asked only within the last 2 years? i keep getting stuff from 9 years ago which doesnt work
 
thanks!
 
anyone who's experienced with nonlinear optimization here?
 
@PedroSpinola A tiny bit, what's your question?
 
I have made a post on SO with a question related to the problem I need to solve just 30min ago.
But what I wanna ask you is:
I don't even know what linear algebra is. I have finished college it's been 15y and didn't work or study with nothing related to it since then.
 
@PedroSpinola Under the Room rules, you're not allowed advertise a question here until 48 hours after you post it.
 
I'm not.
What I'm asking is if you think I have any chance of learning this stuff for this single project, in yoour opinion
Or if the knowledge required is too deep into maths.
If you think it's possible, I woould ask for proper reading material (guides,tutorials,etc)
Because I'm having a really hard time lmao
 
7:39 PM
@PedroSpinola Hmm. That's not even a Python question, so it's offtopic for this room. There are like a billion online courses, tutorials, videos, blogs, out there. If you need a refresher course in linear algebra then please go find one. (Either way, it would help if you define what exact area and level of linear algebra you want to refresh on.)
 
I'm lost, honestly. I'm not sure what I should learn so I can understand and make my nonlinear optimization code work. It's written on Python Scipy this is why I'm asking here.
 
@PedroSpinola: I can't even find a question asked in all of July under your name, did today's question get deleted already? If you keep finding your questions getting downvoted and/or deleted and/or don't attract good answers, please skim the Help on how to ask good questions.
 
Not deleted, it's right here:
 
@PedroSpinola Ok, but you're not allowed advertise questions < 48hrs, please delete that before it gets flagged.
@PedroSpinola and anyway your issue was nothing whatsoever about algebra or numpy, you already got comments telling you it was merely that in Python list2 = list1 never makes a copy of list1. Recommend you try any of the many good Python basics courses out there.
 
I think you got the wrong link because there are no comments to this question yet.
 
7:56 PM
I saw your link briefly but can't see it now again, perhaps it got deleted. The only general advice I can give is: Learn the absolute minimum linear algebra (or whatever domain) you need to achieve the specific task you have in hand, and if you ask any (Python-related) questions, very clearly post your code, data, the expect result and the result you got (including error or stacktrace). But for the subset of your questions that aren't about Python programming, then SO is not the right forum.
 
alright. thanks for advice man
 
Example: I just reworded this recent question of yours, and it's useful to use the term 'constraint'. Like "Generate all combinations taking the elements of <list> 2,3, and 4-at-a-time, and subject to constraints on what can legally be combined, according to the predicate function verify_combination(component1,component2)
@AndrasDeak: I saw you've been fielding questions claiming (without MCVE) that import not working, here was yet another...
 
8:18 PM
what's the best practice to pin sub dependencies
 
I want to sort the list according to the order of the elements in the list
 
8:39 PM
@Jean-FrançoisFabre ... seems that OP wanted to 'enumerate' the list's values as a string f"{index}, {value}", then sort that string in numeric (rather than string) order. Misguided premise. Should have used a tuple. Decorate-Sort-Undecorate.
 
@Jean-FrançoisFabre just another day on the front page
 
but but why sorting when the list is already sorted?
 
@Jean-FrançoisFabre see my previous message ;)
 
@AndrasDeak I must say I don't answer python questions anymore for a reason
 
odds are OP oversimplified their MCVE
 
8:41 PM
@Jean-FrançoisFabre Apparently because the OP never heard of a list comprehension. Like I just wrote above: the OP wanted to string-insert the list index into each value.
 
probably. Then it's a duplicate of "does python have a natural sort order"
 
OP knows how to sort by key... so the only issue is that they have strings rather than 2-tuples...so it's basically "unclear what you're asking" or "mental typo"
 
@Jean-FrançoisFabre No, it's a duplicate of "What is a list comprehension and when should I use one?" but the OP isn't aware of that.
 
I went with unclear due to the enumerate aspect
 
I have x and I want x: okay, done
 
8:42 PM
@smci that's again a non-trivial interpretation of an unclear question
 
unclear it is
 
+1 emoji thank emoji
@smci sorry, I just noticed the notification for this message. What do you mean by "fielding"?
 
@Jean-FrançoisFabre Actually the OP does know what a list comprehension is, they use one then try to sort the output...aargh...
 
people often overlook tuples, and compose a string with 2 data, that need separation further on.
 
in the meantime that question was answered, and it was something most people could not have guessed
@Jean-FrançoisFabre fortunately I haven't seen that yet
 
8:44 PM
2 telepathic people met.
 
@AndrasDeak "getting", "receiving", "dealing with"... a flood of questions claiming (without MCVE) that import not working, usually either simply because the package was not actually imported or installed (copy-paste on a notebook), or alternatively because they wanted todo the import in a funky way, see the one I cited... Data science as a cargo-cult...
 
also, it was a TypeError, not an import/name error
@smci I see
I haven't been consciously focusing on any kind of question... I just close whatever I come across and needs closing
 
@AndrasDeak I said there has been a flood of such questions recently, verily... and trust me I'm also trying to blot them from my consciousness.
 
I see, thanks for clarifying
 
@AndrasDeak so you can close all new python questions then....
 
8:47 PM
...who was the person who was (last year) predicting 'Peak StackOverflow': when as many low-quality new users join as get banned plus burned-out existing users becoming inactive...
 
@Jean-FrançoisFabre only 99.9%
 
yeah, the remaining 0.1% is deleted by OP after getting downvotes
 
@roganjosh I don't have any link, but I'd like to see whatever your current best link for that is. You can safely predict member-state interpretations of GDPR are still in flux, and will continue to be with the the current US-EU antitrust and tech regulation... it's very important issue, but a moving target. And of course there's CCPA in the US (for any California-headquartered company).
@Jean-FrançoisFabre Never use a hammer where a drop-forge will do...
 
@smci I'm more and more using mod powers instead of trying to find a good dupe to hammer.
 

« first day (3575 days earlier)      last day (1362 days later) »