(1, 2, 10)
> (1, 3, 1)
> (1, 3, 10)
> (3, 2, 1)
> (3, 2, 10)
> (3, 3, 1)
> (3, 3, 10)
> (5, 2, 1)
> (5, 2, 10)
> (5, 3, 1)
> (5, 3, 10)
> (7, 2, 1)
> (7, 2, 10)
> (7, 3, 1)
> (7, 3, 10)
That's precisely it. I missed product. Thanks!
> If you n
u need lists instead of tuples convert them
>>> list(t)
[7, 3, 10]
To pass a varying number of lists use a list of lists and a star argument:
>>> lists = [[[1, 2], [3, 4]], [[10, 20, 30], [40, 50]]]
>>> for item in lists:
... print(list(itertools.product(*item)))
...
Say we have [1,3,5,7], [2,3], [1,10]. I'd like to generate
[1,2,1]
[1,2,10]
[1,3,1]
[1,3,10]
[3,2,1]
[3,2,10]
[3,3,1]
[3,3,10]
[5, ...]
...
[7,3,10]
The number of input lists is variable. The example shows three lists,
but there could be only one or ten lists or any
Jaap Woldringh added the comment:
Op 17-01-2020 om 14:03 schreef Karthikeyan Singaravelan:
> Karthikeyan Singaravelan added the comment:
>
> You're referencing to the same list 3 times in B. So modifying it once means
> all the elements referring to same object reflect the change. Make a copy
Ezio Melotti added the comment:
See also
https://docs.python.org/3/faq/programming.html#why-did-changing-list-y-also-change-list-x
You can use the builtin function id() to see the id of the lists, and verify
whether they refer to the same object or not.
--
nosy: +ezio.melotti
Karthikeyan Singaravelan added the comment:
You're referencing to the same list 3 times in B. So modifying it once means
all the elements referring to same object reflect the change. Make a copy of
the list during append to ensure modification of one doesn't affect other. This
is not a
t.py
messages: 360182
nosy: jjhwoldringh
priority: normal
severity: normal
status: open
title: A matrix (list of lists) behaves differently, depending how it is created
type: behavior
versions: Python 3.6
Added file: https://bugs.python.org/file48849/matrix_experiment.py
__
On Sunday, 22 July 2018 21:07:17 UTC+5:30, Thomas Jollans wrote:
> On 22/07/18 14:53, Sharan Basappa wrote:
> > Thanks. I initially thought about this but did not know if this is legal
> > syntax.
>
> In this kind of situation – you think you know how to do something but
> you're not quite sure
On 22/07/18 14:53, Sharan Basappa wrote:
> Thanks. I initially thought about this but did not know if this is legal
> syntax.
In this kind of situation – you think you know how to do something but
you're not quite sure if it'll work as intended – just try it! Start up
an interactive interpreter,
aran Basappa wrote:
>
> >
> >
> > Thanks. This works in my example. Can you tell me how this works?
> >
> > > You can simply unpack the inner list:
> > >
> > > a, b = results[0]
> > >
> > >
> > > Iwo Herk
erka
> >
> > ‐‐‐ Original Message ‐‐‐
> >
> > On 22 July 2018 11:47 AM, Sharan Basappa sharan.basa...@gmail.com wrote:
> >
> > > I am using a third party module that is returning list of lists.
> > >
> > > I am using the example b
On Sunday, 22 July 2018 18:15:23 UTC+5:30, Frank Millman wrote:
> "Sharan Basappa" wrote in message
> news:8e261f75-03f7-4f80-a516-8318dd138...@googlegroups.com...
> >
> > I am using a third party module that is returning list of lists.
> > I am using the exam
"Sharan Basappa" wrote in message
news:8e261f75-03f7-4f80-a516-8318dd138...@googlegroups.com...
I am using a third party module that is returning list of lists.
I am using the example below to illustrate.
1 results = [['1', 0.99921393753233001]]
2 k = results[0]
3 print k[0]
4
gt; >
> > I am using a third party module that is returning list of lists.
> >
> > I am using the example below to illustrate.
> >
> > 1 results = [['1', 0.99921393753233001]]
> >
> > 2 k = results[0]
> >
> > 3 print k[0]
> >
> &g
You can simply unpack the inner list:
a, b = results[0]
Iwo Herka
‐‐‐ Original Message ‐‐‐
On 22 July 2018 11:47 AM, Sharan Basappa wrote:
>
>
> I am using a third party module that is returning list of lists.
>
> I am using the example below to illustrate.
I am using a third party module that is returning list of lists.
I am using the example below to illustrate.
1 results = [['1', 0.99921393753233001]]
2 k = results[0]
3 print k[0]
4 print k[1]
Assume the line 1 is what is returned.
I am assigning that to another list (k on line 2
On Tuesday, May 22, 2018 at 3:55:58 PM UTC+5:30, Peter Otten wrote:
>
>
> > lst2=lst1[:4]
> > with open("my_csv.csv","wb") as f:
> > writer = csv.writer(f)
> > writer.writerows(lst2)
> >
> > Here it is writing only the first four lists.
>
> Hint: look at the first line
subhabangal...@gmail.com wrote:
> lst2=lst1[:4]
> with open("my_csv.csv","wb") as f:
> writer = csv.writer(f)
> writer.writerows(lst2)
>
> Here it is writing only the first four lists.
Hint: look at the first line in the quotation above.
--
I have a list of lists (177 lists).
I am trying to write them as file.
I used the following code to write it in a .csv file.
import csv
def word2vec_preprocessing():
a1=open("/python27/EngText1.txt","r")
list1=[]
for line in a1:
line1=line.lower().r
Steven D'Aprano <rep...@bugs.python.org>
wrote:
>
> Steven D'Aprano <steve+pyt...@pearwood.info> added the comment:
>
> It isn't clear to me what bug you are reporting here:
>
> - What do you mean by "problem reading back from a list of lists"? What
Steven D'Aprano <steve+pyt...@pearwood.info> added the comment:
It isn't clear to me what bug you are reporting here:
- What do you mean by "problem reading back from a list of lists"? What sort of
problem?
- What makes you think that there is a bug in the interpreter, rath
Jan 7 07:54:52
=
The correct results are:
x: 0klist: [1,2,4]
x: 1klist [2,4,7]
x:2 klist: [2,4,7]
etc.
--
files: check_su.dat, compilation_log, hksu_copy.py
messages: 309597
nosy: JHari
priority: normal
severity: normal
status: open
title: Problem while reading
On 3/1/2017, Sayth Renshaw wrote:
> How can I flatten just a specific sublist of each list in a list of lists?
>
> So if I had this data
>
>
> [ ['46295', 'Montauk', '3', '60', '85', ['19', '5', '1', '0 $277790.00']],
> ['46295', 'Dark Eyes', '5', '59', '83
> Replace the slice row[index:index+1] with row[index], either by building a
> new list or in place:
>
> >>> def show(data):
> ...for item in data: print(item)
> ...
> >>> def flatten_one(rows, index):
> ... return [r[:index] + r[index] + r[index+1:] for r in rows]
> ...
> >>> def
Sayth Renshaw wrote:
> How can I flatten just a specific sublist of each list in a list of lists?
>
> So if I had this data
>
>
> [ ['46295', 'Montauk', '3', '60', '85', ['19', '5', '1', '0
> [ [$277790.00']],
> ['46295', 'Dark Eyes', '5', '59',
Sayth Renshaw writes:
> How can I flatten just a specific sublist of each list in a list of lists?
>
> So if I had this data
>
>
> [ ['46295', 'Montauk', '3', '60', '85', ['19', '5', '1', '0 $277790.00']],
> ['46295', 'Dark Eyes', '5', '59', '83', ['6', '4
How can I flatten just a specific sublist of each list in a list of lists?
So if I had this data
[ ['46295', 'Montauk', '3', '60', '85', ['19', '5', '1', '0 $277790.00']],
['46295', 'Dark Eyes', '5', '59', '83', ['6', '4', '1', '0 $105625.00']],
['46295', 'Machinegun Jubs', '6', '53
On 01/12/2017 02:26 AM, Deborah Swanson wrote:
> It's true, I've only been on this list a few weeks, although I've seen
> and been on the receiving end of the kind of "help" that feels more like
> being sneered at than help. Not on this list, but on Linux and similar
> lists. There does seem to be
On Thu, Jan 12, 2017 at 9:27 PM, Marko Rauhamaa wrote:
> An instructive anecdote: somebody I know told me he once needed the
> definitive list of some websites. He posted a question on the relevant
> online forum, but it fell on deaf ears. After some days, he replied to
> his
"Deborah Swanson" :
> I've only been on this list a few weeks, although I've seen and been
> on the receiving end of the kind of "help" that feels more like being
> sneered at than help. Not on this list, but on Linux and similar
> lists. There does seem to be a "tough
Antoon Pardon wrote, on January 12, 2017 12:49 AM
>
> Op 11-01-17 om 23:57 schreef Deborah Swanson:
> >
> >> What are we supposed to do when somebody asks a question based on
an
> >> obvious mistake? Assume that they're a quick learner who has
probably
> >> already worked out their mistake and
Op 11-01-17 om 23:57 schreef Deborah Swanson:
>
>> What are we supposed to do when somebody asks a question based on an
>> obvious mistake? Assume that they're a quick learner who has probably
>> already worked out their mistake and doesn't need an answer? That
>> would certainly make our life
Steven D'Aprano wrote, on January 10, 2017 6:19 PM
>
> On Tuesday 10 January 2017 18:14, Deborah Swanson wrote:
>
> > I'm guessing that you (and those who see things like you do) might
> > not be used to working with quick learners who make mistakes at
> > first but catch up with them real
On 11/01/2017 02:18, Steven D'Aprano wrote:
On Tuesday 10 January 2017 18:14, Deborah Swanson wrote:
I'm guessing that you (and those who
see things like you do) might not be used to working with quick learners
who make mistakes at first but catch up with them real fast, or you're
very
On Tuesday 10 January 2017 18:14, Deborah Swanson wrote:
> I'm guessing that you (and those who
> see things like you do) might not be used to working with quick learners
> who make mistakes at first but catch up with them real fast, or you're
> very judgemental about people who make mistakes,
On 01/09/2017 11:14 PM, Deborah Swanson wrote:
So I guess you should just do your thing and I'll do mine.
As you say.
Takes all kinds, and I think in the end what will count is the quality of my
finished work (which has always been excellent), and not the messy
process to get there.
ght here.
>
> Indeed.
>
> The issue I (and others) see, though, is more along the lines
> of basic understanding: you seemed to think that a list of
> lists should act the same as a list of tuples, even though
> lists and tuples are not the same thing. It's like expecting
&g
t is right
here.
Indeed.
The issue I (and others) see, though, is more along the lines of basic
understanding: you seemed to think that a list of lists should act the same as
a list of tuples, even though lists and tuples are not the same thing. It's
like expecting a basket of oranges to b
s
> ...
> >>> type(foo())
>
> >>>
>
> ... type() will tell you what class your object is an instance of.
> "" tells you that your object is a list.
>
> > And it behaves like a list sometimes, but many times
> > not.
>
> I thin
4.0 (default, Apr 11 2014, 13:05:18)
> ...
> --> type(list)
>
> -->
> --> type(list())
>
> --> type([1, 2, 3])
>
>
> So the `list` type is 'type', and the type of list instances
> is 'class list'.
I just saw that while replying to MRAB. 'records
never looked at the type
of a list before, probably because lists are so obvious by looking at
them.
> > 'records' is in fact a class, it has an fget method and data members
> > that I've used. And it behaves like a list sometimes, but many times
not.
> >
> Its type
On 10/01/17 03:02, Deborah Swanson wrote:
Erik wrote, on January 09, 2017 5:47 PM
IIRC, you create it using a list comprehension which creates the
records. A list comprehension always creates a list.
Well no. The list is created with:
records.extend(Record._make(row) for row in rows)
No,
On 01/09/2017 07:02 PM, Deborah Swanson wrote:
Erik wrote, on January 09, 2017 5:47 PM
As people keep saying, the object you have called 'records'
is a *list*
of namedtuple objects. It is not a namedtuple.
IIRC, you create it using a list comprehension which creates the
records. A list
On 2017-01-10 03:02, Deborah Swanson wrote:
Erik wrote, on January 09, 2017 5:47 PM
As people keep saying, the object you have called 'records'
is a *list*
of namedtuple objects. It is not a namedtuple.
IIRC, you create it using a list comprehension which creates the
records. A list
Erik wrote, on January 09, 2017 5:47 PM
> As people keep saying, the object you have called 'records'
> is a *list*
> of namedtuple objects. It is not a namedtuple.
>
> IIRC, you create it using a list comprehension which creates the
> records. A list comprehension always creates a list.
Well
On 10/01/17 00:54, Deborah Swanson wrote:
Since I won't change the order of the records again after the sort, I'm
using
records.sort(key=operator.attrgetter("Description", "Date"))
once, which also works perfectly.
So both sorted() and sort() can be used to sort namedtuples. Good to
know!
Peter Otten wrote, on January 09, 2017 3:27 PM
>
> While stable sort is nice in this case you can just say
>
> key=operator.attrgetter("Description", "Date")
>
> Personally I'd only use sorted() once and then switch to the
> sort() method.
This works perfectly, thank you.
As I read the docs,
breamore...@gmail.com wrote:
> On Monday, January 9, 2017 at 5:34:12 PM UTC, Tim Chase wrote:
>> On 2017-01-09 08:31, breamoreboy wrote:
>> > On Monday, January 9, 2017 at 2:22:19 PM UTC, Tim Chase wrote:
>> > > I usually wrap the iterable in something like
>> > >
>> > > def pairwise(it):
>> >
On Monday, January 9, 2017 at 5:34:12 PM UTC, Tim Chase wrote:
> On 2017-01-09 08:31, breamoreboy wrote:
> > On Monday, January 9, 2017 at 2:22:19 PM UTC, Tim Chase wrote:
> > > I usually wrap the iterable in something like
> > >
> > > def pairwise(it):
> > > prev = next(it)
> > > for
Rhodri James wrote:
> On 09/01/17 21:40, Deborah Swanson wrote:
>> Peter Otten wrote, on January 09, 2017 6:51 AM
>>>
>>> records = sorted(
>>> set(records),
>>> key=operator.attrgetter("Description")
>>> )
>>
>> Good, this is confirmation that 'sorted()' is the way to go. I want a 2
>>
On 09/01/17 21:40, Deborah Swanson wrote:
Peter Otten wrote, on January 09, 2017 6:51 AM
records = sorted(
set(records),
key=operator.attrgetter("Description")
)
Good, this is confirmation that 'sorted()' is the way to go. I want a 2
key sort, Description and Date, but I think I can
breamore...@gmail.com wrote, on January 09, 2017 8:32 AM
>
> On Monday, January 9, 2017 at 2:22:19 PM UTC, Tim Chase wrote:
> > On 2017-01-08 22:58, Deborah Swanson wrote:
> > > 1) I have a section that loops through the sorted data, compares
two
> > > adjacent rows at a time, and marks one of
Tim Chase wrote, on January 09, 2017 6:22 AM
>
> On 2017-01-08 22:58, Deborah Swanson wrote:
> > 1) I have a section that loops through the sorted data, compares two
> > adjacent rows at a time, and marks one of them for deletion if the
> > rows are identical.
> > and my question is whether
Peter Otten wrote, on January 09, 2017 6:51 AM
>
> Deborah Swanson wrote:
>
> > Even better, to get hold of all the records with the same
Description
> > as the current row, compare them all, mark all but the different
ones
> > for deletion, and then resume processing the records after the
On Monday, January 9, 2017 at 2:22:19 PM UTC, Tim Chase wrote:
> On 2017-01-08 22:58, Deborah Swanson wrote:
> > 1) I have a section that loops through the sorted data, compares two
> > adjacent rows at a time, and marks one of them for deletion if the
> > rows are identical.
> >
> > I'm using
>
Deborah Swanson wrote:
> Even better, to get hold of all the records with the same Description as
> the current row, compare them all, mark all but the different ones for
> deletion, and then resume processing the records after the last one?
When you look at all fields for deduplication anyway
On 2017-01-08 22:58, Deborah Swanson wrote:
> 1) I have a section that loops through the sorted data, compares two
> adjacent rows at a time, and marks one of them for deletion if the
> rows are identical.
>
> I'm using
>
> for i in range(len(records)-1):
> r1 = records[i]
> r2 =
Steve D'Aprano wrote, on January 09, 2017 3:40 AM
>
> On Mon, 9 Jan 2017 09:57 pm, Deborah Swanson wrote:
>
> [...]
> > I think you are replying to my question about sorting a
> namedtuple, in
> > this case it's called 'records'.
> >
> > I think your suggestion works for lists and tuples, and
On Mon, 9 Jan 2017 09:57 pm, Deborah Swanson wrote:
[...]
> I think you are replying to my question about sorting a namedtuple, in
> this case it's called 'records'.
>
> I think your suggestion works for lists and tuples, and probably
> dictionaries. But namedtuples doesn't have a sort function.
Antoon Pardon wrote, on January 09, 2017 2:35 AM
> If I understand correctly you want something like:
>
> records.sort(key = lamda rec: rec.xx)
>
> AKA
>
> from operator import attrgetter
> records.sort(key = attrgetter('xx'))
>
> or maybe:
>
> records.sort(key = lambda rec:
Antoon Pardon wrote, on January 09, 2017 2:14 AM
> > 1) I have a section that loops through the sorted data, compares two
> > adjacent rows at a time, and marks one of them for deletion if the
> > rows are identical.
> >
> > I'm using
> >
> > for i in range(len(records)-1):
> > r1 =
Op 09-01-17 om 07:58 schreef Deborah Swanson:
> Peter Otten wrote, on January 08, 2017 5:21 AM
>> Deborah Swanson wrote:
>>
>>> Peter Otten wrote, on January 08, 2017 3:01 AM
>>
>> Personally I would recommend against mixing data (an actual location)
> and
>> metadata (the column
Op 09-01-17 om 07:58 schreef Deborah Swanson:
> Peter Otten wrote, on January 08, 2017 5:21 AM
>> Deborah Swanson wrote:
>>
>>> Peter Otten wrote, on January 08, 2017 3:01 AM
>>
>> Personally I would recommend against mixing data (an actual location)
> and
>> metadata (the column
Steven D'Aprano wrote, on January 08, 2017 7:30 PM
>
> On Sunday 08 January 2017 20:53, Deborah Swanson wrote:
>
> > Steven D'Aprano wrote, on January 07, 2017 10:43 PM
>
> No, I'm pretty sure that's not the case. I don't have access
> to your CSV file,
> but I can simulate it:
>
> ls =
Peter Otten wrote, on January 08, 2017 5:21 AM
>
> Deborah Swanson wrote:
>
> > Peter Otten wrote, on January 08, 2017 3:01 AM
>
> Personally I would recommend against mixing data (an actual location)
and
> metadata (the column name,"Location"), but if you wish my code can be
> adapted as
Steven D'Aprano wrote, on January 07, 2017 10:43 PM
>
> On Sunday 08 January 2017 16:39, Deborah Swanson wrote:
>
> The recommended way is with the _replace method:
>
> py> instance._replace(A=999)
> Record(A=999, B=20, C=30)
> py> instance._replace(A=999, C=888)
> Record(A=999, B=20, C=888)
>
On Sunday 08 January 2017 20:53, Deborah Swanson wrote:
> Steven D'Aprano wrote, on January 07, 2017 10:43 PM
>>
>> On Sunday 08 January 2017 16:39, Deborah Swanson wrote:
>>
>> > What I've done so far:
>> >
>> > with open('E:\\Coding projects\\Pycharm\\Moving\\Moving
>> 2017 in.csv',
>> >
Paul Rudin wrote, on January 08, 2017 6:49 AM
>
> "Deborah Swanson" writes:
>
> > Peter Otten wrote, on January 08, 2017 3:01 AM
> >>
> >> columnA = [record.A for record in records]
> >
> > This is very neat. Something like a list comprehension for named
> > tuples?
"Deborah Swanson" writes:
> Peter Otten wrote, on January 08, 2017 3:01 AM
>>
>> columnA = [record.A for record in records]
>
> This is very neat. Something like a list comprehension for named tuples?
Not something like - this *is* a list comprehension - it creates a
Peter Otten wrote, on January 08, 2017 5:21 AM
>
> Deborah Swanson wrote:
>
> > Peter Otten wrote, on January 08, 2017 3:01 AM
> >>
> >> Deborah Swanson wrote:
> >>
> >> > to do that is with .fget(). Believe me, I tried every > possible
> >> > way
> > to
> >> > use instance.A or instance[1]
Deborah Swanson wrote:
> Peter Otten wrote, on January 08, 2017 3:01 AM
>>
>> Deborah Swanson wrote:
>>
>> > to do that is with .fget(). Believe me, I tried every > possible way
> to
>> > use instance.A or instance[1] and no way could I get ls[instance.A].
>>
>> Sorry, no.
>
> I quite agree,
Peter Otten wrote, on January 08, 2017 3:01 AM
>
> Deborah Swanson wrote:
>
> > to do that is with .fget(). Believe me, I tried every > possible way
to
> > use instance.A or instance[1] and no way could I get ls[instance.A].
>
> Sorry, no.
I quite agree, I was describing the dead end I was in
Deborah Swanson wrote:
> to do that is with .fget(). Believe me, I tried every possible way to
> use instance.A or instance[1] and no way could I get ls[instance.A].
Sorry, no.
To get a list of namedtuple instances use:
rows = csv.reader(infile)
Record = namedtuple("Record", next(rows))
Steven D'Aprano wrote, on January 07, 2017 10:43 PM
>
> On Sunday 08 January 2017 16:39, Deborah Swanson wrote:
>
> > What I've done so far:
> >
> > with open('E:\\Coding projects\\Pycharm\\Moving\\Moving
> 2017 in.csv',
> > 'r') as infile:
> > ls = list(csv.reader(infile))
> > lst =
On Sunday 08 January 2017 16:39, Deborah Swanson wrote:
> What I've done so far:
>
> with open('E:\\Coding projects\\Pycharm\\Moving\\Moving 2017 in.csv',
> 'r') as infile:
> ls = list(csv.reader(infile))
> lst = namedtuple('lst', ls[0])
>
> where 'ls[0]' is the header row of the csv,
What I've done so far:
with open('E:\\Coding projects\\Pycharm\\Moving\\Moving 2017 in.csv',
'r') as infile:
ls = list(csv.reader(infile))
lst = namedtuple('lst', ls[0])
where 'ls[0]' is the header row of the csv, and it works perfectly well.
'lst' is a namedtuple instance with each of
it as,
[[('the','DT'),('film',
'NN'),('was','AV'),('nice','ADJ')],[('leonardo','NN'),('is','AV'),('great','ADJ')],[('it','PRP'),
('was','AV'),('academy','NN'),('award','NN')]]
that is a list of lists where in each list there is a set of tuples.
I could solve each one like I am getting
one list
subhabangal...@gmail.com writes:
> Now if I want to change the values of tags like 'AT', 'NP-TL',
> 'NN-TL', etc. to some arbitrary ones like XX,YY,ZZ and yet preserve
> total structure of tuples in list of lists, please suggest how may I
> do it.
Changing items in lists is done
Hi
I am trying to use the following set of tuples in list of lists.
I am using a Python based library named, NLTK.
>>> import nltk
>>> from nltk.corpus import brown as bn
>>> bt=bn.tagged_sents()
>>> bt_5=bt[:5]
>>> print bt
[[(u'The', u'AT'
gt; list_of_lists[0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0]
> [[...]]
>
Sorry For Bad Question, But I need List Of Lists That I Can
Acces Horyzontaly, Not In The Deep(But This IS Not All,
I End That Evey List In List Of Lists Can Be A List...
Thanks In Advance...
Robert..;)
--
https://mail.python.org/mailman/listinfo/python-list
Dana petak, 20. studenoga 2015. u 14:06:31 UTC+1, korisnik Nagy László Zsolt
napisao je:
> > Sorry For Bad Question, But I need List Of Lists That I Can
> > Acces Horyzontaly, Not In The Deep(But This IS Not All,
> > I End That Evey List In List Of Lists Can Be A List...
&g
> Sorry For Bad Question, But I need List Of Lists That I Can
> Acces Horyzontaly, Not In The Deep(But This IS Not All,
> I End That Evey List In List Of Lists Can Be A List...
It is not possible to do it with a native list. But you can write your
own iterable that can be iterate
On Sat, Nov 21, 2015 at 12:06 AM, Nagy László Zsolt
<gand...@shopzeus.com> wrote:
>> Sorry For Bad Question, But I need List Of Lists That I Can
>> Acces Horyzontaly, Not In The Deep(But This IS Not All,
>> I End That Evey List In List Of Lists Can Be A List...
&g
On 2015-11-20, HKRSS <hk...@gmail.com> wrote:
>
> Sorry For Bad Question, But I need List Of Lists That I Can
> Acces Horyzontaly, Not In The Deep(But This IS Not All,
> I End That Evey List In List Of Lists Can Be A List...
>
> Thanks In Advance...
> Robert..;)
On Fri, 20 Nov 2015 08:43:04 +0100, HKRSS wrote:
> Thanks In Advance, Robert...;)
Just keep appending child lists to parent list:
l = []
while True:
l.append([])
Until you run out of memory
But I think that this answer although it appears accurate to the question
is not a solut
On Fri, Nov 20, 2015 at 6:39 PM, Chris Angelico wrote:
> My crystal ball suggests that defaultdict(list) might be useful here.
>
> ChrisA
I used something similar to this for some problem in hackerrank,
anyway i think this is what you want.
class defaultlist(object):
def
Dana petak, 20. studenoga 2015. u 18:16:52 UTC+1, korisnik Denis McMahon
napisao je:
> On Fri, 20 Nov 2015 08:43:04 +0100, HKRSS wrote:
>
> > Thanks In Advance, Robert...;)
>
> Just keep appending child lists to parent list:
>
> l = []
>
> while True:
>l.
On Fri, Nov 20, 2015 at 11:58 PM, srinivas devaki
wrote:
> def __str__(self):
> if len(self.list) == 0:
> return '(' + str(self.data) + ')[...]'
> return ''.join(['(', str(self.data), ')['] + map(str, self.list) +
> [', ...]'])
> ...
>
On Fri, Nov 20, 2015 at 11:16 AM, <robert.bra...@si.t-com.hr> wrote:
> Dana petak, 20. studenoga 2015. u 18:16:52 UTC+1, korisnik Denis McMahon
> napisao je:
>> On Fri, 20 Nov 2015 08:43:04 +0100, HKRSS wrote:
>>
>> > Thanks In Advance, Robert...;)
>>
>&
On Sat, Nov 21, 2015 at 5:16 AM, wrote:
> I Think That LISP Is Only Solution, I Wil Give Up Frpm Python...
Capital Letters For The Win. You Should Consider Talking In German.
ChrisA
--
https://mail.python.org/mailman/listinfo/python-list
gt; >
> > Just keep appending child lists to parent list:
> >
> > l = []
> >
> > while True:
> >l.append([])
> >
> > Until you run out of memory
> >
> > But I think that this answer although it appears accurate to the question
&
HKRSS wrote:
> Thanks In Advance, Robert...;)
>>> list_of_lists = []
>>> list_of_lists.append(list_of_lists)
>>> list_of_lists[0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0]
[[...]]
--
https://mail.python.org/mailman/listinfo/python-list
Thanks In Advance, Robert...;)
--
https://mail.python.org/mailman/listinfo/python-list
I Think That There Are Two Ways:
1)Harder Way Use Procedural C...
2)Easier Way Use LISP...
"HKRSS" wrote in message
news:n2miu8$fl4$1...@ls237.t-com.hr...
> Thanks In Advance, Robert...;)
>
>
--
https://mail.python.org/mailman/listinfo/python-list
Martin Panter added the comment:
This is how Python is meant to work; see
https://docs.python.org/2.7/faq/programming.html#how-do-i-create-a-multidimensional-list.
Unless there is something in the documentation that gave you the wrong
impression, I suggest we close this.
--
nosy:
Changes by Martin Panter vadmium...@gmail.com:
--
stage: - resolved
status: open - closed
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24589
___
Zorceta added the comment:
FYI:
ll = [[]]*10
[id(l) for l in ll]
[67940296, 67940296, 67940296, 67940296, 67940296, 67940296, 67940296,
67940296, 67940296, 67940296]
--
nosy: +zorceta
___
Python tracker rep...@bugs.python.org
New submission from Jos Dechamps:
After creating a list of lists, changing one element, leads to changes of all
the elements:
v=[[]]*10
v
[[], [], [], [], [], [], [], [], [], []]
v[3].append(3)
v
[[3], [3], [3], [3], [3], [3], [3], [3], [3], [3]]
v=[[]]*10
v
Bastiaan Albarda added the comment:
The * operator lets you use the same object multiple times, thereby saving
resources.
If you want unique objects use comprehension:
v = [[] for x in range(10)]
v[3].append(3)
v
[[], [], [], [3], [], [], [], [], [], []]
v[3] += [3]
v
[[], [], [], [3,
On 23/04/2015 2:18 AM, subhabrata.bane...@gmail.com wrote:
I have a list of file names of a directory, I want to read each one of them.
After reading each one of them, I want to put the results of each file in a
list.
These lists would again be inserted to create a list of lists.
While
1 - 100 of 433 matches
Mail list logo