Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #99131 > unrolled thread
| Started by | "HKRSS" <hkrss@gmail.com> |
|---|---|
| First post | 2015-11-20 08:43 +0100 |
| Last post | 2015-11-20 11:26 -0800 |
| Articles | 15 — 10 participants |
Back to article view | Back to comp.lang.python
How To Create A Endles List Of Lists In Python...??? "HKRSS" <hkrss@gmail.com> - 2015-11-20 08:43 +0100
Re: How To Create A Endles List Of Lists In Python...??? "HKRSS" <hkrss@gmail.com> - 2015-11-20 09:13 +0100
Re: How To Create A Endles List Of Lists In Python...??? Peter Otten <__peter__@web.de> - 2015-11-20 09:53 +0100
Re: How To Create A Endles List Of Lists In Python...??? "HKRSS" <hkrss@gmail.com> - 2015-11-20 12:00 +0100
Re: How To Create A Endles List Of Lists In Python...??? Nagy László Zsolt <gandalf@shopzeus.com> - 2015-11-20 14:06 +0100
Re: How To Create A Endles List Of Lists In Python...??? robert.bralic@si.t-com.hr - 2015-11-20 05:29 -0800
Re: How To Create A Endles List Of Lists In Python...??? Chris Angelico <rosuav@gmail.com> - 2015-11-21 00:09 +1100
Re: How To Create A Endles List Of Lists In Python...??? Grant Edwards <invalid@invalid.invalid> - 2015-11-20 15:58 +0000
Re: How To Create A Endles List Of Lists In Python...??? srinivas devaki <mr.eightnoteight@gmail.com> - 2015-11-20 23:58 +0530
Re: How To Create A Endles List Of Lists In Python...??? srinivas devaki <mr.eightnoteight@gmail.com> - 2015-11-21 00:05 +0530
Re: How To Create A Endles List Of Lists In Python...??? Denis McMahon <denismfmcmahon@gmail.com> - 2015-11-20 17:14 +0000
Re: How To Create A Endles List Of Lists In Python...??? robert.bralic@si.t-com.hr - 2015-11-20 10:16 -0800
Re: How To Create A Endles List Of Lists In Python...??? Ian Kelly <ian.g.kelly@gmail.com> - 2015-11-20 11:29 -0700
Re: How To Create A Endles List Of Lists In Python...??? Chris Angelico <rosuav@gmail.com> - 2015-11-21 05:30 +1100
Re: How To Create A Endles List Of Lists In Python...??? sohcahtoa82@gmail.com - 2015-11-20 11:26 -0800
| From | "HKRSS" <hkrss@gmail.com> |
|---|---|
| Date | 2015-11-20 08:43 +0100 |
| Subject | How To Create A Endles List Of Lists In Python...??? |
| Message-ID | <n2miu8$fl4$1@ls237.t-com.hr> |
Thanks In Advance, Robert...;)
[toc] | [next] | [standalone]
| From | "HKRSS" <hkrss@gmail.com> |
|---|---|
| Date | 2015-11-20 09:13 +0100 |
| Message-ID | <n2mknk$ges$1@ls237.t-com.hr> |
| In reply to | #99131 |
I Think That There Are Two Ways: 1)Harder Way Use Procedural C... 2)Easier Way Use LISP... "HKRSS" <hkrss@gmail.com> wrote in message news:n2miu8$fl4$1@ls237.t-com.hr... > Thanks In Advance, Robert...;) > >
[toc] | [prev] | [next] | [standalone]
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Date | 2015-11-20 09:53 +0100 |
| Message-ID | <mailman.510.1448009596.16136.python-list@python.org> |
| In reply to | #99131 |
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] [[...]]
[toc] | [prev] | [next] | [standalone]
| From | "HKRSS" <hkrss@gmail.com> |
|---|---|
| Date | 2015-11-20 12:00 +0100 |
| Message-ID | <n2mugp$kt1$1@ls237.t-com.hr> |
| In reply to | #99135 |
"Peter Otten" <__peter__@web.de> wrote in message news:mailman.510.1448009596.16136.python-list@python.org... > 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] > [[...]] > 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..;)
[toc] | [prev] | [next] | [standalone]
| From | Nagy László Zsolt <gandalf@shopzeus.com> |
|---|---|
| Date | 2015-11-20 14:06 +0100 |
| Message-ID | <mailman.513.1448024777.16136.python-list@python.org> |
| In reply to | #99137 |
> 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 iterated forever, and indexed with an integer. But before you do that: what is this needed for?
[toc] | [prev] | [next] | [standalone]
| From | robert.bralic@si.t-com.hr |
|---|---|
| Date | 2015-11-20 05:29 -0800 |
| Message-ID | <9129317f-5f24-4e28-96de-8567e2d7afe8@googlegroups.com> |
| In reply to | #99144 |
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... > It is not possible to do it with a native list. But you can write your > own iterable that can be iterated forever, and indexed with an integer. > > But before you do that: what is this needed for? To Make A Turing Machine That Accepts A Classes.... (This Is My Idea, And Must Be Published By Me, And I Don't Respond How I Think Make This Machine)... Thanks, Robert...;)
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2015-11-21 00:09 +1100 |
| Message-ID | <mailman.514.1448024955.16136.python-list@python.org> |
| In reply to | #99137 |
On Sat, Nov 21, 2015 at 12:06 AM, Nagy László Zsolt <gandalf@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... > It is not possible to do it with a native list. But you can write your > own iterable that can be iterated forever, and indexed with an integer. > > But before you do that: what is this needed for? My crystal ball suggests that defaultdict(list) might be useful here. ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Grant Edwards <invalid@invalid.invalid> |
|---|---|
| Date | 2015-11-20 15:58 +0000 |
| Message-ID | <n2ng03$rl6$2@reader1.panix.com> |
| In reply to | #99137 |
On 2015-11-20, HKRSS <hkrss@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..;)
Not only was that genuine frontier gibberish, it expressed...
something?
--
Grant Edwards grant.b.edwards Yow! I feel partially
at hydrogenated!
gmail.com
[toc] | [prev] | [next] | [standalone]
| From | srinivas devaki <mr.eightnoteight@gmail.com> |
|---|---|
| Date | 2015-11-20 23:58 +0530 |
| Message-ID | <mailman.15.1448044148.2291.python-list@python.org> |
| In reply to | #99137 |
On Fri, Nov 20, 2015 at 6:39 PM, Chris Angelico <rosuav@gmail.com> 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 __init__(self, factory, data=None):
self.factory = factory
self.list = []
self.data = data
def __getitem__(self, x):
if x >= len(self.list):
self.list.extend([self.factory() for _ in
range(len(self.list), x + 1)])
return self.list[x]
def __repr__(self):
return str(self)
def __str__(self):
if len(self.list) == 0:
return '(' + str(self.data) + ')[...]'
return ''.join(['(', str(self.data), ')['] + map(str,
self.list) + [', ...]'])
def __setitem__(self, x, v):
if x >= len(self.list):
self.list.extend([self.factory() for _ in
range(len(self.list), x + 1)])
self.list[x] = v
def main():
factory = lambda: defaultlist(factory)
list_of_lists = defaultlist(factory)
print (list_of_lists[0])
list_of_lists[0][10].data = 20
print (list_of_lists[0])
main()
Gist: https://gist.github.com/c0c2ee1e7c6535ef8c3d
[toc] | [prev] | [next] | [standalone]
| From | srinivas devaki <mr.eightnoteight@gmail.com> |
|---|---|
| Date | 2015-11-21 00:05 +0530 |
| Message-ID | <mailman.18.1448044587.2291.python-list@python.org> |
| In reply to | #99137 |
On Fri, Nov 20, 2015 at 11:58 PM, srinivas devaki
<mr.eightnoteight@gmail.com> wrote:
> def __str__(self):
> if len(self.list) == 0:
> return '(' + str(self.data) + ')[...]'
> return ''.join(['(', str(self.data), ')['] + map(str, self.list) + [', ...]'])
> ...
> Gist: https://gist.github.com/c0c2ee1e7c6535ef8c3d
uhh, there is an error in representing it, the code should be
def __str__(self):
if len(self.list) == 0:
return '(' + str(self.data) + ')[...]'
return ''.join(['(', str(self.data), ')[', ', '.join(map(str,
self.list)), ', ...]'])
Output:
(None)[...]
(None)[(None)[...], (None)[...], (None)[...], (20)[...], ...]
ps: code is updated in gist.
[toc] | [prev] | [next] | [standalone]
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Date | 2015-11-20 17:14 +0000 |
| Message-ID | <n2nkdd$mns$2@dont-email.me> |
| In reply to | #99131 |
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 solution for anything useful, because it will just use all the memory up. So perhaps you need to express your question in a better manner. -- Denis McMahon, denismfmcmahon@gmail.com
[toc] | [prev] | [next] | [standalone]
| From | robert.bralic@si.t-com.hr |
|---|---|
| Date | 2015-11-20 10:16 -0800 |
| Message-ID | <c83d0ce8-9855-4afa-9efe-f9bfe9b78931@googlegroups.com> |
| In reply to | #99171 |
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.append([]) > > Until you run out of memory > > But I think that this answer although it appears accurate to the question > is not a solution for anything useful, because it will just use all the > memory up. So perhaps you need to express your question in a better > manner. > > -- > Denis McMahon, denismfmcmahon@gmail.com I Think That LISP Is Only Solution, I Wil Give Up Frpm Python... Thanks, Robert...;)
[toc] | [prev] | [next] | [standalone]
| From | Ian Kelly <ian.g.kelly@gmail.com> |
|---|---|
| Date | 2015-11-20 11:29 -0700 |
| Message-ID | <mailman.16.1448044194.2291.python-list@python.org> |
| In reply to | #99178 |
On Fri, Nov 20, 2015 at 11:16 AM, <robert.bralic@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...;) >> >> 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 solution for anything useful, because it will just use all the >> memory up. So perhaps you need to express your question in a better >> manner. >> >> -- >> Denis McMahon, denismfmcmahon@gmail.com > > I Think That LISP Is Only Solution, I Wil Give Up Frpm Python... Nagy and Chris gave you two different perfectly good solutions for Python.
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2015-11-21 05:30 +1100 |
| Message-ID | <mailman.17.1448044232.2291.python-list@python.org> |
| In reply to | #99178 |
On Sat, Nov 21, 2015 at 5:16 AM, <robert.bralic@si.t-com.hr> 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
[toc] | [prev] | [next] | [standalone]
| From | sohcahtoa82@gmail.com |
|---|---|
| Date | 2015-11-20 11:26 -0800 |
| Message-ID | <dcbd5076-7c69-4e29-9db7-b025890354eb@googlegroups.com> |
| In reply to | #99178 |
On Friday, November 20, 2015 at 10:16:34 AM UTC-8, robert...@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...;) > > > > 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 solution for anything useful, because it will just use all the > > memory up. So perhaps you need to express your question in a better > > manner. > > > > -- > > Denis McMahon, denismfmcmahon@gmail.com > > I Think That LISP Is Only Solution, I Wil Give Up Frpm Python... > > Thanks, Robert...;) Is There A Reason You're Starting Every Word With A Capital Letter? I mean, really, you're going out of your way and expending extra effort to type incorrectly.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web