Re: [Tutor] Which Python Script Editor of Choice?
When you have you use Visual Studio, I suggest using the beautiful and wonder ViEmu. Best $90 I ever spent: http://www.viemu.com/ On Thu, Apr 3, 2008 at 2:40 PM, W W <[EMAIL PROTECTED]> wrote: > On Thu, Apr 3, 2008 at 12:15 PM, Michael Langford > <[EMAIL PROTECTED]> wrote: > > Many people who go this way, program with or without one just fine. > Those who start right away always using IDE's can just plain die when they > hit an environment where they don't have one (due to time, money, location, > or whatever). > > > > Btw, if people know of good IDE's other than PIDA that are free, run on > windows and linux and allow use of VIM as the editor, please let me know. > > I personally use VIM/vi as my editor. The best thing about using VIM > (at least when it comes to testing) is the ability to run command line > arguments from vim. > > :!python hand_grenade.py > > would run your script (assuming you started editing in whatever > directory). Auto complete (the use of works too. I've never used > an IDE aside from the MS Visual Studio for our CS I class - and I find > it to be horrible overkill, confusing, and less powerful than vim and > g++ from the command line under ubuntu. > > I suppose my method isn't an IDE, but it works for me (and so far I > don't see any reason to change, if I need to edit multiple files at a > time I can :split windows, yada yada). > > Find whatever suits you, and good luck in the hunt > -Wayne > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > -- Michael Langford Phone: 404-386-0495 Consulting: http://www.RowdyLabs.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Which Python Script Editor of Choice?
Dave Kuhlman wrote: > If you are looking for text editors, this page will give you more > choices than you want: > > http://en.wikipedia.org/wiki/Comparison_of_text_editors And this: http://wiki.python.org/moin/PythonEditors When I worked on Windows I used TextPad, it's inexpensive but not free. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Which Python Script Editor of Choice?
On Thu, Apr 03, 2008 at 11:32:54AM -0400, Jeffrey Dates wrote: > Hello, > > So as I'm starting to get into writing some scripts, I'm looking for > recommendations for a nifty script editor. Ideally a freeware/shareware > solution until I can justify a purchase of something more beefy. > > Currently I'm using PSPad, however it's pretty dumb and doesn't recognize > Python context. Which, I suppose is fine, but would be nice if there was > one. Especially since I'm learning. > If you are looking for text editors, this page will give you more choices than you want: http://en.wikipedia.org/wiki/Comparison_of_text_editors My favorites are: - Jed - Emacs - SciTE - Jedit (but only if you have lots of memory) Jed, Emacs, and SciTE are scriptable. SciTe, perhaps, is not. - Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] a pyball python app
Dean, Here's a tutorial/book that you should check out: http://www.greenteapress.com/thinkpython/ How to Think Like a (Python) Programmer by Allen B. Downey He generously has a free PDF to download, and the book makes use of some code - swampy.py I think if you 1) Read the book and try the examples, and at least try /some/ of the assignments, and 2) Examine the source code of the swampy program, you'll learn how to do exactly what you want - create two different balls (or technically, as many as you'd like/the phone will run). Good luck! -Wayne On Thu, Apr 3, 2008 at 1:16 PM, Kent Johnson <[EMAIL PROTECTED]> wrote: > dean garrad wrote: > > > i still ahving problems with the ball script this is the script at the > > moment how it stands with 1 ball working fine and i have been trying to > > add another ball to the script. > > > > i coppied the txt and added a location2 aswell as location. but it didnt > > seam to work :S > > I don't see where you added location2. > > I think you are over your head with this project. I recommend you spend > some time with a tutorial and some simpler programs, then come back to > this one. Perhaps one goal would be to understand how your current > program works. > > Kent > > > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > -- To be considered stupid and to be told so is more painful than being called gluttonous, mendacious, violent, lascivious, lazy, cowardly: every weakness, every vice, has found its defenders, its rhetoric, its ennoblement and exaltation, but stupidity hasn't. - Primo Levi ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Newb Learning Question
Exellent suggestion! thanks! On Thu, Apr 3, 2008 at 2:17 PM, Sander Sweers <[EMAIL PROTECTED]> wrote: > Should be replying to the listSorry :( > > On Thu, Apr 3, 2008 at 11:14 AM, Sander Sweers <[EMAIL PROTECTED]> > wrote: > > On Thu, Apr 3, 2008 at 8:21 AM, Jeffrey Dates <[EMAIL PROTECTED]> > wrote: > > > > > 3rd alternative: if c > 'm': print c > > > > > > > > > > > "Write a program that prints the first letter of a string that comes > after > > > 'm' in the alphabet." > > > > > > s = "this is my string" > > > for i in s: > > > if i > 'm': > > > print i > > > break > > > > One potential problem you will have is with upper case letters. > > > > >>> 'N' > 'm' > > False > > > > To make input all lower case use .lower() > > > > >>> 'N'.lower() > 'm' > > True > > > > Greets > > Sander > > > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Which Python Script Editor of Choice?
On Thu, Apr 3, 2008 at 12:15 PM, Michael Langford <[EMAIL PROTECTED]> wrote: > Many people who go this way, program with or without one just fine. Those who > start right away always using IDE's can just plain die when they hit an > environment where they don't have one (due to time, money, location, or > whatever). > > Btw, if people know of good IDE's other than PIDA that are free, run on > windows and linux and allow use of VIM as the editor, please let me know. I personally use VIM/vi as my editor. The best thing about using VIM (at least when it comes to testing) is the ability to run command line arguments from vim. :!python hand_grenade.py would run your script (assuming you started editing in whatever directory). Auto complete (the use of works too. I've never used an IDE aside from the MS Visual Studio for our CS I class - and I find it to be horrible overkill, confusing, and less powerful than vim and g++ from the command line under ubuntu. I suppose my method isn't an IDE, but it works for me (and so far I don't see any reason to change, if I need to edit multiple files at a time I can :split windows, yada yada). Find whatever suits you, and good luck in the hunt -Wayne ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Newb Learning Question
Should be replying to the listSorry :( On Thu, Apr 3, 2008 at 11:14 AM, Sander Sweers <[EMAIL PROTECTED]> wrote: > On Thu, Apr 3, 2008 at 8:21 AM, Jeffrey Dates <[EMAIL PROTECTED]> wrote: > > > > 3rd alternative: if c > 'm': print c > > > > > > "Write a program that prints the first letter of a string that comes after > > 'm' in the alphabet." > > > > s = "this is my string" > > for i in s: > > if i > 'm': > > print i > > break > > One potential problem you will have is with upper case letters. > > >>> 'N' > 'm' > False > > To make input all lower case use .lower() > > >>> 'N'.lower() > 'm' > True > > Greets > Sander > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] a pyball python app
dean garrad wrote: > i still ahving problems with the ball script this is the script at the > moment how it stands with 1 ball working fine and i have been trying to > add another ball to the script. > > i coppied the txt and added a location2 aswell as location. but it didnt > seam to work :S I don't see where you added location2. I think you are over your head with this project. I recommend you spend some time with a tutorial and some simpler programs, then come back to this one. Perhaps one goal would be to understand how your current program works. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Which Python Script Editor of Choice?
> > Komodo also often gets props from the "IDE People" I've known. To throw another one into the mix, ActiveState has a free/open source version of its Komodo IDE called "Komodo Edit". I downloaded it and played with it for a few minutes awhile ago. Seems pretty slick. Anyone have any first hand experience with this one? It also supports more than just Python (also does Perl, PHP, Ruby, Rails, etc.) http://www.activestate.com/Products/komodo_ide/komodo_edit.mhtml (FWIW, most of the time, I use PythonWin to edit code and a command prompt to run scripts) > Btw, if people know of good IDE's other than PIDA that are free, run on windows and linux and allow use of VIM as the editor, please let me know. Looking at Komodo Edit's page, it supports Win/Mac/Linux, has "Vi emulation", and is free (not crippled in any way that I know of. It just has a smaller feature set when compared to the full Komodo). ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Which Python Script Editor of Choice?
Asking a programmer which editor to use is like asking which religion is best. I use VIM and IPython and shell scripts (I mostly program on windows, but sometimes on Linux as well). There are several options. I'm considering looking into PIDA, which is a "IDE you make from tools you already use" but haven't had time to try to check it out on windows. Eric4 and Wingware are both very fully developed. Komodo also often gets props from the "IDE People" I've known. Other "IDE" choices go as follow, DrPython, pyCrust, emacs, VIM (has IDE addons), IronPython/VisualStudio, Boa Constrictor, and Eclipse. I do often suggest to people who are just starting out: Learn to program without an IDE, then use one after 6 mo/a year. Many people who go this way, program with or without one just fine. Those who start right away always using IDE's can just plain die when they hit an environment where they don't have one (due to time, money, location, or whatever). Btw, if people know of good IDE's other than PIDA that are free, run on windows and linux and allow use of VIM as the editor, please let me know. --Michael On Thu, Apr 3, 2008 at 11:32 AM, Jeffrey Dates <[EMAIL PROTECTED]> wrote: > Hello, > > So as I'm starting to get into writing some scripts, I'm looking for > recommendations for a nifty script editor. Ideally a freeware/shareware > solution until I can justify a purchase of something more beefy. > > Currently I'm using PSPad, however it's pretty dumb and doesn't recognize > Python context. Which, I suppose is fine, but would be nice if there was > one. Especially since I'm learning. > > My run time environment is IDLE. > > Any thoughts or preferences would be appreciated. > thanks! > > Jeffrey Dates > www.kungfukoi.com > > > > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > > -- Michael Langford Phone: 404-386-0495 Consulting: http://www.RowdyLabs.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] a pyball python app
hi i signed onto the site it asked me to. :). can i talk to ya now more ? im not sure if i am in wrong place to send e mail to you still i still ahving problems with the ball script this is the script at the moment how it stands with 1 ball working fine and i have been trying to add another ball to the script. i coppied the txt and added a location2 aswell as location. but it didnt seam to work :S import appuifw from graphics import * import e32 import sensor class SensorConnection(object): delta = [] def __init__(self): """Connect to the sensor.""" sens = sensor.sensors()['AccSensor'] self.s = sensor.Sensor(sens['id'], sens['category']) self.s.connect(self.callme) def callme(self, state): self.delta = [] for key in ['data_1', 'data_2', 'data_3']: val = state[key] self.delta.append(int(val + 40)/80) def cleanup(self): """Cleanup after yourself. *Must be called* before exiting.""" self.s.disconnect() sense_conn = SensorConnection() appuifw.app.screen='full' img=None def handle_redraw(rect): if img: canvas.blit(img) appuifw.app.body=canvas=appuifw.Canvas( redraw_callback=handle_redraw) img=Image.new(canvas.size) running=1 def quit(): global running running=0 appuifw.app.exit_key_handler=quit location=[img.size[0]/2,img.size[1]/2] speed=[0.,0.] blobsize=16 xs,ys=img.size[0]-blobsize,img.size[1]-blobsize acceleration=0.05 friction = 0.993 import time start_time=time.clock() n_frames=0 # To speed things up, we prerender the text. labeltext=u'Tilt the phone to move' textrect=img.measure_text(labeltext, font='normal')[0] text_img=Image.new((textrect[2]-textrect[0],textrect[3]-textrect[1])) text_img.clear(0) text_img.text((-textrect[0],-textrect[1]),labeltext,fill=0xff,font='normal') while running: img.clear(0) img.blit(text_img, (0,0)) img.point((location[0]+blobsize/2,location[1]+blobsize/2), 0x00ff00,width=blobsize) handle_redraw(()) e32.ao_yield() e32.reset_inactivity() speed[0]*=friction speed[1]*=friction location[0]+=speed[0] location[1]+=speed[1] n_frames+=1 if not sense_conn: continue if not len(sense_conn.delta): continue x_bounce_factor = .8 * (1 - min(6,abs(sense_conn.delta[0])) / 9) y_bounce_factor = .8 * (1 - min(6,abs(sense_conn.delta[1])) / 9) if location[0]>xs: location[0]=xs-(location[0]-xs) speed[0]= -x_bounce_factor * speed[0] speed[1]=0.90*speed[1] if location[0]<0: location[0]=-location[0] speed[0]= -x_bounce_factor * speed[0] speed[1]=0.90*speed[1] if location[1]>ys: location[1]=ys-(location[1]-ys) speed[0]=0.90*speed[0] speed[1]= -y_bounce_factor * speed[1] if location[1]<0: location[1]=-location[1] speed[0]=0.90*speed[0] speed[1]= -y_bounce_factor * speed[1] speed[0] -= (sense_conn.delta[1]) * acceleration speed[1] -= (sense_conn.delta[0]) * acceleration speed[0] = max(min(xs / 2, speed[0]), -xs/2) speed[1] = max(min(ys / 2, speed[1]), -ys/2) end_time=time.clock() total=end_time-start_time sense_conn.cleanup() print "%d frames, %f seconds, %f FPS, %f ms/frame."%(n_frames,total, n_frames/total, total/n_frames*1000.) > Date: Thu, 3 Apr 2008 10:34:26 -0400 > From: [EMAIL PROTECTED] > To: [EMAIL PROTECTED] > CC: tutor@python.org > Subject: Re: [Tutor] a pyball python app > > dean garrad wrote: > > > > > > this is the part im lil confused about to add the extra ball > > > > location=[img.size[0]/2,img.size[1]/2] > > speed=[0.,0.] > > > i tried copying but it did nothing do i need to copy it and change > > something so the python app dont read the same txt twice and jus do nothing? > > If you want to just copy/paste, you will have to copy all the lines > using location and speed and change the copies to something like > location2 and speed2. Of course you should also change the starting > location or speed so the two balls don't draw in the same place! > > > also on the txt bellow if i add another bal somehow i dotn have to copy > > or change the txt bellow do i? it should create same value for both balls? > > You have to duplicate all the location and speed code, using the new names. > > > also could you link advise any good tuturials that would help me ive > > read some on the net but need more help really. > > The first two tutorials listed here are popular: > http://wiki.python.org/moin/BeginnersGuide/NonProgrammers > > Kent > > PS Please subscribe to the list so I don't have to moderate all your > requests through. _ The next generation of Windows Live is
Re: [Tutor] socket / over network
re-inventing the wheel ? http://www.howtoforge.com/linux_backuppc > > > On Thu, Apr 3, 2008 at 3:44 PM, Alan Gauld <[EMAIL PROTECTED]> > wrote: > > > "Nathan McBride" <[EMAIL PROTECTED]> wrote > > > > Hi Nathan, > > > > Please don't reply to an existing message to start a new discussion. > > It messes up those of us using threaded mail/news readers and > > increases the likelihood that your message will be missed. > > > > > I'm pretty tired of the lame backup solution we have at work. > > > Could anyone point me to a (more or less newbieish) example of how > > > to > > > have python open a socket on one box and get data from it, then have > > > another > > > box write to it over the network? > > > > For a very simple example of using a socket you could try the > > Network Programming topic in my tutorial. > > > > There is also a HowTo or Topic guide on the Python web site > > that gives a more detailed example. > > > > That having been said, backups are usually best done using > > OS tools or if you must roll your own then using ftp or similar > > as a file transfer mechanism rather than trying to send a > > bytestream over a socket. ftp can handle broken connections > > etc more easily. Detecting and fixing errors over a socket > > stream is non trivial and for backups is pretty much essential!! > > > > -- > > Alan Gauld > > Author of the Learn to Program web site > > http://www.freenetpages.co.uk/hp/alan.gauld > > > > > > ___ > > Tutor maillist - Tutor@python.org > > http://mail.python.org/mailman/listinfo/tutor > > > > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Which Python Script Editor of Choice?
Andreas Kostyrka wrote: > Eric and SPE are also nice. > > The good thing here is that the majority of IDEs for Python are free. > > Andreas > > Am Donnerstag, den 03.04.2008, 16:57 +0100 schrieb Alan Gauld: > >> "Jeffrey Dates" <[EMAIL PROTECTED]> wrote >> >> >>> So as I'm starting to get into writing some scripts, I'm looking for >>> recommendations for a nifty script editor. Ideally a >>> freeware/shareware >>> solution until I can justify a purchase of something more beefy. >>> >> editor choice is a sensitive topic for programmers and >> tends to lead to religious wars. >> >> >> I use TickleText (http://sourceforge.net/projects/tickletext/ ) It doesn't have python syntax highlighting though. I'm really just starting with python, and mostly hack tcl.tk, in which TickleText is written. It's good for writing html and LaTeX, and other stuff, too, and has some other useful features. It's certainly not as fat and bloated as Emacs (hehe...Emacs is cool, really). I used to use medit or kate. But then I made Tickle Text. Kdevelop is nice if you want a full IDE that does recognize python syntax. And, of course, if you are using Linux. I don't use KDE (use fluxbox), but I like some of these KDE tools. /tony -- Anthony Baldwin http://www.BaldwinLinguas.com Translation & Interpreting http://www.TransProCalc.org Free translation project mgmt software ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Which Python Script Editor of Choice?
Ah thanks guy!! Yeah, I guess I didn't mean which is the 'best'... Just some options. Thanks, I'll check out the ones you listed! I'm on Windows btw. Jeffrey Dates www.kungfukoi.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Which Python Script Editor of Choice?
Eric and SPE are also nice. The good thing here is that the majority of IDEs for Python are free. Andreas Am Donnerstag, den 03.04.2008, 16:57 +0100 schrieb Alan Gauld: > "Jeffrey Dates" <[EMAIL PROTECTED]> wrote > > > So as I'm starting to get into writing some scripts, I'm looking for > > recommendations for a nifty script editor. Ideally a > > freeware/shareware > > solution until I can justify a purchase of something more beefy. > > editor choice is a sensitive topic for programmers and > tends to lead to religious wars. > > > Currently I'm using PSPad, however it's pretty dumb and doesn't > > recognize > > Python context. Which, I suppose is fine, but would be nice if > > there was > > one. Especially since I'm learning. > > If you are on Windows then the Pythonwin editor is pretty good. > > Or for a simple editor you can use Scite which is the same editor > engine as Pythonwin but includes multiple tabbed panes. But > doesn't include an interactive shell. > > At the other end of the scale you can install PyDev into the > eclipse editor which is a good solution if you already use > Eclipse for anything else. > > emacs and vim can both be made Python aware too. > > And there are lots of others that each has their followers. > SPE and Ala Mode(comes with wxPython) are others that > I personally tried and found OK. > > My normal tools are: > Pythonwin for short coding sessions or when using the >>> > prompt a lot. > For longer coding sesssions I use the 3 window approach: > vijm for editing, a DOS(Cygwin) window for running the code and > another Cygwin window running the Python >>> prompt. > And Alt-Tab to switch between them. > > > My run time environment is IDLE. > > But IDLE should never be your main run time environment. > It is an IDE for developing code but you should run the code > under the interpreter within the OS, you will generally get better > (more predicatable!) results that way. The IDLE editor is > OK too of course but I assumed you didn't want it for > some reason? > > HTH, > signature.asc Description: Dies ist ein digital signierter Nachrichtenteil ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Which Python Script Editor of Choice?
[snip] > I went to the PSPad site, but found no way to download the editor. Am > I missing something? Ignore that. Something on the home page did not display correctly. Refresh fixed that. -- Bob Gailer 919-636-4239 Chapel Hill, NC ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Which Python Script Editor of Choice?
Jeffrey Dates wrote: > Hello, > > So as I'm starting to get into writing some scripts, I'm looking for > recommendations for a nifty script editor. Ideally a > freeware/shareware solution until I can justify a purchase of > something more beefy. I use Python for Windows and really like it. It is free. http://sourceforge.net/projects/pywin32/ > > Currently I'm using PSPad, however it's pretty dumb and doesn't > recognize Python context. I went to the PSPad site, but found no way to download the editor. Am I missing something? > My run time environment is IDLE. It is more accurate to say "My development environment is IDLE." The underlying Python interpreter is the runtime. -- Bob Gailer 919-636-4239 Chapel Hill, NC ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Which Python Script Editor of Choice?
"Jeffrey Dates" <[EMAIL PROTECTED]> wrote > So as I'm starting to get into writing some scripts, I'm looking for > recommendations for a nifty script editor. Ideally a > freeware/shareware > solution until I can justify a purchase of something more beefy. editor choice is a sensitive topic for programmers and tends to lead to religious wars. > Currently I'm using PSPad, however it's pretty dumb and doesn't > recognize > Python context. Which, I suppose is fine, but would be nice if > there was > one. Especially since I'm learning. If you are on Windows then the Pythonwin editor is pretty good. Or for a simple editor you can use Scite which is the same editor engine as Pythonwin but includes multiple tabbed panes. But doesn't include an interactive shell. At the other end of the scale you can install PyDev into the eclipse editor which is a good solution if you already use Eclipse for anything else. emacs and vim can both be made Python aware too. And there are lots of others that each has their followers. SPE and Ala Mode(comes with wxPython) are others that I personally tried and found OK. My normal tools are: Pythonwin for short coding sessions or when using the >>> prompt a lot. For longer coding sesssions I use the 3 window approach: vijm for editing, a DOS(Cygwin) window for running the code and another Cygwin window running the Python >>> prompt. And Alt-Tab to switch between them. > My run time environment is IDLE. But IDLE should never be your main run time environment. It is an IDE for developing code but you should run the code under the interpreter within the OS, you will generally get better (more predicatable!) results that way. The IDLE editor is OK too of course but I assumed you didn't want it for some reason? HTH, -- Alan Gauld Author of the Learn to Program web site http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] socket / over network
"Nathan McBride" <[EMAIL PROTECTED]> wrote Hi Nathan, Please don't reply to an existing message to start a new discussion. It messes up those of us using threaded mail/news readers and increases the likelihood that your message will be missed. > I'm pretty tired of the lame backup solution we have at work. > Could anyone point me to a (more or less newbieish) example of how > to > have python open a socket on one box and get data from it, then have > another > box write to it over the network? For a very simple example of using a socket you could try the Network Programming topic in my tutorial. There is also a HowTo or Topic guide on the Python web site that gives a more detailed example. That having been said, backups are usually best done using OS tools or if you must roll your own then using ftp or similar as a file transfer mechanism rather than trying to send a bytestream over a socket. ftp can handle broken connections etc more easily. Detecting and fixing errors over a socket stream is non trivial and for backups is pretty much essential!! -- Alan Gauld Author of the Learn to Program web site http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Which Python Script Editor of Choice?
Hello, So as I'm starting to get into writing some scripts, I'm looking for recommendations for a nifty script editor. Ideally a freeware/shareware solution until I can justify a purchase of something more beefy. Currently I'm using PSPad, however it's pretty dumb and doesn't recognize Python context. Which, I suppose is fine, but would be nice if there was one. Especially since I'm learning. My run time environment is IDLE. Any thoughts or preferences would be appreciated. thanks! Jeffrey Dates www.kungfukoi.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Newb Learning Question
> > > 3rd alternative: if c > 'm': print c > after futzing around with interpreting the problem, I ended up with a solution that utilizes the character comparison. "Write a program that prints the first letter of a string that comes after 'm' in the alphabet." s = "this is my string" for i in s: if i > 'm': print i break Thanks for all the help everyone. Seems so obvious now.. ;-) I'm sure I'll be back with some more newb questions in the future. ;-) jeff. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] socket / over network
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hey guys, I'm pretty tired of the lame backup solution we have at work. Could anyone point me to a (more or less newbieish) example of how to have python open a socket on one box and get data from it, then have another box write to it over the network? I'm having trouble finding something like this. Thanks, Nate -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.7 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org iD8DBQFH9PUf/n+duykW6K8RAvXMAKCE5708Bly/9fzHFZu45cd/d11WGQCdGNcG PWcbs2jjZXv7b586aNAnSv4= =9uBW -END PGP SIGNATURE- ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] a pyball python app
dean garrad wrote: > > > this is the part im lil confused about to add the extra ball > > location=[img.size[0]/2,img.size[1]/2] > speed=[0.,0.] > i tried copying but it did nothing do i need to copy it and change > something so the python app dont read the same txt twice and jus do nothing? If you want to just copy/paste, you will have to copy all the lines using location and speed and change the copies to something like location2 and speed2. Of course you should also change the starting location or speed so the two balls don't draw in the same place! > also on the txt bellow if i add another bal somehow i dotn have to copy > or change the txt bellow do i? it should create same value for both balls? You have to duplicate all the location and speed code, using the new names. > also could you link advise any good tuturials that would help me ive > read some on the net but need more help really. The first two tutorials listed here are popular: http://wiki.python.org/moin/BeginnersGuide/NonProgrammers Kent PS Please subscribe to the list so I don't have to moderate all your requests through. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] a pyball python app
this is the part im lil confused about to add the extra ball location=[img.size[0]/2,img.size[1]/2] speed=[0.,0.] blobsize=16 xs,ys=img.size[0]-blobsize,img.size[1]-blobsize acceleration=0.05 friction = 0.993 import time start_time=time.clock() n_frames=0 i tried copying but it did nothing do i need to copy it and change something so the python app dont read the same txt twice and jus do nothing? also on the txt bellow if i add another bal somehow i dotn have to copy or change the txt bellow do i? it should create same value for both balls? x_bounce_factor = .8 * (1 - min(6,abs(sense_conn.delta[0])) / 9) y_bounce_factor = .8 * (1 - min(6,abs(sense_conn.delta[1])) / 9) if location[0]>xs: location[0]=xs-(location[0]-xs) speed[0]= -x_bounce_factor * speed[0] speed[1]=0.90*speed[1] if location[0]<0: location[0]=-location[0] speed[0]= -x_bounce_factor * speed[0] speed[1]=0.90*speed[1] if location[1]>ys: location[1]=ys-(location[1]-ys) speed[0]=0.90*speed[0] speed[1]= -y_bounce_factor * speed[1] if location[1]<0: location[1]=-location[1] speed[0]=0.90*speed[0] speed[1]= -y_bounce_factor * speed[1] im just confused on how to get the programme to add another ball into it and keep everything the same.. i tried changing and copying some of the script but the app jus loads the whole ball script twice and seperate ball on each. also could you link advise any good tuturials that would help me ive read some on the net but need more help really. thank you for your time. . > Date: Thu, 3 Apr 2008 10:16:37 -0400 > From: [EMAIL PROTECTED] > To: [EMAIL PROTECTED] > CC: tutor@python.org > Subject: Re: [Tutor] a pyball python app > > dean garrad wrote: > > i kind of understood what you were saying but not sure how to go by this > > i am still new to python script and learning it as much as i can. > > OK. Do you understand how the current script works? If not, what parts > are confusing? > > Do you understand object-oriented programming at all (classes)? If not, > you should probably read some tutorials and get at least a basic > understanding. > > You could add another ball by brute-force copying of lots of code, or by > making a list of (location, speed) values for each ball, but the code > will end up simpler and easier to understand if you use a class to hold > the parameters for the ball. > > Kent _ Win 100’s of Virgin Experience days with BigSnapSearch.com http://www.bigsnapsearch.com___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] a pyball python app
i kind of understood what you were saying but not sure how to go by this i am still new to python script and learning it as much as i can. here is a video of the script in action http://youtube.com/watch?v=zqZeANFBmis i did not create the script only trying to modify it. i have permission from the developer to modify. > Date: Thu, 3 Apr 2008 08:57:05 -0400 > From: [EMAIL PROTECTED] > To: [EMAIL PROTECTED]; tutor@python.org > Subject: Re: [Tutor] a pyball python app > > dean garrad wrote: > > > this one is the working version of 1 ball that can move around the > > screen im sorry the other one i sent was a test one ive been trying out.. > > > > i cant seam to find it as easy to get it to work with 2 balls on screen. > > anything i try doesnt effect the script. > > What have you tried? Do you understand my suggestion? > > Kent > > PS Please use Reply All to reply to the list > > > > > > when i tes out there is always just 1 ball there the only thing i change > > by accident is the acceleration and gravity of the ball also the size. _ Win 100’s of Virgin Experience days with BigSnapSearch.com http://www.bigsnapsearch.com___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] a pyball python app
dean garrad wrote: > i kind of understood what you were saying but not sure how to go by this > i am still new to python script and learning it as much as i can. OK. Do you understand how the current script works? If not, what parts are confusing? Do you understand object-oriented programming at all (classes)? If not, you should probably read some tutorials and get at least a basic understanding. You could add another ball by brute-force copying of lots of code, or by making a list of (location, speed) values for each ball, but the code will end up simpler and easier to understand if you use a class to hold the parameters for the ball. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] a pyball python app
dean garrad wrote: > this one is the working version of 1 ball that can move around the > screen im sorry the other one i sent was a test one ive been trying out.. > > i cant seam to find it as easy to get it to work with 2 balls on screen. > anything i try doesnt effect the script. What have you tried? Do you understand my suggestion? Kent PS Please use Reply All to reply to the list > > > when i tes out there is always just 1 ball there the only thing i change > by accident is the acceleration and gravity of the ball also the size. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] a pyball python app
dean garrad wrote: > i am currently trying to edit a python app > > it is a normal green ball game that comes with python it uses nokia n95 > accel to move around. > > i have been trying to make more than one ball on the screen at the same > time . > > do you think it is possable ? The attachment seems to be a modified version that moves text around on the screen, not a ball. The program uses global variables to hold the state of the moving image, in particular the lists that hold location and speed. Adding a second image while keeping the same programming style would involve a lot of code duplication. What I suggest is to create a Ball object that holds the location and speed of the ball. The movement code could also go into the Ball class. Get this working with one ball. Then it should be pretty easy to add a second ball. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] a pyball python app
hi there.. im not sure if you can help or you would want to but i fort i may aswell give it a try. i am currently trying to edit a python app it is a normal green ball game that comes with python it uses nokia n95 accel to move around. i have been trying to make more than one ball on the screen at the same time . do you think it is possable ? i have attached the script to this e mail and would be greatful for any advice thanks. dean. _ Amazing prizes every hour with Live Search Big Snap http://www.bigsnapsearch.com# This code has been significantly modified from the original source, which # is distributed with Nokia's Python for Series 60, by Christopher Schmidt, # and is released under the same license as that code (see below). # # Copyright (c) 2008 Christopher Schmidt # Copyright (c) 2005 Nokia Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import appuifw from graphics import * import e32 import sensor class SensorConnection(object): delta = [] def __init__(self): """Connect to the sensor.""" sens = sensor.sensors()['AccSensor'] self.s = sensor.Sensor(sens['id'], sens['category']) self.s.connect(self.callme) def callme(self, state): self.delta = [] for key in ['data_1', 'data_2', 'data_3']: val = state[key] self.delta.append(int(val + 40)/80) def cleanup(self): """Cleanup after yourself. *Must be called* before exiting.""" self.s.disconnect() sense_conn = SensorConnection() appuifw.app.screen='full' img=None def handle_redraw(rect): if img: canvas.blit(img) appuifw.app.body=canvas=appuifw.Canvas( redraw_callback=handle_redraw) img=Image.new(canvas.size) running=1 def quit(): global running running=0 appuifw.app.exit_key_handler=quit location=[img.size[0]/2,img.size[1]/2] speed=[0.,0.] blobsize=16 xs,ys=img.size[0]-blobsize,img.size[1]-blobsize acceleration=0.05 friction = 0.993 speed=[0.,0.] blobsize=16 xs,ys=img.size[0]-blobsize,img.size[1]-blobsize acceleration=0.10 friction = 0.999 import time start_time=time.clock() n_frames=0 # To speed things up, we prerender the text. labeltext=u'Tilt the phone to move' textrect=img.measure_text(labeltext, font='normal')[0] text_img=Image.new((textrect[2]-textrect[0],textrect[3]-textrect[1])) text_img.clear(0) text_img.text((-textrect[0],-textrect[1]),labeltext,fill=0xff,font='normal') while running: img.clear(0) img.blit(text_img, (0,0)) img.point((location[0]+blobsize/2,location[1]+blobsize/2), 0x00ff00,width=blobsize) handle_redraw(()) e32.ao_yield() e32.reset_inactivity() speed[0]*=friction speed[1]*=friction location[0]+=speed[0] location[1]+=speed[1] n_frames+=1 if not sense_conn: continue if not len(sense_conn.delta): continue x_bounce_factor = .8 * (1 - min(6,abs(sense_conn.delta[0])) / 9) y_bounce_factor = .8 * (1 - min(6,abs(sense_conn.delta[1])) / 9) if location[0]>xs: location[0]=xs-(location[0]-xs) speed[0]= -x_bounce_factor * speed[0] speed[1]=0.90*speed[1] if location[0]<0: location[0]=-location[0] speed[0]= -x_bounce_factor * speed[0] speed[1]=0.90*speed[1] if location[1]>ys: location[1]=ys-(location[1]-ys) speed[0]=0.90*speed[0] speed[1]= -y_bounce_factor * speed[1] if location[1]<0: location[1]=-location[1] speed[0]=0.90*speed[0] speed[1]= -y_bounce_factor * speed[1] speed[0] -= (sense_conn.delta[1]) * acceleration speed[1] -= (sense_conn.delta[0]) * acceleration speed[0] = max(min(xs / 2, speed[0]), -xs/2) speed[1] = max(min(ys / 2, speed[1]), -ys/2) end_time=time.clock() total=end_time-start_time sense_conn.cleanup() print "%d frames, %f seconds, %f FPS, %f ms/frame."%(n_frames,total, n_frames/total, total/n_frames*1000.) ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Newb Learning Question
"bob gailer" <[EMAIL PROTECTED]> wrote > 3rd alternative: if c > 'm': print c Wow! Amazingly I just assumed you couldn't directly compare characters with boolean tests. I don't know why I thought that since it must be possible for string comparisons, but I did. You learn something new every day, :-) Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor