Is there any work done in language convirsion from endlish to hindi and vice versa
please let me know

[EMAIL PROTECTED] wrote:
Send Tutor mailing list submissions to
tutor@python.org

To subscribe or unsubscribe via the World Wide Web, visit
http://mail.python.org/mailman/listinfo/tutor
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 Tutor digest..."


Today's Topics:

1. Re: Did anyone get the Kamaelia "Conversing" chapter 5 to
work? (R. Alan Monroe)
2. Importing Modules Within Classes (Daniel Watkins)
3. Re: Did anyone get the Kamaelia "Conversing" chapter 5 to
work? (Michael Sparks)
4. Re: Did anyone get the Kamaelia "Conversing" chapter 5 to
work? (R. Alan Monroe)
5. Matching dictionary entries by partial key
(William O'Higgins Witteman)
6. Re: Importing Modules Within Classes (Kent Johnson)
7. Re: Matching dictionary entries by partial key (Kent Johnson)
8. Simple Tkinter question (Mike Cheponis)
9. Re: Matching dictionary entries by partial key (Danny Yoo)
10. Re: Simple Tkinter question (Danny Yoo)


----------------------------------------------------------------------

Message: 1
Date: Thu, 6 Oct 2005 19:45:10 -0400
From: "R. Alan Monroe" <[EMAIL PROTECTED]>
Subject: Re: [Tutor] Did anyone get the Kamaelia "Conversing" chapter
5 to work?
To: tutor@python.org
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=us-ascii

>> I can see in Pythonwin's debugger that p.boxes['outbox'] fills up with
>> the hundred or so messages intended for display, but they never get
>> displayed. I suspect an indentation problem, but I can't spot it, even
>> stepping through! in the debugger.

> I made exactly the same mistake! You have to put an infinite loop in
> postman.main(). It's in the directions but I guess it's easy to
> miss.

Bingo, you da man.

Alan



------------------------------

Message: 2
Date: Fri, 07 Oct 2005 01:18:24 +0100
From: "Daniel Watkins" <[EMAIL PROTECTED]>
Subject: [Tutor] Importing Modules Within Classes
To:
Message-ID:
<[EMAIL PROTECTED]>
Content-Type: text/plain; charset="iso-8859-1"

Recently, there has been an example of someone importing modules within
a class definition. eg:

class Exemplar:
import re
...use re...

It seems obvious to me that this is incorrect, though more through
training than actual observation on my part, and it should be:

import re

class Exemplar:
...use re...

However, someone (I don't recall who) sai! d that there were occasions
when it would be appropriate to import modules the former way. I was
just wondering under what circumstances importing should be done this
way?

Cheers,
Dan



------------------------------

Message: 3
Date: Fri, 7 Oct 2005 02:23:32 +0100
From: Michael Sparks <[EMAIL PROTECTED]>
Subject: Re: [Tutor] Did anyone get the Kamaelia "Conversing" chapter
5 to work?
To: "R. Alan Monroe" <[EMAIL PROTECTED]>, tutor@python.org
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset="utf-8"

On Friday 07 October 2005 00:13, R. Alan Monroe wrote:
...
> I can see in Pythonwin's debugger that p.boxes['outbox'] fills up with
> the hundred or so messages intended for display, but they never get
> displayed. I suspect an indentation problem, but I can't spot it, even
> stepping through in the debugger.

Hi!

First of all ! thanks for trying the tutorial - hope it's been interesting. I'm
sorry you hit a problem with it - it looks like the HTML formatting has
caused some issues :-(

All the code and examples used were tested before the being placed into the
"tabbed" version of the tutorial. In this case it looks like the whitespace
has gone horribly horribly wrong on that tab :-((( I'll sort it out.

In the meantime though, In case of precisely this problem occuring, I also
placed that source for all 4 main sections (Standing, Walking, Talking,
Conversing) in the following page here:

http://kamaelia.sourceforge.net/MiniAxonFull.html

I've just double checked what happens when running the contents of that
page, and it works as expected (here at least), so I suspect the problems
you're seeing are simply due to "code being in HTML" issues.

Also, the entire tutorial is available as a single page here, rather than
tabbed:
* http://kamaelia.sourceforge.net/MiniAxon.html

But that has the answers inline, which is why I didn't mention it before. That
*does* appear to have formatting preserved correctly in firefox, and I've
also just double checked that when copying and pasting that the stated
results were the ones stated.

Hoping this helps, and thanks! If you're willing to spare a few sentances of
how you found the tutorial (on or off list), I'd be really interested in
hearing. If it's difficult, what was difficult (naff HTML for example...), if
it was clear/unclear, that sort of thing. That said, this query is useful
feedback in itself :)

Best Regards, (and apologies for the HTML formatting ... :-(


Michael.
--
Michael Sparks, Senior R&D Engineer, Digital Media Group
[EMAIL PROTECTED], http://kamaelia.sourceforge.net/
British Broadcasting Corporation, Research and Development
Kingswood Warren, Surrey KT20 6NP

This e-mail may contain personal views which are not the views of the BBC.


------------------------------

Message: 4
Date: Thu, 6 Oct 2005 22:04:43 -0400
From: "R. Alan Monroe" <[EMAIL PROTECTED]>
Subject: Re: [Tutor] Did anyone get the Kamaelia "Conversing" chapter
5 to work?
To: tutor@python.org
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=us-ascii

> I've just double checked what happens when running the contents of that
> page, and it works as expected (here at least), so I suspect the problems
> you're seeing are simply due to "code being in HTML" issues.

Yeah I was writing as much as I was able on my own rather than
copying/pasting the code, so it was mainly an oversight in my own
work.

Alan



------------------------------

Message: 5
Date: Thu, 6 Oct 2005 22:08:02 -0400
From: William O'Higgins ! Witteman <[EMAIL PROTECTED]>
Subject: [Tutor] Matching dictionary entries by partial key
To: tutor@python.org
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset="us-ascii"

I'm trying to traverse a dictionary looking for partial matches of the
key, and I'm not sure how. Here's a sample dictionary:

dict = {00001234 : value1, 20051234 : value2, 20071234 : value3}

Here's what I'm trying to do:

for key in dict:
if key == 0000???? or key == 2005????:
do something with dict[key]

The challenge is that I only care about the first four digits of the key
for the purpose of this match - is there a way to express this? I could
probably create a wrapper dictionary using just the first four digits of
the key as they key, and containing the original key:value pair as a
list within it, but that seems cumbersome. Any one have a suggestion?
Thanks.
--

yours,

William

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mail.python.org/pipermail/tutor/attachments/20051006/7007a205/attachment-0001.pgp

------------------------------

Message: 6
Date: Thu, 06 Oct 2005 22:21:21 -0400
From: Kent Johnson <[EMAIL PROTECTED]>
Subject: Re: [Tutor] Importing Modules Within Classes
Cc: tutor@python.org
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Daniel Watkins wrote:
> Recently, there has been an example of someone importing modules within
> a class definition. eg:
>
> class Exemplar:
> import re
> ...use re...
>
> It seems obvious to me that this is incorrect, though more through
> training than actual observation on! my part, and it should be:
>
> import re
>
> class Exemplar:
> ...use re...

It's not really incorrect, it is legal syntax and it will do what you expect. It is not idiomatic and in general it is simpler to just put all the imports at the top.

> However, someone (I don't recall who) said that there were occasions
> when it would be appropriate to import modules the former way. I was
> just wondering under what circumstances importing should be done this
> way?

That was me. I nest imports quite frequently in Jython code where the first import of a module is fairly expensive in time. Putting the import in the function that needs it delays the import and perhaps the module won't be imported at all.

import is an executable statement. When it runs, the interpreter first looks to see if the module has already been imported. If so, the existing module is bound to the import name in the current namespace. If the! module has not yet been imported, it is loaded *and executed*, then bound to the name in the current namespace.

So if module A imports B which imports C and D, then importing A will also load and execute B, C and D. If any of these are time-consuming you may want to defer them.

I found with my Jython programs that I could shorten start-up time quite a bit by deferring some imports until they were needed.

Another reason for the nested style of imports is to resolve problems with circular imports. There are some subtle problems that can occur when A imports B and B imports A. By nesting one of the imports you can defer it and sometimes avoid the problem. In this case I think removing the circular import is a much better solution - circular dependencies are evil!

Kent
>
> Cheers,
> Dan
>
> _______________________________________________
> Tutor maillist - Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>



------------------------------

Message: 7
Date: Thu, 06 Oct 2005 22:28:23 -0400
From: Kent Johnson <[EMAIL PROTECTED]>
Subject: Re: [Tutor] Matching dictionary entries by partial key
Cc: tutor@python.org
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

William O'Higgins Witteman wrote:
> I'm trying to traverse a dictionary looking for partial matches of the
> key, and I'm not sure how. Here's a sample dictionary:
>
> dict = {00001234 : value1, 20051234 : value2, 20071234 : value3}
>
> Here's what I'm trying to do:
>
> for key in dict:
> if key == 0000???? or key == 2005????:

if key.startswith('0000') or key.startswith('2005'):

or with a regular expresion:
if re.match('0000|2005', key):

> do something with dict[key]
>
>! ; The challenge is that I only care about the first four digits of the key
> for the purpose of this match - is there a way to express this? I could
> probably create a wrapper dictionary using just the first four digits of
> the key as they key, and containing the original key:value pair as a
> list within it, but that seems cumbersome. Any one have a suggestion?

If you have a *lot* of keys and need more speed, that might be a good optimization. For a small dict, just use startswith().

Kent

> Thanks.
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Tutor maillist - Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor



------------------------------

Message: 8
Date: Thu, 6 Oct 2005 20:31:59 -0700 (PDT)
From: Mike Cheponis <[EMAIL PROTECTED]>
Subject: [Tutor] Simple ! Tkinter question
To: tutor@python.org
Message-ID: <[EMAIL PROTECTED]>
Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed

I'm trying to update an Entry's textvariable several times within my Button handler, like so:

from Tkinter import *
from time import *

def my_update():
for i in range(3):
tv.set("Now it's %d"%i)
sleep(1)

root=Tk()
tv=StringVar()
Entry(textvariable=tv).pack()
tv.set("Initial Value of StringVar")
Button(text="Update", command=my_update).pack()
root.mainloop()


What happens when I hit the Update button is a 3-second pause, then "Now it's 2" is displayed.

What I expected to see in the Entry was:

"Now it's 0" (right away)
"Now it's 1" (after 1 second pause)
"Now it's 2" (after another 1 second pause)


Any idea what's going on here? Why doesn't "tv.set("") happen immediately?

Thanks, -Mike



------------------------------

Message: 9
Date: Thu, 6 Oct 2005 21:35:13 -0700 (PDT)
From: Danny Yoo <[EMAIL PROTECTED]>
Subject: Re: [Tutor] Matching dictionary entries by partial key
To: William O'Higgins Witteman <[EMAIL PROTECTED]>
Cc: tutor@python.org
Message-ID:
<[EMAIL PROTECTED]>
Content-Type: TEXT/PLAIN; charset=US-ASCII



On Thu, 6 Oct 2005, William O'Higgins Witteman wrote:

> I'm trying to traverse a dictionary looking for partial matches of the
> key, and I'm not sure how. Here's a sample dictionary:
>
> dict = {00001234 : value1, 20051234 : value2, 20071234 : value3}
>
> Here's what I'm trying to do:
>
> for key in dict:
> if key == 0000???? or key == 2005????:
> do something with dict[key]
>
> The challenge is that I only care about the first four digits of ! the key
> for the purpose of this match - is there a way to express this? I could
> probably create a wrapper dictionary using just the first four digits of
> the key as they key, and containing the original key:value pair as a
> list within it, but that seems cumbersome.

Hi William,

The dictionary (hashtable) data structure is really meant for exact key
match: it does not do partial keyword match well at all, and trying to
bend it to do so is going against its grain.

But using the first four digits as the key sounds right for your
application: from what you've told us so far, you're trying to express a
quick dictionary lookup using the first four digits as the key.

If we do take this route, doing this is not too bad, especially if we take
advantage of a dictionary's setdefault() method:

#######
>>> words = 'this is a test of the emergency broadcast system'.split()
>>> words
['t! his', 'is', 'a', 'test', 'of', 'the', 'emergency', 'broadcast',
'system']
>>>
>>> d = {}
>>> for word in words:
... d.setdefault(word[0], []).append(word)
...
>>>
>>> d
{'a': ['a'], 'b': ['broadcast'], 'e': ['emergency'], 'i': ['is'], 'o':
['of'], 's': ['system'], 't': ['this', 'test', 'the']}
#######


But as Kent mentioned, though, perhaps the easiest thing to implement is a
simple linear scan across all your key-values, and not worry until we know
this is a performance hotspot. *grin* It really depends on how many
entries we're searching against.



------------------------------

Message: 10
Date: Thu, 6 Oct 2005 21:54:01 -0700 (PDT)
From: Danny Yoo <[EMAIL PROTECTED]>
Subject: Re: [Tutor] Simple Tkinter question
To: Mike Cheponis <[EMAIL PROTECTED]>
Cc: tutor@python.org
Message-ID:
<[EMAIL PROTECTED]>
Content-Type: TEXT/PLAIN; charset=US-ASCII



On Thu, 6 Oct 2005, Mike Cheponis wrote:

> I'm trying to update an Entry's textvariable several times within my
> Button handler, like so:
>
> from Tkinter import *
> from time import *
>
> def my_update():
> for i in range(3):
> tv.set("Now it's %d"%i)
> sleep(1)
>
> root=Tk()
> tv=StringVar()
> Entry(textvariable=tv).pack()
> tv.set("Initial Value of StringVar")
> Button(text="Update", command=my_update).pack()
> root.mainloop()


Hi Mike,

The problem is that the GUI needs control back to be able to update the
GUI display. At the moment, there's only one thread of execution, and the
call to time.sleep() deprives the GUI of the control it needs to draw
things.

Tkinter has a parti! cular way of doing sleep()-like behavior that interacts
better with the GUI. We can use the "after()" method to tell the GUI to
do some action after some period of time.

Here's a quick-and-dirty example:

######
import Tkinter
root = Tkinter.Tk()
label = Tkinter.Label(root, text="hello")
label.pack()

def doCountUpdate(n):
label['text'] = n
label.after(1000, doCountUpdate, n + 1)

doCountUpdate(0)
root.mainloop()
######


The initial call to doCountUpdate() updates the label text, and then tells
the label: "after 1000 milliseconds (one second), call doCountUpdate
again, and with n+1 as its argument." After we schedule this next update,
we give control back to the GUI, and trust that the GUI will keep its
promise to call our function after the timeout period.

For reference information on this, see:

http://www.pythonware.com/library/tkinter/introduction/x9507-alarm-handlers-and-other.htm

Th! is isn't the only way to handle this sort of problem: another possible
approach involves the use of threads. But you may want to try using
'after()' first, since I think it has an easier learning curve than
threads.


Best of wishes to you!



------------------------------

_______________________________________________
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


End of Tutor Digest, Vol 20, Issue 22
*************************************


Yahoo! for Good
Click here to donate to the Hurricane Katrina relief effort.
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to