Tagged Questions
0
votes
0answers
4 views
How to write to cloudstorage using task chaining, The blobstore Files API did a nice job
Using the blobstore File API, I could write very very large blobfiles:
create a blobfile
read data from the datastore and write (append) to a blobstore file
pass the datastore page cursor and the ...
0
votes
1answer
5 views
Auto Starting a python script on boot (RPi)
I have a python script on my RPi that needs to run on boot
I added it to rc.local, and it used to work fine
A few days ago, I added a functionality to the program, and it now uses open() to read a ...
1
vote
1answer
31 views
Trouble getting XML elements using ElementTree
I'm trying to parse XML document in Python, so that I can do manipulations on the data and write out a new file. The full file that I'm working with is here, but here is an excerpt:
<?xml ...
-2
votes
0answers
22 views
server not working-Beginner level [on hold]
I want to create an simple web server which accepts my request and sends response messages.
I have developed the below code. There is some error through which it is unable to accept request and send ...
0
votes
0answers
7 views
Codeskulptor simplegui module for Python 2.7
I want to know if there is any way i can use the simplegui module (used in CodeSkulptor - www.codeskulptor.org) with the python 2.7 IDLE?
There is this question - How to integrate ...
2
votes
2answers
47 views
Why does a class' body get executed at definition time?
In contrast to functions, a class' body is executed at definition time:
class A(object):
print 'hello'
Out:
hello
Why is it the case? Is it related to @classmethod / @staticmethod methods ...
0
votes
0answers
27 views
Change the priority of python sys.path
How can I change the priority of the path in sys.path in python 2.7?
I know that I can use PYTHONPATH environment variable, but it is what I will get:
$ PYTHONPATH=/tmp python
Python 2.7.6 (default, ...
-1
votes
0answers
23 views
apple push notifications script not working suddenly
How can I test if my development ASPN certificate is working?
My python script gives the following error:
Traceback (most recent call last):
File "pushnot.py", line 15, in <module>
...
0
votes
1answer
6 views
Can't install trigger network automation tools
I read in the howto documentation to install Trigger, but when I test in python environment, I get the error below:
>>> from trigger.netdevices import NetDevices
>>> nd = ...
1
vote
1answer
26 views
Extract content of <Script with BeautifulSoup
1/ I am trying to extract a part of the script using beautiful soup but it prints Nothing. What's wrong ?
URL = ...
0
votes
1answer
30 views
Transform an algebraic expression with brackets into RPN (Reverse Polish Notation) form
from sys import stdin
t=int(stdin.readline())
while(t):
s=stdin.readline()
str = []
top=-1
for i in range(0, len(s)):
c=s.index(i)
if(c>='a' and c<='z'):
...
0
votes
1answer
29 views
re.compile does not work properly
I'm trying to find tag usin bs4, where text is in format: 'Firma: ...........'. The problem is that re.compile does not work for this at all. I can't find out what am I doing.
Here is the code of ...
-1
votes
2answers
55 views
How to find the nearest prime number in an array, to another number in that array?
I wanted to find out the nearest prime number (that is present in that array), to any another number in the array ?
Example :
list a -> [1,2,4,6,8,12,9,5,0,15,7]
So the nearest prime number to 4 ...
-1
votes
2answers
22 views
“None” output after raw_input in Python 2.7 bug
This is a part of a text adventure that I am working on. It works fine until the user inputs any button to start, and then it prints "None". I was wondering if there was a simple way that I either am ...
0
votes
1answer
55 views
Python sort is not working appropriately
I am trying to sort a list in python by one of it's property, however, it's not sorted correctly, any hint.
I try to print the value before and after sort, they are printing the same value.
def ...
1
vote
2answers
32 views
Why does Python's max() function place a low value on strings with a leading space?
The Quesion
I've noticed that the built-in max() function in Python 2.7.6 seems to place a low "value" on strings with a leading space unless I specifically tell it to use the len function as the ...
-3
votes
1answer
28 views
Key error in dna complement [on hold]
import string
import os,sys
file=open("C:\Python27\\New Text Document.txt",'r')\
seq =file.readlines() basecomplement = {'A': 'T', 'C': 'G', 'G': 'C', 'T': 'A'}
def translate(seq):
aaseq = []
...
0
votes
2answers
19 views
Python stack contents are overwritten when passed to a function
I wrote a quick Python function to reverse the contents of a stack.
def ReverseStack(input_stack):
oldStack = input_stack
newStack = Stack()
while not oldStack.isEmpty():
item = ...
0
votes
1answer
33 views
Python Printing format
i have a table like
This is in CSV file (which i read in python)
Temp E1 E2 n
100 3000 500 0.31
200 4000 521 0.32
300 5000 522 0.33
I want to print follwing output ...
0
votes
1answer
37 views
How do I use Python multiprocessing to get rid of nested while loops
I made this ray tracer to simulate two lens. Each time a ray hits a screen, the position on that screen is voted for. However, this is running so slowly. It's nothing with the ray tracer, is just the ...
0
votes
1answer
13 views
Any way to use rrule going backwards
Is there any way to run dateutils.rrule.rrule going back in time? For example, I would like
[dt.datetime(2014, 8, 29, 0, 0),
dt.datetime(2014, 9, 5, 0, 0),
dt.datetime(2014, 9, 12, 0, 0),
...
0
votes
1answer
46 views
Python Dictionary (Edit only values of Dictionary)
I am beginner with python. I have a list. I want to loop over values of list and add each to my dictionary values respectively. It looked simple but I tried to write few loops but none was working for ...
1
vote
1answer
7 views
How to properly configure the new Anaconda 2.1 in PyCharm 3.4?
I recently updated to Anaconda to 2.1. For some reason, Pycharm 3.4 was previously configured with E.Canopy - Python 2.7.6. I did not know that, so yesterday I uninstalled Canopy. Now when I open ...
-5
votes
2answers
45 views
What are the differences with the code below?
I'm writing a few pieces of code and I've got some questions
def fanction(tata):
for i in range(0,4):
tata +i
print tata
tata =0
fanction(tata)
The results are
0
0
0
0
...
-1
votes
2answers
36 views
Instantiate a class but don't call its __init__ method [duplicate]
I want to know if is there any way to make an object of a class, but don't call its __init__ method :
Look at the below code :
>>> class test():
def __init__(self):
print("an ...
1
vote
1answer
24 views
How do I close a request to a streaming radio stream url?
I am crawling a few pages with requests and came across a url of a radio stream. I'd essentially just like to skip it or do some sort of timeout but the request doesn't end:
u = ...
1
vote
1answer
8 views
Cartopy map visualization error: unknown projection
I want to try some of the Cartopy gallery examples. I'm trying the African map now, but when I run:
import cartopy
import matplotlib.pyplot as plt
ax = ...
0
votes
2answers
42 views
How to install subprocess module for python?
pip is not able to find this module, as well as me on pypi website.
Could you please tell me the secret, how to install it?
I need the module to spawn new shell process via subprocess.call. I have ...
1
vote
2answers
31 views
Separate a set of sublists from within a list by a given element of a sublist
Input is:
main_list = [['a','1','x'], ['b','2', 'm'], ['a', '23', 'm'], ['c', '34', 'x'], ['b', '11'], ['b', '32', 'y']]
Final result should be:
a_list = [['a','1','x'], ['a', '23', 'm']]
...
1
vote
2answers
22 views
Update Parse User info to keep track of player scores in kivy app
we would like to use parse to track our user's scores in our kivy app. Our app requires an encoded secure login so when we try to link the User's parse information (e.g., objectId, username, etc) to ...
2
votes
0answers
16 views
Python/Bokeh: GLib-CRITICAL **: g_slice_set_config: assertion 'sys_page_size == 0' failed
I am trying to run the examples in the bokeh/plotting/server folder of the bokeh interactive visualization library and get the error:
GLib-CRITICAL **: g_slice_set_config: assertion 'sys_page_size ...
3
votes
1answer
65 views
Passing a c++ vector to python and back
I am using a c++ code to do some simulations on an image. At some point, I need to label the image clusters, for which I want to use python ndimage.label (because it is almost 10 times faster than my ...
2
votes
2answers
138 views
anaconda launcher links don't work
I've installed anaconda on mavericks osx. When I'm trying to install ipython notebook from launcher app - it shows message that app is installing, but nothing happens after. Also links in launcher ...
3
votes
1answer
37 views
Creating an installer for a python GTK3 application
I have just finished developing a Python 2.7 application using Gtk3 for GUI.
My question is, how can I now create an installer for Windows, Mac, and Linux (possibly three different installers) for my ...
1
vote
1answer
40 views
No python module found on Mac OSX
I have installed a python module called python-firebase and I installed pip on my Mac OSX 10.8.5 using the command sudo pip install python-firebase and when i run pip list I can see it displayed as ...
16
votes
1answer
1k views
How can I copy a Python string?
I do this:
a = 'hello'
And now I just want an independent copy of a:
import copy
b = str(a)
c = a[:]
d = a + ''
e = copy.copy(a)
map( id, [ a,b,c,d,e ] )
Out[3]:
[4365576160, 4365576160, ...
0
votes
1answer
104 views
PyObject_GetAttrString C++ function returning NULL: Unable to call Python functions from C++
I've just started working with Python with C++ and I'm a bit confused on why I'm unable to call functions in Python from C++.
Here is my current test code in C++:
#include <iostream>
...
8
votes
6answers
3k views
Fatal error when using scripts through virtualenv - extra quotes around python.exe
I am very new to Python and recently installed Python 2.7.6 x86 on Windows. I am trying to create an environment via virtualenv. I installed Python, then installed pip and virtualenv globally. I ...
1
vote
1answer
336 views
How do I tell Aptana Studio to use Python virtualenv?
I did some searches on this topic and the solutions didn't work for me. I am running both a Linux (Ubuntu) environment and Windows. My system is Windows 8.1 but I have virtualbox with Ubuntu on ...
3
votes
1answer
843 views
How to debug crashing openoffice with pyuno
I'd like to use openoffice to programmatically convert docx to pdf. I know unoconv can do this, and indeed unoconv will do this for me, even if I run a separate listener (using unoconv -l) and invoke ...
4
votes
2answers
2k views
python pprint dictionary on multiple lines
i'm trying to get a pretty print of a dictionary but i'm having no luck:
>>> import pprint
>>> a = {'first': 123, 'second': 456, 'third': {1:1, 2:2}}
>>> pprint.pprint(a)
...
2
votes
1answer
2k views
Change the options in OptionMenu in python tkinter
Say I have an option menu network_select that has a list of networks to connect to.
import Tkinter as tk
choices = ('network one', 'network two', 'network three')
var = tk.StringVar(root)
...
-1
votes
0answers
132 views
CMS on existing website in python in google aps engine
It's my first post so
Hello everyone :)
It's my first challenge in webmastering so forgive for my lack of knowledge in this case.
I have ready website (with html, js, css etc.) but I need do CMS to ...
30
votes
1answer
29k views
Url decode UTF-8 in Python
I have spent plenty of time as far as I am newbie in Python.
How could I ever decode such a URL:
...
2
votes
1answer
230 views
Python 2.7 on Windows, “assert main_name not in sys.modules, main_name” for all multiprocessing examples
There is following simple code:
from multiprocessing import Process, freeze_support
def foo():
print 'hello'
if __name__ == '__main__':
freeze_support()
p = Process(target=foo)
...
40
votes
1answer
34k views
How to write a Python module?
I've been making Python scripts for simple tasks at work and never really bothered packaging them for others to use. Now I have been assigned to make a Python wrapper for a REST API. I have absolutely ...
1
vote
2answers
2k views
Debugging python in Aptana 3
I have a pydev project going in aptana studio 3.
In the image below, you can see my project structure and the fact that my nosetests are all passing.
If I click on a file scheduled.py that has a ...
16
votes
3answers
15k views
Skip the headers when editing a csv file using Python
I am using below referred code to edit a csv using Python. Functions called in the code form upper part of the code.
Problem: I want the below referred code to start editing the csv from 2nd row, I ...
5
votes
3answers
634 views
python split a string with at least 2 whitespaces
I would like to split a string only where there are at least two or more whitespaces.
For example
str = '10DEUTSCH GGS Neue Heide 25-27 Wahn-Heide -1 -1'
print str.split()
...
7
votes
5answers
6k views
Is there an easy way to make unicode work in python?
I'm trying to deal with unicode in python 2.7.2. I know there is the .encode('utf-8') thing but 1/2 the time when I add it, I get errors, and 1/2 the time when I don't add it I get errors.
Is there ...