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: Brainstorming on recursive class definitions

2017-09-12 Thread moogyd--- via Python-list
On Tuesday, September 12, 2017 at 5:37:31 PM UTC+2, Johannes Bauer wrote: > Hi group, > > so I'm having a problem that I'd like to solve *nicely*. I know plenty > of ways to solve it, but am curious if there's a solution that allows me > to write the solution in a way that is most comfortable for

Re: Brainstorming on recursive class definitions

2017-09-12 Thread Johannes Bauer
By the way, here's my work in progress: https://gist.github.com/johndoe31415/7e432b4f47f0030f0903dbd6a401e5dc I really really love the look & feel, but am unsure if there's a better way for this? Cheers, Joe -- >> Wo hattest Du das Beben nochmal GENAU vorhergesagt? > Zumindest nicht öffentlich

Brainstorming on recursive class definitions

2017-09-12 Thread Johannes Bauer
Hi group, so I'm having a problem that I'd like to solve *nicely*. I know plenty of ways to solve it, but am curious if there's a solution that allows me to write the solution in a way that is most comfortable for the user. I'm trying to map registers of a processor. So assume you have a n bit ad

Re: Scoping rules for class definitions

2014-04-08 Thread Rotwang
On 04/04/2014 19:55, Ian Kelly wrote: On Fri, Apr 4, 2014 at 12:37 PM, Rotwang wrote: Hi all. I thought I had a pretty good grasp of Python's scoping rules, but today I noticed something that I don't understand. Can anyone explain to me why this happens? x = 'global' def f1(): x = 'loca

Re: Scoping rules for class definitions

2014-04-04 Thread Ian Kelly
On Fri, Apr 4, 2014 at 12:37 PM, Rotwang wrote: > Hi all. I thought I had a pretty good grasp of Python's scoping rules, but > today I noticed something that I don't understand. Can anyone explain to me > why this happens? > x = 'global' def f1(): > x = 'local' > class C: >

Scoping rules for class definitions

2014-04-04 Thread Rotwang
Hi all. I thought I had a pretty good grasp of Python's scoping rules, but today I noticed something that I don't understand. Can anyone explain to me why this happens? >>> x = 'global' >>> def f1(): x = 'local' class C: y = x return C.y >>> def f2(): x = 'local' cl

Re: Generating class definitions at runtime in memory from XSD or JSON

2012-02-17 Thread Stefan Behnel
Stodge, 17.02.2012 02:15: > Does anyone know of a library to generate class definitions in memory, > at runtime, from XSD or JSON? The question is: why do you want to do that? There may be other ways to do what you *actually* want to do, but we don't know what that is. Stefa

Re: Generating class definitions at runtime in memory from XSD or JSON

2012-02-17 Thread Nobody
On Thu, 16 Feb 2012 17:15:59 -0800, Stodge wrote: > Does anyone know of a library to generate class definitions in memory, > at runtime, from XSD or JSON? I know about PyXB, generateDS and some > others, but they all rely on generating python source files at the > command line, an

Generating class definitions at runtime in memory from XSD or JSON

2012-02-16 Thread Stodge
Does anyone know of a library to generate class definitions in memory, at runtime, from XSD or JSON? I know about PyXB, generateDS and some others, but they all rely on generating python source files at the command line, and then using those to parse XML. Thanks -- http://mail.python.org/mailman

Re: Amateur question on class definitions...

2011-11-29 Thread Ian Kelly
On Tue, Nov 29, 2011 at 8:21 AM, J. Marc Edwards wrote: > So I am defining my Python classes for a Django data model.  I have a the > following class hierarchy and would value some expert input on how to best > implement this. > > I have many instances of a particular class which I call a "workflo

Re: Amateur question on class definitions...

2011-11-29 Thread Chris Angelico
On Wed, Nov 30, 2011 at 2:21 AM, J. Marc Edwards wrote: >     ...a list of "a_workflows", i.e. a composite workflow, should I use this > syntax? >     set_of_workflows = list(a_workflow) > This would be usual: set_of_workflows = [a_workflow] Using the list() constructor directly is for when you

Amateur question on class definitions...

2011-11-29 Thread J. Marc Edwards
So I am defining my Python classes for a Django data model. I have a the following class hierarchy and would value some expert input on how to best implement this. I have many instances of a particular class which I call a "workflow", e.g. wf_1, wf_2, wf_3, etc. These class instances of workflows

Re: Newbie Question. Class definitions on the fly.

2006-08-27 Thread Simon Forman
ishtar2020 wrote: > Hi everyone > > I'm sure this question is kinda stupid and has been answered a few > times before... but I need your help! > > I'm writing a small application where the user can analyze some text > based on a set of changing conditions , and right now I'm stuck on a > point whe

Re: Newbie Question. Class definitions on the fly.

2006-08-27 Thread hiaips
ishtar2020 wrote: > Hi everyone > > I'm sure this question is kinda stupid and has been answered a few > times before... but I need your help! > > I'm writing a small application where the user can analyze some text > based on a set of changing conditions , and right now I'm stuck on a > point wh

Newbie Question. Class definitions on the fly.

2006-08-27 Thread ishtar2020
Hi everyone I'm sure this question is kinda stupid and has been answered a few times before... but I need your help! I'm writing a small application where the user can analyze some text based on a set of changing conditions , and right now I'm stuck on a point where I'd like to automatically gen

Re: Dynamically Update Class Definitions?

2005-11-12 Thread Chris Spencer
Jean-Paul Calderone wrote: > There are lots of cases where you cannot rebind the __class__ > attribute. For a comprehensive treatment of this idea (but still not a > completely functionality implementation), take a look at >

Re: Dynamically Update Class Definitions?

2005-11-11 Thread Jean-Paul Calderone
On Sat, 12 Nov 2005 06:24:57 GMT, Chris Spencer <[EMAIL PROTECTED]> wrote: >Chris Spencer wrote: >> Alex Martelli wrote: > >>> If you're in no hurry, you COULD loop over all of gc.get_objects(), >>> identify all those which are instances of old_class and "somehow" change >>> their classes to new_cl

Re: Dynamically Update Class Definitions?

2005-11-11 Thread Chris Spencer
Chris Spencer wrote: > Alex Martelli wrote: >> If you're in no hurry, you COULD loop over all of gc.get_objects(), >> identify all those which are instances of old_class and "somehow" change >> their classes to new_class -- of course, x.__class__ = new_class may >> well not be sufficient, in which

Re: Dynamically Update Class Definitions?

2005-11-11 Thread Chris Spencer
Alex Martelli wrote: > <[EMAIL PROTECTED]> wrote: > > >>Is there a way to loop through all instantiated objects and update >>their classes when a source file changes? I know about Michael Hudson's >>method >>(http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/160164), but >>you have to modif

Re: Dynamically Update Class Definitions?

2005-11-11 Thread Alex Martelli
<[EMAIL PROTECTED]> wrote: > Is there a way to loop through all instantiated objects and update > their classes when a source file changes? I know about Michael Hudson's > method > (http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/160164), but > you have to modify all your classes to subcla

Dynamically Update Class Definitions?

2005-11-11 Thread chrisspen
Is there a way to loop through all instantiated objects and update their classes when a source file changes? I know about Michael Hudson's method (http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/160164), but you have to modify all your classes to subclass AutoReloader. Is there something le