14,949 Topics

Member Avatar for
Member Avatar for yuguang

My program doesn't make it pass these lines on one computer: [code] import re, os, glob, time os.chdir('/Software/xampp/htdocs/catalog/temp') file_list = glob.glob('Full-EP*.txt') file_dict = dict([(os.stat(a_file).st_mtime, a_file) for a_file in file_list]) date_list = list([key for key, value in file_dict.items()]) s = file_dict[max(date_list)] datePattern = re.compile(r'^Full-EP(\d{4})(\D{3})(\d{2})-(\d{2})(\d{2}).txt$') webdate = datePattern.search(s).groups() metadata = os.stat('WEB-Price-List.txt') dbdate …

Member Avatar for yuguang
0
115
Member Avatar for Stefano Mtangoo

I have read a little bit on XML and I will need it to get some information from already available XML files. I would like to learn it by making very small playlist. However I have encountered the two beasts. I don't know much of XML, especially with python. So …

Member Avatar for Stefano Mtangoo
0
126
Member Avatar for chrischavez

hello im not very experienced with python so sorry for any bad code i am running ubuntu 8.10 and using pyserial i have made a script that reads the serial input from an arduino if you are not familier with an arduino here is there website [URL="http://www.arduino.cc/"]http://www.arduino.cc/[/URL] for some reason …

Member Avatar for woooee
0
195
Member Avatar for darangho

Hi, all Is there a way to get strings line by line from tk Text box? I know there is readline for files, but i don't see anything like that for tk Text box. Only thing i see is text.get(float(index1), float(index2)) but it seems unhelpful in my case, although it …

Member Avatar for bumsfeld
0
127
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
89
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
120
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
103
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
149
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
235
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
423
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
229
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
90
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
207
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
86
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
145

The End.