Posts
 
Reputation
Joined
Last Seen
Ranked #2K
Strength to Increase Rep
+0
Strength to Decrease Rep
-0
100% Quality Score
Upvotes Received
4
Posts with Upvotes
4
Upvoting Members
4
Downvotes Received
0
Posts with Downvotes
0
Downvoting Members
0
1 Commented Post
0 Endorsements
Ranked #1K
~45.4K People Reached
Favorite Tags
Member Avatar for vegaseat
Member Avatar for paddy3118
1
2K
Member Avatar for vegaseat

This snippets shows how to have fun replacing multiple words in a text. The target words and the replacement words form key:value pairs in a dictionary. The search and replacement is done using Python's regular expression module re. The code also gives an example of a function within a function.

Member Avatar for Gribouillis
0
20K
Member Avatar for vegaseat

A simple way to find duplicate words in a text. In this case the text is preprocessed to eliminate punctuation marks and set all words to lower case.

Member Avatar for paddy3118
2
4K
Member Avatar for TrustyTony

You can fix one parameter of function call by calling underlying method of fixed parameter instead of using functools.partial or lambda statement.

Member Avatar for paddy3118
1
285
Member Avatar for vegaseat

This code example shows how to create a dictionary with row,column indexed (r,c) key tuples from a typical list of lists 2D matrix. Also an example is shown of the ease of processing the resulting dictionary.

Member Avatar for TrustyTony
5
6K
Member Avatar for vegaseat

Scientists and deficit spenders like to use Python because it can handle very large numbers. I decided to give it a test with factorials. Factorials reach astronomical levels rather quickly. In case you can't quite remember, the factorial of 12 is !12 = 1*2*3*4*5*6*7*8*9*10*11*12 = 479001600, that is 479 million …

Member Avatar for sneekula
2
5K
Member Avatar for jobs

When I execute the following sql,select id from people, inside python and print the result, I get this: ((11L,), (12L,), (13L,), (14L,), (15L,), (16L,), (17L,), (18L,), (19L,), (20L,)) Why does python print L beside the numbers. Just to indicate Long type?

Member Avatar for timogoosen
0
3K
Member Avatar for ultimatebuster

Is it possible to limit a certain variable to only certain type? For example, i have a class named AccurateStr. How can I make sure that the variable "as" is an instance of AccurateStr? Similarly, how can I make sure a variable is a positive int, str etc without the …

Member Avatar for ultimatebuster
0
557
Member Avatar for TomD22

Hey, I am trying to use Tkinter to provide a gui to a simple python script. No matter what I try, my tkinter window always ends up maximised, filling the entire screen. Specifying the height and width has no effect. I have tried a simple label, and tried putting the …

Member Avatar for SgtMe
0
564
Member Avatar for nevets04

Heres the situation so far.I'm in 9th grade and I've been programming in python. I enjoy python however, my high school doesn't offer any courses for python. In 11th and 12th grade, I can take C++. So here's my question: Should I: A) Learn python for the next to years …

Member Avatar for vegaseat
0
208
Member Avatar for lrh9

So I'm interested in learning about data validation. Especially in Python. Python all ready has several common idioms for data validation. There are several statements that evaluate data. For instance, isinstance(object, classinfo) will check that the given object is an instance of the class or type in classinfo. One idiom …

Member Avatar for paddy3118
0
353
Member Avatar for bdesc100

I am trying to specify which variables a function should return. The purpose of this is to allow the function to return different sets of variables according to the requirements of another function, in order to make things more efficient (rather than always returning all the variables): [CODE] # Python …

Member Avatar for paddy3118
0
110
Member Avatar for daniwebnewbie

I'm writing an application that needs to store a ton of objects and some attributes. I was wondering, based on python's inner workings, if it's more memory efficient to have one huge dictionary or many small dictionaries and then one dictionary that just references the smaller dictionaries? Any information would …

Member Avatar for paddy3118
0
240
Member Avatar for orangie

I would really appreciate a help to this problem: Let's say x = Class() x.name = 'the_name' x.value = 10 if you were only give the 'the_name' how do you get the instance ref, x to get x.value

Member Avatar for paddy3118
0
115
Member Avatar for red999

I am creating a script that allows me to calculate the future value of an investment at the end of x years, but I am having a little trouble writing the summation syntax in my script. I am not familar with the sum syntax so I do not know how …

Member Avatar for paddy3118
0
182
Member Avatar for Rejinacm

I want to create varibales as a1,a2,a3,...a10. For that i used a for loop.As the variable in loop increments..i need var gettng created as above . Can anyone give me an idea? At the same time of creation i need to be able to assign to them There i m …

Member Avatar for paddy3118
0
111
Member Avatar for adam291086

I have the variable Adam that contains some information. Later on i have some more information to add to the variable adam. How can this be done something like [CODE] adam = "john" adam = adam + "mike" [/CODE]

Member Avatar for paddy3118
0
88
Member Avatar for Fuse

I have a problem guys. It's due to duck typing. Now I expected to run into something like this sooner or later, but I can't help but feel there's a better solution. [code=Python]import re def patternMatching(pattern, string): matchList = re.findall(pattern, string) print '\n'.join(['%s' % v for v in matchList]) [/code] …

Member Avatar for paddy3118
0
134
Member Avatar for webamateur

I have a list that is retrieved with python from MS Access. This list needs to be sorted alphabetically before being printed on the web browser. Here is what I have and I need it sorted by the P_LastName. [CODE]dbc = odbc.odbc('Intra//') csr = dbc.cursor() q = "SELECT P_ID, P_FirstName, …

Member Avatar for woooee
0
90
Member Avatar for dr_kac

Hello everybody! As I thought I became more comfortable with data structure I've got the problem I can't solve. It looks so: I have that kind of text file: ABCD vvvv 1e-12 ABCD hhhh 1e-6 ABCD ggggg 1e-3 ASDE ffffff 1e-57 ASDE dddd 0.001 etc. I would like to read …

Member Avatar for paddy3118
0
178
Member Avatar for happimani

Dear All, What is the Major Differences between Python 2.3 and 2.4 and What are all the Major Features in Python 2.4?????????? regards Mani

Member Avatar for paddy3118
0
139
Member Avatar for nsandestin

Is there something similar to a LIKE function in python? What I'm trying to accomplish is to search inside a string, if it finds specific criteria it sets another variable to a specific value. In other scripting languages I have used a LIKE function to do this but I can't …

Member Avatar for nsandestin
0
118
Member Avatar for freddypyther

Hi! I've just passed a university subject which made me do a medium console-based game in Java. I had to do the design first with UML and then code the game. I just found useful the Domain model (the first aproach of what's the point of the program) and the …

Member Avatar for jwenting
0
146
Member Avatar for jliu66

Hi, Could u please help me to sort this 3 dimension data in python? How can sort this 5 by 3 array with 1st column or last column? Thanks a lot. marek brutalski 20 zenia markownikowa 10 teresa parufkowa 90 bogumila pierdawa 40 genowefa tempawa 50 John

Member Avatar for Lardmeister
0
165
Member Avatar for jliu66

Hi, My friends, I am new to python. I try to figure out how python knows the end of loop or the end of a block of codes in while... else code Here is the example: while E: Bt else: Bf here if Bf have 20 lines of code. How …

Member Avatar for Lardmeister
0
114
Member Avatar for jliu66

Hi, my friends, I am new to python. I am trying to user csv module to read and write the data in csv. Here is data format. # of columns in each row are the same. 1st row is a header. how I can pass the data into 2-D array? …

Member Avatar for paddy3118
0
99
Member Avatar for jrcagle

Hi all, I see a lot of books teaching beginning Python students to code like this: [code="Python"] def func1(): ... def func2(): ... class Blah(object): ... def main(): ... main() [/code] It strikes me that having people "def main():" and then call main() is a bit silly. In fact, it …

Member Avatar for jrcagle
0
112
Member Avatar for mjsinpl

Hey. any help wud be greatly appreciated. I have just tranferred into the second year of a multimedia course in which they have been doing python programmes. Problem is i have never programmed anything before and have been asked to complete this assignment.:( i dont even know what it is …

Member Avatar for paddy3118
0
77
Member Avatar for MrShoot

Hi, this is my first forum message so I'll make a brief introduction. I'm from Canada and I am Computer Science student. I enjoy working with computers, specially web programming. It has come to my attention (and also a school requirement) to learn Python. So here I am with my …

Member Avatar for Ene Uran
0
158
Member Avatar for grahhh

I'm new to Python, and need a bit of help. I have a large data set that is tab delimited but annoyingly also has some extra spaces in it and I can't seem to get it in a nice array to perform computations on it. This is a simplification of …

Member Avatar for paddy3118
0
182