15,181 Topics

Member Avatar for
Member Avatar for dustbunny000

I'm writing a code to minimize a function and I'm having problems storing the new move. [CODE]import math import random #minimze the function: def f(x): return math.pow(x,2) + math.sin(10*x) x_list=[] energy_list=[] g=2 #starting position def move(): #Generate a random move random.uniform(-0.5,0.5) def energy(): h=g+move() #generate random move E = f(g)-f(h) …

Member Avatar for Gribouillis
0
101
Member Avatar for zyrus001

Is it possible to read and write to a queue at the same time? for example, one thread is using put() and another thread get() on the same queue? When threading, I've added the task_done() but queue.join() seems to wait for all jobs to finish before the main thread continues.

Member Avatar for Gribouillis
0
118
Member Avatar for bertm81

Hi, I am new to python and am wondering is it possible to name a method after a variable. I know I can name a variable after another variable using [code=python] test = "temp" vars()[test] = 123 print temp [/code] this will print 123. so I was thinking something like …

Member Avatar for bertm81
0
218
Member Avatar for tubesnube

Hi, myself and two of my friends are creating a game that imitates that of Whack-a-mole. I am trying to implement code so that when I click on the mole with the mouse, the image changes to a different image, eg. the image when just moving the mouse is a …

Member Avatar for tubesnube
0
2K
Member Avatar for bpatt22

[CODE] class Player(object): def __init__(self): self.points = 0 def add_points(): plyr1.points += 1 plyr2.points += 1 plyr3.points += 1 if __name__ == '__main__': (plyr1, plyr2, plyr3 = (Player(), Player(), Player()) add_points()[/CODE] How could the 3 lines in add_points() be written better/shorter?

Member Avatar for Gribouillis
0
149
Member Avatar for bertm81

Hey All, am looking for a way to break an xml Tag line into tag and attributes. Say I have This line [code=xml] <event time="12:30" value="This is a Sample Value" type="event"> </event> [/code] I have this so far [code=python] # Open file to read f=open("myTest2.xml") #start reading File for line …

Member Avatar for bertm81
0
202
Member Avatar for saulius

Hi all, after many hours, I decided to ask my question. I'm making an editor for the ABC music notation language. It is not a supported language in the standard wx.stc lexers. It should be possible to add my own lexer, but how do I do it? If it is …

0
43
Member Avatar for kinto

Hey, I have a function, though it's not working as it should be. My program is Dijkstra's algorithm, and I am trying to build a list of a node's nearest neighbours using info contained in a text file of the network (7 nodes in this case), in the form: 0,2,4,1,6,0,0 …

Member Avatar for kinto
0
227
Member Avatar for debasishgang7

Hi all,i can send AT commands to my phone(over Bluetooth) using Hyper Terminal.I am trying to do the same process using python.So here is my code: [CODE]import time import serial # configure the serial connections (the parameters differs on the device you are connecting to) ser = serial.Serial( port='COM8', baudrate=2400, …

0
103
Member Avatar for debasishgang7

I am using python in win32 enviornment.i wanna add extra library for using serial port.So i have downloaded the lib for windows env. The package is installing fine.But when ever i import serial following error i get.Can anyone please help me out... [CODE]>>> import serial Traceback (most recent call last): …

Member Avatar for debasishgang7
0
195
Member Avatar for kur3k

Hello, how i can creat menu in wx.ListCtrl(), for example when i double click in item list, i return menu like for wx.Menu().

Member Avatar for kur3k
0
862
Member Avatar for debasishgang7

hi all, I am trying to make a prog. which will download image from a web site.But the problem is the dynamic nature of the web site. The url is like [url]http://www.site.com/image.aspx?id=445[/url] If i wanna access image 1,2 or anything i can change the id and i can view the …

Member Avatar for debasishgang7
0
457
Member Avatar for prateekmeharia

i am using a template which is working fine with mozilla, but it shows allignment problems with safari, is there any code to make templates cross - browser compatible.

Member Avatar for wulaishiwo
0
85
Member Avatar for progr

I am having problems accessing a variable from one class to another. [CODE] class Player(pygame.sprite.Sprite): def rotateShip(self, rotAmt): radians = self.rotation * math.pi / 180 [/CODE] I am trying to use the variable radians from class Player to another class. radians only exists in 'rotateShip'. Thanks for your help in …

Member Avatar for Gribouillis
0
152
Member Avatar for Vi3tkevin

I everyone, I need help with making a program where the program would allow anyone to type in a certain weight of a package and the output would come out with a pricing. I will attach the detailed instructions to this thread. Help would be appreciated! This is what I …

Member Avatar for TrustyTony
0
139
Member Avatar for weblover

hello all, i'm new to python programming and i'm facing a problem and need ur help i finished my script and i'm trying to execute it on windows cmd the script takes a file as an argument , when i run the script with the argument it works very well …

Member Avatar for weblover
0
404
Member Avatar for pythonbegin

Hi All I have just started using a subprocess.call()to call external commands. I want to call R from command line and that I can do it easily by subprocess.call('Rscript script.R') and it works fine. I want to pass the several arguments instead of using default arguments. I tried using Rscript …

Member Avatar for TrustyTony
0
5K
Member Avatar for Clotoss

I have been working on pygame for awhile, and now I am working on making a fairly complex space ship game. I want the player to be able to go forward with 'w' and steer by rotating the ship with the 'a' and 'd'. I've tried pygame.transform.rotate, but it makes …

0
118
Member Avatar for toritza

hello. I am quite new in python so i have a question. I have a csv file in which i have names of 30 cities and their coordinates(lat and long). i want to generate a distance matrix for these cities. How can i do this ?

Member Avatar for Gribouillis
0
2K
Member Avatar for appsrox

Hello, I want to write to a file in a particular format. There should be 2 columns, the first column should allocate 5 spaces to store digits and the next column should allocate 30 spaces to store characters. Ex:- [code] 1 Dave 234 Einstein 100000 Bob . . . [/code] …

Member Avatar for richieking
0
948
Member Avatar for Python_nooby

Recently I have been learning about the socket module and how you can create networking applications using it. I was curious if it would be possible using the socket module to either: Set the port as a USB port to trick the computer into thinking a USB is plugged in …

Member Avatar for richieking
0
488
Member Avatar for jamseyjames

How would you go about extracting part of a key from a dictionary. I have a text file that lists about 1000 birthdays Ex. 1/2/1980 I want to extract just the year portion from the dictionary and then run a count against each year. I have no problems with any …

Member Avatar for richieking
0
82
Member Avatar for Simplicity.

My code tries to solve an optimization problem constrained to hyperbolic PDE by matching a numerical solution to a desired one. The basic idea is that: I've initial condition "U" as input which is being updated by this line: U = Initialize(Update_Design_Parameter(U)). I expect that updated U will affect all …

Member Avatar for Gribouillis
0
163
Member Avatar for silence02

Hello all. I am new to programming, taking my first class in college. Im enjoying it a lot so far, and much of the info on daniweb has been a huge help. Due to some unforeseen circumstances, I had to miss class and am now having some troubles with a …

Member Avatar for silence02
0
3K
Member Avatar for kinto

Hello, I have some code that passes arguments between functions, though I am failing to understand why my code isn't working. This is the relevant section of my Dijkstra's algorithm code: [CODE]def network(): f = open ('network.txt', 'r') network = [[int(node) for node in line.split(',')] for line in f.readlines()] print …

Member Avatar for kinto
0
3K
Member Avatar for kinto

Hello, I am having some trouble in working out the distance of each node from the starting node in my Dijkstra Algorithm code. Here is my code with the section i'm stuck on in bold: [CODE]infinity = 1000000 invalid_node = -1 startNode = 0 class Node: distFromSource = infinity previous …

Member Avatar for woooee
0
166
Member Avatar for laroca

Ok, so I pretty much have my program up and running, but it's not the best looking program aesthetically, and I am trying to do a couple of things to make it look better, and none of them are working. Here is what I want to do. 1) change the …

Member Avatar for woooee
0
255
Member Avatar for Torien7

Hey everyone. I would really appreciate some help. I'm currently building a program in Python 2.6 for an introductory Comp Sci class. The program is supposed to use functions to read a text file from a URL, parse the data into tokens, and use the data to calculate a sort …

Member Avatar for Torien7
0
239
Member Avatar for cloudspade

Hey !can somebody help me how to create a incremental search(numerical method) program using python!

Member Avatar for Zeref
0
102
Member Avatar for etypaldo

Hey, I am doing a 'Helicopter'-style game for a project where the player holds the spacebar for the main sprite to go up, releases to go down. Objects come from the right side of the screen at random y-cords moving until they hit 0 on the x-cord. The player must …

Member Avatar for Clotoss
0
365

The End.