Re: [Tutor] list comprehension with else

2015-01-18 Thread Steven D'Aprano
On Sun, Jan 18, 2015 at 02:20:55PM -0800, Danny Yoo wrote: > Just to add, log(0) is mathematically undefined. > https://en.m.wikipedia.org/wiki/Logarithm. For the record, IEEE-754 specifies that log(0.0) should return -INF. That's what Decimal does: py> from decimal import Decimal py> Decimal(0)

Re: [Tutor] list comprehension with else

2015-01-18 Thread Danny Yoo
Just to add, log(0) is mathematically undefined. https://en.m.wikipedia.org/wiki/Logarithm. So depending on the problem's context, it might be worth asking why log is being applied on this input. Is such input expected? Make sure the code isn't trying to correct for input that shouldn't be there

Re: [Tutor] selecting data from a list

2015-01-18 Thread Albert-Jan Roskam
- Original Message - > From: Peter Otten <__pete...@web.de> > To: tutor@python.org > Cc: > Sent: Sunday, January 18, 2015 4:38 AM > Subject: Re: [Tutor] selecting data from a list > > Colin Ross wrote: > >> Hi all, >> >> I am attempting to isolate a certain subset of data from the

Re: [Tutor] selecting data from a list

2015-01-18 Thread Mark Lawrence
On 18/01/2015 00:49, Colin Ross wrote: Hi all, I am attempting to isolate a certain subset of data from the list "a" and then turn it into any array. To do so, I have written the following code: import numpy as np a = [0,1,2,3,4,5,6,7,8,9,10] b = [10,20,30,40,50,60,70,80,90,100,110] for a in

Re: [Tutor] list comprehension with else

2015-01-18 Thread Sydney Shall
On 18/01/2015 13:41, Asokan Pichai wrote: On Sun, Jan 18, 2015 at 6:50 PM, Sydney Shall mailto:s.sh...@virginmedia.com>> wrote: I am a beginner and I have a question of syntax. Welcome! I am just learning to use list comprehension, which oc course, I find very helpful indeed.

Re: [Tutor] list comprehension with else

2015-01-18 Thread Alan Gauld
On 18/01/15 13:20, Sydney Shall wrote: I am a beginner and I have a question of syntax. Please don't hijack an existing thread. Simply changing the subject line is not enough. Always send a new mail to tutor@python.org to start a new discussion. Otherwise the new discussion gets interleaved wi

Re: [Tutor] list comprehension with else

2015-01-18 Thread Alan Gauld
On 18/01/15 13:20, Sydney Shall wrote: The problem is I am occasionally getting exactly zeros when I need to obtain the logarithm of the number. for i in range(len(cap)): Its usually better to iterate over the collection rather than use indexing: for item in cap: if cap[i] == 0.0:

Re: [Tutor] list comprehension with else

2015-01-18 Thread Asokan Pichai
On Sun, Jan 18, 2015 at 6:50 PM, Sydney Shall wrote: > I am a beginner and I have a question of syntax. > Welcome! > > I am just learning to use list comprehension, which oc course, I find very > helpful indeed. > > However, I am stuck with a specific problem of how to incorporate an else > in

Re: [Tutor] list comprehension with else

2015-01-18 Thread Sydney Shall
On 18/01/2015 13:20, Sydney Shall wrote: I am a beginner and I have a question of syntax. I am just learning to use list comprehension, which oc course, I find very helpful indeed. However, I am stuck with a specific problem of how to incorporate an else in a list comp-rehension. I cannot do it

[Tutor] list comprehension with else

2015-01-18 Thread Sydney Shall
I am a beginner and I have a question of syntax. I am just learning to use list comprehension, which oc course, I find very helpful indeed. However, I am stuck with a specific problem of how to incorporate an else in a list comp-rehension. I cannot do it. The following snippet of code does

Re: [Tutor] Is this the right place for my pyqt questions?

2015-01-18 Thread Alan Gauld
On 18/01/15 12:29, Suhail Mahmood wrote: Hi, everyone Can I get my questions on python, and maybe some frameworks > of python like pyqt, answered here? This group is primarily for beginners to Python, as such, questions about using the Python language, general programming principles and the Pyt

[Tutor] Is this the right place for my pyqt questions?

2015-01-18 Thread Suhail Mahmood
Hi, everyone Can I get my questions on python, and maybe some frameworks of python like pyqt, answered here? Sorry but I am not sure of it if this is right place for questions on something like pyqt as that is what I need right now. If not can you please refer to somewhere where I can get my ans