Re: [Tutor] Syntax error help

2012-03-31 Thread bob gailer

Thank you for posting your code.

Did you forget to reply-all? I am copying this to the list this time.

You apparantly misunderstood my question about what you do to run the 
program. You said " I import then call the first function  (the 
displaymenu) or I have it called in the code it does it automatically".


I am running out of patience trying to get from you what we as a Tutor 
List need in order to help you.


Please answer the following:
What operating system are you using (Windows, Linux, Mac, ...)
WHAT DO YOU DO RUN THE PROGRAM. I gave detailed examples of potential 
answers (see below). Do you not understand what I'm looking for?


On 3/30/2012 11:22 PM, chris knarvik wrote:
Also here is my revised code with what i call a 'programmers error' 
let me know  if you  see it because i dont


Why all the imports - you are not using any math, os or sys code. Also 
You should not do 2 different imports from math. It is better to drop 
the from ...

import math
import os, sys
from math import *

def displaymenu():
print 'please make a selection';
print 'Area (1)';
choice = raw_input('enter selection number')

OK time to learn how to debug.
Since the code goes from if to print, the if condition (choice == 1) 
must be False.

What datatype does raw_input give you?
Why would that cause the condition to be False?
One way to answer that is to read the manual regarding raw_input.
Another is to use print statements with type() to tell you the types.
Therefore just before the if put
print type(choice), type(1)


if choice == 1:
   selctiona()
else:
print'choice',choice,'is wrong'
print"why god wont this thing work"


def areamenu():
print 'Square (1)'
print 'triangle (2)'
print 'rectangle (3)'
print 'trapazoid (4)'
print 'circle (5)'

def selctiona():
areamenu();
choicea = raw_input('enter selection');
if choicea == 1:
   squareacalc()

else:
print 'why god why'

def squareacalc():
sidelength = input('enter side length: ')
print "The Area Is", sidelength **2


You don't seem to call reloadarea!

def reloadarea():
   print 'would you like to calculate again'
   choicer = raw_input('yes(1) or no(2)')
   if choicer == 1:
This is called recursion. It is better in this kind of program to put 
the entire thing in a while loop(see below)*  rather than to use a 
recursive call.

   displaymenu()
   elif choicer == 2:
   print 'goodbye'

displaymenu()

i cant get past the display menu i get this result
please make a selection
Area (1)
enter selection number1
choice 1 is wrong
why god wont this thing work

>>>
let me know if you can see where i went wrong


I hope the guidance I gave above helps.

* Using a while loop instead of recursion:
while True:
  displaymenu()
  print 'would you like to calculate again'
  choicer = raw_input('yes(1) or no(2)')
  if choicer == 2: # this also will not work, for the same reason that 
choice == 1 does not work. Once you fix choice == 1 then you can also 
fix this.

break






what do you mean what do i do to run it

There are several ways to execute (run) a Python program.
You can double-click the file in an explorer.
You can at a command prompt type (e.g.) >python Area.py
or you can start an interactive session then type >>>import Area
or you can use an IDE such as IDLE.
 within IDLE you can write the program in an edit window then RUN
 or you can use the interactive window and type >>>import Area
Which of these (or what else) do you do 





--
Bob Gailer
919-636-4239
Chapel Hill NC

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Problem Stripping

2012-03-31 Thread Mark Lawrence

On 31/03/2012 03:01, bob gailer wrote:

Then, of course, there's "15:45".replace(':','')



For the record in earlier Python versions such as the one the OP is 
using you can do


>>> allchars = "".join([chr(x) for x in range(256)])
>>> 'www.example.com'.translate(allchars, 'cmowz.')
'exaple'

As of Python 2.6 you don't even need the allchars hence

>>> 'www.example.com'.translate(None, 'cmowz.')
'exaple'

--
Cheers.

Mark Lawrence.

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] breeds of Python .....

2012-03-31 Thread Barry Drake
After following the reading suggestions, I soon found myself looking at 
quite a few code examples that would only run under a particular version 
of python.  Finally, I converted the example that I was working on to 
run under Python3.  I just wondered if you guys would advise a newbie 
like me to concentrate on Python3 or stay with Python2 and get into bad 
habits when it comes to change eventually?  Apart from the print and 
input functions, I haven't so far got a lot to re-learn.


Kind regards,Barry.

--
From Barry Drake - a member of the Ubuntu advertising team.

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor



Re: [Tutor] breeds of Python .....

2012-03-31 Thread Modulok
After following the reading suggestions, I soon found myself looking
at quite a few code examples that would only run under a particular
version of python.  Finally, I converted the example that I was
working on to run under Python3.  I just wondered if you guys would
advise a newbie like me to concentrate on Python3 or stay with Python2
and get into bad habits when it comes to change eventually?  Apart
from the print and input functions, I haven't so far got a lot to
re-learn.

Kind regards,Barry.


Barry,

If you're just starting out, go with 3.x. If you have a need for some third
party modules that aren't yet available for 3.x, you'll have to stick with 2.x.
Most beginner tutorials will work without changes, except for the print
statement is now a function, e.g:

print "foo"

Is now:

print("foo")

There isn't a whole lot of difference in syntax to learn. Some modules have
been renamed, some module functions re-worked, etc. Probably the biggest change
is the move to all unicode strings. One thing you can do if you're running 2.x
but want to get into the 3.x swing of things is turn on 3.x warnings. It will
tell you if you did something the 2to3 tool can't automatically fix:

python2.6 -3

If you want, you can actually use the 3.x style print function and true
division when using 2.x by putting this at the top of your code::

from __future__ import print_function
from __future__ import division

Now in 2.x, just like 3.x this will raise an exception:

print "foo" #<-- Now fails in 2.x
print("foo")#<-- Works.

-Modulok-
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Syntax error help

2012-03-31 Thread Alan Gauld

On 31/03/12 03:33, S.Irfan Rizvi wrote:

Please remove me from listi can't do itthey are doing it Attention
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Only you could have joined the list and only you can unsubscribe.
Go to the web page and follow the instructions.

If it doesn't work email me and I'll try to figure out what's
going wrong.

--
Alan G
Tutor list moderator
(and just home from vacation...)

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Syntax error help

2012-03-31 Thread S.Irfan Rizvi
Its failing i can't able to unsubcribe
please remove me from its not going to Span either









*Error: **Authentication failed.*Tutor list: member options login pageIn
order to change your membership option, you must first log in by giving
your email address  and
membership password in the section below. If you don't remember your
membership password, you can have it emailed to you by clicking on the
button below. If you just want to unsubscribe from this list, click on the *
Unsubscribe* button and a
confirmation message
will be sent to you.

*Important:* From this point on, you must have cookies enabled in your
browser, otherwise none of your changes will take effect.
Email address:
Password:
UnsubscribeBy clicking on the *Unsubscribe* button, a confirmation message
will be emailed to you. This message will have a link that you should click
on to complete the removal process (you can also
confirm by
email; see the instructions in the confirmation message).Password reminderBy
clicking on the *Remind* button, your password will be emailed to you.




On Mar 31, 2012 6:51 PM, "Alan Gauld"  wrote:

> On 31/03/12 03:33, S.Irfan Rizvi wrote:
>
>> Please remove me from listi can't do itthey are doing it Attention
>> __**_
>> Tutor maillist  -  Tutor@python.org
>> To unsubscribe or change subscription options:
>> http://mail.python.org/**mailman/listinfo/tutor
>>
>
> Only you could have joined the list and only you can unsubscribe.
> Go to the web page and follow the instructions.
>
> If it doesn't work email me and I'll try to figure out what's
> going wrong.
>
> --
> Alan G
> Tutor list moderator
> (and just home from vacation...)
>
> __**_
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/**mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] breeds of Python .....

2012-03-31 Thread S.Irfan Rizvi
please remove me from here

















On Sat, Mar 31, 2012 at 4:28 PM, Modulok  wrote:
> After following the reading suggestions, I soon found myself looking
> at quite a few code examples that would only run under a particular
> version of python.  Finally, I converted the example that I was
> working on to run under Python3.  I just wondered if you guys would
> advise a newbie like me to concentrate on Python3 or stay with Python2
> and get into bad habits when it comes to change eventually?  Apart
> from the print and input functions, I haven't so far got a lot to
> re-learn.
>
> Kind regards,        Barry.
>
>
> Barry,
>
> If you're just starting out, go with 3.x. If you have a need for some third
> party modules that aren't yet available for 3.x, you'll have to stick with 
> 2.x.
> Most beginner tutorials will work without changes, except for the print
> statement is now a function, e.g:
>
>    print "foo"
>
> Is now:
>
>    print("foo")
>
> There isn't a whole lot of difference in syntax to learn. Some modules have
> been renamed, some module functions re-worked, etc. Probably the biggest 
> change
> is the move to all unicode strings. One thing you can do if you're running 2.x
> but want to get into the 3.x swing of things is turn on 3.x warnings. It will
> tell you if you did something the 2to3 tool can't automatically fix:
>
>    python2.6 -3
>
> If you want, you can actually use the 3.x style print function and true
> division when using 2.x by putting this at the top of your code::
>
>    from __future__ import print_function
>    from __future__ import division
>
> Now in 2.x, just like 3.x this will raise an exception:
>
>    print "foo"     #<-- Now fails in 2.x
>    print("foo")    #<-- Works.
>
> -Modulok-
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor



-- 
       Regards
     ~ S. Irfan Rizvi
 ADR-TS
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] breeds of Python .....

2012-03-31 Thread S.Irfan Rizvi
please remove me from here
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] breeds of Python .....

2012-03-31 Thread Brett Ritter
On Sat, Mar 31, 2012 at 5:37 PM, Barry Drake  wrote:
> concentrate on Python3 or stay with Python2 and get into bad habits when it
> comes to change eventually?  Apart from the print and input functions, I
> haven't so far got a lot to re-learn.

My recommendation is to go with Python2 - most major projects haven't
made the switch and I'd expect another year or two before they do so.
Many tutorials and examples are Python 2-based and there are not that
many differences to unlearn in terms of habits.

-- 
Brett Ritter / SwiftOne
swift...@swiftone.org
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor