Re: Format list of list sub elements keeping structure.

2018-07-24 Thread Sayth Renshaw
> > 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

Re: Format list of list sub elements keeping structure.

2018-07-24 Thread Sayth Renshaw
> > 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

Re: Checking whether type is None

2018-07-24 Thread Chris Angelico
On Wed, Jul 25, 2018 at 9:18 AM, Rob Gaddi wrote: > On 07/24/2018 01:07 PM, Chris Angelico wrote: >> >> On Wed, Jul 25, 2018 at 5:33 AM, Tobiah wrote: >>> >>> Consider: >>> >>> >>> type({}) is dict >>> True >>> >>> type(3) is int >>> True >>> >>> type(

Re: Checking whether type is None

2018-07-24 Thread Rob Gaddi
On 07/24/2018 01:07 PM, Chris Angelico wrote: On Wed, Jul 25, 2018 at 5:33 AM, Tobiah wrote: Consider: >>> type({}) is dict True >>> type(3) is int True >>> type(None) is None False Obvious I guess, since the type object is not None. So wh

Re: Checking whether type is None

2018-07-24 Thread Steven D'Aprano
On Tue, 24 Jul 2018 12:33:27 -0700, Tobiah wrote: [...] > So what would I compare type(None) to? Why would you need to? The fastest, easiest, most reliable way to check if something is None is: if something is None > >>> type(None) > > >>> type(None) is NoneType >

RE: Checking whether type is None

2018-07-24 Thread David Raymond
https://docs.python.org/3.7/library/constants.html "None The sole value of the type NoneType..." "x is None" and "type(x) is type(None)" are equivalent because of that. I think though that the better way to do the first tests would be to use isinstance https://docs.python.org/3.7/library/functi

hello from a very excited and totally blind python programmer and game player

2018-07-24 Thread Daniel Perry
Hi there everyone, my name is Daniel Perry and I'm a totally blind new Python user. I've only just recently started picking up python and playing with it and I intend on building some unique audio computer games for the blind. Such things mostly as simulation games like farming, building type ga

Re: Checking whether type is None

2018-07-24 Thread Chris Angelico
On Wed, Jul 25, 2018 at 5:33 AM, Tobiah wrote: > Consider: > > >>> type({}) is dict > True > >>> type(3) is int > True > >>> type(None) is None > False > > Obvious I guess, since the type object is not None. > So what would I compare type(None) to? >

Re: Checking whether type is None

2018-07-24 Thread Iwo Herka
In Python 2, you can import NoneType from types module. In Python 3, the best you can do is: NoneType = type(None) ​Iwo Herka https://github.com/IwoHerka​ ‐‐‐ Original Message ‐‐‐ On 24 July 2018 7:33 PM, Tobiah wrote: > ​​ > > Consider: > > >>> type({}) is dict > > True >

Re: Can pip install packages for all users (on a Linux system)?

2018-07-24 Thread Wolfgang Maier
On 24.07.2018 20:07, John Ladasky wrote: I've been using "sudo pip3 install" to add packages from the PyPI repository. I have multiple user accounts on the computer in question. My goal is to install packages that are accessible to all user accounts. I know that using the Synaptic Package M

Checking whether type is None

2018-07-24 Thread Tobiah
Consider: >>> type({}) is dict True >>> type(3) is int True >>> type(None) is None False Obvious I guess, since the type object is not None. So what would I compare type(None) to? >>> type(None) >>> type(None) is NoneType

Can pip install packages for all users (on a Linux system)?

2018-07-24 Thread John Ladasky
I've been using "sudo pip3 install" to add packages from the PyPI repository. I have multiple user accounts on the computer in question. My goal is to install packages that are accessible to all user accounts. I know that using the Synaptic Package Manager in Ubuntu will install for all users

Re: curses, ncurses or something else

2018-07-24 Thread Peter Pearson
On Mon, 23 Jul 2018 23:24:18 +0100, John Pote wrote: > I recently wrote a command line app to take a stream of numbers, do some > signal processing on them and display the results on the console. There > may be several output columns of data so a title line is printed first. > But the stream of

Re: Tracking a memory leak in C extension - interpreting the output of PYTHONMALLOCSTATS

2018-07-24 Thread Bartosz Golaszewski
2018-07-24 13:30 GMT+02:00 Bartosz Golaszewski : > 2018-07-24 12:09 GMT+02:00 Bartosz Golaszewski : >> 2018-07-23 21:51 GMT+02:00 Thomas Jollans : >>> On 23/07/18 20:02, Bartosz Golaszewski wrote: Hi! >>> >>> Hey! >>> A user recently reported a memory leak in python bindings (C extension

Re: Tracking a memory leak in C extension - interpreting the output of PYTHONMALLOCSTATS

2018-07-24 Thread Bartosz Golaszewski
2018-07-24 12:09 GMT+02:00 Bartosz Golaszewski : > 2018-07-23 21:51 GMT+02:00 Thomas Jollans : >> On 23/07/18 20:02, Bartosz Golaszewski wrote: >>> Hi! >> >> Hey! >> >>> A user recently reported a memory leak in python bindings (C extension >>> module) to a C library[1] I wrote. I've been trying to

Re: Tracking a memory leak in C extension - interpreting the output of PYTHONMALLOCSTATS

2018-07-24 Thread Bartosz Golaszewski
2018-07-23 21:51 GMT+02:00 Thomas Jollans : > On 23/07/18 20:02, Bartosz Golaszewski wrote: >> Hi! > > Hey! > >> A user recently reported a memory leak in python bindings (C extension >> module) to a C library[1] I wrote. I've been trying to fix it since >> but so far without success. Since I'm pro

Re: Format list of list sub elements keeping structure.

2018-07-24 Thread Peter Otten
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

Re: Format list of list sub elements keeping structure.

2018-07-24 Thread Sayth Renshaw
> 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

Re: Non-GUI, single processort inter process massaging - how?

2018-07-24 Thread Chris Green
Dennis Lee Bieber wrote: > On Mon, 23 Jul 2018 22:14:22 +0100, Chris Green declaimed the > following: > > >Anders Wegge Keller wrote: > >> > >> If your update frequency is low enough that it wont kill the filesystem > >> and > >> the amount of data is reasonably small, atomic writes to a fil

Re: Format list of list sub elements keeping structure.

2018-07-24 Thread Peter Otten
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

Re: Format list of list sub elements keeping structure.

2018-07-24 Thread Thomas Jollans
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

Re: Format list of list sub elements keeping structure.

2018-07-24 Thread Vlastimil Brom
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

Re: Format list of list sub elements keeping structure.

2018-07-24 Thread Mark Lawrence
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