Skip to content

Is it possible to unpack values from list to slice?

I’m trying to use values in list to select part of word. Here is working solution: but I wonder if is it possible to shorten it? Something like this comes to my mind: It produces: Answer You can use the built-in slice (and need to name your list differently to be able to access the built-in):

How to add a comment to post? PostDetailVew, Django 2.1.5

I want add comment to post on his page (“post detail” page). I was find answer, but it create comment on other page. I want create comment on page of “post detail”. urls.py models.py forms.py views.py comment_form.html post_detail.html I think, “comment_form” need to redire…

Web scraping: Index out of Bound (Possible scaling error)

Hi Wrote a web scraping program and it gets the ASN number correctly, but after all the data is scraped, it returns a error “Array Out if Bounds”. I am using Pycharm and latest python version. Below is my code. There is already a similar issue on stackoverflow but I am not able to get the pieces t…

Starred expression in ternary operator python

I wrote a python program to print the ascii value of up to every 3 numbers in a string or “ERROR” if the length is not divisible by three. I was golf the code when I ran into a SyntaxError. Code: But this works: Putting a space before the * or after the 3 doesn’t work. I could just use

Live-output / stream from Python subprocess

I am using Python and it’s subprocess library to check output from calls using strace, something in the matter of: However, this only gives me the output after the called subprocess already finished, which is very limiting for my use-case. I need a kind of “stream” or live-output from the pr…