ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> python-list
python-list
Re: parse a string (Cadence Allegro Netlist) to dictionary
by Joel Davis other posts by this author
Nov 6 2009 10:30PM messages near this date
Re: parse a string (Cadence Allegro Netlist) to dictionary | Re: parse a string (Cadence Allegro Netlist) to dictionary
On Nov 5, 7:23 pm, metal <metal...@[...].com>  wrote:
>  On 11月6日, 上午4时02分, Leland <lelandp...@[...].com> wrote:
> 
> 
> 
>  > Hi,
> 
>  > I always use readline(), strip(), split() and so on to parse a string.
>  > Is there some elegant way to parse the following string into a
>  > dictionary {'50MHZ_CLK_SRC' : 'U122.2, R1395.1'}?
> 
>  > NET_NAME
>  > '50MHZ_CLK_SRC'
>  >  '@TEST_LIB.TEST(SCH_1):50MHZ_CLK_SRC':
>  >  C_SIGNAL='@test_lib.test(sch_1):\50mhz_clk_src\';
>  > NODE_NAME     U122 2
>  >  '@TEST_LIB.TEST(SCH_1):PAGE92_I223@INF_LOGIC.CY2305(CHIPS)':
>  >  'CLK2': CDS_PINID='CLK2';
>  > NODE_NAME     R1395 1
>  >  '@TEST_LIB.TEST(SCH_1):PAGE92_I232@INF_RESISTORS.RESISTOR(CHIPS)':
>  >  'A': CDS_PINID='A';
> 
>  > Thanks,
>  > Leland
> 
>  not very elegantly too.
> 
>  x = re.findall("_NAME[\n\s']+((?<=').+(?=')|\w+\s+\w+)", s)
>  """
>  print {x[0]: x[1:]}>>> {'50MHZ_CLK_SRC': ['U122 2', 'R1395 1']}
> 
>  """

@metal

Apparently you and I differ considerably on our conceptions of
elegance.
-- 
http://mail.python.org/mailman/listinfo/python-list
Thread:
Leland
Rhodri James
Joel Davis
Emile van Sebille
Metal

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved