Posts
 
Reputation
Joined
Last Seen
Ranked #902
Strength to Increase Rep
+4
Strength to Decrease Rep
-1
100% Quality Score
Upvotes Received
5
Posts with Upvotes
4
Upvoting Members
4
Downvotes Received
0
Posts with Downvotes
0
Downvoting Members
0
4 Commented Posts
0 Endorsements
Ranked #718
~10K People Reached
Favorite Forums
Favorite Tags
Member Avatar for knan

I have a dictionary [CODE]dict1={'18':['4000','1234'],'12':['7000','4821','187','1860','123','9000']}[/CODE] I want to sort the keys and values such that, the output is, [CODE]dict1={'12':['123','187','1860','4821','7000','9000'],'18':['1234','4000']}[/CODE] I tried something! but it didn work [CODE]>>> for values in dict1: ... dict1[values].sort() ... >>> dict1 {'18': ['1234', '4000'], '12': ['123', '1860', '187', '4821', '7000', '9000']}[/CODE] Full sorting happens for …

Member Avatar for grantjenks
0
805
Member Avatar for Banjoplucker

[url]http://paste.pound-python.org/show/941/[/url] Having trouble getting a loop to write to a series of newly created sequential blank .wp files. Grateful for any help, thank you. Regards & a Happy New Year! Banjoplucker.

Member Avatar for djidjadji
0
107
Member Avatar for yond

How does incrementing the variable count by the recursive call to the function, save count from being reset to zero everytime it is invoked? I am trying to get a firm understanding of how recursion works. [CODE] def countSubStringMatchRecursive(target,key): """Searches for instances of the key substring occuring inside the target …

Member Avatar for TrustyTony
0
97
Member Avatar for novice20

Hi... I have a set of strings as below: [CODE]4:14.4-17M,5:14.4-2e13M,6:14.4-4e9M,7:14.4-8e,22:28.4-35M,23:28.4-2e30M,24:28.4-4e26M,25:28.4-8e18M,26:28.4-16e2M,27:28.4-18e,28:14.16-36M,29:14.16-2e32M,30:14.16-4e28M,31:14.16-8e20M[/CODE] I want everything after the ':' to be discarded. i.e., i just want a list of what preceeds ':' (4,5,6,7,22,.................) How can this be done?

Member Avatar for novice20
0
106
Member Avatar for rotexhawk

I get the following error from running this code. Was wondering if 'i' and 'j' are considered objects. If yes is there any way i could cast them..... How do i write a better for loop for this.... array2D = [[0 for i in range(10)]for j in range(10)] for i …

Member Avatar for djidjadji
0
204
Member Avatar for hughesadam_87

Hey guys, I've been trying to solve this problem many ways now, and am really just not familiar enough with the language to see an elegant solution. I have a dictionary, where each value is itself a list of lists. For example: [CODE]keyA:([x1,y1,z1], [x2,y2,z2] etc...) [/CODE] Within a key, I …

Member Avatar for djidjadji
0
372
Member Avatar for tillaart36

Hello, im trying to implement a template matching algorithm with the use of Python + PIL and I'm trying to follow the code that wikipedia gives for template matching -> [URL="http://en.wikipedia.org/wiki/Template_matching"]http://en.wikipedia.org/wiki/Template_matching[/URL] Basically it loops through all pixels of a search image, and all pixels of a template. The sum of …

Member Avatar for vegaseat
2
3K
Member Avatar for kadvar

Hi, I'm trying to match patterns of the types sentence1 = "keywords=walter&keywords=scott" sentence2 = "keywords=john&" sentence3 = "keywords=james&keywords=john&keywords=brian&" so basically the keywords=somestring& part can be repeated once or multiple times. I am trying to extract the string(s) between '=' and '&'. I have come up with the following so far. …

Member Avatar for woooee
0
86
Member Avatar for AutoPython

Okay, I was thinking about making an encryption algorithm, now the thing with most algorithms is that they follow specific steps. Well, I was thinking, what if you made an algorithm that generated random characters (the kind you see on your keyboard, excluding characters that could crash the program), and …

Member Avatar for ov3rcl0ck
0
540
Member Avatar for SuperMetroid

Here is the code I have so far: [code]import re from urllib.request import urlopen pg = urlopen('http://www.url.com') pg_r = pg.read() pg.close() print(pg_r) print(re.search('(?<=http://user.url.com/)\w+', pg_r))[/code] What I *want* to do with re.search is find the word between the strings '[color=#0080FF]http://user.url.com/[/color]' and '[color=#0080FF]"[/color]' but I'm not sure how to do that.. Can …

Member Avatar for Ene Uran
0
128
Member Avatar for akie2741

my code is: [CODE] import urllib import urllib2 import re #get URL urla='http://www.sc.iitb.ac.in/~bijnan/personal-details.htm' #connect to this website request=urllib.urlopen(urla) #get html file from this website html=request.read() #get the address from above html file print html [/CODE] How can i find all his addresses in this html,can use the re.complie() method to …

Member Avatar for djidjadji
0
92
Member Avatar for leegeorg07

Hi, I have this code: [code=python] import urllib2 as url import webbrowser def extract(text, sub1, sub2): """ extract a substring from text between first occurances of substrings sub1 and sub2 """ return text.split(sub1, 1)[-1].split(sub2, 1)[0] start="http://xkcd.com/" permlist=[] textlist=[] for i in range(1, 638): temp=start+str(i) permlist.append(str(url.urlopen(temp).readlines()[88])) textlist.append(str(url.urlopen(temp).readlines()[77])) for i in permlist: …

Member Avatar for ov3rcl0ck
0
203
Member Avatar for alex-VX

is there any way to disable a loop when the user is inactive / when the screen saver is on?

Member Avatar for alex-VX
0
102
Member Avatar for awa

Hi, I have the following problem: I would like to read from a file between to keywords (KEY1 and a line consisting of ------), skipping 4 lines after the first keyword. What I have is the following: [CODE]import re import string infileName = raw_input("filename ") infile = open(infileName, 'r') data …

Member Avatar for awa
0
204
Member Avatar for mahela007

I'm a bit confused as to how variables (or fields) of classes are handled in python. I'll give a small example of what I mean. [CODE] class Cow: # the first class that popped into my head legs = 4 moo = cow() [/CODE] now, moo.legs will return 4 and …

Member Avatar for djidjadji
0
166
Member Avatar for AutoPython

The title doesn't really make sense, as a number with some thing like .23238382 attached to the back of it isn't an integer, but that's not the point. I want to make a program that places commas in the correct position in a number you give. Well, in some of …

Member Avatar for AutoPython
0
182
Member Avatar for dbmikus

I am writing a function to extract decimals from a number. Ignore the exception and its syntax, I am working on 2.5.2 (default Leopard version). My function does not yet handle 0's. My issue is, the function produces random errors with certain numbers, and I don't understand the reason. I …

Member Avatar for dbmikus
0
221
Member Avatar for lllllIllIlllI

This code shows an example of using recursion to simply solve a problem. Note though, it can take a long time to do larger numbers such as the 50th fibonacci numbers this way. Hope this helps! :)

Member Avatar for sneekula
0
206
Member Avatar for Caleb2419

I was given an assignment to create a high/low program (well, the first part anyway) that fulfills the following pseudocode: • Print instructions to the user • Start with the variables high = 1000, low = 1, and tries = 1 • While high is greater than low ◦ Guess …

Member Avatar for Caleb2419
0
232
Member Avatar for edward_pedro

Hey all. I'm new to this forum and Python. I need a program that can search an inputted keyword through all the files that end with the ".txt" extension inside a given folder. The output should include the name of the files which contain the keyword, the sentences which contain …

Member Avatar for vegaseat
0
146
Member Avatar for gianniszaf

Hi there, I am running a program in order to generate some reports. The program starts connects to the database takes the first customer and then calls a method in order to create a report for this customer. When it completes takes the second customer generates the report etc etc. …

Member Avatar for woooee
0
231
Member Avatar for lllllIllIlllI

Hi, Just wondering if someone could explain why this is happening: [code] >>> example = "" >>> example in "Hello there" True >>> [/code] I'm confused as to why [ICODE]example in "hello there"[/ICODE] gives a True value as return.

Member Avatar for sravan953
0
149
Member Avatar for bgk111

Hello all, This will hopefully be a quick and easy answer. I am having some difficulties with multiple lists that have certain characteristics, so what do I have: 4 lists, all the same length that signify: [row] [coumn] [VAR1] [VAR2] So basically I have 2 variables at each location (row,col) …

Member Avatar for bgk111
0
93
Member Avatar for mediachicken

Hey guys! I'm working on a program in python with Tkinter that allows you to enter in a bunch of number and such, and generate an image. So, I have PIL creating a blank PNG image and saving it, it all works... Now I want to add stuff to the …

Member Avatar for Ene Uran
0
2K