Re: what's the use of __repr__?when shall I use it?

2005-03-31 Thread Vikram

__repr__ should return something that when eval'ed yields an identical
object (if possible). essentially it should represent the programmer/debug
view of the object.

__str__ should mostly return a highly user-friendly string (note: str(obj)
will use __repr__ if __str__ doesn't exist)

you might also be interested in this thread covering the same topic:
http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/d10731049459726f/2a8f62f478057abd?q=python+__repr__+__str__+difference&rnum=6#2a8f62f478057abd

thanks,
    Vikram

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: dictionary: sorting the values preserving the order

2005-03-31 Thread Vikram

hi,

assuming your key-value relationship is one-to-one then as a simple first
pass you can simply initialize d1={} and for i in d.keys(): d1[d[i]] = i
and pass d1 to your sortedDictValue3 function, no?

thanks,
Vikram


On 31 Mar 2005, Rakesh wrote:

> Hi,
>   For a particular problem of mine, I want to sort  pairs
> by its value.
>
> Eg:
>
> Input:
>
> A, 4
> B, 5
> C, 1
> D, 2
> E, 3
>
> I would like the output to be:
>
> C
> D
> E
> A
> B
>
> i.e. I would like to get the keys in the sorted order of values.
>
> I did google around a little bit. One solution to a similar problem
> suggested is:
>
> # Courtesy:
> http://aspn.activestate.com/ASPN/Python/Cookbook/Recipe/52306
> def sortedDictValues3(adict):
> keys = adict.keys()
> keys.sort()
> return map(adict.get, keys)
>
> This gets a list sorted by the keys. How would I get a revised
> dictionary
> sorted by its values.
>
>

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: __init__ method and raising exceptions

2005-04-01 Thread Vikram
> I can't use 'break' or 'continue' in a class method, nor can I return a
> boolean value from __init__() to check for errors within the for-loop.
> How would I be able to stop the current iteration and continue with the
> next after reporting an error?

maybe i don't fully understand your qn but why don't you let __init__ of
your class raise an exception and then catch it in the outer for loop and
continue. something like:

for i in ...
  try:
foo()
  except:
continue

Vikram

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: newbie - Does IDLE care about sitecustomize.py?

2014-03-22 Thread vikram . denizen
Could you figure this out?

On Wednesday, November 16, 2005 10:37:09 PM UTC+8, bobu...@yahoo.com wrote:
> I have the following test script in the file customize.py
> 
> # C:\Python24\Lib\site-packages\sitecustomize.py
> print "test text from sitecustomize"
> 
> If start Python from command prompt I get
> 
> C:\Python24>python
> test in sitecustomize
> Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)]
> on win32
> Type "help", "copyright", "credits" or "license" for more information.
> 
> which shows that sitecustomize.py works
> 
> 
> Now if I start IDLE I only get
> 
> IDLE 1.1.1
> >>>
> 
> which shows that that IDLE doesn't care about sitecustomize.py
> 
> Am I missing something or how do you customize if you are using IDLE?

-- 
https://mail.python.org/mailman/listinfo/python-list


autocomplete and printing

2009-03-24 Thread vikram moule
Q1. I want to access a database and just by pressing the first alphabet will
showup a dropdown list of all the words starting from that alphabet how can
I do that ?
( I know how to access the database but the further problem is unsolved
hence)
Q2. How can I print a document for example bill or prescription through a
printer or network printer (both) using python ?

Thank
--
http://mail.python.org/mailman/listinfo/python-list


header intact

2006-04-15 Thread Vikram Katju
 
 

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
-- 
http://mail.python.org/mailman/listinfo/python-list


font change

2010-04-23 Thread Vikram Moule
Q1. I want to change the font of the menu . I want to write the menu items
like "File" in my native language.I was successful writing the text in the
window in my font. But I am not able to write the menu items in same font.
In fact I am not able to find how to change the font of the menu.
I am using wx module of wxPython.
Q2. A white window is seen when i execute the program it says
wxPython:stdout/stderr what is that ? and how to get rid of it ?
Thanks in advance.

-- 
Regrads ,
Vikram Moule
-- 
http://mail.python.org/mailman/listinfo/python-list