Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Matt Wheeler Newsgroups: comp.lang.python Subject: Re: Considering migrating to Python from Visual Basic 6 for engineering applications Date: Fri, 19 Feb 2016 17:05:48 +0000 Lines: 23 Message-ID: References: <90cc50d2-1ce5-4588-9bfd-a49d439f00dd@googlegroups.com> <14c75a68-0d2e-45cc-8d73-0d71b6a6aea6@googlegroups.com> <9e57761f-26e1-41c5-8e71-23800de1fdd3@googlegroups.com> <20160219074057.16b9eddb@bigbox.christie.dr> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de gEmynJiOMUaj65+RqbfNOAVWAEsF0nN2V2yPodrMbf0A== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.010 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'exercise': 0.03; 'subject:Python': 0.05; 'subject:Visual': 0.09; 'thread': 0.10; 'subject: \n ': 0.15; '2016': 0.16; 'jumping': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; '>>>': 0.20; 'int,': 0.22; 'parser': 0.22; 'fit': 0.23; 'tim': 0.24; 'words': 0.24; 'header:In-Reply-To:1': 0.24; 'message- id:@mail.gmail.com': 0.27; 'chase': 0.29; 'giant': 0.29; 'there.': 0.30; "i'm": 0.30; "i'd": 0.31; 'probably': 0.31; 'received:google.com': 0.35; 'returning': 0.35; 'received:74.125.82': 0.35; 'but': 0.36; 'there': 0.36; '(i.e.': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'anything': 0.38; 'sure': 0.39; 'subject:from': 0.39; 'rather': 0.39; 'to:addr:python.org': 0.40; 'course': 0.62; 'float,': 0.84; 'from:addr:m': 0.84; 'otten': 0.84 X-Virus-Scanned: Debian amavisd-new at membrane.funkyhat.net X-Gm-Message-State: AG10YOS2qDWkNmdh8jIVejx1AtV+Fp1BYuO83ZZG2c9ycljeL58/7w4vGkYr1tYsRJanevSLGvwPzRVF0bD0mQ== X-Received: by 10.194.61.131 with SMTP id p3mr9295611wjr.159.1455901568809; Fri, 19 Feb 2016 09:06:08 -0800 (PST) In-Reply-To: X-Gmail-Original-Message-ID: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21rc2 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:103206 On 19 February 2016 at 14:58, Peter Otten <__peter__@web.de> wrote: > Tim Chase wrote: >> [a long thing] > > Or just tell the parser what to expect: > > [another long thing] If you're sure all of the words on a line are going to be numbers then >>> [float(x) for x in '2 12.657823 0.1823467E-04 114 0'.split()] [2.0, 12.657823, 1.823467e-05, 114.0, 0.0] This will of course break if anything on the line *doesn't* look like a float, but rather than jumping straight into a giant engineering exercise I'd probably start there. I'm sure there was a recent thread about returning the best fit type (i.e. int, if not then float, if not then str)? -- Matt Wheeler http://funkyh.at