Tagged Questions
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.
0
votes
1answer
6 views
No print messages inspite of instantiating a class - Python
I'm having 2 files namely misc.py which contains class declarations and misc_main.py which contains instantiation of the class.
# misc.py
#!/usr/bin/python
class dummy:
def __init__(self):
...
0
votes
0answers
6 views
angle distance between two rating
This may be well a trivial quesiton, but I can't find a solution I am pleased with.
I'd like to calculate the distance (angle, radiants) between two rotating objects, whose x,y coordinates are given.
...
0
votes
0answers
6 views
Two model. Selection list. Not unique
I have two models. I want that to field first model was the selection list of the field of the second model. But field of secondary model is not unique.
Think, need to redifine field in admin form
...
0
votes
0answers
4 views
Python - Memory Error whilst loading values to get a fourier transform
I'm loading in a 500000 kb (0.5Gb) text file of a single column which consists of a series of voltages read in via a daq card.
import numpy as np
import matplotlib.pyplot as plt
import scipy as sp
...
0
votes
0answers
3 views
How do I use g_settings_schema_get_key from python?
I'm following http://www.micahcarrick.com/gsettings-python-gnome-3.html to use GSettings from python, and I've succeeded to read a value:
from gi.repository import Gio
...
0
votes
0answers
4 views
multiprocessing pool self.value out of range for 'i' format code? only with large numpy arrays (in Anaconda, called by scikit-learn)
My code runs fine with smaller test samples, like 10000 rows of data in X_train, y_train. When I call it for millions of rows, I get the resulting error. Is the a bug on the package, or can I do ...
0
votes
0answers
7 views
only text file uploading instead of folder paramiko
This is my ssh.py code. Its only uploading text document instead of folder. i lost refering documents ...
import paramiko
,
,
,
for fname in ...
0
votes
0answers
6 views
Issue with Scrapy and image scraping
So I have been trying to learn Python by creating a pretty basic crawler. At the moment, all of my scraping works as expected, with the exception of images:
I have added an image store to my ...
0
votes
1answer
8 views
Django rest: Invalid choice error
I have model with char field with choices and serializer with same choices. But when I try save object - I get invalid _choice error "Select a valid choice. ... is not one of the available choices"
...
-4
votes
1answer
16 views
Python array from CSV file
I have two python variables.
Location = "myhome"
Iprange = ["10.0.0.3","10.0.0.9","10.0.0.234"]
I would like to pull those values from an external csv file called details.csv that looks like:
...
0
votes
1answer
16 views
Trouble in ending task using Python
I know that in windows cmd I can type the following text to end a process:
taskkill/im chrome.exe /f
But how can I do it using Python?
I've tried this:
from subprocess import *
call("taskkill/im ...
-1
votes
0answers
10 views
python multiple data store and search
i have a problem with Whitelist compare , if the whitelist is specific m like following
10.1.1.1 , 80 ,www.google.com
10.2.2.2 , 443 ,www.yahoo.com
10.3.3.3 , 80 ,www.apple.com
10.4.4.4 , 443 ...
0
votes
1answer
18 views
Limit the number of digits in integer?
Is there a way to limit number of digits in integer in OpenERP like you can in char type?
I need field that would only let you enter max two digits.
For example with char, you can do this:
from ...
0
votes
1answer
15 views
Django redirecting to wrong view in other app
After adding an other app to my django 1.6 project I ran into a strange problem with the HttpResponseRedirect function of django.
I have a login view for both of the apps but when I try to login to ...
-1
votes
0answers
11 views
Find the nearest natural number made by adding or multiplying all or a part of numbers from a given set
Given a natural number (e.g. 3972) called target and a set of natural numbers (e.g 87, 5, 47) I must figure out how to find the closest number to the target that is made entirely by computing add or ...
0
votes
1answer
9 views
strange pymongo behaviour when adding python list
i have this code:
for product_code in product_codes:
product_categories = []
product_belongs_to = []
get_categories = """SELECT * FROM stock_groups_styles_map WHERE ...
0
votes
2answers
22 views
set operation list inside list and filter duplicate coords
I have list which is three dimensional. I need to remove duplicate element . is it possible to filter duplicate element without traversing or more pythonic way.
In below example 890 and 930 are ...
0
votes
0answers
7 views
Paramiko SFTP : list content to a file
Trying to write list content to remote file.Below is my code
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
conn = ssh.connect(hostname='agnel-1', port=22, ...
0
votes
0answers
15 views
What is Clang++ required to build Blaze?
Curious about how Blaze(next generation of NumPy) will be like, I tried to install with
pip install Blaze
The tarball blaze-0.1.tar.gz is downloaded, but error raised:
Clang++ is required to build ...
0
votes
2answers
15 views
Error when combining datetime.date object with datetime.time object
I am currently trying to combine a datetime.date object with a datetime.time object to get the resulting datetime.datetime style object.
I run an SQL query and parse the results by doing the ...
-1
votes
2answers
18 views
How do I remove verbs, prepositions, conjunctions etc from my text?
Basically in my text I just want to keep nouns and remove other parts of speech.
I do not think there is any automated way for this. If there is please suggest.
If there is no automated way, I can ...
2
votes
0answers
18 views
How to automatically document my class properties with decorators
Suppose I have two classes (A & B) of which the second is derived from the first. Further, I hide some of the properties implemented in A by writing new implementations in B. However, the ...
0
votes
0answers
4 views
Differentiate insert and update while set event in sqlalchemy
How to differentiate insert or update?
from sqlalchemy import event
@event.listens_for(SomeClass.some_attribute, 'set')
def receive_set(target, value, oldvalue, initiator):
# Some logic..
# ...
1
vote
2answers
11 views
Python - AttributeError: 'OnDemand' object has no attribute 'calc'
Something is really happening and i couldnt resolve for a day almost
Examples are below: Trying a simple method calling from one class to another class to figure out the problem as i have experienced ...
1
vote
0answers
10 views
When using multiprocessing to access MySQL, it always throws the following error, how to fix?
When I used Python multiprocessing to access MySQL database, always got the errors:
OperationalError: (2006, 'MySQL server has gone away')
Lost connection to MySQL server during query
I ...
0
votes
0answers
14 views
Padding in python and Tor proxy
I'm having a problem with padding in python but only if I connect to server with tor proxy, if I connect from the client to the server everything goes ok.
In particular when I try to download a file, ...
0
votes
0answers
11 views
Selecting points on a PlotWidget with Qt
I'm new to python/pyside/pyqtgraph and I'm kind of stuck in my program.
So, I have an numpy.ndarray representing 10000 values, and I plot it in a PlotWidget using the plot method.
The result is ok ...
0
votes
0answers
6 views
How can i get raw string input from a QTextEdit in pyside?
I am writing a little script to get some user input from a QTextEdit box using QTDesigner and pyside. I want to pass that block of text to a decode method and I keep getting this error:
...
0
votes
0answers
6 views
Why is cron makes Python's logging writing timestamp in UTC and not in local time?
Why is cron makes Python's logging writing timestamp in UTC and not in local time ?
When running a python script through a cron command, my log file contains
timestamps in UTC:
2014-06-18 08:16:34 - ...
0
votes
1answer
16 views
Cannot call method in other class
Here is the page object file: login.py
from pages.base import BasePage
from config import secrets
from selenium.webdriver.common.keys import Keys
class LoginPage(BasePage):
def __init__(self):
...
1
vote
1answer
20 views
python cannot insert string in table
I did a coding for dynamic updating table. it gave me output,but i can only insert Integers not strings it gives me "operational error" if i enter strings,I tried altering the table field datatype, ...
2
votes
3answers
24 views
How to unpack nested tuples in python?
Let's say I have users (John, Anna) that can order fruits (oranges, apples) in a quantity of their choice.
Here is what I have done in python :
orders = (('John', (('apples', 3), ('oranges', 1))),
...
4
votes
1answer
23 views
Capturing console output in Python
I can capture the output of a command line execution, for example
import subprocess
cmd = ['ipconfig']
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
output = proc.communicate()[0]
print output
...
-4
votes
1answer
30 views
print error: cannot concatenate 'str' and 'float' objects [duplicate]
following line gives me headaches:
print 'Total paid ' + round(totalPay, 2)
gives out an error description: "cannot concatenate 'str' and 'float' objects". According to discussion here: Python ...
0
votes
0answers
8 views
Using ROS message and python to update text input field in kivy GUI
I try to design a GUI to handle stepper motors via ROS, kivy and python. You can find a minimal version of the GUI below. Actually I want to use a ROS message to update a kivy text input field (read ...
-1
votes
0answers
28 views
Pass data from get_queryset to get in Django Python
I have it in my urls.py:
url(r'^myclass/(?P<category>/$', MyClass.as_view(), name='myclass'),
EDIT1:
EDIT CODE:
Now I have my views.py class
class MyClass(View, AlterMixin):
...
0
votes
0answers
10 views
Django password hash with customized admin site for user
I wanted to change the layout of the Admin site for creating/changing Users.
I followed Changing User ModelAdmin for Django admin
to customize the Admin site the way I wanted to, but now when I ...
-2
votes
0answers
13 views
Script python on symfony 2 for session management
I'm trying to migrate a complex form on Symfony which is composed of several steps that I created in php without this framework. At the first step of this form the user must add a video. When the ...
-3
votes
1answer
22 views
Where is the temporary file when a 100 mb file is selected via html form and posted to an URL?
If you select a 100 MB file on a HTML form and POST it to a URL
on your web site or on someone else's web site..
Does the server have to confirm that it accepts the file..
i suppose the file must be ...
0
votes
0answers
23 views
Iterating array objects by index [duplicate]
If I have a list of (a,b,c,d) I want to iterate through this list and select two objects for every iteration like elev1 = a and elev2 = b. So similarly for next iteration elev1 = b and elev2 = c. I ...
0
votes
1answer
38 views
Python - find all lists in a nested list
I am working on my own implementation of genetic programming (GP) in Python. GP aims at evolving programs, represented as LISP S-expressions, to search for a good solution to a problem.
S-expressions ...
1
vote
1answer
23 views
Python threading error, anyone got a solution?
I got a problem with my python program for my Raspberry Pi. I want to create a thread from a def in a class. It displays the following error when I try to run the code:
Exception in thread Thread-1:
...
1
vote
0answers
10 views
svn and python module, subvertpy installtion failed
sudo easy_install subvertpy
Exception: Subversion development files not found. Please set SVN_PREFIX or (SVN_LIBRARY_PATH and SVN_HEADER_PATH) environment variable
anyone who knows what happened??? ...
0
votes
0answers
9 views
Tkinter window with both title bar and windows taskbar
I have searched wide and far for this question, but noone seems to know. I create a simple tkinter window in python 2.7 and want it maximized, just as if I would hit the maximize button in top right ...
0
votes
0answers
13 views
Empty results for public user feed using Facebook Graph API
Using the access_token I get, I ask for public feeds using:
https://graph.facebook.com/[obj_ID]/feed/?access_token=TOKEN
For some reason the return value is empty []. The user's privacy settings are ...
1
vote
1answer
20 views
Sqlite: Update multiple columns from a table
Issue
I have imported a csv using python and created a table called upload. I want to update the Fixture table with the new upload table values. I don't want to insert as I have specific ids for each ...
0
votes
1answer
17 views
cross domain file upload using jquery file upload
i am using jquery file upload by Blueimp, and i need to do cross domain file upload(from localhost:8008 to localhost:8000)
But in the initial stage i didn't get the response even, and i got this ...
0
votes
1answer
19 views
TypeError: 'Game' object is not callable
I am just starting out with object-oriented programming and I am trying to make a game about taking care of a character.
Here is part of my code:
class Game(object):
def __init__(self):
...
-5
votes
2answers
34 views
How to use Regular expressions of Python for getting a simple string saved into a variable? [on hold]
I need to get the following as a string using Python.:
temp = Replace(Replace(Replace($name,"PF_",""),"_UP",""),"_DN","")
Please check the below script. I am able to get only
temp = ...
3
votes
0answers
15 views
Always treat a ForeignKey field like it was in raw_id_fields in Django Admin
This scenario happens way too often in my project:
someone adds a model Foo that has several ForeignKey fields, one of them to refers to model Bar
an admin is added for that model (and works OK)
the ...