Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'languages.': 0.04; 'that?': 0.05; 'subject:Python': 0.06; 'attribute': 0.07; 'variables': 0.07; 'feature,': 0.09; 'ide': 0.09; 'python': 0.11; 'def': 0.12; 'language,': 0.12; 'suggest': 0.14; 'wrote': 0.14; 'anyway': 0.14; 'language.': 0.14; 'mostly': 0.14; '11:32': 0.16; 'attributes.': 0.16; 'crude': 0.16; 'declarations': 0.16; 'dict': 0.16; 'dump': 0.16; 'forbids': 0.16; 'forth.': 0.16; 'implies': 0.16; 'investigate': 0.16; 'local.': 0.16; 'modules.': 0.16; 'objects.': 0.16; 'flexibility': 0.16; 'all.': 0.16; 'so.': 0.16; 'language': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'module': 0.19; 'skip:g 40': 0.19; 'things.': 0.19; 'typing': 0.19; 'help.': 0.21; 'code,': 0.22; 'example': 0.22; 'programming': 0.22; 'comfortable': 0.22; 'header:User-Agent:1': 0.23; 'example.': 0.24; 'library,': 0.24; 'skip:l 30': 0.24; "haven't": 0.24; 'second': 0.26; 'pass': 0.26; 'asking': 0.27; 'certain': 0.27; 'values': 0.27; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'feature': 0.29; "doesn't": 0.30; 'skip:g 30': 0.30; 'statement': 0.30; 'code': 0.31; 'easier': 0.31; 'breaking': 0.31; 'flying': 0.31; 'forces': 0.31; 'styles': 0.31; 'class': 0.32; 'probably': 0.32; 'entirely': 0.33; 'programmers': 0.33; '"the': 0.34; "i'd": 0.34; 'could': 0.34; 'classes': 0.35; 'something': 0.35; 'objects': 0.35; 'but': 0.35; 'there': 0.35; 'really': 0.36; 'doubt': 0.36; 'functions.': 0.36; 'impression': 0.36; 'keyword': 0.36; 'leads': 0.36; 'object,': 0.36; 'processed': 0.36; 'next': 0.36; 'should': 0.36; 'seconds': 0.37; 'too': 0.37; 'list': 0.37; 'somebody': 0.38; 'handle': 0.38; 'to:addr:python-list': 0.38; 'files': 0.38; 'pm,': 0.38; 'short': 0.38; 'structure': 0.39; 'to:addr:python.org': 0.39; 'enough': 0.39; 'how': 0.40; 'even': 0.60; 'read': 0.60; 'easy': 0.60; 'hope': 0.61; 'utilize': 0.61; 'new': 0.61; 'simple': 0.61; "you're": 0.61; 'first': 0.61; 'address': 0.63; 'information': 0.63; 'skip:n 10': 0.64; 'became': 0.64; 'networking': 0.64; 'more': 0.64; 'different': 0.65; 'within': 0.65; 'received:74.208': 0.68; 'funny': 0.74; 'as:': 0.81; 'you:': 0.81; 'benchmark': 0.84; 'delphi,': 0.84; 'etc..': 0.84; 'mature': 0.84; 'received:74.208.4.194': 0.84; 'thing...': 0.84 Date: Wed, 03 Dec 2014 00:02:20 -0500 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Python handles globals badly. References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:b6hBQK8moZUPmVv8ps7wtCMQ0VD/CY/80nl7D2w/P1v 3n7E1kuFS0RRcY96kHWdafZMhb7PCgj4BXNPfhuWzK47h7PyRk vXgXMTnrK0wznFsGvEjjVGUM5h4/iMD8sUsTIVCw5sHLCuYwyA NkUJ6BMTqS7Y9glq7Tzrfev6p/zyY5CGuXCJG7I/o/Ay8ryDSN COGUG594c2YQpZoxx15UWQPW52c+Kcb2zZeZ9ao6IuxtZnfgTZ SDTxeKWWI4QTdg9hQ7BYhfrgKmyypS8CEa5ArW7ub+wKY9xHYS eokNhZvKrgd2IL2kK1cEaQZ7NZ0AwEzIgutAOZ3ARkxoAR+oQM 2LV2c68Py2O1I/rEXqaM= X-UI-Out-Filterresults: notjunk:1; X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 103 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1417582963 news.xs4all.nl 2871 [2001:888:2000:d::a6]:33149 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:81834 On 12/02/2014 11:32 PM, Skybuck Flying wrote: > Some issues I'd like to address to you: > > 1. Structured programming requires more programming time. > 2. Structured programming implies structure which might be less flexible. > 3. Python objects require "self" keyword to be used everywhere, and > other akwardness wich leads to more typing/programming/writing time. > > I used the list feature of python to dump these variable in a list so > that all variables can be processed by a while loop and so forth. Care to share what you mean by "the list feature"? Perhaps you'd do better with "the dict feature", or "the attribute feature." > > At first I wanted flexibility and all variables were individually > "logic-ed" / "processed" but this became too much code to work with. > No meaning without an example. > I was also under the impression using many ifs might be faster than > lists, but this was bogus information at best. They do entirely different things. Without example code, this statement is also meaningless to me. > > I wrote a simple short benchmark for if vs list and list performed fast > enough for my purposes, it could both handle 500k of items without > breaking a sweat, meaning within 1 to 3 seconds or so. > > I am still new at python and definetly don't feel comfortable with the > object feature, though I did use it for these variables which are > actually objects. Everything in Python is an object, from ints to functions. That makes lots of things easier and more symmetric. > > I used to program in Delphi, there I would do everything OO and modular. So why do you no longer want to do that? > > Lastly I also don't like the module approach in python because the > sikuli ide doesn't really support working with multiple files that well. So don't use modules. Nothing about the language forces you to. The main time you might need modules is when you write your second program. Of course, it's nice that somebody else wrote lots of modules for you, the standard library, and PIPI. > > Python also comes with nice libaries/lists/dictionaries/file io etc.. > all easy to use... > > I haven't tried networking with python yet... that could be funny to try > next for my bots :) > > Anyway this global thing made my doubt if python is a good thing... all > in all it wasn't too bad... > You still haven't figured out that declaring the occasional global is much less typing than declaring every local. If you're writing code that's mostly using globals, you probably should investigate the tens of thousands of other languages. > Though I do hope to see a programming language some day, that is aimed > at more mature programmers that know what they are doing. > > Instead of a language aimed at noobs :) a noob language which forbids > certain styles of programming because it would be "bad". That's ridiculous. Python is far from a "noob" language. But when you're a noob, and can still get things accomplished, that's a good thing. Then when you're ready to learn more about the language, asking non-confrontational questions might get you some help. I suggest you learn enough about classes to understand how to make and utilize an object with arbitrary attributes. Even if you did something as crude as: class Dummy(object): pass global = Dummy() global.ShipAbilityDistributeShieldPower = 42 global.ShipAbilityTargetWeaponsSubsystems = 12 ... You can then read and write those values inside functions with no global declarations at all. def myfunc(): if something: global.ShipAbilityDistributeShieldPower = 2 -- DaveA