[Tutor] Shell Output Format - [was: Is there Python code for accessing an object's reference count?]

2006-10-08 Thread Ilias Lazaridis
Kent Johnson wrote:
...
> In [2]: sys.getrefcount(100)
> Out[2]: 43
> 
> In [3]: def foo():
> ...: return 100
> ...:
> 
> In [4]: sys.getrefcount(100)
> Out[4]: 44

off-topic:

how to you get this output format of the shell?

In [2]:
Out[2]:

I've tried to alter IDLE:

IDLE - Customizing output format
http://groups.google.com/group/comp.lang.python/browse_frm/thread/b81ef0c0b134def2

.

-- 
http://lazaridis.com

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Looking for Constructs to Remove Redundant Code

2006-03-31 Thread Ilias Lazaridis
Kent Johnson wrote:
...

Thank you for your comments. I realize that my request was not very 
clear. I make a 2nd attemp, more simplified:

I have this python code:

class Car(BaseClass) :
  manufacturer = stringFactory()
  model = stringFactory()
  modelYear = integerFactory()

  def __str__(self):
  return '%s %s %s' % (self.modelYear, self.manufacturer, 
self.model)

def stringFactory(self)
 s = String() # creates a string object
 #... # does several things
 return s # returns the string object

-

and would like to see it e.g. this way:

class Car(BaseClass):
  manufacturer = stringFactory(2)
  model = stringFactory(3)
  modelYear = integerFactory(1)

def stringFactory(self, position)
 s = String() # creates a string object
 ...  # does several things
  # creates somehow the __str__ functionality... 

 return s # returns the string object

-

hope this is now more clear.

.

-- 
http://lazaridis.com

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Looking for Constructs to Remove Redundant Code

2006-03-31 Thread Ilias Lazaridis
I have this python code

class Car:
 """Type of car."""

 manufacturer = f.string()
 model = f.string()
 modelYear = f.integer()

 _key(manufacturer, model, modelYear)

 def __str__(self):
 return '%s %s %s' % (self.modelYear, self.manufacturer, self.model)

-

and would like to see it e.g. this way:

class Car:
 """Type of car."""

 manufacturer = f.string(true, str=2)
 model = f.string(true, str=3)
 modelYear = f.integer(true, str=1)

-

how would the factory method look like?

def string(self, key, str )
 # create somehow the __str__ function
 # create somehow the key

.

-- 
http://lazaridis.com

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor