Re: Artificial creating of [Lists], is it possible? the best way...

2017-11-17 Thread Rick Johnson
On Thursday, November 16, 2017 at 12:48:05 PM UTC-6, Jakub Rajok wrote:
> Artificial creating of [Lists], is it possible? the best way...

There is nothing "artificial" about creating any object.
Much less python lists.  And i believe the usage of such
word in the title of this thread was unfortunate, as it
injects superfluous distraction into our comprehension of
your true _intentions_.

So, if the suggestions offered so far are _truely_ what you
wanted to do -- and i have not reason to believe they are
_not_ -- then the process here can more accurately be
described, in English, as "creating a list containing N
number of empty sublists".

Words matter!

Anecdotal speaking... an oft-stated observation of politics
is that "Elections have consequences". And in the same
spirit we should also understand that "words _themselves_
have consequences". Or rather: "your _word_choice_ is highly
essential to our correct and efficient comprehension of your
_intent_".

So, in conclusion...

If you cannot describe the result you want to achieve in
_words_, then show us the result in actual _code_. For
instance, the following question would have been self-
explanatory:

"How do i create a list that looks like this -> [[],[],[]]

It is always better to restrict your use of natural language
words to only those you _fully_ understand, than to attempt
to stretch the definition of those words until they wrap
around a concept, for which the "conceptual relationship"
may only be obvious to _you_.

PS: If you think about it, everything we _do_ in the
"programming realm" is artificial. AKA: "Abstract". And
while the end result of our incessant "juggling of
abstractions" (which are _themselves_ built upon multiple
layers of other abstractions) will inevitably be the
concrete action of elections moving through a conductor, we,
as programmers, are unconcerned with such "mechanical
minutiae", and are only interested in the _results_ these
worker-bee elections can bring to us. We are the shrewd
military strategists and unapologetic mercenaries who fight
endless, abstract battles against a manevolent, three-
headed monster which plauges all of mankind -- namely:
"needs", "wants", and "desires --, and who manevolently
unleashes its legions of incoragble gremlins and hordes of
mindless creepy crawlies to seek-out, and utlimately infest,
every system that man -- in his boneheaded hubris -- has
ever struggled to dominate.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Artificial creating of [Lists], is it possible? the best way...

2017-11-17 Thread Grant Edwards
On 2017-11-17, eth0  wrote:
> On Fri, 17 Nov 2017 00:04:16 + in comp.lang.python, MRAB said:
>>  On 2017-11-16 18:47, jakub.raj...@gmail.com wrote:
>> > Hello, im working on school project, its deck game Sorry!
>> > I need to create specific lists:
>> > My idea is about to using for
>> > For i in range (n):
>> > i=[]
>> > I know, that there is no possibility to make it from number, but
>> > i havent idea, how to reach my wants Li/L"i"/L(i), how to make
>> > possible for lists?
>> > 
>> > 
>>  If you want multiple lists, make a list of lists:
>> 
>>  my_lists = []
>> 
>>  for i in range(n):
>>   my_lists.append([])
>> 
>>  Then you can say my_lists[0], my_lists[1], etc.
>
> It'd be even shorter using a list comprehension:
>
> my_lists = [[] for i in range(n)]
>
> And _even shorter still_ just using the multiply operator:
>
> my_lists = [[]] * n

   $ python
   Python 2.7.14 (default, Nov  2 2017, 11:45:51) 
   [GCC 5.4.0] on linux2
   Type "help", "copyright", "credits" or "license" for more information.
   >>> x = [[] for i in 1,2,3,4]
   >>> x
   [[], [], [], []]
   >>> y = [[]] * 4
   >>> y
   [[], [], [], []]
   >>> x[0].append(1)
   >>> y[0].append(1)
   >>> x
   [[1], [], [], []]
   >>> y
   [[1], [1], [1], [1]]



-- 
Grant Edwards   grant.b.edwardsYow! Do I have a lifestyle
  at   yet?
  gmail.com

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Artificial creating of [Lists], is it possible? the best way...

2017-11-17 Thread Chris Angelico
On Sat, Nov 18, 2017 at 2:29 AM, eth0  wrote:
> On Fri, 17 Nov 2017 00:04:16 + in comp.lang.python, MRAB said:
>>  On 2017-11-16 18:47, jakub.raj...@gmail.com wrote:
>> > Hello, im working on school project, its deck game Sorry!
>> > I need to create specific lists:
>> > My idea is about to using for
>> > For i in range (n):
>> > i=[]
>> > I know, that there is no possibility to make it from number, but
>> > i havent idea, how to reach my wants Li/L"i"/L(i), how to make
>> > possible for lists?
>> >
>> >
>>  If you want multiple lists, make a list of lists:
>>
>>  my_lists = []
>>
>>  for i in range(n):
>>   my_lists.append([])
>>
>>  Then you can say my_lists[0], my_lists[1], etc.
>
> It'd be even shorter using a list comprehension:
>
> my_lists = [[] for i in range(n)]
>
> And _even shorter still_ just using the multiply operator:
>
> my_lists = [[]] * n

Those are semantically different though.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Artificial creating of [Lists], is it possible? the best way...

2017-11-17 Thread eth0
On Fri, 17 Nov 2017 00:04:16 + in comp.lang.python, MRAB said:
>  On 2017-11-16 18:47, jakub.raj...@gmail.com wrote:
> > Hello, im working on school project, its deck game Sorry!
> > I need to create specific lists:
> > My idea is about to using for
> > For i in range (n):
> > i=[]
> > I know, that there is no possibility to make it from number, but
> > i havent idea, how to reach my wants Li/L"i"/L(i), how to make
> > possible for lists?
> > 
> > 
>  If you want multiple lists, make a list of lists:
> 
>  my_lists = []
> 
>  for i in range(n):
>   my_lists.append([])
> 
>  Then you can say my_lists[0], my_lists[1], etc.

It'd be even shorter using a list comprehension:

my_lists = [[] for i in range(n)]

And _even shorter still_ just using the multiply operator:

my_lists = [[]] * n
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Artificial creating of [Lists], is it possible? the best way...

2017-11-16 Thread MRAB

On 2017-11-16 18:47, jakub.raj...@gmail.com wrote:

Hello, im working on school project, its deck game Sorry!
I need to create specific lists:
My idea is about to using for
For i in range (n):
i=[]
I know, that there is no possibility to make it from number, but i havent idea, how to 
reach my wants Li/L"i"/L(i), how to make possible for lists?



If you want multiple lists, make a list of lists:

my_lists = []

for i in range(n):
my_lists.append([])

Then you can say my_lists[0], my_lists[1], etc.
--
https://mail.python.org/mailman/listinfo/python-list


Artificial creating of [Lists], is it possible? the best way...

2017-11-16 Thread jakub . rajcok
Hello, im working on school project, its deck game Sorry!
I need to create specific lists:
My idea is about to using for
For i in range (n):
   i=[]
I know, that there is no possibility to make it from number, but i havent idea, 
how to reach my wants Li/L"i"/L(i), how to make possible for lists?


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Artificial creating of [Lists], is it possible? the best way...

2017-11-16 Thread Peter Pearson
On Thu, 16 Nov 2017 10:47:53 -0800 (PST), jakub.raj...@gmail.com wrote:
> Hello, im working on school project, its deck game Sorry!
> I need to create specific lists:
> My idea is about to using for
> For i in range (n):
>i=[]

This will create n different empty lists, in succession, and
discard all but the last one, which will be bound to the name "i".

> I know, that there is no possibility to make it from number, but i
> havent idea, how to reach my wants Li/L"i"/L(i), how to make possible
> for lists?

You'll find that the people on this newsgroup are very helpful, but
they might (like me) be unable to discern what you're asking.


-- 
To email me, substitute nowhere->runbox, invalid->com.
-- 
https://mail.python.org/mailman/listinfo/python-list