Python is a dynamic and strongly typed programming language that is designed to emphasize usability. Two similar but incompatible versions of Python are in widespread use (2 and 3). Please consider mentioning the version and implementation that you are using when asking a question about Python.

learn more… | top users | synonyms (3) | python jobs

0
votes
0answers
5 views

Python: Copy files from a folder to another that created 2 days ago

I want to copy the files from a folder to an other that have been created two days ago from today. This is my code: src = '/home/use' dst = '/var/tmp/backup_tmp' two_days = datetime.now() - ...
0
votes
0answers
8 views

How to update matplotlib plot in while loop?

I am trying to write a script that plots a figure and asks the user to select two points. It then draws a rectangle of which the points are the bottom left and top right corner. The process is then ...
0
votes
1answer
9 views

Python: Get list of URLs from tk.Text and process them

I want to get URLs written as a list in a tk.Text widget and process them systematically one after the other with urllib2. I’ve written the code below but it doesn’t function. I tried to understand ...
0
votes
1answer
13 views

Is this POST data formatted correctly?

I will be storing the following in a string and passing it into a urllib2.Request object: request.add_data(my_data) When I test my code, I get a 400 error, and I'm not sure if this part is causing ...
0
votes
1answer
18 views

Is it able to import from a module named uid_2014-10-13.py?

I used python's datetime module to generate date oriented uid file. But I find that I can't import from `uid_2014-10-13.py' seems that python think these '-' in 2014-10-13 are minus operator. Am I ...
0
votes
1answer
10 views

seaborn jointplot with arrays of different length

I'm trying to draw joint distribution of 2 variables in a package named seaborn (a wrapper over matplotlib). Ultimately, I want to get something like this: ...
0
votes
1answer
10 views

How to create zip of a specific folder using shutil

I'm trying to zip all the folders of a particular directory separately with their respective folder names as the zip file name just the way how winzip does.My code below: folder_list = ...
0
votes
0answers
3 views

datemode error using xlutils

I am trying to modify Excel files using python, but I can't get the xlutils package to work correctly. When I try an example (from this thread): from xlutils.copy import copy w = copy('book1.xls') ...
0
votes
0answers
5 views

How can I subset a data frame based on dates, when my dates column is not the index in Python?

I have a large dataset with a date column (which is not the index) with the following format %Y-%m-%d %H:%M:%S. I would like to create quarterly subsets of this data frame i.e. the data frame dfQ1 ...
-4
votes
1answer
29 views

Python, only using if statement without else and/or elif

given the task below: Write a program that asks the user to input a string. Verify with tests that the string is all in upper case and ends with a period. If either of these tests fails, print an ...
-1
votes
1answer
18 views

Python - Sending requests to an Internet Protocol

Well, I recently got attacked by DoS, and need to understand some things. I know that if someone was launching an attack on an HTTP server, he or she would send HTTP requests to make the connection ...
0
votes
0answers
10 views

ubuntu-tweak cannot run on the ubuntu14.04

Today, when I start my computer,the Unity had been changed. Then, I want to run the application ubuntu-tweak to change the desktop. When I run it,the application can run and give me the error as ...
0
votes
1answer
10 views

Python sockets: how to enable promiscuous mode in linux

According to python documentation we can build simple sniffer like : import socket # the public network interface HOST = socket.gethostbyname(socket.gethostname()) # create a raw socket and bind it ...
0
votes
1answer
14 views

python:compare if string in list

I have a problem. I have an product.address like this 'UK some city some road' And I want to compare this address,if it is start with UK or US or AS or GE I will save product.dstore_id = ...
1
vote
1answer
5 views

cannot use current_user in jinja2 macro?

I was creating a simple macro in jinja2. I use flask-login to manage my current_user. On my base template, I can confirm this is working. {% if current_user.is_authenticated() %} <li><a ...
1
vote
0answers
11 views

How to email to multiple users via x-smtpapi?

I am utilising both sendgrid-python and smtpapi-python libraries. sg = sendgrid.SendGridClient('xx', 'xxx', raise_errors=True) message = sendgrid.Mail() message.set_subject('yyyy') with ...
0
votes
0answers
19 views

Celery - one task in one second

I use Celery to make requests to the server (in tasks). I have hard limit - only 1 request in one second (from one ip). I read this, so its what I want - 1/s. In celeryconfig.py I have: ...
1
vote
0answers
11 views

matplotlib scatter plot change distance in x-axis

I want to plot some Data with Matplotlib scatter plot. I used the following code to plot the Data as a scatter with using the same axes for the different subplots. import numpy as np import ...
-2
votes
0answers
11 views

level wise parsing and skip the repeated tags in Python

How to write a program for reading or parsing the XML file in Sub root Wise. For ex: Below XMl, I want to read/ parse first country details and here also two year tag values are there.. Here I ...
0
votes
0answers
9 views

How to unit test image upload in Django REST Framework

I've just started with Django REST Framework and I'm trying to test a simple file upload enpoint. I've written a barebones code as follows: models.py class Picture(models.Model): some_field = ...
0
votes
0answers
21 views

Extract certain Text and URI parts from downloaded html pages

I have downloaded many html pages and I want to extract from each such tags (the single files are stored in directories and subdirectories) <h2><a ...
0
votes
1answer
13 views

Issues with Loops and Conditional Statements in Python 3 [duplicate]

I am a very beginning programmer, and I am trying to create a grade book program for a professor at a university, so that he may input his midterm and final exam scores and get an average and letter ...
1
vote
1answer
38 views

While loop issues in Python

I'm trying to write a small Python program for use in secondary schools to teach about ciphers. It's all part of an ongoing project they have to do. However on my while loops I have an if condition ...
0
votes
0answers
19 views

Sending email with Python having correct sending time

I'm sending email through an account with the following Python code: import smtplib from email.MIMEMultipart import MIMEMultipart from email.MIMEText import MIMEText def sendMail(target, subject, ...
0
votes
0answers
6 views

Running python unit test with multiple test runner/result

Normally when I run my python unit test I do like this for a xml report: runner = xmlrunner.XMLTestRunner(verbosity=1, output='test-report') runner.run(suite) or this for a text report: runner = ...
0
votes
0answers
14 views

Use decorated methods (@property) in datatable's fields array (django-eztables)

I'm using django-eztables app (0.3.2), and I'm trying to use some model's properties within fields: model's class: class AModel(models.Model): ... @property def a_property(self): ...
0
votes
0answers
12 views

Unexpected behavior when redirecting stdout in daemon

I am implementing a simple daemon using this example. Everything seems to work well, but when I want to print messages it does not work. I overwrite the run function as this: class MyDaemon(Daemon): ...
0
votes
2answers
13 views

Change list_display in django

In my model, I have a url field: url = models.URLField(...) # This is a url for an image And in django admin, it is displayed as text. What I want to do is display the image itself(like a ...
0
votes
1answer
16 views

start ipython notebook with python file

I am not very familiar with python/ipython but somebody was asking me whether it is possible to start an ipython notebook with a specific python file. It then could be used for debugging. another ...
1
vote
0answers
6 views

Twisted mail server with TLS - no portal?

So thanks to a couple of users here, I now have a (almost) working SMTP Server that supports switching from plain text to TLS connection as required. Basic server code is: from twisted.internet ...
0
votes
0answers
16 views

Protect file with signature created with private key and verified by public key

Sorry if the answer is obvious, I am really new to this stuff. I need protect a file from changing using public-key cryptography. The file should look like this: Filecontent ...
-2
votes
1answer
37 views

Remove empty tags in html

How is it possible to remove empty tags in HTML using python? I have some lines like <span style=" letter-spacing:0.20pt;"> </span><span style="letter-spacing:0.90pt;"> ...
-3
votes
0answers
26 views

What is the fastest way to get the source code given any url in python?

I am a beginner in python and doing a project on web crawling. But my link request function which i use for getting the source code from the input url is not fast enough. It is also not safe enough as ...
0
votes
0answers
8 views

python flask-login code magic

Had an error while using Flask-Login package, and during some debug process find this code into the LoginManager class: ... def __init__(self, app=None, add_context_processor=True): ... ...
0
votes
1answer
32 views

Calling class in another folder

Given the folder structure as follows: folder1 __init.py__ python1.py folder2 __init.py__ class1.py say in class1.py I have class aa: def __init__(self,max): self.max=max def ...
-4
votes
0answers
10 views

Get the Excel data into RDF triples

I am working on a Semantic Web project and I want to extract the data from the Excel sheet by getting the xlsx data into RDF triples. I think it's best to do this with Python?
0
votes
0answers
12 views

jQuery autocorrect and flask - add to list

Greetings Stackoverflow, I am struggling to get the correct information from my JSON object I have passed to the input field. Form class ClassForm(Form): function_name = ...
0
votes
0answers
14 views

program doesn't react to string input statement [duplicate]

I want the program to react to a particular string input. In my case it is "no" or "n", but it doesn't; where is the mistake here? import random print ("hi this is a surprise generation app") y1="" ...
0
votes
0answers
7 views

Get error message from Oracle exception using python and cx_oracle

The problem: I need to get error message from oracle database exception, but I don't know how. Example: try: ... cursor.execute("<SOME SQL>") except DatabaseError, e: error, = e.args ...
-1
votes
1answer
21 views

Open CSV File, Write to list, compare 2 lists and print values that appear in both

I am attempting to open two csv files and append them to separate lists then to print out the values that appear in both lists. This is my code below, I cannot get it to print out the list as of yet. ...
0
votes
0answers
8 views

Inserting an image to MySql type BLOB from python and show from MySql to PHP

I am trying to store an image from an url to my database as base64, but when I try to show it in a webpage based on php, it doesn't work.. Here's the python code: import urllib3, io, requests from ...
-2
votes
1answer
23 views

Why does py.test give this error?

I have installed all the required things, including pytest , still i get "EBUSY: [Resource Device]...." error as show in the image. Why is that? I have specified the path too, which by the way ...
0
votes
1answer
28 views

List function parameters not equal to their default values

Given a Python function definition of the form: def foo(a=None, b=1, c='bar'): How can I dynamically determine which parameters have been set to a value different than their default value? For ...
1
vote
0answers
14 views

Python - How to connect to TOR proxy

I've been trying to find out how I would connect to a TOR proxy or connect to the TOR network. With the Socksipy module, I see that people (other stack overflow TOR python questions) can connect to a ...
0
votes
1answer
8 views

Dynamically add class to label tag of particular field in django admin

I have this model. I'm trying to make the label tag for the 'info' field change background-color, if approved=True. Here my models and admin files models.py class MyModel(models.Model): name = ...
0
votes
1answer
10 views

Upload Image To Imgur After Resizeing In PIL

I am writing a script which will get an image from a link. Then the image will be resized using the PIL module and the uploaded to Imgur using pyimgur. I dont want to save the image on disk, instead ...
0
votes
2answers
12 views

pyplot compbine multiple line labels in legend

I have a data that results in multiple line plot, I want to give this lines single label on my legend. I think this can be better demonstrated using the example below, In [22]: a = np.array([[ 3.57, ...
0
votes
0answers
10 views

bash locking mechanism using sockets

I have found this solution to do a process locking mechanism in python: import socket import sys import time def get_lock(process_name): global lock_socket lock_socket = ...
0
votes
1answer
7 views

App Engine “NeedIndexError: no matching index found” does not occur on development server but does on production

I have a Python app engine app that works fine on the development server, but does not work after I upload it on the actual appspot.com server. It seems that missing composite indexes does not ...
1
vote
3answers
15 views

mysqldump error on simple python code

I run the following simple python 2.7 code; dumpcmd = "mysqldump -u " + DB_USER + " -p" + DB_USER_PASSWORD + " " + db + " > " + TODAYBACKUPPATH + "/" + db + ".sql" os.system(dumpcmd) The ...