On Fri, Aug 13, 2021 at 03:44:20PM -0700, guruyaya wrote:
I am fairly sure all of us know about this python quirk:
def no_new_func(a=[]):
...a.append('new')
...return a
no_new_func()
['new']
no_new_func()
['new', 'new']
For some tim
I am fairly sure all of us know about this python quirk:
>>> def no_new_func(a=[]):
...a.append('new')
...return a
>>> no_new_func()
['new']
>>> no_new_func()
['new', 'new']
>>>
For some time I was bother
Elizabeth Weiss wrote:
> What is the point of this code?:
>
> word=[]
> print(word)
>
> The result is []
>
> When would I need to use something like this?
You often need to intialize a list, sometime with (empty) = [].
Then after initializing you should do "something" that perhaps will fill
On 6/26/2016 8:13 PM, Elizabeth Weiss wrote:
Hi There,
What is the point of this code?:
word=[]
print(word)
The result is []
When would I need to use something like this?
Thank you!
Sometimes you need to assign an empty list to a variable prior to using
it in a looping structure
ord = []
This creates a variable, "word", and assigns an empty list to it.
But once you have an empty list, you can start putting things into it. Once
you have a list with items in it, there are all sorts of things you can
usefully do:
- append items to the end;
- insert items at the s
Hi There,
What is the point of this code?:
word=[]
print(word)
The result is []
When would I need to use something like this?
Thank you!
--
https://mail.python.org/mailman/listinfo/python-list
ch...@freeranger.com wrote:
> No, that was pretty much what I was looking for. If anyone has an answer
> to the deeper question, that would be icing on the cake.
>
> What is interesting is that usually the traceback shows the line of code
> that I invoke which, deep inside a library I'm using, h
On Thu, 15 May 2014 21:36:49 -0700, chris wrote:
> Any ideas about what this might mean?
[jumping ahead]
> digital_data_set = (sample_bytes.pop(0) << 8 | sample_bytes.pop(0))
> IndexError: pop from empty list
sample_bytes is an empty list. Or it could be a list with just a
; _split_response
>
> > info[parse_rule[0]] = parse_rule[1](self, info)
>
> >File "/usr/local/lib/python2.7/dist-packages/xbee/ieee.py", line 117, in
> >
>
> > lambda xbee,original: xbee._parse_samples(original['samples'])
>
, in
_parse_samples
digital_data_set = (sample_bytes.pop(0) << 8 | sample_bytes.pop(0))
IndexError: pop from empty list
The error means that sample_bytes is an empty list so calling pop is an
error.
Or were you asking something deeper, like *why* sample_bytes is an
empty list?
Gary Herron
--
https://mail.python.org/mailman/listinfo/python-list
t;/usr/local/lib/python2.7/dist-packages/xbee/ieee.py", line 117, in
lambda xbee,original: xbee._parse_samples(original['samples'])
File "/usr/local/lib/python2.7/dist-packages/xbee/base.py", line 357, in
_parse_samples
digital_data_set = (sample_bytes.pop(0) &
Hello I am trying to modify Python xgoogle module to use yahoo
I have hit a road block where I receive no error messages the code I use to
test just returns an empty list.
and I don't know how to trouble shoot it
the module code is here
http://pastebin.com/iTibRs1R
and the code I am usi
On Thu, Dec 24, 2009 at 11:56 PM, Rodrick Brown wrote:
p=[]
if p is None:
> ... print 'yes'
> ...
> This doesn't work as expected.
That probably means that what you expect is wrong.
>>>p = []
# p is now a list object at a certain location
>>> if p is None:
#check to see if p (a l
>>> p=[]
>>> if p is None:
... print 'yes'
...
>>>
This doesn't work as expected.
--
[ Rodrick R. Brown ]
http://www.rodrickbrown.com http://www.linkedin.com/in/rodrickbrown
--
http://mail.python.org/mailman/listinfo/python-list
Quoting Reckoner :
> Hi,
>
> Observe the following:
>
> In [202]: class Foo():
>.: def __init__(self,h=[]):
>.: self.h=h
[...]
> In [207]: f.h.append(10)
>
> In [208]: f.h
> Out[208]: [10]
>
> In [209]: g.h
> Out[209]: [10]
>
> The question is: why is g.h updated
Reckoner wrote:
Hi,
Observe the following:
In [202]: class Foo():
.: def __init__(self,h=[]):
.: self.h=h
.:
.:
In [203]: f=Foo()
In [204]: g=Foo()
In [205]: g.h
Out[205]: []
In [206]: f.h
Out[206]: []
In [207]: f.h.append(10)
In [208]: f.h
Out[208]
On Mon, Jul 27, 2009 at 1:40 PM, Reckoner wrote:
> Hi,
>
> Observe the following:
>
> In [202]: class Foo():
> .: def __init__(self,h=[]):
> .: self.h=h
> .:
> .:
>
> In [203]: f=Foo()
>
> In [204]: g=Foo()
>
> In [205]: g.h
> Out[205]: []
>
> In [206]: f.h
> Out
Reckoner wrote:
Hi,
X-Antispam: NO; Spamcatcher 5.2.1. Score 50
Observe the following:
In [202]: class Foo():
.: def __init__(self,h=[]):
.: self.h=h
.:
.:
In [203]: f=Foo()
In [204]: g=Foo()
In [205]: g.h
Out[205]: []
In [206]: f.h
Out[206]: []
In [
Hi,
Observe the following:
In [202]: class Foo():
.: def __init__(self,h=[]):
.: self.h=h
.:
.:
In [203]: f=Foo()
In [204]: g=Foo()
In [205]: g.h
Out[205]: []
In [206]: f.h
Out[206]: []
In [207]: f.h.append(10)
In [208]: f.h
Out[208]: [10]
In [209]:
On 26 Mar, 08:18, Niklas Norrthon wrote:
> But that can easily be achieved with the "or" operator as Michiel
> Overton notes elsewhere in this thread:
Michiel Overtoom was what I meant to write. My apologies!
> def some_function(arg, coll=None):
> do_stuff(arg)
> for item in coll or []:
On 26 Mar, 04:31, Steve Holden wrote:
> Stef Mientki wrote:
>
> > Now it would be nice to allow iteration over others too, like None .
> > a = None
> > for item in a :
> > do_something_with_item
>
> To me that makes about as much sense as writing
>
> for x in 1.0:
> prin
On Wed, 25 Mar 2009 21:26:10 +, Martin P. Hellwig wrote:
> Raymond Hettinger wrote:
>> On Mar 25, 7:38 am, srinivasan srinivas
>> wrote:
>>> For ex: to check list 'A' is empty or not.. if A == []:
>>> if A.count == 0:
>>> if len(A) == 0:
>>> if not A:
...
> Personally I would go for the len
Stef Mientki wrote:
> andrew cooke wrote:
>> Andre Engels wrote:
>>
>>> On Wed, Mar 25, 2009 at 4:21 PM, andrew cooke wrote:
>>>
i will go against the grain slightly and say that "len" is probably the
best compromise in most situations (although i admit i don't know what
I believe "if not A:" is the most pythonic, but depending on what
you're doing a list might not be the right thing to use at all. A
little while ago I got some help from this malining list in dealing
with a situation where lists really were not efficient (finding prime
numbers...for fun). In my cas
For ex: to check list 'A' is empty or not..
if A == []:
if A.count == 0:
if len(A) == 0:
if not A:
Connect with friends all over the world. Get Yahoo! India Messenger at
http://in.messenger.yahoo.com/?wm=n/
--
http://mail.python.org/mailman/listinfo/python-list
On Mar 25, 7:38 am, srinivasan srinivas
wrote:
> For ex: to check list 'A' is empty or not..
> if A == []:
> if A.count == 0:
> if len(A) == 0:
> if not A:
PEP 8 recommends the last one, and most Pythonistas here probably
would as well, so that is probably what you should do if you don't
otherwis
On Mar 25, 8:27 am, Andre Engels wrote:
> On Wed, Mar 25, 2009 at 4:21 PM, andrew cooke wrote:
>
> > but i may be wrong - are there any containers (apart from pathological
> > hand-crafted examples) that would not define __len__()?
>
> When writing my answer, I thought of generators, but I now fi
On Mar 25, 1:19 pm, "andrew cooke" wrote:
> actually, the implication of what you said is probably worth emphasising
> to the original poster: often you don't need to test whether a list is
> empty or not, you simply iterate over its contents:
>
> for x in foo:
> # do something
>
> this will
Albert Hopkins wrote:
On Wed, 2009-03-25 at 21:26 +, Martin P. Hellwig wrote:
PEP 8 recommends the latter.
Raymond
I can't seem to find where this recommendation is mentioned or implied.
Wow, you must not have looked very hard:
1. Point your browser to http://www.python.org/dev/pe
On 25 Mar 2009, at 21:29 , Stef Mientki wrote:
Now it would be nice to allow iteration over others too, like None .
a = None
for item in a :
do_something_with_item
I saw this technique used in CherryPy:
>>> a=None
>>> for item in a or []:
...print item
...
>>> a=[1,2,3]
On Wed, 2009-03-25 at 21:26 +, Martin P. Hellwig wrote:
> >
> > PEP 8 recommends the latter.
> >
> >
> > Raymond
> I can't seem to find where this recommendation is mentioned or implied.
Wow, you must not have looked very hard:
1. Point your browser to http://www.python.org/dev/peps/p
Martin P. Hellwig wrote:
> Raymond Hettinger wrote:
>> On Mar 25, 7:38 am, srinivasan srinivas
>> wrote:
>>> if not A:
>> PEP 8 recommends the latter.
> I can't seem to find where this recommendation is mentioned or implied.
it's the next-to-last sub-item, just before the references.
http://www.p
Raymond Hettinger wrote:
On Mar 25, 7:38 am, srinivasan srinivas
wrote:
For ex: to check list 'A' is empty or not..
if A == []:
if A.count == 0:
if len(A) == 0:
if not A:
PEP 8 recommends the latter.
Raymond
I can't seem to find where this recommendation is mentioned or implied.
Personall
andrew cooke wrote:
Andre Engels wrote:
On Wed, Mar 25, 2009 at 4:21 PM, andrew cooke wrote:
i will go against the grain slightly and say that "len" is probably the
best compromise in most situations (although i admit i don't know what
[...]
but i may be wrong - are there a
Andre Engels wrote:
> On Wed, Mar 25, 2009 at 4:21 PM, andrew cooke wrote:
>> i will go against the grain slightly and say that "len" is probably the
>> best compromise in most situations (although i admit i don't know what
[...]
>> but i may be wrong - are there any containers (apart from patholo
On Mar 25, 7:38 am, srinivasan srinivas
wrote:
> For ex: to check list 'A' is empty or not..
> if A == []:
> if A.count == 0:
> if len(A) == 0:
> if not A:
PEP 8 recommends the latter.
Raymond
--
http://mail.python.org/mailman/listinfo/python-list
On Mar 26, 2:21 am, "andrew cooke" wrote:
> i will go against the grain slightly and say that "len" is probably the
> best compromise in most situations (although i admit i don't know what
> count is) because i think it will work when you expect it to and break
> when you have a bug in your progra
On Wed, Mar 25, 2009 at 4:21 PM, andrew cooke wrote:
>
> i will go against the grain slightly and say that "len" is probably the
> best compromise in most situations (although i admit i don't know what
> count is) because i think it will work when you expect it to and break
> when you have a bug i
i will go against the grain slightly and say that "len" is probably the
best compromise in most situations (although i admit i don't know what
count is) because i think it will work when you expect it to and break
when you have a bug in your program.
using a simple boolean is more robust (and wha
On Mar 26, 1:38 am, srinivasan srinivas
wrote:
Depends on what you mean by "best"; like graduation day at
kindergarten, everyone gets a prize:
> For ex: to check list 'A' is empty or not..
> if A == []:
most obviously correct
> if A.count == 0:
best use of imagination
> if len(A) == 0:
best
srinivasan srinivas:
> For ex: to check list 'A' is empty or not..
Empty collections are "false":
if somelist:
... # somelist isn't empty
else:
... # somelist is empty
Bye,
bearophile
--
http://mail.python.org/mailman/listinfo/python-list
srinivasan srinivas wrote:
For ex: to check list 'A' is empty or not..
if A == []:
if A.count == 0:
if len(A) == 0:
if not A:
"if not A"
-tkc
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, Mar 25, 2009 at 3:38 PM, srinivasan srinivas
wrote:
>
> For ex: to check list 'A' is empty or not..
> if A == []:
> if A.count == 0:
> if len(A) == 0:
> if not A:
I would go for the last one, because it has the highest likelihood of
doing what is intended when fed with something that is '
For ex: to check list 'A' is empty or not..
if A == []:
if A.count == 0:
if len(A) == 0:
if not A:
Thanks,
Srini
Add more friends to your messenger and enjoy! Go to
http://messenger.yahoo.com/invite/
--
http://mail.python.org/mailman/listinfo/python-list
En Thu, 12 Feb 2009 07:07:53 -0200, WP
escribió:
Hello group! This is probably a silly newbie mistake but consider the
following program:
import libsbml
def getSBMLModel(biomodel_path):
reader = libsbml.SBMLReader()
sbml_doc = reader.readSBML(biomodel_path)
sbml_model = No
WP a écrit :
Hello group! This is probably a silly newbie mistake but consider the
following program:
import libsbml
def getSBMLModel(biomodel_path):
reader = libsbml.SBMLReader()
sbml_doc = reader.readSBML(biomodel_path)
sbml_model = None
if sbml_doc.getNumErrors() > 0:
Hello group! This is probably a silly newbie mistake but consider the
following program:
import libsbml
def getSBMLModel(biomodel_path):
reader = libsbml.SBMLReader()
sbml_doc = reader.readSBML(biomodel_path)
sbml_model = None
if sbml_doc.getNumErrors() > 0:
print 'I c
; .
> .
> .
> It's also perfectly legitimate--and arguably even more
> precise--to write
>
> if funList == []:
> do_something()
Any of these will be true for an empty list and false for a non-empty
In article <[EMAIL PROTECTED]>,
Matthew Fitzgibbons <[EMAIL PROTECTED]> wrote:
>Alexnb wrote:
>> Okay this is a simple question I just don't know how. If I have a list, say:
>>
>> funList = []
>>
>> and after a while something possible should have been appended to it, but
>> wasn't. How can I te
Alexnb wrote:
Okay this is a simple question I just don't know how. If I have a list, say:
funList = []
and after a while something possible should have been appended to it, but
wasn't. How can I test if that list is empty.
if not funList:
do_something()
-Matt
--
http://mail.python.o
Okay this is a simple question I just don't know how. If I have a list, say:
funList = []
and after a while something possible should have been appended to it, but
wasn't. How can I test if that list is empty.
--
View this message in context:
http://www.nabble.com/Testing-for-an-
En Mon, 24 Mar 2008 15:22:43 -0300, Tzury Bar Yochay
<[EMAIL PROTECTED]> escribió:
> while I can invoke methods of empty string '' right in typing
> (''.join(), etc.) I can't do the same with empty list
>
> example:
>
>>>> a = [1,2,3
while I can invoke methods of empty string '' right in typing
(''.join(), etc.) I can't do the same with empty list
example:
>>> a = [1,2,3]
>>> b = [].extend(a)
>>> b
>>> b = []
>>> b.extend(a)
>>> b
[1,2,3]
I woul
On Feb 10, 8:32 am, Steve Holden <[EMAIL PROTECTED]> wrote:
> Steven D'Aprano wrote:
> > On Fri, 09 Feb 2007 14:15:51 +, Steve Holden wrote:
>
> >> area_name_string = '*% s*' % (Area_name)
>
> >> Interesting, I never realised until now that you can have spaces between
> >> the percent sign and
In <[EMAIL PROTECTED]>,
[EMAIL PROTECTED] wrote:
> With some number:
>
> In [2]: "% 3s" % 'a'
> Out[2]: ' a'
The space still doesn't have any effect here:
In [66]: "%3s" % 'a'
Out[66]: ' a'
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
On Feb 10, 3:32 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
>
> >>> "% s" % 'banana'
> 'banana'
> >>> "% s" % 1
> '1'
> >>> "% s" % -1
> '-1'
> >>>
>
With some number:
In [2]: "% 3s" % 'a'
Out[2]: ' a'
Hieu
--
http://mail.python.org/mailman/listinfo/python-list
Steven D'Aprano wrote:
> On Fri, 09 Feb 2007 14:15:51 +, Steve Holden wrote:
>
>> area_name_string = '*% s*' % (Area_name)
>>
>> Interesting, I never realised until now that you can have spaces between
>> the percent sign and th format effector.
>
> Space is one of the flags. From the docs:
On Fri, 09 Feb 2007 14:15:51 +, Steve Holden wrote:
> area_name_string = '*% s*' % (Area_name)
>
> Interesting, I never realised until now that you can have spaces between
> the percent sign and th format effector.
Space is one of the flags. From the docs:
The conversion flag characters a
On 9 Feb, 14:15, Steve Holden <[EMAIL PROTECTED]> wrote:
> Neil Webster wrote:
> > Hi,
>
> > I was wondering whether anybody could help me out.
>
> > I have a program, for part of it I am trying to pass a variable to a
> > glob function, this returns an empty
Neil Webster wrote:
> Hi,
>
> I was wondering whether anybody could help me out.
>
> I have a program, for part of it I am trying to pass a variable to a
> glob function, this returns an empty list. The strange thing is when
> I hard code in the variable the glob sec
Neil Webster <[EMAIL PROTECTED]> wrote:
> area_name_string = '"*% s*"' % (Area_name)
> os.chdir(Input)
> filename = glob.glob(area_name_string)
Too many quotation marks.
>>> Area_name='Foo'
>>> '"*% s*"' % (Area_name)
'"*Foo*"'
Unless there are files with funny names containing '"' you will not
Hi,
I was wondering whether anybody could help me out.
I have a program, for part of it I am trying to pass a variable to a
glob function, this returns an empty list. The strange thing is when
I hard code in the variable the glob section works.
Does anybody have any ideas as why it is not
> "Steve R. Hastings" <[EMAIL PROTECTED]> (SRH) wrote:
[snip]
>SRH> vowels = frozenset("aeiouAEIOU")
>SRH> f = open("a_file.txt") # note that f is an iterator
>SRH> counts = tally(line[0] in vowels for line in f)
tally([line[0] in vowels for line in f])
>SRH> # counts is a dict; counts.keys
Ron Adam wrote:
> Steve R. Hastings wrote:
>> This neatly replaces truecount(), and you can use it for other things as
>> well.
>
> if True in talley(S): do_somthing()
>
> Works for me... ;-)
>
>
> Cheers,
> Ron
Actulley talley isn't needed for this...
if True in S: do_domething
Steve R. Hastings wrote:
> On Sat, 01 Apr 2006 14:35:58 -0300, Felipe Almeida Lessa wrote:
>> Two changes:
>> - Use "is None".
>> - Use "try ... except" instead of "in"
>
> Yes.
>
>
>> Maybe you don't like my version, and the gains aren't that much, but
>> please use "is None" instead of "== N
Steve R. Hastings wrote:
> Here is a function called "tally()". It reduces a list to a dictionary
> of counts, with one key for each value from the list. The value for
> each key is the count of how many times it appeared in the list.
>
>
> def tally(seq, d=None):
> if d == None:
>
On Sat, 01 Apr 2006 14:35:58 -0300, Felipe Almeida Lessa wrote:
> Two changes:
> - Use "is None".
> - Use "try ... except" instead of "in"
Yes.
> Maybe you don't like my version, and the gains aren't that much, but
> please use "is None" instead of "== None".
Actually, I do like your version.
Em Sáb, 2006-04-01 às 08:35 -0800, Steve R. Hastings escreveu:
> def tally(seq, d=None):
> if d == None:
> d = {}
>
> for x in seq:
> if x in d:
> d[x] += 1
> else:
> d[x] = 1
> return d
Two changes:
- Use "is None".
- Use "try ... ex
On Sat, 01 Apr 2006 00:38:08 -0800, Steve R. Hastings wrote:
> my proposed truecount() returns a tuple, with the length and
> the count of true values.
I never liked the name truecount(), and the more I think about it, the
less I like the function. It should either solve a very important need,
or
On Sat, 01 Apr 2006 02:06:29 -0600, Ron Adam wrote:
> true_count, count = countall(S), len(S)
Unfortunately, this does not solve the problem.
An iterator yields its values only once. If you have an iterator "itr",
you cannot do all(itr) and then do len(itr). Whichever one you do first
will
Ron Adam <[EMAIL PROTECTED]> writes:
> true_count, count = countall(S), len(S)
In general it's preferable to not rely on len being available, since
these are arbitrary iterators.
--
http://mail.python.org/mailman/listinfo/python-list
Steve R. Hastings wrote:
> On Fri, 31 Mar 2006 16:29:00 -0800, Paul Rubin wrote:
>> I think "S and all(S)" is the right way to express that, if that's
>> what's intended.
>
> I still would like a standard function, because "S and all(S)" does not
> work with iterators. I proposed one possible fun
On Fri, 31 Mar 2006 16:29:00 -0800, Paul Rubin wrote:
> I think "S and all(S)" is the right way to express that, if that's
> what's intended.
I still would like a standard function, because "S and all(S)" does not
work with iterators. I proposed one possible function, truecount(S), that
returns a
Ron Adam <[EMAIL PROTECTED]> writes:
> The 'not not S' is just a conversion to bool. Is the following less
> contorted to you?
>
> >>> bool([])
> False
Oh ok. Yes, bool(S) is much less contorted than "not not S".
> 'Is all True' isn't the same as 'Has all True'. As I said, I'm not
> questioni
lol!
--
http://mail.python.org/mailman/listinfo/python-list
Carl Banks wrote:
> Ron Adam wrote:
>> Carl Banks wrote:
>>
>>> In Python, yes and no are the only possible answers. Probably the only
>>> analogous thing you could do in Python would be for all() to raise
>>> ValueError when passed an empty sequence.
>> There is also 'None' which serves a similar
Ron Adam wrote:
> Carl Banks wrote:
>
> > In Python, yes and no are the only possible answers. Probably the only
> > analogous thing you could do in Python would be for all() to raise
> > ValueError when passed an empty sequence.
>
> There is also 'None' which serves a similar purpose of indicati
t; Comments?
Ant wrote:
> all(list) simply means "every element of the list evaluates to True".
> This is trivially true in the case of the empty list. This is logically
> equivalent to "There are no elements in the list which evaluate to
> False".
>
> any(list) si
I don't think that there will be any valid examples.
all(list) simply means "every element of the list evaluates to True".
This is trivially true in the case of the empty list. This is logically
equivalent to "There are no elements in the list which evaluate to
False".
a
Op 2006-03-30, Paul McGuire schreef <[EMAIL PROTECTED]>:
>
> "Antoon Pardon" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
>> Op 2006-03-30, Steven D'Aprano schreef <[EMAIL PROTECTED]>:
>>
>> > So, these flying elephants -- are they pink or not?
>>
>> They are both.
>>
>
> That woul
Alex Martelli wrote:
> > >>>all(flying elephants which are not pink) => true
> > >>>
> > >>>So, these flying elephants -- are they pink or not?
> > >>
> > >> No, you ask two different sets whether they are true.
> > >
> > > No, there is only one empty set.
> >
> > who said anything about empty set
Carl Banks wrote:
> In Python, yes and no are the only possible answers. Probably the only
> analogous thing you could do in Python would be for all() to raise
> ValueError when passed an empty sequence.
There is also 'None' which serves a similar purpose of indicating an
invalid value when pas
Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> Marcin Ciura wrote:
>
> >>>all(flying elephants which are not pink) => true
> >>>
> >>>So, these flying elephants -- are they pink or not?
> >>
> >> No, you ask two different sets whether they are true.
> >
> > No, there is only one empty set.
>
> who s
Steven D'Aprano wrote:
> On Thu, 30 Mar 2006 11:28:54 -0800, Paul Rubin wrote:
>
> > Steven D'Aprano <[EMAIL PROTECTED]> writes:
> >> > No, all(seq) is true if you can't point to a specific element in seq
> >> > that's false.
> >>
> >> No, all(seq) is true if every element in seq is true. Surely th
Steven D'Aprano <[EMAIL PROTECTED]> writes:
> >> No, all(seq) is true if every element in seq is true. Surely that's a
> >> more intuitive definition than your definition by what you can't do.
> > They are different?
> Of course they are different -- they differ in the case of an empty
> sequence
ere
neither True nor False is correct. In hacker culture, the Chinese word
"mu" (literally "without") is sometimes used to mean "I cannot answer that
question because your assumptions are not correct".
In the case of all(seq), the correct answer is "mu". But since we're
stuck with binary logic, the more commonly useful behaviour is True, but
sometimes that leads to problems, such as in my first example of Guido
being punished because he was found guilty of all the terrorist crimes he
committed -- which is an empty list.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
Steven D'Aprano <[EMAIL PROTECTED]> writes:
> > No, all(seq) is true if you can't point to a specific element in seq
> > that's false.
>
> No, all(seq) is true if every element in seq is true. Surely that's a
> more intuitive definition than your definition by what you can't do.
They are differen
"Antoon Pardon" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Op 2006-03-30, Steven D'Aprano schreef <[EMAIL PROTECTED]>:
>
> > So, these flying elephants -- are they pink or not?
>
> They are both.
>
That would make them Schrödinger elephants!
-- Paul
--
http://mail.python.or
Op 2006-03-30, Steven D'Aprano schreef <[EMAIL PROTECTED]>:
> Paul Rubin wrote:
>
>> Steven D'Aprano <[EMAIL PROTECTED]> writes:
>>
>>>Think of it this way: if all(seq) is true, shouldn't it be the case
>>>that you can point to a specific element in seq that is true?
>>
>>
>> No, all(seq) is tru
Marcin Ciura wrote:
>>>all(flying elephants which are not pink) => true
>>>
>>>So, these flying elephants -- are they pink or not?
>>
>> No, you ask two different sets whether they are true.
>
> No, there is only one empty set.
who said anything about empty sets ?
--
http://mail.python.org
Georg Brandl wrote:
> Steven D'Aprano wrote:
>>all(flying elephants which are pink) => true
>>all(flying elephants which are not pink) => true
>>
>>So, these flying elephants -- are they pink or not?
>
> No, you ask two different sets whether they are true.
No, there is only one empty set.
Releva
Ron Adam wrote:
>
> hasall(S, True, lambda n: n=42)
>
That was suppose to be:
hasall(S, True, lambda n: n==42)
--
http://mail.python.org/mailman/listinfo/python-list
Steven D'Aprano wrote:
> Paul Rubin wrote:
>
>> Steven D'Aprano <[EMAIL PROTECTED]> writes:
>>
>>> Think of it this way: if all(seq) is true, shouldn't it be the case
>>> that you can point to a specific element in seq that is true?
>>
>>
>> No, all(seq) is true if you can't point to a specific el
Duncan Booth wrote:
> Ron Adam wrote:
>
>> Where we are assembling widgets in a manufacturing plant. Where we don't
>> want to go to the next step until *all* the sub parts are present.
>>
>> if all(part.status == 'present' for part in unit):
>> do_release()
>>
>> Oops! Some empty bins show
Steven D'Aprano wrote:
> Paul Rubin wrote:
>
>> Steven D'Aprano <[EMAIL PROTECTED]> writes:
>>
>>>Think of it this way: if all(seq) is true, shouldn't it be the case
>>>that you can point to a specific element in seq that is true?
>>
>>
>> No, all(seq) is true if you can't point to a specific e
Steven D'Aprano wrote:
> Okay, Ron's example wasn't the best. How about this
> one, from chess:
>
> The intention is to play cautiously if all threatened
> pieces are valuable, and daringly otherwise.
Isn't that example even worse? Compare:
- You have one of your valuable pieces threatened. You
Steven D'Aprano wrote:
> Paul Rubin wrote:
>
> > Steven D'Aprano <[EMAIL PROTECTED]> writes:
> >
> >>Think of it this way: if all(seq) is true, shouldn't it be the case
> >>that you can point to a specific element in seq that is true?
> >
> >
> > No, all(seq) is true if you can't point to a specif
Duncan Booth wrote:
> Ron Adam wrote:
>
>
>>Where we are assembling widgets in a manufacturing plant. Where we don't
>>want to go to the next step until *all* the sub parts are present.
>>
>>if all(part.status == 'present' for part in unit):
>> do_release()
>>
>>Oops! Some empty bins showe
Paul Rubin wrote:
> Steven D'Aprano <[EMAIL PROTECTED]> writes:
>
>>Think of it this way: if all(seq) is true, shouldn't it be the case
>>that you can point to a specific element in seq that is true?
>
>
> No, all(seq) is true if you can't point to a specific element in seq
> that's false.
No,
Steven D'Aprano <[EMAIL PROTECTED]> writes:
> Think of it this way: if all(seq) is true, shouldn't it be the case
> that you can point to a specific element in seq that is true?
No, all(seq) is true if you can't point to a specific element in seq
that's false.
--
http://mail.python.org/mailman/li
1 - 100 of 125 matches
Mail list logo