0
votes
1answer
13 views

Why do I get the error: “NameError: global name 'pupiluserinputbox' is not defined”

def pupiluserpass(): global usernames, passwords usernameinp = pupiluserinputbox.get() passwordinp = pupilpasswordinputbox.get() Why do I get the error: NameError: global name ...
2
votes
3answers
54 views

Python Lists Issues

So I'm new to coding in general but I'm learning Python. So I've put this together but its not comparing the uInput to the 'con' list. What am I doing wrong here? #countries.py con = [('uk', 'united ...
-2
votes
2answers
33 views

Problems in Python 3 with the while loop fuction [on hold]

I am using the while: suit expression. why is this expression always wrong with an error: invalid syntax x=1 while (x<=100):{x*=2,print(x)}
-1
votes
1answer
41 views

How to specify in a code that it must be a number, because if I enter a word in an integer input the program crashes [duplicate]

Tell me the code that would support this, because if I enter a word into an integer input the program crashes. I know this would be a simple one line code, but I just can't get my head around it. ...
1
vote
1answer
19 views

Passing values from bash to python

I am trying to implement bash with python can anybody help me or teach me on what should be done.Thanks my code is import io val=os.system("echo 'sdfsfs'") #for example print(val)
0
votes
1answer
22 views

Find the occurrences of unique element in list in python

For finding occurrences of unique element in a list in python i used import collections a='77888' b=list(collections.Counter(a).items()) but the b is sorted in order of occurences ...
0
votes
1answer
15 views

splitting two letters to create a word python 3

I am trying to write a code that will ultimately decode words in a file that are in this format: first letter, last letter rest of word Then the code will take those words and cross check them ...
0
votes
1answer
33 views

how to write a string to csv?

help please write data horizontally in csv-file. the following code writes this: import csv with open('some.csv', 'w', newline='') as f: writer = csv.writer(f) writer.writerows('jgjh') ...
0
votes
1answer
35 views

Python getch() - Multiple charachter

I am aware that python getch() is suitable for detecting single keystrokes. Is there any method, that I can use the same function for detecting multiple keystrokes.s, Also, is it possible that the ...
0
votes
2answers
27 views

Python User Input File Name

I'm trying to write a program that takes a users input for a file name, and then either opens the file to add to it, or prints what is already in the file, so far this is what I have: (I keep getting ...
4
votes
2answers
66 views

Square brackets next to an object - What's the notation called?

What's the name for the square brackets syntax in this snippet? And - just to clarify - is it accessing the default field inside 'label' and changing that? I seem to think it is called 'binding' - ...
1
vote
2answers
23 views

How to add multiple valuables with one key in python dict?

I have list of names and i'm trying to add them under key called 'name'. list_of_names = ['john', 'lisa', 'david', 'frans'] key = ['name'] with: namelist = [dict(zip(key, i)) for i in ...
0
votes
3answers
46 views

Python referenced local variable before assignment

I am working on a currency converter for my computing GCSE at school and I have no idea what I am doing wrong here. My code is: PD = 1.66401 # declare pounds to dollars exchange rate def ...
1
vote
2answers
58 views

dicts are not orderable in python 3?

Why are dicts orderable in python2, but not in python3? I can't find it anywhere in the documentation. Python 3.3.4 (default, Feb 11 2014, 16:14:21) >>> sorted([{'a':'a'},{'b':'b'}]) ...
0
votes
0answers
15 views

cant list directories using ftputil

So, I'm trying to list the content of the current directory on the ftp server and then list the directory after the file upload, but it's not working like i expected: #!/usr/bin/env python # -*- ...
0
votes
3answers
32 views

Python way to join subsets of an element into a string?

I have this code...it works, but is there a better way to do it? So if the participant list is [ { 'Id': 5, 'name':'bob'}, {'Id': 4, 'name': 'sally'} ], result should be '5, 4'. participant_list = ...
1
vote
0answers
23 views

requests: TypeError: 'tuple' object is not callable in python 3.1.2

I'm making a web page scraper using BeautifulSoup4 and requests libraries. I had some trouble with BeautifulSoup working but got some help and was able to get that fixed. Now I've run into a new ...
0
votes
0answers
19 views

python 2.5 or later is required

I have Python 2.7.6 installed in my system. I was trying to install PyML but I got this error message ValueError: [u' path'] then I found a solution here, Errors while building/installing C module for ...
-1
votes
3answers
59 views

eliminate unwanted data from list using python

I have a list like this.how can i eliminate \xe2\x80\x99,\xe2\x80\x9c etc from my list using python. is there anyway to eliminate these kind of data from my list?? common pattern is avilable? ...
0
votes
3answers
24 views

Updating OrderedDict getting None

Here is my list , z=[OrderedDict([('name', 'abc'), ('lastname', 'lastname.'), ('address', 'Mumbai'), ('cell', '21******')]), OrderedDict([('name', 'abc'), ('lastname', 'lastname.'), ('address', ...
0
votes
1answer
17 views

ValueError: invalid literal for int() with base 10: '--cgi' when using python3 -m http.server --cgi 8000

When i run python3 -m http.server --cgi 8000 It says: Traceback (most recent call last): File "/usr/lib/python3.2/runpy.py", line 160, in _run_module_as_main "__main__", fname, loader, ...
0
votes
3answers
16 views

Python Tabulate

How can I merge multiple tables in python using tabulate package? append is not working when concatenating the two tables in python.The tables are implemented using tabulate package in python. ...
0
votes
2answers
38 views

When typing can you change what the text is displayed as? [duplicate]

So i am making a program to test a password and was wondering, When the user enters their password can you stop their password from showing as they type it in to the console/GUI?
1
vote
2answers
31 views

how to check the utf-8 equivalent value of a character in python?

I want to know how to find the utf-8 equivalent of a tamil character. Is there any function for it? Can you give the syntax. for line in f: words = line.strip().split() for word1, word2 in ...
0
votes
2answers
34 views

Python3 sums.py

So I've been at this all night. Very new to programming and my objective was to use squareEach(nums) which is a list of numbers that I'd modify by squaring each entry. Next, sumList(nums) is a list of ...
1
vote
0answers
27 views

Tornado - Python global variable

I'm trying to use Tornado with SqlAlchemy, I need to pass the current user from RequestHandler (tornado) to models (SqlAlchemy) in the insert or update action. But I don't want to pass the value ...
3
votes
1answer
40 views

Evaluating Infix Expressions Using Stacks in Python: I cant find my error

after looking at this code for 2 days i decided to get some help. this is my fist time asking a question so please bear with me. my coding experience is minimal and my knowledge goes about as far as ...
0
votes
1answer
20 views

How to filter a list of floats based on their elements?

I'm fairly new to programming. Basically in a list of floats, I want my program to print every one that starts with either '1' or '-1'. This is what I have so far. def oneminus(L): for i in ...
2
votes
4answers
53 views

How to print a string in a list and its index on the same line?

This probably has a very simple solution, but I'm just a beginner. What I have is: def content(L): for i in range(len(L)): print (i), (L[i]) Right now it only prints the index and ...
0
votes
2answers
26 views

Repeating an algorithm as many times as the user requires (PYTHON 3.3.2 GUI)

I'm trying to repeat this algorithm and use the values in my code, please help!!! import random def dice_roll(number): if number == 12: number = random.randint(1,12) ...
2
votes
4answers
54 views

How do I return the earliest letter in the alphabet from a choice of letters?

I am doing an exercise the requires me to return the most frequent letter in a string of letters. In the event that there are two letters that appear with the same frequency, the 'tiebreaker' is ...
-5
votes
0answers
27 views

write a program in python that will convert a base 10 integer into a different base [on hold]

write a program in python that will convert a base 10 integer into a different base (base 2 = binary, base 8 = octal, or base 16 = hexadecimal). Prompt the user for an unsigned integer (i.e. not ...
0
votes
1answer
13 views

Check Python 3 source with Pylint running with Python 2

Some checks of Pylint are depending on whether the checked source code is of kind Python 2 or Python 3. E.g., see How to avoid Pylint warnings for constructor of inherited class in Python 3?. In my ...
1
vote
7answers
50 views

Concise way to split a string into a list of fixed number of tokens

I am writing a piece of code that needs to split a hyphen delimited string into at most three tokens. If there are less than three tokens after splitting, it should append sufficient number of empty ...
0
votes
0answers
37 views

Capturing input using tkinter in Python 3.2

Our inventory system generates 10 digit item numbers based on a pattern. I have written a program that will do the following: Take a 10 digit item number with an incorrect digit and return a list ...
0
votes
1answer
32 views

merge values of same key in a list of dictionaries , and compare to another list of dictionaries in python3

Update: Apparently, I noticed that in my main code, when I extract the values from the list of dictionaries that I get from readExpenses.py, I store it as a set, not as a list of dictionaries. Now, ...
-1
votes
2answers
54 views

How Do I change a sum for string for it to work? [on hold]

import time import random def welcome(): ready="no" while ready=="no": print("Welcome To Encounter Simulator Inc. Where We Provide You with combat..") print("Readying Start Up Sequence....") ...
0
votes
1answer
23 views

python3-module object is not callable

crawl.py. I try to port it to python3. I leave out all unnecessary details. Error: Traceback (most recent call last): File "crawl.py", line 44, in parseAndGetLinks self.parser = ...
1
vote
1answer
47 views

Creating a dictionary with comprehensions?

I am trying to create a dictionary of directory's which pass a certain condition. It's important that each directory is set as a value, and that each key is numbered starting from 1. I have written ...
1
vote
1answer
20 views

“unit tests have failed” for beautifulsoup

i am trying to install beautifulsoup for python33 but its not installing properly it gives error like that: C:\Python33>pip install beautifulsoup Downloading/unpacking beautifulsoup Downloading ...
0
votes
0answers
52 views

Why doesn't my program exit? [on hold]

I have this code but cant get the sys.exit() to work. Any ideas what is wrong: def main(): while True: name = input ('Please Type your Question: ').lower().split() name2 = ...
0
votes
1answer
12 views

Using a variable on sqlalchemy query filter

its possible to use variables on filters? My actual code: import sqlalchemy from sqlalchemy import Table, MetaData, Column, Integer, String from sqlalchemy.orm import sessionmaker from ...
0
votes
1answer
13 views

Python 3 - Saving a google spreadsheet as a csv

I am trying to save a private google spreadsheet into a csv. I have found another thread which has addressed this (Download a spreadsheet from Google Docs using Python), however the answers date back ...
0
votes
2answers
69 views

reading and checking the consecutive words in a file

I want to read the words in a file, and say for example, check if the word is "1",if word is 1, I have to check if the next word is "two". After that i have to do some other task. Can u help me to ...
0
votes
3answers
34 views

Python named keyword by variable

I'm new to python and I'm trying to figure out if I can pass named keywords by string without calling them explicitly. Here an example: def test(height, weight): print("h=" + str(height)) ...
4
votes
2answers
35 views

What magic does staticmethod() do, so that the static method is always called without the instance parameter?

I am trying to understand how static methods work internally. I know how to use @staticmethod decorator but I will be avoiding its use in this post in order to dive deeper into how static methods work ...
3
votes
1answer
47 views

How to run a script from GEANY (win 7)?

please help me sort this out. I have run the following script from IDLE (win7): import requests import lxml.html def get_doc(url): try: req = requests.get(url) except ...
0
votes
1answer
33 views

Assistance with regex python

I need help with a regex pattern that allows me to do the below but I'm not quite sure how to. command, extra = re.search(SomeRegexPattern, string).groups() # or split it to be a list Input: ...
3
votes
2answers
60 views

Are compound if statements faster, or multiple if statements?

Say we have two pieces of code: if foo == True and bar == False and baz == True: do something and if foo == True: if bar == False: if baz == True: do something Which ...
0
votes
1answer
18 views

pytee can not produce proper output in python3

I have a piece of code which runs well in Python 2.7.5 but doesn't work with Python 3. The major problem is tee.write, which can not write to the file. This piece of code suppose to write 20 ...

15 30 50 per page