[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Vala] __str__ method in vala ?



Hi everyone :

Could be really interesting a method like __str__ method in python. 

>From python doc :

__str__(
self)
        Called by the str() built-in function and by the print statement
        to compute the ``informal'' string representation of an object.
        This differs from __repr__() in that it does not have to be a
        valid Python expression: a more convenient or concise
        representation may be used instead. The return value must be a
        string object.
        
Examples : 

>>> string = "hello vala developer"
>>> print string
hello vala developer


>>> list = ["apple", "orange", "cookie"]
>>> print list
['apple', 'orange', 'cookie']


>>> dict = {"key1" : "hello", "key2" : "bye"}
>>> print dict
{'key2': 'bye', 'key1': 'hello'}

>>> import gtk
>>> x = gtk.Window()
>>> print x
<gtk.Window object at 0x81a9734 (GtkWindow at 0x83b1830)>

Opinions ?

telemaco



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]