On 25Dec2019 01:20, mail.python@marco.sulla.e4ward.com
wrote:
About the extra comma, it's da**ed useful:
[...]
The real problem is this one:
a = 1,
Unreadable and prone to subtle errors, because maybe you added the
comma by mistake. Caution: Debugging Nightmares.
Hoo, yes. Only the ot
On Wed, 25 Dec 2019 at 00:56, Avi Gross
wrote:
> I may not be understanding what you are objecting to
I, sir, am objecting that I replied to a topic, and you answered to
me, but in another topic. You could have respond to me in the correct
topic, and then create this other one (that I'm not real
On Wed, Dec 25, 2019 at 10:50 AM Avi Gross via Python-list
wrote:
>
> Cameron,
>
> I am not at all against the feature. I like it as my programming style is
> like you describe. One entry per line indented at the same level, in
> multiple languages. I often do graphics where I generate an image th
convenience is in some sense removing a mathematical symmetry,
but so what?
-Original Message-
From: Cameron Simpson
Sent: Tuesday, December 24, 2019 5:12 PM
To: Avi Gross
Cc: python-list@python.org
Subject: Re: Lists And Extra Commas at end
On 24Dec2019 16:48, Avi Gross wrote:
>
On Tue, 24 Dec 2019 at 19:05, Avi Gross via Python-list
wrote:
> There are some lint programs that check your code and supply warnings and I
> see some languages have the option to generate warnings when the two strings
> are on the same line. I wonder if a Python lint does that. It may at least
>
On Tue, 24 Dec 2019 at 22:51, Avi Gross via Python-list
wrote:
> So, is that a feature you want warnings about? After all, a dangling comma
> may simply mean you left something out and meant to add later?
.completely OT. I responded to a topic named "List and missing
commas", and suggested a
On 24Dec2019 16:48, Avi Gross wrote:
Let me switch gears to the terminal comma situation. Unlike many
languages, Python decided a dangling comma is perfectly allowable in
many situations, perhaps all.
a=[1,2,3,]
a
[1, 2, 3]
[...]
And, of course, you can use the same dangling comma in makin
On 12/24/2019 10:02 AM, Avi Gross via Python-list wrote:
This being Python (which lies about how there should be one unique way to
logically do something)
The koan is:
There should be one-- and preferably only one --obvious way to do it.
It is not:
- only one way
- one unique way
- the on
-Original Message-
From: Python-list On
Behalf Of Tim Daneliuk
Sent: Monday, December 23, 2019 11:22 PM
To: python-list@python.org
Subject: Re: Lists And Missing Commas
On 12/23/19 8:35 PM, Chris Angelico wrote:
> On Tue, Dec 24, 2019 at 12:56 PM DL Neil via Python-list
> wrote:
>>
On 12/24/19 10:45 AM, Tim Daneliuk wrote:
On 12/24/19 6:37 AM, Stefan Ram wrote:
And you all are aware that this kind of string concatenation
happens in C and C++, too, aren't you?
main.c
#include
int main( void ){ puts( "a" "b" ); }
transcript
ab
Noting that it has been a long
On 12/24/19 6:37 AM, Stefan Ram wrote:
> And you all are aware that this kind of string concatenation
> happens in C and C++, too, aren't you?
>
> main.c
>
> #include
> int main( void ){ puts( "a" "b" ); }
>
> transcript
>
> ab
Noting that it has been a long time since I looked at the
On 24/12/19 5:20 PM, Tim Daneliuk wrote:
On 12/23/19 7:52 PM, DL Neil wrote:
WebRef: https://docs.python.org/3/reference/lexical_analysis.html
Yep, that explains it, but it still feels non-regular to me. From a pointy
headed academic
POV, I'd like to see behavior consistent across types. A
On 2019-12-24 6:20 AM, Tim Daneliuk wrote:
On 12/23/19 7:52 PM, DL Neil wrote:
WebRef: https://docs.python.org/3/reference/lexical_analysis.html
Yep, that explains it, but it still feels non-regular to me. From a pointy
headed academic
POV, I'd like to see behavior consistent across types.
On 12/23/19 8:35 PM, Chris Angelico wrote:
> On Tue, Dec 24, 2019 at 12:56 PM DL Neil via Python-list
> wrote:
>> However, your point involves the fact that whereas:
>>
>> 1 + 2 # 3 is *clearly* addition, and
>> "a" + "b" # "ab" is *clearly* concatenation
>>
>> "a" "b" # al
On 12/23/19 7:52 PM, DL Neil wrote:
>
> WebRef: https://docs.python.org/3/reference/lexical_analysis.html
Yep, that explains it, but it still feels non-regular to me. From a pointy
headed academic
POV, I'd like to see behavior consistent across types. Again ... what do I know?
--
https://mai
On 24/12/19 3:35 PM, Chris Angelico wrote:
On Tue, Dec 24, 2019 at 12:56 PM DL Neil via Python-list
wrote:
However, your point involves the fact that whereas:
1 + 2 # 3 is *clearly* addition, and
"a" + "b" # "ab" is *clearly* concatenation
"a" "b" # also evaluates to "
On Tue, Dec 24, 2019 at 12:56 PM DL Neil via Python-list
wrote:
> However, your point involves the fact that whereas:
>
> 1 + 2 # 3 is *clearly* addition, and
> "a" + "b" # "ab" is *clearly* concatenation
>
> "a" "b" # also evaluates to "ab"
>
> and is thus, concatenation w
On 24/12/19 1:48 PM, Tim Daneliuk wrote:
If I do this:
foo = [ "bar", "baz" "slop", "crud" ]
Python silently accepts that and makes the middle term "bazslop".
BUT, if I do this:
foo = [ "bar", "baz" 1, "crud" ]
or this:
foo = [ "bar", 2 1, "crud" ]
The interpreter throws a s
On Tuesday, 24 December 2019, Tim Daneliuk wrote:
> If I do this:
>
> foo = [ "bar", "baz" "slop", "crud" ]
>
> Python silently accepts that and makes the middle term "bazslop".
Strings concatinate over line endings so this case is only sensible really.
>
> BUT, if I do this:
>
> foo
Ian Kelly wrote:
> On Mon, Sep 15, 2014 at 1:36 AM, Peter Otten <__pete...@web.de> wrote:
>> I'd call range() an iterable.
>
> I'd even go so far as to call it a sequence.
>
from collections import Sequence
issubclass(range, Sequence)
> True
If you want to be as specific as possible c
On Mon, Sep 15, 2014 at 1:36 AM, Peter Otten <__pete...@web.de> wrote:
> I'd call range() an iterable.
I'd even go so far as to call it a sequence.
>>> from collections import Sequence
>>> issubclass(range, Sequence)
True
--
https://mail.python.org/mailman/listinfo/python-list
On Mon, 15 Sep 2014 16:59:36 +1000, Steven D'Aprano
wrote:
>Seymore4Head wrote:
>
>> import random
>> nums=range(1,11)
>> print (nums)
>> samp=random.sample(nums,10)
>> top=nums
>> newlist=nums[::-1]
>> tail=newlist
>>
>> for x in range(10):
>> print ("Top {:2d}Tail {:2.0f} Sample {:2d}
On Mon, 15 Sep 2014 09:05:50 -0400 (EDT), Dave Angel
wrote:
>Seymore4Head Wrote in message:
>> import random
>> nums=range(1,11)
>> print (nums)
>> samp=random.sample(nums,10)
>> top=nums
>> newlist=nums[::-1]
>> tail=newlist
>>
>> for x in range(10):
>> print ("Top {:2d}Tail {:2.0f} S
Christian Gollwitzer wrote:
> Am 15.09.14 04:40, schrieb Seymore4Head:
>> nums=range(1,11)
>> print (nums)
>
>> I don't understand why the command nums=range(1,11) doesn't work.
>> I would think that print(nums) should be 1,2,3 ect.
>> Instead it prints range(1,11)
>
> It does work, but in a dif
Christian Gollwitzer wrote:
> range() does
> not return a list of numbers, but rather a generator
Technically, it's not a generator. It's a range object. Generators can
return anything, and you have to program them by using yield:
def gen():
yield 1
yield 2
if today() is Tuesday:
Seymore4Head wrote:
> import random
> nums=range(1,11)
> print (nums)
> samp=random.sample(nums,10)
> top=nums
> newlist=nums[::-1]
> tail=newlist
>
> for x in range(10):
> print ("Top {:2d}Tail {:2.0f} Sample {:2d}
> ".format(top[x],tail[x],samp[x]))
>
> I don't understand why the
Am 15.09.14 04:40, schrieb Seymore4Head:
nums=range(1,11)
print (nums)
I don't understand why the command nums=range(1,11) doesn't work.
I would think that print(nums) should be 1,2,3 ect.
Instead it prints range(1,11)
It does work, but in a different way than you might think. range() does
beliav...@aol.com.dmarc.invalid wrote:
> I am going to read a multivariate time series from a CSV file that looks
> like
>
> Date,A,B
> 2014-01-01,10.0,20.0
> 2014-01-02,10.1,19.9
> ...
>
> The numerical data I will store in a NumPy array, since they are more
> convenient to work with than lists
On Mon, 09 Jun 2014 12:48:12 -0700, beliavsky wrote:
> I am going to read a multivariate time series from a CSV file that looks
> like
>
> Date,A,B 2014-01-01,10.0,20.0 2014-01-02,10.1,19.9 ...
>
> The numerical data I will store in a NumPy array, since they are more
> convenient to work with th
mick verdu wrote:
> ThanK you. It solved my problem.
> Can someone tell me how can i print particular value inside list of key.
>
> I know how to print J['PC2'][1] means will print IP. but I want the user
> to input some element and I will print element just before that element.
>
> e.g. if user
ThanK you. It solved my problem.
Can someone tell me how can i print particular value inside list of key.
I know how to print J['PC2'][1] means will print IP. but I want the user to
input some element and I will print element just before that element.
e.g. if user inputs 192.168.0.2, program wil
mick verdu wrote:
What I want is if host already exists it would
overwrite otherwise add to database. And if host doesn't exist it will first
add this host to database and then compare its IP with IPs of rest of hosts.
If ip matches with any of the other hosts, it will delete the host that it
jus
On 26/01/2014 20:28, mick verdu wrote:
I have programming course and trying to learn things. This is of no human use.
I am just following exercises. Just have to do steps as asked.
A slightly OT observation... Mick, consider using more meaningful names
than t,z etc. You know what they stand
On Sun, 26 Jan 2014 10:47:11 -0800, mick verdu wrote:
> z={ 'PC2': ['02:02:02:02:02:02', '192.168.0.2', '200'],
> 'PC3': ['03:03:03:03:03:03', '192.168.0.3', '200'], 'PC1':
> ['01:01:01:01:01:01', '192.168.0.1', '200'] }
>
> My solution:
>
> z=raw_input("Enter Host, Mac, ip and time")
>
I have programming course and trying to learn things. This is of no human use.
I am just following exercises. Just have to do steps as asked.
--
https://mail.python.org/mailman/listinfo/python-list
@Peter Otten:
I have lists for keys. What I want is if host already exists it would overwrite
otherwise add to database. And if host doesn't exist it will first add this
host to database and then compare its IP with IPs of rest of hosts. If ip
matches with any of the other hosts, it will delete
On 2014-01-26 10:47, mick verdu wrote:
> z={ 'PC2': ['02:02:02:02:02:02', '192.168.0.2', '200'],
> 'PC3': ['03:03:03:03:03:03', '192.168.0.3', '200'],
> 'PC1': ['01:01:01:01:01:01', '192.168.0.1', '200'] }
>
> My solution:
>
> z=raw_input("Enter Host, Mac, ip and time")
> t=z.split()
> t[
mick verdu wrote:
> z={ 'PC2': ['02:02:02:02:02:02', '192.168.0.2', '200'],
> 'PC3': ['03:03:03:03:03:03', '192.168.0.3', '200'],
> 'PC1': ['01:01:01:01:01:01', '192.168.0.1', '200'] }
>
> My solution:
>
> z=raw_input("Enter Host, Mac, ip and time")
> t=z.split()
> t[0]=z[1:]
> for key i
On Mon, 22 Apr 2013 11:13:38 -0700, Ana Dionísio wrote:
> I have an array and I need pick some data from that array and put it in
> a list, for example:
>
> array= [a,b,c,1,2,3]
>
> list=array[0]+ array[3]+ array[4]
>
> list: [a,1,2]
>
> When I do it like this: list=array[0]+ array[3]+ array[4
Ana Dionísio於 2013年4月23日星期二UTC+8上午2時13分38秒寫道:
> Hello!
>
>
>
> I need your help!
>
>
>
> I have an array and I need pick some data from that array and put it in a
> list, for example:
>
>
>
> array= [a,b,c,1,2,3]
>
>
>
> list=array[0]+ array[3]+ array[4]
>
>
>
> list: [a,1,2]
>
>
"Ana Dionísio" wrote in message
news:de1cc79e-cbf7-4b0b-ae8e-18841a1ef...@googlegroups.com...
Hello!
I need your help!
I have an array and I need pick some data from that array and put it in a
list, for example:
array= [a,b,c,1,2,3]
list=array[0]+ array[3]+ array[4]
list: [a,1,2]
When
On 04/22/2013 02:13 PM, Ana Dionísio wrote:
Hello!
I need your help!
I have an array
I think you mean you have a numpy array, which is very different than a
python array.array
and I need pick some data from that array and put it in a list, for example:
array= [a,b,c,1,2,3]
That's a li
On Wed, 20 Mar 2013 20:00:38 +, Grant Edwards wrote:
> On 2013-03-20, Alister wrote:
>
>> and a list comprehension would streamline things further
>>
>> t=[round(x*1.0/60),4 for x in range(1440)] #compatible with V2.7 &
>> V3.0)
>
> There's a typo in the above. It should be:
>
> t = [rou
On 2013-03-20, Alister wrote:
> and a list comprehension would streamline things further
>
> t=[round(x*1.0/60),4 for x in range(1440)] #compatible with V2.7 & V3.0)
There's a typo in the above. It should be:
t = [round((x*1.0/60),4) for x in range(1440)]
--
Grant Edwards gran
On 20/03/2013 19:20, Alister wrote:
On Wed, 20 Mar 2013 16:52:00 +0100, Peter Otten wrote:
Ana Dionísio wrote:
So, I have this script that puts in a list every minute in 24 hours
hour=[]
i=0 t=-(1.0/60.0)
while i<24*60:
i = i+1 t = t+(1.0/60.0)
hour.append([t])
In many cases you
On Wed, 20 Mar 2013 16:52:00 +0100, Peter Otten wrote:
> Ana Dionísio wrote:
>
>> So, I have this script that puts in a list every minute in 24 hours
>>
>> hour=[]
>> i=0 t=-(1.0/60.0)
>> while i<24*60:
>> i = i+1 t = t+(1.0/60.0)
>> hour.append([t])
>
> In many cases you can write
>
>
Ana Dionísio wrote:
> So, I have this script that puts in a list every minute in 24 hours
>
> hour=[]
> i=0
> t=-(1.0/60.0)
> while i<24*60:
> i = i+1
> t = t+(1.0/60.0)
> hour.append([t])
In many cases you can write
for i in range(...):
...
instead of incrementing manually.
>
On Wednesday, March 20, 2013 11:27:30 AM UTC-4, Ana Dionísio wrote:
> So, I have this script that puts in a list every minute in 24 hours
>
>
>
> hour=[]
>
> i=0
>
> t=-(1.0/60.0)
>
> while i<24*60:
>
> i = i+1
>
> t = t+(1.0/60.0)
>
> hour.append([t])
>
>
>
> When it is doi
On Wed, 17 Aug 2011 20:08:23 -0700 (PDT), Emily Anne Moravec wrote:
> I want to add 5 to each element of a list by using a for loop.
>
> Why doesn't this work?
>
> numbers = [1, 2, 3, 4, 5]
> for n in numbers:
> n = n + 5
> print numbers
Because integers are immutable. You cannot turn 1 into
On 08/18/2011 07:22 AM, Mark Niemczyk wrote:
Or, using list comprehension.
numbers = [1, 2, 3, 4, 5]
numbers = [n + 5 for n in numbers]
numbers
[6, 7, 8, 9, 10]
Or, if you want it in-place:
numbers[:] = [n+5 for n in numbers]
which makes a difference if you have another reference to numb
Or, using list comprehension.
>>> numbers = [1, 2, 3, 4, 5]
>>> numbers = [n + 5 for n in numbers]
>>> numbers
[6, 7, 8, 9, 10]
--
http://mail.python.org/mailman/listinfo/python-list
On Aug 18, 1:08 pm, Emily Anne Moravec wrote:
> I want to add 5 to each element of a list by using a for loop.
>
> Why doesn't this work?
>
> numbers = [1, 2, 3, 4, 5]
> for n in numbers:
> n = n + 5
> print numbers
As the for loop steps through numbers, it assigns each integer value
to the
>
> I want to add 5 to each element of a list by using a for loop.
>
> Why doesn't this work?
>
> numbers = [1, 2, 3, 4, 5]
> for n in numbers:
> n = n + 5
> print numbers
>
>
The n variable in the for loop refers to each value in the list, not the
reference to the slot that value is stored in.
On Sep 23, 8:46 pm, Baba wrote:
> On Sep 23, 8:13 pm, nn wrote:
>
>
>
> > On Sep 23, 1:25 pm, Baba wrote:
>
> > > On Sep 23, 4:17 pm, nn wrote:
>
> > > > On Sep 23, 10:56 am, nn wrote:
>
> > > > > On Sep 22, 6:39 pm, Baba wrote:
>
> > > > > > On Sep 22, 9:18 pm, Baba wrote:
>
> > > > > > > O
On Sep 23, 8:13 pm, nn wrote:
> On Sep 23, 1:25 pm, Baba wrote:
>
>
>
> > On Sep 23, 4:17 pm, nn wrote:
>
> > > On Sep 23, 10:56 am, nn wrote:
>
> > > > On Sep 22, 6:39 pm, Baba wrote:
>
> > > > > On Sep 22, 9:18 pm, Baba wrote:
>
> > > > > > On Sep 22, 3:38 pm, nn wrote:
>
> > > > > > > On
On Sep 23, 8:13 pm, nn wrote:
> On Sep 23, 1:25 pm, Baba wrote:
>
>
>
> > On Sep 23, 4:17 pm, nn wrote:
>
> > > On Sep 23, 10:56 am, nn wrote:
>
> > > > On Sep 22, 6:39 pm, Baba wrote:
>
> > > > > On Sep 22, 9:18 pm, Baba wrote:
>
> > > > > > On Sep 22, 3:38 pm, nn wrote:
>
> > > > > > > On
On Sep 23, 1:25 pm, Baba wrote:
> On Sep 23, 4:17 pm, nn wrote:
>
>
>
> > On Sep 23, 10:56 am, nn wrote:
>
> > > On Sep 22, 6:39 pm, Baba wrote:
>
> > > > On Sep 22, 9:18 pm, Baba wrote:
>
> > > > > On Sep 22, 3:38 pm, nn wrote:
>
> > > > > > On Sep 21, 6:39 pm, Baba wrote:
>
> > > > > > > H
On Sep 23, 4:17 pm, nn wrote:
> On Sep 23, 10:56 am, nn wrote:
>
>
>
> > On Sep 22, 6:39 pm, Baba wrote:
>
> > > On Sep 22, 9:18 pm, Baba wrote:
>
> > > > On Sep 22, 3:38 pm, nn wrote:
>
> > > > > On Sep 21, 6:39 pm, Baba wrote:
>
> > > > > > Hi
>
> > > > > > query level: beginner
>
> > > > >
On Sep 23, 10:56 am, nn wrote:
> On Sep 22, 6:39 pm, Baba wrote:
>
>
>
> > On Sep 22, 9:18 pm, Baba wrote:
>
> > > On Sep 22, 3:38 pm, nn wrote:
>
> > > > On Sep 21, 6:39 pm, Baba wrote:
>
> > > > > Hi
>
> > > > > query level: beginner
>
> > > > > as part of a learning exercise i have written
On Sep 22, 6:39 pm, Baba wrote:
> On Sep 22, 9:18 pm, Baba wrote:
>
>
>
> > On Sep 22, 3:38 pm, nn wrote:
>
> > > On Sep 21, 6:39 pm, Baba wrote:
>
> > > > Hi
>
> > > > query level: beginner
>
> > > > as part of a learning exercise i have written code that:
>
> > > > a) asks for a single letter
On Sep 22, 3:39 pm, Baba wrote:
> On Sep 22, 9:18 pm, Baba wrote:
>
>
>
> > On Sep 22, 3:38 pm, nn wrote:
>
> > > On Sep 21, 6:39 pm, Baba wrote:
>
> > > > Hi
>
> > > > query level: beginner
>
> > > > as part of a learning exercise i have written code that:
>
> > wordlist = ['hello', 'bye']
On Sep 22, 9:18 pm, Baba wrote:
> On Sep 22, 3:38 pm, nn wrote:
>
>
>
> > On Sep 21, 6:39 pm, Baba wrote:
>
> > > Hi
>
> > > query level: beginner
>
> > > as part of a learning exercise i have written code that:
>
> > > a) asks for a single letter input (assumption: only 1 letter wil be
> > > en
On Sep 22, 3:38 pm, nn wrote:
> On Sep 21, 6:39 pm, Baba wrote:
>
>
>
> > Hi
>
> > query level: beginner
>
> > as part of a learning exercise i have written code that:
>
> > a) asks for a single letter input (assumption: only 1 letter wil be
> > entered)
> > b) adds that letter to list1 and then
On Sep 21, 6:39 pm, Baba wrote:
> Hi
>
> query level: beginner
>
> as part of a learning exercise i have written code that:
>
> a) asks for a single letter input (assumption: only 1 letter wil be
> entered)
> b) adds that letter to list1 and then goes through list2 and checks:
>
> 1) if any it
* Michael Pardee:
I'm relatively new to python and I was very surprised by the following behavior:
a=1
b=2
'a' refers to an object representing the integer 1.
Since 1 is an immutable value you can just as well think of it as 'a' containing
the value 1, because a reference to an immutable va
In article ,
Michael Pardee wrote:
>
>I'm relatively new to python and I was very surprised by the following
>behavior:
http://starship.python.net/crew/mwh/hacks/objectthink.html
--
Aahz (a...@pythoncraft.com) <*> http://www.pythoncraft.com/
"Many customs in this life persist
Steven D'Aprano wrote:
On Sat, 20 Feb 2010 22:31:44 -0800, Carl Banks wrote:
The one place where Python does have references is when accessing
variables in an enclosing scope (not counting module-level).
What makes you say that?
I think Carl is talking about cells, which *are* actually ob
"Michael Pardee" wrote in message
news:mailman.22.1266722722.4577.python-l...@python.org...
I'm relatively new to python and I was very surprised by the following
behavior:
a=1
b=2
mylist=[a,b]
print mylist
[1, 2]
a=3
print mylist
[1, 2]
Whoah! Are python lists only for literals? Nope
On Sat, 20 Feb 2010 23:44:29 -0800, Carl Banks wrote:
> On Feb 20, 10:50 pm, Steven D'Aprano cybersource.com.au> wrote:
>> What makes you say that?
[...]
>> I don't even understand this.
[...]
>> I'm just confused why you think that
>> lexical scoping is equivalent to references that can't be pu
On 02/21/10 15:21, Steven D'Aprano wrote:
>> > So it looks like variables in a list are stored as object references.
> Python doesn't store variables in lists, it stores objects, always.
>
> Even Python variables aren't variables *grin*, although it's really
> difficult to avoid using the term. P
On Feb 20, 10:50 pm, Steven D'Aprano wrote:
> On Sat, 20 Feb 2010 22:31:44 -0800, Carl Banks wrote:
> > The one place where Python does have references is when accessing
> > variables in an enclosing scope (not counting module-level).
>
> What makes you say that?
>
> > But these
> > references a
On Sat, 20 Feb 2010 22:31:44 -0800, Carl Banks wrote:
> The one place where Python does have references is when accessing
> variables in an enclosing scope (not counting module-level).
What makes you say that?
> But these
> references aren't objects, so you can't store them in a list, so it
>
On Feb 20, 7:25 pm, Michael Pardee wrote:
> I'm relatively new to python and I was very surprised by the following
> behavior:
>
> >>> a=1
> >>> b=2
> >>> mylist=[a,b]
> >>> print mylist
> [1, 2]
> >>> a=3
> >>> print mylist
>
> [1, 2]
>
> Whoah! Are python lists only for literals? Nope:
>
> >>
On Sat, Feb 20, 2010 at 7:25 PM, Michael Pardee
wrote:
>
> But what would be "the python way" to accomplish "list of variables"
> functionality?
>
You're looking for namespaces, AKA dicts.
>>> vars = {}
>>> vars['a'] = 1
>>> vars['b'] = 2
>>> mylist = ['a', 'b']
>>> print [vars[i] for i in mylis
On Sat, 20 Feb 2010 21:25:19 -0600, Michael Pardee wrote:
> I'm relatively new to python and I was very surprised by the following
> behavior:
[snip]
I don't see why. It's fairly unusual behaviour to want, and it would be
surprising if you did this:
def test():
x = 1
mylist = [2, 4, x]
Michael Pardee writes:
> But what would be "the python way" to accomplish "list of variables"
> functionality?
You'll need to explain what “list of variables” functionality is.
If you mean “collection of name-to-value mappings”, the native mapping
type in Python is ‘dict’. If that doesn't meet
On Sat, Feb 20, 2010 at 7:25 PM, Michael Pardee
wrote:
> But what would be "the python way" to accomplish "list of variables"
> functionality?
>
The problem is... Python doesn't have variables. At least not in the way
that you may be used to from other languages. Yeah, it's got data, and data
obv
On Sat, Feb 20, 2010 at 7:25 PM, Michael Pardee
wrote:
> I'm relatively new to python and I was very surprised by the following
> behavior:
>
a=1
b=2
mylist=[a,b]
print mylist
> [1, 2]
a=3
print mylist
> [1, 2]
>
> Whoah! Are python lists only for literals? Nope:
>
On 2/2/2010 3:14 PM, Mitchell L Model wrote:
I need a 1000 x 1000 two-dimensional array of objects.
I would just use 1000 element list, with each element being a 1000
element list or array (if possible). Then l2d[i][j] works fine.
--
http://mail.python.org/mailman/listinfo/python-list
On 08:36 pm, gerald.brit...@gmail.com wrote:
On Tue, Feb 2, 2010 at 3:14 PM, Mitchell L Model
wrote:
I need a 1000 x 1000 two-dimensional array of objects. (Since they are
instances of application classes it appears that the array module is
useless;
Did you try it with an array object using
Did you try it with an array object using the array module?
On Tue, Feb 2, 2010 at 3:14 PM, Mitchell L Model wrote:
> An instructive lesson in YAGNI ("you aren't going to need it"), premature
> optimization, and not making assumptions about Python data structure
> implementations.
>
> I need a 10
On Mar 17, 2:18 am, Peter Otten <__pete...@web.de> wrote:
> Mensanator wrote:
> > On Mar 16, 1:40 pm, Peter Otten <__pete...@web.de> wrote:
> >> mattia wrote:
> >> > I have 2 lists, like:
> >> > l1 = [1,2,3]
> >> > l2 = [4,5]
> >> > now I want to obtain a this new list:
> >> > l = [(1,4),(1,5),(2,4
Il Tue, 17 Mar 2009 08:18:08 +0100, Peter Otten ha scritto:
> Mensanator wrote:
>
>> On Mar 16, 1:40 pm, Peter Otten <__pete...@web.de> wrote:
>>> mattia wrote:
>>> > I have 2 lists, like:
>>> > l1 = [1,2,3]
>>> > l2 = [4,5]
>>> > now I want to obtain a this new list: l =
>>> > [(1,4),(1,5),(2,4)
Mensanator wrote:
> On Mar 16, 1:40 pm, Peter Otten <__pete...@web.de> wrote:
>> mattia wrote:
>> > I have 2 lists, like:
>> > l1 = [1,2,3]
>> > l2 = [4,5]
>> > now I want to obtain a this new list:
>> > l = [(1,4),(1,5),(2,4),(2,5),(3,4),(3,5)]
>> > Then I'll have to transform the values found in
On Mar 16, 1:40 pm, Peter Otten <__pete...@web.de> wrote:
> mattia wrote:
> > I have 2 lists, like:
> > l1 = [1,2,3]
> > l2 = [4,5]
> > now I want to obtain a this new list:
> > l = [(1,4),(1,5),(2,4),(2,5),(3,4),(3,5)]
> > Then I'll have to transform the values found in the new list.
> > Now, some
mattia wrote:
> I have 2 lists, like:
> l1 = [1,2,3]
> l2 = [4,5]
> now I want to obtain a this new list:
> l = [(1,4),(1,5),(2,4),(2,5),(3,4),(3,5)]
> Then I'll have to transform the values found in the new list.
> Now, some ideas (apart from the double loop to aggregate each element of
> l1 with
mattia:
> Now, some ideas (apart from the double loop to aggregate each element of
> l1 with each element of l2):
>>> from itertools import product
>>> list(product([1,2,3], [4,5]))
[(1, 4), (1, 5), (2, 4), (2, 5), (3, 4), (3, 5)]
Bye,
bearophile
--
http://mail.python.org/mailman/listinfo/python-
On Monday 16 March 2009 15:07:06 mattia wrote:
> I have 2 lists, like:
> l1 = [1,2,3]
> l2 = [4,5]
> now I want to obtain a this new list:
> l = [(1,4),(1,5),(2,4),(2,5),(3,4),(3,5)]
> Then I'll have to transform the values found in the new list.
> Now, some ideas (apart from the double loop to agg
Christian Heimes wrote:
Sets are basically dicts without values.
For CPython true, but abstractly, dicts are sets with values, and
mappings are often viewed as sets of key,value pairs.
--
http://mail.python.org/mailman/listinfo/python-list
Stephen Hansen schrieb:
> Now, I believe Python sets *are* for all intents and purposes
> dictionaries, but I think that's just because its the easiest and most
> efficient way to implement their uniqueness properties; they took the
> very-well-tuned dictionary implementation and cut out the stuff
er schrieb:
> Somebody much more intelligent than I said today that someone told him that
> Python lists are just dictionaries with lists hashed by integers. Since he
> said that someone else told him this, I piped up and said that I thought
> that wasn't true. I looked at the source code for lis
En Sat, 07 Feb 2009 01:18:37 -0200, er escribió:
Somebody much more intelligent than I said today that someone told him
that Python lists are just dictionaries with lists hashed by integers.
In addition to all other responses you received, I'd add that lists and
dictionaries share the same
En Sat, 07 Feb 2009 01:18:37 -0200, er escribió:
Somebody much more intelligent than I said today that someone told him
that Python lists are just dictionaries with lists hashed by integers.
In addition to all other responses you received, I'd add that lists and
dictionaries share the same
er wrote:
Somebody much more intelligent than I said today that someone told him
that Python lists are just dictionaries with lists hashed by integers.
Abstractly, which is to say, behaviorally, a Python list is a sequence
class as defined under Built-in Types in the Library manual.
Diction
On Fri, Feb 6, 2009 at 7:32 PM, er wrote:
> Thanks Chris. Lua tables are one of my favorite linguistic traits, which
> was actually part of the discussion that brought up this nugget.
> Nevertheless, any details you care to provide about the details. I'm going
> to dive into the source code in m
> On Fri, Feb 6, 2009 at 10:25 PM, Chris Rebert wrote:
>> On Fri, Feb 6, 2009 at 7:18 PM, er wrote:
>> > Somebody much more intelligent than I said today that someone told him
>> > that
>> > Python lists are just dictionaries with lists hashed by integers. Since
>> > he
>> > said that someone el
Thanks Chris. Lua tables are one of my favorite linguistic traits, which
was actually part of the discussion that brought up this nugget.
Nevertheless, any details you care to provide about the details. I'm going
to dive into the source code in more depth tomorrow, just so I can get a
better unde
On Fri, Feb 6, 2009 at 7:18 PM, er wrote:
> Somebody much more intelligent than I said today that someone told him that
> Python lists are just dictionaries with lists hashed by integers. Since he
> said that someone else told him this, I piped up and said that I thought
> that wasn't true. I lo
Correction, the first sentence should read, "lists are just dictionaries
keyed with integers."
On Fri, Feb 6, 2009 at 10:18 PM, er wrote:
> Somebody much more intelligent than I said today that someone told him that
> Python lists are just dictionaries with lists hashed by integers. Since he
>
On Jun 9, 3:34 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
> Nader wrote:
> > Hello,
>
> > I have two lists and would save them in a tuple.
>
> > a = [1,2,3]
> > b = ['a','b','c']
>
> > with the next statement I can do that:
>
> > t = [(x,y), for x in a for y in b]
>
> > This gives the next l
1 - 100 of 226 matches
Mail list logo