I am new to Python. I'm trying to get a list of NoneType values to create a subplot (plotly library). The following setup is required to create subplots with different specs:
fig = tools.make_subplots(rows=2, cols=3, specs=[ [{'colspan':3}, None, None],
map(lambda x: {}, ew) ],
shared_xaxes=False, shared_yaxes=False,
start_cell='top-left', print_grid=False)
So, based on the values in the list "ew", a list of Nonetype values is needed. The values in the list can vary and so should the list of Nonetypes.
Solution: List of Strings, List comprehension:
lst =', '.join([str(None) for ticker in ew])
Problem: Strings - convert to Nonetype possible?
Solution: Lambda function that inserts None for each value in ew.
map(lambda x: None, ew)
Problem: Brackets of the list. Can't get rid of them.
The Solution I am looking for:
print(lst)
None, None
<type 'NoneType'>
so that:
fig = tools.make_subplots(rows=2, cols=3, specs=[ [{'colspan':3}, lst],
map(lambda x: {}, ew) ],
shared_xaxes=False, shared_yaxes=False,
start_cell='top-left', print_grid=False)
Is there a way to get such a list? or a better solution over a embedded function?
EDIT since there is still an error by inserting the following 'lst' to fig:
lst = print(*map(lambda x: None, ew), sep= ', ') #returns None, None
print('{lst}'.format(**locals())) #returns only None
-> is this a possible explanation?
If you're using Python 3.x you can try this to print a list without the brackets even if there's a NoneType data included:
print (*lst, sep=', ') #lst = [None, None]
It should output:
None, None
If you're using Python 2.x you can also do this by using from __future__ import print_function