15,181 Topics

Member Avatar for
Member Avatar for Rebecca_2

Hi, I have a quick, and what seems like very stupid question. I have a list of files in a directory with various extensions. I want to open only the ones with the extension '.txt'. I have got as far as finding them (and can print their filenames to a …

Member Avatar for vegaseat
0
226
Member Avatar for thecreator232

hi guys !!! i want to make an web browser in python , as my college project . what i'm looking for is guidance , on how to make it and which module's shall i use . currently i'm planning to use webkit and gtk+ to obtain my goal. secondly …

Member Avatar for slate
0
462
Member Avatar for amrX

Hi. if I want to use the for loop to make multiplication table for the number 3 in sequence. For ex; when I excute the for loop, I want the user to enter intger "3" and then it start to question 3x3, to the user and up if they did …

0
51
Member Avatar for Varunkrishna

Hi everyone I am learning python, I came across a sample program which checks whether the given number is prime number or is not a prime number using **for loop** and **range()** function. I can't understand that program, can someone please help me understand it? Here is the program and …

Member Avatar for lucpet
0
936
Member Avatar for vegaseat

Using the PySide GUI toolkit will make selecting, copying and pasting encrypted and decrypted text somewhat easier. Not ideal yet, but it will be a good start for those of you who are not very familiar with GUI programming.

Member Avatar for Lardmeister
2
526
Member Avatar for Jacklittle01

I am trying to make a save feature in a game so that a player could save, then quit the game, then open the window again to select proflie and play from when they left off. Thanks!!

Member Avatar for james.lu.75491856
0
417
Member Avatar for Rebecca_2

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 …

Member Avatar for Gribouillis
0
330
Member Avatar for james.lu.75491856

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` …

Member Avatar for snippsat
0
1K
Member Avatar for Ismatus3

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 …

Member Avatar for Ismatus3
0
5K
Member Avatar for vegaseat

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.

2
666
Member Avatar for crag0

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 …

Member Avatar for Gribouillis
0
362
Member Avatar for estetik23

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.

Member Avatar for <M/>
-3
214
Member Avatar for vegaseat

The code shows you how to create a persistent to file dictionary of data using the python module shelve.

Member Avatar for Gribouillis
4
883
Member Avatar for mohan.jce

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 …

Member Avatar for mohan.jce
0
235
Member Avatar for Fcasualty

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 …

Member Avatar for Fcasualty
0
301
Member Avatar for zswinford

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

Member Avatar for sepp2k
0
14K
Member Avatar for Taruna_1

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.

Member Avatar for Taruna_1
0
3K
Member Avatar for Jacklittle01

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 …

Member Avatar for Gribouillis
0
245
Member Avatar for farmwife

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.

Member Avatar for james.lu.75491856
0
241
Member Avatar for farmwife

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 …

Member Avatar for james.lu.75491856
-1
176
Member Avatar for farmwife

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, …

Member Avatar for farmwife
0
176
Member Avatar for Taruna_1

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 …

Member Avatar for vegaseat
0
320
Member Avatar for np complete

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 …

Member Avatar for Gribouillis
0
233
Member Avatar for Taruna_1

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.

Member Avatar for Taruna_1
0
781
Member Avatar for farmwife

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 …

0
101
Member Avatar for farmwife

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?"

Member Avatar for farmwife
0
1K
Member Avatar for TrustyTony

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 …

Member Avatar for farmwife
0
1K
Member Avatar for Tcll

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 …

Member Avatar for Tcll
0
303
Member Avatar for james.lu.75491856

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 …

Member Avatar for james.lu.75491856
0
163
Member Avatar for giancan

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 ... …

Member Avatar for Gribouillis
0
227

The End.