0
votes
0answers
9 views

How do I install compiled script from setup.py in python 3?

Consider the following setup.py file (for the example the only other source file (false.c) is generated right here): #!/usr/bin/env python from setuptools import setup from distutils.ccompiler ...
0
votes
2answers
27 views

My IDLE script is returning a weird error

So I'm messing around with idle and wrote a silly program: name = "none" phone = "none" while phone == "none": phone = str(input("Please enter your phone number formatted as (111)111-111 ")) ...
1
vote
1answer
15 views

Testing file upload with Flask and Python 3

I'm using Flask with Python 3.3 and I know support is still experimental but I'm running into errors when trying to test file uploads. I'm using unittest.TestCase and based on Python 2.7 examples I've ...
1
vote
2answers
49 views

Python while and for loops - can I make the code more efficient?

I wrote the following code: initial_list = [item1, item2, item3, item4, ...] lists = [[list1], [list2], [list3], [list4], ..., [list(n-1)], [list(n)]] # The number of elements in the both lists might ...
0
votes
0answers
11 views

Python 3.3 is looking at Distribute from Python2.7

I had problem similar as in Assertion error from 'pip list' in virtualenv. (exactly the same error message, just not working in virtualenv), and after using this answer: pip install --upgrade ...
0
votes
3answers
26 views

Writing a list with nested tuples to a csv file

I have a list with nested tuples, like the one below: data = [('apple', 19.0, ['gala', '14', 'fuji', '5', 'dawn', '3', 'taylor', '3']), ('pear', 35.0, ['anjou', '29', 'william', '6', 'concorde', ...
0
votes
1answer
15 views

Import Python module fails (http.cookies)

From what I've learned from my research here and elsewhere, it seems that if a) a module is located in the Python search path or b) contained in a package that is in the Python search path, that the ...
0
votes
1answer
31 views

Sum item inside a tuple

I have a list of nested tuples in which the second element is na float: l = [('drink', ['vodka', '9.2', 'beer', '6.3', 'alcohol', '5.4', 'gin', '2.1', 'liquid']), ('evict', ['tenant', '66.0', ...
1
vote
1answer
32 views

Sorting a tuple by its float element

I am trying to sort this tuple by the value of the number, so that it be rearranged in descending order: l =[('orange', '3.2'), ('apple', '30.2'), ('pear', '4.5')] as in: l2 =[('apple', '30.2'), ...
4
votes
0answers
49 views

Finding which packages support Python 3.x vs 2.7.x

Are there any methods for automatically finding which Python versions are supported by packages on PIP? I am looking for something that generates a table like the one below obtained automatically ...
3
votes
2answers
37 views

Iterate over a list of nested tuples

I have a list of nested tuples that looks like: l = [('apple', ['gala','fuji', 'macintosh']), ('pear', ['seckel','anjou','bosc'])] And I like to sort the second item of the tuple alphabetically, so ...
0
votes
1answer
13 views

Trouble installing django-imagekit - 'execfile' is not defined

I am having problems installing django-imagekit under python 3.2/django 1.5. Is django-imagekit only for python 2 (then why is it available in pip-3.2)? Trying to install django-imagekit from within ...
0
votes
1answer
16 views

Having problems understanding a code about maketrans

def shift_string(text, shift): intab='abcdefghijklmnopqrstuvwxyz' outab=intab[shift:]+intab[:shift] return str.maketrans(intab, outab) shift_string("hello",5) When i run this, a blank ...
1
vote
2answers
27 views

what does the term 'bound' means in class method

When we instantiate a class, the methods get 'bound' to that particular instance for every instance created. What does the word 'bound' means here. I don't think a duplicate copy of the method object ...
3
votes
1answer
36 views

What type of declaration is `def m_test(x: my_var) -> list:`

I saw a type of method declaration in a question, then I searched hundred times! but I could find any useful information, here is declaration: my_var = "556" def my_meth(x: my_var) -> list: ...
1
vote
2answers
43 views

Avoiding to print out a certain word in a list (Python)

So I'm just starting to learn python. I am doing this exercise which asks the following: "Implement a program that requests a list of words from the user and then prints each word in the list that is ...
0
votes
1answer
29 views

Python - x not in list error

I have a list inside a list and I am trying to remove any values in side the nested list that are equal to -1. I am getting a "ValueError: list.remove(x): x not in list" error when I try to run my ...
0
votes
3answers
43 views

Python unique values in a list

I am new to Python and I am finding set() to be a bit confusing. Can someone offer some help with finding and creating a new list of unique numbers( another words eliminate duplicates)? import ...
0
votes
1answer
27 views

Python wait and check if file is created completely by external program

I currently have external program outputting in the file in directory 'DIR'. Now if I want to see from python if the file is created completely, how can I check that and if done execute program. My ...
1
vote
1answer
33 views

Python Sierpinski Triangle Using Class Point

I have to draw a Sierpinski Triangle using a class point, but when I try to run the program I made it won't let me draw the triangle. We have to have an input function for the length of the three ...
0
votes
0answers
14 views

EnableDHCP() returns 81 :Unable to configure DHCP service

i tried to change my ip automatically (via DHCP) described in this post: enter link description here with this bit of code: import wmi # Obtain network adaptors configurations nic_configs = ...
-4
votes
1answer
57 views

Python: can't assign to function call

I'm getting the SyntaxError above on the line stated below. With this code I want totals to be a list of 6 which tallies up how many times each number on a 6 sided dice appears after 5 random rolls ...
0
votes
1answer
42 views

How to turn a python program to a .exe [duplicate]

I have been working a lot on python recently, mostly using IDE. Now I have a need to make a .exe program out of my code. Have tried cx_freeze but i couldn't understand what to do. So, if anyone could ...
36
votes
5answers
597 views

list comprehension filtering - “the set() trap”

A reasonably common operation is to filter one list based on another list. People quickly find that this: [x for x in list_1 if x in list_2] is slow for large inputs - it's O(n*m). Yuck. How do ...
1
vote
2answers
36 views

Parsing a parenthesis

I'm trying to make a calculator in Python 3 (just to learn). I want to be able to evaluate (just as an example) "5 * ( 2 + 1 )^2" from an input(). I would like to be able to detect if parenthesis are ...
0
votes
1answer
56 views

Python - Move elements in nested list

def main(): list1 =[1,2,3,4,5] list2 =[0,0,0,0,0] list3 =[6,7,8,9,10] list=[list1,list2,list3] for i in list: print(i) main() I have this nested list. I want the program ...
0
votes
0answers
44 views

Python StringVar - get function returning nothing?

I'm making a GUI app using the tkinter module in Python (mainly just to improve my Python skills, we're using it in GCSE Computer Science), however I've hit an annoying issue that I cannot figure out. ...
1
vote
2answers
52 views

Merging repeated items in a list into a python dictionary

I have a list that looks like the one bellow, with the same item of a pair repeated some times. l = (['aaron distilled ', 'alcohol', '5'], ['aaron distilled ', 'gin', '2'], ['aaron distilled ', ...
-3
votes
2answers
53 views

Function I just made giving me an 'is not defined' error

I'm trying to make a function to count how many times a number appears in a list of 5 random numbers and then produce that in a new list. It seems to be fine up till the end when I want to test it ...
0
votes
1answer
16 views

Attribute Error Using Biopython Bio.SearchIO.convert

I am writing a script in Python using Biopython modules that will convert Blast XML output to Tabular form. I get an attribute error as follows: Traceback (most recent call last): File ...
0
votes
1answer
46 views

How to fetch data from Skyscanner?

I am new to Python and there has been a request for grabbing the dynamic data from www.skyscanner.net. Can someone guide me on doing so? import requests import lxml.html as lh url = ...
1
vote
1answer
38 views

Unique value in nested list - random

I have a largely working program, it creates nested lists of size set by user and repeats based on user input. However I want the individual sets to only contain unique values currently this is my ...
0
votes
1answer
44 views

Python Dictionary Methods behaving diff for 2.7.6 and 3.3 version

I was using python dictionary built-in methods and found they behave a bit differently in terms of giving the output on 2.7 and 3.3 version of Python. Here is an example: Let my dictionary be the ...
1
vote
2answers
33 views

merge lists in runtime according to user inputs

I have 4 lists like list1 = [] list2 = [] list3 = [] list4 = [] then i need get user input and merge two lists at run time and print them .. I have tried like this first = input('enter 1st ...
1
vote
7answers
67 views

Does the list have any numbers?

I have a list: my_list = [12,8,0,4,7,21,27,"O",29,3,"X","O","X","X"] This list gets updated throughout the program. Every time it gets updated, I want to check to see if it contains only numbers ...
1
vote
0answers
30 views

How to test a program requiring multiple user inputs [on hold]

I have a simple terminal program (written in python 3) that I'm writing a test suite for using unittest. The program just prompts the user for a username, then a password, then prompts again for the ...
0
votes
1answer
56 views

Initialize a variable c with ’b’

I have an assignment about which I am pretty confused. Write a program which: (1.) intializes a variable a with 123, and prints the value of a over 7 places (2.) intializes a variable b with ...
0
votes
3answers
45 views

2d list in python - accessing through column names

I'm parsing two files which has data as shown below File1: UID A B C D ------ ---------- ---------- ---------- ---------- 456 536 1 ...
1
vote
2answers
51 views

Python can't define tuples in a function

For some reason in python everytime I try to define tuples in a function I get a syntax error. For example I have a function that adds vectors to the program, it looks like this: def ...
0
votes
2answers
60 views

Python: for loop - print on the same line

I have a question about printing on the same line using for loop in Python 3. I searched for the answer but I couldn't find any relevant. So, I have something like this: def function(variable): ...
-3
votes
0answers
39 views

Python import Class methods from inherited Class [on hold]

I have a probleme trying to import a class function from inherited class. each class is in a different file. File 1 name: ClassA class A: def test(self): print("test") File 2 name: ClassB ...
2
votes
1answer
35 views

Python 3: Functions dependent on other functions, missing parameter?

I have two functions, the latter of which is dependent on the results of the first. They are both mathematical functions using floats. The gist of the two functions are: def function1(a,aa,b,bb): ...
0
votes
1answer
26 views

TypeError: list indices must be integers, not str error with using .format

I am making a quick menu for fun however for the first option, as shown below in the code. It gives me some indices error TypeError: list indices must be integers, not str However, some code that I ...
0
votes
3answers
34 views

Django custom form ImportError even though file is in the same directory

I'm working through Effective Django's tutorial series. I'm currently having an issue trying to create a custom form to use in an app. I created the forms.py file as instructed in this part of the ...
0
votes
1answer
58 views

a floating point precision of X

This is not a code revision, therefore I have created the thread here. I have an assignment which is as follows: Write a program which: 1. intializes a variable a with 123, and prints the value ...
1
vote
1answer
55 views

Can't terminate thread with Ctrl-c

I've created a setInterval like function in python but cntrl-c can't terminate it Heres the code import threading def setInterval(sec,func,*args,**kw): def wrapper(): ...
6
votes
3answers
81 views

Inconsistent comprehension syntax?

I just stumbled over what seems to be a flaw in the python syntax-- or else I'm missing something. See this: [x for x in range(30) if x % 2 == 0] But this is a syntax error: [x for x in range(30) ...
2
votes
1answer
46 views

Can someone explain this dictionary behaviour?

>>> data = "0:1:2" >>> h2 = data[0] >>> a = {0: "... ", 1: "..- ", 2: ".-."} >>> print (0 in a) True >>> print (h2) 0 >>> print (h2 in a) False ...
0
votes
0answers
11 views

Python: Charmap Codec Unicode Encode Error [duplicate]

When i run the following code, import urllib.request, urllib.parse, urllib.error from bs4 import BeautifulSoup url= "http://couponmaths.com" htmltext = urllib.request.urlopen(url).read() soup = ...
0
votes
2answers
71 views

Is there a fast iterator over random numbers in python?

I'm using a lot of random numbers in a python script of mine. Traditionally I simply called random.random() where I needed them, but now that makes up a significant fraction of the execution time. So ...

15 30 50 per page