Questions tagged as 'python'

1
answer

Saving User Changes

I've been researching how to save user changes (with raw_input ) in Python and I did not find something that made it clear to me. What is the best way to do this (even after closing the program)? Example: def arranque(): machin...
asked by 11.06.2014 / 12:50
2
answers

How to protect my Scrapyd server from unauthenticated calls?

Let's say I have the following configuration in scrapy.cfg in Scrapyd. [deploy] url = http://example.com/api/scrapyd/ username = user password = secret project = projectX In the Scrapyd documentation it cites the username and password optio...
asked by 09.01.2015 / 21:15
1
answer

Problem importing from User models

I'm doing some testing on a Django project, I've created a very simple module just for testing myself. Follow below: from django.contrib.auth.models import User def teste(): for i in User.objects.all(): print i.username if __name...
asked by 12.05.2014 / 17:04
1
answer

Searching for a field contained in several models

I have a manager in my project, which is to do TAGS, and on the front of my system the user will search for a tag, and it will return everything related to that tag. Follow the models.py: from django.db import models from django.utils impor...
asked by 20.11.2018 / 19:05
1
answer

Define array in python

I need to create an array and populate it with random values ( randint(0,9) ), except for the same rows and columns. For example, this way: A| B| C| D| E A x| 2| 1| 4| 2 B 1| x| 1| 1| 2 C 5| 1| x| 4| 3 D 8| 2| 1| x| 2 E 5| 4| 1|...
asked by 19.11.2018 / 15:36
3
answers

Iteration using "while"

I have a little trouble understanding while and I came across an exercise that asked me to do the following: Read N sequences and find out how many 'f's' in each sequence. I can not use for on this issue. My code looks like t...
asked by 10.12.2018 / 22:11
1
answer

How to edit text

I'm trying to create an option where you can edit the startup text, but as I already have some lines of code I'm having a hard time finding a way to do it. How can you do it (in a simpler form than this code)? #============<<<código d...
asked by 12.06.2014 / 01:44
2
answers

How to make a request in Python 3 through an HTTP proxy

In Python, we can retrieve the content of a URL quite simply: from urllib import request response = request.urlopen('http://www.google.com.br') However, in corporate environments we can not access the internet directly, we need to go thro...
asked by 05.02.2014 / 21:03
1
answer

How to upload with progress bar using qftp from pyside?

How can I upload using pft's qftp? I already have an ftp client program that downloads. Below is my ftp client code. #!/usr/bin/env python # -*- coding: latin-1 -*- import os, sys import sip sip.setapi('QString', 2) from PySide import QtCore...
asked by 27.01.2014 / 21:59
1
answer

How to repeat a block of Jinja2?

I'm using Jinja2 as a template engine for generating a static HTML site in a Python script. I want to repeat the contents of a block ( title ) in the layout template ( layout.html <html> <head> <title>{% block title...
asked by 03.01.2014 / 22:05