15,190 Topics

Member Avatar for
Member Avatar for lewashby

I'M reading the book "Beginning Game Development with Python and Pygame". The book showed me how to calculate the distance between two points using vectors. It first explained that you just subtract the values in the first point from the second. But just page or two pages later it says …

Member Avatar for Beat_Slayer
0
88
Member Avatar for lewashby

[CODE]class Vector2(object): def __init__(self, x= 0.0, y = 0.0): self.x = x self.y = y def __str__(self): return "(%s, %s)" % (self.x, self.y) @classmethod def from_points(cls, P1, P2): return cls( P2[0] - P1[0], P2[1] - P1[1] ) A = (10.0, 20.0) B = (30.0, 35.0) AB = Vector2.from_points(A, B) print …

Member Avatar for Beat_Slayer
0
107
Member Avatar for viandante

Hi guys! I'm writing my first small application*. For this I'm using Sqlite as database, Glade as GUI builder and Python as coding. The application is pretty simple: it's a notebook to store names, surnames, adresses, etc.. I've been able to create a first window to store data in Sqlite …

Member Avatar for woooee
0
882
Member Avatar for D33wakar

using wx python.got black bars instead of unicode characters in gui window. [hint]:My interpreter gives error- [COLOR="Red"]Unsupported characters in input[/COLOR]

0
77
Member Avatar for awie10007

Scanning from a laser line and usb cam V Python fill up memory to 1.6G and crash the system Smaller Scan works fine is there a better plotting module or a way of getting past V Python memory block? The plot must happen in color xyz rgb. [CODE]import thread import …

0
201
Member Avatar for TrustyTony
Member Avatar for TrustyTony
0
592
Member Avatar for gunneronaspooky

Trying to get a program to fine the slope and intercept of a line on a graph.... I've got it all working so far...except the last line. I broke it down into pieces and ran it assigning numbers to the variables, but in the program, it doesn't work. Here is …

Member Avatar for IsharaComix
0
168
Member Avatar for -ordi-

Best way to parse this webpage private info: [url]https://ee.ekool.eu/index_et.html?r=2#/?screenId=g.user.login&err=1[/url] I found Beautiful soap and PyKhtml. What is the better?

Member Avatar for -ordi-
0
531
Member Avatar for Sargasso

I am currently trying to take two columns from a *.csv file... log10 transform them, and then plot them up on a graph. The graph is not the issue, I just need to edit those two columns and plot them. The file does have a header row, there are 8 …

Member Avatar for Beat_Slayer
0
126
Member Avatar for Alex Sarria

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

0
30
Member Avatar for pythonstudent

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

Member Avatar for cghtkh
0
103
Member Avatar for _neo_

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 …

Member Avatar for _neo_
0
5K
Member Avatar for _neo_

How can I get error message? [CODE] try: ...# some operations except: sock.sendto(err_msg,0,addr) # send client err_msg from exception [/CODE]

Member Avatar for _neo_
0
269
Member Avatar for Wumbate

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!

Member Avatar for Beat_Slayer
0
55
Member Avatar for Ghostenshell

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

Member Avatar for Ghostenshell
0
217
Member Avatar for csguy11

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

Member Avatar for TrustyTony
0
481
Member Avatar for Reverend Jim

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 …

Member Avatar for Reverend Jim
0
1K
Member Avatar for KrazyKitsune

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

Member Avatar for woooee
0
91
Member Avatar for JDuch

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

Member Avatar for JDuch
0
143
Member Avatar for KrazyKitsune

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

Member Avatar for Stefano Mtangoo
0
603
Member Avatar for jyothics23

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 …

Member Avatar for Tech B
0
2K
Member Avatar for gunneronaspooky

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 …

Member Avatar for gunneronaspooky
0
141
Member Avatar for Delu:sional

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 …

0
94
Member Avatar for udev

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': …

Member Avatar for udev
0
126
Member Avatar for matkod

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 …

Member Avatar for woooee
0
7K
Member Avatar for xtra333

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 …

Member Avatar for xtra333
0
2K
Member Avatar for kinniburghc

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 …

Member Avatar for kinniburghc
0
7K
Member Avatar for gudumba

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 …

Member Avatar for Stefano Mtangoo
0
185
Member Avatar for pixelss

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 …

Member Avatar for pixelss
0
475
Member Avatar for Tenck

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 …

Member Avatar for snippsat
0
283

The End.