Hi Friends,

How to use getchar( ) in python. I want to see the output of the program ,step by step.
I have given print statements in between for the results..
Hence i would like to print the output everytime there is getchar().which is the
similar fn in python

thanks,
Santosh





On 11/6/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
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..."


Today's Topics:

   1. Re: Learning Python (Jorge Vargas)
   2. Problem with XML-RPC not mounted in / (Almad)
   3. Re: Python Distilled (Marc 'BlackJack' Rintsch)
   4. Re: Creating db front end or middleware. (Bruno Desthuilliers)
   5. Re: Python Distilled (Georg Brandl)
   6. Re: Python Distilled (Jorge Godoy)
   7. Re: simple way to un-nest (flatten?) list (Steven D'Aprano)
   8. Re: Python Distilled (Paul McGuire)
   9. RE: Classes referencing each other (Ryan Ginstrom)
  10. Re: forwarding *arg parameter (Steven D'Aprano)
  11. Re: Is there any python lib for calling CVS api? (Paul Boddie)



---------- Forwarded message ----------
From: "Jorge Vargas" < [EMAIL PROTECTED]>
To: ArdPy <[EMAIL PROTECTED]>
Date: Mon, 6 Nov 2006 09:54:26 +0000
Subject: Re: Learning Python
On 6 Nov 2006 01:33:36 -0800, ArdPy <[EMAIL PROTECTED]> wrote:
>
> kaushal wrote:
> > Hi
> >
> > How do i start Learning Python,is there any reference material which I
> > can refer since I dont have
> > any programming experience
> >
> > Thanks and Regards
> >
> > Kaushal
>
> Hi kaushal,
>
> Look into http://diveintopython.org. Dive into python is a really
> readable ebook...enjoy
>
Even though that's a great book I don't recomend it for non
programmers I think this http://docs.python.org/tut/ is a better way
to start

also I'll suggest you start learning other programming languaje before
python or else this will be the only one you will code :)

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




---------- Forwarded message ----------
From: "Almad" < [EMAIL PROTECTED]>
To: python-list@python.org
Date: 6 Nov 2006 02:04:12 -0800
Subject: Problem with XML-RPC not mounted in /
Hi,

I'm trying to build XML-RPC service, both server and client library.

My server is CherryPy with XML-RPC filter. I have here method
registration_ip. When it's in, say http://ws.rpgplanet.nerv/,
everything is OK, but when I move it in http://ws.rpgplanet.nerv/main/,
this behaviour occur:

srv = ServerProxy('http://ws.rpgplanet.nerv/main/')
print srv.register_ip("guest")

raises 404, as according to log, library is trying to access /main/
instead of /main/register_ip

srv = ServerProxy('http://ws.rpgplanet.nerv/')
print srv.main.register_ip("guest")

raises 500, as client is correctly hitting /main/register_ip, but NOT
sending "guest" argument.

I'm probably missing something obvious, so where should problem be? Is
it not possible for XML-RPC to live not in / ?

Thank You for advices,

Almad





---------- Forwarded message ----------
From: Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]>
To: python-list@python.org
Date: Mon, 06 Nov 2006 11:11:41 +0100
Subject: Re: Python Distilled
In <[EMAIL PROTECTED]>, Simon Wittber
wrote:

> I'd also like to remove any deprecated or stuff which is left in for
> backwards functionality (eg Classic classes).

Classic classes are still needed for exceptions:

>>> class E(object):
...    pass
...
>>> raise E
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: exceptions must be classes, instances, or strings (deprecated),
not type

Ciao,
        Marc 'BlackJack' Rintsch




---------- Forwarded message ----------
From: Bruno Desthuilliers <[EMAIL PROTECTED]>
To: python-list@python.org
Date: Mon, 06 Nov 2006 11:19:47 +0100
Subject: Re: Creating db front end or middleware.
tobiah wrote:
> Let's say I want to write a new tool to do
> something to, or report on people in a database.
> Each tool is going to have to have all sorts of
> routines that know about the relationship between
> the data.  The first thought is to write a library
> of routines that do things like, change_address(),
> or fire_employee() or whatever.
> Whoops, now we've decided to move to python.  I
> have to write all of that again.
>
> So I thought, shouldn't there be a cloud that sits
> in front of the database to which I can ask these
> services of?  Some process that awaits requests for
> information, or handles new incoming data.  Now new
> apps written in any language should be able to use a basic protocol in
> order to get the work done.
>
> The question then, is what the best way to do this is.

The first question then is: do you really need a middleware ? Most
RDBMSs are already full-blown server applications - with support for
authentification, permissions, triggers and stored procedures - that can
be accessed by client programs in almost any language.

Now if you effectively want/need a web service, it seems that the
canonical solutions are XMLRPC and SOAP. But if you already use a RDBMS,
this web service should IMHO mostly be designed as an higher-level
interface to the RDBMS, not as a full-blown app managing domain/business
rules (which is the job of the RDBMS). IOW, it should be still possible
for applications to directly interact with the RDBMS.

> First I thought of using cherrypy to sit and listen to
> POST requests, but this would make passing complex structures
> extremely inconvenient.

There are XMLRPC packages for most languages, that knows how to do the
native data structure <-> XMLRPC translation. Python has both client and
server packages in the standard lib.

>  Then I thought about WSDL.
> Would this be the next logical step, or is this more for
> allowing different companies to communicate with each other
> when there needs to be a broadcast description of the interface?

As the name implies, W(eb) S(ervice) D(escription) L(anguage) is meant
to describe a given web service - and says nothing about implementation.

My 2 cents
--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in ' [EMAIL PROTECTED]'.split('@')])"




---------- Forwarded message ----------
From: Georg Brandl <[EMAIL PROTECTED]>
To: python-list@python.org
Date: Mon, 06 Nov 2006 11:26:11 +0100
Subject: Re: Python Distilled
Marc 'BlackJack' Rintsch wrote:
> In < [EMAIL PROTECTED]>, Simon Wittber
> wrote:
>
>> I'd also like to remove any deprecated or stuff which is left in for
>> backwards functionality (eg Classic classes).
>
> Classic classes are still needed for exceptions:
>
>>>> class E(object):
> ...    pass
> ...
>>>> raise E
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> TypeError: exceptions must be classes, instances, or strings (deprecated),
> not type

The error is a bit misleading, since in Python 2.5 all exceptions are new-style,
but new exception classes must be derived from an existing one.
Classic classes, their instances and strings are only allowed for backwards
compatibility.

Georg




---------- Forwarded message ----------
From: Jorge Godoy < [EMAIL PROTECTED]>
To: python-list@python.org
Date: Mon, 06 Nov 2006 08:29:49 -0200
Subject: Re: Python Distilled
Marc 'BlackJack' Rintsch < [EMAIL PROTECTED]> writes:

> In <[EMAIL PROTECTED]>, Simon Wittber
> wrote:
>
>> I'd also like to remove any deprecated or stuff which is left in for
>> backwards functionality (eg Classic classes).
>
> Classic classes are still needed for exceptions:
>
>>>> class E(object):
> ...    pass
> ...
>>>> raise E
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> TypeError: exceptions must be classes, instances, or strings (deprecated),
> not type

On the other hand...

>>> import exceptions
>>> class E(exceptions.Exception):
...     pass
...
>>> raise E
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
__main__.E
>>>


This also has the advantage to let it explicit in the code that E is an
exception.


--
Jorge Godoy      <[EMAIL PROTECTED]>




---------- Forwarded message ----------
From: Steven D'Aprano <[EMAIL PROTECTED]>
To: python-list@python.org
Date: Mon, 06 Nov 2006 21:43:13 +1100
Subject: Re: simple way to un-nest (flatten?) list
On Sun, 05 Nov 2006 21:43:33 +0000, djc wrote:

> There is I am sure an easy way to do this, but I seem to be brain dead
> tonight. So:
>
> I have a table such that I can do
>
>   [line for line  in table if line[7]=='JDOC']
> and
>   [line for line  in table if line[7]=='Aslib']
> and
>   [line for line  in table if line[7]=='ASLIB']
> etc
>
> I also have a dictionary
>   r=  {'a':('ASLIB','Aslib'),'j':('JDOC', 'jdoc')}
> so I can extract values
> r.values()
> [('ASLIB', 'Aslib'), ('JDOC', 'jdoc')]
>
> I would like to do
>
> [line for line  in table if line[7] in ('JDOC','jdoc','Aslib','ASLIB')]

What is the purpose of the "if line[7]" bit?



> so how should I get from
> {'a':('ASLIB','Aslib'),'j':('JDOC','jdoc')}
> to
> ('Aslib','ASLIB','JDOC','jdoc')


Assuming you don't care what order the strings are in:

r = {'a':('ASLIB','Aslib'),'j':('JDOC','jdoc')}
result = sum(r.values(), ())

If you do care about the order:

r = {'a':('ASLIB','Aslib'),'j':('JDOC','jdoc')}
keys = r.keys()
keys.sort()
result = []
for key in keys:
    result.extend(r[key])
result = tuple(result)


--
Steven.





---------- Forwarded message ----------
From: "Paul McGuire" <[EMAIL PROTECTED]>
To: python-list@python.org
Date: Mon, 06 Nov 2006 10:36:34 GMT
Subject: Re: Python Distilled
"Marc 'BlackJack' Rintsch" <[EMAIL PROTECTED]> wrote in message
news: [EMAIL PROTECTED]
> In <[EMAIL PROTECTED]>, Simon Wittber
> wrote:
>
>> I'd also like to remove any deprecated or stuff which is left in for
>> backwards functionality (eg Classic classes).
>
> Classic classes are still needed for exceptions:
>
>>>> class E(object):
> ...    pass
> ...
>>>> raise E
> Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
> TypeError: exceptions must be classes, instances, or strings (deprecated),
> not type
>
> Ciao,
> Marc 'BlackJack' Rintsch

I thought exceptions were converted to new-style classes for Py2.5
(http://docs.python.org/whatsnew/pep-352.html ).  I've not upgraded yet, so
cannot easily test this - under what version of Python was your posted code
run?

-- Paul






---------- Forwarded message ----------
From: "Ryan Ginstrom" < [EMAIL PROTECTED]>
To: <python-list@python.org>
Date: Mon, 6 Nov 2006 18:39:37 +0900
Subject: RE: Classes referencing each other
> Behalf Of Manuel Bleichner
> In a module I have a huge number of classes of the form:
>
> class A(object):
>    connected_to = [B, C]
>    <other attributes...>
>
> class B(object)
>    connected_to = [C]
>    <other attributes...>
>
> class C(object)
>    connected_to = [A]
>    <other attributes...>
>
> As you see, classes A and B reference classes that are not
> yet defined when the class is being defined.
> It will raise a NameError: 'B'.

How about a connection broker?

Simple example:

#############################
connections = {}

def Register( obj ):
        try:
                connections[obj.name]['obj'] = obj
        except KeyError:
                connections[obj.name] = { 'obj' : obj, 'connected_to' : [] }

def ConnectTo( objname, obj ):
        try:
                connections[objname]['connected_to'].append( obj )
        except KeyError:
                connections[objname] = { 'obj' : None, 'connected_to' :
[obj] }

class ConnectionObject:
        def __str__(self):
                return self.name

class A(ConnectionObject):
    def __init__(self):
         self.name = 'A'
        Register( self )
        ConnectTo( 'B', self )


class B(ConnectionObject):
    def __init__(self):
        self.name = 'B'
        Register( self )
        ConnectTo( 'A', self )
        ConnectTo( 'C', self )


class C(ConnectionObject):
    def __init__(self):
        self.name = 'C'
        Register( self )
        ConnectTo( 'A', self )


a = A()
b = B()
c = C()


for (key, val) in connections.iteritems():
    print 'object: %s (%s)' % ( key, val['obj'] )
    str_vals = []
    for obj in val['connected_to']:
        str_vals.append( str( obj ) )
    print '\tconnections from:', str_vals

#############################
Output:

object: A (A)
        connections from: ['B', 'C']
object: C (C)
        connections from: ['B']
object: B (B)
        connections from: ['A']
object: D (None)
        connections from: ['C']

Regards,
Ryan Ginstrom





---------- Forwarded message ----------
From: Steven D'Aprano < [EMAIL PROTECTED]>
To: python-list@python.org
Date: Mon, 06 Nov 2006 22:00:28 +1100
Subject: Re: forwarding *arg parameter
On Sun, 05 Nov 2006 19:35:58 +0000, Tuomas wrote:

> Thanks. My solution became:
>
>  >>> def flattern(arg):
> ...     result = []
> ...     for item in arg:
> ...         if isinstance(item, (list, tuple)):
> ...             result.extend(flattern(item))
> ...         else:
> ...             result.append(item)
> ...     return tuple(result)
> ...
>  >>> def g(*arg):
> ...     arg = flattern(arg)
> ...     return arg
> ...
>  >>> def f(*arg):
> ...     return g(arg)
> ...
>  >>> f('foo', 'bar')
> ('foo', 'bar')


That's the most complicated do-nothing function I've ever seen. Here is a
shorter version:

def shortf(*args):
    return args


>>> f('foo', 'bar')
('foo', 'bar')
>>> shortf('foo', 'bar')
('foo', 'bar')

>>> f(1,2,3,4)
(1, 2, 3, 4)
>>> shortf(1,2,3,4)
(1, 2, 3, 4)

>>> f({}, None, 1, -1.2, "hello world")
({}, None, 1, -1.2, 'hello world')
>>> shortf({}, None, 1, -1.2, "hello world")
({}, None, 1, -1.2, 'hello world')

Actually, they aren't *quite* identical: your function rips lists apart,
which is probably not a good idea.

>>> f("foo", [1,2,3], None) # three arguments turns into five
('foo', 1, 2, 3, None)
>>> shortf("foo", [1,2,3], None) # three arguments stays three
('foo', [1, 2, 3], None)



I still don't understand why you are doing this. Can we have an example of
why you think you need to do this?



--
Steven.





---------- Forwarded message ----------
From: "Paul Boddie" <[EMAIL PROTECTED] >
To: python-list@python.org
Date: 6 Nov 2006 02:55:09 -0800
Subject: Re: Is there any python lib for calling CVS api?
[EMAIL PROTECTED] wrote:
> Hi everyone, this should be a quick question.  I'm writing some scripts
> to take some file and move them into a CVS repository, but it's pretty
> slow, because it uses system calls to execute the CVS commands.

[...]

> anyway, if anyone knows of a useful module, I'd love to hear about it.

You might get some ideas from ViewVC if you're accessing the repository
directly:

http://www.viewvc.org/

There may be scripts out there which import data from various other
revision control systems into CVS, although the focus these days seems
to be on *exporting* data from CVS and putting it into things like
Subversion, Bazaar, Mercurial and so on, but I believe the scripts for
the latter two are Python programs and may also provide some
inspiration.

Paul




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


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

Reply via email to