« first day (3626 days earlier)      last day (1305 days later) » 

1:33 AM
cbg, regret I shall not be making handout tomorrow, have fun!
 
2:04 AM
try:
    assert("Concurrent Log On Detected" not in r.text), "Please Logout From Web"
    assert ("Login Failed" not in r.text), "Invalid User/Pass"
except AssertionError as msg:
    print(msg)
    exit()
How can you achieve the same target with more Pythonatic way ? as i feel that one count false
 
 
3 hours later…
4:41 AM
cbg, is there a way in requests to make sure the header is set at some place so I dont have to pass it in further get calls?
 
use a requests.Session object... set the headers on that, then use that session?
 
ohh makes me dumb, this is what I currently have
with requests.Session() as req:
	auth_response=req.post(login_url,data=creds,headers=headers)
didnt know session could have that, thanks
 
4:59 AM
Yeah... so you'd do session = requests.Session()... then session.headers = headers then just use the sesson, eg: session.post(login_url, data=creds)...
 
yeah thats what I did after your suggestion, at first I was passing in headers=header to the Session object then realized its just an attribute
would sessions.headers=headers here be considered as monkey pathching?
 
don't see why?
 
I have heard of this term but I dont understand how it is any different from just doing a normal attribute assignment, so any instance attribute assignment is considered monkey patching?
 
5:15 AM
nope... might want to look up the term "monkey patching" - it has a very specific meaning
 
 
2 hours later…
7:22 AM
@αԋɱҽԃαмєяιcαη don't use assertions for exception handling
You don't need exception handling to test string membership
if "Concurrent Log On Detected" not in r.text:
    # handle logout case
    pass
That "handle" can be a print, a log, a return, a raise... depends on what your code does and how bad that case is
 
cbg everyone!

I have a script with name find.py. I need to run 'find.py test.txt' from command line to run it with an argument file (test.txt is in the same folder). it gives WindowsError [Error 2] windows can't find the file specified for all the processes (it is a multi processed AV signature scanner tool).

Also is there a way to make such scripts an executable bundle (i have create executable packages before with py2exe, pyinstaller, cxFreeze, i can't figure out a way because how will i be supposed to pass in the file arguments to an executable)
 
7:48 AM
@Aran-Fey Oh such a silly mistake ...Thanks for pointing it out :D
 
 
2 hours later…
9:44 AM
Hi, i was wondering if you guys knew why its happening like this stackoverflow.com/questions/63967239/…
ik its a tuple but still why is it coming with the {}
printing it shows the usual tuple only
 
@CoolCloud google "f-strings"
 
I ve used f strings but i was asking why is it happening with tuple and not with f strings, even i had an answer using f strings, i just removed it
 
10:00 AM
@CoolCloud Then you'll have to be more specific than "why its happening like this"
 
@CoolCloud this is how tkinter decides to format the content. Most likely the { X } are used to preserve whitespace, the same way one would write " X " in Python.
though the general answer to "why is the output strange when passing a tuple as text" should probably just be "because a tuple is not text".
 
Oh, the question. My bad for looking at the post that was linked. Silly me.
 
Yeah, should have been totally immediately obvious, amirite?
 
Yeah, suddenly "why its happening like this" makes sense. All the senses. Every sense.
 
@CoolCloud Worth learning: The textual representation of a thing is not the thing, and many things don't have a strictly correct textual representation. Just because Python decides to represent a tuple as, say, (0, 1, 2, 3) does not mean the tuple is (0, 1, 2, 3).
Scratch that last wisdom, it's totally wrong.
 
11:00 AM
@PSSolanki The usual way to do this in Unixland is to put a "shebang line" at the start of the script (typically something like #!/usr/bin/python - the path should be to the executable you want to process the file), make it executable and put it in a directory that's on your $PATH so the shell finds it. I have little idea what the best way is in Windowsland, sorry.
 
11:23 AM
@αԋɱҽԃαмєяιcαη Be aware that assert can be switched off externally, without your program being able to object. Do not rely on assert/AssertionError for control flow, unless you want a program that is mysteriously broken.
An assert should never depend on external input. The purpose being that once you have asserted that the internals of your program are sound, one can switch off all assert at once to save on the now redundant sanity checks.
 
 
2 hours later…
user13415013
1:08 PM
How to check python for memory leaking problems, which arised when deploying ?
 
user13415013
Is there any method , Im stuck when deploying project on heroku, after successful running it says memory quota exceed killing me,
 
Since Python is garbage collected it does by definition does not leak memory, unless you use custom, compiled extensions.
So there is no single, gemeral method to say which memory your program does not actually need.
You may be looking for a memory profiler: stackoverflow.com/questions/110259/…
 
user13415013
I was deploying ml application on heroku, at first glance, it worked and after all it says r15 r14,h12 errors .
I tried to restart, and use tactics but it unsolving problem.
 
user13415013
Thanks, I hope it will solve my problem.
 
Other than that, you may want to check for cases where you mistakenly keep objects alive. Common problems are using containers such as lists for stream processing, which keeps all items alive even though you only care about the most recent ones. Using dictionaries to store auxiliary data also can keep both the data and metadata alive too long.
The weakref module can be very useful to avoid such issues.
 
user13415013
1:22 PM
thank you, that means, We should avoid using multiple objs and use dictionary to save them .
 
if "ml" actually means machine learning: bad news, machine learning needs a lot of memory
 
user13415013
yes :D, heroku is only free where i can use to make portfolio things for deployment unlike others are paid. I have no choice.
 
@nerd no. no, my post was not intended to mean that.
 
too late, I've already ordered a copper plate with that quote, signed "MisterMiyagi"
 
user13415013
@MisterMiyagi , why?, your idea is helpful, im working to solve it.
 
1:33 PM
@AndrasDeak One of these days, I'll start my own Cargo Cult. Seems easier than teaching things properly.
 
@MisterMiyagi @AndrasDeak Oh i see, thaanks for the helpss !!
 
@nerd just to be clear: if you construct a dict of objects you will still have a reference to the objects and they will use the same amount of memory (plus a little more for the dict)
 
user13415013
Thank you guys, i'll be right back when problem vanishes :)
 
famous last words
 
2:07 PM
Narrator: "... and nerd was never heard of again."
 
user13415013
no i am here, mistakenly had pushed all my train test dataset also on heroku. I am on it :)
 
3:04 PM
Is this meeting happening? Apparently someone has to let me in.
 
Not for another hour is it?
or am I can getting the timezone adjustment off by one...
 
It was in Google calendar so I just clicked on it. I assume Google knows all that timezone stuff.
 
So... it's 15:11 GMT now... and the meeting starts at 12pm GMT-4... so think it's still coming up?
 
My Google Calendar shows that it is displaying GMT-5
 
3:18 PM
The entry in my Google Calendar says that the meeting is 11-12 GMT-4
Weird
 
currently I'm GMT+1 as it's BST... Still not entirely sure that makes things clearer...
hopefully they don't hear the knocking and they're all hiding behind the couch :p
I'd expect @inspectorG4dget to pop into the room here anyway prior to starting to gently remind people :)
 
No it seems I'm the only one with the wrong time, as Google finally kicked me from waiting to join. (trying not to read too much into this...)
Unf my grocery pickup is just after when I thought the meeting would end, so since I'm off by one hour (and since I have to put groceries before camaraderie), it looks like I'll miss this event. I'll have a lightning talk or two ready for next time.
 
This works
    ((a,b),(c,d)) = [['a','b'],['c','d']]
This does not
    a,b,c,d = [['a','b'],['c','d']]
I've never found an explicit explanation in the docs but I think it is
    docs.python.org/3/reference/…

Anyone know some other place in the docs?
 
The one that "does not" is only passing two items to be unpacked, not four.
 
3:34 PM
> The object must be an iterable with the same number of items as there are targets in the target list
^ that's pretty much what it boils down to
 
try ab, cd = [['a', 'b'], ['c', 'd']] and then a, b = ab; c, d = cd
That is the verbose mode of your working version.
 
@PaulMcG ugh... that's a shame... :(
 
@PaulMcG - I know why they are different. I like to reference the docs in comments and answers and the section on Assignments seems the only place but it is not very explicit. I was wondering if there was something else in the docs.
 
Yeah, I had Powerpoint slides and everything... (not really)
Well, my wife is glad that I picked up my office a bit anyway.
 
I guess that is it though as the assignment is recursively defined.
 
3:39 PM
yamming off by one errors - the curse of programmers! And yam you timezones! meep
 
@wwii a, b = [something1, something2] just does the assignments, it doesn't matter if the somethings have additional structure.
I just reloaded the event from the starred link, and now it shows correctly in my calendar. Next time.
 
3:58 PM
@toonarmycaptain 'Handout'?! Ayn Rand disciples will object!
 
If anyone would like to join the hangout, we're live now: meet.google.com/fbr-jbmx-rnh
 
@MattDMo and others: we are in the hangout! Come and join
 
@inspectorG4dget ooo... I might eaves drop if okay? Bit busy with other stuff to properly participate though
 
all good
 
user13415013
@inspecor4gadget yes im in
 
user13415013
4:10 PM
which topic we are discussing
 
you should probably ask this in the hangout
or just listen and see
 
4:30 PM
@nerd: please come back ask your Python question, sorry we were just making small talk
 
@nerd I'm sorry, if you have questions we'd like to help, we were just a bit too wrapped up in talking to each other - we've been in lockdown ...
 
@nerd come back dude! we miss you :) We're just hanging out and killing time
 
5:32 PM
@AndrasDeak Alright. thank you.
@MisterMiyagi so the best case is to handle it properly using try/except
 
6:19 PM
 
6:33 PM
@nerd inspectorG4dget and I edited the room hangout description, to clarify it's a general non-Python chat, without any formal agenda, slides etc. More just a social meetup (I also had no idea what to expect, I'd never been to one before). But if you do want to raise a Python question, just show up in the hangout and ask it. (Microphone is optional but suggested.)
 
I had no idea you were so obsessed with self-driving cars :p
 
From the hangout: Jon Clement's recommendation of [All of Netflix’s interactive specials, ranked by how much your choices matter](polygon.com/2020/5/13/21257711/netflix-best-interactive-shows-movies-ranked-bandersnatch-kimmy-schmidt-minecraft). Fun things to do in time of C***d.
 
hmm
wasn't the chat supposed to be next week :D
ah...
 
@AnttiHaapala What, has September 19 been rescheduled?! That's good news for everyone with critical work deliverables on Sept 19.
 
not that I had time today.
 
6:47 PM
@AnttiHaapala Sure, well if you want to suggest another time and date to @inspectorG4dget ...
 
hello everybody!
i have a question
 
Sep 1 at 2:22, by inspectorG4dget
Here's the calendar invite for the Oct 3 hangout. 9am in Seattle, 12pm in Toronto/NYC, 21.30 in India, 17.00 in London
 
for concatinating tuples, which is better, tuple1 + tuple2 or (*tuple1, *tuple2)
by better i mean which is more efficient, and which is more "pythonic"
 
@ThaddaeusMarkle In an expression? function call? generator expression? If you could post a line or three of code context, could answer you better.
 
+. It's shorter, more readable, and supported in more python versions
@smci In what context is + not the clear winner?
 
6:50 PM
@smci the specific use case is using a tuple as an index for a multi-dimentional numpy array to get the q value of a state + action in a q table for q-learning.
for example, current_q = q_table[discrete_state + (action,)] from sentdex's q learning tutorail
 
@ThaddaeusMarkle use that
 
which could instead be current_q = q_talbe[(*discrete_state, action)]
 
@ThaddaeusMarkle no
 
@AndrasDeak ok
is the *tuple syntax only used for variable number of arguments for functions?
 
99% of the time, yeah
 
6:53 PM
@ThaddaeusMarkle or unpacking variables in loops or assignments
 
@AndrasDeak could you give a short example? I can't picture what you're describing.
 
first, *rest = foo()
 
ok that makes sense
thanks guys!
 
No problem
 
hello guys
I am working on a scenario
I would like your help as I am new to Python
anybody available?
 
7:00 PM
@Crusader please read our rules before asking sopython.com/chatroom
 
got it
@AndrasDeak Thanks
 
:)
:(
 
@AndrasDeak what happened?
 
I am just banging my head over that question but none seems to work out
 
7:05 PM
> Don't ask for answers to your recent Stack Overflow questions. Those who can answer are already watching the queue on the main site.
 
ohh ok
gotcha
 
@Aran-Fey (In the case where you can't be 100% sure both arguments are in fact tuples. If they're integers or strings or objects that implement .__add__, then you get exceptions or surprises. I see this a lot in data-science code.)
@ThaddaeusMarkle FYI in pandas, we don't need to, we can use .loc[arg1, arg2] / .iloc[arg1, arg2] with multiple arguments.
 
7:25 PM
@smci that does something else I think.
They want (i, j) and k to turn into arr[i, j, k]
 
@AndrasDeak Ah, ok. Right, that makes sense.
 
8:00 PM
@ThaddaeusMarkle + works for well for a pair
but if you have 3:
>>> dis.dis('(*a, *b, *c)')
  1           0 LOAD_NAME                0 (a)
              2 LOAD_NAME                1 (b)
              4 LOAD_NAME                2 (c)
              6 BUILD_TUPLE_UNPACK       3
              8 RETURN_VALUE
it is only one op.
 
8:30 PM
@AnttiHaapala how does it know how many to pop off? Or is that special-cased for 3?
 
operand
 
Hmm?
 
3 is the operand
 
Ohhh right
Thanks
I kind of ignored that column until now...
 

« first day (3626 days earlier)      last day (1305 days later) »