« first day (3906 days earlier)      last day (1043 days later) » 

12:36 AM
@AndrasDeak PHEW. ok. got it working from terminal (still not sure how the binary ran).
 
sounds good, nice job
 
looks good
 
dump of parent and child pid to confirm your testcode
 
yup, I've figured it out eventually
 
12:39 AM
now just to find out why it's pickling on windows vs linux...although I believe it's due to windows not being able to use fork()
 
probably, yeah
 
so instead of parent/child proc it's spawning sibling processes?
If that's the case, somehow pickle picks up on that (detecting OS?) and throws failure.
 
Also probably, yeah. But if I was unsure earlier I'm not even here now; I haven't used windows in a very long time.
 
would have been great to have known that BEFORE architecting this :(
yeah I'll update you as I learn more if you're around
just to share
 
For what it's worth I would've expected pickle to be involved in similar amounts on windows and linux. I know one difference is that on windows you absolutely have to keep away multiprocessing code from the global scope, but I thought you could only end up in stalling processes rather than new errors.
@Elysiumplain thanks, I'm curious to learn what's going on
 
1:13 AM
@Kwsswart What are your thoughts on flask-login? How come you used JWT in your sample project as opposed to flask-login?
 
 
7 hours later…
8:06 AM
Some YouTube adverts make me laugh. I tend to recognise the ones that'll end without intervention, so I just ignore them and don't open the tab. This particular one has some dramatic speech starting with "We stand here in defiance..." and has people in dramatic poses. I happened to have the tab open this time. The company? Logitech. I thought they just sold cheap, crappy peripherals?
 
 
1 hour later…
9:23 AM
Not all are crappy
 
The more I think about it, I think Tesco had a "Logitek" brand but I can't find a trace of it. Somewhere I have a 1GB memory stick that would answer this for me. I think I've conflated brands
Now I don't know if it's a brain fart or the result of a legal case that Tesco lost and everything had to be mopped up. That's not good for my brain!
I'm not imagining it - I swear that was a brand over here. But I can't find a trace of it
 
Or they bought logitech mice in tesco, and can't spell :P
 
I'll be the first to hold my hand up on bad spelling, but that only adds weight in my mind that this existed because I distinctly remember the "K" and thinking it was so tacky
 
9:38 AM
I found an independent mention of logiteck in a blog. It's "Logiteck Ultra Flat Keyboard". Well, that's also logitech.
 
The irony in needing a memory stick to give proof.. and not knowing where it is. I always have one in my pocket (seriously) but I upgraded to 32GB :/
 
should've bought a 32 GB logiteck stick
 
Well I couldn't, because they only sold cheap crap and they lost an epic legal battle (at least in my head)
 
I don't even know why the memory stick gets a place in my pocket these days because my mac doesn't even have a USB port. I need to rethink my checklist of pocket contents
cbg
Got it. No mega legal battle, just the Logik brand merged with Technika as here. That's been more distressing than I would have hoped.
I guess that means that the first screenshot, they really did think "tech" was spelt "teck". Curse them for fuelling my incorrect memory.
 
 
2 hours later…
11:57 AM
Hi! I have a somewhat general question related to the stack overflow type of posts. Is it normal to make a post about "Hey, I made a program but I feel something is really wrong about the way I implemented things here, here and here, can someone recommend a better solution for it?"
Or users of this site aren't fans of this type of "code review" posts?
 
There is a Code Review site that might be better-placed for those type of questions
 
@Jermog there's a grey area and constant debate whether code review posts are welcome here. But if you have complete, working code and specifically want others to look at it and suggest improvements, do that ^
especially with specific points you want to ask about they'll be very happy to help
 
I mean, yeah, obviously, I would post it after making sure everything works. But I will try this site posted previously first, since it's more fitting place it seems
 
But it isn't. SO is the place for things that don't work (I'm using a pretty big brush here). If it does work then that's where you might want to go to Code Review
Or you can ask here, and things are a bit more flexible :) Just be sure to read the room rules first, particularly about bigger blocks of code
 
it doesn't seem there is a room on scala :( I don't have a question about Python currently
for scala*
 
12:03 PM
yup
 
:( Not sure what to suggest then. I guess you'll have to make a judgement between which site is most appropriate
 
well, you linked me the codereview.stackexchange.com already so it's good enough
 
 
1 hour later…
1:32 PM
Hey guys,

I'm trying to get Python running nativly on my Apple Silicon mac but I'm having real difficulty. Anaconda doens't seem to support it yet but offical Python (from python.org) apparently is supposed to and I've managed to download and install the universal2 binary from python.org but whenever I run anything in it (Spyder, IDLE), it shows in Activity Monitor as an Intel process (roseta translated) not an Apple Silicon native process/program.

Can anyone help?
 
AAB
Hi all
In Django app say I pass url as part of get query string how do I ensure it remains unmodified when I retrieve it using request.get in the view?
say a url as follows abc.com/categ+cpu+price
In my view, the + is converted to space. how do I ensure the data is unchanged
Do I need to encode values before sneding them?
Say I convert user input to base64 using javascript and decode them in my view is it a good way?
 
1:53 PM
@JamesMcIntyre If there are no native binaries available, you will have to recompile it for your system. You should be able to find the appropriate source code and tooling on python.org; IIRC it's not much more difficult than running ./configure.
brew might also be an option. AFAIK it locally compiles any Python it installs.
(NB: Don't have an Apple Silicon, so I'm just extrapolating here. Take it with a grain of salt.)
 
2:26 PM
@MisterMiyagi Thanks MisterMiyagi, I'm just confused because there is supposed to be apple silicon binarys: youtube.com/watch?v=Vor_OkEnxAA
(from 3.9.1 onwards)
 
2:54 PM
Hello, can anyone here help me with a question I have relevant to pygame?
 
Perhaps
 
That moment when your PR passes every single unittest... except the one you added.
 
@Kevin I have a Place class in python that quite literally makes a Place with an entrance and an exit. Bees follow exits from right to left and win if they reach the last Place. Now, I've implemented all this functionality textually but I don't know how to create those Places using pygame
Any pointers would be very helpful
 
To create images on the screen, try using sprites
 
@Kevin So then I would make the image of bees move over those Place images but how would I get them to follow the exits?
 
3:10 PM
To make a bee move from one position to another over time, consider linear interpolation
 
3:50 PM
@MisterMiyagi sounds like the best outcome
 
@AndrasDeak Not when you're stuck in a recursive xkcd.com/386!
 
Not sure I see the connection
 
I know either my test or my code are wrong. Just not which. :/
 
Ah. A lot better than debating with other people if you ask me.
 
4:19 PM
Hi everyone, if the testing and training accuracy (for a churn prediction logistic regression model) are both low and similar to each other (66.8 vs 66.1) does it mean I am underfitting the model? also the learning curves start slightly higher around the mark of 66(for both training score and validation score) and then decrease and stabilize around 66
 
4:43 PM
Might actually use a venv for once, today
 
The horror!
 
I've got a package B, which depends on package C. Normally I'd just stick C's folder inside B and call it a day. But now I have a package A, which depends on both B and C. I can't simultaneously have B and C directly inside A, and have C directly inside B.
But if I put a venv around A and pip install C, then C should be accessible anywhere in the venv regardless of its location and/or my CWD. Right?
 
Right. I don't really get why you need a venv though. The solution is to install B and C, be it in a venv or not
 
Ah, that's because of my secret requirement: B and C are highly specialized packages, and I don't want them gunking up my global install. I only need them when I'm working on/within A.
 
Ok, perfect use case for a venv then
 
4:58 PM
Cool, I'm pleased I'm on the right track
 
5:57 PM
Hi guys, I am new to python coming from a PHP background. I have been introducing myself with flask a little and I wanted to split the files into multiple ones. I came across this answer stackoverflow.com/a/59155127/13833218 . I found it simple than using blueprints but its not working with me though there are tons of positive reviews for that. I am getting a syntax error in the line where import statement is present. Any suggestions to fix that?
 
@RifkyNiyas please show us the code.
 
It's pretty identical to the one given in the answer. Here it is
 from __main__ import app
    @app.route('/test')
    def test():
        return 'it works!'
the above was for user-routes.py
 
I was about to ask you to read the guidelines about posting code, but you did it anyway, good job :D
 
Obviously you can't do import user-routes because that's not a valid name. That would be interpreted as user - routes
 
@CoolCloud Thank you. Had this experience in the PHP chat room
@Aran-Fey ok. then should I change the filename and the import statement to 'userRoutes' or something like that?
 
6:04 PM
Since this is python it should be user_routes, but yes
 
@Aran-Fey Oh, so what if the file is named hello-there.py, how would we import it?
Ah so, import hello_there?
 
You wouldn't. You'd rename it
If you really have to, importlib.import_module('hello-there')
 
FWIW, I've taken the liberty of changing that answer to use test_routes.py now.
 
ok. I got it. Thank you guys
BUT
 
So there is no way to import those type of filenames directly?
 
6:05 PM
nope
 
Hmmm I see, thanks :D
 
In the above answer it has been given as test-routes.py and no one has ever pointed it out
59
A: How to divide flask app into multiple py files?

nimeresamYou can use simple trick which is import flask app variable from main inside another file, like: test_routes.py from __main__ import app @app.route('/test', methods=['GET']) def test(): return 'it works!' and in your main files, where you declared flask app, import test-routes, like: app.py...

 
StackOverflow is full of terrible answers. Something minor like that is just the tip of the iceberg
 
Anyway MisterMiyagi has edited it now
 
yesss!! wasted my past hour full of finding the solution for this
Thank you @MisterMiyagi :)
That solution was quite simple compared to blue prints by the way
 
6:10 PM
It's not a great solution though. Importing a module generally shouldn't have side effects like that
One day an unsuspecting dev will come along, will see a notification from their IDE like "Unused import: test_routes", remove the import, and everything will break
 
thats true
Thanks guys
 
6:40 PM
@RifkyNiyas blueprints are absolutely awesome btw
They take a bit more infrastructure to set up, but then you will have a structure that is fully extensible. So much so that unless I'm building a throw-away app in 20 mins just to target some JS plotting library, I'll build a webapp with a single blueprint
I'm not a fan of from __main__ import app and I have a strong feeling this could be brittle
Even the answers addressing blueprints there are poor. I'm just not sure whether it's due to change that came in time, but it's a lot simpler than they state :/ I've not seen that Q/A before, I might add an answer
@AAB shouldn't it use &?
 
AAB
6:58 PM
@roganjosh the url has page/categ+cpu+model
this is how it is for some urls
 
That's in content served, not in a request to the server
 
AAB
+ was use earlier toencode space
theitdepot.com/details-MSI+B450M+PRO-M2+MAX+AMD+Motherboard_C13P32012.html
this is a sample url
:|
 
Can you give me a bit more context please? I have seen + used in URLs but I really don't know how they're supposed to work because it's not the way I'm used to parsing GET requests with multiple params
So you're scraping?
 
AAB
@roganjosh yes
 
le sigh
 
AAB
7:00 PM
I just need to get user input like the above url
I tried base64 encoding and works fine so far
@roganjosh ?
 
Backtracking a bit, why did you post this as a problem with django? If you're scraping then it isn't your web framework that's generating the URL
 
AAB
@roganjosh I didnt say its an issue with django just that when I pass the url to my site as part of a get the + turn to ' '
I am looking for way for it to not happen
 
5 hours ago, by AAB
In Django app say I pass url as part of get query string how do I ensure it remains unmodified when I retrieve it using request.get in the view?
Are we talking about two different things? Because that definitely says that you have an issue with how your server handles requests
 
AAB
@roganjosh sorry I suck at communicating stuff
my issue is when I send mysite.com?url=<url> the <url> has the + changed to ' ' when I access it using request.GET
I want things to stay as submitted by user.
 
If you want to put base64 data into a url, I recommend base64.urlsafe_b64decode
I wonder if Javascript has a similar function? If not, you could probably write one yourself with string replacement
 
7:06 PM
What on Earth are you building? A site that the user enters a URL for and you scrape it for them?
In any case, I've made it a personal policy that I'm not going to support scraping, sorry
 
If you don't mind the string being about twice as large, you could also use percent encoding
 
AAB
@Kevin built-in javascript does not have urlsafe
some extra library is needed
@roganjosh I scrape prices and allow users to check price history or similar products from other vendors.
 
I mean, you could do it yourself with literally two lines of code. Literally the only thing the url safe version does differently is "substitutes - instead of + and _ instead of / in the standard Base64 alphabet"
 
AAB
@Kevin :| I did not know that so the reason we are doing this is the base64 + may get converted to space again and / would make it look like a URL path that's the reason we do it or is it something more complex.
 
Yeah that's basically the reason
 
AAB
7:13 PM
@Kevin I dont know much about base64 encoding apart from we can use it to send data over networks
What does it do?
Is it like any character will only be one of 64 characters always
 
Yeah.
 
it does base-64 encoding
it's like base-10 encoding except you run out of digits after 9
 
AAB
@roganjosh Is scraping illegal or bad? I thought only scalping was a crime.
 
Sayeth Wikipedia: "Base64 is designed to carry data stored in binary formats across channels that only reliably support text content". So it basically does what you're trying to do: pass data around without it getting garbled by processes that don't handle special characters very well.
Unfortunately, there aren't really 64 "plain text" characters in ascii to begin with. 26 uppercase letters, 26 lowercase letters, and 10 digits gets you to 62. You need two more characters to reach 64, and whichever ones you pick are going to be garbled by something or other
 
@AAB to be a crime it would, by definition, be illegal? In any case, I don't bother myself with that. I find it cheap - if I'm going to use my time to help other people, I'd rather it go into helping people generate original data/ideas/etc. than just taking stuff from others
And apologies, I misread "scalping" as "scraping", so the first part of my response is not applicable. The last part is
 
7:21 PM
I wonder if Javascript has a b32encode equivalent... Base 32 is much less likely to be garbled by anything than base 64.
 
AAB
@Kevin stupid question but how do you know that only those 2 replacements are needed to make it URL safe?
 
Hmm, let me see if I can provide some formal sources
Never hurts to verify one's assumptions by poking through an RFC
 
I think AAB is merely looking for the source of your quote which they may have missed: docs.python.org/3/library/base64.html#base64.urlsafe_b64decode
 
AAB
@AndrasDeak thanks
 
Perhaps. In any case, datatracker.ietf.org/doc/html/rfc3986#section-2.2 describes "reserved" characters that are possibly unsafe in a URI (and, consequently, URLS). Then datatracker.ietf.org/doc/html/rfc3986#section-2.3 describes "unreserved" characters that are safe.
plus, equals, and slash are listed under reserved, while minus and underscore are unreserved.
I wonder why docs.python.org/3/library/base64.html#base64.urlsafe_b64encode doesn't do anything about the "=" pad character. period and tilde are still available in the unreserved category. Maybe they're treated specially by some file systems?
 
7:31 PM
both period and tilde have meaning in linux
or at least bash
 
AAB
@Kevin ~ is home and . is current in linux
 
Well heck.
 
The first question is whether = needs escaping, not whether replacements are available
 
AAB
@kevin
 
Well, if you're putting b64 data in a query string, then I'm hopeful that most browsers would be smart enough to think "this equals sign is probably not the beginning of yet another query string", and leave it ungarbled
 
7:34 PM
hmm
Isn't that invalid syntax? key=value=other_value
Based on common sense alone, to be clear.
 
It should be. I don't think browsers would do that, but then, is it really browsers in control here?
The URL handling would be on the backend and it would be on the backend to make sure that it directs to a page or route that it itself can parse?
 
I think we're talking about design decisions for URL safe base 64.
 
Hmm maybe I'm overestimating the do-what-I-mean ability of browsers.
In any case, en.wikipedia.org/wiki/Base64#Decoding_Base64_without_padding confirms that pad bytes do not uniquely encode data, so you can strip them off before putting them through a pipe that's unfriendly to equals signs
Hmm, trying to remember if I also got Directory cannot be installed in editable mode the last time I did pip install --editable on a local project... It might be because this one is a package.
 
7:51 PM
I thought only packages can be installed in any way
 
Oh good, I wrote it down. I guess I had a setup.py last time.
Success. Past Kevin was thoughtful to explain it to me in small simple words I can understand.
When I do python main.py in my venv's shell, main can import the package I installed in the venv. When I do just main.py, it can't import the package. Let's spin the wheel of blame.
[I spin the wheel. It has only a single section, labeled "Windows"]
 
I suspect just doing main.py runs in the main python env
Do you have #!/usr/bin/env python at the top? It might help.
 
8:08 PM
I'll try... No change in behavior. Oh well. I'm not too hung up about the problem. This kind of thing has been happening ever since I installed 3.8 without uninstalling 3.7 first.
 
You can also be more specific. In a twist of fate I came across this Q&A earlier today: stackoverflow.com/questions/7574453/…
 

« first day (3906 days earlier)      last day (1043 days later) »