I've discovered that same thing. Usually I end out not sending my message
because in the process of composing my email I end out I, too, find the
errors.
-Wayne
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http:/
> -Original Message-
> From: tutor-bounces+mike.hansen=atmel@python.org
> [mailto:tutor-bounces+mike.hansen=atmel@python.org] On
> Behalf Of Mac Ryan
> Sent: Friday, February 12, 2010 8:33 AM
> To: tutor@python.org
> Subject: [Tutor] Tutor list as pair
In similar vein, I find that a concept suddenly makes more sense to me when
I try to explain it to someone else (or I realize that I don't fully
understand and need to do some more research).
But with regard to the plush toy you mention, I just ran into that anecdote
in Coders at Work. Can't recal
Have you ever got that piece of advice about - when you have stuck on a
bug you seem unable to track - getting a plush toy to whom you explain
your code? (This is of course a workaround if you do not have a fellow
developer to help you out).
Well... I found out this advice kind of works for me, wi
On Mon, Feb 8, 2010 at 4:15 PM, wrote:
> I've been trying to work my way through some 'beginner projects' I found
> around the web, one of them involves generating some random numbers. I
> decided to use a list of lists, and I'm wondering if this is a valid
> comprehension...IDLE doesn't seem to
I've been trying to work my way through some 'beginner projects' I found
around the web, one of them involves generating some random numbers. I
decided to use a list of lists, and I'm wondering if this is a valid
comprehension...IDLE doesn't seem to mind, but maybe I lack the experience
to know be
On Fri, Oct 9, 2009 at 1:21 AM, wesley chun wrote:
> [generator expressions] are
> "lazy" because you iterate over the values one at a time instead of
> creating the entire list. they are slightly slower but save memory.
I don't think you can make a blanket statement comparing speed of list
comp
> I've been studying python now for a few weeks and I've recently come
> into list comprehensions. [...]
> Those make sense to me. The way I understand them is:
> do something to x for each x in list, with an optional qualifier.
that's pretty much correct.
> On the other hand I've seen a few exa
Hello,
On Wed, Oct 7, 2009 at 6:57 AM, Christer Edwards
wrote:
>
> do something to x for each x in list, with an optional qualifier.
>
To be more precise:
http://docs.python.org/tutorial/datastructures.html#list-comprehensions
"Each list comprehension consists of an expression followed by a fo
Christer Edwards schrieb:
I've been studying python now for a few weeks and I've recently come
into list comprehensions. Some of the examples that I've found make
sense, and I find them readable and concise. In particular I'm
referring to the python docs on the topic
(http://docs.python.org/tut
I've been studying python now for a few weeks and I've recently come
into list comprehensions. Some of the examples that I've found make
sense, and I find them readable and concise. In particular I'm
referring to the python docs on the topic
(http://docs.python.org/tutorial/datastructures.html#list
To: "Rayon"
Cc:
Subject: Re: [Tutor] list sort problem
Rayon wrote:
ok so here it is I think this one should be very clear:
I have some data in a list, the data in question:
0.0046,0.095,0.0904,521456,['MCI 521456 0.0904'],['ATT 521
0.0919'],['IDT 521 0
quot;Rayon"
Cc:
Subject: Re: [Tutor] list sort problem
Rayon wrote:
ok so here it is I think this one should be very clear:
I have some data in a list, the data in question:
0.0046,0.095,0.0904,521456,['MCI 521456 0.0904'],['ATT 521 0.0919'],['IDT
521 0.095'],[
Rayon wrote:
ok so here it is I think this one should be very clear:
I have some data in a list, the data in question:
0.0046,0.095,0.0904,521456,['MCI 521456 0.0904'],['ATT 521 0.0919'],['IDT 521
0.095'],['None']
0.0083,0.0192,0.0109,39023821,['MCI 39023821 0.0109'],['ATT 39 0.012'],['IDT
ok so here it is I think this one should be very clear:
I have some data in a list, the data in question:
0.0046,0.095,0.0904,521456,['MCI 521456 0.0904'],['ATT 521 0.0919'],['IDT 521
0.095'],['None']
0.0083,0.0192,0.0109,39023821,['MCI 39023821 0.0109'],['ATT 39 0.012'],['IDT 39
0.0192'],['S
Wayne wrote:
On Tue, Aug 11, 2009 at 7:17 AM, wrote:
hi i am currently doing the 'livewires' python tutorial lesson 5. i am
making a little game that makes a few squares chase a circle around a little
grid. i can get the 1 square acting on 1 variable to come up, but the
tutorial now wants
if u want to add new attributes into ur list
u need to import list object in ur class
class customlist(list):
x = 'your val'
c = customlist()
>>> dir(c)
['__add__', '__class__', '__contains__', '__delattr__', '__delitem__',
'__delslice__', '__dict__', '__doc__', '__eq__', '__ge__',
'__getattr
On Tue, Aug 11, 2009 at 7:17 AM, wrote:
> hi i am currently doing the 'livewires' python tutorial lesson 5. i am
> making a little game that makes a few squares chase a circle around a little
> grid. i can get the 1 square acting on 1 variable to come up, but the
> tutorial now wants me to creat
On Tue, Aug 11, 2009 at 5:47 PM, wrote:
> hi i am currently doing the 'livewires' python tutorial lesson 5. i am
> making a little game that makes a few squares chase a circle around a little
> grid. i can get the 1 square acting on 1 variable to come up, but the
> tutorial now wants me to creat
hi i am currently doing the 'livewires' python tutorial lesson 5. i am making a
little game that makes a few squares chase a circle around a little grid. i can
get the 1 square acting on 1 variable to come up, but the tutorial now wants me
to create a list of variables that act under the same cl
Dinesh B Vadhia wrote:
I'm suffering from brain failure (or most likely just being brain
less!) and need help to create a list comprehension for this problem:
d is a list of integers: d = [0, 8, 4, 4, 4, 7, 2, 5, 1, 1, 5, 11, 11,
1, 6, 3, 5, 6, 11, 1]
Want to create a new list that adds the
On 7/3/2009 4:19 PM Emile van Sebille said...
On 7/3/2009 3:54 PM Dinesh B Vadhia said...
As the lists of integers get larger (mine are in the thousands of
integers per list) the list comprehension solution will get slower.
Do you agree?
Yes, no doubt. Your original post asked only if the
On 7/3/2009 3:54 PM Dinesh B Vadhia said...
Thanks Emile / Kent.
The problem I see with this solution is that at each stage it is
re-summing the j's instead of retaining a running total which the
'for-loop' method does ie.
>>> dd = []
>>> y = d[0]
>>> for i, x in enumerate(d):
>>>
"Dinesh B Vadhia" wrote
As the lists of integers get larger ... the list comprehension
solution will get slower. Do you agree?
Yes thats why Chris said the linear loop solution is almost
certainly faster in this case. However you could speed up
the for loop significantly by missing out th
y += x
>>>dd.append(y)
As the lists of integers get larger (mine are in the thousands of integers per
list) the list comprehension solution will get slower. Do you agree?
Dinesh
From: Kent Johnson
Sent: Friday, July 03, 2009 1:21 PM
To: Dinesh B Vadhia
Cc: tutor@python.o
On 7/3/2009 1:59 PM Chris Fuller said...
The problem with these list comprehensions is that they have O(n**2)
complexity.
But, the more you work with them the more ease you'll develop at
understanding and deploying them. I often find that a (quick) (perhaps
complex) list comprehension is
On Friday 03 July 2009 15:37, Emile van Sebille wrote:
> On 7/3/2009 1:21 PM Kent Johnson said...
>
> > On Fri, Jul 3, 2009 at 3:49 PM, Dinesh B
> >
> > Vadhia wrote:
> >> d = [0, 8, 4, 4, 4, 7, 2, 5, 1, 1, 5, 11, 11, 1, 6, 3, 5, 6, 11, 1]
> >>
> >> and we want:
> >>
> >> [0, 8, 12, 16, 20, 27, 29,
On 7/3/2009 1:21 PM Kent Johnson said...
On Fri, Jul 3, 2009 at 3:49 PM, Dinesh B
Vadhia wrote:
d = [0, 8, 4, 4, 4, 7, 2, 5, 1, 1, 5, 11, 11, 1, 6, 3, 5, 6, 11, 1]
and we want:
[0, 8, 12, 16, 20, 27, 29, 34, 35, 36, 41, 52, 63, 64, 70, 73, 78, 84, 95,
96]
dd = [ sum(d[:j]) for j in range(len(d
On Fri, Jul 3, 2009 at 3:49 PM, Dinesh B
Vadhia wrote:
> d = [0, 8, 4, 4, 4, 7, 2, 5, 1, 1, 5, 11, 11, 1, 6, 3, 5, 6, 11, 1]
>
> and we want:
>
> [0, 8, 12, 16, 20, 27, 29, 34, 35, 36, 41, 52, 63, 64, 70, 73, 78, 84, 95,
> 96]
> dd = [ sum(d[:j]) for j in range(len(d)) ][1:]
>
> gives:
>
> [0, 8, 1
]
Dinesh
Message: 6
Date: Fri, 03 Jul 2009 12:22:30 -0700
From: Emile van Sebille
To: tutor@python.org
Subject: Re: [Tutor] list comprehension problem
Message-ID:
Content-Type: text/plain; charset=ISO-8859-1; format
On 7/3/2009 12:09 PM Dinesh B Vadhia said...
I'm suffering from brain failure (or most likely just being brain less!)
and need help to create a list comprehension for this problem:
d is a list of integers: d = [0, 8, 4, 4, 4, 7, 2, 5, 1, 1, 5, 11, 11,
1, 6, 3, 5, 6, 11, 1]
Want to create a n
I'm suffering from brain failure (or most likely just being brain less!) and
need help to create a list comprehension for this problem:
d is a list of integers: d = [0, 8, 4, 4, 4, 7, 2, 5, 1, 1, 5, 11, 11, 1, 6, 3,
5, 6, 11, 1]
Want to create a new list that adds the current number and the pri
Thanks to all for the comments, It was much more than I expected.
Vincent
On Fri, Jun 19, 2009 at 4:30 PM, Lie Ryan wrote:
> Alan Gauld wrote:
>>
>> "Vincent Davis" wrote
>>
>> class B():
>> def __init__(self, b1, b2):
>> self.fooa = b1
>> self.foob = b2
>>
>> I assume thats what you r
Alan Gauld wrote:
>
> "Vincent Davis" wrote
>
> class B():
> def __init__(self, b1, b2):
> self.fooa = b1
> self.foob = b2
>
> I assume thats what you really meant!
>
> Ok now I have several instances in a list
> b1 = B(1, 2)
> b2 = B(3, 4)
> b3 = B(9, 10)
> alist = [b1, b2, b3]
>
>>
"Vincent Davis" wrote
class B():
def __init__(self, b1, b2):
self.fooa = b1
self.foob = b2
I assume thats what you really meant!
Ok now I have several instances in a list
b1 = B(1, 2)
b2 = B(3, 4)
b3 = B(9, 10)
alist = [b1, b2, b3]
Lets say for each instance of the class I want to
Vincent Davis wrote:
given a class like
class B():
def __init__(self, b1, b2):
??? self.fooa = fooa
??? self.foob = foob
Ok now I have several instances in a list
b1 = B(1, 2)
b2 = B(3, 4)
b3 = B(9, 10)
alist = [b1, b2, b3]
Lets say for each instance of the class I want to print the value of
fo
On Thu, Jun 18, 2009 at 7:32 PM, Vincent Davis wrote:
> given a class like
> class B():
> def __init__(self, b1, b2):
> self.fooa = fooa
> self.foob = foob
>
> Ok now I have several instances in a list
> b1 = B(1, 2)
> b2 = B(3, 4)
> b3 = B(9, 10)
> alist = [b1, b2, b3]
>
> Lets say for eac
given a class like
class B():
def __init__(self, b1, b2):
self.fooa = fooa
self.foob = foob
Ok now I have several instances in a list
b1 = B(1, 2)
b2 = B(3, 4)
b3 = B(9, 10)
alist = [b1, b2, b3]
Lets say for each instance of the class I want to print the value of
fooa if it is greater tha
Luke Paireepinart wrote:
> Robert Berman wrote:
>> Emille,
>>
>> Thank you for the example of list splicing. Do you know if this is
>> faster than a more conventional loop statement as in my code for
>> primearray which is in my original post (reprinted here)
> As has been mentioned, you will wan
Robert Berman wrote:
Emille,
Thank you for the example of list splicing. Do you know if this is
faster than a more conventional loop statement as in my code for
primearray which is in my original post (reprinted here)
As has been mentioned, you will want to profile your code to know what
is
Robert Berman wrote:
Greetings,
I am working on a 'simple' algorithm to solve the problem called PRIME1
explained at http://www.spoj.pl/problems/PRIME1/.
I do have an algorithm based on the Sieve of Eratosthenes and it does
work as I am failing the project not because of a computational error
Emille,
Thank you very much for the information on timeit. I will investigate
and use it.
>>... but this isn't what BuildSieve yields:
>>> BuildSieve(20)
>>[0, 0, 2, 3, 0, 5, 0, 7, 0, 0, 0, 11, 0, 13, 0, 0, 0, 17, 0, 19, 0]
>>So I still don't know what primearray is/does.
If you look at or pr
Wayne,
Thank you for the suggestion. I will let you know how well this plays
out.
Robert
On Wed, 2009-06-17 at 19:26 -0500, Wayne wrote:
> On Wed, Jun 17, 2009 at 7:11 PM, Robert Berman
> wrote:
> Emille,
>
> Thank you for the example of list splicing. Do you know i
On 6/17/2009 5:11 PM Robert Berman said...
Emille,
Thank you for the example of list splicing. Do you know if this is
faster than a more conventional loop statement
Faster can be exactly determined using timeit. (for some definition of
exact -- the one we use mostly around here anyway)
On Wed, Jun 17, 2009 at 7:11 PM, Robert Berman wrote:
> Emille,
>
> Thank you for the example of list splicing. Do you know if this is faster
> than a more conventional loop statement as in my code for primearray which
> is in my original post (reprinted here)
>
> The code is as follows:
>
> d
Emille,
Thank you for the example of list splicing. Do you know if this is
faster than a more conventional loop statement as in my code for
primearray which is in my original post (reprinted here)
The code is as follows:
def BuildSieve(itemsin):
TheSieve=list()
TheSieve = range(0,itemsi
On 6/17/2009 4:48 PM Robert Berman said...
Emile,
Thank your for your comments. I do have a list running from 0-101.
Yes, it is true, I only needed 0 - 10 and yes I will change it.
However, if you use primearray
you haven't posted the primearray code...
However, for the time being
Emile,
Thank your for your comments. I do have a list running from 0-101.
Yes, it is true, I only needed 0 - 10 and yes I will change it.
However, if you use primearray as a sieve of all primes 2-100 you
will see it works quite well. Printing a range, say primearray[21]
through primear
On 6/17/2009 3:03 PM Robert Berman said...
Greetings,
I am working on a 'simple' algorithm to solve the problem called PRIME1
explained at http://www.spoj.pl/problems/PRIME1/.
I do have an algorithm based on the Sieve of Eratosthenes and it does
work as I am failing the project not because of
Greetings,
I am working on a 'simple' algorithm to solve the problem called PRIME1
explained at http://www.spoj.pl/problems/PRIME1/.
I do have an algorithm based on the Sieve of Eratosthenes and it does
work as I am failing the project not because of a computational error
but because of the drea
Martin Walsh wrote:
> johnf wrote:
>> On Thursday 16 April 2009 05:04:39 pm Alan Gauld wrote:
>>> "johnf" wrote
>>>
> I want to save the list to the field and when I retrieve the string
> convert
> it back to a list.
>
> But this does NOT work.
> mylist=[1,2,3,4]
> myst
johnf wrote:
> On Thursday 16 April 2009 05:04:39 pm Alan Gauld wrote:
>> "johnf" wrote
>>
I want to save the list to the field and when I retrieve the string
convert
it back to a list.
But this does NOT work.
mylist=[1,2,3,4]
mystr=str(mylist)
newlist=
On Thursday 16 April 2009 05:04:39 pm Alan Gauld wrote:
> "johnf" wrote
>
> >> I want to save the list to the field and when I retrieve the string
> >> convert
> >> it back to a list.
> >>
> >> But this does NOT work.
> >> mylist=[1,2,3,4]
> >> mystr=str(mylist)
> >>
> >> newlist= list(mystr)
> >>
"johnf" wrote
I want to save the list to the field and when I retrieve the string
convert
it back to a list.
But this does NOT work.
mylist=[1,2,3,4]
mystr=str(mylist)
newlist= list(mystr)
I keep thinking there must be a simple way of get this done.
Is this a good way?
newlist = eval(mys
On Thu, Apr 16, 2009 at 6:52 PM, johnf wrote:
> I am dealing with a database field that can only store strings.
> I want to save the list to the field and when I retrieve the string convert it
> back to a list.
>
> But this does NOT work.
> mylist=[1,2,3,4]
> mystr=str(mylist)
>
> newlist= list(my
On Thursday 16 April 2009 03:52:02 pm johnf wrote:
> I am dealing with a database field that can only store strings.
> I want to save the list to the field and when I retrieve the string convert
> it back to a list.
>
> But this does NOT work.
> mylist=[1,2,3,4]
> mystr=str(mylist)
>
> newlist= lis
I am dealing with a database field that can only store strings.
I want to save the list to the field and when I retrieve the string convert it
back to a list.
But this does NOT work.
mylist=[1,2,3,4]
mystr=str(mylist)
newlist= list(mystr)
I keep thinking there must be a simple way of get this d
On Fri, Feb 13, 2009 at 11:01 AM, bob gailer wrote:
> Moos Heintzen wrote:
>
>> I guess I can't reference [0] on an empty list. (I come from a C
>> background.)
>>
> Can you have an empty array in C? If so, it does not have any elements, so
> you can't refer to element 0.
I think the OP was co
Moos Heintzen wrote:
Hi,
I was wondering why this happens. I was trying to create a list of lists.
>>> d = [[]]
>>> d[0][0]=1
Traceback (most recent call last):
File "", line 1, in ?
IndexError: list assignment index out of range
>>> d
[[]]
What's wrong with that?
However:
>>> d[0].append(1)
"Moos Heintzen" wrote
>>> d = [[]]
>>> d[0][0]=1
IndexError: list assignment index out of range
>>> d[0].append(1)
>>> d
[[1]]
I guess I can't reference [0] on an empty list.
Thats right. You can't assign a value to a position in
a list that hasn't been created yet. It has nothing to
do w
Hi,
I was wondering why this happens. I was trying to create a list of lists.
>>> d = [[]]
>>> d[0][0]=1
Traceback (most recent call last):
File "", line 1, in ?
IndexError: list assignment index out of range
>>> d
[[]]
What's wrong with that?
However:
>>> d[0].append(1)
>>> d
[[1]]
I guess I
I think I find it most interesting that the greatest percent is still under
15% and then it tapers rapidly. I'm curious what % of people posted 5 or
less messages... perhaps it will become a personal project somewhere down
the road ;)
-Wayne
On Fri, Jan 2, 2009 at 7:28 AM, Kent Johnson wrote:
>
"Norman Khine" wrote
>>> currencies = [{'sign': '\xe2\x82\xac', 'id': 'EUR',
>>> 'is_selected':
False, 'title': 'EURO'}, {'sign': '\xc2\xa3', 'id': 'GBP',
'is_selected': True, 'title': 'Pound'}, {'sign': '$', 'id': 'USD',
'is_selected': False, 'title': 'Dollar'}]
What is the simplest way t
On Fri, Jan 2, 2009 at 8:17 AM, Norman Khine wrote:
> Hello,
> I have this list
>
currencies = [{'sign': '\xe2\x82\xac', 'id': 'EUR', 'is_selected':
False, 'title': 'EURO'}, {'sign': '\xc2\xa3', 'id': 'GBP', 'is_selected':
True, 'title': 'Pound'}, {'sign': '$', 'id': 'USD', 'is_sele
On Fri, Jan 2, 2009 at 8:13 AM, Sander Sweers wrote:
> On Fri, Jan 2, 2009 at 13:52, Kent Johnson wrote:
>> Or ask more questions, that works too!
>
> So you and Alan ask the most questions ;-)
No, that honor goes to Dick Moores. He is in the top 10 in 4 of the
last 5 years!
> Thanks to all the
Hello,
I have this list
>>> currencies = [{'sign': '\xe2\x82\xac', 'id': 'EUR', 'is_selected':
False, 'title': 'EURO'}, {'sign': '\xc2\xa3', 'id': 'GBP',
'is_selected': True, 'title': 'Pound'}, {'sign': '$', 'id': 'USD',
'is_selected': False, 'title': 'Dollar'}]
What is the simplest way to e
On Fri, Jan 2, 2009 at 13:52, Kent Johnson wrote:
> Or ask more questions, that works too!
So you and Alan ask the most questions ;-)
Seriously now, this really shows the power of Python and I'll have a
good time figuring out how this exactly works.
Thanks to all the Tutors for year of great su
On Fri, Jan 2, 2009 at 5:34 AM, Alan Gauld wrote:
> I think the figures reflect the general level of activity on the list.
> We seem to have peaked in 2005...
> Statistics, don't you love 'em :-)
I couldn't resist adding a total number of posts and percent to the
calculations. Statistics + pytho
On Fri, Jan 2, 2009 at 2:06 AM, Luke Paireepinart
wrote:
> Yeah, I agree. Interesting script, Kent. Surprisingly short.
>
> I didn't realize I wasn't in the top 5 posters for 2008! I guess I
> have a new year's resolution to be more helpful.
Or ask more questions, that works too!
Kent
"Kent Johnson" wrote
that generates it. The lists for previous years (back to 2003) are
at
the end so everyone on the list doesn't hit the archives to find out
Alan, I thought you might have passed me this year but we are both
off
a little :-)
I think the figures reflect the general lev
-01 at 09:34 -0500, Kent Johnson wrote:
>> For several years I have been using a simple script to find the top 20
>> posters to the tutor list by web-scraping the archive pages. I thought
>> others might be interested so here is the list for 2008 and the script
>> that generates
On Thu, 2009-01-01 at 09:34 -0500, Kent Johnson wrote:
> For several years I have been using a simple script to find the top 20
> posters to the tutor list by web-scraping the archive pages. I thought
> others might be interested so here is the list for 2008 and the script
> that gener
For several years I have been using a simple script to find the top 20
posters to the tutor list by web-scraping the archive pages. I thought
others might be interested so here is the list for 2008 and the script
that generates it. The lists for previous years (back to 2003) are at
the end so
"Mark Tolonen" <[EMAIL PROTECTED]> wrote
L = [[0,0,0] *3]
I think you meant:
[[0,0,0]]*3
[[0, 0, 0], [0, 0, 0], [0, 0, 0]]
Yes indeed, to much haste and not enough testing!
Alan G
___
Tutor maillist - Tutor@python.org
http://mail.python.o
"Alan Gauld" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
[snip]
Something like
L = [[0,0,0] *3]
I think you meant:
[[0,0,0]]*3
[[0, 0, 0], [0, 0, 0], [0, 0, 0]]
-Mark
Now L contains 3 copies of the same list so when you change
any one copy it is reflected in all of
<[EMAIL PROTECTED]> wrote
self.boardarray[row][col] = self.currentPlayer
4, self.boardarray[2][4] will be set to "2". Instead, the program is
setting multiple values within the list as 2. Here is an example
output, when I click on (0,0):
[[2, 0, 0, 0, 0], [2, 0, 0, 0, 0], [2, 0, 0, 0, 0],
[EMAIL PROTECTED] wrote:
Hello,
I am completely baffled by this action and would appreciate any help. My
problem is occurring within a class which is within a larger program; if
I need to post the entire program let me know and I will. It's only
about 250 lines so far. Anyways, I am using a l
Hello,
I am completely baffled by this action and would appreciate any help.
My problem is occurring within a class which is within a larger
program; if I need to post the entire program let me know and I will.
It's only about 250 lines so far. Anyways, I am using a list of lists
to store dat
Thank you for the advice.
Actually, what annoys me is that list textual output, either with print or
str(), calls repr() for each item of the list, instead of str(). That's why I
had these strange things with floats, as illustrated in my first post on the topic:
class Seq(list):
''' se
On Fri, 14 Nov 2008 15:21:17 +0100, spir wrote:
> Well, actually not really I guess. I asked for rounded floats, not
> full-precision ones.
> Now, after more reflexion on the topic, I understand that even rounded
> floats need to keep full precision internally, because of the 'modular'
> difference
A.T.Hofkamp a écrit :
> spir wrote:
>> # By the way, I do not understand at all the behaviour of repr on
>> rounded floats:
>> x = round(1.1,1)
>> print x, repr(x), "%s" %x
>> 1.1 1.1001 1.1
>
> This is a FAQ question:
>
>
http://www.python.org/doc/faq/general/#why-are-floating-point-
[addendum]
Well, actually, the previous Seq didn't solve all problems. Obvious case of
nested lists. Below a modified version.
denis
class Seq(list):
''' specialized sequence type with improved str
Override list's behaviour that str(list) calls repr instead of
str on it
spir wrote:
# By the way, I do not understand at all the behaviour of repr on
rounded floats:
x = round(1.1,1)
print x, repr(x), "%s" %x
1.1 1.1001 1.1
This is a FAQ question:
http://www.python.org/doc/faq/general/#why-are-floating-point-calculations-so-inaccurate
Sincerely,
Albe
Below an illustration of what troubles me a bit.
denis
class Seq(list):
''' specialized sequence type with improved str
Override list's behaviour that list.__str__
calls __repr__ instead of __str__ on items.
???
'''
def __str__(self):
Arun Tomar wrote:
hi!
I've a list
new_array = ['n1', 'm1', 'p1', 'n2', 'm2', 'p2', 'n3', 'm3', 'p3']
I am trying to convert this to a csv in 3 columns so that the final
output would look something like this
"n1","m1","p1"
"n2","m2","p2"
"n3","m3","p3"
This can easily be done with the "csv"
hi!
I've a list
new_array = ['n1', 'm1', 'p1', 'n2', 'm2', 'p2', 'n3', 'm3', 'p3']
I am trying to convert this to a csv in 3 columns so that the final
output would look something like this
"n1","m1","p1"
"n2","m2","p2"
"n3","m3","p3"
regds,
arun.
On Mon, Sep 15, 2008 at 10:56 AM, Norman Khine <[EMAIL PROTECTED]> wrote:
> Hello,
> I have this code:
>
> topics = object.parent.get_topics()
>for i, topic in enumerate(topics):
>all_previous_topics = topics[:i]
>print all_previous_topics
>
> where topics returns a
Hello,
I have this code:
topics = object.parent.get_topics()
for i, topic in enumerate(topics):
all_previous_topics = topics[:i]
print all_previous_topics
where topics returns a list.
I am trying to get all the topics before current topic in the loop.
Is ther
"Carlos Laviola" <[EMAIL PROTECTED]> wrote
i
[0, 1, 2]
j
[2, 1, 0]
Theoretically, I could then just iterate over range(len(M)) and grab
M[i[N]j[N]], but that's not legal. What would be the right way of
doing
this?
M [ i[N] ] [ j[N] ]
You just missed a couple of brackets...
HTH,
Alan
Hi,
I have a simple "matrix" (nested list) defined as such:
M = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
I'm trying to come up with a different way of getting its, well,
"reverse antidiagonal", since the actual antidiagonal of M goes from
M[0, N] to M[N, 0] according to
http://planetmath.org/encycloped
On Sat, Jul 26, 2008 at 03:08:45AM -0400, Kent Johnson wrote:
> On Fri, Jul 25, 2008 at 7:35 PM, Mike Meisner <[EMAIL PROTECTED]> wrote:
> > Do you happen to know if there is an efficient way to initialize a list
> > like this without explicitly writing out each element?
>
> You can make a copy o
On Fri, Jul 25, 2008 at 8:20 PM, Michiel Overtoom <[EMAIL PROTECTED]> wrote:
> Mike wrote...
>
>>Do you happen to know if there is an efficient way to initialize a list
>>like this without explicitly writing out each element?
>
temp = [[0, 0, 0],[0, 0, 0],[0, 0, 0]]
print temp
> [[0, 0,
On Fri, Jul 25, 2008 at 7:35 PM, Mike Meisner <[EMAIL PROTECTED]> wrote:
> Do you happen to know if there is an efficient way to initialize a list
> like this without explicitly writing out each element?
You can make a copy of the inner list each time through the loop:
IP = []
temp = [[0,
On Sat, 2008-07-26 at 02:20 +0200, [EMAIL PROTECTED] wrote:
> Message: 8
> Date: Fri, 25 Jul 2008 19:35:54 -0400
> From: "Mike Meisner" <[EMAIL PROTECTED]>
> Subject: Re: [Tutor] List indexing problem
> To: "Steve Willoughby" <[EMAIL PROTECTED]&g
Mike wrote...
>Do you happen to know if there is an efficient way to initialize a list
>like this without explicitly writing out each element?
>>> temp = [[0, 0, 0],[0, 0, 0],[0, 0, 0]]
>>> print temp
[[0, 0, 0], [0, 0, 0], [0, 0, 0]]
>>> print [[0]*3]*3
[[0, 0, 0], [0, 0, 0], [0, 0, 0]]
--
ED]>
To: "Mike Meisner" <[EMAIL PROTECTED]>
Cc:
Sent: Friday, July 25, 2008 7:03 PM
Subject: Re: [Tutor] List indexing problem
Mike Meisner wrote:
I need to do some statistical analysis by binning values into an array.
Being new to Python, I tried to use a list of lists. I
"Mike Meisner" <[EMAIL PROTECTED]> wrote
def testanalysis():
IP = []
temp = [[0, 0, 0],[0, 0, 0],[0, 0, 0]]
# initialize to zero
for i in range(20):
IP.append(temp)
this appends the same list (temp) 20 times. So when you
change the list it is reflected 20 times. Lists hold
Mike Meisner wrote:
I need to do some statistical analysis by binning values into an array.
Being new to Python, I tried to use a list of lists. I've extracted
just the minimum code that I'm having trouble with:
What you need to remember is that Python works with *objects*, and
variables a
I need to do some statistical analysis by binning values into an array.
Being new to Python, I tried to use a list of lists. I've extracted just the
minimum code that I'm having trouble with:
def testanalysis():
IP = []
temp = [[0, 0, 0],[0, 0, 0],[0, 0, 0]]
# initialize to zero
Eli Brosh wrote:
Hello,
Is there a way to get a list of installed python modules and their
versions ?
i.e. I would like to know if matplotlib is installed on my computer and
what version is it.
And so with other modules.
You've got two slightly different requirements there:
1) List all mod
401 - 500 of 705 matches
Mail list logo