15,190 Topics
![]() | |
[CODE]import string def main(): print ("This program calculates the number of words in a sentence") sent = input("Enter a sentence: ") words = str.split(sent) print ("The total word count is:", len(words)) print ("The total character count-withspace is:", len(sent)) retry = input(''' Would you like to try again?''') if retry == … | |
As promised, here is my final project in my Python programming course. I got the solution all by myself, although, feel free to make any changes you see fit, I've already turned it in. [quote]For this assignment you are to develop a Python program based on the scenario and following … | |
Hello all! I'm using the phenny IRC bot, and I've got this script, to greet people when they join a channel: #!/usr/bin/env python """ greet.py - Phenny Sahana-Eden Greet Module (c) 2011 Nolan Lum <nol888@gmail.com> """ import os, re import sqlite3 def setup(self): fn = self.nick + '-' + self.config.host … | |
I've been trying to make a cash register program and right now this is my draft. For the program, the prices need to add up to a total which than will be calculated with HST and discount amounts. The discount needs to be the lowest number price entered from all … | |
Hey guys and gals, I'm just starting Python, and I was wondering if someone could translate this code into english ? from sys import argv script, first, second, third = argv print "The script is called:", script print "Your first variable is:", first print "your second variable is:", second print … | |
I was going to try and use Mechanize for one of my programs so I just tested a bit of code I found on a website when I was searching for a tutorial on mechanize. [url]http://stockrt.github.com/p/handling-html-forms-with-python-mechanize-and-BeautifulSoup/[/url] I know the site is 2 years old but on all of the other … | |
Alright guys, I'm kinda new to python. I've made a kind of an organiser program that allows you to make entries with deadlines, write them to a text file and display them in human readable format when I want it to. I first made it in command line and it … | |
This code is based on code from series of programs [URL="http://www.ferg.org/thinking_in_tkinter/"]'Thinking in tkinter'[/URL] This code is not perfect, especially it does not recognize key release when mouse moves out of button area during push. Leave event could also be captured for that to stop the event in that case. | |
I am having trouble compiling an exe. I tried both py2exe and cxfreeze with similar results, I made an exe but it didn't work. I figured out that I needed to send the image files and sounds with it (should have thought of that to begin with). Now that I … | |
So I'm writing a code that imports pygame to play files of music notes. I set each note to a button, 24 notes for 24 buttons. However, the program will also have four more buttons: "Record", "Stop", "Playback", and "Quit". when the record button is clicked, it will append the … | |
how i can set a header and footer when printing a QTextDocument in pyqt4 ? | |
[CODE]from time import sleep import win32com.client as win32 RANGE = range(3, 8) def word(): word = win32.gencache.EnsureDispatch('Word.Application') doc = word.Documents.Add() word.Visible = True sleep(1) rng = doc.Range(0,0) rng.InsertAfter('Hacking Word with Python\r\n\r\n') sleep(1) for i in RANGE: rng.InsertAfter('Line %d\r\n' % i) sleep(1) rng.InsertAfter("\r\nPython rules!\r\n") doc.Close(False) word.Application.Quit() if __name__ == '__main__': word() … | |
![]() | I am trying to create a walker that goes through directories. Here are the inputs and outputs which I have partly working. I am using a test directory but I would like this to be done on any directory which is leading to some problems. [CODE][IN]: print testdir #name of … |
hell everyone,i am ruuning a program from headfirst programming using pygem.....my pygem is installed in this location -------> [B][COLOR="Red"]C:\Python32\Lib\Lib\site-packages\pygame[/COLOR][/B] now my piece of code is: [B]from tkinter import * import pygame.mixer app = Tk() app.title("Head First Mix") app.geometry('250x100+200+100') sound_file = "Sototar Bilasita.wav" mixer = pygame.mixer mixer.init() def track_start(): track.play(loops = … | |
Hi. I'm creating an interface using the Tkinter library, but I seem to be having some issues with placing 3 buttons BELOW 3 buttons which are on top. All buttons should be inside the second LabelFrame. I've looked all over and I can't seem to figure out why the other … | |
Hello everybody I'm trying to use Python and Django to make my first website , i followed this tutorial : [URL="http://webpy.org/docs/0.3/tutorial"]http://webpy.org/docs/0.3/tutorial[/URL] , and i could finaly while the execution of the Python code nouveau_fichier.py which is : [CODE]#! /usr/bin/python # -*- coding: utf-8 -*- import web urls = ( '/(.*)', … | |
hello friends As the tittle say , i just would like to know if there is possibilities to change the graphisme of the Button : color , form , insert image on the Button ... , Thank you for answering , good luck :) . | |
hello friends , I just don't know , why in using Crontab it don't execute a code python that contain : [CODE]execfile("Backup1.py")[/CODE] my code is nouveau_fichier2.py : [CODE]#!/usr/bin/python #-*- coding:Utf-8-*- # -*- coding: cp1252 -*- import os print 'helo' #os.system("sudo chmod 777 /home/ismail/Bureau/Test/20111214") execfile("Backup1.py")[/CODE] and my crontab file after "crontab … | |
I am having trouble parsing xml files using ElementTree after the python code is turned into .exe using cx_freeze. [CODE] from xml.etree import ElementTree file1 = 'file1' file2 = 'file2' tree1 = ElementTree.parse(file1) tree2 = ElementTree.parse(file2) print 'Done' [/CODE] It works fine with the .py file, but after I made … | |
What I'm trying to do is read a line from a file containing some data that includes a person's first and last name, their hourly wage and the number of hours they worked, and then writing to a seperate file their last name, first name: wage. The input file looks … | |
So, this seems like it should be the default to me... if you're going to make your own picture for a button, I don't see why you'd want the default border around it, but I can't for the life of me figure out how to get rid of it. I … | |
Beginner here (meaning I probably did something silly): I am trying to target indexed elements that have [A], in them. Entries for 'scarcity' and 'sweet' are both shown. I am running into trouble when index item[2] is empty. I get the following message: [code=text]['scarcity', 'scarce', '[A],', 'ity', '[N|A]', '[N]'] scarcity … | |
Hi, I need to extract some info from a file. This is two rows from what the file looks like: prob=0.0093;ID=RGT430;BQRS=491;BRZ=-4.263;ID2=RT914;DRT=0.00;HRun=0;HaplotypeScore=0.2794; prob=0.003;ID=RGR301;BQRS=4;BRZ=-3.261;ID2=EV913;DRT=0.00;HRun=0;HaplotypeScore=0.2654; ....etcetc until last row: prob=0.345. I want to extract prob from each row in the file and put it in a new file, but I don't know how … | |
Have you ever cited the Python documentation? How did you do it? I can't seem to find author names and such information. I've only ever cited books as well. I'm trying to find out who authored the 2.7.2 docs, and how to cite them properly, since I used it to … | |
[code] import urllib from urllib2 import urlopen from gzip import GzipFile from cStringIO import StringIO import re import urllib2 def download(url): s = urlopen(url).read() if s[:2] == '\x1f\x8b': # assume it's gzipped data with GzipFile(mode='rb', fileobj=StringIO(s)) as ifh: s = ifh.read() return s s = download('http://www.locationary.com/place/en/US/Virginia/Richmond-page20/?ACTION_TOKEN=NumericAction') findLoc = re.compile('http://www\.locationary\.com/place/en/US/Virginia/Richmond/.{1,100}\.jsp') findLocL … | |
Hi! I am trying to make a program that will put the bands I've played with in alphabetical order. I'm getting the band names from a file on my computer. I am fairly new to python and don't have much experience what so ever. I'll post the code that I … | |
Hi everyone! I joined these forums about a week ago so I could try and learn more about Python, and thankfully I can say that I have learned a bit. Enough to try and create a Mastermind game, although I'm having trouble with converting the code into Pygame and give … | |
I am getting this error PYTHON - TypeError: unsupported operand type(s) [CODE]weekPay = [] names = [] hours = [] wages = [] while True: name = raw_input("Please input yor first and last name or type \"Done\" to continue: ") if name.title() == "Done": break names.append(name.title()) hour = raw_input("Please input … | |
In my code they're instructed to enter a width and height. However obviously these will be intergers, but I need to perform checks that they are intergers before they're used. Atm I've got this: [CODE] while True: if width.isdigit() == True and height.isdigit() == True: if width >= 2 and … | |
Hi there, I'm writing my first Python script for a(n imperative) programming class at university, and I want to make it a little better. It's meant to be fairly short, 50 lines. I've written the basic 'mechanism' to look at the user input. Instead of simply printing every property of … |
The End.