15,406 Topics

Member Avatar for
Member Avatar for pymatio

How would you count how many opening HTML tags there were & then closing tags in a line? eg [CODE] for line in something: for match in re.match("[I]opening_regex_here[/I]",line): # will match <H1> or <html> or whatever opentags += 1 for match in re.match("[I]closing_regex_here[/I]",line): # will match <H1> or </html> or …

Member Avatar for vegaseat
0
3K
Member Avatar for sravan953

I have a string, say for example: [CODE]str="aasd<script>"[/CODE] How do I make Python to note down one character at a time until it encounters the '<'? I know it has to be a loop, but which function? Thanks

Member Avatar for siddhant3s
0
106
Member Avatar for sravan953

Hey guys.... I use Python 2.6.2. I recently created a program which accepts commands from my website, here's the code I used: [CODE]import urllib import subprocess import time open_site=urllib.urlopen("http://www.sravan953.webs.com/command_python.htm") read_site=open_site.read() def run_program(): current=time.asctime() print 'Runnning program'+' ['+current+']' subprocess.call(read_site) def check_argument(): current=time.asctime() if read_site=='': print 'No command given'+' ['+current+']' timer() else: …

Member Avatar for vegaseat
0
164
Member Avatar for tomtetlaw

I am using pygame I want my program to read an image file that only has black on it and whenever the character moves over a part that has black on it, he stops moving, any ideas on how to get started? The black image is not to be shown.

Member Avatar for tomtetlaw
0
289
Member Avatar for pymatio

I have the following script: [CODE] import sys import os import re pages = [] if len(sys.argv) > 1: for root, dirs, files in os.walk(sys.argv[1]): for f in files: filename = os.path.join(root, f) if (filename.endswith('.html')) or (filename.endswith('.htm')): pages.append(filename) for page in pages: f = open(page, "r") count = 1 for …

Member Avatar for pymatio
0
122
Member Avatar for leegeorg07

Hi, is there an internal module / method to change the colour of the text in the pythonwin? I am asking this so that I can make more exciting text based games

Member Avatar for leegeorg07
0
2K
Member Avatar for sciguy77

Hi, I'm trying to build a web server in Python, and here is what I have so far: [CODE] Code: from http.server import HTTPServer, BaseHTTPRequestHandler class RequestHandler(BaseHTTPRequestHandler): def _writeheaders(self): self.send_response(200) self.send_header('Content-type', 'text/html') self.end_headers() def do_HEAD(self): self._writeheaders() def do_GET(self): self._writeheaders() self.wfile.write("""<HTML> <HEAD><TITLE>Sample title</TITLE></HEAD> <BODY>sample text</BODY> </HTML>""") serveraddr = ('', 8080) srvr …

Member Avatar for sciguy77
0
162
Member Avatar for njparton

I'm stuck trying to get mechanize working as part of a larger project I'm working on. I'm trying to logon to the following website which I am registered at (but not as "bob" as below obviously): [url]http://www.morningstar.co.uk/uk/membership/signup.aspx?loginType=1&lastvisit=%2fuk%2fportfoliomanager%2fportfolio.aspx%3fSite%3duk%26lang%3den-GB[/url] I think I've managed to select the correct form (?) but I'm getting …

Member Avatar for njparton
0
208
Member Avatar for yamman13

Hey I'm new here registered today. I've been trying to import some definitions from other .py files in the same folder, but for some reason IDLE wont recognize/ import them and keeps telling me they arent defined. I have tried From file import * and was wondering if my syntax …

Member Avatar for jlm699
0
68
Member Avatar for fellixombc

I'm brand new to python, so i need a bit help parsing. Why i need parsing? so my irc bot can reconignise me. here is my code: [CODE]#### # Made by Fellixombc # pythonbots.no-ip.org:8080 (coming soon) # Contact: Fellixombc@hotmail.com (add me on msn, I don't check my email's) # Copyright …

0
68
Member Avatar for infinitelygreen

Hello! I recently started learning Python, and I'm trying to install the package GASP ([url]http://pypi.python.org/pypi/gasp/0.4.5[/url]) in order to be able to code some graphics. However, the file is of type EGG. I found that I need to install EasyInstall in order to be able to install EGG files. (The download …

Member Avatar for infinitelygreen
0
96
Member Avatar for darkwing

Hi all, I'm trying to write a video player with wxpython and pygst. The main Frame has one panel and one notebook. On one page of the notebook, I need to play multiple videos at the same time. On this page, I declare two CameraPanel instances (code below) and put …

0
65
Member Avatar for leegeorg07

Hi, I have this code: [code=python] def yn(input): if input.lower == 'y': return True else: return False def limestone(): I = raw_input("are there shelly fragments? (y/n)") if yn(I): print "Shelly limestone" else: print "chalk" def crystals(): I = raw_input("Are the crystals big?(y/n)") if yn(I): big_crystals() else: print "Basalt" def big_crystals(): …

Member Avatar for leegeorg07
0
72
Member Avatar for poeticinsanity

I'm having a simple problem. I'm using this class to do some stuff with another module. Now, for some reason the self.database and other variables are not able to be accessed by the other methods. I thought _init_ was suppose to work as a constructor, thus the other methods should …

Member Avatar for poeticinsanity
0
90
Member Avatar for tomtetlaw

How do I search a string for anything? What I mean is, I need to say: [code=python] if line == 'playername = (any name)': temp = line.strip().replace('playername=', '') return temp [/code] Any ideas?

Member Avatar for jlm699
0
109
Member Avatar for max.yevs

Ok, so this is kind of a complicated question... but... Ok so I have a python script, you enter some numbers it gives you some numbers back that sort of thing. But of course right now it just looks like a black window with text. kind of like [URL="http://blog.benhall.me.uk/images/InstallingWindows2008EnterpriseCoreServe_F3A1/6Cmd.jpg"]this.[/URL] But …

Member Avatar for vegaseat
0
150
Member Avatar for codedhands

Hello everyone,i am pretty new to GUI programming,am currently playing around with PyQt4.I would like to know how the ui for yahoo was created.Because the controls provided by pyqt are just normal gray-colored stuffs.Could it be that those fancy control or widgets are graphical images done with photoshop,gimp etc? Please …

Member Avatar for scru
0
99
Member Avatar for EGG123

I need to take a text file of a number of gene sequences in fasta format eg >geneA agctactactacgatcgaacgtagctactactacgatcgaacgtagctactactacgatc gaacgtagctactactacgatcgaacgtagctactactacgatcgaacgtagctactact acgatcgaacgtagctactactacgatcgaacgtagctactactacgatcgaacgtagct actactacgatcgaacgtagctactactacgatcgaacgtagctactactacgatcgaac gtagctactactacgatcgaacgtactacgatcgaacgta and put it into: geneA agctactactacgatcgaacgtagctactactacgatcgaacgtagctac where all of the sequence is on one line. I can concatenate it in excel for one sequence but i have …

Member Avatar for woooee
0
105
Member Avatar for Stefano Mtangoo

Hi, I have never been into sockets, so I decided to dive in. With some help from devshed, I managed to make a server as shown below. But I cant get it receive data from client. Please correct me :) ERROR: socket.error: (10057, 'Socket is not connected') [CODE=python] import socket …

Member Avatar for Stefano Mtangoo
0
290
Member Avatar for vicky12345

[CODE]def who_knows(a, b): """ a and b are lists """ c = [] for i in a: if is_mem(b, i): c.append(i) return uniqify(c) def is_mem(a, elem): for i in a: if i == elem: return True return False def uniqify(arr): b = {} for i in arr: b[i] = 1 …

Member Avatar for JasonHippy
0
105
Member Avatar for max.yevs

this is another pretty simple question, but i've been trying to do it, and cant get it basically what i need is pretty simple, its like say you have a list of 5 numbers. now you need to print out all the lists of possible 3 numbers from those 5 …

Member Avatar for max.yevs
0
91
Member Avatar for max.yevs

im sorry this is kind of a silly question i know, but does anyone know any succesful ways to change a .py into a .exe? like so that someone without python installed on their computer can run it? i've seen this topic in a couple places but everything i've tried …

Member Avatar for max.yevs
0
175
Member Avatar for dingletoo

I am working on a script that will eventually run as scheduled via chron. This script will access ftp site and download most recent file added to directory. As I want this to be automatic, I wont have a file name to pass. How do I tell python which file …

Member Avatar for siddhant3s
0
65
Member Avatar for Summer_Intern

Hello, I am trying to embed a html file (a report from sql) in to a word document in a particular location. I am trying to get this done using the Office Interop. 1) How can I embed a html file in to a word document ? 2) How can …

Member Avatar for Summer_Intern
0
2K
Member Avatar for SoulMazer

So, I always thought that it was possible to return dictionaries in Python. I was wanting to do this because I would prefer not to use globals. However, I am having trouble with returning my dictionary. Code: [code=python] #!/usr/bin/python # 6/9/09 def loadWords(): pathstart = "/home/foo/Documents/PyScripts/Vocab/Lists/" print "What is the …

Member Avatar for jlm699
0
104
Member Avatar for njparton

I've been tearing my hair out for 2 days over this, hopefully someone here can help me. I'm trying to scrape the price data off the following webpage: [URL="http://www.morningstar.co.uk/UK/snapshot/snapshot.aspx?lang=en-GB&id=F0GBR04S4X"]http://www.morningstar.co.uk/UK/snapshot/snapshot.aspx?lang=en-GB&id=F0GBR04S4X[/URL] The value I want currently stands at 6.19 (i.e. the NAV value on the right hand side). I currently have a …

Member Avatar for njparton
0
202
Member Avatar for Jarmok

Hi all, I'm developing a system in Python. When the app has been a time running, its CPU consumption goes from 10% to 96% and stays there until I close it. Has anyone been in this situation and has a clue to solve it? My program uses Threads, pyserial and …

Member Avatar for sneekula
0
52
Member Avatar for mg0959

I am using the OptionMenu with Tkinter. I have found that sometimes when I use the OptionMenu widget, I encounter a problem. After the user clicks on the OptionMenu and selects an option, sometimes other widgets such as buttons in the window will not work until the user clicks somewhere …

Member Avatar for sneekula
0
79
Member Avatar for TerabyteST

Hello. I'm having trouble about drawing a border around a listctrl [code]"""Main module for psutils GUI""" __version__ = "$Revision: 8 $" # $Source$ import random import wx import psutil ID_EXIT = 110 class MainGUIFrame(wx.Frame): """Main frame. Shows processes and graph""" def __init__(self): """Initialization of the frame""" wx.Frame.__init__(self, None, -1, "psutils", …

Member Avatar for TerabyteST
0
348
Member Avatar for sravan953

Hey guys.. I have been making a random password maker, which makes a password of 8 characters length, but I am encountering a problem. Here'e the code I used: [CODE]import random list=['a','b','c','d','e','f','g','h','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','!','@','#','$','%','^','&','*'] randlist='' a=1 def password(): while a<=8: randlist+=random.choice(list) a+=1 return password() print randlist print 'Are you satisfied with your …

Member Avatar for lllllIllIlllI
0
121
Member Avatar for zoro007

Hello, I have file name is file.txt inside it this lines line1=hello world line2=hello web line3=hello egy I want print full lines start with line2= like in linux command cat file.txt | grep "line2=" this code will print full line --> line2=hello web And if any one have books in …

Member Avatar for siddhant3s
0
127
Member Avatar for bhanu1225

Hello All Can crystal reports be generate in Python ? Any suggestions plz??

0
58
Member Avatar for jayrodau

I would appreciate if someone could point me in a direction for setting up a publish and subscribe for udp. Here is a brief description of what I am looking for: As we know, UDP allows directly sending message and receiving message without establishing any connection.A UDP protocol is used …

0
43
Member Avatar for hughesadam_87

Hey everyone, I wrote a code which runs a game of rock paper scissors, and each time you lose, it counts down until at 0, it exits. The only way I've been able to exit the code is to throw in a 'sys.exit()' command. I hear there are better ways …

Member Avatar for hughesadam_87
0
150
Member Avatar for sravan953

I have a file, called 'html.html', which contains 'open_skype' in the first line and in the second line it contains the location of the file. Now, what I want to do is, make a function read the first line and then the second line should be read separately....if you don't …

Member Avatar for vegaseat
0
8K
Member Avatar for Aestter

Right. Basically I'm new to Python ( Go on call me a noob) and I'm trying to make a program that will open certain programs when you give the right password. But i just can't seem to get it to open the right files. So far, I am only trying …

Member Avatar for sravan953
0
171
Member Avatar for amadain

Hi I wonder if someone could point me in the right direction. I used the following code to access gmail but I got a urllib2.URLError: <urlopen error unknown url type: 'http> error when I ran it. I have included the Traceback import twill, string, os b=twill.commands.get_browser() b.set_agent_string("Mozilla/5.0 (Windows; U; Windows …

0
85
Member Avatar for sravan953

Hey guys.... I want to make a program which reads the HTML code from my blog, saves the HTML code as a string, so that I can check if specific words are present in the HTML code, here's the code I used: [CODE]import urllib import string open_site=urllib.urlopen('http://www.sravan953.blogspot.com') read_site=open_site.read() value=str(read_site) for …

Member Avatar for sravan953
0
170
Member Avatar for akindo

Hi all. I am new to Python and have a problem regarding data structures. In my application I will be having several messages and my own type of IDs (Lamport clocks) to go with these messages. I will need to frequently ask for specific messages based on the ID. Hence …

Member Avatar for akindo
0
139
Member Avatar for sravan953

Can anyone teach me how to create a function which when called shuts down the computer, or opens an image or video and so on?

Member Avatar for dads
0
158
Member Avatar for max.yevs

yet another ridiculously simple question, yet i feel compelled to ask because i've been stuck here for like an hour without it working ok so say you have one list, a, and you need the user of the program to input a list of several more numbers, call that list …

Member Avatar for shadwickman
0
174
Member Avatar for rope78

Hi all, I have a rather conceptual Python question. I have written a client - server application, using sockets. So far, I'm not using any database nor file, everything is held in server's variables. Now I need to make some kind of web interface for the server - for a …

0
62
Member Avatar for jen638

I am trying to write a program that generates a list and a random number on 3 seperate occations, then checks the list to see if the number is in the list, all the while, timing the procedure( Python code) 1st list is 1-100, 2nd list is 1-1000, third list …

Member Avatar for slate
0
161
Member Avatar for max.yevs

quick question i have come across, i can't find a definition for it perhaps i'll have to make a couple lines to define it? anyways for list a, which has only integers, i need to define the average, x... so i'm looking for something quick to do this: [code=python] >>>a …

Member Avatar for max.yevs
0
164
Member Avatar for zoro007

Hello, I want do somthing in python equal this code in bash For example the file.txt in it "dani_web_the_best" and want print "web" cat file.txt | cut -d"_" -f2 What equal cut -d"_" -f2 in python ?

Member Avatar for zoro007
0
110
Member Avatar for Wraithan

[code=python] class Item: def __init__(self, id, content, userid, duedate, collapsed, inhistory, priority, itemorder, faded, projectid, checked, datestring): self.id = id self.content = content self.userid = userid self.duedate = duedate self.collapsed = collapsed self.inhistory = inhistory self.priority = priority self.itemorder = itemorder self.faded = faded self.projectid = projectid self.checked = checked …

Member Avatar for slate
0
1K
Member Avatar for sravan953

Hey guys..... I have a small program which I created called 'password.py'....I wanted to share it with my friends and so on.....which is why I installed Py2exe. But it doesn't seem to work, I've used this code: [CODE]from distutils.core import setup import py2exe setup(console=['password.py'])[/CODE] and saved it as 'compiler.py'. I …

Member Avatar for Stefano Mtangoo
0
87
Member Avatar for seamonkie

[CODE] from math import sin, cos, pi import pygame displayWidth = 640 displayHeight = 480 fpsLimit = 90 def sinInterpolation(start, end, steps=30): values = [start] delta = end - start for i in range(1, steps): n = (pi / 2.0) * (i / float(steps - 1)) values.append(start + delta * …

0
40
Member Avatar for mindfad

[code]from psychopy import visual, core, misc, event import numpy #for maths on arrays from numpy.random import random, shuffle #we only need these two commands from this lib from random import * import math win = visual.Window([1024,768], units='pix', monitor='testMonitor',rgb=(-1,-1,-1)) numbers = range(100) #range of stimuli to be generated or how many …

Member Avatar for mindfad
0
208
Member Avatar for fatbob

Hi all I am new to programming and python and am having trouble reading particular strings from a text file and writing them out to a separate file. The file has a large number of lines, has the following format and is interspersed with signature sentences i don't need: subdoc="Book=2:chapter=1" …

0
71

The End.