In <0c642381-4dd2-48c5-bb22-b38f2d5b2...@googlegroups.com>
paul.garcia2...@gmail.com writes:
> Write a program which prints the sum of numbers from 1 to 101
> (1 and 101 are included) that are divisible by 5 (Use while loop)
> x=0
> count=0
> while x<=100:
> if x%5==0:
>
On 29/11/2016 23:58, paul.garcia2...@gmail.com wrote:
Write a program which prints the sum of numbers from 1 to 101 ( 1 and 101 are
included) that are divisible by 5 (Use while loop)
This is the code:
x=0
count=0
while x<=100:
if x%5==0:
count=count+x
x=x+1
print(count)
This
On 2016-11-29 23:58, paul.garcia2...@gmail.com wrote:
Write a program which prints the sum of numbers from 1 to 101 ( 1 and 101 are
included) that are divisible by 5 (Use while loop)
This is the code:
x=0
count=0
while x<=100:
if x%5==0:
count=count+x
x=x+1
print(count)
On Monday, 30 June 2014 18:16:21 UTC+5:30, Peter Otten wrote:
Jaydeep Patil wrote:
I have did excel automation using python.
In my code I am creating python dictionaries for different three columns
data at a time.There are are many rows above 4000. Lets have look in below
Jaydeep Patil wrote:
Dear Peter,
I have tested code written by you. But still it is taking same time.
Too bad ;(
If you run the equivalent loop written in Basic from within Excel -- is that
faster?
If you run the loop in Python with some made-up data instead of that fetched
from Excel --
On Tue, 01 Jul 2014 14:40:18 +0200, Peter Otten wrote:
What I'm trying to tell you: you need to put in some work to identify
the culprit...
His next question was how do I read a range from excel, please give me
an example
I gave him an example of using google to search for solutions to his
Jaydeep Patil wrote:
I have did excel automation using python.
In my code I am creating python dictionaries for different three columns
data at a time.There are are many rows above 4000. Lets have look in below
function. Why it is taking too much time?
Code:
def
On Monday, June 30, 2014 1:32:23 PM UTC+2, Jaydeep Patil wrote:
I have did excel automation using python.
In my code I am creating python dictionaries for different three columns data
at a time.There are are many rows above 4000. Lets have look in below
function. Why it is taking too much
marco.naw...@colosso.nl wrote:
In the past I even dumped an EXCEL sheet as a
CSV file
That's probably the only way you'll speed things up
significantly. In my experience, accessing Excel via
COM is abysmally slow no matter how you go about it.
--
Greg
--
The first item in a sequence is at index zero because it is that far away from
the beginning. The second item is one away from the beginning. That is the
reason for zero-based indexing.
--
http://mail.python.org/mailman/listinfo/python-list
Hi Roy,
On Feb 11, 2013, at 10:24 AM, Roy Smith r...@panix.com wrote:
Is this server that you're talking to something that you have control
over, i.e. are you stuck with this protocol? Given a choice, I'd go
with something like JSON, for which pre-existing libraries for every
language
Hi Dave,
On Feb 11, 2013, at 9:22 AM, Dave Angel da...@davea.name wrote:
Exactly how are you sending hexadecimal ? If that 0xad (which is only one
byte, what about the other 3 ?) is intended to be a C description, then it's
certainly not hex, it's binary. And probably little-endian, to
Hi MRAB,
My code now works thanks to your advice.
{msgver: 1.0, msgid: 200, subcode: 100, appver: 1.0, appid:
1.0, data: {1: igb0, 2: igb1, ifcnt: 2}}
connected to misty:8080
sending data
138 bytes sent: 0x86{msgver: 1.0, msgid: 200, subcode: 100,
appver: 1.0, appid: 1.0, data: {1: igb0, 2:
On 2013-02-11 14:56, Ihsan Junaidi Ibrahim wrote:
Hi Roy,
On Feb 11, 2013, at 10:24 AM, Roy Smith r...@panix.com wrote:
Is this server that you're talking to something that you have control
over, i.e. are you stuck with this protocol? Given a choice, I'd go
with something like JSON, for
On Tue, Feb 12, 2013 at 2:11 AM, MRAB pyt...@mrabarnett.plus.com wrote:
I probably wouldn't make it fixed length. I'd have the length in
decimal followed by, say, \n.
Or even followed by any non-digit. Chances are your JSON data begins
with a non-digit, so you'd just have to insert a space in
On 02/11/2013 10:02 AM, Ihsan Junaidi Ibrahim wrote:
snip
print 'message length is {0}'.format(nbuf)
while True:
buf = sock.recv(nbuf)
if not buf:
break
This loop doesn't terminate till buf is zero length, which it will be
eventually. At that
On Feb 11, 2013, at 11:24 PM, Chris Angelico ros...@gmail.com wrote:
On Tue, Feb 12, 2013 at 2:11 AM, MRAB pyt...@mrabarnett.plus.com wrote:
I probably wouldn't make it fixed length. I'd have the length in
decimal followed by, say, \n.
Or even followed by any non-digit. Chances are your
On Tue, Feb 12, 2013 at 12:41 PM, Ihsan Junaidi Ibrahim ih...@grep.my wrote:
On Feb 11, 2013, at 11:24 PM, Chris Angelico ros...@gmail.com wrote:
On Tue, Feb 12, 2013 at 2:11 AM, MRAB pyt...@mrabarnett.plus.com wrote:
I probably wouldn't make it fixed length. I'd have the length in
decimal
In article mailman.1655.1360594595.2939.python-l...@python.org,
Ihsan Junaidi Ibrahim ih...@grep.my wrote:
I'm running JSON for my application messaging protocol but with JSON and
python default unordered dict,
there's no guarantee if I put in the length key in the JSON message, it will
be
On 2013-02-12 02:20, Chris Angelico wrote:
On Tue, Feb 12, 2013 at 12:41 PM, Ihsan Junaidi Ibrahim ih...@grep.my wrote:
On Feb 11, 2013, at 11:24 PM, Chris Angelico ros...@gmail.com wrote:
On Tue, Feb 12, 2013 at 2:11 AM, MRAB pyt...@mrabarnett.plus.com wrote:
I probably wouldn't make it
On 02/10/2013 07:48 PM, Ihsan Junaidi Ibrahim wrote:
Hi,
I'm implementing a python client connecting to a C-backend server and am
currently stuck to as to how to proceed with receiving variable-length byte
stream coming in from the server.
I have coded the first 4 bytes (in hexadecimal) of
On 2013-02-11 00:48, Ihsan Junaidi Ibrahim wrote:
Hi,
I'm implementing a python client connecting to a C-backend server and am
currently stuck to as to how to proceed with receiving variable-length byte
stream coming in from the server.
I have coded the first 4 bytes (in hexadecimal) of
In article mailman.1612.1360544258.2939.python-l...@python.org,
Ihsan Junaidi Ibrahim ih...@grep.my wrote:
I'm implementing a python client connecting to a C-backend server and am
currently stuck to as to how to proceed with receiving variable-length byte
stream coming in from the server.
On 03:56 am, tjre...@udel.edu wrote:
exar...@twistedmatrix.com wrote:
There's a lot of things in Python that I don't strictly *need*. That
doesn't mean that they wouldn't be welcome if I could have them.
Getting rid of the range/xrange dichotomy would improve things.
The developers agreed a
On 02:12 am, pavlovevide...@gmail.com wrote:
On Aug 16, 3:35�pm, sturlamolden sturlamol...@yahoo.no wrote:
On 16 Aug, 14:57, Dennis Lee Bieber wlfr...@ix.netcom.com wrote:
Well, the alternative would be to have two keywords for
looping: one
for your simple incrementing integer
On 01:53 am, pavlovevide...@gmail.com wrote:
On Aug 16, 6:28�pm, exar...@twistedmatrix.com wrote:
On 01:23 am, benjamin.kap...@case.edu wrote:
On Sun, Aug 16, 2009 at 6:35 PM, sturlamolden sturlamol...@yahoo.no
wrote:
A compiler could easily recognise a statement like
� for i in range(n):
On 01:44 am, http wrote:
exar...@twistedmatrix.com writes:
Although I think PyPy also recognizes this case and makes it as
efficient as using xrange, and does so without breaking any rules.
How can pypy possibly know that the user hasn't assigned some other
value to range?
It doesn't really
On 16 Aug, 19:12, Carl Banks pavlovevide...@gmail.com wrote:
If you don't care about the dynamic stuff why don't you just use
Cython? Or quit complaining and just use xrange.
I think you are the only one complaining here.
--
http://mail.python.org/mailman/listinfo/python-list
exar...@twistedmatrix.com wrote:
On 02:12 am, pavlovevide...@gmail.com wrote:
On Aug 16, 3:35�pm, sturlamolden sturlamol...@yahoo.no wrote:
On 16 Aug, 14:57, Dennis Lee Bieber wlfr...@ix.netcom.com wrote:
� � � � Well, the alternative would be to have two keywords for
looping: one
for your
Carl Banks wrote:
On Aug 16, 3:35 pm, sturlamolden sturlamol...@yahoo.no wrote:
On 16 Aug, 14:57, Dennis Lee Bieber wlfr...@ix.netcom.com wrote:
Well, the alternative would be to have two keywords for looping: one
for your simple incrementing integer loop, and another for a loop that
On Sun, 16 Aug 2009 15:35:26 -0700, sturlamolden wrote:
On 16 Aug, 14:57, Dennis Lee Bieber wlfr...@ix.netcom.com wrote:
Well, the alternative would be to have two keywords for
looping: one
for your simple incrementing integer loop, and another for a loop
that operates over
John Machin wrote:
On Aug 17, 8:35 am, sturlamolden sturlamol...@yahoo.no wrote:
A compiler could easily recognise a statement like
for i in range(n):
as a simple integer loop. In fact, Cython is able to do this.
Extremely easy, once users relinquish the right to replace built-in
On Sun, Aug 16, 2009 at 11:10 PM, Nobodynob...@nowhere.com wrote:
Java also has iterators; it's more a case of people coming from C and BASIC.
Although, some of those may have come *through* Java without abandoning
old habits. You see the same thing with people coming from BASIC to C and
Emmanuel Surleau wrote:
Dr. Phillip M. Feldman wrote:
[snip]
def is_prime(n):
for j in range(2,n):
if (n % j) == 0: return False
return True
It seems as though Python is actually expanding range(2,n) into a list of
numbers, even though this is incredibly wasteful of memory. There
On Aug 17, 4:40 am, exar...@twistedmatrix.com wrote:
On 02:12 am, pavlovevide...@gmail.com wrote:
On Aug 16, 3:35 pm, sturlamolden sturlamol...@yahoo.no wrote:
On 16 Aug, 14:57, Dennis Lee Bieber wlfr...@ix.netcom.com wrote:
Well, the alternative would be to have two keywords for
On 06:32 pm, pavlovevide...@gmail.com wrote:
On Aug 17, 4:40�am, exar...@twistedmatrix.com wrote:
On 02:12 am, pavlovevide...@gmail.com wrote:
On Aug 16, 3:35�pm, sturlamolden sturlamol...@yahoo.no wrote:
On 16 Aug, 14:57, Dennis Lee Bieber wlfr...@ix.netcom.com wrote:
� � � �
exar...@twistedmatrix.com wrote:
There's a lot of things in Python that I don't strictly *need*. That
doesn't mean that they wouldn't be welcome if I could have them. Getting
rid of the range/xrange dichotomy would improve things.
The developers agreed a couple of years ago. Starting using
Dr. Phillip M. Feldman wrote:
[snip]
def is_prime(n):
for j in range(2,n):
if (n % j) == 0: return False
return True
It seems as though Python is actually expanding range(2,n) into a list of
numbers, even though this is incredibly wasteful of memory. There should
be
On Sun, 16 Aug 2009 08:30:54 +0200, Emmanuel Surleau wrote:
[...]
I will also observe that if you were to stop programming whatever
language you are more familiar with in Python, and start programming
Python in Python, you'll have an easier time of it.
I don't see what's particularly
It's a particular unfair criticism because the critic (Ethan Furman)
appears to have made a knee-jerk reaction. The some language in Python
behaviour he's reacting to is the common idiom:
for i in range(len(seq)):
do_something_with(seq[i])
instead of the Python in Python idiom:
for
On Sun, Aug 16, 2009 at 2:30 AM, Emmanuel Surleau
emmanuel.surl...@gmail.com wrote:
I don't see what's particularly un-Pythonic with this code. Not using xrange()
is a mistake, certainly, but it remains clear, easily understandable code
which correctly demonstrates the naive algorithm for
Steven D'Aprano st...@remove-this-cybersource.com.au wrote in message
news:02969972$0$20647$c3e8...@news.astraweb.com...
On Fri, 14 Aug 2009 18:25:45 -0700, Dr. Phillip M. Feldman wrote:
It seems as though Python is actually expanding range(2,n) into a list
of numbers, even though this is
bartc wrote:
Steven D'Aprano st...@remove-this-cybersource.com.au wrote in
message news:02969972$0$20647$c3e8...@news.astraweb.com...
On Fri, 14 Aug 2009 18:25:45 -0700, Dr. Phillip M. Feldman wrote:
It seems as though Python is actually expanding range(2,n) into a list
of numbers, even
On 16 Aug, 11:45, bartc ba...@freeuk.com wrote:
A for-loop, for iterating over a simple sequence, should be one of the
fastest things in the language.
Anyone experienced with interpreted high-level languages knows this is
not true. Not because iterating a sequence is expensive, but because
the
On 16 Aug, 14:57, Dennis Lee Bieber wlfr...@ix.netcom.com wrote:
Well, the alternative would be to have two keywords for looping: one
for your simple incrementing integer loop, and another for a loop that
operates over the elements of some collection type.
A compiler could easily
On Sun, Aug 16, 2009 at 6:35 PM, sturlamolden sturlamol...@yahoo.no wrote:
A compiler could easily recognise a statement like
for i in range(n):
as a simple integer loop. In fact, Cython is able to do this.
but special cases aren't special enough to break the rules.
--
On Aug 17, 8:35 am, sturlamolden sturlamol...@yahoo.no wrote:
A compiler could easily recognise a statement like
for i in range(n):
as a simple integer loop. In fact, Cython is able to do this.
Extremely easy, once users relinquish the right to replace built-in
range with their own
On 01:23 am, benjamin.kap...@case.edu wrote:
On Sun, Aug 16, 2009 at 6:35 PM, sturlamolden sturlamol...@yahoo.no
wrote:
A compiler could easily recognise a statement like
� for i in range(n):
as a simple integer loop. In fact, Cython is able to do this.
but special cases aren't special
exar...@twistedmatrix.com writes:
Although I think PyPy also recognizes this case and makes it as
efficient as using xrange, and does so without breaking any rules.
How can pypy possibly know that the user hasn't assigned some other
value to range?
--
On Aug 16, 6:28 pm, exar...@twistedmatrix.com wrote:
On 01:23 am, benjamin.kap...@case.edu wrote:
On Sun, Aug 16, 2009 at 6:35 PM, sturlamolden sturlamol...@yahoo.no
wrote:
A compiler could easily recognise a statement like
for i in range(n):
as a simple integer loop. In fact, Cython
On Aug 16, 3:35 pm, sturlamolden sturlamol...@yahoo.no wrote:
On 16 Aug, 14:57, Dennis Lee Bieber wlfr...@ix.netcom.com wrote:
Well, the alternative would be to have two keywords for looping: one
for your simple incrementing integer loop, and another for a loop that
operates over
On Sun, 16 Aug 2009 11:41:21 -0400, Benjamin Kaplan wrote:
It's not that the code is bad, but too many people coming from Java
and C keep thinking of for loops like they're using Java or C and
therefore that for i in range(a,b) is identical to for(int i = a; i
b; i++). It's not and, for the
look at xrange -- http://docs.python.org/library/functions.html#xrange
--
http://mail.python.org/mailman/listinfo/python-list
On Saturday 15 August 2009 03:25:45 Dr. Phillip M. Feldman wrote:
It seems as though Python is actually expanding range(2,n) into a list of
numbers, even though this is incredibly wasteful of memory. There should be
a looping mechanism that generates the index variable values incrementally
as
On Aug 15, 11:38 am, Mark Lawrence breamore...@yahoo.co.uk wrote:
Dr. Phillip M. Feldman wrote: I wrote the following correct but inefficient
test of primality for purposes
of demonstrating that the simplest algorithm is often not the most
efficient. But, when I try to run the following
On Fri, 14 Aug 2009 18:25:45 -0700, Dr. Phillip M. Feldman wrote:
It seems as though Python is actually expanding range(2,n) into a list
of numbers, even though this is incredibly wasteful of memory. There
should be a looping mechanism that generates the index variable values
incrementally as
Hendrik van Rooyen wrote:
On Saturday 15 August 2009 03:25:45 Dr. Phillip M. Feldman wrote:
And while you are about it, you may as well teach them that it is much better
to do a multiplication than a division.
Actually, division speed hasn't been much of an issue in years. Arithmetic
John Nagle wrote:
Hendrik van Rooyen wrote:
On Saturday 15 August 2009 03:25:45 Dr. Phillip M. Feldman wrote:
And while you are about it, you may as well teach them that it is much
better to do a multiplication than a division.
Actually, division speed hasn't been much of an issue in
It seems as though Python is actually expanding range(2,n) into a list of
numbers, even though this is incredibly wasteful of memory. There should be
a looping mechanism that generates the index variable values incrementally
as they are needed.
This has nothing to do with Python's for loop
Dr. Phillip M. Feldman wrote:
I wrote the following correct but inefficient test of primality for purposes
of demonstrating that the simplest algorithm is often not the most
efficient. But, when I try to run the following code with a value of n that
is large enough to produce a significant
Dr. Phillip M. Feldman wrote:
I wrote the following correct but inefficient test of primality for purposes
of demonstrating that the simplest algorithm is often not the most
efficient. But, when I try to run the following code with a value of n that
is large enough to produce a significant
On Aug 14, 8:25 pm, Dr. Phillip M. Feldman pfeld...@verizon.net
wrote:
I wrote the following correct but inefficient test of primality for purposes
of demonstrating that the simplest algorithm is often not the most
efficient. But, when I try to run the following code with a value of n that
is
In article pecora-d381e9.08361703042...@ra.nrl.navy.mil,
Lou Pecora pec...@anvil.nrl.navy.mil wrote:
In article
5c92e9bd-1fb4-4c01-a928-04d7f6733...@e21g2000yqb.googlegroups.com,
Aaron Brady castiro...@gmail.com wrote:
Did I tell you guys that 'natural' has 38 definitions at
dictionary.com?
On Apr 2, 5:29 pm, Steven D'Aprano
ste...@remove.this.cybersource.com.au wrote:
On Wed, 01 Apr 2009 21:58:47 -0700, Lie wrote:
On Apr 1, 7:06 pm, Steven D'Aprano
ste...@remove.this.cybersource.com.au wrote:
There is a major clash between the names of ordinals in human languages
and
In article
5c92e9bd-1fb4-4c01-a928-04d7f6733...@e21g2000yqb.googlegroups.com,
Aaron Brady castiro...@gmail.com wrote:
On Apr 2, 6:34 pm, Tim Wintle tim.win...@teamrubber.com wrote:
On Thu, 2009-04-02 at 15:16 -0700, Emile van Sebille wrote:
Lou Pecora wrote:
Confusion only comes when
Lie wrote:
[snip]
Alternatively:
One friend of mine half-seriously advanced the following thesis: We
should count from zero. But first is, etymologically, a diminution
of foremost, and (as TomStambaugh says) should mean 0th when we
count from 0. And second is from the Latin secundus, meaning
On Apr 3, 10:36 pm, Lou Pecora pec...@anvil.nrl.navy.mil wrote:
Aaron Brady castiro...@gmail.com wrote:
Did I tell you guys that 'natural' has 38 definitions at
dictionary.com?
Amazing. I suggest you pick the one that fits best.
You mean the one that feels most natural?
--
On Apr 3, 10:43 am, alex23 wuwe...@gmail.com wrote:
On Apr 3, 10:36 pm, Lou Pecora pec...@anvil.nrl.navy.mil wrote:
Aaron Brady castiro...@gmail.com wrote:
Did I tell you guys that 'natural' has 38 definitions at
dictionary.com?
Amazing. I suggest you pick the one that fits best.
On Apr 2, 4:05 pm, Aaron Brady castiro...@gmail.com wrote:
On Apr 1, 11:58 pm, Lie lie.1...@gmail.com wrote:
On Apr 1, 7:06 pm, Steven D'Aprano
ste...@remove.this.cybersource.com.au wrote:
There is a major clash between the names of ordinals in human languages
and zero-based counting.
On Thu, 02 Apr 2009 04:23:32 +, John O'Hagan wrote:
Beyond being part of a conventionally-ordered set of keys, what can an
ordinality of zero actually mean? (That's a sincere question.)
In set theory, you start by defining the integers like this:
0 is the cardinality (size) of the empty
On Wed, 01 Apr 2009 21:58:47 -0700, Lie wrote:
On Apr 1, 7:06 pm, Steven D'Aprano
ste...@remove.this.cybersource.com.au wrote:
There is a major clash between the names of ordinals in human languages
and zero-based counting. In human languages, the Nth-ordinal item comes
in position N. You
On Apr 1, 9:23 pm, John O'Hagan resea...@johnohagan.com wrote:
Despite being thoroughly acclimatised to zero-based indexing and having no
wish to change it, I'm starting to see the OP's point.
Many of the arguments presented in this thread in favour of zero-based
indexing have rather been
On Apr 2, 1:29 am, Steven D'Aprano
ste...@remove.this.cybersource.com.au wrote:
On Wed, 01 Apr 2009 21:58:47 -0700, Lie wrote:
On Apr 1, 7:06 pm, Steven D'Aprano
ste...@remove.this.cybersource.com.au wrote:
There is a major clash between the names of ordinals in human languages
and
Carl Banks pavlovevide...@gmail.com writes:
This is unforgiveable, not only changing the indexing semantics of
Python (because a user would have NO CLUE that something underlying
has been changed, and thus it should never be done), but also for
the needless abuse of exec.
Then I guess you'd
Carl Banks wrote:
On Apr 1, 2:32 pm, Arnaud Delobelle arno...@googlemail.com wrote:
Check the date on the line above (and the PS in that post).
If I were your boss and you ever pulled something like this, your ass
would be so fired.
This is unforgiveable, not only changing the indexing
On Apr 1, 11:28 pm, Hrvoje Niksic hnik...@xemacs.org wrote:
Carl Banks pavlovevide...@gmail.com writes:
This is unforgiveable, not only changing the indexing semantics of
Python (because a user would have NO CLUE that something underlying
has been changed, and thus it should never be done),
On Thu, 2 Apr 2009, Steven D'Aprano wrote:
On Thu, 02 Apr 2009 04:23:32 +, John O'Hagan wrote:
Beyond being part of a conventionally-ordered set of keys, what can an
ordinality of zero actually mean? (That's a sincere question.)
[snip erudite definition of cardinality]
For
Steven D'Aprano wrote:
In set theory, you start by defining the integers like this:
0 is the cardinality (size) of the empty set, the set with nothing in it.
1 is the cardinality of the set of empty sets, that is, the set
containing nothing but the empty set.
2 is the cardinality of the
En Wed, 01 Apr 2009 08:04:12 -0300, andrew cooke and...@acooke.org
escribió:
something i don't think has been mentioned much - if you're using
range() in your python code then you're almost always doing it wrong.
i just grepped lepl and i use range 20 times in 9600 lines of code. out
of
In article pan.2009.04.02.06.28...@remove.this.cybersource.com.au,
Steven D'Aprano ste...@remove.this.cybersource.com.au wrote:
So an ordinality of zero just means the number
of elements of something that doesn't exist.
You do realize that will give most people headaches. :-)
--
-- Lou
On Thu, 2009-04-02 at 06:28 +, Steven D'Aprano wrote:
In set theory, you start by defining the integers like this:
snip
0 = len( {} )
1 = len( {{}} )
2 = len( {{}, {{}}} )
3 = len( {{}, {{}}, {{}, {{}}} )
etc.
not quite len() - surely you mean something like any object along with
an
In article
bd70785c-1e86-4437-a14e-d84028f57...@k19g2000prh.googlegroups.com,
Carl Banks pavlovevide...@gmail.com wrote:
I think people were being facetious. To me the first item in the list
is x[0]--ordinal does not match cardinal. However, I don't use
ordinals much when talking about
Lou Pecora wrote:
Confusion only comes when you try to force the
defintion of one of them on the other and then say it's illogical or not
natural. Both are natural.
Consider the French 'Premiere etage' vs the American 'First Floor'
Emile
--
On Thu, 2009-04-02 at 15:16 -0700, Emile van Sebille wrote:
Lou Pecora wrote:
Confusion only comes when you try to force the
defintion of one of them on the other and then say it's illogical or not
natural. Both are natural.
Consider the French 'Premiere etage' vs the American 'First
On Apr 2, 6:34 pm, Tim Wintle tim.win...@teamrubber.com wrote:
On Thu, 2009-04-02 at 15:16 -0700, Emile van Sebille wrote:
Lou Pecora wrote:
Confusion only comes when you try to force the
defintion of one of them on the other and then say it's illogical or not
natural. Both are
Chris Rebert c...@rebertia.com writes:
Among other things, it has the nice property that:
len(some_list[n:m]) == m-n
And also that it is intuitive how to represent an empty slice
(foo[n:n]). When traversing over sublists, it's also a useful
property that foo[a:b] + foo[b:c] == foo.
--
On Mar 31, 7:23 pm, Lada Kugis lada.ku...@gmail.com wrote:
On 01 Apr 2009 01:26:41 GMT, Steven D'Aprano
ste...@remove.this.cybersource.com.au wrote:
Why Python (and other languages) count from zero instead of one, and
why half-open intervals are better than closed intervals:
Lada Kugis schrieb:
On 01 Apr 2009 01:26:41 GMT, Steven D'Aprano
ste...@remove.this.cybersource.com.au wrote:
Why Python (and other languages) count from zero instead of one, and
why half-open intervals are better than closed intervals:
On Wed, 01 Apr 2009 04:39:26 +0100, Rhodri James wrote:
Dragging this back to the original topic, you clearly find starting list
indices from zero unintuitive. To me, with a mathematical background,
it's not just intuitive, it's correct. All sorts of useful properties
fall out from that,
something i don't think has been mentioned much - if you're using
range() in your python code then you're almost always doing it wrong.
i just grepped lepl and i use range 20 times in 9600 lines of code. out
of those, all but 3 are in quick and dirty tests or experimental code,
not in the main
andrew cooke wrote:
[...]
so in a small/moderate size library of 600 lines (including blanks and
6000
comments, but excluding tests and exploratory code) the only time i have
used range with array indices i was either unhappy with the code, or
Natural language is full of ambiguity, which is why my parents used to
argue about the meaning of next Wednesday, or of the next exit.
Until you have a starting reference, and until you decide whether it's a
closed or open interval, you can't be sure everyone will get the same
semantics.
Lada Kugis:
(you have 1 apple, you start counting from 1 ...
To little children I now show how to count starting from zero: apple
number zero, apple number one, etc, and they find it natural
enough :-)
Bye,
bearophile
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, 01 Apr 2009 04:39:39 -0700, bearophileHUGS wrote:
Lada Kugis:
(you have 1 apple, you start counting from 1 ...
To little children I now show how to count starting from zero: apple
number zero, apple number one, etc, and they find it natural enough :-)
Ah, but that's not the same
2009/4/1 Carl Banks pavlovevide...@gmail.com:
I am also an engineer, and I can tell your idea of intuitive is not
universal, even among engineers. I certainly do not lean toward one-
based indexing.
Another engineer here who finds 0-based indexing more intuitive than
1-based indexing.
--
In article 1ej5t4930m29h0f6ttpdcd83t08q2q3...@4ax.com,
Lada Kugis lada.ku...@gmail.com wrote:
On 01 Apr 2009 01:26:41 GMT, Steven D'Aprano
ste...@remove.this.cybersource.com.au wrote:
Why Python (and other languages) count from zero instead of one, and
why half-open intervals are better
In article 72i5t4tgfo2h4gd6ggcs02flkca85kg...@4ax.com,
Lada Kugis lada.ku...@gmail.com wrote:
and
the (m-n) point Chris was trying to explain doesn't seem that relevant
to me.
That's because you haven't done enough programming really using the
Python structures and objects. You can
On Wed, 1 Apr 2009 00:40:17 -0700 (PDT), Carl Banks
pavlovevide...@gmail.com wrote:
Lada,
I am also an engineer, and I can tell your idea of intuitive is not
universal, even among engineers. I certainly do not lean toward one-
based indexing.
From a programming standpoint--and remember Python
On 01 Apr 2009 08:06:28 GMT, Steven D'Aprano
ste...@remove.this.cybersource.com.au wrote:
There are advantages and disadvantages to both systems, but on balance, I
think that zero-based is a better system for programming, and one-based
for natural language.
Nicely put.
Yes, along with some
Lada Kugis wrote:
[snip]
Yes, that's it. I won't argue over it, since I can't change it, but 1
is still more natural to me (it is the real world way). The above
pros seem to me to be very little compared to the cons of the ... and
the (m-n) point Chris was trying to explain doesn't seem that
1 - 100 of 138 matches
Mail list logo