Re: [Tutor] Help with class example

2012-10-26 Thread Dave Angel
On 10/18/2012 07:59 PM, Frank Pontius wrote: > Hello, > I'm taking a beginners course on Python. > > Have class example which is to be used in H/W, which I can't get to work. > Thus I figure the example is wrong. But I need this to get H/W done. > > Using 'import random' and random.randrange in fu

Re: [Tutor] Help with class example

2012-10-26 Thread bob gailer
On 10/18/2012 7:59 PM, Frank Pontius wrote: Help with class example Hello, Hi - this just showed up in my mailbox. Perhaps there was a delay getting it posted. The "" around tails and heads are not ascii quote characters. They are what some word processors change ascii quotes into to meet t

Re: [Tutor] Python and xml *creation*

2012-10-26 Thread Devin Jeanpierre
On Fri, Oct 26, 2012 at 6:49 PM, Sander Sweers wrote: > Op vrijdag 26 oktober 2012 17:00:16 schreef Prasad, Ramit: >> Based on the most recent comment (May 2010) I would probably >> stick with online tutorials. > > I generally do not trust "reviews" on the publisher's website as they have > been p

Re: [Tutor] Python and xml *creation*

2012-10-26 Thread Sander Sweers
Op vrijdag 26 oktober 2012 17:00:16 schreef Prasad, Ramit: > Based on the most recent comment (May 2010) I would probably > stick with online tutorials. I generally do not trust "reviews" on the publisher's website as they have been proved to be constructed by them. > Here are some tutorials fo

Re: [Tutor] For - if - else loop; print selective output

2012-10-26 Thread Alexandre BM
You can break the loop when you get a positive matches, and add a variable where you can count the number of positive matches, if it's equal to zero print 'not found' On 24/10/2012 17:43, Saad Javed wrote: Let me modify this example: a = [['jimmy', '25', 'pancakes'], ['tom', '23', 'brownies']

Re: [Tutor] newb help reading lines from csv

2012-10-26 Thread Matt Williams
Dear Rob, This caught me out as well for a long time. As I understand it, csv.reader is a file-reader, which iterates ONCE over the file. There may be more elegant solutions, but I do: import csv ifile = open('test.csv', "r") reader = csv.reader(ifile) inData = [] for row in reader: i

[Tutor] Help with class example

2012-10-26 Thread Frank Pontius
Hello, I'm taking a beginners course on Python. Have class example which is to be used in H/W, which I can't get to work. Thus I figure the example is wrong. But I need this to get H/W done. Using 'import random' and random.randrange in function, returning #. import random def RandomNumberGen

Re: [Tutor] Strings.

2012-10-26 Thread David Hutto
On Tue, Oct 23, 2012 at 7:48 PM, Alexander wrote: > On Tue, Oct 23, 2012 at 7:24 PM, Nitin Ainani wrote: >> Dear Sir/Madam, >> >> I am new to python I have a question. It is as follows: >> >> Suppose s is a variable and s stores empty string >> >> emptyString = "" > #consider the string to be no

Re: [Tutor] Help Passing Variables

2012-10-26 Thread David Hutto
#Apologies, this is the actual code: def SwapCaseAndCenter(a_string, upper_or_lower = None, center_num = None): if upper_or_lower == "upper": print a_string.center(center_num).upper() if upper_or_lower == "lower": print a_string.center(center_num)

Re: [Tutor] Help Passing Variables

2012-10-26 Thread David Hutto
#A little more complex in terms of params: def SwapCaseAndCenter(*kwargs): if upper_or_lower == "upper": print a_string.center(center_num).upper() if upper_or_lower == "lower": print a_string.center(center_num).lower() a_string = raw_input("Give m

Re: [Tutor] Help Passing Variables

2012-10-26 Thread David Hutto
#This is the actual code: def SwapCaseAndCenter(a_string, upper_or_lower = None): if upper_or_lower == "upper": print a_string.center(center_num).upper() if upper_or_lower == "lower": print a_string.center(center_num).lower() a_string = raw_input(

Re: [Tutor] Help Passing Variables

2012-10-26 Thread David Hutto
Algorithm it, and look at the instance below the function first where variables are drawn in as raw input, and comments with # are just comments, not part of the code: def SwapCaseAndCenter(a_string, upper_or_lower = None): #find if it's upper, and print if upper_or_lower == "upper":

Re: [Tutor] managing memory large dictionaries in python

2012-10-26 Thread Dwight Hutto
Now this one removes, the usage of different dicts, removes the whitespace, and uses just a whole dict, then becomes 7.6kb That's a big difference to someone parsing files, and utilizing memory storage areas. -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com {0:0,1:1,2:2,3:3,4:4

Re: [Tutor] program for a problem

2012-10-26 Thread Dwight Hutto
On Mon, Oct 8, 2012 at 11:55 AM, Tharuni Dheeraj wrote: > please send me the program for the following que: > > Write a program that asks the user for a dollar amount.It then reports the > corresponding number of euros by using the current exchange rate. > -- > Regards, > Tharuni Dheeraj > > > ___

Re: [Tutor] For - if - else loop; print selective output

2012-10-26 Thread Alan Gauld
On 26/10/12 20:38, Mark Lawrence wrote: On 26/10/2012 17:58, eryksun wrote: Sorry, Saad; this is now *way* off topic... Apart from blatant trolling nothing is off topic on any Python mailing list. That's simply not true. The mailing lists mostly have clear topic areas. This one is for learn

Re: [Tutor] For - if - else loop; print selective output

2012-10-26 Thread Mark Lawrence
On 26/10/2012 17:58, eryksun wrote: Sorry, Saad; this is now *way* off topic... Apart from blatant trolling nothing is off topic on any Python mailing list. That is one of the joys of reading them. Contrast that to the mailing lists associated with the group of languages that are based on

Re: [Tutor] For - if - else loop; print selective output

2012-10-26 Thread eryksun
Sorry, Saad; this is now *way* off topic... On Thu, Oct 25, 2012 at 5:39 PM, Oscar Benjamin wrote: > >> degrades if there are many collisions). On average, you can check if a >> set/dict contains an item in constant time, i.e. O(1). The amortized >> worst case is O(n). > > Why do you say "*amorti

Re: [Tutor] Python and xml *creation*

2012-10-26 Thread Prasad, Ramit
Sander Sweers wrote: > Hi List, > > I am looking for resources on creating xml files in python. I have found some > resources but they all are very basic. I find lots of resources online about > parsing and searching in an xml file but not so much about creating them. > > Do any of you know of go

Re: [Tutor] Python and xml *creation*

2012-10-26 Thread Sander Sweers
Op zaterdag 27 oktober 2012 03:30:26 schreef Steven D'Aprano: > On 27/10/12 03:14, Sander Sweers wrote: > > Do any of you know of good online resources? I found an o'reilly book [1] > > do you know if it is any good? > > > > [1] http://shop.oreilly.com/product/9780596001285.do > > For those of us

Re: [Tutor] Python and xml *creation*

2012-10-26 Thread Steven D'Aprano
On 27/10/12 03:14, Sander Sweers wrote: Do any of you know of good online resources? I found an o'reilly book [1] do you know if it is any good? [1] http://shop.oreilly.com/product/9780596001285.do For those of us who have email access but no web access at the moment, or who have access to

[Tutor] Python and xml *creation*

2012-10-26 Thread Sander Sweers
Hi List, I am looking for resources on creating xml files in python. I have found some resources but they all are very basic. I find lots of resources online about parsing and searching in an xml file but not so much about creating them. Do any of you know of good online resources? I found an o