15,175 Topics
| |
| Hi, I am very new to programming but am hoping it will be able to speed a few things up for me. However I am struggling to work out how to write a Python3 script that does the following and am wondering if you could help me out. I have … |
I tried downloading the file and playing it using `winsound` to play it with the flag `SND_MEMORY`, but it only accepts `str` instead of the `bytes` object I got from `urllib.request.urlopen`. Using `decode()` needs a valid encoding, but I don't have one. CLARIFICATION:downloading the file I mean as using `urllib.request.urlopen` … | |
Hello , I am making tries to display images in different tkinter windows , in every window displaying a different image , for this i made this code : # -*- coding: cp1252 -*- from Tkinter import * import Tkinter as tk import ttk from PIL import ImageTk, Image import … | |
This short snippet shows you how to preprocess a text to remove punctuation marks, then do a word frequency count using Counter() from the Python module collections. Finally, two sorts are applied to display words with matching frequency in alphabetical order. | |
I am still new to programming and hoping someone can point me in the best direction. I am creating a script that monitors a directory and creates a zip file and then mails the archive. I have successfully monitored the dir and can zip the files. I am somewhat lost … | |
I started learning about Python 15 days ago and I'm a little bit confused whether it is a programming language or scripting language. I am thinking it is a programming language because it contains Exception, RE, Networking etc. However I thought scripting languages could not contain features like Networking,Exception etc. | |
The code shows you how to create a persistent to file dictionary of data using the python module shelve. | |
i have been looking around and its hard to find what i want. I am able to add context menu item to a FOLDER by doing this: [HKEY_CLASSES_ROOT\Directory\shell\Command] @="TestRightClick:" [HKEY_CLASSES_ROOT\Directory\shell\Command\Command] @="myExe.exe %1" I need to have "context menu for all the files in folders of a particular directory". context menu … | |
I am trying to add a custom widget dynamically, multiple times. However, the widgets just stack up in the same place. I have tried several combinations of Layout() and Fit() and setSizerAndFit() after adding custom widget to the sizer Thank you for any help #!/usr/bin/env python # -*- coding: US-ASCII … | |
num_trades = int(input("Number of trades for today?")) for i in range(1, num_trades + 1): action = input("Trade number", i ,"(buy/sell)?") num_shares = int(input("Number of shares to buy?")) price_per_share = float(input("Price per share?")) I'm getting a TypeError on the line "action = input("Trade number", i ,"(buy/sell)?")" Help Thanks | |
I have an integer dataframe and in my code I am doing some length calculation( which can be only perfomred on string), therefore I need to convert my dataframe to String. I have tried using str(), its not helping me, it would be helpful if you could suggest something. | |
I saw this code on stack overflow def writeProfile(profileName, profileData): """ pickle user profile data """ os.chdir(PROFILE_DIR) fileName = profileName + ".dat" f = open(fileName, "wb") pickle.dump(profileData, f) f.close() os.chdir("..") It is for saving progress under the pickle module. I don't see a way to save variables. How would I … | |
Which of these is the best practice for executable Linux scripts: #! usr/bin/env python #! usr/bin/python #! usr/bin/env python3 #! usr/bin/python3 All four of them work just fine on my system, so I'm looking for the best practice. Thanks. | |
This code: def reverse(x): for i in range(len(x)): y[i] = x[-(i+1)] return y a = [1, 2, 3, 4, 5] b = reverse(a) returns a "global variable 'y' not defined" error. WHAT GLOBAL VARIABLE????? If I add 'y = []' anywhere in the code, either inside the function or outside … | |
I had a function all by itself in the file [filename].py, and the file was properly executable. This is how people advised me to call it externally: import func func.[filename]() But I was getting errors all over the place. So I contacted Python help and they told me something different, … | |
Hi, I want to replace all the character in my string with 'aaaa' as many number of times as there are occurence of the character. For eg. if my string is "cat", output should be "aaa" and if its "hello" output should be "aaaaa". As of now, I am using … | |
Hi, I'm new to python so I'm asking a noob question. I'm given a large string from which I have to take all the digits and check if its prime or not. Then I have to take the first 25 chars of the string and append the prime digits to … | |
Hi, I have a list which contains strings in each value. I want the word count of each string and then I will have to find out the string with minimum word count and max. word count in that list. Help is much appreciated. | |
Okay, so cryptography is insanely well developed and I'm not doing anything new here, but I still thought I'd monkey around with a cryptography project. Here's what I want it to do: 1) generate an encryption and decryption key that is randomly between 20 and 40 digits long and contains … | |
Suppose you have this file named func.py: def func(x): y = raw_input(x) return y func(z) And then you have this calling code: z = raw_input('Type a request for input and hit enter: ') omega = execfile('func.py') print(omega) Why does the output always end up being "None?" | |
Here is exercise in error handling, while looping and for looping with itertools.chain. It is also exercise of functions not letting user to go without giving proper input. I call them to myself 'jail functions'. Here you could add as an exercise breaking out of loop and continuing until user … | |
Just to note, this thread may never be marked solved until my main project evolves. anyways... To put it simply, this language is a common-interface language meant for conversion between all languages. This means that this language has to support all features between all languages in the most simplest of … | |
class stdout(object): def __init__(self,realout,prefix): self.file = realout self.at_start_of_line = True self.prefix=prefix def write(self, text): if len(text): if self.at_start_of_line: text = self.prefix + text self.file.write(text) self.at_start_of_line = (text[-1] == '\n') sys.stdout=stdout(sys.stdout,"OUT ["+f+"]> ") File "C:\Users\James\Desktop\run.py", line 13, in write self.file.write(text) File "C:\Users\James\Desktop\run.py", line 10, in write if self.at_start_of_line: AttributeError: 'stdout' object … | |
Dear friends, I have a set of values as follows (filename is string; values are floating; notimportant... is self-explaining): filenameA, value1_1, value2_1, value3, value4, notimportant filenameA, value1_2, value2_2, value3, value4, notimportant filenameA, value1_3, value2_3, value3, value4, notimportant filenameA, value1_5, value2_5, value3, value4, notimportant filenameA, value1_7, value2_7, value3, value4, notimportant ... … | |
def GenContent(address,what): return urllib.urlopen("http://www.yelp.com/search?find_desc="+what+"&#find_loc="+address).read() I am using python to do this. It works prefectly in my browser. | |
I'm creating a shooting game and I don't want to allow unlimited bullets to be shot on the screen, so how can I limit the amount of bullets fired. heres the code # Sample Python/Pygame Programs # Simpson College Computer Science # http://programarcadegames.com/ # http://simpson.edu/computer-science/ import pygame, sys, random from … | |
I have a directory with hundreds of CSV files in it. Many of the files have synonyms for words that I no longer want. I want to replace all of the synonyms with approved words. For example some CSVs have synonyms like `vial` `jug` `canteen` `urn` etc and I want … | |
I made this program this morning, the problem is that when I go to run it it says: > Traceback (most recent call last): > File "C:/Python33/Test random number creator.py", line 4, in <module> > print (x)('x')(y) > TypeError: 'NoneType' object is not callable > ` Here is the program: … | |
More or less a templet database that allows you to load, save, add, list, search, edit and delete data items. I used movies as an example, but you can easily change that to make a database of many other things. | |
Duplicate occurance of the same value has to be removed. If the (linked)list traversed from head contains sequence 3,2,8,8,8,5,2,3 after calling last = Node(3) head = Node(2, last) head = Node(5, head) head = Node(8, head) head = Node(8, head) head = Node(8, head) head = Node(2, head) head = … |
The End.