Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #103713
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | MRAB <python@mrabarnett.plus.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: General computer language, syntax question. |
| Date | Mon, 29 Feb 2016 14:07:02 +0000 |
| Lines | 35 |
| Message-ID | <mailman.9.1456754835.20602.python-list@python.org> (permalink) |
| References | <5b619ffa-aae6-4fa8-9f62-58532668ec93@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Trace | news.uni-berlin.de D5lhFkI498DlzZAid22Kwgj+Nl9WpvLPSNdLKzx6Uziw== |
| Return-Path | <python@mrabarnett.plus.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'javascript,': 0.07; '"if': 0.09; 'empty,': 0.09; 'subject:language': 0.09; 'python': 0.10; "'b',": 0.16; "'c'": 0.16; "'c',": 0.16; "'d',": 0.16; "'e']": 0.16; "['a',": 0.16; 'boolean': 0.16; 'cyclic': 0.16; 'empty.': 0.16; 'exhausted': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'help?': 0.16; 'javascript"': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'nodes': 0.16; 'received:192.168.1.4': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'element': 0.18; '>>>': 0.20; 'programming': 0.22; 'header:In-Reply-To:1': 0.24; 'feature': 0.24; 'script': 0.25; 'header:User-Agent:1': 0.26; 'entries': 0.27; 'skip:( 20': 0.28; 'node': 0.29; 'subset': 0.29; 'array': 0.29; 'received:84': 0.32; 'problem': 0.33; 'lock': 0.33; 'languages': 0.34; 'add': 0.34; 'false': 0.35; 'but': 0.36; 'list,': 0.36; 'should': 0.36; 'instead': 0.36; 'there': 0.36; 'possible.': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'really': 0.37; 'turn': 0.37; 'list.': 0.37; 'seem': 0.37; 'sure': 0.39; 'does': 0.39; 'received:192': 0.39; 'to:addr:python.org': 0.40; 'email addr:gmail.com': 0.62; 'more': 0.63; 'due': 0.65; 'beautiful': 0.66; 'lack': 0.76; 'networks,': 0.79; 'madness.': 0.84; 'subject:General': 0.84 |
| X-CM-Score | 0.00 |
| X-CNFS-Analysis | v=2.1 cv=bsGxfxui c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=IkcTkHD0fZMA:10 a=pGLkceISAAAA:8 a=_R4aTjxZHuFDHGoqUu4A:9 a=QEXdDO2ut3YA:10 |
| X-AUTH | mrabarnett@:2500 |
| User-Agent | Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 |
| In-Reply-To | <5b619ffa-aae6-4fa8-9f62-58532668ec93@googlegroups.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.21 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Xref | csiph.com comp.lang.python:103713 |
Show key headers only | View raw
On 2016-02-29 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.
>
Does this help?
>>> items = ['a', 'b', 'c', 'd', 'e']
>>> 'c' in items
True
>>> 'f' in items
False
>>> len(items)
5
>>> len([])
0
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
General computer language, syntax question. jonas.thornvall@gmail.com - 2016-02-29 05:45 -0800
Re: General computer language, syntax question. jonas.thornvall@gmail.com - 2016-02-29 05:56 -0800
Re: General computer language, syntax question. jonas.thornvall@gmail.com - 2016-02-29 06:05 -0800
Re: General computer language, syntax question. Joel Goldstick <joel.goldstick@gmail.com> - 2016-02-29 09:38 -0500
Re: General computer language, syntax question. Ian Kelly <ian.g.kelly@gmail.com> - 2016-02-29 07:54 -0700
Re: General computer language, syntax question. Steven D'Aprano <steve@pearwood.info> - 2016-03-01 22:42 +1100
Re: General computer language, syntax question. Joel Goldstick <joel.goldstick@gmail.com> - 2016-02-29 08:55 -0500
Re: General computer language, syntax question. MRAB <python@mrabarnett.plus.com> - 2016-02-29 14:07 +0000
Re: General computer language, syntax question. Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-02-29 14:39 +0000
Re: General computer language, syntax question. Joel Goldstick <joel.goldstick@gmail.com> - 2016-02-29 09:48 -0500
csiph-web