On Thu, May 16, 2013 at 1:42 AM, eryksun eryk...@gmail.com wrote:
On the other hand a BufferedWriter will buffer the remaining 3000
bytes that can't be written. You won't find out until an exception is
raised when the file is closed:
Actually it was buffering all 4000 bytes. I forgot about the
On 14 May 2013 17:11, Marc Tompkins marc.tompk...@gmail.com wrote:
The OP expressed some confusion between what a function DOES and what it
RETURNS. It occurs to me that the print() function (or, more generically,
ANY print() function - it doesn't have to be Python 3) is a good
On Wed, May 15, 2013 at 10:03:20AM +0100, Oscar Benjamin wrote:
On 14 May 2013 17:11, Marc Tompkins marc.tompk...@gmail.com wrote:
Again, the return value of print() - e.g. success/failure - is
separate from what print() actually prints.
I was surprised by this so I've just tested it
On Wed, May 15, 2013 at 2:26 AM, Steven D'Aprano st...@pearwood.infowrote:
I assumed Marc was talking hypothetically. A print function *could*
return a result, even if Python's print function does not.
Actually, I was mixing up my memory of an overloaded print() function with
Python's built-in
On 15/05/13 16:51, Marc Tompkins wrote:
Actually, I was mixing up my memory of an overloaded print() function
And C's printf() returns the number of chars printed.
I actually wish python had followed suit because, as Marc says,
it can occasionally be useful...
--
Alan G
Author of the Learn
On Wed, May 15, 2013 at 1:02 PM, Alan Gauld alan.ga...@btinternet.comwrote:
On 15/05/13 16:51, Marc Tompkins wrote:
Actually, I was mixing up my memory of an overloaded print() function
And C's printf() returns the number of chars printed.
I actually wish python had followed suit because,
On 15 May 2013 22:21, Marc Tompkins marc.tompk...@gmail.com wrote:
On Wed, May 15, 2013 at 1:02 PM, Alan Gauld alan.ga...@btinternet.com
wrote:
And C's printf() returns the number of chars printed.
I actually wish python had followed suit because, as Marc says,
it can occasionally be
On Wed, May 15, 2013 at 3:43 PM, Oscar Benjamin
oscar.j.benja...@gmail.comwrote:
On 15 May 2013 22:21, Marc Tompkins marc.tompk...@gmail.com wrote:
On Wed, May 15, 2013 at 1:02 PM, Alan Gauld alan.ga...@btinternet.com
wrote:
And C's printf() returns the number of chars printed.
I
On 15 May 2013 23:52, Marc Tompkins marc.tompk...@gmail.com wrote:
On Wed, May 15, 2013 at 3:43 PM, Oscar Benjamin oscar.j.benja...@gmail.com
wrote:
On 15 May 2013 22:21, Marc Tompkins marc.tompk...@gmail.com wrote:
On Wed, May 15, 2013 at 1:02 PM, Alan Gauld alan.ga...@btinternet.com
On Wed, May 15, 2013 at 3:52 PM, Marc Tompkins marc.tompk...@gmail.comwrote:
I was thinking along the lines of an optional parameter (verbose or
something similar), so print() would supply a return value if you asked it
to but keep stumm if you didn't.
After I hit Send, I thought of the
On Wed, May 15, 2013 at 4:14 PM, Oscar Benjamin
oscar.j.benja...@gmail.comwrote:
I don't really understand what the reason for having the information
is. Would it return the number of characters written or the number of
bytes?
It's absolutely useless in an interactive session, or any time
On 16/05/13 00:18, Marc Tompkins wrote:
On Wed, May 15, 2013 at 3:52 PM, Marc Tompkins marc.tompk...@gmail.com
mailto:marc.tompk...@gmail.com wrote:
I was thinking along the lines of an optional parameter (verbose
or something similar), so print() would supply a return value if you
On 16/05/13 06:02, Alan Gauld wrote:
On 15/05/13 16:51, Marc Tompkins wrote:
Actually, I was mixing up my memory of an overloaded print() function
And C's printf() returns the number of chars printed.
I actually wish python had followed suit because, as Marc says,
it can occasionally be
On Wed, May 15, 2013 at 5:07 PM, Steven D'Aprano st...@pearwood.infowrote:
Guido's time machine strikes again.
py import sys
py sys.stdout.write('NOBODY expects the Spanish Inquisition!\n')
NOBODY expects the Spanish Inquisition!
40
The write() method of file objects in Python 3 return
On Wed, May 15, 2013 at 8:07 PM, Steven D'Aprano st...@pearwood.info wrote:
On 16/05/13 06:02, Alan Gauld wrote:
And C's printf() returns the number of chars printed.
I actually wish python had followed suit because, as Marc says,
it can occasionally be useful...
Guido's time machine
On 14/05/13 02:37, Dave Angel wrote:
def counting_primes():
primelist = []
for prime in range(2,1000):
if isprime(prime):
primelist.append(prime)
return primelist
Actually no, since the OP's looking for the first 1000 primes not for
all the primes under 1000.
Ah
On 14/05/13 00:01, Daniel Magruder wrote:
I am still confused as what return does.
Having seen the other replies I'll try a slightly
different explanation.
All programs are formed by a hierarchy of functions.
You start with a top level driver block which then utilizes or calls
helper
On Tue, May 14, 2013 at 1:51 AM, Alan Gauld alan.ga...@btinternet.comwrote:
On 14/05/13 00:01, Daniel Magruder wrote:
I am still confused as what return does.
This isn't a direct response to Alan, but to something the OP expressed
many, many messages ago...
The OP expressed some confusion
Dear Dave,
I am using python 2.
I am still confused as what return does. What does it mean if a function
returns True to the caller? What is the caller?
Your code worked for returning a list of 1000 items of odd numbers, so I then
tried writing a code to replay isodd to give True or False for
On 14/05/13 00:01, Daniel Magruder wrote:
I am still confused as what return does.
What does it mean if a function returns True to the caller?
What is the caller?
The caller is the program code that calls the function.
For example if I write a function
def square(x):
return x*x
and
On Mon, May 13, 2013 at 4:01 PM, Daniel Magruder d...@att.net wrote:
Dear Dave,
I am using python 2.
I am still confused as what return does. What does it mean if a function
returns True to the caller? What is the caller?
You've defined a function - isodd - but it doesn't automatically
On Mon, May 13, 2013 at 5:13 PM, Marc Tompkins marc.tompk...@gmail.comwrote:
In fact, you could shorten your isodd() function to:
def isodd(candidate):
return candidate%2 !=0:
and it would function identically.
Sorry - that should be
def isodd(candidate):
return candidate%2 !=0
On 05/13/2013 07:01 PM, Daniel Magruder wrote:
Dear Dave,
I am using python 2.
I am still confused as what return does. What does it mean if a
function returns True to the caller? What is the caller?
Have you ever used (called) a function? If so, you've written a caller.
For example, if
On 05/13/2013 07:55 PM, Alan Gauld wrote:
On 14/05/13 00:01, Daniel Magruder wrote:
SNIP
That seems OK but it would be simpler with a for loop:
def counting_primes():
primelist = []
for prime in range(2,1000):
if isprime(prime):
primelist.append(prime)
(Please don't top-post. And don't reply privately, as I'm not the only
one reading this thread. Post the reply to the list, as you did last
time with your reply-all)
On 05/13/2013 09:45 PM, Daniel Magruder wrote:
Dear Dave,
I don't have a clue what you're confused about. Do you not
On 05/11/2013 09:58 PM, Daniel Magruder wrote:
Please respond to the list, not the individual. Otherwise you're
robbing yourself and others of the possibility of learning from and
helping multiple people. I don't mind if you ALSO reply to me (which is
what reply-all does by default), but
On 12/05/13 12:43, Dave Angel wrote:
Despite going to many sources I can not seem to find a single source
that adequately explains Python 100% without any technical jargon or
assumptions of prior knowledge.
Its impossible to learn to program without learning technical jargon,
but there are
On Sun, May 12, 2013 at 6:43 AM, Dave Angel da...@davea.name wrote:
[...]
With no experience in programming other languages, you'd need a different
kind of tutorial than I sought when I was learning Python. And you
absolutely need to match your tutorial against the version of Python you're
On Sun, May 12, 2013 at 9:43 PM, Dave Angel da...@davea.name wrote:
On 05/11/2013 09:58 PM, Daniel Magruder wrote:
Please respond to the list, not the individual. Otherwise you're robbing
yourself and others of the possibility of learning from and helping multiple
people. I don't mind if
Dear Tutor at Python.org,
I am new to the python language and have been teaching myself through various
online resources. I found an exercise where I am to create a program that
prints a list of the first 1000 prime numbers. After many attempts and looking
at other answers for other ways around
On 05/11/2013 04:44 PM, Daniel Magruder wrote:
Dear Tutor at Python.org,
I am new to the python language and have been teaching myself through various
online resources. I found an exercise where I am to create a program that
prints a list of the first 1000 prime numbers. After many attempts
31 matches
Mail list logo