PKCS7 padding implementation in Python

2006-07-10 Thread Satchidanand Haridas
Hi,Do any of the cryptographic modules for Python support PKCS7 padding scheme? I would like to use this scheme with block cipher encryption algorithms to pad text whose length is less than a proper block size.  thanks in advance,Satchit -- 
http://mail.python.org/mailman/listinfo/python-list

WS-Security support for Python SOAP libraries

2006-06-14 Thread Satchidanand Haridas
Hi,

Do any of the existing SOAP libraries for Python have support for 
WS-Security?

thanks,
Satchit

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


creating single-instance executables using python/py2exe

2005-11-11 Thread Satchidanand Haridas
Hi,

I have created an application using python/wxPython and py2exe. I have 
associated a certain file extension with this application so that when I 
double-click the file, my application is launched. The application runs 
fine except that a new instance is created when I double click on two 
different files. Is there a way in which I can make sure only one 
instance is created? Any additional files are opened in the same running 
instance? Would appreciate any comments/feedback.

thanks,
Satchit

-- 

Satchidanand Haridas (sharidas at zeomega dot com)

ZeOmega (www.zeomega.com)
Open  Minds' Open Solutions

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


Re: best Pythonic way to do this sort: Python newb

2005-10-09 Thread Satchidanand Haridas


Satchidanand Haridas (sharidas at zeomega dot com)

ZeOmega (www.zeomega.com)
Open  Minds' Open Solutions



Sean Berry wrote:

Paul Rubin http://[EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
  

Sean Berry [EMAIL PROTECTED] writes:


myList = [[value1, value2, value3],[value1, value2, value3], ...]

I have a function which takes value3 from the lists above and returns
another value.  I want to use this returned value to sort the lists.

So, my resultant list would be ordered by the return value of the
function with value3 as its argument.

From a relative Python newb, what is the best way to do this?
  

def get_key(x): return x[2]
sorted_list = sorted(myList, key=get_key)



Sorry if I am missing something.  But. what is sorted here?

My simplified function looks like this

def myFunction( myNumber ):
do some math calculations to myNumber
return result of calculations

So, I want to sort myList by the return of myFunction( value3 )

I tried doing the following... with no luck so far
myList.sort(lambda x, y: cmp(myFunction(x[2]), myFunction(y[2]))

  

I think the above statement should be as follows:

myList.sort(lambda x, y: cmp(myFunction(x[2]) - myFunction(y[2]))



hope that helps.

regards,
Satchit
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Confused with module and .py files

2005-10-05 Thread Satchidanand Haridas
Iyer, Prasad C wrote:

Actually I am bit confused between the modules and .py file
How do I differentiate between the 2.

  

A module 'name' is the same as the name of your file without the '.py' 
extension.

For example
I have a file import1.py, import2.py file
Which has few functions and classes
And if I have a class with same name BaseClass in both the file

How would I use it if I declare it as given below in my 3rd class

from import1.py import *
from import2.py import *


  

You should say :
from import1 import *
from import2 import *

If according to your earlier question, you have a class with the same 
name in two different modules, the better thing then (as others on the 
list have already pointed out) is to do the following:

import import1, import2

c1 = import1.MyClass()
c2 = import2.MyClass()

regards,
Satchit


Satchidanand Haridas (sharidas at zeomega dot com)

ZeOmega (www.zeomega.com)
Open  Minds' Open Solutions




regards
prasad chandrasekaran










--- Cancer cures smoking

#-Original Message-
#From: [EMAIL PROTECTED]
#[mailto:[EMAIL PROTECTED] On
#Behalf Of [EMAIL PROTECTED]
#Sent: Wednesday, October 05, 2005 1:32 PM
#To: python-list@python.org
#Subject: Python-list Digest, Vol 25, Issue 65
#
#Send Python-list mailing list submissions to
#  python-list@python.org
#
#To subscribe or unsubscribe via the World Wide Web, visit
#  http://mail.python.org/mailman/listinfo/python-list
#or, via email, send a message with subject or body 'help' to
#  [EMAIL PROTECTED]
#
#You can reach the person managing the list at
#  [EMAIL PROTECTED]
#
#When replying, please edit your Subject line so it is more specific
#than Re: Contents of Python-list digest...

This message contains information that may be privileged or confidential and 
is the property of the Capgemini Group. It is intended only for the person to 
whom it is addressed. If you are not the intended recipient,  you are not 
authorized to read, print, retain, copy, disseminate,  distribute, or use this 
message or any part thereof. If you receive this  message in error, please 
notify the sender immediately and delete all  copies of this message.

  

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


Re: Quick help needed: how to format an integer ?

2005-10-05 Thread Satchidanand Haridas
One possible solution. Don't know how efficient it is though. :-)

  def put_decimal(s):
... return ''.join( [ [s[i], '.%s' % s[i]][(len(s)-i)%3 == 0] for i 
in range(0, len(s))])
...
  put_decimal(10001234)
'10.001.234'
  put_decimal(12622)
'12.622'

thanks,
Satchit


[EMAIL PROTECTED] wrote:

Hi !

I need to convert some integer values.

1622 -1 622

or

10001234 - 10.001.234

So I need thousand separators.

Can anyone helps me with a simply solution (like %xxx) ?

Thanx for it: dd

Ps:
Now I use this proc:

def toths(i):
s=str(i)
l=[]
ls=len(s)
for i in range(ls):
c=s[ls-i-1]
if i%3==0 and i0:
   c=c+.
l.append(c)
l.reverse()
return .join(l)



  

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


Re: Removing dictionary-keys not in a set?

2005-04-18 Thread Satchidanand Haridas
Hi,
I am not sure if this way is a good one, but it certainly is consise. 
Also sometimes, it's better to go for a simple approach than the consise 
one (for readability). With the abive disclaimer, I present my solution:

d1 = {1 : 2, 3 : 4, 5 : 6, 7 : 8, 9 : 10 }
s1 = [ 1, 5, 7 ]
# assuming you are using python 2.3.5
import sets
d2 = dict( [ ( x, d1[ x ] ) for x in sets.Set( d1.keys() ). 
intersection( sets.Set( s1 ) ) ] )

thanks,
Satchit
Tim N. van der Leeuw wrote:
Hi,
I'd like to remove keys from a dictionary, which are not found in a
specific set. So it's kind of an intersection-operation.
I can create a new dictionary, or a loop over all keys and test them
for set-membership, but I was wondering if there was a smart way to
express this in 1 or 2 concise statements that I'm not aware of.
So are there smarter ways to get the intersection of dictionary and set
into a dictionary than the following pseudo-code:
# Variation 1
d2 = {}
for key in s: d2[key] = d1[key]
# Variation 2
for key in d.iterkeys(): if key not in s: del d[key]
And if there's no smarter way, then which of these two options would
give best performance?
Cheers,
--Tim
 

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


Re: A ClientForm Question

2005-04-06 Thread Satchidanand Haridas
Hi,
ClientForm and Mechanize like tools do not execute javascript . You will 
normally have to do them manually in your python code itself. In your 
case, if you have a button, which (and I assume) executes some 
javascript code that sets some hidden variable and/or changes the 
'action' attribute of the form, you will have to change/assign those 
elements in your python code itself.

ClientForm and mechanize can get tedious to use when one has a lot of 
JavaScript functionality in the form.

Hope this answered your question... :-)
regards,
Satchit
narke wrote:
John J. Lee wrote,
 

See second bullet point under Why does .click()ing on a button not
   

work for me?.
Thanks for you advice. However, after read through the FAQs, I have not
managed to find a solution for my problem.  I belive my button is
coupled with some Java script which mess thing up and there is no a
easy solution.  Am I right?
-
narke
 

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


Re: dictionary: sorting the values preserving the order

2005-04-01 Thread Satchidanand Haridas
Rakesh wrote:
Hi,
 For a particular problem of mine, I want to sort key, value 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
 

the following code does that:
 d1 = {'a':4,'b':5,'c':1,'d':2,'e':3}
 i1 = [ (d1[i], i) for i in d1.keys() ]
 i1.sort()
 i1
[(1, 'c'), (2, 'd'), (3, 'e'), (4, 'a'), (5, 'b')]
 for each in i1:
... print each[1]  
c
d
e
a
b

thanks,
Satchit


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: tree data structure

2005-03-25 Thread Satchidanand Haridas
Hi,
You could use Python dictionaries as trees. Example:
to represent a simple tree:
'a' - (  'b' ,  'c' )
'b' - ( 'd',  'e',  'f')
'e' - ( 'g')
'f' - ('h', 'i', 'j')
treeD = { 'a' : (
   { 'b' : (
'd', 
   { 'e'  :  'f' },
   {f  :  ( 'h', 'i', 'j' )}
)
   },
'c'
   )
   }

hope this helps.
regards,
Satchit

Satchidanand Haridas (sharidas at zeomega dot com)
ZeOmega (www.zeomega.com)
Open  Minds' Open Solutions
#20,Rajalakshmi Plaza,
South End Road,
Basavanagudi,
Bangalore-560 004, India

vivek khurana wrote:
Hi! all
i am a new member on this list. I have to implement 
tree data structure using python. How it can be done 
in python. Is there an existing data structure which
can be used as tree? I have searched archives and 
manuals but no luck.

Regards
VK
Hug the REALITY ;-)

Disclaimer
The facts expressed here belong to everybody, the opinions to me. The 
distinction is yours to draw...
		
__ 
Do you Yahoo!? 
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/ 
 

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


Re: renaming 'references' to functions can give recursive problems

2005-02-16 Thread Satchidanand Haridas
peter wrote:
Hello, nice solution:
but it puzzles me :)
can anyone tell me why
---correct solution
def fA(input):
 return input
def newFA(input, f= fA):
  return f(input)
fA = newFA
is correct and:
 

 def fA(input):
... print inside fA
... return input
...
 def newFA(input,f=fA):
... print inside newFA
... return f(input)
...
 fA = newFA
 fA(2)
inside newFA
inside fA
2
while:
-infinite loop-
def fA(input):
 return input
def newFA(input):
  return fA(input)
fA = newFA
gives an infinite recursive loop?
 

 def fA(input):
... print inside fA
... return input
...
 def newFA(input):
... print inside newFA
... return fA(input)
...
 fA = newFA
 fA(2)
inside newFA
inside newFA
inside newFA
inside newFA
What is happening is that when you call fA (inside newFA) in the second 
case, you are calling newFA because fA is pointing to newFA (hope that 
made sense ;-)). So it was recursive. While in the former case you 
called f, which pointed to fA, but not to newFA. Probably the following 
will make it clearer:

 def fA(input):
... print inside fA
... return input
...
 def newFA(input,f=fA):
... print inside newFA
... print f is pointing to: ,f
... return f(input)
...
 fA = newFA
 fA(2)
inside newFA
f is pointing to:  function fA at 0x43123374
inside fA
2
 fA
function newFA at 0x43194064
 newFA
function newFA at 0x43194064
Thus f and fA do not point to the same function object when you execute 
the statement fa(2). This f is called once and terminates.

thanks,
Satchit
--
http://mail.python.org/mailman/listinfo/python-list


implementing singleton class at the module level

2005-02-10 Thread Satchidanand Haridas
Hi,
I was looking at ways to implement a Singleton class. I saw some methods 
described on the PythonSingleton wiki 
(http://c2.com/cgi/wiki?PythonSingleton). I implemented the following.

code
module: A.py
--
class Singleton:
   def __init__(self):
  #do something
singleton_instance = Singleton()

Then in any other module (eg B.py):
from A import singleton_instance
/code
singleton_instance will be created only once and can be reused in other 
modules. But is this ok? I am trying to figure out what are the 
disadvantages of using the above method. I would appreciate any 
comments. thanks.

regards,
Satchit
--
http://mail.python.org/mailman/listinfo/python-list


Re: EDI x12 -- XML

2005-02-04 Thread Satchidanand Haridas
Hi,
In case you weren't aware of the pyx12 project on sourceforge.  The 
project summary on sourceforge.net  
(http://sourceforge.net/projects/pyx12/) says the following and I quote:

pyx12 is a python based ANSI X.12 to XML EDI translator and validator. 
It is designed to be a step in the conversion of a X12 transaction to 
back-end database process. It can convert to and from an XML 
representation of the X12 document. 

fyi.
thanks,
Satchit

Satchidanand Haridas (sharidas at zeomega dot com)
ZeOmega (www.zeomega.com)
Open  Minds' Open Solutions
#20,Rajalakshmi Plaza,
South End Road,
Basavanagudi,
Bangalore-560 004, India

Greg Lindstrom wrote:
Hello, List-
I am working on automating a system accepting input data in EDI x12 
format and would like to convert it to XML.  Before I start, I thought 
I'd ask if anyone has worked on such a beast.  I have seen work by 
Chris Cioffi on parsing EDI records.  Is anything else out there 
before I either write one or use one that I have written in Perl?

Thanks!
--greg--
Greg Lindstrom   501 975.4859
Computer Programmer  [EMAIL PROTECTED]
NovaSys Health
Little Rock, Arkansas
We are the music makers, and we are the dreamers of dreams.  W.W.

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


Re: Please suggest on the book to follow

2005-01-27 Thread Satchidanand Haridas
Hi,
Probably the best resources for learning Python are available online. 
Here are a few sites that you might find helpful:

1. http://byteofpython.info/ 

2. http://www.diveintopython.org/   -- Writted by Mark Pilgrim, covers 
many advanced material. The site says /Dive into Python/  is a Python 
book for experienced programmers.

3. http://gnosis.cx/TPiP/  -- Site for Text Processing in Python, a 
book by David mertz. You will find many other very good Python related 
material on his website.


regards,
Satchit

Satchidanand Haridas (sharidas at zeomega dot com)
ZeOmega (www.zeomega.com)
Open  Minds' Open Solutions
#20,Rajalakshmi Plaza,
South End Road,
Basavanagudi,
Bangalore-560 004, India

santanu wrote:
Hi all,
I know a little python (not the OOP part) learnt by studying the online
tutorial. Now I would like to learn it more thoroughly.
I have access to 'Programming Python' which I liked (on flipping
through the
pages), but the problem is it deals only with version 2.0 of Phython.
So, I would be glad if you could suggest me whether it would be really
a good
idea to learn from this book. In other words, will I have to unlearn
too much
after I complete this book (by the time I am done with this book, I
believe
we will be having Python 2.6 or so).
Please suggest.
Regards,
Santanu
 

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


Re: DevX: Processing EDI Documents into XML with Python

2005-01-25 Thread Satchidanand Haridas
There has already been some work in this area - although for X12 
transactions for the healthcare industry. Its on sourceforge already and 
best of all the development language is Python:

http://sourceforge.net/projects/pyx12/
thanks,
Satchit

Satchidanand Haridas (sharidas at zeomega dot com)
ZeOmega (www.zeomega.com)
Open  Minds' Open Solutions
#20,Rajalakshmi Plaza,
South End Road,
Basavanagudi,
Bangalore-560 004, India

Jeremy Jones wrote:
Claudio Grondi wrote:
You don't have to rely on expensive and proprietary EDI conversion 
software
to parse, validate, and translate EDI X12 data to and from XML; you can
build your own translator with any modern programming language, such as
Python.

 by Jeremy Jones
 http://www.devx.com/enterprise/Article/26854
 Excerpt:
 Python is an object-oriented, byte-compiled language with a clean
syntax, clear and consistent philosophy, and a strong user community. 
These
attributes (both of the language and the community) make it possible to
quickly write working, maintainable code, which in turn makes Python an
excellent choice for nearly any programming task. Processing any 
flavor of
EDI is no exception.

Hi,
just wanted to share with you, that the last issue
of the DevX newsletter comes with a Python related
article as first item in the list of subjects.
Claudio
 

Anyone interested in processing EDI with Python will probably be 
interested in giving it a read.  Please feel free to scrutinize the 
code mercilessly.  I plan on creating a project on Sourceforge with 
the code that is attached to that article (and hopefully with 
modifications coming from user input in the ensuing months).  Comments 
are greatly appreciated.

Thanks for posting this, Claudio.
Jeremy Jones
--
http://mail.python.org/mailman/listinfo/python-list


Re: How can I get the names of the files in a directory?

2005-01-15 Thread Satchidanand Haridas
Hi,
try the 'listdir' function in the 'os' module. Also check the 'walk' 
function.

regards,
Satchit

Satchidanand Haridas (sharidas at zeomega dot com)
ZeOmega (www.zeomega.com)
Open  Minds' Open Solutions
#20,Rajalakshmi Plaza,
South End Road,
Basavanagudi,
Bangalore-560 004, India

Sara Fwd wrote:
Can you guys also help me find a module that looks in
a directory and print out the names of the files in there?
		
__ 
Do you Yahoo!? 
Yahoo! Mail - Helps protect you from nasty viruses. 
http://promotions.yahoo.com/new_mail
 

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