Tagged Questions
0
votes
3answers
23 views
My game wont go to my function
Well here's the problem my game() function wont go to my firstlevel() function and just keeps says process exited with exit code 0 And I have no clue why I even tried changing the function name And ...
0
votes
0answers
9 views
Create Permutations and Add Results Together (Pandas, Python 3)
I currently have a df that looks like this:
Word Score Other
This 10 1
is 10 2
an 20 5
example 50 3
great 20 2
What I am then doing ...
0
votes
0answers
12 views
Display fullscreen jpeg on X Server (of Raspberry Pi) using Python 3
I am developing a software in Python that generates static jpeg files, which are written to the file system. The software ist running at startup and gets triggered by some external and internal ...
1
vote
2answers
28 views
Mixing *vargs and **kargs arguments in function call
def func(*v, **k): pass
func(**{'a': 1}, *(1, 2, 3)) # ERROR...
func(a=1, *(1, 2, 3)) # OK...
I don't get why this first doesn't work, instead the second does.
Someone could just ...
0
votes
2answers
27 views
Pack 4 byte integers into bytearray or array
I can't seem to find out how to do this, so it may not be that simple after all. I looked this post, this one, and many others, but I can't get the type of answer I'm looking for. Most of the posts I ...
-2
votes
1answer
23 views
using “\” character in python strings
I want to print 'This\' in Python IDLE output. I try with the below strings but I couldn't do it :
1:
>>> "This\"
SyntaxError: EOL while scanning string literal
2:
>>> "This\ "
...
1
vote
1answer
13 views
Pyusb can't find a device while libusb can
I have an ACR38 smartcard reader connected to my computer and I can see its Vendor ID and Product ID using libusb-Win32 inf wizard :
But I can't communicate with it in Python 3.4.1 via pyusb-1.0.0a2 ...
0
votes
0answers
31 views
Conditionals decoration of functions in Python
For debugging purpose I want to write a function to do this:
If debug_mode == 0 doesn't echo any message.
If debug_mode == 1 echoes the message to the stdout with print()
If debug_mode == 2 echoes ...
-2
votes
2answers
44 views
Python noob, need help improving program
I am new to python coding, i need a program that will show current CPU temperature. My CPU have 4 cores, so i made following program.
#!/usr/bin/python
import subprocess
import re
sensor_data = ...
0
votes
1answer
9 views
Tkinter askopendialog runtime error after dialog confirmation
Consider the following code snippet:
from tkinter import *
import tkinter.filedialog as fd
def mycallback(event):
fname = fd.askopenfilename()
print(fname)
root = Tk()
b1 = Button(root, ...
1
vote
0answers
10 views
networkx - change color/width according to edge attributes - inconsistent result
I managed to produce the graph correctly, but with some more testing noted inconsistent result for the following two different line of codes:
nx.draw_circular(h,edge_color=[h.edge[i][j]['color'] for ...
3
votes
2answers
30 views
Centering window python tkinter
Ive recently started using tkinter in python, and I was having trouble centering the window. I tried all the tips on this website, but whenever I try them, the window is like a line in the middle of ...
1
vote
2answers
25 views
Unexpected results for Project Euler #17 (Python 3 vs Python 2.7)
So I was working through Project Euler #17, trying to find the answer, not really aiming for efficiency. However, after reading over every single number (I think) printed, I can't find what is leading ...
0
votes
1answer
34 views
Linker error: C/C++ Extensions for python
As my title kind of says, I'm trying to develop a C extension for Python. I followed this tutorial here and I ran the setup.py script. How ever when I run the python interpreter and try to import my ...
1
vote
1answer
31 views
Installing Bigfloat for Python
I am trying to install Bigfloat for python 3.4 on a Windows 8 machine. I have seen many of the other questions asking about how to install this, but nothing seems to work.
Pip and easy_install give ...
1
vote
2answers
38 views
Inheriting a python class while adding a property
I'm running into a problem trying to inherit a python class while adding a property. To illustrate, define the following classes:
class A:
def __init__(self, prop, x1, x2):
self.prop = ...
2
votes
2answers
41 views
How to select a specific columns in a text file by the specific column names and extract their contents in Python
I am a beginner in Python and I am finding it very difficult to come up with the correct solution for this problem. I glanced through all the similar posts in stackoverflow and couldn't find the ...
0
votes
1answer
19 views
python 3 Value adding elements from a list and printing the total
I have hit rough spot in trying to figure out a problem that I am having with my code.
I would like the output to result in:
Enter the high integer for the range 100
Enter the low integer for the ...
1
vote
1answer
51 views
Pythonic way of multiplying contents of list by one another in Python3
I note this question has already been asked here, but this mostly deals with python2:
Python: multiply all items in a list together
With the demise of reduce in python3 (see What is the problem with ...
2
votes
1answer
55 views
Can I make the decimal module handle all calculations in Python?
I would like the decimal module to handle all my calculations, so that I always get exact, correct decimal answers whenever I calculate something. Is there a way to get Python to assume that all ...
0
votes
3answers
48 views
How can I remove the last two characters from my file?
I'm taking out all of the coordinates from a kml file. This works, but my issue is that at the end of my file I end up with "}, }" instead of a "}}". I realize I can just manually edit the end of the ...
0
votes
0answers
42 views
What is the difference between this two way to import a module? [duplicate]
What is the difference between these two below ways to import a module? Why one of them failed while another one not!
>>> import sys
>>> sys.path.append('d:/pyusb-1.0.0a2/usb')
...
1
vote
1answer
48 views
Why I can't import this module
Everything is obvious as the below image and the codes followed it :
I want to import a module that phycially there is in the D:\pyusb-1.0.0a2\usb, but I receive errors!
Python 3.4.1 ...
-3
votes
1answer
29 views
Python record level comparision 2 large delimited files
I have 2 large delimited files.
Help needed in :
a) I need to get the row count based on the key column for both the files
b) finding the duplicates based on key column in both the files
c) Get ...
1
vote
1answer
15 views
Beautiful Soup not Scraping all the visible website Data (Python 3)
My issue is that I'm trying to scrape a bunch of different websites to find all visible text to download to a .txt file -- unfortunately I'm not getting all the possible text I can from these ...
1
vote
2answers
25 views
Scrape websites and export only the visible text to a text document Python 3 (Beautiful Soup)
Problem: I am trying to scrape multiple websites using beautifulsoup for only the visible text and then export all of the data to a single text file.
This file will be used as a corpus for finding ...
0
votes
1answer
26 views
Interacting with website forms
I'm trying to connect to a school url and automate the process with selenium. Originally I tried using splinter, but ran into similar problems. I can't seem to be able to interact with the username ...
0
votes
3answers
51 views
Having trouble understanding recursion
I was doing the first recursion exercise on this here: http://cscircles.cemc.uwaterloo.ca/16-recursion/
I followed the obvious hint and made this:
def countup(n):
if n == 0:
print('Blastoff!')
...
1
vote
1answer
42 views
Can anyone see why my python regex search is only outputtings “0”s?
I'm working on a python program to extract all the tags within a kml file.
import re
KML = open('NYC_Tri-State_Area.kml','r')
NYC_Coords = open('NYC_Coords.txt', 'w')
coords = ...
1
vote
1answer
25 views
Import a module or add a path one time forever in python
I want to work with smartcard readers. So I must import some modules such as core from pycard library.
Q1: How I can do it automatically! Now each time I open PythonGUI I must import it again and ...
1
vote
2answers
17 views
Python .extend splitting Characters unnecessarily
colourImgArray = []
sizeList = soup.find('table', {'class' :'table-sku'})
for sizeTD in sizeList.findAll('td', {'class' :'name'}):
for ...
0
votes
0answers
19 views
Pi camera preview with GUI - Raspberry Pi
i am new in the 'Python world' and i am (trying to) make a photobooth for my kids.
i bought a picamera and wrote a python script for it.
the python script it's simple (like the examples of the ...
-3
votes
0answers
29 views
trouble with importing file in python [on hold]
I am writing one program that is using some functions in another program that i wrote.
I have written command for importing like this:
import stack_(array)
But I always get this error message:
...
0
votes
1answer
20 views
(unicode error) 'unicodeescape' codec can't decode bytes in position 16-17: truncated \uXXXX escape
I want to import one module of pyusb library that is in the d:\pyusb-1.0.0a2\usb. So first of all I must add its path to sys.path. But I receive the below error.
Note : I successfully can import ...
0
votes
1answer
28 views
How can I make a “FOR”(loop) in html, using chameleon and pyramid in python 3.4?
How can a make a loop using chameleon and pyramid in my html?
I search but i found nothing like that =/
Is easier use javascript in this case?
I use datatable in MACADMIN(bootstrap theme).
<div ...
2
votes
1answer
30 views
Python ElementTree unescapes HTML entities
I wrote a simple script that parses XML into a comma-delimited format. A sample
of the XML source looks like this:
<?xml version="1.0" encoding="utf-8"?>
<users>
<row Id="-1" ...
0
votes
2answers
41 views
Would I be missing anything or running into walls if I want to develop Django/Flask web apps in Windows? [on hold]
I know that there are some issues with rails development under Windows and all the people are suggesting to switch to OS X/Ubuntu.
I run a company and I need to stick with Windows (7). I cannot ...
1
vote
1answer
37 views
Extract text of certain font face from a docx file
I am using python 3.4 along with python-docx library to work on .docx files. I have been able to extract text from the document. But my objective is to extract only those text with certain font (and ...
0
votes
1answer
6 views
Porting new.module() to Python3
How would I implement this in Python3:
def import_code(code, name, add_to_sys_modules=False):
module = new.module(name)
sys.modules[name] = module
do_bookkeeping(module)
exec(code in ...
0
votes
2answers
43 views
Optimizing a nested for loop with two lists
I have a program that searches through two separate lists, lets call them list1 and list2.
I only want to print the instances where list1 and list2 have matching items. The thing is, not all items in ...
0
votes
2answers
59 views
Is nesting generators in Python better?
Ok, so I have tried reading a couple of sources: One, Two, Three. The first source clearly points that using generator expressions conserves memory, and makes things faster. But what happens when they ...
2
votes
1answer
33 views
Get last value of an OrderedDict in Python3
Here is way to get the last key of an OrderedDict in Python3.
I need to get last value of an OrderedDict in Python3 without conversions to list.
Python 3.4.0 (default, Apr 11 2014, 13:05:11)
...
0
votes
1answer
20 views
Get stdout in case of success and stdout+stderr in case of failure
try:
output = subprocess.check_output(command, shell=True)
except subprocess.CalledProcessError as exc:
logger.error('There was an error while ...: \n%s',
exc.output)
...
-3
votes
1answer
39 views
Need code to get specific text from url
I am trying to figure out what i need to add to this code so after the url source is read I can eliminate everything but text that is in between tags and then have have it print results
import ...
0
votes
0answers
18 views
AttributeError: 'RPS' object has no attribute 'checkMe'
I'm following a series of online Python exercises. One of the assignments is to write a Python program for a Rock, Paper, Scissors game. While the exercises haven't gotten to objects or classes yet, I ...
1
vote
1answer
37 views
Why can't I get the database lastrowid?
I want to record form data and pass it to the another page, so I was just going to pass it the (autoincrementing) row id and then retrieve it in the next function. It is properly creating the database ...
-1
votes
0answers
18 views
python http.client handle cookie
I'm trying to connect to a website but for that I need to catch a cookie that the server send me to send him back. Here is my code. I really don't know how to make it. I know that http.cookiejar and ...
0
votes
2answers
50 views
How do I pass the contents of an list into an existing file?
exchangerates = []
newrate = float(input("Enter amount:"))
with open("ExchangeRates.txt","r") as readfile:
for line in readfile:
exchangerates.append(line.strip().split(","))
for ...
0
votes
1answer
31 views
Python Tuple within a Tuple
I have a python question.
I generated this list
14:00,18.7,383.5,266405,5480,212500,183750,52380,6804,57150,17431,65567
14:01,18.7,383.5,226430,6600,210850,206700,51870,11868,69850,18486,59222
Now ...
0
votes
0answers
21 views
Paramiko screen output
Im using this:
import paramiko
client = paramiko.SSHClient()
client.load_system_host_keys()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy)
client.connect("example.com", port=22, ...