15,194 Topics

Member Avatar for
Member Avatar for sebcbien

Hello, I'm trying to update a dictionary using variable in a class. Something looking like this : [code=python] class testClass(object): def __init__(self): self.data0 = 0 self.data1 = 1 self.data2 = 2 self.data3 = 3 self.d = dict( data0 = self.data0, data1 = self.data1, data2 = self.data2, data3 = self.data3 ) …

Member Avatar for snippsat
0
175
Member Avatar for viandante

I'm trying to make a siple list to display sqlite rows in a grid using wxList. I can't come up with something decent. I can't place correctly the items in the list. [code] #!/usr/bin/env python # -*- coding: utf-8 -*- # generated by wxGlade HG on Wed Sep 22 12:34:17 …

Member Avatar for viandante
0
137
Member Avatar for doffing81

Let's create a continuing thread to program Crazy 8's from scratch for learning purposes! [B]DECK/CARD IDEA'S[/B] My simple starting suggestion: [CODE]deck = ['2C','3C','4C','5C','6C','7C','8C','9C','10C','JC','QC','KC','AC', '2D','3D','4D','5D','6D','7D','8D','9D','10D','JD','QD','KD','AD', '2H','3H','4H','5H','6H','7H','8H','9H','10H','JH','QH','KH','AH', '2S','3S','4S','5S','6S','7S','8S','9S','10S','JS','QS','KS','AS',][/CODE]

Member Avatar for doffing81
0
1K
Member Avatar for Enders_Game

So I'm trying to make a parser for a game replay. I just need help getting started, I have docs for it explaining. Atm I'm just trying to get the header parsed. [code] replay = open(r'C:\Users\CookieMonster\Desktop\mix.w3g', 'rb') #offset | size | description print(replay.read(0x1c)) #0x0000 | 28 chars | zero terminated …

Member Avatar for griswolf
0
358
Member Avatar for slingblade

I've been trying to modify a function and every attempt seem to screw up the plist. [CODE]def removeItem(pl, item_name): for dock_item in pl['persistent-apps']: if dock_item['tile-data']['file-label'] == item_name: verboseOutput('found', item_name) pl['persistent-apps'].remove(dock_item) return True for dock_item in pl['persistent-others']: if dock_item['tile-data']['file-label'] == item_name: verboseOutput('found', item_name) pl['persistent-others'].remove(dock_item) return True return False [/CODE] This scans …

Member Avatar for slingblade
0
129
Member Avatar for PascalNouma

Hi everyone, Does anyone know how to remove a particular attribute in XML by using Python? [CODE] <country> <city capital="Paris">Paris</city> ............ ............ </country> <country> <city capital="Helsinki">Helsinki</city> ............ ............ </country> <country> <city capital="Bogota">Bogota</city> ............ ............ </country> [/CODE] I just wanna delete or remove Paris and Helsinki here by using SAX or …

Member Avatar for bvdet
0
326
Member Avatar for acrocephalus

Hello! I have a frame with some sizers in it (see code at th end for a running example). I would like to know how to repeat the sizers 2, 3 and 4 when pressing the add button. The sizers should be added before the submit button, and the control …

Member Avatar for acrocephalus
0
125
Member Avatar for emorjon2

hello! I'm coding in python and have make the computer controll a lego NXT robot via bluetooth. Next step is to involve my lg ku990 mobile to the network, so I can get the camera and sound information from the mobile phone. Do anyone knows a python library as allow …

0
165
Member Avatar for Archenemie

[CODE]paid_value = self.paidinput.GetValue().strip()[/CODE] I have this line of code to take a number from the paidinput field, but i need the value as an integer, how would i go about this?

Member Avatar for Archenemie
0
100
Member Avatar for AnnetteM

Hello Daniweb, I would like to read binary data into floating point numbers. I'd be happy with a 1-D array (or vector) or a 2-D array. Just something I can write to a text file. I attached a small sample of this data. Here is the code I have so …

Member Avatar for woooee
0
4K
Member Avatar for kadvar

Hi, Given a sentence, I'm trying to check if all the individual constituents of a word are present in it and if they are then do some further processing. I can't seem to get the logic to work. [CODE]wordlist = ['England area','Germanic 6th'] mysentence = 'The area now called England …

Member Avatar for kadvar
0
101
Member Avatar for Sandhya212

Hi, My requirement is to identify '-' in string1 and delete those corresponding locations in string2. The logic I am implementing is that 1. find the locations in string1 where '-' occurs 2. At these locations, insert spaces in string2 and then 3. have string2 without spaces. I managed to …

Member Avatar for TrustyTony
0
127
Member Avatar for kez1985

Hi I recently started using python for work and was tasked with creating a mailer script for one of our linux servers. I found a number of good examples on the web for different mailer app implementations and eventually came to the code below. Can anyone advise me on good …

Member Avatar for TrustyTony
0
195
Member Avatar for cmcpart0422

Hey I'm new to the site but I'm taking a class that will probably have me here often asking stupid questions. One of my homework problems is create a python program using a while loop to answer the 100 fowl problem. The 100 fowl problem is a farmer sold 100 …

Member Avatar for cmcpart0422
0
111
Member Avatar for Sandhya212

Dear all. I have a file with lines like this.[CODE] query 210 ACTTGGACTC 219 query 311 ACTTGGACTC 320 ....[/CODE] From every line, I need to extract the number coming right after 'query' and then the DNA sequence. I currently read each line as a list but was only able to …

Member Avatar for Sandhya212
0
179
Member Avatar for bettersaid

Is it possible in python to open all files in a directory? this only opens a particular file: [CODE]import os path = "/Desktop/directory/file.odt" temp = os.system("open " + path)[/CODE] how about this? am i doing it right? [CODE]import os mypath = "/Desktop/directory" temp = os.listdir(mypath) temp = [os.path.join(mypath, i) for …

Member Avatar for redyugi
0
133
Member Avatar for bettersaid

[CODE]import os from appscript import * this = app(u'System Events').application_processes[param1].windows[param2].exists() while True: this1 = app(u'System Events').application_processes[param1].windows[param2].count(each=k.radio_button) if count == (this1): this2 = app(u'System Events').application_processes[param1].windows[param2].radio_buttons[param3].click() try: os.makedirs(param1) except OSError: if os.path.exists(param1): this3 = os.system('screencapture -C '+ param1 +'/'+ param2) while True: self.param2 = os.path.join(param1, 'win%s_%s_img_%s' % (param1, param2)) return param2 + …

Member Avatar for bettersaid
0
190
Member Avatar for kimmi_baby

I've created a program with turtle graphics that has 3 functions. One draws rectangles, one draws squares and one sets the position. I'd like to create a function that fills in the shapes with different colours. I know about begin fill and end fill... but I would really like to …

Member Avatar for stevenpgrm
0
83
Member Avatar for bettersaid

f i opened a document in terminal through this [CODE]os.system("open " + pathName)[/CODE] how should i close it? is there something like [CODE]os.system("exit")[/CODE] or something Thanks

Member Avatar for bettersaid
0
78
Member Avatar for python_user

Hi Guys i have a situation where i need to have a options menu kind of thing. When they select some option in the menu i need to have a text-box/box which accepts only date/box which accepts only int beside it to accept the value I am trying to do …

0
58
Member Avatar for smittles

I am brand-new to Python, and this is my first post on DaniWeb. Seems like a positive community, and I hope one day to contribute as a knowledgable expert and not a world-class newbie. I'm wanting to create a simple python program that "fakes" Shakespeare or haiku-style output. I realize …

Member Avatar for TrustyTony
0
187
Member Avatar for ihatehippies

Is there a way to set an objects id or memory position? Ultimately I'm trying to change function "a" to function "b" while still preserving any saved reference to function "a"

Member Avatar for ihatehippies
0
169
Member Avatar for dustbunny000

Is there a logical operator in python for and/or of strings? I am trying to write a weasel code. What I have so far: [CODE]import random import math keys='abcdefghijklmnopqrstuvwxyz ' monkey='methinks it is like a weasel' def attempt(): attempt='' for i in range(len(monkey)): x=random.choice(keys) attempt+=x return(attempt) library_attempts=[] for i in …

Member Avatar for TrustyTony
0
102
Member Avatar for dustbunny000

Hi there. I am trying write a module that can be executed at the command line and for some reason it's not working. Does anyone know why? [CODE]import sys def fibonacci(N): a,b =0,1 while b < N: a,b = b, a+b print b N=sys.argv[1][/CODE] Does it matter that I'm running …

Member Avatar for TrustyTony
0
95
Member Avatar for pythonbegin

Dear All I am working with a tab-delimeted files - first two columns are pairs of identifiers and third column is floating point number (0-1) denoting interaction strength between colmn1 and 2. sample file is also attached. eg- column1 column2 column3 john steve 0.67588 john matt 1.00 red blue 0.90 …

Member Avatar for TrustyTony
0
104
Member Avatar for novice20

could anyone help me regarding calling different python scripts from within a main script.How can this be acheived? Thanks in advance

Member Avatar for cghtkh
0
230
Member Avatar for dustbunny000

for: [CODE]import random keys='abcdefghijklmnopqrstuvwxyz ' random.choice(keys)[/CODE] How would I count how many times it takes random.choices(keys) to generate "m"?

Member Avatar for D33wakar
0
168
Member Avatar for Wumbate

Here's a weird one: I have a Tkinter.Text widget that I import data from with inputText.get(1.0,END) However, later in the program I have the text in an array, but the array has values like: 'u\x00s\x00e\x00r\x00' Is there a way to decode this weird string to a normal string? I think …

Member Avatar for D33wakar
0
90
Member Avatar for moonlite25

I have this code: def rollBox(length, numDivisions, count): Angle = 90/numDivisions if count == 0: return elif numDivisions == 0: rollBox(length, numDivisions, count - 1) else: square(length) turtle.right(Angle) rollBox(length, numDivisions - 1, count) Is there any way to still decrease the 'numDivisions' parameter to zero while still keeping its original …

Member Avatar for TrustyTony
0
79
Member Avatar for novice20

could anyone please help me regarding how to add a newline character to the log file created using logging module. All the output is dumped onto a single line, which makes it unreadable. I s there any way to make the log file legible?

Member Avatar for TrustyTony
0
56
Member Avatar for darkwing

Hi all. I'm writing a simple GUI to display some text and update the text as I receive data from a multicast address. What I have is a Frame, and then a wxScrolledWindow that is using the Frame as its parent window. The scrolled window contains a vertical box sizer …

Member Avatar for darkwing
0
426
Member Avatar for ste_a47

I'd like to implement a functionality in an app of mine, but I don't know how to go about it. What I want is this: I have a model class that uses imagekit to save its images, and I'd like to have the users being able to update the images …

0
86
Member Avatar for MrAlshahawy

Hi all, I want to know the last event in log ; in other words , when I use this code below : [code] telephone.incoming_call() # waits for an incoming call telephone.call_state(handle_call) [/code] it calls the handle_call function when there is (Answering - Missed - Dialing - Ringing) events , …

Member Avatar for MrAlshahawy
0
86
Member Avatar for novice20

I am new to python n developing scripts as a part of my project.I need help regarding HOW THE OUTPUT OF THE SCRIPT CAN BE REDIRECTED TO A TEXT FILE(FOR MAINTAINING ERROR LOG), WHILE ALSO PRINTING IT ON CONSOLE?? Thanks for all the help in advance and I am looking …

Member Avatar for novice20
0
161
Member Avatar for Wumbate

Hi, I have a UI built in Tkinter. The user can type in some inputs and hit "Run" When the "Run" occurs, a program executes that could take 30 seconds or more! The problem is that this blocks the graphics updating. At the beginning, I set a Label to "Running …

Member Avatar for D33wakar
0
29K
Member Avatar for dustbunny000

[CODE]import math import random choices=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,\ 37, 38, 39, 40, 41, 42, 43, 44, 45, …

Member Avatar for TrustyTony
0
78
Member Avatar for bettersaid

helo! can anyone help me in automatically saving files with fixed filename in python? the OUTPUT would be like this: FILE- A01.txt FILE- A02.txt FILE- B01.txt File- B02.txt i was hoping that i could save a file automatically after making some changes in the older version. Thank you, Gene

Member Avatar for bettersaid
0
445
Member Avatar for marcom10

I need to write a mortgage calculator program that will find the amount of a monthly mortgage payment for a loan. [CODE] # Get information from user print 'CALCULATOR FOR MORTGAGE LOANS' loan_str = raw_input ("Amount of loan:") loan = eval(loan_str) years_str = raw_input("Number of years:") years = eval(years_str) rate_str …

Member Avatar for woooee
0
116
Member Avatar for lewashby

Program 1 [CODE]import math class Vectory2(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] ) def get_magnitude(self): return math.sqrt(self.x**2 + self.y**2) def normalize(self): …

Member Avatar for snippsat
0
97
Member Avatar for moonlite25

Hi, I am coding a program to make a rolling box function using turtle graphics. The box is supposed to appear to be rolling across a floor to the right like this: [url]http://img194.imageshack.us/img194/2944/rollingbox.png[/url] There are supposed to be three function parameters: length for the length of a side, numDivisions for …

0
47
Member Avatar for dustbunny000

This might be dumb... but I'm having problems raising e to a negative number and I can't figure out what is going on. [CODE]>>> math.exp(((-23*(23-1))/730)) 0.36787944117144233 >>> math.exp(-506/730) 0.36787944117144233 >>> math.exp(-.69) 0.5015760690660556 >>> math.exp(-(506/730)) 1.0[/CODE] For some reason I keep getting different answers when they should all be the same... …

Member Avatar for dustbunny000
0
85
Member Avatar for lewashby

[CODE]import math 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(P1, P2): return Vector2(P2[0] - P1[0], P2[1] - P1[1]) def get_magnitude(self): return math.sqrt(self.x**2 + self.y**2) def normalize(self): magnitude = self.get_magnitude() self.x /= …

Member Avatar for lewashby
0
114
Member Avatar for dragonflame17

I wrote this program for a class, the only problem is that it returns the anwser for assessmentValue twice. I can't figure out what to do to fix it...please help!! [code=php] def main(): #Get the actual value for the property. actualValue = input ("Enter the actual value of the property:$") …

Member Avatar for TrustyTony
0
108
Member Avatar for Monster Killer

Hello. I was wondering if there was a way to use python to convert a video to flash and add controls online. Like youtube, a user uploads a video and it gets converted and controls get added. I have looked online and everyone says "Use this extension blah blah blah" …

Member Avatar for Monster Killer
0
120
Member Avatar for mamdooh26

Hi every one I am facing a problem in deleting items from a list <<< Could any help me !!! [CODE]b=['a', 'b', 'r', 'g'] for c in b: b.remove(c) [/CODE] but when I check b the result is ['b', 'g'] how can I delet all items using for loop thanks

Member Avatar for cghtkh
0
85
Member Avatar for kumar_k

Hi, I want to convert a string to numbers ... i tried a lot of codes.. iam a beginner... Kindly help... Ex: a=1 b=2 c=3 d=4 e=5 f=6 g=7 h=8 i=9 j=10 input value -->abc output value --> 123 input value -->abcj output value -->12310 I mean i want to …

Member Avatar for kumar_k
0
94
Member Avatar for ←Guybrush→

Ahoy Sailors! So I'm making a Python built application with the Twisted engine, Where size is a slight issue, Currently compiled under Python26 using Py2Exe, The file stands at 1.8MB (With trimmings), Now my script should work using Python 2.4 which also should decrease the file size considerably, However the …

0
50
Member Avatar for WildBamaBoy

I'm attempting to write a game server and I need it to continue on with the code while listening for a connection. I know this is done with the threading module but I don't know how exactly to do this. Python documentation didn't work for me. [CODE] #[LISTENER] print "Initializing …

Member Avatar for lrh9
0
174
Member Avatar for emorjon2

hi there! i'm have a biiig trouble. I've make a simple chatbot, as can learning. The problem is, that I can't insert data into the dictionary without a error. here is the code: [CODE] codes = {} def arraycompare(array1, array2): l = 0 for i in array1: for j in …

Member Avatar for griswolf
0
136
Member Avatar for Synthuir

So I'm writing a bit of code for use in an IRC bot. I tried to use scheduler to get around the barbaric-ness of calling time.sleep() every time I want the bot to delay for a few seconds. In scheduler you can choose the delay function "for example time.sleep()"-- but …

Member Avatar for lllllIllIlllI
0
237

The End.