>
> Well, your code was close. All you needed was a little tweak
> to make it work like you requested. So keep working at it,
> and if you have a specific question, feel free to ask on the
> list.
>
> Here's a tip. Try to simplify the problem. Instead of
> looping over a list of lists, and then a
> > Then using this cool answer on SO [...]
>
> Oh. I thought you wanted to learn how to solve problems. I had no idea you
> were auditioning for the James Dean part. My bad.
Awesome response burn lol.
I am trying to solve problems. Getting tired of dealing with JSON and having to
figure out
Sayth Renshaw wrote:
>
>> myjson = ...
>> path = "['foo']['bar'][42]"
>> print(eval("myjson" + path))
>>
>> ?
>>
>> Wouldn't it be better to keep 'data' as is and use a helper function like
>>
>> def get_value(myjson, path):
>> for key_or_index in path:
>> myjson = myjson[key_or_in
> myjson = ...
> path = "['foo']['bar'][42]"
> print(eval("myjson" + path))
>
> ?
>
> Wouldn't it be better to keep 'data' as is and use a helper function like
>
> def get_value(myjson, path):
> for key_or_index in path:
> myjson = myjson[key_or_index]
> return myjson
>
> path
Sayth Renshaw wrote:
> I have data which is a list of lists of all the full paths in a json
> document.
>
> How can I change the format to be usable when selecting elements?
How do you want to select these elements?
myjson = ...
path = "['foo']['bar'][42]"
print(eval("myjson" + path))
?
Would
On 24/07/18 08:25, Mark Lawrence wrote:
> On 24/07/18 06:41, Sayth Renshaw wrote:
>> On Tuesday, 24 July 2018 14:25:48 UTC+10, Rick Johnson wrote:
>>> Sayth Renshaw wrote:
>>>
elements = [['[{0}]'.format(element) for element in elements]for
elements in data]
>>>
>>> I would suggest you a
2018-07-24 3:52 GMT+02:00, Sayth Renshaw :
> I have data which is a list of lists of all the full paths in a json
> document.
>
> How can I change the format to be usable when selecting elements?
>
> data = [['glossary'],
> ['glossary', 'title'],
> ['glossary', 'GlossDiv'],
> ['glossary', 'Gloss
On 24/07/18 06:41, Sayth Renshaw wrote:
On Tuesday, 24 July 2018 14:25:48 UTC+10, Rick Johnson wrote:
Sayth Renshaw wrote:
elements = [['[{0}]'.format(element) for element in elements]for elements in
data]
I would suggest you avoid list comprehensions until you master long-form loops.
I
On Tuesday, 24 July 2018 14:25:48 UTC+10, Rick Johnson wrote:
> Sayth Renshaw wrote:
>
> > elements = [['[{0}]'.format(element) for element in elements]for elements
> > in data]
>
> I would suggest you avoid list comprehensions until you master long-form
> loops.
I actually have the answer ex
On Tuesday, 24 July 2018 14:25:48 UTC+10, Rick Johnson wrote:
> Sayth Renshaw wrote:
>
> > elements = [['[{0}]'.format(element) for element in elements]for elements
> > in data]
>
> I would suggest you avoid list comprehensions until you master long-form
> loops.
My general issue is that I wa
I am very close to the end result. I now have it as
Output
[ ['[glossary]'],
['[glossary]', '[title]'],
['[glossary]', '[GlossDiv]'],
['[glossary]', '[GlossDiv]', '[title]'],
['[glossary]', '[GlossDiv]', '[GlossList]'],
['[glossary]', '[GlossDiv]', '[GlossList]', '[GlossEntry
> >
> > for item in data:
> > for elem in item:
> > out = ("[{0}]").format(elem)
> > print(out)
>
> Hint: print implicitly adds a newline to the output string. So collect all
> the values of each sublist and print a line-at-time to output, or use the
> end= argument of Py3's p
I have data which is a list of lists of all the full paths in a json document.
How can I change the format to be usable when selecting elements?
data = [['glossary'],
['glossary', 'title'],
['glossary', 'GlossDiv'],
['glossary', 'GlossDiv', 'title'],
['glossary', 'GlossDiv', 'GlossList'],
['
13 matches
Mail list logo