Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #38637

Re: Implicit conversion to boolean in if and while statements

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder3.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rantingrickjohnson@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'syntax': 0.03; 'explicitly': 0.04; 'context': 0.05; 'constructor': 0.07; 'correct.': 0.07; 'function,': 0.07; 'remaining': 0.07; 'python': 0.09; 'immutable': 0.09; 'literal': 0.09; 'mutable': 0.09; 'notation': 0.09; 'subject:while': 0.09; 'survive': 0.09; 'to:addr:comp.lang.python': 0.09; 'cc:addr:python-list': 0.10; "wouldn't": 0.11; '(list)': 0.16; 'confusion': 0.16; 'denotes': 0.16; 'frozenset': 0.16; 'hypothetical': 0.16; 'syntax,': 0.16; 'syntax.': 0.16; 'wrote:': 0.17; 'typical': 0.17; 'solution.': 0.18; 'define': 0.20; 'object.': 0.22; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In- Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'chris': 0.28; 'grouping': 0.29; 'oop': 0.29; 'them?': 0.29; 'array': 0.29; 'basic': 0.30; 'symbol': 0.33; 'problem': 0.33; 'received:google.com': 0.34; 'built-in': 0.35; 'mapping': 0.35; 'sequence': 0.35; 'there': 0.35; 'but': 0.36; 'should': 0.36; 'enough': 0.36; 'why': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'apply': 0.39; 'list,': 0.39; 'remove': 0.61; 'include:': 0.61; '2013': 0.84; 'complexity': 0.84; 'dict,': 0.84
X-Received by 10.49.84.167 with SMTP id a7mr827618qez.11.1360548546178; Sun, 10 Feb 2013 18:09:06 -0800 (PST)
Newsgroups comp.lang.python
Date Sun, 10 Feb 2013 18:09:06 -0800 (PST)
In-Reply-To <mailman.1570.1360471828.2939.python-list@python.org>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=70.196.109.207; posting-account=h3aEwQoAAACiuqX-oR3gvCVFm8lLHoWj
References <mailman.2132.1342341291.4697.python-list@python.org> <5002a1f9$0$29995$c3e8da3$5496439d@news.astraweb.com> <mailman.2141.1342369188.4697.python-list@python.org> <7b027612-a07e-40f9-8ad2-3e95c5440482@googlegroups.com> <mailman.2148.1342375350.4697.python-list@python.org> <bbc44546-ffb7-4ff9-bd43-3bfa068df75f@googlegroups.com> <mailman.2154.1342389192.4697.python-list@python.org> <86872ad2-fda0-403b-9f18-d1cb18e41860@t32g2000yqd.googlegroups.com> <CAPTjJmov--b_s5e=OYsWWV8w6byj5a+28NNu-vRWGV8mr8w5cg@mail.gmail.com> <mailman.2159.1342404957.4697.python-list@python.org> <50039290$0$29978$c3e8da3$5496439d@news.astraweb.com> <mailman.2197.1342498752.4697.python-list@python.org> <9309333c-13a0-464c-bd94-9c682363b8c9@googlegroups.com> <511516db$0$29969$c3e8da3$5496439d@news.astraweb.com> <ee71b775-b527-4bb3-a080-12aad962b0ba@googlegroups.com> <62c3e7bb-d023-43b4-b759-f424707fd346@googlegroups.com> <mailman.1521.1360368357.2939.python-list@python.org> <75c82449-773e-4077-a6c9-e9cef08f845f@googlegroups.com> <CALwzidm7vg3ucvgm=TzAjQyS8VBWY6ouK0himZ45mPpPL+e-UA@mail.gmail.com> <mailman.1533.1360386069.2939.python-list@python.org> <13e5e306-d253-418e-a1b2-ac5bde03f07d@googlegroups.com> <mailman.1570.1360471828.2939.python-list@python.org>
User-Agent G2/1.0
X-Google-Web-Client true
X-Google-IP 70.196.109.207
MIME-Version 1.0
Subject Re: Implicit conversion to boolean in if and while statements
From Rick Johnson <rantingrickjohnson@gmail.com>
To comp.lang.python@googlegroups.com
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Message-ID <mailman.1620.1360549057.2939.python-list@python.org> (permalink)
Lines 56
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1360549057 news.xs4all.nl 6896 [2001:888:2000:d::a6]:33224
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:38637

Show key headers only | View raw


On Saturday, February 9, 2013 10:50:25 PM UTC-6, Chris Angelico wrote:
> [...]
> I don't understand. Wouldn't freezing an array (list) result in a
> tuple? And, why should there be no literal syntax for them?
> 
> Having a convenient literal notation for every basic type is extremely
> handy. 

Actually i must admit that you are correct. Of course the problem with literal syntax is symbol congestion. But i have a solution. A solution that can survive the limited number of grouping chars that python employs now. Except, i will define them explicitly

{}: denotes ANY mapping object.
[]: denotes ANY mutable sequence object.
(): denotes ANY immutable sequence object.
<>: Hmm, there must be a good use for this one!

The key to removing complexity is to declare the literal syntax much the way Python "represents" a "set". Observe:

py> set([1,2,3])
set([1,2,3])

Using this syntax we can apply "grouping" chars in proper context when writing literal syntax. The only problem is how do we make this syntax unique enough to avoid confusion and complexity???  Some hypothetical literal syntax, "syntaxes", include:

<set>[1,2,3] # Set literal
<set>(1,2,3) # FrozenSet literal

set=>[1,2,3] # Set literal
set=>(1,2,3) # FrozenSet literal

set::[1,2,3] # Set literal
set::(1,2,3) # FrozenSet literal

set<[1,2,3]> # Set literal
set<(1,2,3)> # FrozenSet literal

<set[1,2,3]> # Set literal
<set(1,2,3)> # FrozenSet literal

set([1,2,3]) # Set literal
set((1,2,3)) # FrozenSet literal


...and to avoid conflicts with the "set" function, we just remove the set function! Only the types list, dict, and tuple(bka:StaticList!) should have a built-in constructor function, the remaining should have a typical OOP style constructor:

mySet = Set([1,2,3])
mySetLiteral = set([1,2,3])

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: Implicit conversion to boolean in if and while statements Rick Johnson <rantingrickjohnson@gmail.com> - 2013-02-07 22:16 -0800
  Re: Implicit conversion to boolean in if and while statements Michael Torrie <torriem@gmail.com> - 2013-02-07 23:27 -0700
    Re: Implicit conversion to boolean in if and while statements Rick Johnson <rantingrickjohnson@gmail.com> - 2013-02-07 22:32 -0800
    Re: Implicit conversion to boolean in if and while statements Rick Johnson <rantingrickjohnson@gmail.com> - 2013-02-07 22:32 -0800
  Re: Implicit conversion to boolean in if and while statements Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-09 02:16 +1100
    Re: Implicit conversion to boolean in if and while statements Rick Johnson <rantingrickjohnson@gmail.com> - 2013-02-08 09:48 -0800
      Re: Implicit conversion to boolean in if and while statements Roy Smith <roy@panix.com> - 2013-02-08 12:58 -0500
      Re: Implicit conversion to boolean in if and while statements Rick Johnson <rantingrickjohnson@gmail.com> - 2013-02-08 11:58 -0800
        Re: Implicit conversion to boolean in if and while statements Chris Angelico <rosuav@gmail.com> - 2013-02-09 11:05 +1100
          Re: Implicit conversion to boolean in if and while statements Rick Johnson <rantingrickjohnson@gmail.com> - 2013-02-08 16:49 -0800
            Re: Implicit conversion to boolean in if and while statements Chris Angelico <rosuav@gmail.com> - 2013-02-09 12:17 +1100
              Re: Implicit conversion to boolean in if and while statements Rick Johnson <rantingrickjohnson@gmail.com> - 2013-02-09 20:54 -0800
                Re: Implicit conversion to boolean in if and while statements Chris Angelico <rosuav@gmail.com> - 2013-02-10 16:04 +1100
                Re: Implicit conversion to boolean in if and while statements Rick Johnson <rantingrickjohnson@gmail.com> - 2013-02-11 04:28 -0800
                Re: Implicit conversion to boolean in if and while statements Chris Angelico <rosuav@gmail.com> - 2013-02-11 23:50 +1100
                Re: Implicit conversion to boolean in if and while statements Rick Johnson <rantingrickjohnson@gmail.com> - 2013-02-11 05:28 -0800
                Re: Implicit conversion to boolean in if and while statements Chris Angelico <rosuav@gmail.com> - 2013-02-12 00:52 +1100
                Re: Implicit conversion to boolean in if and while statements Rick Johnson <rantingrickjohnson@gmail.com> - 2013-02-11 20:24 -0800
                Re: Implicit conversion to boolean in if and while statements Rick Johnson <rantingrickjohnson@gmail.com> - 2013-02-11 20:24 -0800
                Re: Implicit conversion to boolean in if and while statements Rick Johnson <rantingrickjohnson@gmail.com> - 2013-02-11 05:28 -0800
                Re: Implicit conversion to boolean in if and while statements Rick Johnson <rantingrickjohnson@gmail.com> - 2013-02-11 04:28 -0800
              Re: Implicit conversion to boolean in if and while statements Rick Johnson <rantingrickjohnson@gmail.com> - 2013-02-09 20:54 -0800
            Re: Implicit conversion to boolean in if and while statements Ian Kelly <ian.g.kelly@gmail.com> - 2013-02-08 18:29 -0700
            Re: Implicit conversion to boolean in if and while statements Chris Angelico <rosuav@gmail.com> - 2013-02-09 16:01 +1100
              Re: Implicit conversion to boolean in if and while statements Rick Johnson <rantingrickjohnson@gmail.com> - 2013-02-09 20:26 -0800
                Re: Implicit conversion to boolean in if and while statements Chris Angelico <rosuav@gmail.com> - 2013-02-10 15:50 +1100
                Re: Implicit conversion to boolean in if and while statements Rick Johnson <rantingrickjohnson@gmail.com> - 2013-02-10 18:09 -0800
                Re: Implicit conversion to boolean in if and while statements Rick Johnson <rantingrickjohnson@gmail.com> - 2013-02-10 18:09 -0800
                Re: Implicit conversion to boolean in if and while statements Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-10 22:37 +1100
                Re: Implicit conversion to boolean in if and while statements Roy Smith <roy@panix.com> - 2013-02-10 09:45 -0500
                Re: Implicit conversion to boolean in if and while statements Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2013-02-10 18:06 +0100
                Re: Implicit conversion to boolean in if and while statements Rick Johnson <rantingrickjohnson@gmail.com> - 2013-02-11 04:18 -0800
                Re: Implicit conversion to boolean in if and while statements Chris Angelico <rosuav@gmail.com> - 2013-02-11 23:40 +1100
                Re: Implicit conversion to boolean in if and while statements Rick Johnson <rantingrickjohnson@gmail.com> - 2013-02-11 05:13 -0800
                Re: Implicit conversion to boolean in if and while statements Chris Angelico <rosuav@gmail.com> - 2013-02-12 00:35 +1100
                Re: Implicit conversion to boolean in if and while statements Rick Johnson <rantingrickjohnson@gmail.com> - 2013-02-11 20:00 -0800
                Re: Implicit conversion to boolean in if and while statements Rick Johnson <rantingrickjohnson@gmail.com> - 2013-02-11 20:00 -0800
                Re: Implicit conversion to boolean in if and while statements 88888 Dihedral <dihedral88888@googlemail.com> - 2013-02-11 17:06 -0800
                Re: Implicit conversion to boolean in if and while statements Chris Angelico <rosuav@gmail.com> - 2013-02-12 16:55 +1100
                Re: Implicit conversion to boolean in if and while statements Rick Johnson <rantingrickjohnson@gmail.com> - 2013-02-12 09:48 -0800
                Re: Implicit conversion to boolean in if and while statements Chris Angelico <rosuav@gmail.com> - 2013-02-13 08:24 +1100
                Re: Implicit conversion to boolean in if and while statements 88888 Dihedral <dihedral88888@googlemail.com> - 2013-02-12 18:43 -0800
                Re: Implicit conversion to boolean in if and while statements 88888 Dihedral <dihedral88888@googlemail.com> - 2013-02-12 18:43 -0800
                Re: Implicit conversion to boolean in if and while statements Ian Kelly <ian.g.kelly@gmail.com> - 2013-02-15 13:12 -0700
                Re: Implicit conversion to boolean in if and while statements Chris Angelico <rosuav@gmail.com> - 2013-02-16 11:12 +1100
                Re: Implicit conversion to boolean in if and while statements Rick Johnson <rantingrickjohnson@gmail.com> - 2013-02-12 09:48 -0800
                Re: Implicit conversion to boolean in if and while statements 88888 Dihedral <dihedral88888@googlemail.com> - 2013-02-11 17:06 -0800
                Re: Implicit conversion to boolean in if and while statements Rick Johnson <rantingrickjohnson@gmail.com> - 2013-02-11 05:13 -0800
                Re: Implicit conversion to boolean in if and while statements Serhiy Storchaka <storchaka@gmail.com> - 2013-02-15 21:09 +0200
              Re: Implicit conversion to boolean in if and while statements Rick Johnson <rantingrickjohnson@gmail.com> - 2013-02-09 20:26 -0800
          Re: Implicit conversion to boolean in if and while statements Rick Johnson <rantingrickjohnson@gmail.com> - 2013-02-08 16:49 -0800
        Re: Implicit conversion to boolean in if and while statements Ian Kelly <ian.g.kelly@gmail.com> - 2013-02-08 18:06 -0700
          Re: Implicit conversion to boolean in if and while statements Rick Johnson <rantingrickjohnson@gmail.com> - 2013-02-09 22:25 -0800
          Re: Implicit conversion to boolean in if and while statements Rick Johnson <rantingrickjohnson@gmail.com> - 2013-02-09 22:25 -0800
      Re: Implicit conversion to boolean in if and while statements Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-09 14:16 +1100
        Re: Implicit conversion to boolean in if and while statements Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-02-09 15:36 -0500
      Re: Implicit conversion to boolean in if and while statements Mark Janssen <dreamingforward@gmail.com> - 2013-02-11 21:12 -0800

csiph-web