Interesting Tags
   11 tags on

0 answers

multiple usage of generator from list in python

Basically, I'm in following situation - I generate a list, e.g. l = [2*x for x in range(10)] which I iterate through later on multipletimes, e.g. for i in l: print i # 0,2,4,6,8,10,12,14,16,18 ...

0 answers

Multi-processing a shell script within python

My Requirement is to run a shell function or script in parallel with multi-processing. Currently I get it done with the below script that doesn't use multi-processing. Also when I start 10 jobs in ...

1 answer

if statement not catching None

I'm writing a syntax controller for empirical formulas. It seems to be working fairly well, BUT there is one error that I can not seem to fix. Here is the code: import string from linkedQFile import ...

1 answers | 2 mins ago by user3128156 on Stack Overflow
0 answers

django saving form field in generic or functional view

Lets say I have a form and its files are user, value, age I am using generic or functional view... so how can I do like def SomeView(request): mod = MyModel() mod.user = request.user ...

0 answers

Python array is not functioning

I've written a program using Python 2.7, Numpy and OpenCV to grab a photo from my webcam and give the rgb value of every pixel. After running the code on a 640x480 pixel photo: for x in range(638): ...

2 answers

Regex to match the first occurrence of a string between quotes, but exclude certain words?

I have a regular expression that catches all characters within quotes in a text file, but I'd like to: match only the first occurrence of this pattern exclude certain words from this pattern match ...

2 answers | 5 mins ago by dharkko on Stack Overflow
1 answer

Wrong scatter label color in pyplot legend

I am making this bar plot: ... using this code segment: my_cmap = plt.get_cmap('copper') plt.figure() plt.set_cmap(my_cmap) plt.pcolormesh(xx, yy, Z) labels = ['Negative', 'Negative (doubtful)', ...

1 answer

Django - Global name 'PayLaneRestClient' is not defined

I am having a issue while importing a class and trying to use it from Django's I have the following error : global name 'PayLaneRestClient' is not defined. from django.shortcuts import ...

1 answers | 6 mins ago by micael on Stack Overflow
0 answers

comtypes: in call_with_inout, ctypes TypeError: 'c_double' object is not iterable

Im working with Agilent IVI drivers in Python 2.7.9 and can't seem to get 'proven' code to work on a particular Windows 7 machine. It executes successfully on other machines. While this issue seems ...

1 answer

Python parsed data displayed twice

I'm making a program that looks up Japanese words on a dictionary site and takes the definition from there. The problem I've been having is, sometimes a word will repeat the definition of the last ...

1 answers | 7 mins ago by Dominic4774 on Stack Overflow
1 answer

What is the use of buffering in python's built-in open() function?

Python Documentation : open(name[, mode[, buffering]]) The above documentation says "The optional buffering argument specifies the file’s ...

1 answers | 8 mins ago by SRI VVISHNU on Stack Overflow
2 answers

python overlapping values from serial

I have my arduino connected to the pi via usb and it is sending readings from a DHT sensor using the simple program below (this bit works as expected in the arduino serial monitor): int chk = ...

0 answers

Read binary chunks with VLC using Pyhton

I would like to ask if it's possible to read binary flow with VLC. I managed to do it by writing the data into a file and then reading it with vlc, but can I do it without using a file as a buffer to ...

2 answers

How does Python importing exactly work?

I have two specific situation where I don't understand how importing works in Python: 1st specific situation: When I import a same module in two different scripts, the module isn't imported twice, ...

2 answers | 9 mins ago by jco on Stack Overflow
0 answers

pygame.midi - no sound on Mac Yosemite

I am using a Mac with Yosemite and python 2.7 with pygame 1.9.1. I enabled my IAC driver in the Audio Midi setup. When I run the from pygame examples, the little virtual keyboard comes up - ...

1 answer

Does this basic class properly exemplify how to make a class in Python 3?

I am trying to understand initialization and class and OOP in Python 3, and I am curious if this is properly showing how to do so? Your kindness is appreciated. CODE: class bank: def ...

1 answers | 14 mins ago by Colby Cox on Stack Overflow
2 answers

Python: ContextManager-like for function alias

ContextManager is really useful and it's also make our code more readable, but it seems it only works if the given function is meant to be a context manager, otherwise it will fail (no __exit__ or ...

1 answer

How to save weights of a neural network

I am facing problem in saving weights of a trained neural network in a text file. Here is my code def nNetwork(trainingData,filename): lamda = 1 input_layer = 1200 output_layer = ...

1 answer

Recursive unittest discover

I have a package with a directory "tests" in which I'm storing my unit tests. My package looks like: . ├── LICENSE ├── models │   └── ├── ├── requirements.txt ├── ├── ...

2 answers

How to iterate through sentence of string in Python?

Assume I have a string text = "A compiler translates code from a source language". I want to do two things: I need to iterate through each word and stem using the NLTK library. The function for ...

2 answers

How to get an extra column in relational model in Django-rest-framework serializer?

I have Category and Article model,Article has a foreign key reference Category,in my serializer i can get the name column in Category model because of the __str__ method,but how can i get other ...

1 answer

Efficient algorithm or python's built-in function to remove sublist from very large list

I want to remove sublist(20000-80000 elements) from the list containg approx 100000 network addresses as elements in it. I am creating my program in python. There is 2 method I know: filtering ...

4 answers

How to simplify a class without writing methods that are already simple?

I have a complex class and I want to simplify it by implementing a facade class (assume I have no control on complex class). My problem is that complex class has many methods and I will just simplify ...

4 answers | 29 mins ago by reader_1000 on Stack Overflow
1 answer

use Python requests or robobrowser to scrape data from aspx form

I want to scrape data from an .aspx page at My problem is how to formulate the search parameters correctly to be used in a ...

1 answer

Signing In and Scraping Webpages with Scrapy

Hoping some one is able to help me with this. I am using Scrapy to login and scrape data. This particular code works for one website. But I have another website that Scrapy cannot log on to because of ...

5 answers

Call Javascript function from Python

I am working on a web-scraping project. One of the website, I am working has the data coming from Javascript. There was a suggestion in one of my earlier question, that I can directly call the ...

1 answer

Python Tkinter: Bind function with labels in for loop

I'm creating labels dynamically in a for loop using tkinter. I don't know how many labels will be created, but on clicking of each of the labels, a particular function must be called with a particular ...

0 answers

Django check if checkbox is selected

I'm currently working on a fairly simple django project and could use some help. Its just a simple database query front end. Currently I am stuck on refining the search using checkboxes, radio ...

1 answer

Python standard output shows hidden characters in emacs

I wrote a python function that generates a list of words. First, it reads a file that consists of words separated by new lines. Depending on the word, it either inserts it into the list or inserts a ...

1 answers | 42 mins ago by gallardoelise on Stack Overflow
1 answer

Why is Spark asking for a main method when I submit a python file?

I have a file with the following content: from __future__ import print_function import os import pyspark.sql import pyspark.sql.types from pyspark import SparkContext from pyspark.sql ...

15 30 50 per page
1 2 3