Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #100753

Newbie: Convert strings in nested dict to tuples

X-Received by 10.31.157.213 with SMTP id g204mr6695771vke.14.1450826098228; Tue, 22 Dec 2015 15:14:58 -0800 (PST)
X-Received by 10.50.66.208 with SMTP id h16mr448030igt.9.1450826098156; Tue, 22 Dec 2015 15:14:58 -0800 (PST)
Path csiph.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!peer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!6no278624qgy.0!news-out.google.com!l1ni11512igd.0!nntp.google.com!mv3no19829783igc.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups comp.lang.python
Date Tue, 22 Dec 2015 15:14:57 -0800 (PST)
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=209.97.193.146; posting-account=JdkEkAoAAACHHyWOqVGU4JQp9A_G34rU
NNTP-Posting-Host 209.97.193.146
User-Agent G2/1.0
MIME-Version 1.0
Message-ID <b2962e5a-80fc-4012-a9d6-0caa8abd8a2c@googlegroups.com> (permalink)
Subject Newbie: Convert strings in nested dict to tuples
From KP <kai.peters@gmail.com>
Injection-Date Tue, 22 Dec 2015 23:14:58 +0000
Content-Type text/plain; charset=ISO-8859-1
X-Received-Bytes 1652
X-Received-Body-CRC 1196205641
Xref csiph.com comp.lang.python:100753

Show key headers only | View raw


I now know how to convert a string cont. coordinates to a tuple, but hwo can I do this?

Given

cfg = {'canvas': ('3840', '1024'),
      'panel1': {'gpio': '1', 'id': '4', 'co': '0,0,1280,1024'}, 
      'panel2': {'gpio': '2', 'id': '5', 'co': '1280,0,2560,1024'},
      'panel3': {'gpio': '3', 'id': '6', 'co': '2560,0,3840,1024'}}

how can I transform cfg to 

cfg = {'canvas': ('3840', '1024'),
      'panel1': {'gpio': '1', 'id': '4', 'co': ('0','0','1280','1024')}, 
      'panel2': {'gpio': '2', 'id': '5', 'co': ('1280','0','2560','1024')},
      'panel3': {'gpio': '3', 'id': '6', 'co': ('2560','0','3840','1024')}}

Again, thanks for all help!

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Newbie: Convert strings in nested dict to tuples KP <kai.peters@gmail.com> - 2015-12-22 15:14 -0800
  Re: Newbie: Convert strings in nested dict to tuples Peter Otten <__peter__@web.de> - 2015-12-23 00:22 +0100
    Re: Newbie: Convert strings in nested dict to tuples KP <kai.peters@gmail.com> - 2015-12-22 15:31 -0800

csiph-web