« first day (3518 days earlier)      last day (1413 days later) » 

12:02 AM
@MisterMiyagi is that string theory?
(better late than never)
 
wim
@AaronHall Ah, I wanted to delete the question since it's negatively scored. Can you do that?
I noticed you posted same answer on the dupe target, so we don't need both.
 
You're at +2/-3, so it will cost you... 14 schmeckles. ok, to be serious, is it a identical dupe?
 
wim
yep
 
Yes, why the link and onebox?
 
12:15 AM
@AndrasDeak do you have an honest opinion on the identicalness of the dupe target...
 
wim
all comments on dupe target could be zapped too, they refer to a previous edit of the question.
 
You know, we'd usually flag an identical dupe for deletion explaining why...
that way I can abstain due to my conflict of interest...
 
we don't need a mod to delete that question
@wim if you flag them as no longer needed they'll be gone
 
wim
12:30 AM
@AndrasDeak I am not eligible to delvote it for some reason
 
Because OP can't delete if there's an upvoted answer...
it's not smart enough to allow your usual 1 delvote out of 3. You can only have a binding vote.
 
wim
ahh yep.
recommend to delete it because that conversation with 2357112 is not reflecting well for you - asking other users for upvotes is sort of frowned upon?
 
very much
but so is dupe answering, so... :P
 
 
2 hours later…
2:45 AM
@MisterMiyagi In that answer's recipe, would it make sense to simply wrap getattr(obj, attr) in a try/except, in case you want to assign None/False, and also lose the conditional, so you also get the intended error message if the attribute isn't present in the subclass?
 
3:00 AM
stackoverflow.com/questions/61792921/… - accepted answer and the associated conversation contains some rather misleading opinions
 
wim
3:11 AM
smells like socks
 
3:47 AM
Good God what is going on with these answers?
 
 
2 hours later…
5:49 AM
@JonClements: another one I'd like to add to canon: Normalize columns of pandas data frame
 
Refactoring old code sucks! I know I'm going to end up almost completely rewriting at least 50% of the code I'm modifying to accommodate the functionality I just rewrote.
At least I can see from this old code that I've clearly grown from a year or two ago...!
 
cbg
@toonarmycaptain Refactoring in a dynamic language is a bit of a pain.
 
@IljaEverilä The bigger pain for me right now is using painful code, that I know I'll be rewriting as a class or two (maybe one of them will be a dataclass) eventually.
 
6:40 AM
@AndrasDeak Might be Lund strings.
 
7:04 AM
@toonarmycaptain use getattr if you want the native error message, or hasattr if you want to manually trigger a custom error. if not getattr(obj, attr_name) is indeed not strictly correct due various objects being falsey.
 
user12267139
7:27 AM
I have a regex Expression which filters if the string is a digit or contains a single comma ^[\d]+(?:,[\d]+)?$ Im trying to extend the expression to filter floats as well
 
Change , to [,.]?
 
user12267139
@Aran-Fey thanks forgot to use the breakets
 
Sam
cbg all. Any of you guys have recommendations for asgi frameworks in Python? I've stumbled onto Quart but want to hopefully compile a list to further research
 
asgi has too many complicated words in it. Anyway the whole of internet stuff has too many complicated acronyms :P
 
Sam
7:48 AM
lol
To be fair, I did not know what asgi was until late last night.
 
haha
 
8:07 AM
Hello @all I am trying to integrate swagger win flask app using connexion module, but getting below error
python3.7/site-packages/connexion/utils.py", line 68, in deep_getattr
return functools.reduce(getattr, attrs, obj)
AttributeError: module 'user' has no attribute 'create'
have anyone faces similar issue or have idea how to fix it
let me know if you would like more information, code
 
P.S., it is not a new question
Its 5 days old
 
8:41 AM
> I'v just started programming and have created a linear regression model that allows me to extract a root mean squared error from it to determine how accurate the model is.
I'm sure there will be no problems with that
 
8:57 AM
I'm regularly impressed by the capabilities of beginning programmers. Right before they ask about the most trivial or problems.
 
I'm not saying it's guaranteed that they'll be stuck on basic stuff soon, but there's a high chance.
Having a project to work toward does help in learning. But all too often I fear it's more like an Icarus situation...
 
When I was new I made a mod for Quake 3... added a bunch of new weapons, added hit zones (headshots, etc), and then at some point I needed a function to accept a "rocket" instead of a "missile", so I copy-pasted the whole thing and renamed the parameter...
 
 
2 hours later…
 
2 hours later…
12:20 PM
@Sam I didn't get to try it in a production environment yet, but fastapi with uvicorn was really nice to work with
 
I am using configargparser and it works like a charm, but when using single letter params like -m the autocomplete breaks. Have you guys noticed that and do you know a workaround? Because like that single letter params are useless
 
1:06 PM
haha I went up to a coworker and told him I need a cookie :D
The look on his face :P
Because of: "You are seeing this message because this site requires a CSRF cookie when submitting forms."
 
@Hakaishin you use configparser to parse command line args?
 
ahh, that "arg" part slipped right through my attention span.
yeah, no clue. I only know about docs.python.org/3/library/configparser.html
 
:P Sometimes I miss the most obvious bright flashing information, because it resembles spam or an ad too much, that it get's autoblocked by my brain. Don't tell the ad agencies, that ads in normal small black font are the most effective with programmers :D
 
1:23 PM
@Edo98 Please take a look at the room rules. We ask not to promote question more recent than 48h, to avoid duplicate information on main and the chat.
 
2:16 PM
cbg all
 
Realized yesterday I'm trying my file access in reverse. I'm going to be using a linux system to read a file on Windows system. Seems a bit easier.
 
Frankly, neither should be that difficult. There's ssh, there's smb, there's nfs, there are all sorts of means to exchange data between the two.
 
It's more difficult when you're an embedded hardware engineer XD I'm learning tho and enjoying it along the way. Trying to pick up best practices the first time too
Also I'm trying to do it in Python. Accessing the file itself isn't bad. Trying to build it into my logic controller for something is a bit more...interesting @MisterMiyagi
 
Hm, I guess so. I'm afraid I've never worked with an embedded system that needed to serve data but was too small to deploy a convenient daemon/service.
Though if Python isn't too heavy for it, some proper service probably isn't either, no?
 
PSN
2:31 PM
Hello
I need help with a Django project
 
@MisterMiyagi so essentially I've got a state machine. I'm using a Linux SBC as a slave and reading from the master (Windows PC) a text file that will determine my next state on my state machine logic.
So If a service/daemon is the way to go, I'm all ears (might need just a link to explain how to do it)! I was just going to put it in my main python logic files.
 
@biggi_ That sounds like communication, not data serving. Have you considered sockets?
 
I haven't yet. Currently it's setup as a text file that a LabView program on the same machine is reading. If possible; I was going to try to make it easier on the other guy and read the text file since these will all be on a network switch and it seems possible.
Let me rephrase: I've considered it. I thought this might be the "better" of the two options.
 
2:47 PM
Anyone know why Stack is sending out emails say I need to search better?
What would even trigger that.......I haven't used search in a while. sigh just made me turned-off everything in email settings
oh, nvm Google found it - its a sneaky way to advertise Teams
 
Nice.
 
You can definitely set that system up with a server configuration (running a daemon or service)
 
Do you have a link or something that may help me understand it better?
 
21 hours ago, by LinkBerest
I've used RaspberryPi to setup web & print servers before so I know its possible but its beyond this room (more a superuser question at this point and you'll need to research it before hand)
I actually like RaspberryPi for stuff like print servers (cheap and highly-configurable is nice in those instances)
 
Yea; I'm just trying to see if that's best. I'll need to read it, base logic off it, then read it again/etc. Keep looping and what not.
To be honest; I think the biggest issue is that I've never done anything like this so I'm not even quite sure where to start. With that being said, I've just started trying a few things that don't seem to work or wont' be a good way and I move onto trying something else.
 
3:09 PM
You start by reading then trying then continuing that loop (as this is one of those questions which require a certain level of basic networking knowledge which if you skip and go straight to "copy & pasting code" will hurt you in the long run)
I think it took until graduate school (and learning to read journal articles) for me to fully learn that lesson
 
Yea; I'm not looking to copy/paste code. Maybe just looking for a nudge (or kick) in the right direction haha
 
I've already pointed you to using OpenSSH (on windows which includes the ability to use a secure file copy, scp, to connect & copy a file - there are also plenty of 3rd-party apps which allow this). Again, you can map the device (yes, you can map a Linux computer on your home network to your windows 10 machine). Or you can set it up as a server or use sockets <- search for any of those
 
wim
3:36 PM
Anyone tried the Rust implementation of Python? github.com/RustPython/RustPython
 
@biggi_ If you want to try sockets, I recommend working through the Socket Programming HowTo. If you grok it, you should be able to build an app that communicates with another instance of itself using a simple, self-designed messaging protocol. Basically a distributed echo program.
@wim Nope, just seen it mentioned in the 0 is 0 Q. Didn't know they were production ready yet.
 
Will look into it! I'm setting Ubuntu up on an old Thinkpad for testing a bit
 
@wim I don't see the point, TBH. Don't see Python going anywhere without adjusting the language for proper compilation/JIT support. No point creating yet another heap of hand-crafted optimisations that will need burning in the future.
 
wim
can be compiled to wasm, maybe that's cool for python on browser?
 
doesn't C go to WASM these days as well?
 
3:56 PM
I've never heard of a legitimate job which uses webassembly (could just be my market but just saying)
 
C & C++ are the only things that compile directly to WASM (there's support for other languages but it varies)
 
@LinkBerest as far as I'm aware, LLVM can compile to WASM, so any Fancy New Language should work as well.
 
yeah, it should but I haven't seen the garabage collection working correctly for full Java/C#/etc support
technically, just Java personally (when I play around with internals to figure Spark stuff out) but C# is similar so I'd imagine
Mostly I hope it works out as it be nice for certain applications but it does feel a lot like a "we have too many standards so lets make one more to combine them all" situations (to me)
 
4:08 PM
hi! I'm using WTForms DecimalField and I would like to translate to Spanish the 'Not a valid decimal value' error message
how can I do that?
 
google tells me that some (all?) validation objects take an optional named paramter, message, which controls what error message is displayed
 
but this is not a validator
 
Hmm
 
I know you can do that with InputRequired(error_message)
but I'm talking about the field, DecimalField
 
Google tells me that Field objects have a _translations parameter
_translations – A translations object providing message translations. Usually passed by the enclosing form during construction. See I18n docs for information on message translations.
 
4:13 PM
hello guys
 
is it raised as an exception? If so you may be able to chain the exception and just put whatever message you want
 
that sounds interesting
let me try
 
thanks!
I'll let you know
 
Chaining the exception might be a sensible approach if you want exactly this message to be in spanish, and everything else in English
 
wim
4:17 PM
huh, that exception chaining answer is weird.
unless I misunderstood something completely - if you raise from an except block, it will be already chained from the error that the try block raised. to chain it explicitly should only be done if you wanted to chain it from some OTHER error instead
 
oops...I didn't mean to link to the answer (only the question) but was looking at its edit history and hit back before copying the link
 
@wim There is a minor difference of "NewException was raised unexpectedly while handling the old Exception" versus "NewException was raised on purpose while handling the old Exception". The distinction is basically impossible to convey with an explicit except OldException: raise NewException because that is always on purpose.
One probably also needs ten years of mediation on a secluded mountain temple to see the benefit of this level of detail.
 
My power just flickered. I hope my internet continues to work, because there will be Consequences if I don't show up for the very important video conference in five minutes :-I
Stand back, I'm going to use my mind powers to repel the thunderstorm for thirty minutes
 
that happened to me yesterday - my battery backup lasted for 30 minutes so just missed saying goodbye (which made me seem a jerk)
 
wim
@MisterMiyagi I meant the context will be set anyway without using "from exc". So why add that?
 
4:25 PM
cbg, hope I am not interrupting anything, can anyone tell me if it is possible to set a default style to all buttons in PyQt? I tried to google "pyqt set default button color" but no results
 
Hmm, the thunderstorm wasn't repelled. Must be one of those mind-power-resistant clouds that the government has been manufacturing.
 
@wim from exc sets the .__cause__, not the .__context__.
For most people, that just means the traceback has some minor different wording that no-one notices.
 
Best package to automate google searches?
I tried "pip install google" but there's no docs on it. At all.
 
wim
@MisterMiyagi that's true but it's not really a good example because the reference is already there in __context__ (why put it into both?)
the chaining is more useful when raising from outside of an except block, imo
 
# During handling of the above exception, another exception occurred:
try:
    {}['Kevin']
except KeyError:
    {}['Miyagi']
# The above exception was the direct cause of the following exception:
try:
    {}['Kevin']
except KeyError as exc:
    raise NameError from exc
 
4:28 PM
 
@JossieCalderon Where did you hear of this package?
 
@wim The answer is pretty bad anyways – the question already says they know this works. They're asking for a Py2 solution.
 
I googled "pip install google"
 
It's bad enough to demonstrate something, but that something was not even requested.
 
wim
@MisterMiyagi yes, I get how it works. I just don't think the answer really gives a typical usage example for why the feature exists
 
4:30 PM
Agreed.
 
wim
it's a self-answer shrugs
 
@JossieCalderon as with anything Google use their API (its google-api-python-client)
 
If you want to search for packages, you are better off going to pypi.org and searching there. When I looked at pypi.org's entry for the "google" package, it points me to a couple of downloadable whl and tar.gz files (so pip installable), released in Dec 2019, but the project homepage is nothing related to that package that I can see, and not updated since 2017. I would pip uninstall that asap until I know more about it.
 
@PaulMcG alright, that makes it really weird.
 
wim
sometimes I suspect people just post a self-answer when they hear about a new feature, even if they don't really understand the feature yet 😒
 
4:31 PM
@LinkBerest thank you for that, I will see how I can make use of it
 
@wim true. but in this case, they already knew it a month earlier. oO
 
@JossieCalderon - be aware that "pip install something-something" just to see what it does is pretty risky. In the past, PyPI has had nefarious packages uploaded that mimicked well known packages but with slightly misspelled names, like "pip install reqwests" for example. Many have been cleaned up, but you should do a little homework (and be careful in your typing) when pip installing.
A "google" PyPI package would be an easy mark for getting people to download more than they bargained for (I don't know that that package is bad, but A) I never heard of it, and B) the bogus homepage is suspicious.)
 
C) Google has an official package and its not that
 
I must be missing something because I do form = CalculationForm(request.form, meta={'locales': ['es_ES', 'es']}) but I still getting 'Not a valid decimal value' error message for DecimalField
 
CBG
 
4:40 PM
any thoughts? I keep googling but I only see Babel based solutions and I would like to use the WTForms built-in one
 
sure, wtforms is weird: is this an application-wide level?
 
I run a command to start a CLI app.
FLASK_ENV=development FLASK_APP=src/api.py flask run
It works great! Another dev checked out my project and ran it and he can only get it running if he does a absolute path to the `api.py` file. Anyone have any idea?
It says flask.cli.NoAppException: Could not import "api".
 
Are you both running the terminal from the same location?
 
@roganjosh yes
 
4:46 PM
Possible causes: PYTHONPATH env var not set correctly; missing or incorrect .pth file in site-packages; no __init__.py in src dir
 
wim
@PaulMcG it is neither official nor malicious pythonhosted.org/google/google-pysrc.html
 
@PaulMcG both of us don't have the __init__.py... It was never there.
 
Ok, so probably not the cause
 
wim
@MisterMiyagi my bad, it was a 2009 question. kinda weird
 
How would I debug the PYTHONPATH being incorrect
I don't have the PYTHONPATH set either
 
4:49 PM
It's an environment variable - look at your environment vars (on Windows, the command is "set"; on Linux its "env")
 
When I print print(os.environ["PYTHONPATH"]) I get KeyError: 'PYTHONPATH'
 
Print out 'sys.path' on both systems
 
I don't know what we're talking about but messing with PYTHONPATH can't be the solution
 
r_form = MultiDict([("birthdate", "invalid date")])
form = MyForm(r_form, meta={'locales': ['es_ES']})
print(form.birthdate.process_errors)
^ Tested on my machine and worked fine (after building the MyForm & BaseForm classes the documentation showed) so don't know
 
Is your colleague on Windows? @Johnston
 
4:52 PM
@roganjosh both on Mac
We both have a relatively similar sys.path
It's the flask command that doesn't find the module.
 
5:25 PM
please, any thoughts?
I cannot find any working example
must I assume that it only works with wtforms Form? I'm using a FlaskForm from flask_wtf
 
wim
5:39 PM
this is not flask tech support chat. give your question on main more than 7 mins for people to answer..
 
I know it is not...
 
this is a dupe of that
^closed thanks
 
5:57 PM
Ok so I figured out why this is happened for me but I don't know how to fix it.
My other devs computer has system.path a few directories under mine (the parent) and mine is at the source.

I don't know how the `sys.path` determines to set that `sys.path`
Why would his sys.path be a few levels up from mine?
Neither of us have PYTHONPATH set AFAICT
Ok I figured it out
The other dev has a .env in a parent dir and I have one in the current directory. telling load_dotenv to load the parent env file seems to change the sys.path
 
6:22 PM
how can I split a long command line into separate lines (each argument on a separate line)
 
did you try .split?
note that command lines have a fixed limit how much data can be passed through them, which is not increased by using separate lines.
for shell-like argument splitting, use shlex.split.
 
I want to document my command and want it on separate lines (one line for each argument) but it would be nice if reader can simply copy and paste it to command line to run it
I've seen such thing done in online documentation on Microsoft documents but for azure comman line interface
I'm trying to find an example
for example

az aks create \
    --resource-group myResourceGroup \
    --name myAKSCluster \
    --service-principal <appId> \
    --client-secret <password>
when I search google for something similar for python they keep pointing to string split() method but that's not what I meant
 
even if that's possible, it almost certainly won't be cross-platform
so... which shell are you targeting? bash?
 
windows command prompt
 
oof
I'm gonna go ahead and say it's not possible :P
 
6:32 PM
thats fine
what about inside jupyter-notebook?
 
no clue, sorry
 
thats ok :) I can keep it one line
 
jupyter+subprocess just uses lists of strings, like the rest of Python. You can format lists across multiple lines natively.
 
Sam
7:00 PM
@Arne thanks for sharing :)
 
@MisterMiyagi Thanks, didn't know about hasattr. I think custom message is preferable, as the implementation isn't important.
 
Sam
7:31 PM
What's the etiquette for making changes to an open source project which hasn't been active for years.. should I reach out to the author with a PR or is it acceptable to keep it contained in your own repo?
 
as long as the license allows it, there is no problem keeping the changes to your own repo.
Though if the contribution is useful and there is any chance the original author might include it, opening a PR certainly helps make the world a better place.
 
Sam
Yeah. I think the latter is true in this case. Will attempt to reach out first
thanks
its a GNU General Public License
 
@Aran-Fey its possible but it would be difficult if your not used to .Net or Powershell
well, not that hard assuming your wanting to do something like (this is PS):
powershell -noprofile -command "&{"^
 "$process = start-process powershell -ArgumentList '-noprofile -noexit -file script_to_run.ps1'^
 -verb RunAs -PassThru;"^
 "$process.WaitForExit();"^
 "}"
^ from memory, I'm on my Chromebook so may or may not be 100% correct syntax
 
7:59 PM
powershell is cheating!
 
@Aran-Fey Why?
 
@Aran-Fey if that's cheating, I don't want to know the honest solution!
(Okay, that's a lie. I do.)
 
@AnnZen no real reason
 
because not as many people know it (well) and there's a solid amount of "little hacks" that just work but are massive security holes (much of which caused by people not realizing that you should have an admin account when developing in Windows - i.e. a "root")?
^ thankfully less true in recent years
 
8:36 PM
I have trouble talking about base class versus meta class lately. Per LSP, the relation between class and base class is "is a" – list "is a" object. What's the equivalent for the meta class – list ??? type?
 
I usually see "is a" used to describe an instance -> class relationship
For a class -> base class relationship, I think I'd say "is a kind of"
So "list is a type", and "list is a kind of object"
 
wim
Can't believe I am the first downvoter here stackoverflow.com/a/1350574/674039
The question is about sandboxing, and user suggests to put sys.modules["os"] = None as a means to prevent malicious code running.
 
bad idea, good execution
 
wim
8:51 PM
good execution?
 
...assuming nobody needs to import os anywhere else in the program
ok, bad execution
 
wim
@Aran-Fey "is a" is usually describing subclass -> class.
it's language used in contrast to "has a" (composition)
I've never heard "is a kind of" used before.
@MisterMiyagi "instance of" maybe??
 
@wim neither have I (:
 
@wim That could work. The "kind of" also rings some bells, but my Type Theory is week today.
 
9:45 PM
Yet another asking of "How to find the dataframe row(s) containing the max of column X?" stackoverflow.com/questions/62168733/… . However as to which target to use...
...should use this top-voted answer? I gave it the update it badly needed, since argmax() is history, it was deprecated ages ago; pandas long-ago switched to row labels instead of integer indices; pandas users are warned not to use duplicate row labels. (but if they insist they can). Instead of integer indices, logical indexing works fine, and can be converted to integer indices with np.flatnonzero()
... Find maximum value of a column and return the corresponding row values using Pandas is also a duplicate, and again its-top-voted answer uses idxmax() which assumes unique max..
... Python pandas idxmax for multiple indexes in a dataframe wording is confused, and anyway, just use logical indexing already, not idxmax()
 
10:42 PM
@LinkBerest That's for using Google accounts...I just need to do a simple search and was wondering if I need to re-invent the wheel here.
For example, I want to build a function "gSearch(myString)" that returns something from the pages of google (list of results) that I will scrape myself.
 

« first day (3518 days earlier)      last day (1413 days later) »