Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Dennis Lee Bieber Newsgroups: comp.lang.python Subject: Re: Considering migrating to Python from Visual Basic 6 for engineering applications Date: Fri, 19 Feb 2016 08:13:15 -0500 Organization: IISS Elusive Unicorn Lines: 80 Message-ID: References: <9e57761f-26e1-41c5-8e71-23800de1fdd3@googlegroups.com> <729e6513-4d1d-4b9b-be8b-4b7664abac2e@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de BMykk85ASB8pQU3muR5wAwXdcDVRILw/n9HyEdCk6l/Q== Return-Path: 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; 'python,': 0.02; 'url:pypi': 0.03; 'subject:Python': 0.05; 'float': 0.05; 'lines,': 0.05; 'delimiter': 0.09; 'input,': 0.09; 'integer,': 0.09; 'integers': 0.09; 'message-id:@4ax.com': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:Visual': 0.09; 'tuple': 0.09; 'type;': 0.09; 'python.': 0.11; 'def': 0.13; '#no': 0.16; '2016': 0.16; '>that': 0.16; 'columns': 0.16; 'fld': 0.16; 'input.': 0.16; 'integers,': 0.16; 'loops': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'vb.net': 0.16; 'string': 0.17; 'integer': 0.18; 'string,': 0.18; 'url:home': 0.18; 'input': 0.18; 'language': 0.19; 'arrays': 0.22; 'lawrence': 0.22; 'parse': 0.22; 'simpler': 0.22; 'decide': 0.23; 'seems': 0.23; 'feb': 0.23; 'ignored.': 0.23; 'specified': 0.23; 'split': 0.23; "haven't": 0.24; 'sort': 0.25; 'module': 0.25; "i've": 0.25; 'command': 0.26; 'header:X-Complaints-To:1': 0.26; 'rest': 0.26; 'error': 0.27; 'checking': 0.27; 'fri,': 0.27; 'data,': 0.27; 'entries': 0.27; 'array': 0.29; 'character': 0.29; "i'm": 0.30; 'becomes': 0.30; 'skip:[ 10': 0.31; 'operations': 0.31; 'fixed': 0.31; 'anyone': 0.32; 'included': 0.32; 'language.': 0.32; 'url:python': 0.33; 'int': 0.33; 'surely': 0.33; 'utility': 0.33; 'values.': 0.33; 'languages': 0.34; 'structure': 0.34; 'list': 0.34; 'could': 0.35; 'done': 0.35; 'fail': 0.35; 'something': 0.35; 'asking': 0.35; 'but': 0.36; 'there': 0.36; 'url:org': 0.36; 'url:library': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'being': 0.37; 'received:org': 0.37; 'charset:us-ascii': 0.37; 'data': 0.39; 'sure': 0.39; 'subject:from': 0.39; "didn't": 0.39; 'to:addr:python.org': 0.40; 'mark': 0.40; 'called': 0.40; 'some': 0.40; 'easy': 0.60; 'url:3': 0.60; 'your': 0.60; 'provide': 0.61; 'email addr:gmail.com': 0.62; 'granted': 0.63; 'different': 0.63; 'within': 0.64; 'our': 0.64; 'for:': 0.64; 'here': 0.66; 'soon,': 0.76; '(10': 0.84; '1960s.': 0.84; 'pythonistas,': 0.84; '.net,': 0.91; 'dennis': 0.91; 'received:108': 0.93; 'engineers,': 0.95 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: adsl-108-68-179-144.dsl.klmzmi.sbcglobal.net X-Newsreader: Forte Agent 6.00/32.1186 X-No-Archive: YES 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:103192 On Fri, 19 Feb 2016 03:53:03 -0800 (PST), wrong.address.1@gmail.com declaimed the following: > >That is what VB.net seems designed for. I know nothing about Python, and have to decide soon, so I am asking these *very stupid* questions. > I've not done .NET, but surely they haven't removed the ability to read a full line and then perform string operations on the result to find fields. But in general, for ad-hoc input, scanning of some sort will be required to locate/parse the values. It becomes much simpler if the input has a specified structure (fixed columns being traditional). >The new languages are not designed by engineers or for engineers, so it is likely that what we take for granted may not be easy in Python. It was different when there was no such thing called "computer science" in the 1960s. > There was FORTRAN -- which didn't even have a character string data type; one used fixed size arrays of individual characters and had to perform lots of loops to locate and copy "words". Heck, even in the mid-80s, one of the most used utility functions in the department I was in was to take a line of user input and split it into a 2-dimensional array (10 entries of 32 characters max) on white space, just so the rest of the program could parse the user command input. Provide a specification for your input data, and I'm sure almost anyone here could come up with something to read it. >2 12.657823 0.1823467E-04 114 0 >3 4 5 9 11 >"Lower" >278.15 A block of four lines, white-space delimited: Integer, 2 floats, 2 integers 5 integers string with " delimiter float def readBlock(fin): #NO ERROR CHECKING INCLUDED ln = fin.readline().strip() flds = ln.split() l1 = [int(flds[0]), float(flds[1]), float(flds[2]), int(flds[3]), int(flds[4])] ln = fin.readline().strip() l2 = [int(fld) for fld in ln.split()] ln = fin.readline().strip() l3 = ln.strip('"') ln = fin.readline().strip() l4 = float(ln) return (l1, l2, l3, l4) The "l1 =" line could fail for: less than 5 fields on the input line; invalid character for int/float data within a field; excess fields will be ignored. The "l2 =" line could fail for: invalid character for int data; it will accept any number of integer fields. The "l4 =" could fail for invalid characters for a float. What it returns is a tuple containing a list of 5 (mixed) numerics, a list of 5 integers, one string, and a float. >> https://docs.python.org/3/library/re.html. Or a likely replacement for >> the re module https://pypi.python.org/pypi/regex. >> > >Thanks. > >> -- >> My fellow Pythonistas, ask not what our language can do for you, ask >> what you can do for our language. >> >> Mark Lawrence -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/