[Tutor] Python Editor

cyclicflux at yahoo.com cyclicflux at yahoo.com
Wed Feb 22 03:57:13 CET 2012


I agree,  pyscripter if using windows used to be my favorite,  and is in the  
top 3 favorite python editors. Based on your tastes and your editor  
selection I'd say that you might like another batteries-included(not much  
config, autocomplete, ability to test code/etc... ) editor for python native  
to both Windows &  Linux would be that of Aptana Studio(primary focus is  
that of web), customized from eclipse however depending on the distro you  
use is may have to be compiled. But pydev(Aptana's python-based plugin) is  
included with Aptana Studio. If indeed the lack of a pre-configured  
system-ready package/compiling from source is not enticing, then one can use  
the pkg-management conducive to your distro and install eclipse(as most  
distros have that). Then go to the plug-in installation in Eclipse's help  
menu and install pydev,  from I believe http://pydev.org. Its def.  A great  
editor,  and I have used it alot,  and the fact both windows,  and linux use  
it your able to seamlessly resume your work no matter what os your using.   
But Wine most certainly isnt bad and I have gotten if memory serves me  
correctly pyscripter to work on my archlinux install.  Some other editors  
that are more so geared towards python development on linux are cream/pida,  
eric,  &  spyder(probably most similar to pyscripter). My one concern with  
pyscripter I believe is that its not being updated currently(I could be  
wrong, but I think thats what I last saw. ).  Good luck! 

Will 

Sent from my Verizon Wireless Phone

-----Original message-----
From: tutor-request at python.org
To: tutor at python.org
Sent: Wed, Feb 22, 2012 00:28:23 GMT+00:00
Subject: Tutor Digest, Vol 96, Issue 89

Send Tutor mailing list submissions to
	tutor at 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-request at python.org

You can reach the person managing the list at
	tutor-owner at 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: Pyhton editor (ken brockman)
   2. Re: Checking for file completion. (Steven D'Aprano)
   3. how to rewrite area.py (William Stewart)
   4. Re: how to rewrite area.py (Dave Angel)
   5. Re: how to rewrite area.py (Steven D'Aprano)


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

Message: 1
Date: Tue, 21 Feb 2012 15:29:01 -0800 (PST)
From: ken brockman <krush1954 at yahoo.com>
To: "Prasad, Ramit" <ramit.prasad at jpmorgan.com>,	"tutor at python.org"
	<tutor at python.org>
Subject: Re: [Tutor] Pyhton editor
Message-ID:
	<1329866941.17077.YahooMailNeo at web39302.mail.mud.yahoo.com>
Content-Type: text/plain; charset="iso-8859-1"





________________________________
 From: "Prasad, Ramit" <ramit.prasad at jpmorgan.com>
To: "tutor at python.org" <tutor at python.org> 
Sent: Tuesday, February 21, 2012 10:08 AM
Subject: Re: [Tutor] Pyhton editor
 
>>However I stumbled upon PyScripter and I find it really amazing.
>Pity it is only for Windows.

WINE?

Ramit

I?concur. Pyscripter , though?I've?only installed it a few days ago, seems  
to be one of the better ones. I am?running?it in a virtualbox winXP on top  
of?Linux?Ubuntu, but i love the simply way you can use tkinter from a  
server? No muss no fuss. Just install and go. I understand that the way it  
had been built, it can't be readily ported to Linux. Mores the pity.

Ken



Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423

--

This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.? 
_______________________________________________
Tutor maillist? -? Tutor at 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/20120221/1bad24e9/attachm 
ent-0001.html>

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

Message: 2
Date: Wed, 22 Feb 2012 10:35:00 +1100
From: Steven D'Aprano <steve at pearwood.info>
To: Python Tutor <tutor at python.org>
Subject: Re: [Tutor] Checking for file completion.
Message-ID: <4F442A24.3030705 at pearwood.info>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Tony Pelletier wrote:

>> Missing a return statement in the case of an exception.
> 
> Can you explain this?  Why would I want the return on the exception?

Because if you don't, it will return None.


-- 
Steven



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

Message: 3
Date: Tue, 21 Feb 2012 15:51:39 -0800 (PST)
From: William Stewart <williamjstewart at rogers.com>
To: tutor at python.org
Subject: [Tutor] how to rewrite area.py
Message-ID:
	<1329868299.29511.YahooMailClassic at web88611.mail.bf1.yahoo.com>
Content-Type: text/plain; charset="iso-8859-1"

hello
I need to rewrite area.py program so that it has separate functions for the  
perimeter and area of a square, a rectangle, and a circle (3.14 *  
radius**2). 
I am horrible at math and I cannot even figure out what I need to do for  
this
Any help would be appreciated

All I have is the menu which looks like this
?
?
?
?
import math
print "your options are:"
print " "
print "1) Area(SQUARE)"
print "2) Area(RECTANGLE)"
print "3) Area(CIRCLE)"
print "4) Perimeter(SQUARE)"
print "5) Perimeter(RECTANGLE)"
print "6) Perimeter(CIRCLE)"
print "7) Exit"
while True: 
??? selection = raw_input("Please select an option from the menu.: ")
python area.py

print "Calculate information about a rectangle"
length = input("Length:")
width = input("Width:")
print "Area",length*width
print "Perimeter",2*length+2*width
print 'To find the area of a rectangle,'
print 'Enter the width and height below.'
print
w = input('Width:? ')
while w <= 0:
??? print 'Must be a positive number'
??? w = input('Width:? ')
h = input('Height: ')
while h <= 0:
??? print 'Must be a positive number'
??? h = input('Height: ')
print 'Width =',w,' Height =',h,' so Area =',area(w,h)
-------------- next part --------------
An HTML attachment was scrubbed...
URL:  
<http://mail.python.org/pipermail/tutor/attachments/20120221/7cf9ef80/attachm 
ent-0001.html>

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

Message: 4
Date: Tue, 21 Feb 2012 19:17:07 -0500
From: Dave Angel <d at davea.name>
To: William Stewart <williamjstewart at rogers.com>
Cc: tutor at python.org
Subject: Re: [Tutor] how to rewrite area.py
Message-ID: <4F443403.6070101 at davea.name>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

On 02/21/2012 06:51 PM, William Stewart wrote:
> hello
> I need to rewrite area.py program so that it has separate functions for  
the perimeter and area of a square, a rectangle, and a circle (3.14 *  
radius**2).
> I am horrible at math and I cannot even figure out what I need to do for  
this
> Any help would be appreciated
>
> All I have is the menu which looks like this
>   
>   
>   
>   
> import math
> print "your options are:"
> print " "
> print "1) Area(SQUARE)"
> print "2) Area(RECTANGLE)"
> print "3) Area(CIRCLE)"
> print "4) Perimeter(SQUARE)"
> print "5) Perimeter(RECTANGLE)"
> print "6) Perimeter(CIRCLE)"
> print "7) Exit"
> while True:
>      selection = raw_input("Please select an option from the menu.: ")
> python area.py
>
> print "Calculate information about a rectangle"
> length = input("Length:")
> width = input("Width:")
> print "Area",length*width
> print "Perimeter",2*length+2*width
> print 'To find the area of a rectangle,'
> print 'Enter the width and height below.'
> print
> w = input('Width:  ')
> while w<= 0:
>      print 'Must be a positive number'
>      w = input('Width:  ')
> h = input('Height: ')
> while h<= 0:
>      print 'Must be a positive number'
>      h = input('Height: ')
> print 'Width =',w,' Height =',h,' so Area =',area(w,h)
>


Just what don't you understand?  If it's really just the math, then go 
ahead and write dummy versions of the needed functions and control 
structures, and then ask for help modifying the code.

There are bugs in the present code that have nothing to do with math, 
and I'm not just referring to the line  "python area.py".



-- 

DaveA



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

Message: 5
Date: Wed, 22 Feb 2012 11:25:32 +1100
From: Steven D'Aprano <steve at pearwood.info>
To: tutor at python.org
Subject: Re: [Tutor] how to rewrite area.py
Message-ID: <4F4435FC.10608 at pearwood.info>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

William Stewart wrote:
> hello
> I need to rewrite area.py program so that it has separate functions for  
the perimeter and area of a square, a rectangle, and a circle (3.14 *  
radius**2). 
> I am horrible at math and I cannot even figure out what I need to do for  
this
> Any help would be appreciated

Have you learned about functions? Here's an example. Put this in a file and 
try it.

def get_drink():
     answer = raw_input("Would you like a cup of tea? (y/n) ").lower()
     while answer not in ('y', 'yes', 'n', 'no'):
         print "I'm sorry, I don't understand that response."
         print "Please enter Yes or No."
         answer = raw_input("Would you like a cup of tea? (y/n) ").lower()
     if answer in ('y', 'yes'):
         return "a nice steaming cup of tea, with a couple of biscuits"
     else:
         return "a stale cup of bitter coffee"


drink = get_drink()
print "I have", drink


Notice a few things:

First, you define a function with the "def" keyword, and give it a name, in 
this case, "get_drink". Names should usually be verbs ("doing words"),  
because 
functions do things.

Second, the function normally should use the "return" statement to send a 
result back to the caller.

Third, you call the function by name, using round brackets (parentheses) to 
indicate to Python that you are calling it, and save the result in a  
variable 
("drink" in the above example).

And finally, you can then use the variable for further processing.

In your case, you want six functions, to get the area of a square, the 
perimeter of a rectangle, etc. So for each function, you need to decide on a  

descriptive name, such as this:

def get_area_of_square():
     # Ask the user for the width of the square.
     ...
     # Calculate the area.
     area = width**2
     return area


The dots ... need to be filled in by you. Your program already has code that  

asks the user for a width, just grab it and put it inside the function.

The formulae you need are:


SQUARES:
     area = width*width = width**2
     perimeter = width+width+width+width = 4*width

RECTANGLES:
     area = width*height
     perimeter = width+height+width+height = 2*(width+height)

CIRCLES:
     area = pi*radius**2
     circumference = 2*pi*radius


To get the value of pi, put this at the top of your program:

from math import pi

Hope this helps.



-- 
Steven


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

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


End of Tutor Digest, Vol 96, Issue 89
*************************************

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120221/c52b9a99/attachment-0001.html>


More information about the Tutor mailing list