15,185 Topics

Member Avatar for
Member Avatar for sravan953

Hey guys, I have already worked on a program which uses threads, but today I just wanted to work on threading, and only threading: [code=python] import threading class first_time(threading.Thread): def print_first_time(self): print("What is your name?") for x in range(1000): first_time().start() [/code] But, the problem is, nothing happens! Why is it …

Member Avatar for bumsfeld
0
90
Member Avatar for princessotes

Hi, I'll try and explain my problem as simple as possible. I have written a module to perform a generalised operation (as shown below). [code] from math import sqrt from math import pow from math import log10 from Numeric import * import numpy as np def Entropy(parameters, temperature): t=float(temperature/1000.0) return …

Member Avatar for bumsfeld
0
122
Member Avatar for romes87

Hi, I am new in Daniweb. I am trying to do a simple task in Python but cannot figure out how it works. Keeps getting it wrong. Basically, I have a main GUI class App which has 2 entry boxes where you fill two numbers, a listbox where the results …

Member Avatar for romes87
0
3K
Member Avatar for blah32

[CODE] def find_and_sep(inputstr, thing_to_find): #thing to find is a string that is a regular expression #finds thing_to_find and returns tuple of the rest (before, thing, after) inputstr.strip() #match it m=re.match(thing_to_find, inputstr) #match first instance if(m==None): return "" start = inputstr[:m.start()] mid = inputstr[m.start():m.end()] end = inputstr[m.end():] tuple_x = start,mid,end return …

Member Avatar for sravan953
0
106
Member Avatar for cohen

Hey guys, I need some help with Python (obviously). I need python to insert a space. I have: [CODE]name = raw_input('Enter your name? ') # prompt and read user's name [/CODE] and that works, and it asks me for a name, and insert it, then i got: [CODE]print 'Hello ' …

Member Avatar for cohen
0
157
Member Avatar for SoulMazer

Ok, I really hated to resort to threading, but it seems like I have no other choice. I am writing a client script for the "instant message" server I just finished writing. Sadly, I am having a slight problem with threading. What I would like to do is have two …

Member Avatar for SoulMazer
0
152
Member Avatar for zachabesh

Hi all, I'm trying to mimic an html form that calls a script on the web. When I put the form together on a page, it works, and I was wondering if there was a way I could "scrape" this post request and see what I'm missing when I try …

Member Avatar for zachabesh
0
98
Member Avatar for willygstyle

Hello, I'm working on a new little project that moniters a configuration file. Everything seems to work great except for when I attempt to do some error handling. The configuration file simply looks like this. # third sets the lights # 0 = off, 1 = on, 3 = lights …

Member Avatar for willygstyle
0
113
Member Avatar for Zaffron

So I want to make a program that allows me to press a key (for example a). So when I press a, I want it to type(right term?) a predefined string (abcdefghijklmnopqrstuvwxyz for example). Like once the program is complete, I could go into notepad and press a and it …

Member Avatar for Zaffron
0
69
Member Avatar for catcit

Hello! I have a little problem. I have to print a table (four columns from an Excel file) in a text box. I took a string and I kept appending all the cells from the file that interested me and I used the textbox provided by easygui. [CODE]textbox(msg='', title=' ', …

Member Avatar for woooee
0
238
Member Avatar for Morika

Hi, I'm a newbie to python and I'm reading a file and trying to split a string every 3 spaces, that is included any whitespace. string.split() will split the string up every whitespace, but is there another way to specify every 3 spaces, whether there is whitespace or not? I'm …

Member Avatar for Morika
0
169
Member Avatar for kenji

Hi, I have slogged my way through, Mark Lutz's Learning Python it is a great book but the problem I have with it is that it doesn't have any practical programing question like the dietel books. Can you guys please tell me a few books with questions that follow the …

Member Avatar for Stefano Mtangoo
0
67
Member Avatar for Lingson

hi, i just start to learn and doing programming with python (was an old timer programmer in other languages). when i saw a project idea about creating your own squareroot function, i tried it. the problem start was when i try to compare the result of x**2 where x is …

Member Avatar for Lingson
0
141
Member Avatar for Stefano Mtangoo

I cannot get the code work. I want to use placeholder than a fixed value. When use fixed value it works but not placeholder. Please correct me! [CODE=python] import sqlite3 as sql class Tables(object): def __init__(self): print "Class created!" def CreateDb(self, dbname): self.conn = sql.connect("?", (dbname, )) self.cur = self.conn.cursor() …

Member Avatar for Stefano Mtangoo
0
3K
Member Avatar for miac09

Hi, I'm trying to run a batch of commands from a .txt file using python. ("cmd.batch.txt" = ~1000 command lines : perl cmd.1.pl -in -parameters) and redirect renamed output files to new folders. It works fine for the first line, but I'm having trouble getting something to loop through all …

Member Avatar for willygstyle
0
154
Member Avatar for tehbrozor

Hello, I am trying to make a GUI interface for a plotting routine written with matplotlib. The GUI is in PyGtk. One of the things I would like to have is a cross hair through the mouse cursor (a vertical and horizontal line intersecting at the mouse) which moves along …

Member Avatar for tehbrozor
0
427
Member Avatar for zachabesh

Hey all, Here's my problem: I have a class that I want to be able to save and and load. But I need the class to be mutable I guess. Check it out: [CODE=python]class Tool: def __init__(self,name,function): self.name = name self.function = function self.savename = self.name + '.txt' def save(self): …

Member Avatar for foosion
0
99
Member Avatar for denniskhor

My question is : How to sort files by name and delete in Python. What i want and mean is: In TextFolder have: a1.txt a2.txt a3.txt a4.txt a5.txt a6.txt a7.txt a8.txt a9.txt a10.txt i wan sort the file by name and i only wan keep 10 files only in the …

Member Avatar for sneekula
0
230
Member Avatar for Stefano Mtangoo

[CODE=python] import sqlite3 as sql class Tables(object): def __init__(self): print "Class created!" def CreateDb(self, dbname): self.conn = sql.connect("?", (dbname, )) self.cur = self.conn.cursor() def CreateNewTable(self, tablename):#, tablename self.cur.execute("CREATE TABLE IF NOT EXISTS ?(id INTEGER, name TEXT)", (tablename, )) listed = [(1, "Mary"), (2, "Martha"), (3, "Jesca"), (4, "Don")] for i …

Member Avatar for Stefano Mtangoo
0
148
Member Avatar for Missy_poo

I need help with writing a program that asks the user to enter distance in kilometers and then converts distance to miles

Member Avatar for Stefano Mtangoo
0
101
Member Avatar for dantheman3141

I appologize for the length of this post, but I have no clue what is wrong with my program. As an experiment, I wrote a XOR encryption program. It isnt very fast, but it works. Apparently, only for strings. I implemented a file encryption function, and it seems that some …

Member Avatar for dantheman3141
0
97
Member Avatar for flipjoebanana

Hello, I am aware of programs such as py2exe and py2app for converting python to standalone windows and mac apps and have gotten those to work for most things, but I'm not sure about the best way to transfer to the Linux platform. The problem is the program I have …

0
54
Member Avatar for sravan953

Hey guys... I have some code here: [CODE] import os import threading import urllib import time a=0 class launch(threading.Thread): def start_now(): try: urllib.urlopen("http://www.google.com") except: a+=1 start_now() def end(): print("\nOut of 10000 requests, "+str(a)+" requests failed.") for x in range(10001): launch().start() print("http://www.google.com") end() raw_input("<Done>") [/CODE] This works, in the sense that …

Member Avatar for woooee
0
91
Member Avatar for sab786

Hi all,:'( his for over a week now i cant get my head round it so i hope some one can help me... i have a dictionary which reads my file line by line and counts the occurance of tuples ...ok great. then for every key in my dictionary (which …

Member Avatar for woooee
0
282
Member Avatar for blah32

I am new to regular expressions, but I do not get why this is not working : [CODE] import re inputstr = "HI\n//asgwrg\nasdg" re.sub("\/\/(.*)(\n)", "\n", inputstr) [/CODE] I am trying to substitute everything between "//" and newline with newline. Can someone tell me whats wrong? I am using python 3.1

Member Avatar for jlm699
0
87
Member Avatar for smoore

Okay so when I open a file and I would like to pickle something to the file you are supposed to open the file in 'rb' (read binary) mode to load stuff from it. If you want to dump something the file is supposed to be in 'wb' (write binary) …

Member Avatar for jlm699
0
146
Member Avatar for vl4kn0

Hi, I have got a little problem with __setitem__ method. It works fine in single class, but if class member is instance of the same class method __setitem__ doesn't work on class member but on class. Here is an example: Here is a class with __setitem__ method: [code="python"] class MyClass: …

Member Avatar for vl4kn0
0
168
Member Avatar for Furtano

Hello, I want to use an new library i downloaded e.g. chilkat library ([url]http://www.chilkatsoft.com/python.asp)[/url], how do i do that ? I tried to put on the beginning of my code: [code=python] __path__ = ["dir_with_chilkat_pyd"] require chilkat [/code] but does'nt work. What i want to run: [url]http://www.example-code.com/python/http_loginForm.asp[/url]

Member Avatar for leegao
0
1K
Member Avatar for SuperMetroid

Why don't either of these implementations actually write to the file? Code v1: [CODE] txtfile = open('C:/Python31/SKUs.txt', 'w') with txtfile: num = 817 while num <= 820: x = "G" + str(num) print(str(x), end=" ") num += 1 txtfile.close()[/CODE] Code v2: [CODE]txtfile = open('C:/Python31/SKUs.txt', 'w') num = 817 while num …

Member Avatar for SuperMetroid
0
155
Member Avatar for fallopiano

Hi all. I'm having a bit of trouble (maybe it's easier than I think..) finding the lowest and highest number in a tuple of lists. Here is my main tuple: [CODE=python]list_of = ([0,7],[100,25],[150,59],[300,189]) [/CODE] so pretty much, I need python to return the lowest and highest number for each 'item' …

Member Avatar for snippsat
0
268

The End.