On 14Aug2019 11:15, Steven D'Aprano wrote:
On Wed, Aug 14, 2019 at 09:58:35AM +1000, Cameron Simpson wrote:
On 11Aug2019 22:58, James Hartley wrote:
>I am lacking in understanding of the @staticmethod property.
>Explanation(s)/links might be helpful. I have not found the descriptions
>found i
On Wed, Aug 14, 2019 at 09:58:35AM +1000, Cameron Simpson wrote:
> On 11Aug2019 22:58, James Hartley wrote:
> >I am lacking in understanding of the @staticmethod property.
> >Explanation(s)/links might be helpful. I have not found the descriptions
> >found in the Internet wild to be particularly
On 11Aug2019 22:58, James Hartley wrote:
I am lacking in understanding of the @staticmethod property.
Explanation(s)/links might be helpful. I have not found the descriptions
found in the Internet wild to be particularly instructive.
You have received some answers; to me they seem detailed en
Part 3.
On Sun, Aug 11, 2019 at 10:58:37PM -0500, James Hartley wrote:
> from collections import namedtuple
>
> class Foo():
> Dimensions = namedtuple('Dimensions', ['height', 'width'])
> _dimensions = Dimensions(3, 4)
>
> def dimensions():
> print('id = {}'.format(id(Foo.
Part Two.
On Sun, Aug 11, 2019 at 10:58:37PM -0500, James Hartley wrote:
> from collections import namedtuple
>
> class Foo():
> Dimensions = namedtuple('Dimensions', ['height', 'width'])
> _dimensions = Dimensions(3, 4)
>
> def dimensions():
> print('id = {}'.format(id(Foo
On Sun, Aug 11, 2019 at 10:58:37PM -0500, James Hartley wrote:
> I am lacking in understanding of the @staticmethod property.
> Explanation(s)/links might be helpful. I have not found the descriptions
> found in the Internet wild to be particularly instructive. Given the code
> below:
[...]
> The
James Hartley wrote:
> I am lacking in understanding of the @staticmethod property.
> Explanation(s)/links might be helpful. I have not found the descriptions
> found in the Internet wild to be particularly instructive. Given the code
> below:
> =8<--
> from collections impor
I am lacking in understanding of the @staticmethod property.
Explanation(s)/links might be helpful. I have not found the descriptions
found in the Internet wild to be particularly instructive. Given the code
below:
=8<--
from collections import namedtuple
class Foo():
Dim
thanks!
On Sun, Jul 23, 2017 at 5:35 PM, Danny Yoo wrote:
> On Sun, Jul 23, 2017 at 1:24 PM, Michael C
> wrote:
> > class mahschool:
> > def print():
> > print('Say something')
>
>
> By the way, you've chosen a name for your method that's spelled the
> same as the name of the built-
On 07/23/2017 02:42 PM, Michael C wrote:
> never mind, I forgot to put 'self' in the method definition!
class mahschool:
def print(self):
print('Say something')
a = mahschool()
a.print()
Indeed. The error message was clear on this - but not in a way that's
always instructive until
On Sun, Jul 23, 2017 at 1:24 PM, Michael C
wrote:
> class mahschool:
> def print():
> print('Say something')
By the way, you've chosen a name for your method that's spelled the
same as the name of the built-in "print" function. I'd recommend you
choose a different name than "print"
never mind, I forgot to put 'self' in the method definition!
class mahschool:
def print(self):
print('Say something')
a = mahschool()
a.print()
On Sun, Jul 23, 2017 at 1:24 PM, Michael C
wrote:
> class mahschool:
> def print():
> print('Say something')
>
>
> a = mahs
class mahschool:
def print():
print('Say something')
a = mahschool()
a.print()
With this, I get this error:
Traceback (most recent call last):
File "test.py", line 8, in
a.print()
TypeError: print() takes 0 positional arguments but 1 was given
What did I do wrong?
Thank
On 20/06/17 23:39, Rex Florian via Tutor wrote:
> Can someone explain how Python achieves the vector addition of more than 2
> vectors
> without some kind of looping?
>
> class Vector:
>def __init__(self, a, b):
>def __str__():
>def __add__(self,other):
> return Vector(self.a +
Hello,
Below is a class I am using to comprehend how class works.
The code came from tutorialspoint.com and executes correctly but I do not
understand why it works.
The original example defined just v1 and v2. I decided to experiment and
instantiated v3.
The executed the print statement yiel
Rafael Knuth wrote:
> Hey there,
>
> I am trying to wrap my head around Class Inheritance in Python, and I
> wrote a little program which is supposed to calculate revenues from
> customers who don't get a discount (parent class) and those who get a
> 30% discount (child class):
>
> class FullPri
On 21/02/17 09:49, Rafael Knuth wrote:
> class DiscountCustomer(FullPriceCustomer):
> discount = 0.7
> def calculate_discount(self, rate, hours):
> print ("Your customer %s made you %s USD at a 30% discount
> rate this year." % (self.customer, self.rate * rate * discount))
I meant
On 21/02/17 09:49, Rafael Knuth wrote:
> class FullPriceCustomer(object):
> def __init__(self, customer, rate, hours):
>
>
> class DiscountCustomer(FullPriceCustomer):
> discount = 0.7
> def calculate_discount(self, rate, hours):
>
> customer_one = DiscountCustomer("Customer A", 75,
Hey there,
I am trying to wrap my head around Class Inheritance in Python, and I
wrote a little program which is supposed to calculate revenues from
customers who don't get a discount (parent class) and those who get a
30% discount (child class):
class FullPriceCustomer(object):
def __init__(
On 23/01/15 01:44, jarod...@libero.it wrote:
How can gave the attributes __name__ to a function?
You don't Python does it for you.
class Foo(object):
def __init__(self):
steps = {}
tmp = open("rnaseq.base.ini","rb")
config.readfp(tmp)
readsets =
pa
You are trying to use advanced features of Python, and they are not
the right tool for what you're trying to do.
Specifically, you're trying two things at the same time:
1. Properties, which allows method calls to look like simple variable access.
2. The __name__ special attribute on methods (
On Fri, Jan 23, 2015 at 12:37 AM, jarod...@libero.it wrote:
> Thanks for the help and patience!
> It is a function on the class so I suppose for read that function list I
> need self.steps Where I'm wrong?
> @property
> def steps(self):
> return [
>
>
> #@property
> def show(self):
> ftp="\n".join([str(idx + 1) + "- " + step.__name__ for idx, step
in enumerate(self.steps)])
>
Questions you should be asking yourself:
What is self.steps? What type is it?
In the case where this breaks with an error, what is self.steps t
If the code I'm seeing is correct, the problem is the class is Jobs,
and you instantiated a Job, which doesn't exit.
Replace one with the other in either case should fix it.
On Thu, Jan 22, 2015 at 11:11 AM, jarod...@libero.it wrote:
> Dear All,
>
> I created a class that invoke from another fi
Dear All
How can gave the attributes __name__ to a function?
class Foo(object):
def __init__(self):
steps = {}
tmp = open("rnaseq.base.ini","rb")
config.readfp(tmp)
readsets =
parse_illumina_readset_file("/home/mauro/Desktop/readset.csv")
@prop
On 22Jan2015 17:11, jarod...@libero.it wrote:
I created a class that invoke from another file another class
I get an error that I do not understand: gobal name Job is not defined
However If I see the class imported I found the class Job.
Any suggestion or example on class invoke another class
On Thu, Jan 22, 2015 at 8:11 AM, jarod...@libero.it wrote:
> Dear All,
>
> I created a class that invoke from another file another class
> I get an error that I do not understand: gobal name Job is not defined
Please use copy-and-paste. You just typed out the error message by
hand: we can tell
Dear All,
I created a class that invoke from another file another class
I get an error that I do not understand: gobal name Job is not defined
However If I see the class imported I found the class Job.
Any suggestion or example on class invoke another class
#job,py
class Jobs:
.
#trial
> i am trying to understand this code:
> http://nbviewer.ipython.org/gist/BenLangmead/6665861
I'm slightly familiar with the purpose of the code. It's constructing
a Suffix Tree, though not in linear time.
Reading the code... ah. I see. This is enumerating through all
suffixes, and building it
On 25/05/14 16:39, rahmad akbar wrote:
Hi guys
i am trying to understand this code:
http://nbviewer.ipython.org/gist/BenLangmead/6665861
i understand functions quite alright . but i have no idea about
classes yet.
Do you understand modules?
Modules contain functions and data that you can reus
On 2014-05-25 09:20, R. Alan Monroe wrote:
can you
guys help explain. super thanks
A class is like a blueprint.
An instance of that class is like a house built from that blueprint.
Think about it. An infinite number of houses could be constructed
using those blueprints. But the architect only
> can you
> guys help explain. super thanks
A class is like a blueprint.
An instance of that class is like a house built from that blueprint.
Think about it. An infinite number of houses could be constructed
using those blueprints. But the architect only had to draw them once.
__init__() is like
Hi guys
i am trying to understand this code:
http://nbviewer.ipython.org/gist/BenLangmead/6665861
i understand functions quite alright . but i have no idea about
classes yet. the code is written using class and i could not make much
sense out of it. all this init and self thingy drive me crazy. c
Peter, Spir - thanks for your time and effort!
I am posting this query to few more Python mailers.
Thank you,
Sangeeth
On Tue, Feb 25, 2014 at 5:22 AM, spir wrote:
> On 02/24/2014 08:19 PM, Sangeeth Saravanaraj wrote:
>
>> Sorry, I should have described what I was trying!
>>
>> I want to cre
On 02/24/2014 08:19 PM, Sangeeth Saravanaraj wrote:
Sorry, I should have described what I was trying!
I want to create a decorator which should do the following things:
- When an object of the decorated class is created, the objects name
(say the value of the incoming "id" argument) sho
Sangeeth Saravanaraj wrote:
> On Mon, Feb 24, 2014 at 10:53 PM, Peter Otten <__pete...@web.de> wrote:
>
>> Sangeeth Saravanaraj wrote:
>>
>> > I am trying to capture an object initiation and deletion events using
>> > the __call__() and __del__() methods with the following approach.
>>
>> Note th
On Mon, Feb 24, 2014 at 10:53 PM, Peter Otten <__pete...@web.de> wrote:
> Sangeeth Saravanaraj wrote:
>
> > I am trying to capture an object initiation and deletion events using the
> > __call__() and __del__() methods with the following approach.
>
> Note that there is no guarantee that __dell__
Sangeeth Saravanaraj wrote:
> I am trying to capture an object initiation and deletion events using the
> __call__() and __del__() methods with the following approach.
Note that there is no guarantee that __dell__ will ever be called. Usually
it is better to introduce a weakref with callback.
>
I am trying to capture an object initiation and deletion events using the
__call__() and __del__() methods with the following approach.
class A(object):
def __init__(self, klass):
print "A::__init__()"
self._klass = klass
def __call__(self):
print "A::__call__()"
On Sat, Dec 21, 2013 at 12:40 PM, Steven D'Aprano wrote:
> On Sat, Dec 21, 2013 at 08:41:17AM -0500, eryksun wrote:
>>
>> >>> vars(type)['__base__']
>>
>
> Oooh, nice! I always forget about vars(), and end up messing about with
> __dict__.
It's a bit more efficient to use the __dict__ at
On Sat, Dec 21, 2013 at 08:41:17AM -0500, eryksun wrote:
> On Sat, Dec 21, 2013 at 2:14 AM, Steven D'Aprano wrote:
> >
> > (Sometimes, people will call them "members", especially if they are used
> > to C#. The meaning here is member as in an arm or leg, as in
> > "dismember", not member in the se
(I fixed the subject line for you.)
On Sat, Dec 21, 2013 at 02:53:28AM -0500, Keith Winston wrote:
> On Sat, Dec 21, 2013 at 2:14 AM, wrote:
>
> > I don't like the terms "class variable" and "instance variable". In the
> > Python community, these are usually called class and instance attributes
On Sat, Dec 21, 2013 at 2:14 AM, Steven D'Aprano wrote:
>
> (Sometimes, people will call them "members", especially if they are used
> to C#. The meaning here is member as in an arm or leg, as in
> "dismember", not member in the sense of belonging to a group.)
A Python object isn't just a fixed-s
On Fri, Dec 20, 2013 at 02:04:49AM -0500, Keith Winston wrote:
> I am a little confused about class variables: I feel like I've repeatedly
> seen statements like this:
I don't like the terms "class variable" and "instance variable". In the
Python community, these are usually called class and inst
On Fri, Dec 20, 2013 at 5:20 AM, Alan Gauld wrote:
>
> Similarly if you have a name defined within the instance it will use that if
> not it will look in the class.
An instance can generally shadow class attributes, except properties
and other data descriptors defined by the class are given prece
On 20/12/13 07:04, Keith Winston wrote:
Class.pi == 3.14 # defined/set in the class def
instance.pi == 3.14 # initially
instance.pi = 4 # oops, changed it
Class.pi == 3.14 # still
Class.pi = "rhubarb" # oops, there I go again
instance.pi == 4 # still
Sorry if I'm beating this to a pulp, I
Hi,
> I am a little confused about class variables: I feel like I've repeatedly
> seen statements like this:
please take a look at the archives - this topic has been discussed on
this list recently.
-nik
--
* mirabilos is handling my post-1990 smartphone *
Aaah, it vibrates! Wherefore art tho
I am a little confused about class variables: I feel like I've repeatedly
seen statements like this:
There is only one copy of the class variable and when any one object makes a
change to a class variable, that change will be seen by all the other
instances.
Object variables are owned by each indi
Hi,
Thanks for correcting me.
The solutions mentioned by Dominik and Alan have simplified the concept to
me now.
Regards,
Reuben
On Sun, Nov 17, 2013 at 5:25 AM, Dominik George wrote:
> On Sat, Nov 16, 2013 at 09:13:13AM -0800, reutest wrote:
> > class myclass():
> >
> > def test(
On 16/11/13 17:13, reutest wrote:
class myclass():
def test(self):
print "print this line"
if __name__ == '__main__':
myclass.run()
If you have a question it helps if you ask it rather than have us guess.
In this case I'm guessin
On Sat, Nov 16, 2013 at 09:13:13AM -0800, reutest wrote:
> class myclass():
>
> def test(self):
> print "print this line"
>
>
> if __name__ == '__main__':
> myclass.run()
Is that a question?
If I were to guess, I'd say you sho
class myclass():
def test(self):
print "print this line"
if __name__ == '__main__':
myclass.run()
--
View this message in context:
http://python.6.x6.nabble.com/Class-attribute-error-tp5039199.html
Sent from the Pyth
- Original Message -
> From: Steven D'Aprano
> To: tutor@python.org
> Cc:
> Sent: Sunday, October 6, 2013 4:52 AM
> Subject: Re: [Tutor] class decorator question
>
> On Sat, Oct 05, 2013 at 12:26:14PM -0700, Albert-Jan Roskam wrote:
>
>> >
On 06/10/2013 03:58, Steven D'Aprano wrote:
On Sun, Oct 06, 2013 at 01:06:18AM +0100, Alan Gauld wrote:
On 05/10/13 20:26, Albert-Jan Roskam wrote:
General question: I am using pastebin now. Is that okay,
For code as short as this it's probably best kept with the message.
But once you get to
On Sun, Oct 06, 2013 at 01:06:18AM +0100, Alan Gauld wrote:
> On 05/10/13 20:26, Albert-Jan Roskam wrote:
>
> >General question: I am using pastebin now. Is that okay,
>
> For code as short as this it's probably best kept with the message.
> But once you get to 100+ lines its more debatable and i
On Sat, Oct 05, 2013 at 12:26:14PM -0700, Albert-Jan Roskam wrote:
> >> On http://lucumr.pocoo.org/2013/5/21/porting-to-python-3-redux/ I saw
> >> a very cool and useful example of a class decorator. It (re)implements
> >> __str__ and __unicode__ in case Python 2 is used. For Python 3, the
> >>
On 05/10/13 20:26, Albert-Jan Roskam wrote:
General question: I am using pastebin now. Is that okay,
For code as short as this it's probably best kept with the message.
But once you get to 100+ lines its more debatable and if you get
to 200+ lines I'd definitely say a pastebin is better.
fro
___
> From: Steven D'Aprano
>To: tutor@python.org
>Sent: Saturday, October 5, 2013 3:14 PM
>Subject: Re: [Tutor] class decorator question
>
>On Sat, Oct 05, 2013 at 05:33:46AM -0700, Albert-Jan Roskam wrote:
>> Hi,
>>
>> On
On Sat, Oct 05, 2013 at 05:33:46AM -0700, Albert-Jan Roskam wrote:
> Hi,
>
> On http://lucumr.pocoo.org/2013/5/21/porting-to-python-3-redux/ I saw
> a very cool and useful example of a class decorator. It (re)implements
> __str__ and __unicode__ in case Python 2 is used. For Python 3, the
> dec
Hi,
On http://lucumr.pocoo.org/2013/5/21/porting-to-python-3-redux/ I saw a very
cool and useful example of a class decorator. It (re)implements __str__ and
__unicode__ in case Python 2 is used. For Python 3, the decorator does nothing.
I wanted to generalize this decorator so the __str__ metho
On 12/9/2013 05:10, zubair alam wrote:
> class PizzaShop(): pizza_stock =
> 10 def get_pizza(self): while
> PizzaShop.pizza_stock: PizzaShop.pizza_stock -=
> 1 yield "take yours pizza order, total pizzas left
> {}".format(PizzaShop.pizza_stock)
> mypizza_sho
On 12/09/13 10:10, zubair alam wrote:
class PizzaShop():
pizza_stock = 10
def get_pizza(self):
while PizzaShop.pizza_stock:
PizzaShop.pizza_stock -= 1
yield "take yours pizza order, total pizzas left
{}".format(PizzaShop.pizza_stock)
mypizza_shop = Pi
class PizzaShop():
pizza_stock = 10
def get_pizza(self):
while PizzaShop.pizza_stock:
PizzaShop.pizza_stock -= 1
yield "take yours pizza order, total pizzas left
{}".format(PizzaShop.pizza_stock)
mypizza_shop = PizzaShop()
pizza_order = mypizza_shop.get_pizz
> i am learning how a __class__ data member behaves in python as
> compared to static data member in java [...]
The error is not related to class variables. Also could you elaborate on
what you intended to find out with this snippet?
> class PizzaShop():
> pizza_stock = 10
>
> def get_pi
On Wed, Sep 11, 2013 at 5:40 AM, zubair alam wrote:
> i am learning how a __class__ data member behaves in python as compared to
> static data member in java, but following code is throwing error
>
>
> class PizzaShop():
> pizza_stock = 10
> def get_pizza(self):
> while not PizzaSh
i am learning how a __class__ data member behaves in python as compared to
static data member in java, but following code is throwing error
class PizzaShop():
pizza_stock = 10
def get_pizza(self):
while not PizzaShop.pizza_stock:
PizzaShop.pizza_stock -= 1
Michael O'Leary wrote:
> I wrote some code to create tasks to be run in a queue based system last
> week. It consisted of a big monolithic function that consisted of two
> parts: 1) read data from a file and create dictionaries and lists to
> iterate through
> 2) iterate through the lists creating
On 18 February 2013 07:36, Michael O'Leary wrote:
> I wrote some code to create tasks to be run in a queue based system last
> week. It consisted of a big monolithic function that consisted of two parts:
> 1) read data from a file and create dictionaries and lists to iterate
> through
> 2) iterate
I wrote some code to create tasks to be run in a queue based system last
week. It consisted of a big monolithic function that consisted of two parts:
1) read data from a file and create dictionaries and lists to iterate
through
2) iterate through the lists creating a job data file and a task for th
From: Tutor
[mailto:tutor-bounces+terrence.brannon=bankofamerica@python.org] On Behalf
Of Art Scheel
Sent: Tuesday, September 11, 2012 3:34 PM
To: tutor@python.org
Subject: [Tutor] 'class' for someone with no object oriented programming
experience
Are there any better res
On 15/02/2012 18:35, Hugo Arts wrote:
[snip]
An __init__ might seem like it's special in some way, declaring
attributes. But it's not, really, it's just another method that gets
passed the object it is called on (that would be "self"). It's only
special because it gets called when an object is c
On 15/02/2012 18:14, Sivaram Neelakantan wrote:
I was under the impression that you have to define the attributes of
the class before using it in an instance. Following the book
'thinking in Python',
class Point:
... """pts in 2d space"""
...
print Point
__main__.Point
b = Point()
b.x
On Thu, Feb 16 2012,Alan Gauld wrote:
[snipped 19 lines]
> Python allows instance attributes to be added at runtime.
> In general this is a bad idea IMHO, a dictionary would probably
> be more appropriate, but there can, very occasionally, be valid
> uses for it.
Thanks for that, I kept thinkin
On Wed, Feb 15, 2012 at 7:14 PM, Sivaram Neelakantan
wrote:
>
> I was under the impression that you have to define the attributes of
> the class before using it in an instance. Following the book
> 'thinking in Python',
>
class Point:
> ... """pts in 2d space"""
> ...
print Point
>
On 15/02/12 18:14, Sivaram Neelakantan wrote:
I was under the impression that you have to define the attributes of
the class before using it in an instance.
Only in some languages. Python is not one of those.
class Point:
... """pts in 2d space"""
...
b = Point()
b.x =3
b.y =4
print b.
I was under the impression that you have to define the attributes of
the class before using it in an instance. Following the book
'thinking in Python',
>>> class Point:
... """pts in 2d space"""
...
>>> print Point
__main__.Point
>>> b = Point()
>>> b.x =3
>>> b.y =4
>>> print b.y
4
>>>
Why
On Mon, Feb 06, 2012 at 08:17:05PM -0500, Greg Nielsen wrote:
[...]
> So here is the problem, to create an object, you need to assign it to
> a variable, and you need to know what that variable is to call upon it
> later, so to have a object build a second object, it would need to somehow
> cr
On 02/06/2012 08:17 PM, Greg Nielsen wrote:
Hello List,
My name is Greg, and while working on a project I've come across a
rather interesting problem. I'm trying to create a rough model of a star
cluster and all of the stars and planets contained within. Kind of a cool
project; hopefully i
Hello List,
My name is Greg, and while working on a project I've come across a
rather interesting problem. I'm trying to create a rough model of a star
cluster and all of the stars and planets contained within. Kind of a cool
project; hopefully it should work a little like this. I create a St
On 18/01/12 02:13, Stayvoid wrote:
class A:
def __init__(self, data):
self.data = data
print self.data
I'm trying to understand this function-like syntax:
A('foo').__init__(42)
You would not normally call any method with a double underscore
pre/poist f
On 01/17/2012 09:13 PM, Stayvoid wrote:
Hello!
Here is another one.
class A:
def __init__(self, data):
self.data = data
print self.data
I'm trying to understand this function-like syntax:
A('foo').__init__(42)
A(12).data
What are we actually calling thi
Hello!
Here is another one.
class A:
def __init__(self, data):
self.data = data
print self.data
I'm trying to understand this function-like syntax:
A('foo').__init__(42)
A(12).data
What are we actually calling this way?
Are there any other ways to get the
Thanks.
I totally get it now.
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
On Sun, Jan 1, 2012 at 8:40 PM, Stayvoid wrote:
> Hi there!
>
class Sample:
def method(self): pass
>
Sample().method()
>
> What's the difference between class __main__.Sample and
> __main__.Sample instance?
> Why should I write "Sample().method" instead of "Sample.method"?
>
Th
Hi there!
>>> class Sample:
>>> def method(self): pass
>>> Sample().method()
What's the difference between class __main__.Sample and
__main__.Sample instance?
Why should I write "Sample().method" instead of "Sample.method"?
Cheers!
___
Tutor mail
"David Merrick" wrote
Is it possible too have
crit1 = Critter("Dave")
crit2 = Critter("Sweetie")
farm = [crit1,crit2] #List#
and then be able to use Critters methods on farm?
No, Marc has already answered that.
class Critter(object):
"""A virtual pet"""
def __init__(self, name, hu
On Sun, Jun 26, 2011 at 7:12 PM, David Merrick wrote:
> Is it possible too have
>
> crit1 = Critter("Dave")
> crit2 = Critter("Sweetie")
> farm = [crit1,crit2] #List#
>
> and then be able to use Critters methods on farm?
>
> No. farm is a list, and lists don't inherit the methods of the objects
Is it possible too have
crit1 = Critter("Dave")
crit2 = Critter("Sweetie")
farm = [crit1,crit2] #List#
and then be able to use Critters methods on farm?
# Critter Caretaker
# A virtual pet to care for
class Critter(object):
"""A virtual pet"""
def __init__(self, name, hunger = 0, bore
"David Merrick" wrote
Can someone show me how to code this correctly please?
We've been doing that but you are still making
some very basic mistakes which reflect a deep
misunderastanding of what you are doing. You
really should take several steps back and review
the use of variables and fun
"michael scott" wrote
you are using python 3 by your print statements, so I
don't think you need the int() around your input,
Yes he does because in Python 3 input is the same as raw_input
in Python 2
even in python.2x input() was safe for numbers I believe
(the whole list will rip my
yer know which one he is feeding / talking to / playing with in your
farmlet?
Anyways best of luck in your program, sounds pretty cool...
What is it about you... that intrigues me so?
From: Alexandre Conrad
To: David Merrick
Cc: tutor@python.org
Sen
David,
2011/6/22 David Merrick :
> # listen to your critter
> elif choice == "1":
> for critter in farmlet:
> farmlet.talk()
You want to call .talk() on your "critter" instance which has the
.talk() method, not on farmlet (which is a list as the error m
Can someone show me how to code this correctly please?
# Critter Caretaker
# A virtual pet to care for
class Critter(object):
"""A virtual pet"""
def __init__(self, name, hunger = 0, boredom = 0):
self.name = name
self.hunger = hunger
self.boredom = boredom
#
"David Merrick" wrote
class Critter(object):
def __init__(self, name, hunger = 0, boredom = 0):
def __pass_time(self):
def __str__(self):
@property
def mood(self):
def talk(self):
def eat(self):
def play(self):
class Farm(Critter):
I still don't think a Farm is a typ
# Critter Caretaker
# A virtual pet to care for
class Critter(object):
"""A virtual pet"""
def __init__(self, name, hunger = 0, boredom = 0):
self.name = name
self.hunger = hunger
self.boredom = boredom
# __ denotes private method
def __pass_time(self):
> >>I'm not sure I follow that bit.
>
> Say you have a master part, # 3245671, this is sort of a "primary machined
>number".
>
> On the blueprint for this part, there will be certain features that don't
> have
>any dimensional
>
> information, but instead have a callout of some kind, i
Elwin Estle wrote:
--- On Wed, 1/26/11, Alan Gauld wrote:
From: Alan Gauld
Subject: Re: [Tutor] class question
To: tutor@python.org
Date: Wednesday, January 26, 2011, 1:10 PM
Is this really a series of different types of casting or a single Workpiece
going through a sequence of Actions
each
* Emile van Sebille [110126 12:30]:
> On 1/26/2011 11:03 AM Tim Johnson said...
>>
>> I've developed a module which necessitates a very large amount of
>> documentation. At this point all of the documentation is in the
>> class docstring. I'm thinking that perhaps I should pare down the
>> docstri
On 1/26/2011 11:03 AM Tim Johnson said...
FYI: I'm currently using version 2.6.5
I've developed a module which necessitates a very large amount of
documentation. At this point all of the documentation is in the
class docstring. I'm thinking that perhaps I should pare down the
docstring and deliv
--- On Wed, 1/26/11, Alan Gauld wrote:
From: Alan Gauld
Subject: Re: [Tutor] class question
To: tutor@python.org
Date: Wednesday, January 26, 2011, 1:10 PM
>>Is this really a series of different types of casting or a single Workpiece
>>going through a sequence of Actions
>>
1 - 100 of 405 matches
Mail list logo