15,181 Topics
| |
| Hey guys, I have made a program called 'tLapse', here's the code: [code='python'] import subprocess import time import os print("Welcome to tLapse...") time.sleep(3) os.system('cls') try: com=open("action.txt",'r').read() condition=True except: print("File error") raw_input("<Any key to quit>") condition=False if(condition): clock=raw_input("Enter time duration after which\nuser-specifiedaction will be\npeformed.\n\nFormat- [hh:mm][24- hour format]: ") def app(path): ext=path[-3:] … |
I'm a newbie to python. After opening a file in 'r' mode then using the approach below. f = open( '/g.txt','r') for line in f: I find a pattern I'm looking for in a text file. Then I use f.tell() to record the file position. However, I think due to … | |
Hi all. I'm new to the forum, this is my first post =) I'm trying to create a list containing 3^10 lists, each list has 10 string. Each string can be of 1 or 3 types, for simplicity let them be 'a', 'b','c'. So basically I wish to generate all … | |
Its long now I try to understand wxPython's print frame work. Every effort have fallen apart. I just cannot understand how it works. I have tried to google with no avail. wxDemo is too painful to swallow :( I request anyone familiar with framework to give me a jump start … | |
I'm trying to develop a simple script that will keep the scores of a cricket match. In my script I want the __init__ method on one class to create an object of another class. here's an example. [code=python] class Person: def __init__(self,name): self.name = name class clubMember: def __init__(self,name): New_clubmember … | |
Why does this make sense in 3.1? [code]>>> a = b'\x01\x02' >>> a[0] 1 >>> a[0:1] b'\x01' >>> a[0] == a[0:1] False >>> a = '\x01\x02' >>> a[0] '\x01' >>> a[0:1] '\x01' >>> a[0] == a[0:1] True[/code] Shouldn't we get True for both comparisons? | |
| |
I am trying to replace a section of code within a series of php files. I open the files, read the contents into a "sourcecode" variable and locate a section of code. I then capture this section in a variable like this: [code=python]phpsection=sourcecode[phpstart+2:phpend][/code] The problem is after I locate this … | |
Hello, I am a python newbie and I am trying to accommodate to the basics. What's the python equivalent for the following Java snippet ? [B]Java:[/B] [CODE]public class Main { public static void main(String args[]){ int a,b,c; a= (int) (Math.random()*100); c=0; while((b=(int)(Math.random()*100))!=a){ c+=1; } System.out.println(c); } }[/CODE] I was trying … | |
Hi, the following project is the first small step in an anagram solver that I am coding. I have four letters "a", "b", "c", "d" and the aim of the following code is to produce all possible permutations of these letters, given that the first letter is always "a". (I … | |
this is a software that you ill have to login ells i will shut-down i used the threading so the Tk gui.would keep on going but it wont stop after 0. its not a problem its just iterating me knowing its in the background. so is there any way to … | |
Hello. I have a (main) list of objects 'feedbacks' which have an 'order_id' and a 'message'. I have another list of simply 'order_id's whose correspondent object in the main list I would like to see removed. For example: main list: [object type 'feedback', object type 'feedback', object type 'feedback'] let's … | |
Hi all, I'm learning python and hope someone can help me with a sort of tricky search/parse problem. I have a tab deliminited file like this: 2 1 863.8 300.2 0.0131 0.0759 0.1727 0.0879 1.5821 3 1 874.5 289.5 0.0574 0.1292 0.4447 0.2258 1.1846 3 2 874.5 289.5 0.0573 0.0527 … | |
| Hey guys, I am making a program called 'Weather Watch' which basically gets weather updates for any city you type in. For now, it only gets info for a particular city. I don't know how to search for the term entered in [url]www.weather.com[/url] and then get the updates. The code … |
Hey everybody im currently rewriting my game from an engine into opengl and pygame and im not sure how to use opengl with pygame here is what i have done so far =) [CODE=python] from sys import path,exit,argv ; path += ['.'] import wave, pymedia.audio.sound as sound from OpenGL.GL import … | |
| Hey guys, I have some code: [code='python'] import urllib2 as url import subprocess import os webs=open("url.txt",'r') read_webs=webs.read() def get_html(): try: req=url.urlopen(read_webs) res=req.read() return True except: print("<Error reading from the website>") def get_command(): if True: for x in res: if(x!='<'): command+=x else: break determine() command="" def determine(): format=command[len(command)-3:] print format get_html() … |
Hi, I´m new to Python and right now I´m trying to learn to parse a text. Here is my code (that doesn´t work the way I want) [CODE]text = ['Mary', 'went', 'out', 'at', '7pm', 'to','buy','some','candy'] keyPerson = ['Mary', 'Clark', 'Steven'] keyTime = ['7pm', '6am', '2pm'] keyThing =['candy','eggs','fruit'] list = [] … | |
When several producer threads put items in a queue.Queue, and a consumer thread gets items from the queue, there is no way for the consumer thread to tell the producers that they should stop feeding the queue. This snippet defines a subclass of Queue with a close method. After the … | |
I am trying to figure out the best way to deploy a python script that I wrote. Many of the users wont have python on their machines but might want to make slight alterations to the script. What I was thinking about doing was using Py2exe to compile a script … | |
Hi, I'm new to python, but I want to start learning :) I just wondered if anyone could tell me how to use a variable from a function outside the function? | |
Hi please help me to install libxml2-2.7.1 and libxslt-1.1.24.tar.gz fot python 2.5.2. When i try to install libxml2-2.7.1, i gets installed but when i import the libxml2 in python interpreter then i get the following error: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "libxml2.py", line … | |
Hello! I need to create a progress bar and up to this our this class [URL="http://code.activestate.com/recipes/492230/#clast"]http://code.activestate.com/recipes/492230/#clast[/URL] is the best class that fits my needs. I posted my problem at comments. Thanks, Danci Emanuel | |
Hi, I have installed "MySQL-python-1.2.2" in my CentOS 5.3 server using "python setup.py install" command. It is giving me the error as : Traceback (most recent call last): File "setup.py", line 5, in <module> import ez_setup; ez_setup.use_setuptools() File "/home/installars/MySQL-python-1.2.2/ez_setup.py", line 85, in use_setuptools import setuptools; setuptools.bootstrap_install_from = egg zipimport.ZipImportError: can't … | |
Hi all. I would like to be able to parse some data from a password protected site. The parsing of the data is already developed and tested (I manually logged in to the site and downloaded the source code for testing purposes). I am stuck at the log in part. … | |
Okay, so, my main problem here, is that I can't get my parameters from my function name to work with the other variables from the function. Here's the code: [CODE] def next_block(x): p1 = 2 p2 = 2.3 p3 = "c" p4 = "String" p5 = "3.4444" return p1, p2, … | |
Okay, I'm done with making a lot of threads with nooby quesions. Those were just some things in the back of my mind. But that's not the point. Here's a program that generates a random 8 character string. It consists of letters A-Z, a-z, and 1-9. There's 767,544,201,216 possible combinations. … | |
Hi guys, I've a problem calling a 'parent' PyQt4 method from inside an object that inerits it. Here is the code: [ICODE] import sys from PyQt4 import QtCore, QtGui class ItiaQPushButton(QtGui.QPushButton): def __init__(self, txt): super(ItiaQPushButton, self).__init__("Hello") print super(ItiaQPushButton, self).__doc__ #QtGui.QPushButton.setText("BO") def setText2(self, txt): self.setText(txt) #super(ItiaQPushButton, self).setText("PROVA") class Window(QtGui.QWidget): def __init__(self, … | |
Is it possible to run a .py file on a computer that doesn't have Python installed? I'm asking this because I was messing around with py2exe and noticed that every time I built an executable, it would create a 'python26.dll' along with some other files. I was wondering, if I … | |
Okay, I have yet another question that I could not find.I noticed that you can't set variables in for loops without having to do something (like in batch). I've tried googling it and doing a site search, I have gotten no results. So what would the code or command be … | |
I'm trying to open a usb webcam via Python. Can anyone give me a hint how to do that? Thanks, Shawn |
The End.