Re: [Tutor] Get a single random sample

2011-09-09 Thread Alan Gauld
On 09/09/11 11:44, kitty wrote: ...I have been an R user for 7 years and and am finding it difficult to do even basic things in python, If you are trying to do the kinds of things that R is good at in Python you will find it involves a lot more work. That's because Python is a general purpos

Re: [Tutor] Get a single random sample

2011-09-09 Thread Steven D'Aprano
Peter Otten wrote: Steven D'Aprano wrote: # Get ten random samples, sampling with replacement. samples = [random.choice(subset) for i in range(10)] That may include subset items more than once. Hence the "sampling with replacement" comment. Use the aptly named random.sample(subset, 10

Re: [Tutor] Get a single random sample

2011-09-09 Thread Peter Otten
Peter Otten wrote: > Steven D'Aprano wrote: > >> # Get ten random samples, sampling with replacement. I can quote. But not read ;( >> samples = [random.choice(subset) for i in range(10)] Sorry for the noise. ___ Tutor maillist - Tutor@python.org T

Re: [Tutor] Get a single random sample

2011-09-09 Thread Peter Otten
Steven D'Aprano wrote: > # Get ten random samples, sampling with replacement. > samples = [random.choice(subset) for i in range(10)] That may include subset items more than once. Use the aptly named random.sample(subset, 10) to avoid that. ___ Tu

Re: [Tutor] Get a single random sample

2011-09-09 Thread Peter Otten
kitty wrote: > Hi, > > I'm new to python and I have read through the tutorial on: > http://docs.python.org/tutorial/index.html > which was really good, but I have been an R user for 7 years and and am > finding it difficult to do even basic things in python, for example I want > to import my data

Re: [Tutor] Get a single random sample

2011-09-09 Thread Steven D'Aprano
kitty wrote: I'm new to python and I have read through the tutorial on: http://docs.python.org/tutorial/index.html which was really good, but I have been an R user for 7 years and and am finding it difficult to do even basic things in python, for example I want to import my data (a tab-delimited

Re: [Tutor] Get a single random sample

2011-09-09 Thread Dave Angel
On 09/09/2011 06:44 AM, kitty wrote: Hi, I'm new to python and I have read through the tutorial on: http://docs.python.org/tutorial/index.html which was really good, but I have been an R user for 7 years and and am finding it difficult to do even basic things in python, for example I want to imp

Re: [Tutor] _init_() arguments

2011-09-09 Thread Steven D'Aprano
Stu Rocksan wrote: class Complex: def _init_(self, realpart, imagpart) Special methods in Python have TWO underscores at the beginning and end. You need to call it __init__ rather than _init_. Also, are you aware that Python already includes a built-in complex type? >>> comp

[Tutor] Get a single random sample

2011-09-09 Thread kitty
Hi, I'm new to python and I have read through the tutorial on: http://docs.python.org/tutorial/index.html which was really good, but I have been an R user for 7 years and and am finding it difficult to do even basic things in python, for example I want to import my data (a tab-delimited .txt file)

Re: [Tutor] _init_() arguments

2011-09-09 Thread Christian Witts
On 2011/09/09 12:10 PM, Stu Rocksan wrote: I have a very basic question that I am sure has a simple answer. I would be very appreciative of anyone that would set me straight. Python 2.7.2 I am simply trying to pass arguments. Based on the documentation that I've read so far _init_() is called

[Tutor] _init_() arguments

2011-09-09 Thread Stu Rocksan
I have a very basic question that I am sure has a simple answer. I would be very appreciative of anyone that would set me straight. Python 2.7.2 I am simply trying to pass arguments. Based on the documentation that I've read so far _init_() is called upon instance creation and the arguments are

Re: [Tutor] Flat is better than Nested

2011-09-09 Thread Mac Ryan
On Thu, 8 Sep 2011 21:39:47 -0500 "Ryan Strunk" wrote: > By the time I write this all into a file, the end user will never > even know this crazy hierarchy exists, but I will, and I don't like > it. Do I just need to get over it and realize that sometimes nested > is necessary, or is there a bett