Tagged Questions
0
votes
0answers
9 views
Blender3D - Installing along side python 2.7 win7 64bit
I'm interested in doing some work in Blender3D, but the latest release won't run and I believe it is because of my current python 2.7 install, which I use due to certain modules not supporting python ...
0
votes
0answers
20 views
Drawing star around the center of the screen
I have an homework as follows:
Write a program where you enter from the keyboard a number n. Then n
stars are drawn onto the screen, circling around the center of your
screen. You can assume ...
0
votes
1answer
19 views
How do I force close a port being used by an independent service?
For example, if I have my minecraft server running on port 25565, I want to have a python script close the port so that all connections will be dropped and no further connections will be made without ...
0
votes
0answers
21 views
Extracting only portion of HTML using lxml in python
I've just started learning the lxml library for parsing HTML. I know that there are ways to extract specific tags from HTML using xpath, however, I need to extract a specific portion of HTML from a ...
0
votes
1answer
37 views
How to iterate over x amount of lines in a .txt file
I'm trying to write a program to sort and tag lines in a file. For example, suppose I have a .txt file of a health clinic with a variety of information about a patient. I want to tag the information. ...
0
votes
1answer
41 views
How to tell which modules have been imported in some source code?
Is there a way to inspect source code (or compiled code object) and tell what modules are being imported in Python 3.3?
For instance, in:
import foo
def func():
from bar import *
return 42
...
-1
votes
0answers
27 views
function that returns past tense of given verb
Any python program support to find the past tense of the given verb. I think there is no ambiguous on this question but stack overflow not allowed to post a small explanation that's why I explain the ...
0
votes
2answers
46 views
Python 3.x: Lists and loops
I need help with my code when answering the following question.
An arithmetic progression is a sequence of numbers in which the distance (or difference) between any two successive numbers is the ...
0
votes
2answers
35 views
Floating point operation again
I just asked about why python gives value of 3.3 - 1.1 is 2.1999999999999997. I think because 3.3 or 1.1 represented in base 2, isn't it? At least my opinion was right ...
3
votes
1answer
48 views
Calculate the complexity of the function, hw in python
I need to calculate the running time complexity of the function in terms of n (for exmaple O(n)),
n is len(lst) , lst is a variable of list type.
this is what I thought, is it right? (I need to ...
1
vote
1answer
12 views
BeautifulSoup - Handing of cases where variable.find( ).string returns empty
from bs4 import BeautifulSoup
import codecs
import sys
import urllib.request
site_response= urllib.request.urlopen("http://site/")
html=site_response.read()
file = open ("cars.html","wb") #open file ...
4
votes
4answers
74 views
Fastest way to download thousand files using python?
I need to download a thousand csv files size: 20KB - 350KB. Here is my code so far:
Im using urllib.request.urlretrieve. And with it i download thousand files with size of all of them together: ...
1
vote
2answers
35 views
Unsupported operand type(s) for +: 'int' and 'str'
I am currently learning Python so I have no idea what is going on.
num1 =int(input("What is your first number? "))
num2 =int(input("What is your second number? "))
num3 =int(input("What is your ...
0
votes
2answers
18 views
Getting error “No attribute draw”
So I'm trying to use graphics to draw three separate dice and while I have finally gotten them to show up, I'm now getting this error
>>> Game()
Traceback (most recent call last):
File ...
1
vote
1answer
21 views
Point is not defined even though I imported graphics
So this is my class for a game called Zombie Dice.
I've imported graphics but I get this error and I have no idea why. Please explain some possibilities for me.
"File "<pyshell#0>", line 1, ...
2
votes
6answers
73 views
Python - list.remove(x) x not in list
I am trying to create a simple program in Python 3.3 that takes a list of four names, and randomly assigns them to another person in the list. For example, if the names were John, Aaron, Lydia, and ...
0
votes
2answers
33 views
Roll dice program - TypeError: list indices must be integers, not list
I'm writing a program that will roll any number of dice, with any number of sides, any number of times. I'm stuck in my function that rolls the dice a number of times and then replaces the zeros in ...
-1
votes
2answers
56 views
Urrlib request nothing happens python 3.3
hello i made a small script. It should input a password to the (password input) on the website.
but when i run the script it doesn't give an error but also nothing happens. Where is my fault ?
import ...
1
vote
0answers
47 views
Snake Python 3 explanation needed
I have started this and I am stuck on creating one function. I know how to do parts of what it is asking but I don't know how to create it together. I have made a function that takes a snake (a list ...
0
votes
1answer
21 views
Does pysvn work with Python 3.2 on Ubuntu 11.04?
I've got the pysvn module working great in Python 2.7.1, but it refuses to import in Python 3.2. It was installed with apt-get, so I figured it should work for both.
xxxxx:~$ python
Python 2.7.1+ ...
0
votes
4answers
47 views
counting 2*2 squares in n*n binary matrix
I've got an n*n binary matrix (only 1 and 0), how can I go about counting 2*2 squares (squares are made by 1)
for example A=[[1,1],[1,1]] is considered to make one 2*2 square. or
A = [[1, 1, 0, 1],
...
0
votes
1answer
39 views
Appending Items to a List from a File
So, I've been scouring this forum and I can't seem to find the answer. I've also tried several different methods to extract this information by tweaking my code, but to no avail :(
So, I am trying to ...
1
vote
1answer
23 views
Trouble with binascii.Error: Odd-length string
I am attempting to write an program that encrypts and decrypts text files using RSA. I seem to have run into an issue while using unhexlify from binascii.
out_format = '%%0%dx' % (chunk_size * 2,)
...
1
vote
1answer
35 views
Python subclass invoking method from parent class
I'm currently self-learning Python, and I came to the lesson about inheritance, so this is my first experience with subclasses. I'm learning from the book "Think Python", and the example is about ...
1
vote
0answers
17 views
Zelle's Simple Python Graphics Library RGB to Grayscale Conversion Project
So I have been tasked with a project to convert an image of my choosing from color to grayscale using only the graphics library provided in the link (http://mcsp.wartburg.edu/zelle/python/). I ...
3
votes
2answers
42 views
Numerical simulation giving different results in Python 3.2 vs 3.3
This might be a weird question, but here it goes:
I have a numerical simulation. It's not a particularly long program, but somewhat lengthy to explain what it's doing. I am running the simulation a ...
3
votes
1answer
45 views
Tkinter Draw Problems
I just finished writing a Tkinter based GUI of the board game Othello for a programming class. Everything seems to be working correctly, but something strange is still happening: any changes that ...
0
votes
4answers
26 views
Python: subprocess.Popen variable behavior
I want to read all files in a directory and pass them via command line to another program.
The following is a part of my code (for one file here) which does not seem to work, and I don't really ...
1
vote
5answers
30 views
Properly formatted multiplication table
How would I make a multiplication table that's organized into a neat table? My current code is:
n=int(input('Please enter a positive integer between 1 and 15: '))
for row in range(1,n+1):
for col ...
1
vote
1answer
29 views
Error Remains After Running 2to3.py on a Module
I used the 2to3.py script to convert several of my files to Python 3 a while back. I believe I need to run all fixers, so my command included
-f all -f buffer -f idioms -f set_literal -f ws_comma ...
0
votes
2answers
56 views
Dictionary changed size during iteration but I don't see where I've changed it
I'm new to Python, so bear with me, but I've tried to create a script that gets synonyms to a word if I don't already have it and add it to my dictionary in JSON format.
Here is my code:
import ...
0
votes
1answer
42 views
python how to quit screensaver
I have to quit from screensaver. I have an alarm clock (written in python-pygame) that after a minute, without input, goes in screensaver (blank). I have also a pir sensor that, when I pass my hand, ...
0
votes
2answers
94 views
Cant get code to print
import random
class rectangle:
def point(self):
self.x = 5
self.y = 10
self.width = 50
self.height = 100
return("rectangle"(self.x,self.y,self.width,self.height))
...
1
vote
1answer
25 views
How to get the size of typed memoryviews in cython
Is it possible to get the size of a MemoryView in cython? Ideally, I'm looking for something like arr.shape in numpy.
0
votes
1answer
33 views
ImportError: No module named tis_class
I've a Python3 script, normally works great.
But I've this module error message in line 5 :
pi@raspberrypi ~ $ python3 ScriptCompteur.py
Traceback (most recent call last):
File ...
0
votes
1answer
29 views
TypeError: 'int' object does not support item assignment, I don't understand where my error is
name=0
gender=0
gpa=0
k=1
num= float(input("how many student's would you like to process? "))
while k<num:
name[k]= (input("enter student's first and last name: "))
print (name[k])
...
0
votes
1answer
22 views
Tracking listbox widget information
I am trying to create a GUI using tkinter for selecting text files with the end result being the file name along with the path for use with another program. The text files may not be in the same ...
0
votes
0answers
31 views
Snake Movement Python3
I have started this and I am stuck on creating one function I know how to do parts of what it is asking but don't know how to create it together. I have make a function that takes a snake (a list of ...
0
votes
0answers
20 views
Bad file descriptor in Python
I have an asynchronous server implemented using socketserver.
This server takes a client request asynchronously and process the request. I am saving the socket so that I can message respective clients ...
2
votes
2answers
39 views
regex to delete whitespace in csv-file with quotes to separate text?
I'm new to programming and regex and read Mastering Regular Expression, but I can't find an answer to how to get rid of tabs, newlines and strange non-word or non-digit characters (icons and strange ...
1
vote
2answers
42 views
How to parse and print a tree in python
Currently I have data in the following format
A
A -> B -> C -> D -> Z
A -> B -> O
A -> X
this is stored in a list [line1,line2, and so forth]
Now I want to print this in the ...
-4
votes
2answers
62 views
I don't know what to do with the else in Python [on hold]
elif num < ord('a'):
num += 26
translated += chr(num)
else:
translated += symbol
return translated
mode = getMode()
message = getMessage()
key = getKey()
when ever I run this code as it is, ...
0
votes
1answer
25 views
How do I keep argparse from failing because it doesn't recognize the program name?
I'm getting an error trying to run a some python code. The error I get is that argparse doesn't recognize an argument: the program name.
migration.py: error: unrecognized arguments: migration.py
...
1
vote
1answer
31 views
Python 3.3 Pickle Errors for read/write
I'm trying to write a program that displays a menu and allows users to write to a file, read from a file, or exit. The file contains a list object, so I'm using a .dat file. I've read the python ...
1
vote
2answers
15 views
Multiplication Table For Python in IEP?
I Am using python 3.3 with IEP and i am trying to make a multiplication table that is nice an orderly. Everywhere i look online says it will be nice but it ends up just being 1 row and long where i ...
0
votes
2answers
49 views
invalid character in identifier python [on hold]
def getTranslatedMessage(mode, message, key):
if mode[0]=='d':
key=-key
translated=''
for symbol in message:
if symbol.isalpha():
num = ord(symbol)
i have changed it and now the error has changed ...
0
votes
0answers
21 views
NLTK ImportError: DLL load failed: %1 is not a valid Win32 application
import nltk
text = nltk.word_tokenize("And now for something completely different")
nltk.pos_tag(text)
print(text)
Using the above code, I get the following error, apparently when trying to use the ...
0
votes
2answers
37 views
TypeError: accept missing 2 required arguments (Still functional)
This is a curiosity question. I have a block of code that executes upon an accepted.connect().
It throws out this error but when I check the results they still work. And from what I understand from ...
1
vote
1answer
21 views
Self scope in PyQT5 app?
I am trying to get my first Python learning app completed, I used PyQT5 designer to make a basic UI and used the following to test things out and I get the NameError: global name 'self' is not defined ...
0
votes
0answers
22 views
Can I make key-binding add-on for a browser game? [migrated]
I was adviced to post here from Programmers SE.
So we got this Drakensang Online, a RPG browser game. I got 7 skill slots on the skill bar but the last skill slot is kinda far and uncomfortable for ...