Python is a dynamic and strongly typed programming language that is designed to emphasize usability. Two similar but incompatible versions of Python are in widespread use (2 and 3). Please consider mentioning the version and implementation that you are using when asking a question about Python.

learn more… | top users | synonyms (3) | python jobs

0
votes
0answers
8 views

Print a list of tuples as table

I have a list o tuples: list = [(element1, element2, element3), (elementelel4, element5, elementelement6), (el7, el8, elel9)] I want to print it as a table (so the distance between elements should ...
0
votes
0answers
7 views

error installing exe python module

I am trying to install the file pokereval-138.win32-py2.7.exe from http://sourceforge.net/projects/fpdb/files/fpdb/pypoker-eval-win32/ but I get an error saying "The file exists. Could not create a ...
0
votes
0answers
4 views

How do I set the domain for a Twisted Session cookie

I have a Twisted web application using Twisted's HTTP sessions. How can I specify the domain of the session's cookie? For example: my application is running on sub.example.com, but I want to set the ...
0
votes
0answers
9 views

How to auto compile python/c extension?

I wrote a python/c extension file lda_model.c and I added setup.py: from setuptools import setup, Extension modules = [Extension('c_lda_model', sources=["lda_model.c"])] setup(ext_modules=modules) ...
-2
votes
2answers
31 views

Python: how to solve a string: “2 + 2”

so my question is: given a random string like this "5 + 5" how can I return a result in Python? I can't just do int("5+5"). For example: op1 = raw_input("Enter first number(e.g. 2):") op2 = ...
0
votes
0answers
5 views

Non exclusive or operator to generate new parsing expressions for a Parsing Expression Grammar (PEG)

I am writing a PEG containing the following three parsing expressions: int => ^[-+]?[1-9]\d* frac => ^[-+]?[.][0]?[1-9]\d* exp => ^[E][1-9]\d* (exp stands for the "E ...
-1
votes
2answers
20 views

Python immutable function parameter [duplicate]

I'm trying to understand the core ideas of Python and I've come across to a nice article that explains passing the parameter reference to an object. For instance; def add_to_list(list_to_add, value): ...
0
votes
0answers
4 views

How can i link *.ui widget to the derived class?

I am using pyqthraph in order to make a data monitoring program. First, I opened qt desiner and added a few pyqtgraph.PlotWidgets. Then I saved it as a ui file and called the file like: ...
0
votes
1answer
32 views

How to make python code simpler

i have following python code. Can i optimise it to one line: url = request.session.get('my_value', '/') if url == '/None/': url = '/' Any help will be appericiated
0
votes
0answers
9 views

TkInter ScrollBar does not work with ListBox

Here is my code for a ListBox and ScrollBar. The ScrollBar is showing at the right side of my frame but is disabled and not working when the items is ListBox exceeds its area: frameLeft = ...
0
votes
0answers
40 views

How to get whole source code of a huge web page?

I'm trying to get source code and work with that but problem is that this page is probably so big. I get only approx. one half of it. I use PyCharm IDE. This is my code: def getSoup(url): req ...
0
votes
2answers
15 views

Executing function after python test suite finished execution

I'm using python unittest frame work for do some testing. class AbstractTest(unittest.TestCase): def setUp(self): def tearDown(self): # Close! self.transport.close() def ...
0
votes
0answers
7 views

how to get the sample data out of “Tektronix Waveform Data” file(wfm) in python

I want to get the waveform data out of an waveform file generated by a Tektronix osciloscope. Any ideas or suggestions for a python egg/modul? Merci
-1
votes
0answers
10 views

VPython - Traffic Flow Model - Nagel and Schreckenberg [on hold]

I have problem with Nagel and Schreckenberg traffic flow model. Theory I want to create simulation - Traffic Jam On Circular Road https://playingwithmodels.wordpress.com/2010/05/12/traffic-jam/ ...
0
votes
0answers
9 views

Handling string with delimiters in argparse

I need to pass string with delimiter as argument to python script. So, I used parser.add_argument('--filter', default=None, nargs='*', action="append") The input to the script can be any of the ...
0
votes
0answers
5 views

Way to aggregate generated test result with nosetest and multiprocessing

I’m using nose to run my tests. Most of my test use yield, eg: @attr(id='666') def test_even(self): """test even""" for i in range(20): yield eq_, i%2 , 0, 'failed for %d' %i out of ...
0
votes
1answer
10 views

Machine learning for finding even/odd number getting incorrect/correct output for two different classifiers

I tried a Machine Learning algorithm on a hypothetical problem :- I made a fake feature vector and a fake result data set by the following python code :- x=[] y=[] for i in range(0,100000): ...
0
votes
0answers
18 views

Display Two Forms in one Template in Django

My aim is to use Two models in One template. I have tried various ways around this and have had no success. Originally I had 2 views, 2 models and Two forms. After searching I found people using ...
0
votes
0answers
6 views

Implementing previous and next buttons using tkinter

I am developing a desktop app and one of the key requirements is that when i search for a person with a unique identifier i will get multiple records/rows but now i can only view only one. I want to ...
-1
votes
0answers
23 views

For looping with new variables

I have a simple question using python looping: briefly I need to create 3 new variables called enseble+'x' where x is the some value taken from 1 to 3. This new variable must correspond to some ...
0
votes
2answers
11 views

Python BeautifulSoup get data that's in a tag (HTML content)

<meta itemprop="price" content="4.05"/> Here's my HTML that I need to extract "4.05" from. I'm using Beautiful Soup, with python. Any help would be great, I've searched around but haven't ...
0
votes
0answers
6 views

Open .h5 file using pandas

I am working with large data sets. For example: data.shape = (3000, 3000, 75), where "75" is the number of elements in my time axis. I open such data sets for a single point in time using h5py: ...
0
votes
1answer
17 views

Regex pattern to extract substring

mystring = "q1)whatq2)whenq3)where" want something like ["q1)what", "q2)when", "q3)where"] My approach is to find the q\d+\) pattern then move till I find this pattern again and stop. But I'm not ...
0
votes
0answers
8 views

Using Selenium to navigate to a url after sign-up causes a “whoops” html page to appear

I am trying to build tests for my website using selenium, my site is built on django and therefor has test cases built in. I am using djangos LiveServerTestCase as their docs suggest for Selenium. ...
0
votes
0answers
4 views

How to get the values from pyjnius (kivy) autoclass() objects on android?

I'm following the tutorial here: http://bytedebugger.wordpress.com/2014/07/17/python-for-android-tutorial-1-using-the-accelerometer/ and now I'm trying to replace the accelerometer display with the ...
0
votes
0answers
13 views

matplotlib savefig doesnt work as show() for figure with inset

I am using matplotlib to plot a main figure with two insets. All is fine and show() also works as it should. However when I try to use savefig command (rather than saving in show() window), all become ...
1
vote
2answers
24 views

Python is reusing variables from one instance of an object for a new one [duplicate]

Can anybody explain this behaviour? class A(object): def __init__(self, x={}): self.x = x var1 = A() print '#1', var1.x var1.x['key'] = 'value' print '#2', var1.x var2 = A() print '#3', ...
0
votes
0answers
11 views

PySide Column not hiding

I am building with PySide and to give myself better modularity and adding in concurrency I have moved a table into it's own class as so: Table.py class Table(QtGui.QTableWidget): def ...
2
votes
0answers
5 views

Python comtypes Photoshop 64-bits

I have been using the comtypes module for Python to automate Photoshop CS5, but I am getting a TypeError when I try to execute commands on Photoshop 64-bit. These same commands have been working fine ...
0
votes
0answers
2 views

software pwm using I2C with raspberry in python

i'm looking for a solution using a mcp23017 gpio-expander with raspberry pi as led-dimmer, but every 4-5sec there is a short flickering. i carried out that flickering is also there if i use gpio ...
0
votes
0answers
18 views

Python on Mac: How should I manage same modules in different directories?

I am having problems figuring out what is the best practice for handling duplicate modules with different version in different directories. What I have done and figured out so far is the following. I ...
-2
votes
0answers
27 views

Planning on building a big web service. What kind of developers do I need? [on hold]

I'm a designer. I'm looking for web/mobile developers to help me build a similar platform like Airbnb or Yelp, but I don't know a lot about backend or on what technologies these two sites are built ...
2
votes
3answers
17 views

Host multiple websites on same python app

I want to start make a django app, but i want to know if it's possible to use same "core" to host multiple sites.each site will just have a unique conf file (templates to use, db name, meta info, ...
0
votes
2answers
22 views

Using Python to remove duplicated contents in cells in Excel

I am trying to use Python to remove the duplicated contents in the cells of an Excel Spreadsheet. Here are the data formated a CSV here for convenience. The data is in 1 column, in the original file. ...
-2
votes
2answers
21 views

Bit by bit comparison of using Java or Python for unit testing frameworks and Selenium

Currently we are in the process of finalizing which language out of Java, Python should be used for Automation using selenium webdriver and a suitable unit testing frameworks. I have made use of ...
0
votes
2answers
22 views

The number of tries never increments by more than one in Python - help please?

Whenever it takes me several tries to beat the game, it always says the number_of_guesses is 1, which isn't true. What have I done wrong? My code: import random print("Welcome to Rock, Paper, ...
1
vote
0answers
12 views

Kerberos ticket in python without using subprocess

Currently, I have the following code and it does the trick. def negociateKRBticket(): kinit = '/usr/bin/kinit' kinit_args = [kinit, '-kt', KEYTAB_PATH , USER_NAME] kinit = ...
0
votes
1answer
16 views

No POST-Data from Ajax in Django

I want to post a array of data in AJAX to a Django-Site. Code from Javascript: var arr = {}; arr["first"] = "first"; arr["second"] = "second"; arr["third"] = "third"; var success = "" var ...
-3
votes
0answers
15 views

Implement real time bayesian analysis in ElasticSearch

I want to implement a naive Bayes filtering for my incoming log messages (that come form Logstash) already parsed. The idea is that the user can say if a given log message is important or not and ...
0
votes
2answers
13 views

Django - How can you include annotated results in a serialized QuerySet?

How can you include annotated results in a serialized QuerySet? data = serializer.serialize(Books.objects.filter(publisher__id=id).annotate(num_books=Count('related_books')), use_natural_keys=True) ...
-6
votes
1answer
40 views

Looking for optimised python code [on hold]

I have a simple if check using python, can i make it more generic or optimised. if url == '/None/': url = '/'
0
votes
0answers
5 views

sqlalchemy-migrate DatabaseNotControlledError exception

I would like to add a new column in my existing database, initially created by sqlalchemy. I tried using the sqlalchemy-migrate tool to do this and running into the following error: ...
-3
votes
0answers
29 views

Takes 3 Arguments But 1 is Given [on hold]

Using Tkinter to create stegnograpghy app using stepic the User will choose a PNG image from directory, enter message in text area and click encode button to perform the ...
-1
votes
0answers
27 views

Search 1 dictionary against another using regex

Here's the code snippet: import re import fileinput temp_list_OG=[] temp_list_ACE=[] object_group_dict={} ace_dict = {} with open('C:/Cisco/Code/ASA.txt','r') as infile: for line in infile: ...
1
vote
2answers
16 views

Python GIL: concurrent C++ embed

Can python embedded into c++ allow you to run n python scripts concurrently? I am currently dealing with the dread which is the GIL. My project requires concurrency of at least 2 threads and the easy ...
0
votes
1answer
40 views

Django - None vs. Null

I am setting a ForeignKey to on_delete=models.SET_NULL, null=True But i am confused, I just want that If FK gets deleted, all other relations should stay in db. is the result of ...
-1
votes
0answers
27 views

How to i can sum several different value types like binary?? (python)

I'm trying to sum several different types of tags, but not how. I have variables of type char, int, byte, and I intend to convert binary to add them later and get a number (preferably int). The ...
0
votes
1answer
23 views

Error importing modules in Python

I've just installed Python 2.7.8 (as default version) following these steps. I was using Python 2.7.6 before this. I have been importing modules such as pyglet, gasp and pygame normally. Now, I can't ...
0
votes
1answer
18 views

Combining/merging 2 different Excel files/sheets

I am trying to combine 2 different Excel files. The one I work out so far is: import os import pandas as pd df = pd.DataFrame() for f in ['c:\\file1.xls', 'c:\\ file2.xls']: data = ...
0
votes
3answers
31 views

PYTHON-Merge single elements in list with sublist

I try to make flat list. Now I have list: L=['aa',['bb','cc']] and I try: L=['aa',['bb','cc']] new=[] for i in L: print i new+=i print new and I got: 'aa' ['bb','cc'] ...