15,406 Topics

Member Avatar for
Member Avatar for gunbuster363

I am using BeautifulSoup for my project and I don't know how the object returned by the Soup is organized, so I don't know how to access it, except using only print I can only do this: [CODE]link = soup.find(attrs={'class' : re.compile("util2$")}) print link [/CODE] it print out the whole …

Member Avatar for gunbuster363
0
2K
Member Avatar for jaymeaux77

Hi there, Im writing a program that takes a function and makes a plot of it. the program consists of 2 functions and each creates its own GraphWin. However i want to have a mouse click at the end close both windows. So i returned the window from the first …

Member Avatar for jaymeaux77
0
99
Member Avatar for lllllIllIlllI

Hi, Im using wxPython for my latest project and i was wondering, how do i make the window go to the best size, so it includes all of the objects on screen? I used to be able to remember... but i forgot :P

Member Avatar for lllllIllIlllI
0
87
Member Avatar for pythopian

PlugIns in their simplest form can be just python modules that are dropped into some designated directory and dynamically loaded by the main application. This snippet can be used to do just that. [B][U]Usage[/U][/B] To load plugin modules: [CODE]>>> plugins = importPluginModulesIn('mypackage') >>> plugins {'foo': <module 'foo' from 'mypackage\foo.py'>, 'bar': …

Member Avatar for pythopian
2
828
Member Avatar for relb.test

So here's the problem. I have sample.gz file which is roughly 60KB in size. I want to decompress the first 2000 bytes off this file. I am running into CRC check failed error cuz I guess the gzip CRC field appears at the end of file, and it requires the …

0
56
Member Avatar for lllllIllIlllI

Hi guys, Im a making a program where i need to be able to specify a folder and have my program import every module from that folder into my program... I was wondering how i would go about it. I can't use something like eval. But yeah, help would be …

Member Avatar for pythopian
0
14K
Member Avatar for leegeorg07

Hi I have this code currently: [code] dict = open("dict.txt", "r").readlines() print dict LETTERS={'a':1, 'b':2, 'c':3, 'd':4, 'e':5, 'f':6, 'g':7, 'h':8, 'i':9, 'j':10, 'k':11, 'l':12, 'm':13, 'n':14, 'o':15, 'p':16, 'q':17, 'r':18, 's':19, 't':20, 'u':21, 'v':22, 'w':23, 'x':24, 'y':25, 'z':26} word_value=0 lettersv=[] letterss=[] def main(): word=raw_input('what is the word?') word=word.lower() for …

Member Avatar for leegeorg07
0
116
Member Avatar for A_Dubbs

Hey guys, I was wondering if you could clear up some things on classes for me. I have had a semi-easy time understanding python and programming concepts up to this point but now am having a real tough time on classes. I think it is because my book uses long …

Member Avatar for bumsfeld
1
232
Member Avatar for sanchitgarg

suppose i have 10 different functions. i generate a random no. between 1 to 10. depending on its value i want to call the fucntion. eg. no. 3 call func, no. 8 calls func 8... etc. how do i do it using a loop without using the if else statement …

Member Avatar for sanchitgarg
0
244
Member Avatar for TheManual

I am trying to create a RPN calculator, the addition and subtraction functions work but it only accepts numbers under 10. How can I fix this so any integers are allowed? Thanks. [code] import sys accepted = '0123456789dr+-*/%^=' numbers = '0123456789' stack = [] while len(stack) <= 20: while True: …

Member Avatar for TheManual
0
92
Member Avatar for gunbuster363

Here is my code. If I use forloop to write, it got error: Traceback (most recent call last): File "m.py", line 20, in <module> f.write(tag[i].string) TypeError: argument 1 must be string or read-only character buffer, not None HOWEVER, if I don't use for loop, instead write as : f.write(tag[1].string) it …

Member Avatar for gunbuster363
0
151
Member Avatar for Mona1990

Hi I was wondering if someone could help me to figure out how to write a code for : Write a function print_table which consumes two parameters, a list of list of strings, and an integer for the length of the list. The function should print out the strings from …

Member Avatar for Mona1990
0
300
Member Avatar for mahela007

What would it take to make graphics show on the monitor without using stuff like tkinter and Qt? (tkinter and Qt are called toolkits right?)

Member Avatar for mahela007
0
261
Member Avatar for gunbuster363

I want to create a file and open it and write on it with f= open('out.txt', 'a') then it got error: File "m.py", line 10, in <module> f=open('./out.txt', 'a') IOError: [Errno 13] Permission denied: './out.txt' What happened?? I am using opensuse and was using a user account to edit and …

Member Avatar for gunbuster363
0
124
Member Avatar for leegeorg07

Hi I have been trying to use the python subprocess module but I find the documentation for 2.6.4 vague, does anyone else know of good tutorials for it? thanks in advance

Member Avatar for leegeorg07
0
95
Member Avatar for XLL

Hi all,I got a issue that how can I run several functions at same time? say [CODE] a=1 def function1(a) a+1 return a def function2(b) b+2 return b def plotGraph(a,b) return graph [/code] how can I just run plotGraph function here?..I am totally newb..hope anyone can help..thanks

Member Avatar for pythopian
0
115
Member Avatar for jex89

Hi, I don’t know if anyone would be able to help me with the following problem, I am hoping :D .. I have looked on the internet but no look. I have pickled a document into the pickle object, how can I now search the pickled object to remove a …

Member Avatar for pythopian
0
3K
Member Avatar for calccrypto

I wrote my own sha implementations but i cant get them to read files correctly. i know to use [CODE]open(file,'rb').read()[/CODE] as the input into the algorithm, but [CODE]import hashlib hashlib.sha1(open(file,'rb').read()).hexdigest()[/CODE] and my code [CODE]sha_1(open(file,'rb').read())[/CODE] return two different hashes. any idea why? i know that a normal string will have the …

Member Avatar for mn_kthompson
0
148
Member Avatar for jaison2

The function should ask the user for the price of the delivery and if the price is less than £10 then it should print a statement saying "the total price including the delivery charge is" + £1.50 or it should just output the normal price if it is more than …

Member Avatar for snippsat
0
224
Member Avatar for XLL

Hi all, I am a newb, got a simple question, anyone can give any idea about it will be great,thanks in advance. a=2 b=3 def functionA(a,b): c=a+b return c def functionB(c) answer=c+1 return c but this code doesnt work....what I want is just assign functionA as one of the argument …

Member Avatar for jlm699
0
82
Member Avatar for Garee

I'm having a little trouble with a piece of code im trying to write. I have created a deck of cards and then shuffled them however now I am trying to covert my deck (which is simply a list containing the numbers between 1 and 52) into the form "AS", …

Member Avatar for vegaseat
0
346
Member Avatar for zyrus001

I though it'll be interesting to look at threads and queues, so I've written 2 scripts, one will break a file up and encrypt each chunk in a thread, the other will do it sequentially. I'm still very new to python and don't really know why the treading script takes …

Member Avatar for Gribouillis
0
266
Member Avatar for sentinel123

Hello This is like my 4th week using Python and I'm still not familiar with it so I might need some help from you guys. I gotta write a little Connect 4 game in Python, I just got started and boom - I'm stuck! I tried to create a board …

Member Avatar for sentinel123
0
2K
Member Avatar for nirah_pooh

hi all May i know if anybody already use Clamwin binaries to develop an antivirus software? i need some ideas how to built clamwin binaries. All of the instruction given by I'm already followed [url]http://wiki.clamwin.com/index.php/Building_ClamWin[/url]. I got problem to make patch for wxPython. How to make a patch? From the …

Member Avatar for Gribouillis
0
171
Member Avatar for rbushlow

I have the following python code to access a MySQL database: [CODE] #!usr/bin/python # server_version.py - retrieve and display database server version import MySQLdb con = MySQLdb.connect (host = "localhost", user = "username", passwd = "password", db = "test") cursor = conn.cursor () cursor.execute ("SELECT VERSION()") row = cursor.fetchone () …

Member Avatar for rajasekhar1242
0
182
Member Avatar for james27

Hello all, im making some script with python mechanize, one of problem is it really hard to find which support javascript supported web client scraping or crawler. actually i was found some such as python-spidermonkey and pykhtml and so on. but most of all only support on linux . i …

0
65
Member Avatar for vansoking

[CODE]#! /usr/bin/env python #filename:pwd.py # development environment:python2.51 import getpass usr=getpass.getuser() while True: pwd=getpass.getpass("passwd:%s:" % usr) if pwd=='123': print "welcome to python!!!!" break else: print "The password you entered is incorrect" [/CODE]

Member Avatar for vansoking
1
399
Member Avatar for sanchitgarg

I have to write a code for generating random numbers without using random module and its function. How do I do it? I tried using the system time as it keeps on changing (importing milli seconds) but with tht I am able to get random nos in the range of …

Member Avatar for sanchitgarg
0
9K
Member Avatar for denniskhor

I want use MD5 to compare both folder in Python. Following steps that i want to compare both folder by using MD5: 1. After all the files downloaded to folderA. 2. All the files inside folderA will copy to folderB. 3. Then MD5 will compare both folder is correct hash. …

Member Avatar for vansoking
0
1K
Member Avatar for ihatehippies

Anyone know the developers? Anyone else waiting for 3.x support? This is the only thing keeping me from upgrading to python 3.1 ....

Member Avatar for vegaseat
0
111
Member Avatar for jex89

Hi, I am undertaking a peice of work and may need a bit of help. The problem i need to find a solution for is as follows - I am requesting a Text based document through a http request, and currently have the document i want from the http request. …

Member Avatar for jlm699
0
75
Member Avatar for Xydric

Hi Guys and Gals! I come to you today requesting assistance! Let me explain what I am trying to do first, and then I will show you my code. The purpose is to read a list of regular expressions in from a text file (one regex per line, only about …

Member Avatar for jlm699
0
111
Member Avatar for leegeorg07

Hi, i currently have these 2 files: [code] #!C:\Python26\python.exe #index.py print 'Content-type: text/html\n\n' print '<html><head>' print '<title>My Page</title>' print '</head><body>' print '<h1>Powers of two</h1>\n<ol>' print '<form action="sqr.py" method="post">' print '<label>How many numbers?</label>' print '<input type="text" name="b"/>' print '</ol></body></html>' [/code] and [code] #!C:\Python26\python.exe #sqr.py import cgi a = cgi.FieldStorage() b = …

Member Avatar for leegeorg07
0
255
Member Avatar for TheManual

I have managed to create a custom sized grid which prints correctly but when I try and print X or 0 a new line is started. Please see the "test" result below. [code] def createBoard(): global rows,columns,board rows = input("How many rows (more than 4)? ") columns = input("How many …

Member Avatar for TheManual
0
323
Member Avatar for Danman290

I'm new to this forum and to python in general, so be easy on me please. :icon_smile: I'm making a class to handle all events including mouse events. (I'm using pygame by the way) Heres how it looks so far: [CODE] class Event: #controlls all actions relating to events including …

Member Avatar for Danman290
0
16K
Member Avatar for lookatmills

If I have a text file that contains strings and integers such as: Alabama 3200 Denver 4500 Chicago 3200 Atlanta 2000 what code could I use to print the smallest number (2000) after reading in that textfile. I know I first have to split the text so I'm just operating …

Member Avatar for pythopian
0
71
Member Avatar for persianprez

I should be getting this as my output, but it keeps going through each result: [CODE]10 -> 5 -> 16 -> 8 -> 4 -> 2 -> 1 ; length = 7 11 -> 34 -> 17 -> 52 -> 26 -> 13 -> 40 -> 20 -> 10 -> …

Member Avatar for persianprez
0
125
Member Avatar for figved

I have written a script for scraping a web site, and it works fine. What does not work fine, is when I try to use the write function, to write the results to a txt-file. I am trying to run this: import BeautifulSoup, urllib2, re, time import codecs path='C:/Users/Me/Documents/Python' outfile=open(r'C:/Users/Steinar/Documents/Python/Vegvesen/vegresultat.txt', …

Member Avatar for pythopian
0
322
Member Avatar for pythopian

This is one simple way to emulate a singleton class on behalf of a normal class. (A singleton class is a class with at most one instance.) The implementation does not emulate a class 100% (for example it lacks the special attributes lile __dict__ or __bases__), but it should be …

2
235
Member Avatar for xm1014

Hello everyone, I'm learning Python and I have a few questions about Dictionaries and sorting them by a value other than the key. Lets say, for example, I have a Dictionary full of data that needs to be sorted on the 3rd value instead of the key. How would I …

Member Avatar for vegaseat
0
445
Member Avatar for pyprog

I have a file of the following format: a 1 a 2 a 3 b 4 b 5 b 6 c 7 c 8 c 9 Here is my code: [CODE]def file_to_dict(fname): f = open("file.txt") d = {} for line in f: columns = line.split(" ") letters = columns[0] numbers …

Member Avatar for pythopian
0
1K
Member Avatar for pyguy420

i have to write a rock paper scissors program in python, but every time i run my code... [CODE]def rockPaperScissors(): import random computerIndex = random.randint(1,3) if computerIndex == 1: computer = "rock" elif computerIndex == 2: computer = "scissors" else: computer = "paper" player = raw_input("rock, paper or scissors :") …

Member Avatar for vegaseat
0
83
Member Avatar for sneek

Hi, may anybody tell me what "initializes the interpreter" mean in detail? Does this function starts a new process or thread of the python interpreter in the background or what does this call do?? Hopefully somebody can give me a little hint :) Jonny

Member Avatar for sneek
0
309
Member Avatar for rasizzle

Hi all, I want to take this code: [CODE]list_in_list = [[1,5,13,30,-4], [1,5,10,30,-4], [1,5,15,30,-4], [1,5,9,30,-4], [1,5,16,30,-8]][/CODE] and sort it by the 3rd item in each sublist (list_in_list[x][2]) I'd like to do it by the highest number so my output would be: [CODE]sorted_list_in_list = [[1,5,16,30,-8],[1,5,15,30,-4], [1,5,13,30,-4],[1,5,10,30,-4], [1,5,9,30,-4]][/CODE] Any help or suggestions?

Member Avatar for vegaseat
0
122
Member Avatar for pyprog

I have a dictionary like {"a":["b", "c", "d"], "b":["h", "i", "j"], "c":["k", "l", "m"]. I need to write a function that returns True if a requested key has requested value. Also, if "a" has "b" and "b" has "h", "i", and "j", then "a" has "b", "c", "d", "h", "i", …

Member Avatar for masterofpuppets
0
133
Member Avatar for Onkel Bob

I am new to programming (but not to the concepts) and I need to process some .csv files. Here's what I have: The files containing Cartesian coordinates, XYZ of various "polygons." (They are cell perimeters of a mouse embryo) The polygons are in quotes because they are not closed, and …

Member Avatar for Onkel Bob
0
102
Member Avatar for LB22

Hi, I'm stuck with a certain problem. I'm using URLLIB2 to get the end url of a list of links. This was pretty straightforward. Some of the links I'm probing pass through 1 or more other urls before landing the user at the end destination. For example, the start url …

Member Avatar for pythopian
0
151
Member Avatar for kepra78

Hi, I'm a newbie! I'm writing because I have a question about wxpython and trasparency... I'm trying to design a visible frame with a trasparent window inside it (think about a sort of "window" in which you can see the desktop). With SetTrasparent() on the wxFrame the entire frame becomes …

0
49
Member Avatar for plzhelp

is it possible to search a multi dimensional list for a certain letter then print out where that letter is? i know u can use list.index() to find a letter but i could figure out how to do it with multi dimensional lists. thx in advance

Member Avatar for pythopian
0
93
Member Avatar for masterinex

Hi guys , Im new at pythons . Hope you all can help me out here : Im trying to write a code which prints the elements from every list as a line . so If my lists are : l1 = ['0000002', '0000003', '0000004', '0000005', '0000008', '0000009', '0000010'] l2 …

Member Avatar for masterinex
0
290

The End.