0
votes
1answer
14 views

Add lots of data to Google App Engine NDB (Python)

I'm working on a project that requires me to import lots of data (on the scale of tens of thousands of entities) into the Google App Engine NDB. The data is stored in a text file, for which I wrote a ...
0
votes
1answer
21 views

Python OS.WALK Remove Directories

I'm trying to remove directories from os.walk (I don't need the files from those dirs) My code: def findit(root, exclude_files=[], exclude_dirs=[]): exclude_files = (fnmatch.translate(i) for i ...
0
votes
1answer
31 views

What is happening when I use the @func_name.setter annotation and it does not change a variable?

I don't think my title adequately explains what I'm talking about. Take this code for example: >>> class D: ... x = None ... @property ... def hello(self): ... return ...
2
votes
0answers
34 views

Alter default parameters of a function in a decorator in Python

I have a decorator to alter string arguments passed to functions: def decorator(fn): def wrapper(*args): replacements = list() for arg in args: new_item = arg + "!!!" ...
2
votes
1answer
12 views

Python: How to make integers from a stream of character data?

In my project, I have a special processor which is sending out 12 bytes and on my PC I have a python script which is reading those 12 bytes into a list. I'm pasting one such packet I have received ...
0
votes
2answers
18 views

Checking input values to methods to reduce the number of computations

I have a number of methods that are independent of each other but are needed collectively to compute an output. Thus, when a variable in any of the methods changes all the methods are called in the ...
1
vote
0answers
20 views

Error when tryting to use matplotlib

I'm just trying to plot a basic line chart with matplotlib of python. But I'm getting continuous errors and fixing one by one but stuck this time. I'm using Python 2.7 and below is the code I'm trying ...
0
votes
2answers
27 views

Return Value from Dropdown with Python

I have a drop down with the below code. The form is filled out when I load the webpage. I'd like to return the value that is already selected and assign it to a Python variable. I am getting the ...
0
votes
1answer
37 views

Python 2.7 Local Variables are acting like global variables

I have 2 functions contained in 2 separate files. The functions are similar and use the same names for local variables within them. The argument, 'eachtickerlist', that is passed into each function ...
0
votes
2answers
22 views

Searching and replacing cent symbol in Python

OS: CentOS 6.5 Python version: 2.7.5 I have a file with the following sample of information. I would like to search and replace the cent symbol and replace with $0. infront. Alpha $1.00 Beta ¢55 ...
0
votes
0answers
13 views

UndeclaredNamespace error with feedparser

Hello I am getting the following error when using Feedparser: raise UndeclaredNamespace, "'%s' is not associated with a namespace" % givenprefix feedparser.UndeclaredNamespace: 'media' is not ...
1
vote
1answer
28 views

Scraping HTML info with Python

I'd like to find the product ID (ProductID1111111) given the product name (Product 1) using Python. My thoughts would be to use the find function to return the character position of Product1 then back ...
0
votes
2answers
21 views

python moving multiple files from one folder to the other based on text characters in file name

I'm quite new to Python. I've been exploring the shutil module and can move things in general. My question revolves around: Imagine a scenario in which you have hundreds of files in an export ...
0
votes
0answers
34 views

percentiles from counts of values

I want to calculate percentiles from an ensemble of multiple large vectors in Python. Instead of trying to concatenate the vectors and then putting the resulting huge vector through numpy.percentile ...
0
votes
1answer
25 views

Rabbitmq - consuming and publishing on same channel?

I have two python processes connected to Rabbitmq via pika. Each consumes a set of topics which the other publishes as a response. One uses the SelectConnection and the other uses the ...
4
votes
2answers
44 views

sorting list of objects in Python [duplicate]

In Python, I am parsing an xml file into dictionary, using this module. The core of my code is very simple: configdict = ConvertXmlToDict('tasks.xml') for task in ...
0
votes
1answer
5 views

Openshift Write and Share via URL

So basically, I'd like to write to a file on Openshift via Python and then have a user able to access the written file via a URL without it being included in the git repository. So, in essence, let's ...
2
votes
3answers
27 views

Shadow a global variable with a modified copy

Please note: this is not a question about how to change a global variable inside a function body. I understand the global keyword. My script has a bunch of global configuration variables. I want ...
2
votes
2answers
26 views

ffmpeg Python Subprocess Error returned non-zero exit status 1

So I have a line here that is meant to dump frames from a movie via python and ffmpeg. subprocess.check_output([ffmpeg, "-i", self.moviefile, "-ss 00:01:00.000 -t 00:00:05 -vf scale=" + ...
0
votes
0answers
11 views

How to achieve @abstractstaticmethod and @abstractclassmethod in Python 2.7? [duplicate]

How to achieve @abstractstaticmethod and @abstractclassmethod in Python 2.7? class Thing(object): __metaclass__ = abc.ABCMeta # works @abstractmethod def instanceMethod(self): pass # ...
0
votes
1answer
21 views

Python: Building a dependency graph from items in a List

I would like to b build a data dependency graph between items in a list (assembly instruction). Here is what i'm looking for: I have to extract the operands from 3 consecutive assembly instructions ...
-2
votes
1answer
30 views

how to print lines using regur expression in python?

I want to print only the paricular strings from all lines in the file using re.search. i want to print only from is to script For example file.txt contains: python is a nice script language dogs ...
-2
votes
2answers
54 views

what does backward-slash b do in Python?

what is the purpose of backward-slash b in python, I ran print "\"foo\bar" in the python interpreter and got this result: >>>print "\"foo\bar" "foar
0
votes
0answers
9 views

pymouse not running with opencv in python

Its a simple code that i was testing When i use cv2.imshow and subsequently waitkey() of opencv the pymouse module stops working and doesnt change mouse's co-ordinates but when i comment out the ...
1
vote
1answer
27 views

Circular import confusion

I have three files: 1) one.py from two import test print(test) 2) two.py test = [1, 2] import three print(test) 3) three.py from two import test test.append(3) When I run the command ...
0
votes
0answers
13 views

google spreadsheet api worksheet_id issue

I have working code to edit a spreadsheet using python gdata library. I have used it on some spreadsheets whose gid=0 and it is working perfectly because worksheet_id of sheet 1 is 'od6' but it is not ...
4
votes
2answers
55 views

Make a Python class throw an error when creating a new property

Let's say this is my class: class A: def __init__(self): self.good_attr = None self.really_good_attr = None self.another_good_attr = None Then a caller can set the ...
0
votes
1answer
38 views

Is there a faster way to search a numpy array

I have a numpy array of roughly 3125000 entries the data is structured using the following dtype dt = np.dtype([('startPoint', '<u8' ), ('endPoint', '<u8')]) The data is from a file that has ...
1
vote
1answer
18 views

os.walk doesn't work correctly with unicode characters in path

I want to walk through directory where subdirectories can contain non-ascii characters in names. In this case os.walk considers the subdirectory as a file. The examples below: I have directory test ...
-2
votes
0answers
23 views

Python two side range [duplicate]

Is there a Python native function which returns the following values: value=1. # center size=5 perc=10% result: [.9, .95, 1, 1.05, 1.1]
0
votes
2answers
24 views

write csv file with double quotes for particular column not working

I'm trying to write a csv file using python csv writer. In which one of the column value is enclosed in "" [double quotes] e.g. : 'col1' 'col2' "test", when I open the file in wordpad, the word test ...
1
vote
1answer
18 views

runtimewarning while using lagrange interpolation in numpy

I am trying to implement lagrange interpolation on a time series. My input is in below format which contains two columns datetime and stock value '3/8/2012 16:00:00 32.21' '3/9/2012 16:00:00 32.16' ...
1
vote
3answers
31 views

How can I implement pattern event to call classmethod in Python?

I want to call some function depend on event code how can I do it in Python? I made such code but it not works and I am user that only one step to make it working. class Thing(object): ...
0
votes
2answers
46 views

Understanding Python interpreter -t (-tt) option

I'm trying to figure out what the options -t and -tt do. From the doc: Issue a warning when a source file mixes tabs and spaces for indentation in a way that makes it depend on the worth of a tab ...
0
votes
1answer
16 views

printing filename in askopenfilename

As the codes shown,i wanted to print the file name. It printed this line <open file u'C:/Users/121794/Desktop/New folder (2)/Tonight.mp3', mode 'r' at 0x01D63C80> def callback(): ...
4
votes
1answer
37 views

Python __getitem__ behaviour across different versions

class A(object): def __getitem__(self, item): print item a = A() a[0:-1] Output on python 2.7.3, 2.7.7, 2.7.8, 3.3.2 on Windows: slice(0, -1, None) Output on python 2.7.6 (32 bit) ...
0
votes
2answers
43 views

Python - return all self.* variables modified by method

Is there some way to return all the self variables that have been modified by a method in python? For example, I have a method that modifies twenty self variables and want to return self.variable1, ...
2
votes
2answers
47 views

Producing an array from an ellipse

I have an equation that creates an ellipse in the general form x^2/a^2 + y^2/b^2 = 1. I wish to produce an array whereby all points inside the ellipse are set to one and all points outside are a zero. ...
0
votes
2answers
29 views

Is 'encoding is an invalid keyword' error inevitable in python 2.x?

Ansi to UTF-8 using python causing error I tried the answer there to convert ansi to utf-8. import io with io.open(file_path_ansi, encoding='latin-1', errors='ignore') as source: with ...
-3
votes
1answer
71 views

Why is this not correct? (codeeval challenge)PYTHON

This is what I have to do https://www.codeeval.com/open_challenges/140/ I've been on this challenge for three days, please help. It it is 85-90 partially solved. But not 100% solved... why? This is ...
0
votes
1answer
18 views

How to construct dynamical class with custom metaclass in python?

As I read in documentation I can create class dynamically but how to replace this class metaclass? Should I just replace type metaclass with SomeMetaClass? The question is very simple but simple ...
0
votes
1answer
48 views

Python Os.walk Filter Filenames (What extensions not to include and skip dirs)

filetypes = ("*.jpg","*.txt","*.csv") filelist = [] for root, dirnames, filenames in os.walk("c:\\"): for ft in filetypes: for f in fnmatch.filter(filenames, ft): ...
0
votes
1answer
30 views

Given a list of items each associated with a color, how can I depict such a coloring?

So I'm working with a function in NetworkX that partitions a graph's vertices into blocks which receive colors (in (0, 1) ) which are then used to color the nodes of the graph(which correspond to ...
0
votes
2answers
34 views

Requesting First available resource in simpy python

I want to create a simulation model that simulates a bank with 3 number of counters. I want there to be one queue for customers, and if any one of the counters is available, it will service the ...
0
votes
1answer
21 views

How does one take a listbox selection and depending on that selection a second list box is created?

So I am still learning tkinter. I have three list boxes and the first one has a certain number of options. When the user selects an option, the second list box needs to fill depending on previous ...
0
votes
2answers
57 views

How do I properly format this string in Python?

I am parsing through a folder of txt files. These text files have a Dell computer service tag on the second line. I'd like to grab the second line and eventually place it in a csv spreadsheet. When ...
3
votes
0answers
30 views

IPython behavior different for .py and .ipy files despite script being “pure” python (custom exception handler hook stops working)

I have written an exception handler that is meant to log all uncaught exceptions in the code before calling the normal python exception hooks. Python and iPython have slightly different ways of doing ...
0
votes
2answers
34 views

python help usage issues

I am not sure exactly how to make use of python help. eg. I need to know about the QLineEdit.EchoMode(), I need to know how to use this function, input and output. I typed : ...
1
vote
4answers
39 views

In python, how can I print lines that do NOT contain a certain string, rather than print lines which DO contain a certain string:

I am trying to condense a very large log file, and to do so, I must eliminate every line which contains the string "StatusRequest" and "StatusResponse", while printing the other lines w/o this string. ...
-1
votes
2answers
31 views

Why does this function return NoneType?

def create(Type): if type(Type) == int: return 1 if tyoe(Type) == str: return "String" print create(int) print create(str) #both of these print 'None' As I am not that ...