« first day (3696 days earlier)      last day (1235 days later) » 

12:57 AM
Hello
Is there any event in Python/PyQt5 like On-System-DateTimeChange ?
 
 
2 hours later…
2:57 AM
hello! i was wondering if anyone could help me with a simple argparse issue. the code is supposed to run with the command:

python3 compute_pony_lang.py -p pony_counts num_words

however, an issue occurs at line 38, where: compute_pony_lang.py: error: the following arguments are required: num_words

i think this should be a simple fix - however, i'm not quite sure where i'm going wrong and would appreciate some pointers. thanks!

code: https://codeshare.io/5OQBQg
i should add: the code runs fine without the -p argument; the error only shows up when -p is provided
 
3:50 AM
So the -p flag optionally accepts a value? That's kinda weird. I think you have to run it like python3 compute_pony_lang.py pony_counts num_words -p then
 
good morning folks :)
 
@Aran-Fey -p is an optional flag. the command runs now, but the wrong code block is executing and i'm not sure why :/
(the else block executes with or without the -p argument, when the if is supposed to run in the case args.p is provided and else if args.p is not provided)
 
nargs='?' means that it accepts 0 or 1 values. That's why it gobbles up your pony_counts value and argparse complains there's an argument missing
 
i've updated the code in the codeshare - basically removed the nargs argument and added action='store_true' to the -p argument
 
So the problem's solved then?
 
4:03 AM
i have a different problem - the -p argument (optional flag) is supposed to execute the if statement on line 57; if not provided, the else block executes. however, the else block executes even when -p is in the command and i'm not sure why
 
yeah, I can't reproduce that
 
I am trying to push my project into my github repo but not sure why i'm not able to. I typed the following in my Git Bash shell $ ssh -T git@github.com and returns this
Hi Pherdindy! You've successfully authenticated, but GitHub does not provide shell access.
I am using pycharm and typed this in their terminal `git remote -v`
origin ssh://git@github.com:Pherdindy/lzd-data.git (fetch)
origin ssh://git@github.com:Pherdindy/lzd-data.git (push)
 
Just do git push
 
`git push origin master` will display below
ssh: Could not resolve hostname github.com:Pherdindy: Name or service not known
fatal: Could not read from remote repository.
`git push`
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use
 
Does the Pherdindy/lzd-data repo exist on github?
 
4:16 AM
 
Huh. Then I have no clue what the problem is
 
4:30 AM
Yeah will just look around I guess or try to redo it
 
 
2 hours later…
6:14 AM
Okay the remote I put in was wrong initially which should be set to git@github.com:Pherdindy/lzd-data.git instead of ssh://git@github.com:Pherdindy/lzd-data.git
The last issue now is that PyCharm cannot seem to get access to GitHub adding the private key in Git Bash seems to be independent from PyCharm's
 
6:54 AM
hi
do you know git about creapter FUD (by pass virus) in python?
 
;( spent whole day trying to push into github still no progress lol
 
 
2 hours later…
8:51 AM
It isn't possible you've modified your .ssh/config file to tweak hostnames, is it? I've had my battles authenticating to github ...
 
@Pherdindy did you set pycharm to use user agent?
 
I'm in pythonanywhere bash and trying to do
```pip2 install flask-mysqldb ```
and it says:
*** ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied ***
my sudo doesn't work, this command doesn't exist there, any idea how to get pass through ?
 
9:08 AM
nvm, that got solved
 
@holdenweb I actually tried to edit .ssh/config to do that but currently do not have admin privileges so wasn't able to
@Hakaishin No didn't really change anything from defaults in PyCharm
@holdenweb I actually read a post in SO about changing the config file directly as PyCharm accesses that to include the private key
 
9:38 AM
@Pherdindy I'm talking about ~/.ssh/config - the one in your personal .ssh directory. Changes to that can affect how hostnames are interprerted.
Clutching at straws, though ...
 
9:50 AM
Having 2 different IDEs on 2 different OS + 2 or 3 different gits (at least on Windows) is why I always use git over https instead of ssh
 
I have a shell script that lets me switch Github identities (I use a separate account for work).
 
10:15 AM
I suppose i'm going to use https instead for now
No issues with http at all lol probably some authentication issue from PyCharm
I actually configured git to work on cmd and git bash i'll try running it one last time using cmd.exe
 
10:44 AM
@Pherdindy I think you need to change the defaults to use the built in ssh user agent. I tried to find it quickly but couldn't find it.
I use ssh everywhere on different oses and it works perfectly
 
I keep forgetting that Pycharm is a Jetbrains project. I just saw "intellij" in that link and it reminded me of the Java problem I still have to solve <shudders> :)
 
 
1 hour later…
12:04 PM
Already fixed the issue I asked my friend and we built in git shell in pycharm's terminal so it would kind of inherit the variables
"C:\Program Files\Git\bin\sh.exe" --login to pycharm's shell
 
I'm stuck in a situation,
trying to deploy an app on pythonanywhere
and it tells me that flask-mysqldb is not installed
while it's installed when try to run command pip install flask-mysqldb

Anyone has any idea what's happening here?
is it related to somekind of path issue?
 
Probably. It's possible you didn't install into the correct environment
This type of question comes up so frequently these days and it's somewhat frustrating because we a) know the interpreter isn't lying and b) can't see the particular setup. So we know the goal but it takes lots of questioning to get there
How do you launch your Flask server?
Sorry, the server that serves your flask app
If you have app.run() in a script and launch it with python app.py in a terminal, then the answer is just python -m pip install flask-mysqldb
^ I'm not suggesting that you should actually structure things that way, btw. If you have a production server serving the app, that's much better. I'm just starting from the broadest base to narrow down from there
 
12:28 PM
okay so i was reading all flask-deployment docs for pythonanywhere
i checked things which they suggested for possible error in the import because (as they say) its done differently on pythonanywhere

What i checked is if
python3.7 -i /var/www/www_my_domain_com_wsgi.py
let me open the interpreter and it did,

I also made sure if my virtual env python version is same as my app>

I also tried to import flask-mysqldb on that interpreter and it worked fine there

For the deployment on live server they said that we could use this code on the app.py file
@roganjosh actually this is what i'm not getting, when i try to run this command * python -m pip install flask-mysqldb * it says already satisfed but when i try to run my app, there's an error that it couldn't found package flask_mysqldb
 
I haven't actually deployed on pythonanywhere but my gut instinct is that the command to run the app isn't activating your virtual env first
 
i believe you, let me investigate further on that
because the error it's showing isn't helping me
 
I need to look into what pythonanywhere actually does, because it seems it might be abstracting an awful lot away from you in deployment
 
yes sure, I was just trying to do this simple one-pager deploy and it's my first deployment for a python flask app
 
mm, it looks pretty involved and I don't have much time currently to figure it out. I was gonna drop my website into a free account and see if I could run it, but it's looking like that might not be a 10-min job
 
12:36 PM
ahh, sure
well tbh i thought it would be a 10 min job and im stuck for hours now :'(
 
Probably tangential but why are you using that host and trying to use mysql?
You can get hosting for $5/month and get, basically, a full Linux machine that you fully control. MySQL is perhaps overkill for something you want to run for free
I'm not saying that using MySQL is bad, but it points to the idea that you might actually be looking to run something at-scale
 
@HabibRehman lol thinking deploying a website is a 10min job? That sounds like marketing and not reality. Deploying things takes a lot of time if you do it the first time
 
@Hakaishin haha not like marketing -_- paradon me, but i guess was over confident because of the experience i have
 
Indeed, but they perhaps took my cue from saying it might be a 10 min job
 
:D
 
12:46 PM
FWIW it took me 3 days to deploy my own site the first time
 
@roganjosh well i just want to test it for now, will surely go for linode deployment next. but i'm stuck with mysql for now as its a pretty small app and i need to learn more databases for sure
 
I'd like to say I look back on that experience and laugh. I don't :P
 
Can you give me a super-high-level overview of how your app is launched? I mean super-high-level. For example, my old dashboard -> "supervisor runs a bash script that launches the server on startup"
 
Lol the issue is solved xD f*** it wasn't related to anything because of the package but an execption wasn't handled on the index function which was causing th run a false query . DAMNNNNN
it was actually 10min job :'( and i wasted so much time wish i had more debugging power
 
12:52 PM
Unhandled exceptions should stop your program
And all caught exceptions should be handled or reraised
 
pythonanywhere's web app dashboard page gives you links to the server output and error logs.
 
yes i'm looking right now how do i handle the url arguments for the same function
 
First place to look when the app is erroring
 
yes that error i was at line 3, that flask_mysqldb isn't there.
Thats why i spent time searching and checking the import path
 
1:12 PM
Also, there's a pending edit that (I think) should be approved
 
cbg all
 
cbg
 
cbg
what does it stand for though xD
 
no rest in moderation for Room 6 RO's :p
 
@HabibRehman see Salad
 
1:17 PM
Cannabigerol ?
potato?
 
Banana, I guess
 
Garlic
 
stackoverflow.com/a/22190078/12502959 in this answer comments, is the user "pouya" right in thinking so?
I feel like he is missing the point
 
@HabibRehman Good sir, you may want to reconsider that remark :P
 
xD
python still has alot of things to do, so yea i'm not totally sure but why not
 
1:20 PM
question about cookies , i want to encode the session value, I tryed a base 64 encoder and inserted the value into, but got no meaningfull data out
is there a other solution to this ?
 
What's the web framework you're using?
 
flask
 
In which case, you can store the session info server-side with flask-session
Just pick a storage type (from a file to a database table) so that it isn't in the cookie
Or, I've misunderstood your overriding concern
 
ijust want to know what information contains the session, so far I dont want to store the cookie on the server
 
@python_learner Take opinions on Python language design from people collecting their points in the javascript tag with a grain of salt.
 
1:26 PM
ahh my bad, I just hovered over the name and saw almost 2k rep so thought it was okay to comment
but thanks for clearing it out, appreciate that
 
@real_hagrid I don't think I understand any of this. The session would contain whatever you put in it, which I thought was what you wanted to encrypt.
 
I've added a comment on that question for the ancestry of str.index. I'd wager that str.find can trace its lineage back to C.
 
Is this a GDPR-type question or a practical question of using sessions to store info?
I guess "both" is a valid answer to that question, but it doesn't help me understand the problem too much if that's the answer :)
 
@MisterMiyagi well still you can't be judgy just because people have points on JS ?
 
@roganjosh just read that the cookie contains a hashed string, I wanted to decode that string
 
1:31 PM
he did mention with a grain of salt, so his suggestion doenst ask you to ignore it completely @HabibRehman
 
@real_hagrid You can't read a hashed string. that's the point. But now it seems more like you want to read data from cookies from other sites, rather than being concerned about what your server does
 
well its useless to have a convo on this topic anyway @python_learner so nvm
 
anyways hope you are all having a nice weekend
 
+1 would definitely recommend weekends to friends
 
same to you all cabages
 
1:46 PM
@real_hagrid every result I'm pulling up on encryption around this (not hashing) looks half-baked. I think you're going off-course
 
@roganjosh Im using flask_login, and didnt know that the login manager sets a session automatically and encodes the value, I just used print to get the session value from the function, sorry for the confusion
 
In which case, back your sessions up server-side as I suggested and then there's "little" worry. I'm not going to profess that it's totally safe, but you can pull the data out of the session in the first place so it's not exposed in the browser
 
@roganjosh thanks Im gonna keep that in mind, so far the data is not so sensitive
 
Any login info is sensitive
Even if you ask your colleagues to set up test accounts, they may pick passwords that they use elsewhere
Making sure that this info isn't exposed or readable elsewhere is part of the MVP. I argue that you need to fix this now
And FWIW it's a couple of lines of code to give sessions storage outside of cookies
 
 
1 hour later…
3:08 PM
ive trying to return the linked list with the nodes between a and b replaced with list2
why cant i return like this?
 
3:23 PM
for [0,1,2,3,4,5] a= 3, b=4, list = [100000,100001,100002]
why does it just return [5]?
 
hey fellas, is someone here familiar with quicktions Fractions library ?
 
@HabibRehman FWIW the tech help at pythonanywhere is extremely user-friendly.
@roganjosh No PRs for as_blog yet? ;-)
 
4:00 PM
@Trajan Consider that this would be much simpler to follow if you were to provide a MCVE.
 
4:21 PM
@holdenweb clue to my current effectiveness; I've just woken up after a spontaneous napping event :P Last week was dire and I didn't get a chance to look properly sorry. I'll take a look shortly
 
I'm working with programmer who's telling me quicktions Fractions is used for exponentiation, but while reading the docs I don't get no reference to that whatsoever, and from what I understand it will only deal with fractions, and will turn float values into the most approximate fraction with denominator and numerator. Is he tripping, or am I not understanding something? That's a snippet of how he implemented this library:
`x**Fractions(y**Fractions(calculation1) + y**Fractions(calculation2))`
Would that be any faster than
hey @roganjosh I wanna have a private chat with you, if you will, but I lost your website address
 
4:44 PM
@PedroSpinola Also note that the point of Fractions instead of float is not speed but accuracy. float has limited precision and is especially unsuited for decimals and as such currency.
 
@roganjosh Absolutely no obligation. As it happens I decided to start using PRs to make the changes more visible on Github, and I just landed another. The code is still horrible, but it's early days.
 
Awesome @MisterMiyagi! Thanks for pointing these out! The actual line of code using this is within a function that will run millions of time on execution of the main function, and reads:
my_list.append(a**Fraction(((b/c)**Fraction(d))* ((e/f)**Fractions(g))))
where a-g are all float values
but it's not using a**b where both are fractions, is it?
where you see (b/c) and (e/f) should'n I be using instead:
Fractions(b,c)
Fractions(e,f)
 
If the variables are all floats, then it its a waste indeed.
 
When I say float I mean numbers like 0.984098345903458098049358
 
Doing mixed float/Fraction math is usually the wrong choice. It has neither accuracy nor speed.
 
4:59 PM
@PedroSpinola If you want to open a chat channel with me then you can do that by clicking on my name. That will be public. If you really want to send a private message then you can do here but if it's SO stuff, I'd prefer in a chat room
@holdenweb I just had to present to the Exec team of a client on Friday and the lead-up was hectic, which was why I asked to meet next week. They're always fun, aren't they? :P I'm just about getting back to normality so I will definitely have a look before we chat
 
Hope it all went well. Yeah, those intense build-ups can be ... intense.
 
Everything was going swimmingly until one of our internal Sales guys caught up with us Tues/Wed and told us it was, basically, crap
As it happens, it went really well. Our sales guy was decidedly unhelpful and just caused panic. Oh well, the main thing is that it worked out :)
 
@MisterMiyagi I see! thanks a lot man, really appreciate :)
@roganjosh it's not SO stuff, I've sent you an email through your website ;)
 
6:05 PM
@holdenweb lol, first file I open and it's beverage themed. I think I can get behind this project :P
 
Thank Alex for that one. But he's Italian, so give him credit for not pushing the national brands. I raise my whisky glass to you, sir!
If you want to get involved I'll be happy to invite you as a contributor to the repo (and before too long we'll want reviewers ...).
 
I'm going to try get my head around it a bit first and see what I might be able to add. I mean, it's not like the current team is lacking... :)
This I find interesting, though. I don't think I've seen this setup before
Do you find that an easier interim to logging?
 
6:28 PM
Did I mention the code was completely gash? At one point I was hacking on the parser, and I had print statements that I suddenly realised I need to be able to switch on and off easily. Hence the naff soluition.
Completely undisciplined, I acknowledge, but I have fifty years' accumulated bad habits to contend with.
 
Oh, I definitely wasn't attacking the code. Apologies if it came across that way! I throw print in all over the place but this looked like it might be something a bit more permanent
 
If you can't attack this code then you shouldn't work on the project. This is essentially the fastest MVP I could throw together. There was little prior thought to structure, and I had a lot of fun playing with various parsing schemes until I realised most of what I wanted to do didn't actually require me to parse the documents!
I believe I mentioned in the sprint demo this is pre-alpa code.
While what you say may be true it doesn't mean the code isn't naff.
I _long past_ stopped taking comments about my code personally. I mean, literally, a long time ago—about 1976.
 
I feel like I've accidentally offended you. That wasn't my intention at all to criticise the code. I was just curious about that specific setup to test things out. I'm fully aware that the code is pre-alpha
 
Egoless programming is a style of computer programming in which personal factors are minimized so that quality may be improved. The cooperative methods suggested are similar to those used by other collective ventures such as Wikipedia. == History == The concept was first propounded by Gerald M. Weinberg in his seminal book of 1971, The Psychology of Computer Programming. == Peer reviews of code == To ensure quality, reviews of code by other programmers are made. The concept of egoless programming emphasises that such reviews should be made in a friendly, collegial way in which personal feelings...
Gerald Weinberg is always worth reading, btw.
 
Ok, well my comments didn't land in the particular order that makes sense, when we were both typing at the same time
The actual motivation behind my question on debug() was to see whether I was missing a trick, not that I thought it was a bad idea
It's precisely because of your background that I was wondering. Normally I have print that I then have to rip out of the code everywhere. On aggregate, maybe I would be better to use your debug function. I can then rip it out at the end but maybe don't have to go back and hash out the prints
 
6:49 PM
Good heavens, I just spent several minutes (I thought) explaining that nothing you say about code I write is ever likely to cause offence of any kind. It just seemed to me that you divined intent on my part where there was none.
debug was just my pragmatic answer to the question "now I'm printing thirty thousand lines of debug output, how can I focus on the ones I'm interested in."
I considered a decorator that redefined the print function, but it seemed overkill when most methods/functions only had one print statement at most.
 
It was just unfortunate that you typed faster than me, so my comment landed after your explanation :) I think I might adopt the debug() fnc approach myself going forwards. In any case, I have your app running now so I'm about to test
 
I am surprised. You'll want
export FLASK_APP=src/tools/serve.py
export FLASK_DEBUG=1
export PYTHONPATH=src/tools
(That's in my local env, but not yet committed)
And I take the fact that you are thinking of adopting a debug-like solution as a compliment. Thanks!
Maybe it should go into hu (though in that case the debug switches should really be a function attribute).
 
@holdenweb indeed, that's how it was intended :)
 
As far as not putting code into production, __debug__ is your friend, as code guarded by an if __debug__ is, I believe, optimised away altogether. I know zero production sites that take advantage of this, including the one I inherited at Labster.
 
7:06 PM
That would explain why I've not seen the setup before :P
 
That's also when assertions are disabled, right?
 
user14596741
:)
 
7:30 PM
Sorry to be a pain, @holdenweb but can you link your walthrough video again so I can approach this as Joe Bloggs? Chat search sucks
 
That's the one. Thanks!
 
@AndrasDeak Correct.
 
8:06 PM
On a related note: deprecation warnings should be enabled by default
 
AAB
hi all,
I am working with scrapy 2.3 any way to run all spiders parallely from a python script ?
 
@AndrasDeak If they did that, people might optimise more often!
@AAB Threading, multiprocessing and async are the commonest ways to run parallel tasks in Python.
 
AAB
@holdenweb yes I am aware I can use subprocess.Popen()
but anything in scrapy like a method called crawl etc?
 
8:24 PM
Subprocess is a fourth method, but you would then be forced to use the scrapy command line.
The simplest way would be to define a class whose instances perform a parameterised scrapy search in a separate thread, I think, since most of the time will be spent waiting for network responses.
 
AAB
@holdenweb you are saying create a thread per spider and run them?
 
That was indeed my suggestion, but you need to be careful about communications: queue.queue is your friend there.
 
AAB
8:40 PM
@holdenweb thanks let me see a few examples
 
 
2 hours later…
11:09 PM
cbg
if I had a df test_ratio=pd.DataFrame(np.mat('1 .7 ; .8 1 ; 1 .9'))
how could I construct a test for where some set of matching values (in this case 1) occur in column 0 and column 1
so that this evaluates to True True True
but if it was just np.mat('1 .7 ; 1 .9') it would evaluate False False
the only other major complication is that some of the non 1 values may be NaN
 

« first day (3696 days earlier)      last day (1235 days later) »