Tagged Questions
0
votes
1answer
15 views
website using default python interpreter instead of install virtualenv interpreter
I have installed python 2.7 on centos.
I have created and activated a virtualenv associated with this interpreter.
My path looks like this:
...
0
votes
3answers
25 views
Classes, Hidden Attributes and Inheritance
I am pretty new to OOP and Python. Pretty much everything that I know is self-taught, so I would be grateful if you can provide just links for me to read since I do not know the exact terminology that ...
-2
votes
3answers
34 views
How do I execute an def in python from input
For example, I have:
def function():
return
and I want to execute it via:
d = input('Enter the def name: ')
by entering the def name('function' in this case).
How would I do this?
...
-1
votes
0answers
12 views
python for loop -mysql
Data
uid Chr_postion chr_start chr_end region gene
1 chr1 934380 934586 HES4_69.395 HES4
2 chr1 935336 935537 HES4_72.3360 HES4
3 chr1 984384 984583 AGRN_99.4969 AGRN
...
0
votes
0answers
20 views
Python 2.7 & Linux - Memory release issue
I'm running twistd server with python script which does next:
1. Accepts user's request
2. Analyzes it
3. Creates worker for current request and runs some data extraction based on it (from internal DB ...
0
votes
0answers
11 views
Upload a file to Sugarcrm
I am having trouble uploading a file, from a form to Sugarcrm.
I am using this tutorial, which states that the following code should update an account:
#2 - UPDATE AN EXISTING ENTRY
sugarcrm_conn= ...
0
votes
1answer
20 views
Inserting value in orderedict by index?
Let say I have this ordered dictionary:
import collections
d = collections.OrderedDict([('a', None), ('b', None), ('c', None)])
And I have these values in a list:
lst = [10, 5, 50]
Now when I ...
0
votes
1answer
21 views
how to get a single list element in yaml format
In my python program , I have my string:
test = {"Controller_node1_external_port": {"properties": {"fixed_ips": **[{"ip_address": "12.0.0.1"}]**,"network_id": {"get_param": ...
-1
votes
1answer
21 views
TypeError unsupported operand type(s)
from math import *
a = input("A= ")
b = input("B= ")
c = input("C= ")
d = b*b-(4*a*c)
print "The discriminent is: %s!" %d
if d >= 0:
x1 = (0-b+sqrt(d))/2*a
x2 = (0-b-sqrt(d))/2*a
...
0
votes
0answers
18 views
Django ForeignKey db_constraint
I have a question about ForeignKey.db_constraint
If I understand the documentation correctly, if I set this to false a Foreign Key constraint is not created in my database correct? Which allows me to ...
1
vote
0answers
17 views
web2py; psutil import error dll load failed
I am developing a web app using web2py, I am new to both web app development as well as web2py.
In my python code, I have to use 'psutil' for calculating the disk size, ram being used, free ram, and ...
0
votes
1answer
12 views
Weird load_module input parameters
I have written a custom Python module loader/importer which has find_module and load_module methods. I run into a bit of a problem when I want to import Cherrypy module with it.
In
cherrypy/__ ...
1
vote
2answers
25 views
Block execution until condition
I am using eventlet and have two main process running. One of the process acts as a producer and the other as consumer. The problem is that instead of using queue from eventlet package I want to use a ...
0
votes
2answers
27 views
How to print only first few lines of output through python code?
Is there a special method/function to print only first few lines of output in python 2.7. We know that in terminal we could do that through "$head -3 " for seeing first 3 lines. do I have to just ...
-4
votes
1answer
22 views
How to deploy a django website on google app engine?
I have a website written in Django now I want to migrate to google app engine. What is the easiest way to deploy Django app on google app engine with minimal changes, my database is in postgresql. ...
0
votes
2answers
37 views
Influence of choosing string as seed of random on the output
In python, in order to permutate the lettters of a string one can write
import random
random.seed(str_key)
length = range(len(original_str))
random.shuffle(length)
join "".join([original_key[idx] for ...
0
votes
1answer
39 views
Pythonic way to strip a string
I am trying to achieve a python equivalent of the following bash command:
VERSION=$( curl --silent "http://nexus:8080/nexus/service/local/lucene/search?g=com.xxx.yyy&a=zzz" | sed -n ...
0
votes
0answers
15 views
Python Eclipse threaded subprocess.Popen() <terminated, exit value: 137>
I am running python 2.7 on Ubuntu in Eclipse
I am trying to call subprocess.Popen from a thread other than the main thread.
When I run this code from Eclipse:
#lsbt.py
class ...
1
vote
1answer
12 views
how to point django website to python version besides default on centos
I am using Centos and have installed python 2.7 so that I can run django 1.7.
I installed python 2.7 according to ...
0
votes
2answers
26 views
Python String Parsing Floats [duplicate]
How to change a '14/15' string to a float?
I am trying to extract data from a text file would like to convert '1/3' to a float. float('1/3') doesn't work. I was thinking about splitting into two parts ...
0
votes
0answers
8 views
Storing/retrieving username and password in a Kivy iOS app using Keychain
Is there a way to use iOS Keychain to store and retrieve a username and password in a Kivy app?
2
votes
1answer
36 views
How to change the Python Interpreter that gdb uses?
I'm using ubuntu 14.04, where python3 is a default system package.
I want to debug Python2.7 programs with gdb, but I seem to encounter this issue:
When i'm in gdb, using the py command puts me in ...
1
vote
1answer
15 views
Using lmfit to find out what function models my data
I am trying to determine what function best models my data, and online research has pointed me to lmfit. Trying the original example code, applying it to my data worked ...
0
votes
1answer
31 views
ValueError: Expecting property name: line 1 column 2 (char 1)
guys. I have a database with lots of tweets that I crawled using Twitter API. Those tweets are in a json format what allows me to convert them into dictionaries, right? So here we go: I'm trying to ...
-3
votes
0answers
32 views
Combine a hex tuple
I have a hex tuple of ('00', '17', '0d', '00', '00', '38', '1d', 'ab')
I would like to combine it into one string: '00-17-0d-00-00-38-1d-ab'
Not having much luck with the join command.
Edit
The ...
1
vote
1answer
27 views
Saving offline copy of Google Python tutorial using python.
I am trying to write python code to save offline copy of "Google python tutorial" so that I can access the file even when I am not connected to internet.
For this I am importing the following ...
0
votes
0answers
15 views
django run server error with mysql
After I solve the issue with "image not found" when I run python manage.py syncdb by adding "export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/" into .bash_profile.
The problem comes with python ...
0
votes
0answers
9 views
navigate the timeline buttons
I'm working on my python script for xbmc media application.
I have added the list of buttons for the channels and programs in the tv xbmc guide. I have one yellow image in the channel button and I ...
-3
votes
0answers
25 views
Highest value of multiple dictionaries
I need a function which takes a list of dictionaries, checks the value of the key "id" in each
dictionary and returns the maximum value. Assuming that each dict has the key "id"
Could anyone help me?
...
0
votes
1answer
32 views
No module named Tkinter
I have a small script in python2.7 that I want to convert into Windows executable. I use pyinstaller for this.
The script:
import sys
import matplotlib.pyplot as plt
import matplotlib.image as ...
-8
votes
0answers
35 views
make better performance through python [on hold]
We have a python code which gives start/stop functionality in our application. This is two thousand lines of code. But when this script uses in multiple session, this code either start giving poor ...
3
votes
1answer
45 views
how to join multiple sorted files in Python alphabetically?
How can I read multiple CSV input files line by line, compare the characters in each line, write the line appearing first alphabetically to an output file, and then advance the pointer of the minimum ...
0
votes
0answers
7 views
How to correctly use PaCAL Lt() conditioning
I was very excited to have just discovered PaCAL. However, I'm having a problem and can't tell if it's a bug, or my incompetence.
Running the following code (to find the conditioned distribution):
...
0
votes
0answers
13 views
httplib2 can I get original response headers
Here is my sample code:
http.debuglevel=1
...
response, content = conn.request(target,method,body,headers)
print response
here is the result from the fact I am in debug (note I just left few lines ...
-1
votes
0answers
15 views
Python 2.7 - Tkinter user entry prompt
Okay, so I'm attempting to deploy a Tkinter prompt into my script to simply read the user entry into the "ROOTDIR" variable.
Below is a Tkinter script that seems ideal for what I'm attempting to ...
0
votes
0answers
21 views
Import pexpect in child module - 'no module named pexpect'
I'm seeing weird behavior that I don't understand, so I'm turning to the experts here on SO for help. I have looked at similar questions, without finding anything that looked helpful.
I'm writing a ...
1
vote
1answer
10 views
Extract an attribute value , Lxml
I have the following Xml file:
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r\n<w:document xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" ...
0
votes
0answers
8 views
Error in installing sip4.16.3 for PyQt4
I am trying to install PyQt4 on mu ubuntu 14.o4 LTS.
The installation manual says that before installing PyQt, sip must be installed having version atleast 4.16 .
So, I downloaded the archive and ...
1
vote
0answers
48 views
Putting an if statement in a function call [on hold]
I am building a Qt-based program. At some point, a variable var gets set with a certain text. Depending on whether a checkbox is checked or not, a flag gets set to True or False and the variable var ...
1
vote
0answers
13 views
pypfop 0.2.0 and environment variable FOP_CMD
I'm trying to get working pypfop 0.2.0 with this tutorial. Unfortunately I'm not able to pass through step 2.2:
Decompress in wherever place you like and set environment variable FOP_CMD to the ...
1
vote
2answers
22 views
How to merge 2 xml files with namespaces
I am trying to merge two XML files using ElementTree module. Following are the XMLs:
a.xml:
<?xml version="1.0"?>
<ListOrdersResponse ...
0
votes
4answers
46 views
Unable to restrict loops to 21 lines
I am trying to loop over a list. Each row contains three numbers. The list can be as long as it can be but I just want to check the first 21 rows. I've tried using islice but I cannot seem to get it ...
0
votes
2answers
22 views
Python “while true” loop does NOT end (using Python Tweepy)
The following code seems to be mostly "working". Meaning that it scrapes all the tweets from Twitter API for a specified day. Though it seems the while True loop never breaks and I don't see the ...
0
votes
3answers
30 views
Python convert epoch time to day of the week
How can I do this in Python? I just want the day of the week to be returned.
>>> convert_epoch_time_to_day_of_the_week(epoch_time_in_miliseconds)
>>> 'Tuesday'
-1
votes
2answers
25 views
Python - archiving file before moving to another directory? [duplicate]
Let say I have this code that moves files in another directory:
import os, shutil
try:
os.chdir(rec.gec_daily_dir)
direct = os.listdir(/src/dir/)
for f in direct:
...
0
votes
0answers
19 views
Correct proxy settings in PyCharm using Python 2.7
I set up my Python programming environment using the latest PyCharm Community Version (3.4) and Python 2.7.8 on a Windows 7 machine. I'am working behind a proxy for SSL-Connections like the ...
-2
votes
2answers
33 views
Count decimal places in a float [duplicate]
In python, I import a file that has different length decimal places in the numbers, such as 7.2 or 7.2332 Is it possible to find out the number of decimal places in the number, if so, how? All the ...
-3
votes
2answers
34 views
how to merge data present in text files without changing the format using python? [on hold]
I have 3 files, file1,file2 and file3, in file1 I have 3 columns say with 10 rows; in file2 I have 1 column with say 15 rows; in file3 I have again 1 column with say 10 rows. Now how do I merge all ...
0
votes
1answer
32 views
How to convert python str to bytearray
I'm using Python 2.7 and I need to convert return value of strcut.pack() function (which is str according to docs) to a bytearray object. bytearray() builtin function accepts a string value, but docs ...
-3
votes
1answer
44 views
Python Error : global variable is not defined [on hold]
I am learning python from Coursera An Introduction to Interactive Programming in Python . Please go to Code-Skulptor http://www.codeskulptor.org/#user38_FhvRVUdSKJ_0.py and please correct the program ...