How do I execute a bash command from Ipython/Jupyter notebook passing the value of a python variable as an argument like in this example: (obviously I want to grep for foo and not the literal string py_var) Answer General solution As suggested by Catbuilts, use {..}: Its behaviour is more predictable than $&#…
How to replace a comma with an underscore in Django template filter
Hi I have javascript as follows contains django variables. all results are a query result fro my view: The problem am facing is if the value of item is a comma separated value, then the id is not passing to the template I have. But if the value of item is a one word my code is working perfectly and
Can I run Jupyter notebook cells in commandline?
I am deploying a Python package, and I would like to run a simple test to see if all cells in my notebook will run without errors. I would like to test this via commandline as I have issues running a notebook in virtualenv. Is there are simple command-line way to test this? Note to the moderator: this questio…
How to update JIRA issue reporter from Python
I’m trying to update the reporter of an issue using the JIRA Python API (version 1.0.3). I am signed in (using basic auth) as a user who has full permissions, and I am trying to do it for an issue which I myself have created. The issue is successfully created, however when I call the update command, it …
How to use Python to convert an octal to a decimal
I had this little homework assignment and I needed to convert decimal to octal and then octal to decimal. I did the first part and could not figure out the second to save my life. The first part went like this: I read how to convert it here: Octal to Decimal, but I have no clue how to turn it
Why doesn’t contextmanager reraise exception?
I want to replace class’s __enter__/__exit__ functions with single function decorated as contextlib.contextmanager, here’s code: When we got exception inside Test’s __exit__, we pass it to _cm’s __exit__, it works fine, I see exception inside _cm. But then, when I decide to reraise ins…
Django rest framework override page_size in ViewSet
I am having problem with django rest framework pagination. I have set pagination in settings like – Below is my viewset. I want to set different page size for this viewset. I have tried setting page_size and Paginate_by class variables but list is paginated according to PAGE_SIZE defined in settings. An…
Extract digits from string by condition
I want to extract digits from a short string, base on a condition that the digits is in front of a character (S flag). example and result: I can split the string to a list to get the individual element, but how could I just get the 18 and 10? Answer Use re.findall with the regex r'(d+)S’. This matches a…
Unsupported operand type(s) for +: ‘float’ and ‘str’ error [closed]
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers. Closed 1 y…
How to find out week no of the month in python?
I have seen many ways to determine week of the year. Like by giving instruction datetime.date(2016, 2, 14).isocalendar()[1] I get 6 as output. Which means 14th feb 2016 falls under 6th Week of the year. But I couldn’t find any way by which I could find week of the Month. Means IF I give input as some_fu…