Re: Class and tkinter problem

2021-01-07 Thread Paulo da Silva
Às 20:35 de 07/01/21, Terry Reedy escreveu: > On 1/7/2021 4:20 AM, Terry Reedy wrote: >> On 1/7/2021 2:42 AM, Christian Gollwitzer wrote: >>> Am 07.01.21 um 08:29 schrieb Paulo da Silva: >>> Does anybody know why cmd method isn't called when I change the button state (clicking on it) in t

Re: Class and tkinter problem

2021-01-07 Thread Terry Reedy
On 1/7/2021 4:20 AM, Terry Reedy wrote: On 1/7/2021 2:42 AM, Christian Gollwitzer wrote: Am 07.01.21 um 08:29 schrieb Paulo da Silva: Does anybody know why cmd method isn't called when I change the button state (clicking on it) in this example? I know that this seems a weird class use. But why

Re: Class and tkinter problem

2021-01-07 Thread Paulo da Silva
Às 07:29 de 07/01/21, Paulo da Silva escreveu: > Hi! > > Does anybody know why cmd method isn't called when I change the button > state (clicking on it) in this example? > I know that this seems a weird class use. But why doesn't it work? > Thanks. > > class C: > from tkinter import Checkbutt

Re: Class and tkinter problem

2021-01-07 Thread Paulo da Silva
Às 16:02 de 07/01/21, Peter Otten escreveu: > On 07/01/2021 08:42, Christian Gollwitzer wrote: >> Am 07.01.21 um 08:29 schrieb Paulo da Silva: >> ... > > I recommend that the OP use a more conventional stye and do the setup > outside the class or, better, in an instance of the class. > There are

Re: Class and tkinter problem

2021-01-07 Thread Paulo da Silva
Às 09:20 de 07/01/21, Terry Reedy escreveu: > On 1/7/2021 2:42 AM, Christian Gollwitzer wrote: >> Am 07.01.21 um 08:29 schrieb Paulo da Silva: >> >>> Does anybody know why cmd method isn't called when I change the button >>> state (clicking on it) in this example? >>> I know that this seems a weird

Re: Class and tkinter problem

2021-01-07 Thread Paulo da Silva
Às 07:42 de 07/01/21, Christian Gollwitzer escreveu: > Am 07.01.21 um 08:29 schrieb Paulo da Silva: > >> Does anybody know why cmd method isn't called when I change the button >> state (clicking on it) in this example? >> I know that this seems a weird class use. But why doesn't it work? >> Thanks

Re: Class and tkinter problem

2021-01-07 Thread Peter Otten
On 07/01/2021 08:42, Christian Gollwitzer wrote: Am 07.01.21 um 08:29 schrieb Paulo da Silva: Does anybody know why cmd method isn't called when I change the button state (clicking on it) in this example? I know that this seems a weird class use. But why doesn't it work? Thanks. class C:

Re: Class and tkinter problem

2021-01-07 Thread Terry Reedy
On 1/7/2021 2:42 AM, Christian Gollwitzer wrote: Am 07.01.21 um 08:29 schrieb Paulo da Silva: Does anybody know why cmd method isn't called when I change the button state (clicking on it) in this example? I know that this seems a weird class use. But why doesn't it work? Thanks. class C:

Re: Class and tkinter problem

2021-01-06 Thread Christian Gollwitzer
Am 07.01.21 um 08:29 schrieb Paulo da Silva: Does anybody know why cmd method isn't called when I change the button state (clicking on it) in this example? I know that this seems a weird class use. But why doesn't it work? Thanks. class C: from tkinter import Checkbutton import tkinte

Re: Class Definitions

2020-11-14 Thread Terry Reedy
On 11/14/2020 4:09 AM, Manfred Lotz wrote: On 11 Nov 2020 19:21:57 GMT r...@zedat.fu-berlin.de (Stefan Ram) wrote: In my Python course I gave the assignment to define a counter class "Main" so that counter0 = Main() counter1 = Main() counter1.count(); counter1.count(); counter1.count() c

Re: Class Definitions

2020-11-14 Thread Manfred Lotz
On Sat, 14 Nov 2020 05:08:07 -0600 2qdxy4rzwzuui...@potatochowder.com wrote: > On 2020-11-14 at 10:09:32 +0100, > Manfred Lotz wrote: > > > On 11 Nov 2020 19:21:57 GMT > > r...@zedat.fu-berlin.de (Stefan Ram) wrote: > > > > > In my Python course I gave the assignment to define a > > > cou

Re: Class Definitions

2020-11-14 Thread 2QdxY4RzWzUUiLuE
On 2020-11-14 at 10:09:32 +0100, Manfred Lotz wrote: > On 11 Nov 2020 19:21:57 GMT > r...@zedat.fu-berlin.de (Stefan Ram) wrote: > > > In my Python course I gave the assignment to define a > > counter class "Main" so that > > > > counter0 = Main() > > counter1 = Main() > > counter1.count();

Re: Class Definitions

2020-11-14 Thread Manfred Lotz
On 11 Nov 2020 19:21:57 GMT r...@zedat.fu-berlin.de (Stefan Ram) wrote: > In my Python course I gave the assignment to define a > counter class "Main" so that > > counter0 = Main() > counter1 = Main() > counter1.count(); counter1.count(); counter1.count() > counter1.count(); counter1.count()

Re: Class Definitions

2020-11-12 Thread dn via Python-list
On 13/11/2020 08:47, Alan Bawden wrote: r...@zedat.fu-berlin.de (Stefan Ram) writes: I expected this solution: class Main: def __init__( self ): self.value = 0 def count( self ): self.value += 1 but a student turned in the following so

Re: Class Definitions

2020-11-12 Thread Alan Bawden
r...@zedat.fu-berlin.de (Stefan Ram) writes: I expected this solution: class Main: def __init__( self ): self.value = 0 def count( self ): self.value += 1 but a student turned in the following solution: class Main: value = 0 def

Re: class definition question

2019-08-10 Thread Cameron Simpson
On 07Aug2019 16:36, Terry Reedy wrote: On 8/7/2019 3:26 PM, Manfred Lotz wrote: On Wed, 07 Aug 2019 14:39:00 -0400 Dennis Lee Bieber wrote: On Wed, 7 Aug 2019 20:11:15 +0200, Manfred Lotz declaimed the following: More often I see something like this: class Myclass: ... but sometimes I see

Re: class definition question

2019-08-07 Thread Terry Reedy
On 8/7/2019 3:26 PM, Manfred Lotz wrote: On Wed, 07 Aug 2019 14:39:00 -0400 Dennis Lee Bieber wrote: On Wed, 7 Aug 2019 20:11:15 +0200, Manfred Lotz declaimed the following: Hi there, More often I see something like this: class Myclass: ... but sometimes I see class Myclass(object): ...

Re: class definition question

2019-08-07 Thread Manfred Lotz
On Wed, 07 Aug 2019 14:39:00 -0400 Dennis Lee Bieber wrote: > On Wed, 7 Aug 2019 20:11:15 +0200, Manfred Lotz > declaimed the following: > > >Hi there, > >More often I see something like this: > > > >class Myclass: > >... > > > > > >but sometimes I see > > > >class Myclass(object): > >... > > >

RE: Class initialization with multiple inheritance

2019-07-20 Thread Joseph L. Casale
-Original Message- From: Barry Scott Sent: Tuesday, July 16, 2019 11:53 AM To: Joseph L. Casale Cc: python-list@python.org Subject: Re: Class initialization with multiple inheritance > And here is the MRO for LeftAndRight. > > >>> import m > LeftAndRight.__ini

Re: Class initialization with multiple inheritance

2019-07-16 Thread Barry Scott
> On 16 Jul 2019, at 01:13, Joseph L. Casale wrote: > > I am trying to find explicit documentation on the initialization logic for a > Base class when multiple exist. For the example in the documentation at > https://docs.python.org/3/tutorial/classes.html#multiple-inheritance, > if Base1 and

Re: Class initialization with multiple inheritance

2019-07-15 Thread DL Neil
On 16/07/19 12:13 PM, Joseph L. Casale wrote: I am trying to find explicit documentation on the initialization logic for a Base class when multiple exist. For the example in the documentation at https://docs.python.org/3/tutorial/classes.html#multiple-inheritance, if Base1 and Base2 both themselv

Re: Class Issue`

2019-03-06 Thread Grant Edwards
On 2019-03-06, Marko Rauhamaa wrote: > Rhodri James : >> On 06/03/2019 14:15, Calvin Spealman wrote: C++ (a language I have no respect for) >>> This was uncalled for and inappropriate. Please keep discord civil. >> >> That was the civil version :-) > > C++ is a programming language without fe

Re: Class Issue`

2019-03-06 Thread Marko Rauhamaa
Rhodri James : > On 06/03/2019 14:15, Calvin Spealman wrote: >>> C++ (a language I have no respect for) >> This was uncalled for and inappropriate. Please keep discord civil. > > That was the civil version :-) C++ is a programming language without feelings. It's nobody's ethnicity, sexual orienta

Re: Class Issue`

2019-03-06 Thread Rhodri James
On 06/03/2019 14:44, Chris Angelico wrote: Ouch, did C++ burn you in the past? I've tried and failed to learn the language three times. It's been suggested that my mistake was using Stroustrop's book :-) There just seem to be so much boilerplate and fiddly bits that it quickly gets too com

Re: Class Issue`

2019-03-06 Thread Chris Angelico
On Thu, Mar 7, 2019 at 1:34 AM Rhodri James wrote: > > On 06/03/2019 14:15, Calvin Spealman wrote: > >> C++ (a language I have no respect for) > > This was uncalled for and inappropriate. Please keep discord civil. > > That was the civil version :-) > Ouch, did C++ burn you in the past? IMO it's

Re: Class Issue`

2019-03-06 Thread Rhodri James
On 06/03/2019 14:15, Calvin Spealman wrote: C++ (a language I have no respect for) This was uncalled for and inappropriate. Please keep discord civil. That was the civil version :-) -- Rhodri James *-* Kynesim Ltd -- https://mail.python.org/mailman/listinfo/python-list

Re: Class Issue`

2019-03-06 Thread Calvin Spealman
> C++ (a language I have no respect for) This was uncalled for and inappropriate. Please keep discord civil. On Wed, Mar 6, 2019 at 7:12 AM Rhodri James wrote: > On 05/03/2019 22:39, Milt wrote: > > The following code gives me unusual results - base on experience with > C++. > > > > class Car:

Re: Class Issue`

2019-03-06 Thread Rhodri James
On 05/03/2019 22:39, Milt wrote: The following code gives me unusual results - base on experience with C++. class Car:    # carColor = None    # mileage = None    def __init__(self, color = None, miles = None):   self.mileage = miles   self.carColor = color    def print(self):  

Re: Class Issue`

2019-03-05 Thread Terry Reedy
On 3/5/2019 6:11 PM, Kevin Hu wrote: Python is a language with very weak typing, Python runtime objects are strongly dynamically typed. Their type/class is one of their attributes. All classes are subclasses of class 'object'. Python names (variables) are untyped in a sense, or one could

Re: Class Issue`

2019-03-05 Thread eryk sun
On 3/5/19, Kevin Hu wrote: > > Python is a language with very weak typing, and it’ll happily shoehorn data > into variables even when you don’t expect it to. Python has strong typing, in that it doesn't implicitly coerce unrelated types in expressions. However, it has no enforced static typing of

Re: Class Issue`

2019-03-05 Thread DL Neil
Milt, On 6/03/19 11:39 AM, Milt wrote: The following code gives me unusual results - base on experience with C++. class Car:    # carColor = None    # mileage = None    def __init__(self, color = None, miles = None):   self.mileage = miles   self.carColor = color    def print(self)

Re: Class Issue`

2019-03-05 Thread Kevin Hu
I believe for the correct behavior you’ll need: myCar = Car(color=‘blue’, miles=15000) myCar = Car(miles=25000, color=‘orange’) In which case both objects will be initialized as the way you’d expect. Python is a language with very weak typing, and it’ll happily shoehorn data into variables ev

Re: Class Issue`

2019-03-05 Thread Chris Angelico
On Wed, Mar 6, 2019 at 10:01 AM Milt wrote: > > The following code gives me unusual results - base on experience with C++. > def __init__(self, color = None, miles = None): >self.mileage = miles >self.carColor = color > > myCar = Car('blue', 15000) > myCar = Car(25000, 'orange'

Re: class inheritance when not defined

2017-09-08 Thread Ben Finney
Steve D'Aprano writes: > Good way: > > Foreigner speaking English as their second language: > "Who is the father of this class?" > > Native English speaker: > "The father is 'object', but in English we would normally ask > 'what is the parent?' instead." Of the three scenario

Re: class inheritance when not defined

2017-09-08 Thread Steve D'Aprano
On Fri, 8 Sep 2017 07:03 pm, Ben Finney wrote: >> Who is the father of ExampleClass1 ? > > No-one, since classes do not have gender. (The convention is to use the > gender-neutral “parent” to refer to that relationship.) Possibly not the case in Russia. Besides, words have gender in many langua

Re: class inheritance when not defined

2017-09-08 Thread Ben Finney
Andrej Viktorovich writes: > I found several class creation samples: > > class ExampleClass1: > > class ExampleClass2(object): > > > What is difference between them? Very little difference. In Python 3, both create classes that inherit from one other class, ‘object’. In Python 2, the first cre

Re: class inheritance when not defined

2017-09-08 Thread Thomas Jollans
On 2017-09-08 10:17, Andrej Viktorovich wrote: > Hello > > I found several class creation samples: > > class ExampleClass1: > > class ExampleClass2(object): > > > What is difference between them? Who is the father of ExampleClass1 ? > In Python 3, unless you've redefined "object", these are

Re: Class - error return

2016-09-06 Thread Smith
From: Smith On 06/09/2016 11:23, Peter Otten wrote: > If so look at > >> > ...: def __str__(self): >> > ...: return "Visitor: %i, Contacts: %i % >> > (self.visits,self.contacts)" > once more. Where are the quotes? Where should the be? > > > I solved the problem. thank you Pe

Re: Class - error return

2016-09-06 Thread nospam . Smith
On 06/09/2016 11:23, Peter Otten wrote: > If so look at > >> > ...: def __str__(self): >> > ...: return "Visitor: %i, Contacts: %i % >> > (self.visits,self.contacts)" > once more. Where are the quotes? Where should the be? > > > I solved the problem. thank you Peter -- https

Re: Class - error return

2016-09-06 Thread Smith
On 06/09/2016 11:23, Peter Otten wrote: If so look at > ...: def __str__(self): > ...: return "Visitor: %i, Contacts: %i % > (self.visits,self.contacts)" once more. Where are the quotes? Where should the be? I solved the problem. thank you Peter -- https://mail.python

Re: Class - error return

2016-09-06 Thread Peter Otten
Smith wrote: > you can help me ? Yes ;) But you might consider posting on python-tutor instead of python- list. > I can not understand where is the error in this script. It's always a good idea to state both what you expect and what you get instead explicitly, in plain english. > In [72]: day

Re: class attribute

2016-01-28 Thread Joel Goldstick
On Thu, Jan 28, 2016 at 9:56 AM, Chris Angelico wrote: > On Fri, Jan 29, 2016 at 12:56 AM, jmp wrote: > > My guess is that models.Model has a metclass. Without going too much int > > details, the metaclass may change the class structure when it's created. > > > > django is very specific and very

Re: class attribute

2016-01-28 Thread Todd Dembrey
On 28/01/16 13:15, ast wrote: hello Here is a class from django framework from django.db import models class Article(models.Model): titre = models.CharField(max_length=100) auteur = models.CharField(max_length=42) contenu = models.TextField(null=True) date = models.DateTimeField(

Re: class attribute

2016-01-28 Thread Chris Angelico
On Fri, Jan 29, 2016 at 12:56 AM, jmp wrote: > My guess is that models.Model has a metclass. Without going too much int > details, the metaclass may change the class structure when it's created. > > django is very specific and very database oriented. > > " > article = Article(titre="Bonjour", aute

Re: class attribute

2016-01-28 Thread ast
"ast" a écrit dans le message de news:56aa1474$0$27833$426a7...@news.free.fr... OK, thank you for answer I didn't studied metaclass yet that's why it is not clear for me. I have to take a look at that concept first -- https://mail.python.org/mailman/listinfo/python-list

Re: class attribute

2016-01-28 Thread jmp
On 01/28/2016 02:15 PM, ast wrote: hello Here is a class from django framework from django.db import models class Article(models.Model): titre = models.CharField(max_length=100) auteur = models.CharField(max_length=42) contenu = models.TextField(null=True) date = models.DateT

Re: Question re class variable

2015-09-29 Thread John Gordon
In alister writes: > why not simply use pythons builtin id function? > each new instance of an object is automatically assigned a unique ID It's only guaranteed to be unique for objects that exist at the same time. If an object is created and destroyed and then another new object is created,

Re: Question re class variable

2015-09-29 Thread Steven D'Aprano
On Tue, 29 Sep 2015 09:17 pm, Anssi Saari wrote: [...] >> The problem is that in python you can't change a class variable through >> an instance. The moment you try, you create an instance attribute. > > That much is clear but why does his other version of __gen_id() work > (after a fashion)? It

Re: Question re class variable

2015-09-29 Thread Antoon Pardon
Op 29-09-15 om 13:17 schreef Anssi Saari: > Antoon Pardon writes: > >> Op 29-09-15 om 11:27 schreef ple...@gmail.com: >>> I have a perplexing problem with Python 3 class variables. I wish to >>> generate an unique ID each time an instance of GameClass is >>> created. There are two versions of the

Re: Question re class variable

2015-09-29 Thread Anssi Saari
Antoon Pardon writes: > Op 29-09-15 om 11:27 schreef ple...@gmail.com: >> I have a perplexing problem with Python 3 class variables. I wish to >> generate an unique ID each time an instance of GameClass is >> created. There are two versions of the __gen_id method with test run >> results for each

Re: Question re class variable

2015-09-29 Thread jmp
On 09/29/2015 01:02 PM, jmp wrote: class GameObject: @property def id(self): return id(self) #use the builtin id function print GameObject().id Cheers, JM I should add that until you don't serialize your object you're fine. If you need to serialize it, you may want to look at h

Re: Question re class variable

2015-09-29 Thread jmp
On 09/29/2015 11:27 AM, ple...@gmail.com wrote: I have a perplexing problem with Python 3 class variables. Your problem is that when assigning values to your class attribute, you are actually creating a instance attribute. class Foo: bar = "I'm a class attribute" def __init__(self):

Re: Question re class variable

2015-09-29 Thread Antoon Pardon
Op 29-09-15 om 11:27 schreef ple...@gmail.com: > I have a perplexing problem with Python 3 class variables. I wish to generate > an unique ID each time an instance of GameClass is created. There are two > versions of the __gen_id method with test run results for each listed below > the code. Th

Re: Question re class variable

2015-09-29 Thread alister
On Tue, 29 Sep 2015 02:27:23 -0700, plewto wrote: > I have a perplexing problem with Python 3 class variables. I wish to > generate an unique ID each time an instance of GameClass is created. > There are two versions of the __gen_id method with test run results for > each listed below the code. >

Question re class variable

2015-09-29 Thread plewto
I have a perplexing problem with Python 3 class variables. I wish to generate an unique ID each time an instance of GameClass is created. There are two versions of the __gen_id method with test run results for each listed below the code. Originally I used the version which is now commented out

Re: class-based class decorator

2015-01-15 Thread Albert-Jan Roskam
- Original Message - > From: Jean-Michel Pichavant > To: Albert-Jan Roskam > Cc: Python > Sent: Tuesday, January 13, 2015 5:37 PM > Subject: Re: class-based class decorator > > - Original Message - >> From: "Albert-Jan Roskam" >&

Re: class-based class decorator

2015-01-13 Thread Jean-Michel Pichavant
- Original Message - > From: "Albert-Jan Roskam" > > From: Jean-Michel Pichavant > > I don't really understand how you successfuly manage positional > > parameters, > > since the caller may not name them. > > I'm asking because if your intend to check only the keyword > > parameters, > >

Re: class-based class decorator

2015-01-13 Thread Albert-Jan Roskam
On Tue, Jan 13, 2015 6:31 AM CET Ian Kelly wrote: >On Jan 12, 2015 6:47 AM, "Albert-Jan Roskam" wrote: >> Thanks for your replies. I changed it into a regular decorator (not a class >> decorator). It would have been even nicer if I only needed to specify it >> once

Re: class-based class decorator

2015-01-13 Thread Albert-Jan Roskam
- Original Message - > From: Jean-Michel Pichavant > To: Albert-Jan Roskam > Cc: Python > Sent: Monday, January 12, 2015 4:20 PM > Subject: Re: class-based class decorator > > - Original Message - >> From: "Albert-Jan Roskam" >

Re: class-based class decorator

2015-01-12 Thread Ian Kelly
On Jan 12, 2015 6:47 AM, "Albert-Jan Roskam" wrote: > Thanks for your replies. I changed it into a regular decorator (not a class > decorator). It would have been even nicer if I only needed to specify it once > per class, but, well, in my case this hardly matters. The code below works as > int

Re: class-based class decorator

2015-01-12 Thread Jean-Michel Pichavant
- Original Message - > From: "Albert-Jan Roskam" > import functools > import inspect > import warnings > > warnings.simplefilter("always") > > class check_deprecated_args(object): > > def __init__(self, deprecated_params, msg=None): > self.deprecated_params = deprecated_para

Re: class-based class decorator

2015-01-12 Thread Albert-Jan Roskam
- Original Message - > From: Ian Kelly > To: Python > Cc: > Sent: Saturday, January 10, 2015 7:30 AM > Subject: Re: class-based class decorator > > On Fri, Jan 9, 2015 at 2:26 PM, Albert-Jan Roskam > > wrote: >> >> >> Hi, >&g

Re: class-based class decorator

2015-01-09 Thread Ian Kelly
On Fri, Jan 9, 2015 at 2:26 PM, Albert-Jan Roskam wrote: > > > Hi, > > I am trying to write a class decorator that checks whether deprecated > parameters with non-default > > arguments are used. More complete code is here: http://pastebin.com/ZqnMis6M. > In the code below, > > how should I modif

Re: class-based class decorator

2015-01-09 Thread Chris Angelico
On Sat, Jan 10, 2015 at 8:26 AM, Albert-Jan Roskam wrote: > I am trying to write a class decorator that checks whether deprecated > parameters with non-default > > arguments are used. More complete code is here: http://pastebin.com/ZqnMis6M. > In the code below, > Any particular reason to make

Re: Class Inheritance from different module

2014-09-22 Thread Jean-Michel Pichavant
- Original Message - > From: "Jean-Michel Pichavant" > To: "Juan Christian" > Cc: "Python" > Sent: Monday, 22 September, 2014 1:37:41 PM > Subject: Re: Class Inheritance from different module > > > > cl

Re: Class Inheritance from different module

2014-09-22 Thread Jean-Michel Pichavant
> class User(Inheritance from API): > def __init__(self, ID): > steamapi.core.APIConnection(api_key = KEY) > super( " Inheritance SteamUser" (ID)) # creates the user using the > API > > > [...] > > > So that in my code when I need to create a new user, I just call 'usr > = User("XXX")' ins

Re: Class Inheritance from different module

2014-09-20 Thread Peter Otten
Juan Christian wrote: > I have the following structure: > > Third-party API installed via pip: > steamapi / > app.py > consts.py > core.py > users.py > [...] > > My script: > test.py > > > In the API, the module users.py has a class 'SteamUser' and I want to > mimic it's usage on my code, like

Re: Class Inheritance from different module

2014-09-20 Thread Steven D'Aprano
Juan Christian wrote: [...] > In the API, the module users.py has a class 'SteamUser' and I want to > mimic it's usage on my code, like this: > > import steamapi > > [...] > > class User(Inheritance from API): What do you mean, "Inheritance from API"? You can't inherit from an API, only from c

Re: Class and instance related questions.

2014-01-24 Thread Terry Reedy
On 1/24/2014 3:45 PM, Chris Angelico wrote: On Sat, Jan 25, 2014 at 7:32 AM, Asaf Las wrote: On Friday, January 24, 2014 6:37:29 PM UTC+2, Chris Angelico wrote: On Sat, Jan 25, 2014 at 3:31 AM, Asaf Las wrote: Hi Is there way to get list of instances of particular class through class itself?

Re: Class and instance related questions.

2014-01-24 Thread Dave Angel
Asaf Las Wrote in message: > On Friday, January 24, 2014 10:45:30 PM UTC+2, Chris Angelico wrote: >> On Sat, Jan 25, 2014 at 7:32 AM, Asaf Las wrote: >> > On Friday, January 24, 2014 6:37:29 PM UTC+2, Chris Angelico wrote: >> >> >> It's possible to unbind the name, but every instance retains a

Re: Class and instance related questions.

2014-01-24 Thread Asaf Las
On Friday, January 24, 2014 11:18:08 PM UTC+2, Chris Angelico wrote: > On Sat, Jan 25, 2014 at 8:03 AM, Asaf Las wrote: > > Chris, i like answers which open doors to my curiosity :-) > > yet i should spend my credits very carefully :-) > Trust me, there is no limit to what you can learn when you h

Re: Class and instance related questions.

2014-01-24 Thread Chris Angelico
On Sat, Jan 25, 2014 at 8:03 AM, Asaf Las wrote: > Chris, i like answers which open doors to my curiosity :-) > yet i should spend my credits very carefully :-) Trust me, there is no limit to what you can learn when you have that kind of curiosity! Ask more questions and you'll get more details.

Re: Class and instance related questions.

2014-01-24 Thread Asaf Las
On Friday, January 24, 2014 10:45:30 PM UTC+2, Chris Angelico wrote: > On Sat, Jan 25, 2014 at 7:32 AM, Asaf Las wrote: > > On Friday, January 24, 2014 6:37:29 PM UTC+2, Chris Angelico wrote: > >> On Sat, Jan 25, 2014 at 3:31 AM, Asaf Las wrote: > >> > Hi > >> > Is there way to get list of instan

Re: Class and instance related questions.

2014-01-24 Thread Chris Angelico
On Sat, Jan 25, 2014 at 7:32 AM, Asaf Las wrote: > On Friday, January 24, 2014 6:37:29 PM UTC+2, Chris Angelico wrote: >> On Sat, Jan 25, 2014 at 3:31 AM, Asaf Las wrote: >> > Hi >> > Is there way to get list of instances of particular >> > class through class itself? via metaclass or any other m

Re: Class and instance related questions.

2014-01-24 Thread Asaf Las
Hi Chris Thanks for answers On Friday, January 24, 2014 6:37:29 PM UTC+2, Chris Angelico wrote: > On Sat, Jan 25, 2014 at 3:31 AM, Asaf Las wrote: > > Hi > > Is there way to get list of instances of particular > > class through class itself? via metaclass or any other method? > Not automatical

Re: Class and instance related questions.

2014-01-24 Thread Chris Angelico
On Sat, Jan 25, 2014 at 3:31 AM, Asaf Las wrote: > Hi > > Is there way to get list of instances of particular > class through class itself? via metaclass or any other method? Not automatically, but you can make a class that keeps track of its instances with a weak reference system. > Another que

Re: class inheritance python2.7 vs python3.3

2014-01-06 Thread jwe . van . dijk
On Monday, 6 January 2014 18:14:08 UTC+1, jwe.va...@gmail.com wrote: > I have problems with these two classes: > > > > class LPU1(): > > def __init__(self, formula): > > """ > > formula is a string that is parsed into a SymPy function > > and several derived func

Re: class inheritance python2.7 vs python3.3

2014-01-06 Thread Steven D'Aprano
jwe.van.d...@gmail.com wrote: > I have problems with these two classes: > > class LPU1(): > def __init__(self, formula): > """ > formula is a string that is parsed into a SymPy function > and several derived functions > """ > self.formula = formula >

Re: class inheritance python2.7 vs python3.3

2014-01-06 Thread Dave Angel
On Mon, 6 Jan 2014 09:14:08 -0800 (PST), jwe.van.d...@gmail.com wrote: I have problems with these two classes: class LPU1() : You forgot to derive from object. That's implied on 3.x, but you say you're also running on 2.7 Without naming your base class you're asking for an old style clas

Re: class inheritance python2.7 vs python3.3

2014-01-06 Thread Chris Angelico
On Tue, Jan 7, 2014 at 4:14 AM, wrote: > class LPU3(LPU1): > def __new__(self): > """ > the same functions as LPU1 but some added functions > and some functions redefined > """ You probably don't want to be using __new__ here. Try using __init__ instead, o

Re: Class construction

2013-10-22 Thread Neil Cerutti
On 2013-10-21, Marcin Szamotulski wrote: > So the process (with some simplifications) goes like this: > > 1. get metaclass: meta > 2. call meta.__prepare__ to get namespace (class __dict__) > 3. evaluate the class body in the namespace > 4. call meta with arguemnts: name, bases, na

Re: Class construction

2013-10-21 Thread Marcin Szamotulski
You can inspect the process in this way: >>> c = 'class A: pass' >>> code = compile(c, '', 'exec') >>> from dis import dis >>> dis(code) 1 0 LOAD_BUILD_CLASS 1 LOAD_CONST 0 (", line 1>) 4 LOAD_CONST 1 ('A') 7 MAKE_FUN

Re: class implementation

2013-10-10 Thread Ben Finney
Piet van Oostrum writes: > from import * is considered bad practice anyway. It is better just to import > the things you need. > > from pykkar import World, Pykkar, _WorldProper Or, even better, be explicit: import pykkar … foo = pykkar.World() -- \ “Computer perspect

Re: class implementation

2013-10-10 Thread Piet van Oostrum
markot...@gmail.com writes: > > OK so I did a took time of and read the pykkar code through. abd I found that > there is a third class i have to implement. [...] > So I have come up with this code > from pykkar import * > > create_world(""" > > # # > # v# > # # > #

Re: class implementation

2013-10-10 Thread Cameron Simpson
On 10Oct2013 11:34, markot...@gmail.com wrote: > OK so I did a took time of and read the pykkar code through. abd > I found that there is a third class i have to implement. > This Is the pykkar sourcecode [... lots and lots of docstring and code ...] [... and finally a little more messgae ...] > I

Re: class implementation

2013-10-10 Thread markotaht
kolmapäev, 9. oktoober 2013 2:55.28 UTC+3 kirjutas Cameron Simpson: > On 08Oct2013 01:20, wrote: > > > I cant just subclassing doesent work. It seem the init method of the source > > class also calls out another class. And the problem is, i can subclass the > > other class to with the required

Re: class-private names and the Zen of Python

2013-10-09 Thread Charles Hixson
On 10/08/2013 06:24 AM, Steven D'Aprano wrote: On Tue, 08 Oct 2013 12:13:48 +0200, Marco Buttu wrote: In the following case: >>> class Foo: ... _Foo__a = 100 ... __a = 33 ... >>> Foo._Foo__a 33 I think this behavior, for a user who does not know the convention, could be a surprise

Re: class-private names and the Zen of Python

2013-10-08 Thread Marco Buttu
On 10/09/2013 01:00 AM, Oscar Benjamin wrote: > On Tue, 08 Oct 2013 12:13:48 +0200, Marco Buttu wrote: > > > Another question is: where is the place in which this transformation > > occurs? Is it at the parser level, before the dictionary attribute is > > gave as argument to the metaclass?

Re: class implementation

2013-10-08 Thread Cameron Simpson
On 08Oct2013 01:20, markot...@gmail.com wrote: > I cant just subclassing doesent work. It seem the init method of the source > class also calls out another class. And the problem is, i can subclass the > other class to with the required function but the end result is that it > doesent work, sin

Re: class implementation

2013-10-08 Thread Rhodri James
On Tue, 08 Oct 2013 15:05:26 +0100, wrote: Parent class is at the link. Please quote some context when you reply. What link? Then again, I'm not about to click on some random link someone posts to a newsgroup. Apart from being one of the classic ways to get a virus onto my computer, it

Re: class-private names and the Zen of Python

2013-10-08 Thread Oscar Benjamin
On Oct 8, 2013 2:26 PM, "Steven D'Aprano" < steve+comp.lang.pyt...@pearwood.info> wrote: > > On Tue, 08 Oct 2013 12:13:48 +0200, Marco Buttu wrote: > > > Another question is: where is the place in which this transformation > > occurs? Is it at the parser level, before the dictionary attribute is >

Re: class-private names and the Zen of Python

2013-10-08 Thread Ned Batchelder
On 10/8/13 7:15 AM, Marco Buttu wrote: Also, as Terry mentions, no one has ever assigned the two names you show, Sincerely, I can not now if someone has assigned (or will assegne) in such way... If you explain more about what you are building, and where this crops up as a problem, we can

Re: class implementation

2013-10-08 Thread markotaht
Parent class is at the link. -- https://mail.python.org/mailman/listinfo/python-list

Re: class-private names and the Zen of Python

2013-10-08 Thread Steven D'Aprano
On Tue, 08 Oct 2013 12:13:48 +0200, Marco Buttu wrote: > In the following case: > > >>> class Foo: > ... _Foo__a = 100 > ... __a = 33 > ... > >>> Foo._Foo__a > 33 > > I think this behavior, for a user who does not know the convention, > could be a surprise. Yes, you are correct. It s

Re: class-private names and the Zen of Python

2013-10-08 Thread Marco Buttu
On 10/08/2013 01:07 PM, Ned Batchelder wrote: On 10/8/13 6:13 AM, Marco Buttu wrote: >>> class Foo: ... _Foo__a = 100 ... __a = 33 ... >>> Foo._Foo__a 33 ... You also get a "problem" if you do this: >>> class Foo: ... a = 100 ... a = 33 ... >>> Foo.a

Re: class-private names and the Zen of Python

2013-10-08 Thread Ned Batchelder
On 10/8/13 6:13 AM, Marco Buttu wrote: In the following case: >>> class Foo: ... _Foo__a = 100 ... __a = 33 ... >>> Foo._Foo__a 33 I think this behavior, for a user who does not know the convention, could be a surprise. Should be raising an exception (in order to inform the user the t

Re: class-private names and the Zen of Python

2013-10-08 Thread Marco Buttu
On 10/08/2013 12:36 PM, Terry Reedy wrote: On 10/8/2013 6:13 AM, Marco Buttu wrote: In the following case: >>> class Foo: ... _Foo__a = 100 ... __a = 33 ... >>> Foo._Foo__a 33 I think this behavior, for a user who does not know the convention, could be a surprise. No one qualified

Re: class-private names and the Zen of Python

2013-10-08 Thread Terry Reedy
On 10/8/2013 6:13 AM, Marco Buttu wrote: In the following case: >>> class Foo: ... _Foo__a = 100 ... __a = 33 ... >>> Foo._Foo__a 33 I think this behavior, for a user who does not know the convention, could be a surprise. No one qualified to use such names would do such a thing , so

Re: class implementation

2013-10-08 Thread Dave Angel
On 8/10/2013 04:20, markot...@gmail.com wrote: > I cant just subclassing doesent work. I can't parse that "sentence." > It seem the init method of the source class also calls out another class. And the problem is, i can subclass the other class to with the required function but the end result i

Re: class implementation

2013-10-08 Thread Mark Lawrence
On 08/10/2013 09:20, markot...@gmail.com wrote: To whom and to what are you replying? -- Roses are red, Violets are blue, Most poems rhyme, But this one doesn't. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list

  1   2   3   4   5   6   7   8   9   10   >