Explanation about for loop

2007-01-11 Thread raghu
can any one help me explaining for loop and its execution and its
syntax with a simple example.

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


Re: How can i eval subindex on list[ ][ ] ?

2007-01-17 Thread raghu

its working for me i think its better to mention the value of i and j
for both lists or you might have done mistake while formatting strings
it should be %s for strings and %d for numbers if any subelement in
lists does not formatted properly it may lead to error

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


Standard streams

2007-01-19 Thread raghu
what is standard streams in case of python?

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


Diff between opening files in 'r' and 'r+' mode

2007-01-30 Thread raghu
i want to know the difference between 'r' mode and 'r+' mode
1.i = open('c:\python25\integer.txt','w')>for writiing
  i.write('hai')->written some content in text file
  i = open('c:\python25\integer.txt','r')>for reading
  print i.read()>for printing the contents in that text file
  i = open('c:\python25\integer.txt','w')-->for writing
  i.write('how')---?Rewrite the contents
  print i.read()
[MY QUESTION]:i want to read the text file contents cant it be done by 
giving (print i.read())?
Before going to next question [I deleted all the contents in the text 
file]

2.i = open('c:\python25\integer.txt','r+')-For reading and writing
   i.write('hai')->written some content  to text file
   print i.read()->{؆('c:\python25\integer.txt','w')
   i write('')
   print i.read()how')
   i = open('c:\python25\integer.txt','r')
   print i.read()
   i = open('c:\python25\integer.txt','w')
   i.write()
   i = open('c:\python25\integer.txt','r')
  print i.read() } --->Thats what i saw on 
interpreter(In curly braces) when  i ran the script
[MY QUESTION]:1.from where the above in curly braces is printed?and i 
have written only 'hai' to the text file
  2.Should i recall again the opening of the 
file in 'r' mode to read the file?

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

Explanation about pickle module

2007-01-30 Thread raghu
can any one explain about pickle i read in the book but they have not 
provided any example for that so please explain with a simple example

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


Reference Counts

2006-05-17 Thread raghu
Hi All,

I am a new user of Python and am having a bit of problem understanding
the Reference counting and memory leakage issues.

Requesting help from experienced users

I wrote the following simple program.


#!/usr/bin/python

import sys
global a

print "Total Reference count at the start =",sys.gettotalrefcount()
a=1
print "a ref count =",sys.getrefcount(a)
b=a
print "a ref count =",sys.getrefcount(a)

del a
del b

print "Total Reference count at the end =",sys.gettotalrefcount()


I executed it. I am seeing the following.

Total Reference count at the start = 16538
a ref count = 49
a ref count = 50
Total Reference count at the end = 16540
[6416 refs]

There are a few questions that I am having on this.

(1) Why should 'a' reference count be 49 before I even made an
assignment ?
(2) The Total Reference count at the end has increased by 2 . Why ? Am
I leaking memory ?
(3) I have read somewhere that an increase in sys.gettotalrefcount() is
indicative of a memory leak ? Aint that correct ?

Thanks for the help.

Bye,
raghavan V

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


Re: Reference Counts

2006-05-18 Thread raghu
Heiko,

Thanks for the explanation. I understood the idea of 1 being interned.
Also I understood the globals vars having a reference in the internal
dict.

I ran the "leaky" version of the program and yes...it showed a
progressively increasing totalrefcount as below.
Before 0 : 16579
After 0 : 16581
Before 1 : 16581
After 1 : 16583
Before 2 : 16583
After 2 : 16585
Before 3 : 16585
After 3 : 16587
Before 4 : 16587
After 4 : 16589
Before 5 : 16589
After 5 : 16591
Before 6 : 16591
After 6 : 16593
Before 7 : 16593
After 7 : 16595
Before 8 : 16595
After 8 : 16597
Before 9 : 16597
After 9 : 16599
Before 10 : 16599
After 10 : 16601
Before 11 : 16601
After 11 : 16603
Before 12 : 16603
After 12 : 16605
Before 13 : 16605
After 13 : 16607
Before 14 : 16607
After 14 : 16609
Before 15 : 16609

However, the 'non-leaky' one showed a funny trend ...it kept increasing
the totalrefcount for five iterations (see 1 thru 5) and then dropped
down by 5 ( See Before 5 : 16584
After 5 : 16580 ) suddenly and again increase as shown below. However,
at the time when the script finsished execution, we were not too far
from the starting totalrefcount (16584 from 16579),


Before 0 : 16579
After 0 : 16580
Before 1 : 16580
After 1 : 16581
Before 2 : 16581
After 2 : 16582
Before 3 : 16582
After 3 : 16583
Before 4 : 16583
After 4 : 16584
Before 5 : 16584
After 5 : 16580
Before 6 : 16580
After 6 : 16581
Before 7 : 16581
After 7 : 16582
Before 8 : 16582
After 8 : 16583
Before 9 : 16583
After 9 : 16584
Before 10 : 16584
After 10 : 16580
Before 11 : 16580
After 11 : 16581
Before 12 : 16581
After 12 : 16582
Before 13 : 16582
After 13 : 16583
Before 14 : 16583
After 14 : 16584
Before 15 : 16584

What is the Mystery behind the increase and the subsequent drop ?

Thanks.

Raghavan V

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


Re: Reference Counts

2006-05-18 Thread raghu
Hmm...

I tried the gc.collect(). It aint helping. The reference count still
keeps growing till 5 after it which it drops. As you said, it is not
gonna hurt right away.

The only downside in that mysterious up and down thingie is that , we
could get to a wrong conclusion about a leak, if we ran the algo for
say 3 times. Right ?

Thanks Heiko for all the help. And in case, you get to decode the
mystery behind the increase before the decrease ..kindly let me know.

Bye,
Raghavan V

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


referrers

2006-05-24 Thread raghu
Hi All,

The sys.getrefcount() is very useful to get the number of references on
a particular object.

Is there any companion function to get "who" the referrers are ?

for e.g.

global x
global y
global z


x0=24012
y=x0
z=x0

print "ref count ",sys.getrefcount(x0)


This prints a ref count of 5.

Basically, I need to know which are the 5 entities who are referring to
x0 ?

Is there any way of doing it ?

Thanks.

Bye,
raghavan V

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


Re: referrers

2006-05-24 Thread raghu
Diez,

I did look into gc, specifically gc.get_referrers(), but it seemed to
give me something that I cant decipher.

I added the following line.

print "referrers ",gc.get_referrers(x0)

This is what I got.

referrers  [{'__builtins__': ,
'__file__': './tst1.py', 'pdb': , 'sys':
, 'y': 24012, 'gc': ,
'myfuncs': ,
'__name__': '__main__', 'x0': 24012, 'z': 24012, 'os': ,
'__doc__': None, 'types': },
(None, '/home/Raghavan/tst', 'my pid is ', 24012, 'ref count ',
'referrers ')]

Also the len of this is 2, while I got refcount=5. So I dont know
whether this can be used in the same way.

Thanks.

Bye,
Raghavan V

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


Accepting a SAML 2 Assertion

2010-11-22 Thread raghu bg
Hello,

I am working on providing a SSO solution to a customer who acts as an
identity provider. He already has IDP on his side to generate SAML 2
assertions with user first name , last name  and time stamp as parameters.
Our task is to accept this assertion which is signed, decrypt it and send it
to the authenticator we already have. The authenticator validates the info
and gives access to our application which is written using Python. Here we
act as the *service provider.*
I am new to SAML and have no idea how to integrate SAML to our current
Python application. Can you help me on how to accept these assertion
requests from the Idp and decrypt it at Service Provider end using Python.

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


Windows SSH (remote execution of commands) - Python Automation

2008-12-29 Thread Narasimhan Raghu-RBQG84
Hi experts,
 
I am looking for some information on how to automate remote login to a
UNIX machine using ssh from a windows XP box.
 
Possible way:
 
1. Use putty (or any other ssh client from windows XP). -- Can be
automated with command line parameters. The problem is that I am able to
login - Putty window opens up as well. But obviously I am unable to run
any commands in that. I need to find something like a handle to that
Putty window so that I can execute commands there.
 
Can anyone provide me some help in achieving this ?
 
 
Thanks,
 
--
Raghu
--
http://mail.python.org/mailman/listinfo/python-list


RE: string in files

2008-12-30 Thread Narasimhan Raghu-RBQG84
Simple solution: us result=yourString.split(" ") and you get a list with
all the words. 

-Original Message-
From: [email protected]
[mailto:[email protected]] On Behalf Of
[email protected]
Sent: Tuesday, December 30, 2008 3:43 PM
To: [email protected]
Subject: string in files

guys i need info on how to call up different words in a line of a file
using python example : file = 'this is a python coding group'

i want to assign a xter to this, is, a, python , coding and group

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


Re: mod_python and PHP sharing same session

2006-04-04 Thread K Raghu Prasad
Scott wrote:
 > I am trying to get a mod_python application to read an existing PHP
 > session.  I need some data that was set in the session by the PHP
 > application.  I am using the mod_python Session class but even when I
 > specify the session id that PHP uses the Session(req, sid) call
 > returns a new session id.  The session file exists in /tmp as
 > mp_sess.dbm and I have verified that PHP is reading/writing it and from
 > what I have read mod_python will use the same file.  I have used the
 > PythonOption session DbmSession in the Apache configuration to force
 > this and specified the filename as well but to no avail.

PHP and Python stores the session data differently. One way to fix this
problem without the issues of managing file locks is to use override
file based session handler of PHP with database based one. You can
use MySQL to store this data. Then you need to write a parser in Python
to parse the session data of PHP. Since this data is plain text, you don't
have to do any reverse engineering to understand its format. Once both
these things are ready, you can access the values stored by PHP application
from the Python one.

By the way, won't it be easy to use cookies to shared data between these
two applications?

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