tutor-requ...@python.org 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 > tutor-requ...@python.org > >You can reach the person managing the list at > tutor-ow...@python.org > >When replying, please edit your Subject line so it is more specific >than "Re: Contents of Tutor digest..." > > >Today's Topics: > > 1. Re: Having a return when subprocess.Popen finishes (Nick Raptis) > 2. Re: Having a return when subprocess.Popen finishes (Payal) > 3. Re: Django Read (Huy Ton That) > 4. Re: differences between mmap and StringIO (Christopher King) > 5. Re: Tkinter mainloop() (Francesco Loffredo) > > >---------------------------------------------------------------------- > >Message: 1 >Date: Thu, 08 Jul 2010 16:33:02 +0300 >From: Nick Raptis <airsc...@otenet.gr> >To: tutor@python.org >Subject: Re: [Tutor] Having a return when subprocess.Popen finishes >Message-ID: <4c35d38e.4090...@otenet.gr> >Content-Type: text/plain; charset=ISO-8859-1; format=flowed > >subprocess.Popen is a class, and as such it returns an object which can >do a lot of stuff besides just reading the output. > >What you want to do here is using it's communicate() method as such: > >output, errors = ping.communicate() > > >Also, there is a quicker way, I think from version 2.7 forward: use the >shortcut >output = subprocess.check_output("your command here") > >Always check latest documentation for your python version too >http://docs.python.org/library/subprocess.html > >Nick > >On 07/08/2010 04:04 PM, Paul VanGundy wrote: >> Hi All, >> >> I'm trying to get data from subprocess.Popen. To be specific, I am >> trying to read a ping echo and take the output and assign it to a >> variable like below: >> >> ping = subprocess.Popen("ping -c 5 %s" % (server), >> stdout=subprocess.PIPE, shell=True) >> >> However, when I run the command the output that gets assigned to my ping >> variable is something along the lines of '<subprocess.Popen object at >> 0x9524bec>' and am not returned to>>> prompt. I know that is the proper >> output but I need to be able to capture the ping replies and assign >> those to a variable. I tried adding a \r and \n at the end of my cmd. >> Any help would be greatly appreciated. I'm open to improvements, >> different ways of doing it and corrections. :) If more info is needed >> let me know. Thanks. >> >> /paul >> _______________________________________________ >> Tutor maillist - Tutor@python.org >> To unsubscribe or change subscription options: >> http://mail.python.org/mailman/listinfo/tutor >> >> >> > > >------------------------------ > >Message: 2 >Date: Thu, 8 Jul 2010 06:39:51 -0700 >From: Payal <payal-pyt...@scriptkitchen.com> >To: tutor@python.org >Subject: Re: [Tutor] Having a return when subprocess.Popen finishes >Message-ID: <20100708133951.ga4...@scriptkitchen.com> >Content-Type: text/plain; charset=us-ascii > >On Thu, Jul 08, 2010 at 09:04:54AM -0400, Paul VanGundy wrote: >> Hi All, >> >> I'm trying to get data from subprocess.Popen. To be specific, I am >> trying to read a ping echo and take the output and assign it to a >> variable like below: >> >> ping = subprocess.Popen("ping -c 5 %s" % (server), >> stdout=subprocess.PIPE, shell=True) > >>>> import subprocess >>>> server = 'localhost' >>>> ping = subprocess.Popen("ping -c 5 %s" % >>>> (server),stdout=subprocess.PIPE, shell=True) >>>> ping.communicate() >('PING localhost (127.0.0.1) 56(84) bytes of data.\n64 bytes from >localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.044 ms\n64 bytes from >localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.046 ms\n64 bytes from >localhost (127.0.0.1): icmp_seq=3 ttl=64 time=0.052 ms\n64 bytes from >localhost (127.0.0.1): icmp_seq=4 ttl=64 time=0.046 ms\n64 bytes from >localhost (127.0.0.1): icmp_seq=5 ttl=64 time=0.049 ms\n\n--- localhost >ping statistics ---\n5 packets transmitted, 5 received, 0% packet loss, >time 3997ms\nrtt min/avg/max/mdev = 0.044/0.047/0.052/0.006 ms\n', None) >>>> > >hth, >With warm regards, >-Payal >-- > > > >------------------------------ > >Message: 3 >Date: Thu, 8 Jul 2010 10:19:38 -0400 >From: Huy Ton That <huyslo...@gmail.com> >To: Jeff Johnson <j...@dcsoftware.com> >Cc: tutor@python.org >Subject: Re: [Tutor] Django Read >Message-ID: > <aanlktik4qwufimjc3-gr4y4wx36pkhuiayjbpt-lm...@mail.gmail.com> >Content-Type: text/plain; charset="iso-8859-1" > >I've went through the djangobook myself, and found it quite readable. This >would be my recommendation as well. > >Be sure to read the sidebar comments; if you ever feel stuck, someone else >may have addressed the question/answer for you! > >-Lee > >On Thu, Jul 8, 2010 at 9:31 AM, Jeff Johnson <j...@dcsoftware.com> wrote: > >> On 07/08/2010 06:06 AM, Nick Raptis wrote: >> >>> There actually aren't that many books on django around yet which is a >>> pity. >>> You should definitely read "The django book": >>> http://www.djangobook.com/en/2.0/ >>> either on the online version on that link, or it's printed counterpart >>> (yes, it's really the same book): >>> http://www.amazon.com/Definitive-Guide-Django-Development-Second/dp/143021936X/ >>> >>> The printed one is a bit more updated (1.1) and pays off it's money >>> because of it's great reference section :) >>> >>> Nick >>> >>> On 07/08/2010 03:48 PM, Dipo Elegbede wrote: >>> >>>> Hi all, >>>> >>>> I have done a little basic on python and have to start working on a >>>> major django platform. >>>> I'm starting new and would like recommendations on books I can read. >>>> >>>> Kindly help me out. I want to get my hands dirty as fast as I can so >>>> that I can be part of the project. >>>> >>>> Thanks and Best regards, >>>> >>>> >>> I have six books on my bookshelf for Django. There are others I don't >> have. Django 1.0 Template Development is my favorite. Many of them walk >> you through building apps step by step. Do a search on Amazon. That is >> where I got most of them. >> >> -- >> Jeff >> >> ------------------- >> >> Jeff Johnson >> j...@dcsoftware.com >> >> >> >> _______________________________________________ >> Tutor maillist - Tutor@python.org >> To unsubscribe or change subscription options: >> http://mail.python.org/mailman/listinfo/tutor >> >-------------- next part -------------- >An HTML attachment was scrubbed... >URL: ><http://mail.python.org/pipermail/tutor/attachments/20100708/ebcdec1c/attachment-0001.html> > >------------------------------ > >Message: 4 >Date: Thu, 8 Jul 2010 18:39:33 -0400 >From: Christopher King <g.nius...@gmail.com> >To: Eduardo Vieira <eduardo.su...@gmail.com> >Cc: Tutor Mailing List <tutor@python.org> >Subject: Re: [Tutor] differences between mmap and StringIO >Message-ID: > <aanlktin1yibq5bioozu95nylv_fgrcvuwrhwthkpn...@mail.gmail.com> >Content-Type: text/plain; charset="iso-8859-1" > >Well, I would just use the builting function open. I think Nick said in the >beggining. Or, I would use the module I created. It's a file object, with >the property file_txt. Unlike the other modules which you have to use read >and write methods, I made a method which allows you to manulipulate like a >string. I didn't even add a appending feature, but doing file.file_txt += >'bla', you can append. I can send it to you if you like. > >On Wed, Jul 7, 2010 at 6:52 PM, Eduardo Vieira <eduardo.su...@gmail.com>wrote: > >> Hello, I'm getting confused about the usage of those 2 modules. Which >> should I use one to get/manipulate data from a text file? >> >> Regards, >> >> Eduardo >> www.express-sign-supply.com >> _______________________________________________ >> Tutor maillist - Tutor@python.org >> To unsubscribe or change subscription options: >> http://mail.python.org/mailman/listinfo/tutor >> >-------------- next part -------------- >An HTML attachment was scrubbed... >URL: ><http://mail.python.org/pipermail/tutor/attachments/20100708/45f9c016/attachment-0001.html> > >------------------------------ > >Message: 5 >Date: Thu, 08 Jul 2010 20:40:36 +0200 >From: Francesco Loffredo <ilcomputertraspare...@gmail.com> >To: tutor@python.org >Subject: Re: [Tutor] Tkinter mainloop() >Message-ID: <4c361ba4.4050...@libero.it> >Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > > >Il 07/07/2010 9.11, Alan Gauld wrote: >> >> "Francesco Loffredo" <ilcomputertraspare...@gmail.com> wrote >> >>> ... What's the >>> difference between the two methods? >> >> Its a little bit subtle but I believbe update() updates all widgets >> whereas update_idle_tasks will only update those widgets that >> have changed since the last update. In a complex GUI this can >> be notably faster. Most of the books I've seen recommend not >> using update() as it can cause race conditions but I have no experience >> of that - because I use update_idle_tasks! :-) > >Ok, now I'm using update_idletasks() too (update_idle_tasks() doesn't >exist) and I like it. Thanks a lot! > >> ... > >>> where would you put the >>> automatic move call, if not where I did? I need an automatic move be >>> performed at the proper moment, when it's the computer player turn. >> >> Create the auto move in an event handler of its own and associate >> with an event. Then raise that event when your players move is finished. >> Tkinter will then call the automove for you, updating the screeen >> automatically. In an event driven environment control is passed >> around by means of events. >I prefer not to make this project fully event driven, because while it's >fairly easy to translate a mouse click into the game coordinates of the >hex that's being clicked, I don't like translating a pair of integers to >some point (maybe the center) of an hexagon, creating an Event >structure, raising that Event and handling it, just to figure out...the >same couple of integers I started with. No, I prefer not to create fake >Events when there's none involved... at least in this little game. I'll >remember your advice for some serious project! >> >> How do you raise an event in Tkinter? >> Use the event_generate() method. >And this would have been my next question, thanks for mind-reading! >> >> Alternatively use the after() method with a short delay - say 10ms... >That's what I actually did. It plays like a charm! THANK YOU! >> >> HTH, > SID! > >Francesco > > >------------------------------ > >_______________________________________________ >Tutor maillist - Tutor@python.org >http://mail.python.org/mailman/listinfo/tutor > > >End of Tutor Digest, Vol 77, Issue 25 >************************************* _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor