15,190 Topics
![]() | |
Hey everybody. I was reading some code on the website and I saw this: [CODE]with open(FILE) as number_file: lucky_numbers = [set(line.strip().split('-')) for line in number_file] [/CODE] What does "with ... as ..." mean? What is it used for? How is it used? | |
hii..m stuck in an issue...and need a help I have Try.c file having contents ValidateFunction() { ...... ...... print } .... I want to print data between the braces {....}. Also i do not want to read the contents of file line by line because file is of very big … | |
[url]http://paste.pound-python.org/show/941/[/url] Having trouble getting a loop to write to a series of newly created sequential blank .wp files. Grateful for any help, thank you. Regards & a Happy New Year! Banjoplucker. | |
I have a share -//192.168.0.11/myshare which has many files in it. Which is the best way to delete all the files in this directory using python? I tried: [CODE]import os folder = '\\192.168.0.12\myshare1' for the_file in os.listdir(folder): file_path = os.path.join(folder, the_file) try: if os.path.isfile(file_path): os.unlink(file_path) except Exception, e: print e[/CODE] … | |
Hi, I am trying to install the Python4Delphi components, but it doesn't compile (from python4delphi.googlecode.com/svn/trunk). It also seems out of date. What is the best current way to use Python inside Delphi? Any advice or help will be greatly appreciated. Thanks! | |
Hello, This is a really simple question but I just don't see the error here: [CODE]def foo(): x = input('write something: ') if x == 1 or x == 2: print('OK') else: print('NO') print(x)[/CODE] Why does it keep printing NO? Also, I have a more complicated one: def foo(x, y): … | |
Hi all, i was writing a gui for a small desktop application i made as a part of learning python.I use python 2.7.I used Tkinter.I am new to python and this was my first trial with Tkinter. First i created 9 buttons arranged in the form of a 3*3 matrix … | |
So I have a program I am making but I need to make it more efficient, is there any way to condernse the following code into a more compact and efficient code? [CODE]r1p1=o r1p2=o r1p3=o r1p4=o r2p1=o r2p2=o r2p3=o r2p4=o r3p1=o r3p2=o r3p3=o r3p4=o r4p1=o r4p2=o r4p3=o r4p4=o r5p1=o r5p2=o … | |
I wrote this as reaction for Pascal newbie's question in Pascal Delphi forum. | |
Hello all!!! It's been a while but glad to have enough time to be back. My question is basically one of design. I'm working on a new project using pygame at the moment, mainly to brush up on and enhance some Object Oriented skills. The project itself is basically going … | |
![]() | Hello, I am a newbie in python. I have a unicode in Tamil. When I use the sys.getdefaultencoding() I get the output as "Cp1252" My requirement is that when I use text = testString.decode("utf-8") I get the error "UnicodeEncodeError: 'charmap' codec can't encode characters in position 0-8: character maps to … |
Hey fellows, I've created a fairly large math suite for my spectrometer research, which is basically a set of programs that does several math operations, generates plots etc... It's beginning to get pretty bulky, and seems like it would benefit from a nice class; wherein, I could store all the … | |
Hey friends lets checkout a small, simple and cute python program for taking photos with with your webcam without the help of any third party application programs. [CODE] import os import datetime import opencv.adaptors from opencv import highgui import Image def get_image(camera): im = highgui.cvQueryFrame(camera) # Add the line below … | |
I wrote a program which I tested in the IDE of python 3.2, it worked but whenever I open the program directly or run from command prompt, it doesn't run correctly, after the user inputs the correct answer, the program keeps saying try again. [URL="http://www.daniweb.com/software-development/python/code/359115"]here's the program it's in the … | |
Hello everyone, I have created my own random text generator with a custom method, no Markov chains included, and now I would like to try it on a different text corpus that is larger from that of NLTK's and I wanted to know which Data structure should I use in … | |
Hi all, I'm trying to read data from this xml file that looks like this: <VEGETABLE > < FRUIT > <FRUIT name="apple">1</FRUIT> <FRUIT name="Orange">2</FRUIT> <FRUIT name="Benana">6</FRUIT> I wrote the following script:[CODE]import sys from xml.dom.minidom import parse from cmath import sqrt # Load XML into tree structure tree = parse(sys.stdin) #Find … | |
I am trying to implement this code for hash table in python and i don't understand why i and k are not used in the while loop. Can somebody help me please, [CODE] import random data = [] m = 10 t = [] for i in range(10): data.append(random.randint(0, 100)) … | |
I"m trying to determine if the user is root or not then prompt to become root user; [CODE]if os.geteuid() != 0: # If not root user... os.system("gksudo crack.py") # Open root password window else: # Do Nothing if os.geteuid() == 0: # If you are root user... os.system("You are now … | |
Hello, my task is to create a basic game using Pygame. I decided to do the basic snake game like the one that was on all of the old mobile phones. However when inputing some of the basic code, i realised that once i have paused my game i have … | |
I have to creat a program that draws squares instead of circles. It also has to draw additional squares for each mouse click, and at the end print a message "Click again to quit" after the loop, and wait for a final clikc before closing the window. This is what … | |
I am trying to only have the words print out if they occur the same number of times as in the fibonacci sequence. If a words show up 1,2,3,5,8 etc then it will print up. I have gotten the program to print up the words based on how many times … | |
Greetings all! Anyway excuse my English. I can't understand how I can do this: <loop cycle; variable is filled by some values> <loop is still running, but simultaneously another command is running> <loop is terminated; i want to read variable> More specifically (it concerned with Scapy module, but I'll explain … | |
For some reason it just jumps to the else statement instead of going to if and elif. Any input would really be apreciated. [CODE]a=raw_input( "What is your name: ") b= int(raw_input( "What year were you born: ")) c= int(raw_input( "What year is it now: ")) print "Hello",a,"you are",c-b,"years old." class … | |
I have stated to make a program called virtual Tv, I have been having troubles with variabels and I need the variable: state to be able to be change and accessed outside the class and inside, but I think that state is a local variable at the moment. [CODE]import random … | |
I want to limit the size of a list control box. Let us take the following code: [code] import wx class Students(wx.Frame): def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, id, title, size=(380, 230)) hbox = wx.BoxSizer(wx.HORIZONTAL) panel = wx.Panel(self, -1) self.list = wx.ListCtrl(panel, -1, style=wx.LC_REPORT) self.list.InsertColumn(0, 'name') self.list.InsertColumn(1, 'age') hbox.Add(self.list, … | |
Hello. I have been trying to run a simple script in Windows 7 DOS using the python command, but it returns this error message: 'python' is not recognized as an internal or external command, operable program, or batch file. I've looked up how to fix on Google, but I can't … | |
For this program I am trying to figure out how to sort/print the words out based on frequency of appearance in ascending order. As of now I can only get the words to sort/print based on alaphabetical order [CODE] from collections import Counter import string while True: filename=raw_input('Enter a file … | |
Hi guys, thanks for all the help lately, but I require some more :o I need it that the user is able to choose what is on the controller, when I type in a valid option I test for it that it gets to that point but it does not … | |
I need to know how to copy some folders not all from a source tmp/folder. I'm new to python and I want to better understand python. I can't use copytree because I don't wish to copy all folders. I want to be able to pick the folders I want to … | |
I'm looking for a simple way to rotate a shape in python, tkinter. The shape I'm rotating is a triangle (polygon) if it matters. Thanks in advance for all the help |
The End.