15,181 Topics
| |
Hi, everybody! My name is Alex and I'm programming in C++ and Python just for hobby. My main interest is about games, fractal and fractal music. So, by the moment, I have a personal project with sounds by mean Python. I apologize, my English is not good... | |
Hey everyone, I am just starting to learn iteration in Python. I am stuck on an assignment that my teacher gave me. I am supposed to make a code to display this: 1 -2 3 -4 5 -6 7 -8 So far my code is this: counter=8 number=9 while counter>0: … | |
How can I get results from exec()? Any suggestions appreciated!!! [CODE] #!/usr/bin/python import socket sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) host = socket.gethostname() port = 1234 sock.bind((host,port)) while True: cmd, addr = sock.recvfrom(1024) if len(cmd) > 0: print("Received ", cmd, " command from ", addr) exec(cmd) # here how I can get … | |
How can I get error message? [CODE] try: ...# some operations except: sock.sendto(err_msg,0,addr) # send client err_msg from exception [/CODE] | |
Hi, I just finished a Python UI app with Tkinter and want to make it runnable by double-clicking an application on Mac OS X. But I'm having trouble figuring out how to do it. Does anyone have any instructions they could point me to? Thanks! | |
I need to check for floating point numbers inside my class but it doesn't seem to be working. Any suggestions? [CODE] class Rectangle: def __init__(self, length = 1, width = 1): self.__length = length self.__width = width ##Setters to float def set_length(self, length): self.__length = float(length) try: #self.__length = float(length) … | |
[code] def index_dir(self, base_path): num_files_indexed = 0 allfiles = os.listdir(base_path) #print allfiles num_files_indexed = len(allfiles) #print num_files_indexed docnumber = 0 self._inverted_index = {} #dictionary for file in allfiles: self.documents = [base_path+file] #list of all text files f = open(base_path+file, 'r') lines = f.read() # Tokenize the file into words tokens … | |
Can someone please fill in the missing line of code in OnPageChange? I have a notebook control and on a page change event, I want to retrieve the label of the tab that was just selected. GetLabel and GetLabelText both return '' [CODE] import wx import wx.lib.mixins.inspection class Frame(wx.Frame): def … | |
Unicode: I would like to use the radical symbol (U + 221A) in my script. How do you print the Unicode without an error? Super/Subscript: Is it possible to make a variable superscripted (and subscripted, for that matter)? | |
Somebody was so kind as to indicate to me an interactive Python learning program. I started using it, but lost the URL. I cannot find it back in the threads i started. Can this Python forum member remember me of his suggestion? Thanks | |
[code=syntax]from __future__ import division from math import sin from math import cos from math import tan from math import radians a = raw_input("enter 1 for sin, 2 for cos, 3 for tan") if a == 1: degree1 = int(raw_input("Type in angle value: ") radian = radians(degree3) sin = sin(radian) print … | |
Hi, I try to communicate with equipment through serial port. It is slightly order equipment so it requires to send command in a specified format ends CHECKSUM (Like start with 'STX' and end with 'ETX' etc and the command looks something like '020T025F00R000000000000000'). [B]Issue with Python:[/B] For my case they … | |
Okay...I'm back again for the next program...here's what i have so far [CODE]print "Euclid's Method" a= raw_input(("Enter first number ")) b= raw_input(("Enter second number ")) def euclid(a,b): while b != 0: a, b = b, a%b return a[/CODE] My question is, how do I get it to print out the … | |
I just installed eclipse and Pydev. but I can't I can't add Python 2.7 as the interpreter for Pydev. I couldn't find the interpreter file at 'mac/usr/local/bin/' I only see /python 3.1 and some others. Is it because of I have installed 3.1 and 2.7 both? Even then I click … | |
Hi! In every iteration of reading a file I populated a dictionary and appended it to a list . A part of that list looks like this : . . . Key Doc ID freq line number {'Emin': ({'file13.txt': 1}, {'Emin': [38]})} {'Gun': ({'file13.txt': 2}, {'Gun': [43, 71]})} {'I': ({'file13.txt': … | |
Hi, Im trying to create a canvas as a background but i can manage to work =/ I create a window with the text and the size of de image, but the image is not there can someone help me? thanks. [CODE]import Tkinter as tk import tkMessageBox class Janela: def … | |
Hi Guys. I am new here. I am trying to run a Poker program that can detect the different hands in poker. here is my code [CODE] class Card: # A card is an Object with a suit and rank # attributes. def __init__(self, rank, suit): # To create a … | |
I want to create a jpg image containg some graphics which I draw using the Tkinter Canvas widget. This draws the image to screen and then I use the PIL library ImageGrab() function to grab it off the screen into a file. It would be much neater to by-pass drawing … | |
Hi, I started Python command prompt and entered this: import distutils.dir_util as du du.mkpath( "c:/foo/bar" ) #assume dir 'foo' doesn't exist This works fine and it creates the path 'foo/bar'. Now, go to file explorer and delete the dir 'foo' and go to the Python prompt and issue the same … | |
Hello, i'm very new to programming in genera. Python is the first language I'm learning. So, I was instructed to make a program that ask the user for loan payment, insurance, gas, oil, tires, and maintenance. The program will calculate the monthly cost and annual cost. here is what i … | |
I know it's one of those programming languages thought of as an easy thing to learn (or so it seems like it). My problem is not with the difficulty of learning the language, rather the outdated guides and the problems with Python 3.2. So I looked into a book called … | |
hey guys.i have one realy big big problem.. My programming teacher gave my a task to get these functions to work, but i dont know python program so good.. thats why maybe someone of you could help me, and make these 3 functions to work .:).. please!! these lines are … | |
I need help with this. At the end of the semester, students often wish to know what grade they need on the final exam to get an A in the course. Write a program that prompts for the user’s grades on exam 1, exam 2, and the homework and from … | |
I have this program I'm trying to write, a simple application with gui: a menu and a button. Whenever I go to run it, this is the error I get: Traceback (most recent call last): File "/Users/[I]myname[/I]/Documents/School/Programming/Window.py", line 27, in <module> app = Application() File "/Users/[I]myname[/I]/Documents/School/Programming/Window.py", line 14, in __init__ … | |
I am new to this whole programming thing. I am currently using python 3.2. I want to get into trying to build GUI, but i can't find any programs that seem to work with python version 3.x. Should I downgrade to an earlier version of python? If so what is … | |
I need to write a function that takes in an array of integers and an integer, checks if the sum of any of the numbers in the array is equal to the supplied integer. Any ideas would be much appreciated. | |
[CODE]background_image_filename = 'sushiplate.jpg' sprice_image_filename = 'fugu.png' import pygame from pygame.locals import * from sys import exit pygame.init() screen = pygame.display.set_mode((640, 480), 0, 32) background = pygame.image.load(background_image_filename).convert() sprite = pygame.image.load(sprice_image_filename) # our clock object clock = pygame.time.Clock() x1 = 0. x2 = 0. # speed in pixels per second speed = … | |
I've built my fair share of computers and figured it was time to learn to take advantage of that hardware by learning to program. So I'm taking some courses online. I'm having some issues writing some programs though, so any help would be appreciated. Right now, I'm stuck on this … | |
Hi! I am using a label widget in order to display a n rows and m columns matrix. My program allows repeated generation of a random matrix of integer (of arbitrarily number of rows and columns) - I am observing these matrices by representing them in a Label type widget. … | |
Here's the problem. Bought a new wireless printer, HP B209a. Have a wireless router, Belkin, been using it for years. I take it, the printer, out of the box, follow all the instructions on setting it up, run the setup program in a laptop, following all on screen instructions. It … |
The End.