Hi, everyone
I am new to python, so what I ask may be so basic. I don't know the
difference between
s = 'a' 'b'
and
s = 'a'+'b'
They have the same results. Thanks for relying!
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/li
On Wed, Jul 2, 2008 at 9:05 PM, Alan Gauld <[EMAIL PROTECTED]> wrote:
> "sean_mcdaniel" <[EMAIL PROTECTED]> wrote
>
>> I am having problems with classes and subclasses. Do the different
>> __init__
>> statements have to have different argument lists?
>
> You got the solution to your specific questi
On 03/07/2008, Alan Gauld <[EMAIL PROTECTED]> wrote:
> "John Fouhy" <[EMAIL PROTECTED]> wrote
> > you can instead say:
> >
> > try:
> > foo()
> > except TypeError:
> > # do something else
> This makes slightly more sense, although a TypeError seems a bit
> too vague, if it had bveen a Callab
"John Fouhy" <[EMAIL PROTECTED]> wrote
otherwise. this will be removed for Python 3.x because you can
just
use hasattr(obj, '__call__').
I was about to go BOO HISS because callable() is much more
readable than hasattr() but...
you can instead say:
try:
foo()
except TypeError:
# do
"sean_mcdaniel" <[EMAIL PROTECTED]> wrote
I am having problems with classes and subclasses. Do the different
__init__
statements have to have different argument lists?
You got the solution to your specific question but to answer
your more pholosophical one:
sub classes should ideally have th
On 03/07/2008, Emil <[EMAIL PROTECTED]> wrote:
> I have created a class called Fibs which allow you to access a specific
> number in the
> Fibonacci series(http://en.wikipedia.org/wiki/Fibonacci_number) But it seems
> to me that it
> is a bit inefficient, any suggestions on how to make it more e
"Paul Melvin" <[EMAIL PROTECTED]> wrote
For example, if I generate some numbers using range the only way I
could
easily sum them was to append them to a list and then call the sum
function,
if I tried without the list I couldn't sum them at all.
Lots of good general answers but specifically
Hello all
I have created a class called Fibs which allow you to access a specific number
in the Fibonacci series(http://en.wikipedia.org/wiki/Fibonacci_number) But it
seems to me that it is a bit inefficient, any suggestions on how to make it
more efficient?
Here is the code:
class Fibs(obje
On 03/07/2008, wesley chun <[EMAIL PROTECTED]> wrote:
> on a related note, currently in Python, there is a callable() Boolean
> function that returns True if the object's callable and False
> otherwise. this will be removed for Python 3.x because you can just
> use hasattr(obj, '__call__').
I
- Message from [EMAIL PROTECTED] -
Date: Wed, 02 Jul 2008 14:32:27 -0400
From: bob gailer <[EMAIL PROTECTED]>
[EMAIL PROTECTED] wrote:
[snip]
In a case like
print '%s%s' %42 , 333
...
TypeError: not enough arguments for format string
it would be ambiguous whether 3
Hi y'all,
I found the problem. My __init__ statement in the subclass had an extra
underscore, which is why the baseclass __init__ was the only one called.
Duh!
Sean
sean_mcdaniel wrote:
>
> Thank you for the reply.
>
> I have made the substitution, but I still receive the same error. I
> pr
[EMAIL PROTECTED] wrote:
[snip]
In a case like
print '%s%s' %42 , 333
...
TypeError: not enough arguments for format string
it would be ambiguous whether 333 was intended as a second formatting
argument or as a second thing to be printed.
Here's where the Language Reference comes in ha
> > It seems to me that Wes is saying only that all function objects are
> > callable, not that all callable objects are functions.
>
> Wesley said that function objects have a "heaping distinction" of
> being callable. Only he can say for sure what that means; I took it to
> mean that being ca
Thank you for the reply.
I have made the substitution, but I still receive the same error. I
previously defined the __init__ statements in the old way, i.e.
FileParse.__init__(self)
but with the same problematic outcome.
Thank you,
Sean
Lie Ryan wrote:
>
>> Hi Folks,
>>
>> I can redefine
- Message from [EMAIL PROTECTED] -
Date: Wed, 2 Jul 2008 16:49:19 +1200
From: John Fouhy <[EMAIL PROTECTED]>
On 02/07/2008, Christopher Spears <[EMAIL PROTECTED]> wrote:
File "point.py", line 13, in __str__
point_str = "(%f,%f)" % self.x, self.y
TypeError: not enoug
mponents now, its just
putting them together to make something meaningful :)
If anyone has any tips/link/experiences to help me on my way I would appreciate
it
Cheers
paul
__ Information from ESET Smart Security, version of virus signature
> Hi Folks,
>
> I can redefine the class and I get a "TypeError: __init__() takes
> exactly 1
> argument (2 given)" error. I'm creating a SinglePeakFit object and
> not a
> FileParse one. Still puzzled...
In this:
class SinglePeakFit(FileParse):
...
def __init___(self, filename):
On Wed, Jul 2, 2008 at 11:50 AM, Dick Moores <[EMAIL PROTECTED]> wrote:
> It seems to me that Wes is saying only that all function objects are
> callable, not that all callable objects are functions.
Wesley said that function objects have a "heaping distinction" of
being callable. Only he can say
Hi folks,
I am having problems with classes and subclasses. Do the different __init__
statements have to have different argument lists? I expected my code to
print out "location 1" and "location 2" indicating that both __init__
statements had been successfully called, but it seems like only the
s
Hi Folks,
I can redefine the class and I get a "TypeError: __init__() takes exactly 1
argument (2 given)" error. I'm creating a SinglePeakFit object and not a
FileParse one. Still puzzled...
Thanks,
Sean
New definition:
"""Contains various classes for parsing input files. Used for various
fi
At 03:46 AM 7/2/2008, Kent Johnson wrote:
On Wed, Jul 2, 2008 at 3:54 AM, wesley chun <[EMAIL PROTECTED]> wrote:
> in the former, you have a function object. it's just like any other
> Python object, but with one heaping distinction: it's callable --
> this means that u can slap on a pair of p
> If I have a set of numbers, or strings etc. which have been
generated
> and I then want to do something with them, for example a sum function
> call. Is the best way to put those items in a list, or similar
> container, before applying the function.
The best design tips I could give is not
On Wed, Jul 2, 2008 at 6:31 AM, Daniele <[EMAIL PROTECTED]> wrote:
>>> If I have a set of numbers, or strings etc. which have been generated and I
>>> then want to do something with them, for example a sum function call. Is
>>> the best way to put those items in a list, or similar container, bef
On Wed, Jul 2, 2008 at 5:54 AM, Tim Golden <[EMAIL PROTECTED]> wrote:
> Paul Melvin wrote:
>>
>> If I have a set of numbers, or strings etc. which have been generated and
>> I then want to do something with them, for example a sum function call. Is
>> the best way to put those items in a list, or
On Wed, Jul 2, 2008 at 3:54 AM, wesley chun <[EMAIL PROTECTED]> wrote:
> in the former, you have a function object. it's just like any other
> Python object, but with one heaping distinction: it's callable --
> this means that u can slap on a pair of parentheses after the object
> and execute it
>> If I have a set of numbers, or strings etc. which have been generated and I
>> then want to do something with them, for example a sum function call. Is
>> the best way to put those items in a list, or similar container, before
>> applying the function.
>
> Not only "best" but "necessary". th
Paul Melvin wrote:
If I have a set of numbers, or strings etc. which have been generated
and I then want to do something with them, for example a sum function
call. Is the best way to put those items in a list, or similar
container, before applying the function.
Not only "best" but "necessar
Hi,
I am new to python and although have done basic many, many years ago it has
all gone, replaced by rubbish!
My question is this:
If I have a set of numbers, or strings etc. which have been generated and I
then want to do something with them, for example a sum function call. Is
the b
At 12:54 AM 7/2/2008, wesley chun wrote:
ok, someone has to be the bad guy and show an example of equivalent
code that's more difficult to read:
choice([use_for_float_demo, use_for_integer_demo])()
seriously tho, the bottom line of what people have been telling you is
that for the function (or
ok, someone has to be the bad guy and show an example of equivalent
code that's more difficult to read:
choice([use_for_float_demo, use_for_integer_demo])()
seriously tho, the bottom line of what people have been telling you is
that for the function (or method) foo():
def foo():
:
there is
30 matches
Mail list logo