Re: Running another python interpreter

2007-10-18 Thread Sushant
Does gateway.py has the python interpreter in the top (i.e., 
#!/usr/local/bin/python)

-Sushant.
On Thursday 18 October 2007 2:13 pm, Simon Pickles wrote:
> Well, I tried:
>
> os.spawnv(os.P_NOWAIT, "gateway.py", ())
>
> and got:
>
> OSError: [Errno 8] Exec format
>
> Simon Pickles wrote:
> > Hello,
> >
> > I have several servers which link to each other (and of course, to
> > clients).
> >
> > At present, I am starting them in turn manually. Is there a way with
> > python to say, "open gateway.py in a new interpreter window"?
> >
> > I looked at execv, etc, but they seem to replace the current process.
> > Ah, maybe I need spawnv().
> >
> > I am on windows i386, python 2.5
> >
> > Thanks
> >
> > si
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: dynamic invoke

2007-10-19 Thread Sushant
I did not know about getattr and it is the right thing. 

getattr seems to be converting string into function pointer and I am just 
saying that string cannot be used as a function pointer in Python as may be 
in PHP.

I copied the PHP code so I did not replace arrow with  dot. Good point :)

-Sushant.

On Friday 19 October 2007 11:05 am, Diez B. Roggisch wrote:
> Sushant wrote:
> > Python will not allow string to be used a function pointer. It is type
> > unsafe. Best way is to convert string into function pointers manually.
> >
> > if dynamicMethod == 'bar':
> > method = oFoo->bar
> > else:
> > method = oFoo->default
> > method()
>
> Sorry to say so, but that answer is bogus. It's not even Python!
>
> Jarek has already shown how to solve this problem. And type-safety-issues
> have nothing to do with it at all.
>
> Diez
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: dynamic invoke

2007-10-19 Thread Sushant
Python will not allow string to be used a function pointer. It is type unsafe. 
Best way is to convert string into function pointers manually.

if dynamicMethod == 'bar':
method = oFoo->bar
else:
method = oFoo->default
method()

On Friday 19 October 2007 7:56 am, Diez B. Roggisch wrote:
> Nils wrote:
> > On Oct 19, 12:39 pm, [EMAIL PROTECTED] wrote:
> >> Hello,
> >>
> >> Is there any way (other then eval) to invoke a method by passing
> >> method name in a string.
> >> It's very simple in php:
> >> $oFoo = new Foo();
> >> $dynamiMethod = "bar";
> >> $oFoo->$dynamiMethod();
> >>
> >> Unfortunately I can't find a good solution to do the same thing in
> >> python. Does it have some build-in function to do it?
> >>
> >> Kind Regards,
> >>
> >> Lukasz.
> >
> >  Use apply():
> > http://docs.python.org/lib/non-essential-built-in-funcs.html
>
> Apply doesn't help the OP - it's useful if you already have a function
> pointer.
>
> And it's obsoleted by the * and ** parameter passing mechanism.
>
> Diez
-- 
http://mail.python.org/mailman/listinfo/python-list


Use of Python in .NET

2006-06-07 Thread sushant . sirsikar
Hi,
  I am developing a code which has MVC (Model - View - Controler)
architecture.My view is in .NET. And my controller is in Python.So can
i call Python script from .NET? If yes,
 Can anybody tell me method or related documentation?
  Thanks in Advamce

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


PYTHONPATH

2006-04-20 Thread sushant . sirsikar
Hi,
  I am using Linux env.I set the PYTHONPATH using

import sys
sys.path.append()

But we i close python and start again i is not showing my new entry in
PYTHONPATH.
Can anyone help me to make my path persistant?
Thanks

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


Property In Python

2006-04-21 Thread sushant . sirsikar
Hi,
  I want to know how we can write Properties in Pyhton.Any one knows
good doc for this one?
Thanks

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


How to debug python code?

2006-03-30 Thread sushant . sirsikar
hi,
   I am new to Python programming.I am not getting exactly pdb.Can
anyone tell me effective  way to debug python code?
   Please give me any example.
   Looking for responce.
   Thank You.
Sushant

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


Best IDE for Python?

2006-03-30 Thread sushant . sirsikar
hi,
  I want to know which is the best IDE for python.Please if
possible mention the features of the IDE.
  Thank You.
Sushant

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


Get the input from user

2006-04-03 Thread sushant . sirsikar
hi,
I am doing example of address book.when user enter stop and presses
enter my loop should stop.But there is some prob in my loop.It is
accepting \r after pressing Enter key.How do i check end of input :
  addressbook={}
name = raw_input("Enter Name (stop to Finish)")

name = EnterAddress(addressbook)

ShowAddress(name, addressbook)

def ShowAddress(name, addressbook):
name = raw_input("Enter Name for Address ")
print "Address of %s is %s" %(name,addressbook[name])

def EnterAddress(addressbook):
while name != "stop":
entry = raw_input("Enter the address")
addressbook[name]=entry
name = raw_input("Enter Name (Leave blank to Finish)")
return name

thanks
Sushant

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


Re: using range() in for loops

2006-04-04 Thread sushant . sirsikar
hi John,
 Python doesn't provide for loop like C / C++ but using Range() or
Xrange() you can achive all the functionalities of the C for loop.If
you wants distributed for loop You can use Xrange.
John Salerno wrote:
> I'm reading Text Processing in Python right now and I came across a
> comment that is helping me to see for loops in a new light. I think
> because I'm used to the C-style for loop where you create a counter
> within the loop declaration, for loops have always seemed to me to be
> about doing something a certain number of times, and not about iterating
> over an object.
>
> The reason for this distinction comes from the fact that I read a lot
> how using range and for is somewhat discouraged, because it doesn't
> really use a for loop for it's true purpose. So my question is, is this
> just a Python-oriented opinion about for loops, or is it a general idea?
>
> Also, what if you *do* need to just do something a set number of times.
> Is this okay, or does it mean you are approaching the problem
> incorrectly? Using for and range together seems to be a common idiom,
> yet at the same time discouraged, so I'm wondering what is a good balance.
> 
> Thanks.

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


Re: Strange problem when running python code

2006-04-04 Thread sushant . sirsikar
Are U Using any IDE for Python?
If yes then check out the setting and make sure that u are running same
code.

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


Extending Python

2006-04-04 Thread sushant . sirsikar
Hi All.
We can extend the functionality of python using C,C++.I want to
know what are the other lang that we can use to extend the
functionality of Python?
Bye

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


``pickling'' and ``unpickling''

2006-04-05 Thread sushant . sirsikar
Hi,
  I am new in Python World.I want to know what is mean by ``pickling''
and ``unpickling'' ?
And how can we used it?Please Give Me some links of Picking Examples.
  Thanks

Sushant

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


Re: good style guides for python-style documentation ?

2006-04-06 Thread sushant . sirsikar

Fredrik Lundh wrote:
> (reposted from doc-sig, which seems to be mostly dead
> these days).
>
> over at the pytut wiki, "carndt" asked:
>
> Are there any guidelines about conventions concerning
> punctuation, text styles and language style (e.g. how
> to address the reader)?
>
> any suggestions from this list ?
>
> 
Hi
 You can read the document given in link:
Documenting Python http://docs.python.org/dev/doc/style-guide.html 
Bye

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