Re: [Tutor] text processing lines variable content

2019-02-07 Thread ingo janssen
On 07/02/2019 18:06, Peter Otten wrote: Sorry, I don't understand the question. after a quick look not unlike what you propose but I have to investigate further, lengths of chunks are known or can be found (sketchy): order=

Re: [Tutor] text processing lines variable content

2019-02-07 Thread Peter Otten
ingo janssen wrote: > > > On 07/02/2019 11:08, Peter Otten wrote: >> replace the sequence of tests with dictionary lookups > > updated the gist a few times, now I could pre calculate the slices to be > taken per line, but will there be much gain compared to the copping from > the left side of

Re: [Tutor] text processing lines variable content

2019-02-07 Thread ingo janssen
On 07/02/2019 11:08, Peter Otten wrote: replace the sequence of tests with dictionary lookups updated the gist a few times, now I could pre calculate the slices to be taken per line, but will there be much gain compared to the copping from the left side of the list? ingo

Re: [Tutor] text processing lines variable content

2019-02-07 Thread ingo janssen
On 07/02/2019 11:08, Peter Otten wrote: Personally I would avoid the NameError and start with empty lists. If you manage to wrap all branches into functions with the same signature you can replace the sequence of tests with dictionary lookups. Just before I saw your post I put my current

Re: [Tutor] text processing lines variable content

2019-02-07 Thread ingo janssen
On 07/02/2019 10:40, Alan Gauld via Tutor wrote: Just saves a little typing is all. Sensei, be lazy, I will study current state of code is at https://gist.github.com/ingoogni/e99c561f23777e59a5aa6b4ef5fe37c8 ingo ___ Tutor maillist -

Re: [Tutor] text processing lines variable content

2019-02-07 Thread Peter Otten
ingo janssen wrote: > > On 07/02/2019 09:29, Peter Otten wrote: >> Where will you get the order from? > > Peter, > > the order comes from the command line. Then my one-function-per-format approach won't work. > I intend to call the python > program with the same command line options as the

Re: [Tutor] text processing lines variable content

2019-02-07 Thread Alan Gauld via Tutor
On 07/02/2019 08:58, ingo janssen wrote: >try: > lbl = f_label(label) >except NameError as e: > lbl = f_number(label) > label=[lbl] Just a minor point but since you aren't doing anything with the error you don't need the 'as e' bit at the end of each

Re: [Tutor] text processing lines variable content

2019-02-07 Thread ingo janssen
On 07/02/2019 09:58, ingo janssen wrote: On 07/02/2019 09:29, Peter Otten wrote: Where will you get the order from? Ahrg, that should have been: #all output formatting options order = "%i %q %r %w %p %P %o %m %g %E %s %e %F %a %A %f %t %l %n %v %c %C" order =

Re: [Tutor] learning python from scratch

2019-02-07 Thread Alan Gauld via Tutor
On 06/02/2019 21:22, Michael Munn wrote: > dear fellow programmeers, this is michael. I have a question for Python. > I'm a beginner Pythonist. I havee been learning the history and it's use > for past years. My main focus this year is to learn it's code and begin > coding. Can you program in any

Re: [Tutor] text processing lines variable content

2019-02-07 Thread ingo janssen
On 07/02/2019 09:29, Peter Otten wrote: Where will you get the order from? Peter, the order comes from the command line. I intend to call the python program with the same command line options as the Voro++ program. Make the python program call the Voro++ and process its output. one

Re: [Tutor] text processing lines variable content

2019-02-07 Thread Peter Otten
ingo janssen wrote: > depending on how the input file is created data packet a can be in an > other position for every line. > figured out how to do it though > > order=[a,b,e,d...] > for i in lines: >i=i.split(" ") > for j in order: >if j = a: > use function for processing data