- Strength to Increase Rep
- +4
- Strength to Decrease Rep
- -1
- Upvotes Received
- 5
- Posts with Upvotes
- 4
- Upvoting Members
- 4
- Downvotes Received
- 0
- Posts with Downvotes
- 0
- Downvoting Members
- 0
Re:
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 … |
|
Re:
[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. |
|
Re:
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 … |
|
Re:
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? |
|
Re:
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 … |
|
Re:
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 … |
|
Re:
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 … |
|
Re:
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. … |
|
Re:
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 … |
|
Re:
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 … |
|
Re:
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 … |
|
|
Re:
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: … |
Re:
is there any way to disable a loop when the user is inactive / when the screen saver is on? |
|
Re:
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 … |
|
Re:
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 … |
|
Re:
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 … |
|
Re:
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 … |
|
Re:
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! :) |
|
Re:
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 … |
|
Re:
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 … |
|
|
Re:
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. … |
Re:
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. |
|
Re:
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) … |
|
Re:
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 … |