Re: [Tutor] bracket issue

2017-04-18 Thread Cameron Simpson
On 15Apr2017 14:05, Alan Gauld wrote: On 15/04/17 03:17, Palm Tree wrote: s="2*3+3(8-4(5+6+9))+2+3+3(4/4)" i want to find expression enclosed in brackets. i want outputs to be like: (8-4(5+6+9)) (5+6+9) (4/4) You probably could do it with some fancy regex but personally I'd investigate a

Re: [Tutor] bracket issue

2017-04-17 Thread Danny Yoo
> coming to recursion well i currently use eval() so everything ok i don't > have to worry about brackets but i want to write my own parser. a top down > parser for expressions. Do *not* use eval to parse expressions. It is an extremely bad idea to do this. Instead, you can use ast.parse, whic

Re: [Tutor] bracket issue

2017-04-16 Thread Palm Tree
-- Forwarded message -- From: "Palm Tree" Date: 16 Apr 2017 10:07 Subject: Re: [Tutor] bracket issue To: "Peter Otten" <__pete...@web.de> Cc: Ok thanks for the answers. Perfect. Just to clarify why i wanted recursion was that well coming to compiler

Re: [Tutor] bracket issue

2017-04-15 Thread Peter Otten
Palm Tree wrote: > hi all. i'm trying to write a simple program. i'm using python 3.4 > > let us say i have > > s="2*3+3(8-4(5+6+9))+2+3+3(4/4)" > > i want to find expression enclosed in brackets. > > i want outputs to be like: > (8-4(5+6+9)) > (5+6+9) > (4/4) > note : i'd like an answer invol

Re: [Tutor] bracket issue

2017-04-15 Thread Alan Gauld via Tutor
On 15/04/17 03:17, Palm Tree wrote: > s="2*3+3(8-4(5+6+9))+2+3+3(4/4)" > > i want to find expression enclosed in brackets. > > i want outputs to be like: > (8-4(5+6+9)) > (5+6+9) > (4/4) > You probably could do it with some fancy regex but personally I'd investigate a proper text parser. There

[Tutor] bracket issue

2017-04-15 Thread Palm Tree
hi all. i'm trying to write a simple program. i'm using python 3.4 let us say i have s="2*3+3(8-4(5+6+9))+2+3+3(4/4)" i want to find expression enclosed in brackets. i want outputs to be like: (8-4(5+6+9)) (5+6+9) (4/4) i've tried where denotes an indentation level : #first part sbracket