15,406 Topics

Member Avatar for
Member Avatar for Thropian

I made a little python code that makes a ball bounce around the screen. Every time you left click it makes another ball. when you right click it clears the screen but you can't spawn more balls afterward... any help (python, tkinter) [CODE]from Tkinter import * import time import base_translate …

Member Avatar for Thropian
0
1K
Member Avatar for BirdaoGwra

Hi, It is my code: [CODE]mylist = [['fiss','giss'], ['e','h'], ['d','u'], ['c','t'], ['b','o'], ['a','z']] for alist in mylist: g = ' '.join(alist) print g f = open("write.txt", "w") f.write(g) f.close()[/CODE] How will I write all the words in the txt file. it is only writing the last line of the file. …

Member Avatar for Tommymac501
0
139
Member Avatar for tcl76

hi, is there a way to convert from string to long? for eg: i want to concatenate all the arrays into data and make it same type (long) as data1. [CODE] a='0x' array0 = '00000018000004000000000000000000' array1 = '00000000000000000000000000000000' array2 = 'fe000000000000000000000000000000' array3 = '00000000000000000000000000ffffff' data = a+array0+array1+array2+array3 print data print …

Member Avatar for Gribouillis
0
5K
Member Avatar for tcl76

hi, i have a script that converts hex to bin and bin to hex back. however, when converting back to hex the leading 0s are truncated. how to maintain the leading 0s? i'm using Python 2.5 and Win XP. tq [CODE] import binascii import string def byte_to_binary(n): return ''.join(str((n & …

Member Avatar for TrustyTony
0
3K
Member Avatar for debasishgang7

hey all, i'm trying to get all content of a webpage using python and trying to put them all into a file. Here is my code: [CODE]import urllib data = urllib.urlopen('http://www.site.net/index.html').read() #print data //if i ignore the rest part of this code the code is just working awesome...its printing the …

Member Avatar for richieking
0
141
Member Avatar for kuchi

Apache is running in UNIX box, and we have configured folder path in config file and we are accessing python code from that folder. In the python code, we have two methods new_page() and access_form_elements(), new_page() -- print new HTML page with two form elements and method=POST and action=same .py …

0
83
Member Avatar for aldusforte

Hi all. I am new as can be to programming. I always heard a good way to learn to write was to find a project that I am interested in and start from there. So my ideal goal is to write a script that cleans up my downloads folder, ie …

Member Avatar for aldusforte
0
392
Member Avatar for Tommymac501

I am trying to replace a fixed field name in an XML file with data. I know that I could do it the proper way using XML tools, but, this is a standard templae file that only needs one item replaced. It seems simpler to just hack a replacment. [CODE] …

Member Avatar for woooee
0
81
Member Avatar for yeleek

I have two lists which contain titles and links to interesting pages (trying to write a scraper). Where I'm falling down is on the actual printing. [CODE]for i in var1: print i for a in var2: print a[/CODE] Prints all of list 1 and then all of list 2. If …

Member Avatar for yeleek
0
101
Member Avatar for rssk

hi all....... I m running a program in windows like this import os os.system('snmpwalk -v2c -c ar441c 192.168.1.10 .1.3.6.1.4.1.18489.1.2.1.1') when i run this i m getting error like [B]SNMPWALK IS NOT RECOGNISED AS A INTERNAL AND EXTERNAL COMMAND,OPERABLE PROGRAM OR BATCH FILE[/B] so anyone can plz help me........ thanks in …

Member Avatar for rssk
0
4K
Member Avatar for zizuno

I have code the goes to a page and downloads information on its update. Every once in a while it errors out with [code] url2z = url2z.read() File "/usr/lib/python3.1/http/client.py", line 502, in read s = self._safe_read(self.length) File "/usr/lib/python3.1/http/client.py", line 594, in _safe_read raise IncompleteRead(b''.join(s), amt) http.client.IncompleteRead: IncompleteRead(15928 bytes read, 37182 …

Member Avatar for TrustyTony
0
350
Member Avatar for Parth tank
Member Avatar for joeywheels

Hi everyone! New here and to Python. I'm having trouble with my break statement executing and cannot figure out why. I'm learning to write to files and want the loop to break if the user hits enter. It's not working for some reason. I've even tried to get fancy (in …

Member Avatar for joeywheels
0
107
Member Avatar for kikuolen

I have to make generetor and ouput must be all combinations.And they are written to .txt file and then user input search from that file. Anyone can help me to wrote that program?

Member Avatar for TrustyTony
0
45
Member Avatar for wilko1995

Hey, does anyone think they could explain how this code works? [CODE]def hanoi(n, a='A', b='B', c='C'): """ move n discs from a to c using b as middle """ if n == 0: return hanoi(n-1, a, c, b) print a, '->', c hanoi(n-1, b, a, c) hanoi(3) [/CODE]

Member Avatar for TrustyTony
0
117
Member Avatar for xunilxunil

Hello. First of all I am a newcomer to programming languages world and of course very new to Python. In my job, we are using Linux systems. Time to time I need to check some command and script outputs on the terminal. So, I wanted to code a small application …

Member Avatar for xunilxunil
0
306
Member Avatar for novice20

Hi, I get the log messages 'twice' on the console and only once in the log file. Can any one tell me the reason for this duplication on console? here is how I have set the logger: [ICODE]import logging #--set up logging to file logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s', datefmt='%Y-%m-%d …

Member Avatar for novice20
0
104
Member Avatar for computerstudent

I'm trying to put together a code that will basically take a user input string and reprint every 3rd character. i.e. if a user inputs "Superman" it should be reprinted like "S e a" I'm sure this is Uber-simple to you but I'm just starting out, whether it is efficient …

Member Avatar for TrustyTony
0
157
Member Avatar for canyvr

I am a beingger for using Python,now I am doing a palindrome program,but I have tried many time it still doenst work, can anyone help me to fix it??Thanks a lot!!!!! Here is the code: [CODE] s=input("Enter alphabetic characters: ") def palindrome(s): index=0 c=True while index<len(s): if s[index]==s[-1-index]: index +=1 …

Member Avatar for canyvr
0
157
Member Avatar for Archenemie

I have a listbox and what I basically want to achieve is as I click a value within the listbox I want the value clicked to be passed to a function. I could easily do this using a button and listbox.GetValue() but I believe the quality of my finished code …

Member Avatar for Archenemie
0
219
Member Avatar for hailsontherocks

Just trying to change the formatting of various bits of my print code. Is there a simple way to do it?

Member Avatar for hailsontherocks
0
134
Member Avatar for paramaster

So yeah, i figured out how to write program that will print digits in reverse(with small help of the internet, put i get it). Anyway i want to write program that will print digits in their regular order. [CODE]def num_digits(n): count=0 while count <= abs(n): count = count + 1 …

Member Avatar for TrustyTony
0
106
Member Avatar for paramaster

Hello daniweb community, i'm new to all this and i'm pretty happy that found this. Anyway i'm having sevral issues. Frist one is: my Python GUI (IDLE) won't open program. [CODE]def num(n): count=0 while count <= abs(n): count = count + 1 n= abs(n)/10 print count num(-23) [/CODE] This code …

Member Avatar for paramaster
0
190
Member Avatar for amalgorious

Hi. I write really terrible python, sort of like using crayons in art class. I have a couple questions. First is: where is the best forum for python newbies to learn how to write better code (standards) and optimize code (faster)? I just joined this forum, so it may not …

0
90
Member Avatar for matt_pds

I am trying to make a basic gui in tkinter for one of my python scripts. I have gotten it to work but I need a way for the user to break the main loop of the script by clicking a button. The loop is a for loop looping through …

0
39
Member Avatar for Ghostenshell

Help with passing the arguments. This program is supposed to ask for how many numbers do you want. I would stick with ten. Then how many numbers in a randrange (upper limit) Please choose 100 After a list is generated it is supposed to sort the numbers and look for …

Member Avatar for Gribouillis
0
97
Member Avatar for Archenemie

I want to represent money which is usually to 2DP and I add up items using float values but whenever I have a value that is similar to the one used it only converts it to a string to 1DP. This seems like its going to be annoying to work …

Member Avatar for Archenemie
0
253
Member Avatar for iwanttolearnc

im currently studying having a python program supply data to a website. to do this, i am working with a simple example. as a disclaimer to you guys: im quite new with webservers and websites so please bear with me. 1. the python program simply generates a random number continuously …

Member Avatar for iwanttolearnc
0
180
Member Avatar for l00kit

Hello all, I'm studying socket programming and have trouble when simulate a FTP server (I don't want to use pyftpdlib). The problem is when the client want to list the directory (LIST command) on the server, I do not find a way to send directory contents. here is the code: …

Member Avatar for l00kit
0
254
Member Avatar for robtyu

I am trying to figure out what I am missing to get this to work. I am not sure how to get the account balance to change as the user continues to do more transactions. Here is the code I've written so far but now I'm stuck. import math [CODE]def …

Member Avatar for woooee
0
5K
Member Avatar for python01

Hi all, I am trying to set up a system like Scatt or Notpel(alot simpler, but using basic principle), and i need to get the laser in an optical mouse to be able to track a laser or IR LED. so far I have managed to get the mouse to …

Member Avatar for python01
0
184
Member Avatar for rebo544

Hi I'm new with Python (I'm a genetics major who took a computing course as an elective) and I have an assignment that requires me to write a simple text based game. Its an exercise an working with lists, if, elif, and while statements. It also has to be able …

Member Avatar for ultimatebuster
0
384
Member Avatar for sravan953

[CODE]# A simple calculator x=input("What do you want to do? \n 1) Add \n 2) Subtract \n 3) Multiply \n 4) Divide \n") #This is a comment, note that single line comments start with a hash '#' """'x' is a variable. The 'input' statement accepts a number where as the …

Member Avatar for mak.smash
0
958
Member Avatar for sophanox

Hey guys, this is my first project since learning the python basics so please bear with me! I am trying to either portscan a host or ping sweep a class c network based on what the user specifies. The code is very basic I know but what's giving me issues …

Member Avatar for sophanox
0
6K
Member Avatar for ksmakkapawee

I have 2 arrays A = [good, bad, cat, frog] and B = [best, great, ill, evil, wicked, rotten, vicious, poor, nasty, puss, toad, paddock] and I want to match between 2 arrays with ironpython or c# Match Result!! [good : best, great] [bad : ill, evil, wicked, rotten, vicious, …

Member Avatar for richieking
0
128
Member Avatar for MrKnowNothing

Hello, I am knew here and not sure how to ask but I guess I will ask it here and if this is not where it goes feel free to tell me where to post it.....THANKS I am trying to write a recursive function Python program that will ask the …

Member Avatar for Rehab A
0
313
Member Avatar for Viasur

Hello everyone, I'm looking for a programmer that can make a small program for me. I have a buget so is kind of a small job. If anyone knows how to do this or knows a friend that can, let me know please. Here is the information of what I …

Member Avatar for richieking
0
147
Member Avatar for python01

Hi all, I was just wondering if it is possible to use python to send pulses of 5 v (default) through the parallel port. I have made up a circuit board to interpret the pulses, yet this isn't helpful since there are no pulses to receive. Here's some specs( maybe …

Member Avatar for python01
0
241
Member Avatar for Hoff123

Hi! I am kind of new at pygame and I can't use functions. I define the "screen" variable outside of all functions(the "screen" variable is the "window"), and I can't use it in functions. I know it has to be global, but that won't work. Anyway the best i can …

Member Avatar for Hoff123
0
5K
Member Avatar for people people

I am trying to make a simple game for class but I am getting hung up on one of the parts. There are two dice that roll and then you can input either the full sum or multiple numbers that equal the sum (ex. dice = 10 you could pick …

Member Avatar for TrustyTony
0
128
Member Avatar for bwbyron

So this is my original code. [CODE] import random hints = {"python" : "A program", "jumble" : "The act of mixing up", "easy" : "Facil is to Spanish as ____ is to English", "difficult" : "Not eaay, but ____", "answer" : "To ____ a question.", "xylophone" : "An instrument. Also …

Member Avatar for woooee
0
753
Member Avatar for MacUsers

Dear all, I was trying out OptionParser() and didn't quite understand who to use it correctly. This is my sample script: [code=python]#!/bin/env python from time import strftime from calendar import month_abbr from optparse import OptionParser # Set the CL options parser = OptionParser() usage = "usage: %prog [options] arg1 arg2" …

Member Avatar for MacUsers
0
209
Member Avatar for Micko

Hello, I'm using PythonWin and I have a problem. i don't know how to run script from Python shell Pythonwin Interactive Window). For example I wrote this code (from tutorial): [code] import sys print 'Begining... now...' for x in sys.argv: print x [/code] and I save it as Script.py in …

Member Avatar for danholding
0
2K
Member Avatar for kinto

Hello, I am stuck on how I have pass function arguments to the main method of my program. Here is my code: [CODE]network = [] def populateArray(): file = open('C:\\My Documents\\route.txt', 'r') for line in file: network.append(line) print "Network = " print network def main(): if __name__ == "__main__": main() …

Member Avatar for richieking
-1
266
Member Avatar for nosehat

What is the procedure in Python for opening a very large binary file in read/write mode, and overwriting individual bytes or sequences of bytes? I'm working with huge files that are many GB, and I would like to seek(arbitrary_long_integer), and overwrite what's there (instead of appending or inserting). I need …

Member Avatar for richieking
0
4K
Member Avatar for jeuxdeau2009

Im writing a blackjack program to train one to count cards using the Hi-Lo System. I found the engine online ( it was open sourced.) Instead of the code here using only numbers and Letters, i want to add only pictures of the cards instead of the numbers and card …

0
115
Member Avatar for zizuno

Basically I have an irc bot that connects to irc and listens to commands. Imports all of its functions from it. Here is some sample code with comments on what happens So my question is: how can I pass all of the information required to send irc information without reconnecting …

0
56
Member Avatar for rawrxiv

Good morning friends, I am having a weird little issue with python that I am certain stems from me failing to understand wtf is going on. I will give you the general disclaimer that I am a total programming beginner so I'll need some latitude :) The following snippet is …

Member Avatar for richieking
0
144
Member Avatar for BirdaoGwra

Hi, I am making a simple application where it reads and loads words from a text file into a ListCtrl(lc_report) in wxPython. There are only two column. i am loading it like this : [CODE]f=open('Test.txt','r') all_words = map(lambda l: l.split(" "), f.readlines())[/CODE] And in Test.txt file, there are some words …

Member Avatar for richieking
0
204
Member Avatar for sarfrazashfaq

HI All! I am creating a Python function that should set environment variable. My simple code is [I]#!/usr/bin/python import os os.environ['FK_DBO_PASS']="12345" print "After setting Environment Variable is ",os.environ['FK_DBO_PASS'][/I] When i execute this code file in command prompt it is giving me this result [I]After setting Environment Variable is 12345[/I] But …

Member Avatar for BearofNH
0
2K

The End.