Tagged Questions
0
votes
1answer
12 views
Object attributes and dictionaries
Compare
class Results(object):
foo = 1
bar = 1
r = Results()
r.__dict__
Out[54]: {}
and
class Results(object):
def __init__(self):
self.foo = 1
self.bar = 1
r = ...
0
votes
0answers
10 views
How would I log in on Facebook using a python programme?
I have a Python programme that I have stored my log in details on, How would I get the python programme to connect to the Facebook login page and input my log in details for me and then log in or ...
0
votes
0answers
11 views
Difficulties in designing a GUI using a class-based approach
So, I had difficulties before with developing my GUI that essentially highlighted that my approach was all wrong. I've since tried again. The original question with the extensive background is here: ...
0
votes
2answers
40 views
How to execute a calculation in python and capture the output?
How can I execute a calculation in python (2.7) and capture the output in the variable 'results'?
Input:
let calculation = '(3*15)/5'
let formatting = '\\%2d'
let grouping = '0'
exe "python -c ...
0
votes
3answers
22 views
Python write a new csv file by filtering selected rows from an existing csv file
just a question, I was trying to write selected rows from a .csv file to a new .csv file, but there is an error.
The test.csv file that I was trying to read is like this(two columns):
2013-9 1
...
0
votes
0answers
8 views
In Python Pylons, how should I call a controller action directly?
I've got a controller with an action:
class MyController():
def myAction(self):
#do stuff
There is also a route to it: my-controller/my-action.
I'm writing a script and I'd like to be ...
0
votes
0answers
12 views
pip install misses some generated files when writing installed-files.txt
When pip installing a project that has a custom build_py command which generates an additional file in the build directory, the installed-files.txt file generated by pip on an install does not list ...
0
votes
1answer
10 views
Python MySqlDB store_result returns only one row
I'm using MySqlDB to execute many queries that I have in a dictionary, my problem is that store_result() only returns one of the severals statistics I wan't to get.
Here on of the query that gives me ...
-2
votes
0answers
11 views
Vbulletin Forum Sites Post
I want to login from the forum site I wrote the code I want to open a new topic on the forum website. this site VBulletin Forum's base
import mechanize
usr = "hadila"
pas = "12345678"
sitename = ...
-1
votes
2answers
36 views
Getting rid of 'nan' from list value of dictionary , python
I have this dictionary:
dict_new =
{'extracted_layout': [nan, nan, nan, nan, nan, nan, nan, nan, nan, 'shyamanna layout', nan, nan, nan, nan, 'm t s layout', nan, nan, nan, nan, nan, nan, nan, nan, ...
0
votes
0answers
25 views
print get request generated by requests module in python [duplicate]
lets say i create a GET request using requests module in python as follows:
import requests
r = requests.get(url)
print r.text
now r.text will print the response. Is there a way to print the ...
1
vote
1answer
27 views
Ring Buffer for n-dimensional Vectors
I am working on an real-time application. For this I need to store around 20 arrays per second. Each arrays consists of n Points with their respective x and y coordinate (z may follow as well in the ...
-2
votes
0answers
11 views
How to use txloadbalancer [on hold]
I want to use load balancer in python, so I downloaded txloadbalancer in python. How to use that load balancer?
1
vote
0answers
20 views
Python sub processes block when doing blocking read from stdin in main process
I have a Python multiprocessing application which starts "workers" using the multiprocessing API. The main process is itself started by a service process which is not written in Python. The workers ...
1
vote
0answers
14 views
Python's difflib SequenceMatcher speed up
I'm using difflib SequenceMatcher (ratio() method) to define similarity between text files. While difflib is relatively fast to compare a small set of text files e.g. 10 files of 70 kb on average ...
0
votes
0answers
12 views
Kill iPython Notebook Tab In Browser If Notebook Server Is Stopped
I want to kill Ipython Notebook tab in browser automatically if notebook server is stopped. Alternatively, whenever notebook server starts, it has to check if an existing tab is there. If a tab exits, ...
0
votes
0answers
9 views
Overhead regarding the Pub Sub mechanism of Wamp WS
I have created a Websocket server application using the python Wamp WS server library.
I am making use of the "PubSub" mechanism provided by the Wamp WS.
I need to egister about 200 - 300 clients with ...
1
vote
1answer
43 views
How to debug python script that is crashing python
I'm trying to help debug a python script that is causing python (2.7) itself to crashes.
The script logs some info to a file and it ends at a different stop on each run, or at least what it writes ...
0
votes
1answer
12 views
How to change kivy NumericProperty object atrribute by pressing button in other screen
In our app, we have a GameScreen that has a NumericProperty object that displays a player's score (GameScreen_player1_score). On a separate ClueScreen (using kivy Screen Manager) we have a ...
1
vote
0answers
16 views
Python Parameterized Queries with Special Characters and UTF-8 Characters
I'm new to python so I apologize for something I assume is an easy question, but haven't been able to find a good reference on how to do it. I think I might be confused about how to use of unicode ...
0
votes
1answer
24 views
Python “print” coming after while loop even though it's physically before?
I'm messing around with some python (in eclipse using dynamic language toolkit) and even though I have the print command a line before my while loop, I have to enter the values and type "done" before ...
0
votes
1answer
20 views
Pickling a dict inside a PyQt app
I'm attempting to dump a pickle file in my PyQt app only its seems to be completely ignoring the statement.
import cPickle as pickle
class MyActions(QtGui.QMainWindow):
def __init__(self, ...
0
votes
3answers
36 views
Use Python 2 Dict Comparison in Python 3
I'm trying to port some code from Python 2 to Python 3. It's ugly stuff but I'm trying to get the Python 3 results to be as identical to the Python 2 results as possible. I have code similar to this:
...
1
vote
1answer
26 views
Using two models in one form in django 1.5
How can I use two models with OneToOne relation in one form using the CreateView in Django 1.5?
My models are these:
class Act(models.Model):
name = models.CharField()
class ...
-2
votes
1answer
33 views
Python write selected rows from a .csv file to a new .csv file [on hold]
just a question, I was trying to write selected rows from a .csv file to a new .csv file, I don't know why there is an error.
The test.csv file that I was trying to read is like this(two columns):
...
0
votes
2answers
15 views
Displaying view function in Django
I am trying to display the result of my view function on a Django webpage but only get one line with no hyperlink.
code:
from django.http import HttpResponse
import feedparser
def index(content):
...
-1
votes
2answers
28 views
Python 3 to 2 equivalent code
This is from Ken Lambert's book, based on Python 3.
print('The median is', end=" ")
What is the equivalent in Python 2? I think it's the 'end=' that's causing the problem.
1
vote
0answers
12 views
Is there a way to force a 32 bit version installation for a Python 2.7.x? [duplicate]
By default, Python 2.7.x installs as 64 bit version on a Linux RHEL.
I'm wondering if there are some options to tell it install as a 32 bit version?
(Need it to communicate with NI-VISA which, for ...
0
votes
2answers
58 views
Solving Quadratic Equation Equal to 0 in Python
I'm new to the python language and I'm trying to write a program to solve for a bunch of time/distance/acceleration variables. I know I need some kind of solve function to use in the ...
3
votes
1answer
19 views
Why can't I define (and save) Tkinter fonts inside a function?
Defining a font inside a function and in the main body of the script seems to behave differently, and I can't seem to figure out how it's supposed to work.
For example, the Label in this example ends ...
-3
votes
1answer
21 views
uncertainty about the use of multi variable
I've got this code below
>>> params = {"server":"mpilgrim", "database":"master", "uid":"sa", "pwd":"secret"}
>>> params.items()
[('server', 'mpilgrim'), ('uid', 'sa'), ('database', ...
1
vote
1answer
21 views
Iterating through all foreign key related children of an abstract django model
I am trying to iterate through all foreign key related models for a given django model. There are potentially 13 different models that might have foreign key relationships but they all inherit the ...
0
votes
0answers
7 views
Boa-constructor will not start. Do I just need to define NO_3D?
I'm trying to use boa- with Python 2.7.6 just as in this question:
could not start boa constructor on windows with python2.7
I get the same error as uchiha.
I have the boa.py file opened in the ...
0
votes
0answers
23 views
Most elegant way to dump json dict with keys in a specific order (python) [duplicate]
I would like to dump some debugging information as human-readable json. This means that I'd like for certain keys to precede others.
I would like to write something like: json.dumps({'b' : 2, 'a' : ...
0
votes
0answers
27 views
Can't stop web server in Google App Engine Launcher
I am running development web server in Google App Engine Launcher without any troubles.
But I can't successfully stop it. When I am press Stop button, nothing happens.
Nothing adds in logs after ...
0
votes
1answer
15 views
Replacing “tokens” in Python string with alternate values
The Problem
Imagine a script that receives a string:
http://whatever.org/?title=@Title@¬e=@Note@
...and a list of tokens:
['arg:Title=SampleTitle', 'arg:Note=SampleNote']
What is the most ...
0
votes
1answer
29 views
Get a 3D or 4D array as input and reshape it to 2D array in a function from external script
Okay, my question is a little more specific than reshaping a 3D or 4D array to a 2D array.
I am writing a script for front end processing of 3D or 4D arrays.
I want to call a function from an ...
0
votes
2answers
38 views
What's the end on 'print “%d” % (5)' called?
A linguistic question I guess, but what's the (5) called in the code
print "%d" % (5) ?
I call the %d an integer representation, but I'm not sure what to call the stuff it actually represents, ...
0
votes
0answers
23 views
Join two tables in different databases where the content of table utf_8 text
How could I join tow tables in different database files using Python, were the stored data a unicode text in utf_8 (arabic text)?
I have table1 in db_b & table2 in db_a.
I want to join them ...
4
votes
2answers
52 views
How to restrict object creation
Consider following example
class Key:
def __init__(self, s):
self.s = s
d = {}
for x in range(1, 10000):
t = Key(x)
d[t] = x
This will create 10000 keys. Is it possible to ...
-4
votes
0answers
26 views
Python Dict poor performance [on hold]
If python dict is not performing well, in that case what could be possibly went wrong ? How to debug? I see it as a problem in keys part.
-7
votes
0answers
32 views
Python Script for replace a character in a string [on hold]
How to replace a character in a string without using replace method in python?
1
vote
3answers
100 views
Accessing python class variable defined inside the main module of a script
I have a django project that uses celery for async task processing. I am using python 2.7.
I have a class in a module client.py in my django project:
# client.py
class Client:
def ...
0
votes
1answer
74 views
django and mysql_config error
I tried to install mysql module with pip install mysql-python and I got this:
(env)nathann@esp2:/home/esp2$ sudo pip install mysql-python
Downloading/unpacking mysql-python
Downloading ...
6
votes
4answers
13k views
“Python version 2.7 required, which was not found in the registry” error when attempting to install netCDF4 on Windows 8
I use Anaconda 1.7, 32 bit. I downloaded the correct version of the netCDF4 installer from here.
I attempted to copy the HKEY_LOCAL_MACHINE\SOFTWARE\Python folder into ...
22
votes
2answers
4k views
Python relative imports for the billionth time
I've been here
http://www.python.org/dev/peps/pep-0328/
http://docs.python.org/2/tutorial/modules.html#packages
Python packages: relative imports
python relative import example code does not work
...
5
votes
3answers
8k views
Python optional parameter
Is there a way in python to pass optional parameters to a function while calling it and in the function definition have some code based on "only if the optional parameter is passed"
3
votes
1answer
2k views
python xlutils : formatting_info=True not yet implemented
I've got simple code to copy files with xlutils, xlrd, xlwt (downloaded new libraries from python-excel.org) with not loosing formatting. I've got an error as below:
from xlwt.Workbook import *
from ...
0
votes
4answers
5k views
Write a program that calculates the minimum fixed monthly payment needed in order pay off a credit card balance within 12 months
This question is for python 2.7. The question asks to write a program that calculates the minimum fixed monthly payment needed in order pay off a credit card balance within 12 months.By a fixed ...
11
votes
4answers
6k views
Python: Recommended way to walk complex dictionary structures imported from JSON?
Importing from JSON can get very complex and nested structures.
For example:
{u'body': [{u'declarations': [{u'id': {u'name': u'i',
u'type': u'Identifier'},
...