Questions tagged as 'python'

2
answers

Error when calling function

When I call this function: def check_bit4(input): mask = "0b010" desired = input & mask if desired > 0: return "on" else: return "off" This error appears: Traceback (most recent call last): File "python", line 9,...
asked by 25.07.2018 / 17:18
1
answer

How to generate condition of interruption of a repetition loop in Python during its execution?

I'm trying to make a program in Python that while executing a loop loop, some command is waiting for an input condition while the loop is executed. For example, a program that prints on the screen numbers, in ascending order and every 1 sec...
asked by 26.07.2018 / 18:29
1
answer

Parse txt file and return it in another file - Python [closed]

Good evening! It has a file with numbers, saved in txt format, each number separated by space, there being a list with about 50 values in each line of the txt file (and more than 10,000 lines in the file): 78 34 85 67 96 197 etc. I want to...
asked by 18.07.2018 / 02:12
1
answer

In Python, how to assign stdout, stdin, and stderr to variables, using the module "subprocess" with the hidden console?

In Python, how to assign stdout, stdin, and stderr to variables, using the module "subprocess" with the hidden console? Because before I package the program into executable .exe, I can do the normal assignment, but after the program bundled to e...
asked by 17.07.2018 / 22:00
3
answers

Required field modification if checkbox is selected in Django

I need to check if a "checkbox" button, called yes_no, was selected on my html page and change the "name" field to mandatory when this checkbox is triggered. My code is as follows: In the models.py file: from django.db import models # Crea...
asked by 29.07.2018 / 15:34
1
answer

Python asyncio and threading

I am studying the module asyncio of Python and there is the function run_coroutine_threadsafe which should be run on a thread other than the event loop. Here's my script: #!usr/bin/python3 # -*- coding: utf-8 -*- import asyn...
asked by 15.08.2018 / 02:53
1
answer

How to use indices of two arrays to form a third array?

Basically what I want to do is C[i][j] = B[A[i][j]][i] . In the case A and B are 2 arrays 5x5. The formula is C [i, j] = B [A [i] [j]] [i] that is, C is the value of B [X] [i], where X is the value of A [i] [j]. Note tha...
asked by 15.08.2018 / 16:33
1
answer

Print BSON of MongoDB with several different structures

Hello, I'm making an application using Python (Flask) and MongoDB. In this application the user can assemble his page inserting Images, Text or youtube link. With the sequence you want. This first part I did and I'm recording in Mongo. The...
asked by 23.08.2018 / 00:03
1
answer

NameError when entering the value read by the input function

I'm running Python version 2.7: Python 2.7.12 (default, Dec 4 2017, 14:50:18) [GCC 5.4.0 20160609] on linux2 When I try to run this line of code : x = input('Enter your name:') print('Hello, ' + x) I have the following error: $ pyt...
asked by 18.08.2018 / 00:23
1
answer

Access Denied when trying to delete directory with PYTHON

I have several folders, and within these, several other folders, and I need to enter one by one to delete other folders (Yes, many folders are nested). The name of the folders I want to delete are named in the year + month format (eg 201808),...
asked by 07.08.2018 / 15:33