« first day (4926 days earlier)      last day (279 days later) » 

06:22
Can someone explain this?
>>> re.search('<script[ >]', html)
<re.Match object; span=(3539, 3547), match='<script '>

>>> re.search('</script>', html)
<re.Match object; span=(824336, 824345), match='</script>'>

>>> re.search('<script[ >].*?</script>', html)
>>>
Why does it work individually but not together?
I'm a moron, . doesn't match newlines
 
4 hours later…
10:15
Apple pricing - it was cheaper for me to do a 100 mile round trip to get the laptop charger that I left at work than to buy a new one. I still have 3 more opportunities to forget it before I approach break-even. I just hope I don't have to use them!
 
2 hours later…
12:43
can one install multiple packages via subprocess.call (['pip', 'install', '...']) command ?
Yeah, that's actually the recommended way to use pip (i.e. launch a subprocess, don't import it)
12:58
@Aran-Fey - thanks . i assume it would be just list of packages , space separated (['pip'], ['install'], ['numpy' 'pandas' ..
as such
['pip', 'install', 'numpy', 'pandas']
also , I would like to know , if we can pass objects as a command line argument from one script to another in python . say script1 calls script 2 , via os.system('python script2 arg1 arg2 ..) as such, can one of the command line arguments be an python object
No, command line arguments must be strings
ok thanks
13:18
@arve in short, passing actual Python objects (as oppossed to their serializations) between different runtimes is very difficult (/impossible?) regardless of method.
@matszwecja - thanks. i am relatively new to python. unfortunately, the code i'm working on right now, i have to pass a user object with user credentials from one script to another. and i was wondering , if i can simply pass the user object. not sure, if serializing the user object and passing the authentication token as string from one script to another is safe
however, both scripts will run in the same container. so may be it is ok
It's generally better to pass credentials via volatile means, e.g. stdin. But it should work to pass them as arguments as well.
13:34
@MisterMiyagi - great thanks.
is there any example/blogs on how to do it via stdin ? out of curiosity , i want to take a look, if that is something i can use now
Passing them as command line arguments is extra bad because there are ways to read those. The task manager displays them, for example
@Aran-Fey - thanks . i will keep that in mind
As much as I hate them, this might be a good use for environment variables
@Aran-Fey - oh interesting, do you thing that is more safer. both locally and say in some container in the cloud
@arve There isn't much to do. The subprocess has various means to write to stdin - for example, you can directly pass a string as input to subprocess.run.
@Aran-Fey Those are exposed at least on UNIX as well.
Plus they are inherited by child processes. :/
13:39
@Aran-Fey - and i'm guessing the environment variables won't be logged anywhere
i am assuming i can set the environment variable via subprocess , right?
@MisterMiyagi Welp, never mind then
@MisterMiyagi - just for my clarity, the environment variables are exposed and inherited by child processes?
@arve environment variables are readable in /proc (by root and every process of the same user) and they are inherited by child processes.
ok thanks
Security is really though to get right, especially so in a language you are new to. And no system is gonna be 100% secure. It's important to get your expectations right when working on securing a system
 
6 hours later…
19:17
@arve what is the ultimate fate of your docker container? Note that the filesystem of containers is transparent so .env would be visible if you distribute it
 
1 hour later…
20:31
@MisterMiyagi I remember you asking if it was really true that you have to hold strong references to asyncio tasks. I'm currently looking through the asyncio source code and I can tell you that asyncio internally definitely doesn't do that
(and yes, I'm sure that the task survives, because it annoys me with a "task exception was never retrieved" warning when the program exits)
20:48
@Aran-Fey I did finally get a real-life example, actually. While the inter-task events (say, a lock) are safe, the event loop events (say, waiting for a socket) are not. Tasks keep their events and thus each other alive, but the event loop happily forgets about any events requested from it.
Huh. I don't understand the details, but here it's doing something with a socket and immediately drops the reference to the task
An example is here, showing how reading a connection is not safe.
If you read too deep it's a lovecraftian rabbit hole from there, with basic stuff such as asyncio.shield() being unsafe.
I guess such things are to be expected. Asyncio is only... hold on... 12 years old

« first day (4926 days earlier)      last day (279 days later) »