Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Joel Goldstick Newsgroups: comp.lang.python Subject: Re: General computer language, syntax question. Date: Mon, 29 Feb 2016 09:48:48 -0500 Lines: 65 Message-ID: References: <5b619ffa-aae6-4fa8-9f62-58532668ec93@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de 4CoS+bQd+meRjK59Uhkb/AX1buRusyRDyDNAJguEX9RA== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.019 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'javascript,': 0.07; 'cc:addr:python-list': 0.09; '"if': 0.09; 'empty,': 0.09; 'subject:language': 0.09; 'python': 0.10; '>>>': 0.15; '2016': 0.16; 'boolean': 0.16; 'cyclic': 0.16; 'empty.': 0.16; 'exhausted': 0.16; 'javascript"': 0.16; 'nodes': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'element': 0.18; 'language': 0.19; '>>>': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'lawrence': 0.22; 'programming': 0.22; 'am,': 0.23; 'feb': 0.23; 'header:In-Reply-To:1': 0.24; 'feature': 0.24; 'mon,': 0.24; 'script': 0.25; 'message-id:@mail.gmail.com': 0.27; 'entries': 0.27; 'skip:( 20': 0.28; 'node': 0.29; 'subset': 0.29; 'array': 0.29; 'print': 0.30; 'url:mailman': 0.30; 'language.': 0.32; 'problem': 0.33; 'url:python': 0.33; 'lock': 0.33; 'url:listinfo': 0.34; 'languages': 0.34; 'add': 0.34; 'received:google.com': 0.35; 'false': 0.35; 'but': 0.36; 'list,': 0.36; 'should': 0.36; 'instead': 0.36; 'there': 0.36; 'url:org': 0.36; 'possible.': 0.36; 'received:209.85': 0.36; 'skip:{ 10': 0.36; 'url:library': 0.36; 'subject:: ': 0.37; 'really': 0.37; 'skip:& 10': 0.37; 'turn': 0.37; 'received:209.85.213': 0.37; 'list.': 0.37; 'seem': 0.37; 'received:209': 0.38; 'sure': 0.39; 'skip:e 20': 0.39; 'url:mail': 0.40; 'mark': 0.40; 'url:3': 0.60; 'email addr:gmail.com': 0.62; 'more': 0.63; 'our': 0.64; 'due': 0.65; 'beautiful': 0.66; 'url:info': 0.71; 'lack': 0.76; 'networks,': 0.79; '8bit%:16': 0.84; 'madness.': 0.84; 'pythonistas,': 0.84; 'subject:General': 0.84; 'to:none': 0.91; 'joel': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc; bh=XQsmariZSxSKGvFzEDqjqz71eix7vec9LoIpPgdoti0=; b=VX8iGPl1wDf2Ls7CVuvXlwqeobNKlp3lXMi8rW51en/5Hzr/kjwFy0wPELNMh2mj4W /AqpDevDBkLrUE5FouteL3XOLkdHrkaTY6TIy4RQlIlnm8+0Nb5APAhbwFbcBqzPw9kL mIlUq3xbfjWVtGJrI5UbpZQERwRBtLsKhr03dEhQ2SsrnNKHhpE+IMA4k4BLaEsTq77O 20EUqVcPVgEImGE1b6ZQX5ytvIhTHs++ASJssIQ8IK+TFvqtzX7USbqqhYfJq44P5ZbK MQKvS+BmJObZjp6F+EiRhoZxa6uII+FnSwIj1OVwc3OW5RKfyQfE+t/UU5xNl27nwGqv sxng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:cc; bh=XQsmariZSxSKGvFzEDqjqz71eix7vec9LoIpPgdoti0=; b=WlxBf3udUDfb65BEz5S2cwlYIhINQobYl1sT32uTE7sJiK11fir1Vd422RTfKHh91/ yg/YUvQVitdihO3yO6LsNXFV3/zxoo0wwAhHWULcHImsZ6jIXQks4/hZcsFwBVoQSBUn jIB8Aa3GD1g4GqHDnHXyU6dmuXAkIcfqQO8r00LLnJeZVvx1oyIYapZv7b3V6YPvi27F 8pBA5VpGpeINfOmMKWOmpc7k5ASBdIDkN31/HMe+eFV/QzKur3b4icIuOq2++8UQzLka UCSr34im++j0BHBjygemHtXi+TCAHEaafSD+P+kLmfvY4el5NB/yZIUY074pyGKjZ12Z Iyuw== X-Gm-Message-State: AD7BkJK2NjrqOEzg6aRqVF8prB5P/i+pCTnYyoZ5boUGkXddAR7/kczCaWytEAYCIe6YNu+FovRxJnmNiGk3Fg== X-Received: by 10.50.32.2 with SMTP id e2mr9354576igi.73.1456757328848; Mon, 29 Feb 2016 06:48:48 -0800 (PST) In-Reply-To: X-Content-Filtered-By: Mailman/MimeDel 2.1.21 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:103717 On Mon, Feb 29, 2016 at 9:39 AM, Mark Lawrence wrote: > On 29/02/2016 13:45, jonas.thornvall@gmail.com wrote: > >> I have a problem programming uniform networks, "x nodes with y links" >> that turn out to be really hairy to solve for me and i feel i really lack >> the programming features >> >> "Actually i program in javascript" but the problem seem general for all >> programming languages including Pyhton. >> >> For a beautiful solution it would require "If in list/array return >> boolean" "If not in list/array return boolean". >> >> But there is no such feature Python nor Javascript, so instead i set >> boolean value "inlist" to false and loop thru, to see if it is already in >> list. If not it is added to list. >> >> So if the current node i generate links for is x and i try to generate a >> link to node z, and z's links exhausted i will add it to exhausted list. >> >> And if there is node-x exhausted entries in list, well then script should >> break because it will lock into a cycle. The cyclic lockup is due to only a >> subset of the networks on the form (links*deep)+1=nodes is possible. >> >> So what i need is to know howto write "if list/array ***empty*** do >> {something}" >> >> I sure know howto check if an array have 1 element 2,3,4 but how do you >> check for empty. >> >> I think it is crazy that you can not do general comparissons of the type >> If in list/array >> If not in list/array >> >> But it is even more crazy that you can not check if list/array is empty, >> that is just madness. >> >> > Please see > https://docs.python.org/3/library/stdtypes.html#truth-value-testing > > -- > My fellow Pythonistas, ask not what our language can do for you, ask > what you can do for our language. > > Mark Lawrence > > -- > https://mail.python.org/mailman/listinfo/python-list > >>> l = [] >>> l [] >>> if l: ... print 'not empty' ... >>> -- Joel Goldstick http://joelgoldstick.com/ http://cc-baseballstats.info/