Re: [Tutor] Unable to run a simple Hello.py in WinXP

2010-05-18 Thread Sivapathasuntha Aruliah
Adam Bark 


05/18/2010 01:21 AM


To
Sivapathasuntha Aruliah/S1/a...@amkor
cc
tutor@python.org
Subject
Re: [Tutor] Unable to run a simple Hello.py in WinXP










On 17 May 2010 09:05, Sivapathasuntha Aruliah <
sivapathasuntha.arul...@amkor.com> wrote:

Hi 
If possible please run the following two lines after saving it as a py 
file on WINXP and check whether it runs smooythly. When I run I  get 
error. I use Python 3.1.2 (r312:79149, Mar 21 2010, 00:41:52) [MSC v.1500 
32 bit (Intel)] on win32 
Type "copyright", "credits" or "license()" for more information. However 
when I give the following command on Python shell print("Hello", "World!") 
it neately prints Hello World! 

#! /usr/bin/env python3 

print("Hello", "World!") 



Regards,
Siva
 
Hi, are you sure you got your python path correct? Are you running 64bit 
windows by any chance?
Hi Adam
I also suspected it could be 64 bit but from IDLE gui which I used it 
shows the followings which confirms 32 bit?  So please if you have WINXP 
bit32 please try to run and show me what command including paths you used 
to get a successful run.

"Python 3.1.2 (r312:79149, Mar 21 2010, 00:41:52) [MSC v.1500 32 bit 
(Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> "<>___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Unable to run a simple Hello.py in WinXP

2010-05-18 Thread Sivapathasuntha Aruliah
Hi Yashwin
When I run the hello.py from it's location by double clicking it shows an 
error with the pop up window C:\Python31\python.exe is not a valid win32 
application.
When I give the command from IDLE then it says SyntaxError: invalid syntax 
Which can be seen from Python Shell. Please analyse.





Regards,
Siva
Test Equipment Engineering
Amkor Technology (S) Pte Ltd
1 Kaki Bukit View
#03-28 TechView Building
Singapore 415941
Tel: (65) 6347 1131
Fax: (65) 6746 4815



Yashwin Kanchan 


05/18/2010 03:28 AM


To
Sivapathasuntha Aruliah/S1/a...@amkor
cc
tutor@python.org
Subject
Re: [Tutor] Unable to run a simple Hello.py in WinXP








Hi Siva

This looks more of issue with the python installation on your PC.

Could be a bad installation, in which case I would suggest re-installation 
of python.
Also it could be something to do with permission on your PC.

Also you say that you were successful in running the script on python 
shell.
Could you please tell us do you mean IDLE or the python command prompt?In 
either case please tell us how do you to initiate the shell on your 
machine.

Regards
Yashwin Kanchan

On 17 May 2010 09:05, Sivapathasuntha Aruliah <
sivapathasuntha.arul...@amkor.com> wrote:

Hi 
If possible please run the following two lines after saving it as a py 
file on WINXP and check whether it runs smooythly. When I run I  get 
error. I use Python 3.1.2 (r312:79149, Mar 21 2010, 00:41:52) [MSC v.1500 
32 bit (Intel)] on win32 
Type "copyright", "credits" or "license()" for more information. However 
when I give the following command on Python shell print("Hello", "World!") 
it neately prints Hello World! 

#! /usr/bin/env python3 

print("Hello", "World!") 



Regards,
Siva
Test Equipment Engineering
Amkor Technology (S) Pte Ltd
1 Kaki Bukit View
#03-28 TechView Building
Singapore 415941
Tel: (65) 6347 1131
Fax: (65) 6746 4815
___
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


[Tutor] Different between pass & continue

2010-05-18 Thread M. Bashir Al-Noimi

Hi All,


I couldn't understand the difference between pass and continue keywords, 
could you explain to me?



--
Best Regards
Muhammad Bashir Al-Noimi
My Blog: http://mbnoimi.net

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


Re: [Tutor] Different between pass & continue

2010-05-18 Thread Christian Witts

M. Bashir Al-Noimi wrote:

Hi All,


I couldn't understand the difference between pass and continue 
keywords, could you explain to me?




Taken from the docs at http://docs.python.org/tutorial/controlflow.html

The continue statement continues the next iteration of a loop for eg.
for line in file:
   if not line.strip():  # If the line is empty then
   continue

The pass statement does nothing. It can be used when a statement is 
required syntactically but the program requires no action. For example:


while True:
   pass  # Busy-wait for keyboard interrupt (Ctrl+C)

--
Kind Regards,
Christian Witts


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


Re: [Tutor] Different between pass & continue

2010-05-18 Thread Steven D'Aprano
On Tue, 18 May 2010 10:34:16 pm M. Bashir Al-Noimi wrote:
> Hi All,
>
>
> I couldn't understand the difference between pass and continue
> keywords, could you explain to me?


"pass" is a do-nothing statement. It literally does nothing.

"continue" is only allowed inside a for-loop or while-loop, and 
means "jump to the start of the loop". It is related to "break".

Consider the difference between these three loops:


>>> for x in (1,2,3):
... print(x)
... pass
... print(x, "again")
...
1
1 again
2
2 again
3
3 again
>>>
>>>
>>> for x in (1,2,3):
... print(x)
... continue
... print(x, "again")
...
1
2
3
>>>
>>>
>>> for x in (1,2,3):
... print(x)
... break
... print(x, "again")
...
1
>>>



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


[Tutor] PYTHON 3.1

2010-05-18 Thread Dipo Elegbede
Python 3.1.1 (r311:74483, Aug 17 2009, 17:02:12) [MSC v.1500 32 bit (Intel)]
on win32
Type "copyright", "credits" or "license()" for more information.
>>> print 'hello'
SyntaxError: invalid syntax (, line 1)
>>> print ('hello')
hello
>>>

the above print is what i came across having installed python 3.0 and trying
to run the print command.
with previous versions, a print command takes the form
print 'parameter'
and the output is
parameter

but with this new version it seems you need to put in brackets like:
print ('hello')
to get an output like:
hello

please confirm this is a new syntax for print.
thank you.

i will put up morte concerns as they arrive.

thanks.
-- 
Elegbede Muhammed Oladipupo
OCA
+2348077682428
+2347042171716
www.dudupay.com
Mobile Banking Solutions | Transaction Processing | Enterprise Application
Development
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] PYTHON 3.1

2010-05-18 Thread James Reynolds
On Tue, May 18, 2010 at 8:40 AM, Dipo Elegbede wrote:

> Python 3.1.1 (r311:74483, Aug 17 2009, 17:02:12) [MSC v.1500 32 bit
> (Intel)] on win32
> Type "copyright", "credits" or "license()" for more information.
> >>> print 'hello'
> SyntaxError: invalid syntax (, line 1)
> >>> print ('hello')
> hello
> >>>
>
> the above print is what i came across having installed python 3.0 and
> trying to run the print command.
> with previous versions, a print command takes the form
> print 'parameter'
> and the output is
> parameter
>
> but with this new version it seems you need to put in brackets like:
> print ('hello')
> to get an output like:
> hello
>
> please confirm this is a new syntax for print.
> thank you.
>
> i will put up morte concerns as they arrive.
>
> thanks.
> --
> Elegbede Muhammed Oladipupo
> OCA
> +2348077682428
> +2347042171716
> www.dudupay.com
> Mobile Banking Solutions | Transaction Processing | Enterprise Application
> Development
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>

In python 3K print is a function.

So, print('hello, world') is the correct syntax.

You may find this article helpful:
http://docs.python.org/py3k/whatsnew/3.0.html
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] PYTHON 3.1

2010-05-18 Thread Christian Witts

Dipo Elegbede wrote:
Python 3.1.1 (r311:74483, Aug 17 2009, 17:02:12) [MSC v.1500 32 bit 
(Intel)] on win32

Type "copyright", "credits" or "license()" for more information.
>>> print 'hello'
SyntaxError: invalid syntax (, line 1)
>>> print ('hello')
hello
>>>

the above print is what i came across having installed python 3.0 and 
trying to run the print command.

with previous versions, a print command takes the form
print 'parameter'
and the output is
parameter

but with this new version it seems you need to put in brackets like:
print ('hello')
to get an output like:
hello

please confirm this is a new syntax for print.
thank you.

i will put up morte concerns as they arrive.

thanks.
--
Elegbede Muhammed Oladipupo
OCA
+2348077682428
+2347042171716
www.dudupay.com 
Mobile Banking Solutions | Transaction Processing | Enterprise 
Application Development



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

The Python 3.x series changed the print statement to a print function.

--
Kind Regards,
Christian Witts


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


Re: [Tutor] PYTHON 3.1

2010-05-18 Thread Dipo Elegbede
thanks a lot.

i was almost going to abandon this python again out of frustration. i have
done it before but with you guys around, it would never happen again.

i have a pdf version of python programming for absolute beginners, could
anyone please help me with its accompaning CD content?

thanks as i anticipate responses.

regards.
On Tue, May 18, 2010 at 2:02 PM, James Reynolds  wrote:

>
>
> On Tue, May 18, 2010 at 8:40 AM, Dipo Elegbede wrote:
>
>> Python 3.1.1 (r311:74483, Aug 17 2009, 17:02:12) [MSC v.1500 32 bit
>> (Intel)] on win32
>> Type "copyright", "credits" or "license()" for more information.
>> >>> print 'hello'
>> SyntaxError: invalid syntax (, line 1)
>> >>> print ('hello')
>> hello
>> >>>
>>
>> the above print is what i came across having installed python 3.0 and
>> trying to run the print command.
>> with previous versions, a print command takes the form
>> print 'parameter'
>> and the output is
>> parameter
>>
>> but with this new version it seems you need to put in brackets like:
>> print ('hello')
>> to get an output like:
>> hello
>>
>> please confirm this is a new syntax for print.
>> thank you.
>>
>> i will put up morte concerns as they arrive.
>>
>> thanks.
>> --
>> Elegbede Muhammed Oladipupo
>> OCA
>> +2348077682428
>> +2347042171716
>> www.dudupay.com
>> Mobile Banking Solutions | Transaction Processing | Enterprise Application
>> Development
>>
>> ___
>> Tutor maillist  -  Tutor@python.org
>> To unsubscribe or change subscription options:
>> http://mail.python.org/mailman/listinfo/tutor
>>
>>
>
> In python 3K print is a function.
>
> So, print('hello, world') is the correct syntax.
>
> You may find this article helpful:
> http://docs.python.org/py3k/whatsnew/3.0.html
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>


-- 
Elegbede Muhammed Oladipupo
OCA
+2348077682428
+2347042171716
www.dudupay.com
Mobile Banking Solutions | Transaction Processing | Enterprise Application
Development
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] what is wrong with this syntax?

2010-05-18 Thread Dipo Elegbede
ples help me figure out what is wrong with this syntax?


print('Here are the numbers from 0 to 9')
for i in the range(10):
print(i)

thank you.

i am currently reading a byte of a python.

thanks.

-- 
Elegbede Muhammed Oladipupo
OCA
+2348077682428
+2347042171716
www.dudupay.com
Mobile Banking Solutions | Transaction Processing | Enterprise Application
Development
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] what is wrong with this syntax?

2010-05-18 Thread zaldi
in the header of for loop, you don't need to use "the" -> for i in range(10)

On 5/18/10, Dipo Elegbede  wrote:
> ples help me figure out what is wrong with this syntax?
>
>
> print('Here are the numbers from 0 to 9')
> for i in the range(10):
> print(i)
>
> thank you.
>
> i am currently reading a byte of a python.
>
> thanks.
>
> --
> Elegbede Muhammed Oladipupo
> OCA
> +2348077682428
> +2347042171716
> www.dudupay.com
> Mobile Banking Solutions | Transaction Processing | Enterprise Application
> Development
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] what is wrong with this syntax?

2010-05-18 Thread alex gunn
its the "the" part

print('Here are the numbers from 0 to 9')
# for i in the range(10):  #your version
for i in range(10): #try this
print(i)

im still learning myself, so be gentle if im wrong but it worked for me.

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


Re: [Tutor] PYTHON 3.1

2010-05-18 Thread Dave Angel
(Please don't top-post.  Add your comments to the end of the portion 
you're quoting.)


Dipo Elegbede wrote:

thanks a lot.

i was almost going to abandon this python again out of frustration. i have
done it before but with you guys around, it would never happen again.

i have a pdf version of python programming for absolute beginners, could
anyone please help me with its accompaning CD content?

thanks as i anticipate responses.

regards.
  
  

I don't know the version that your CD was written for.

If you're going to use a tutorial, it's smart to get a matching version 
of Python.  So if your tutorial is for 2.x, you should get Python 2.6 
(or soon, 2.7).  Otherwise, you'll be frequently frustrated by the 
differences.


They're not that bad, once you know the language.  But while you're 
learning, try to match your learning materials with your version.


DaveA

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


Re: [Tutor] what is wrong with this syntax?

2010-05-18 Thread Vern Ceder

Dipo Elegbede wrote:

ples help me figure out what is wrong with this syntax?


print('Here are the numbers from 0 to 9')
for i in the range(10):
print(i)


Remove the word "the"

print('Here are the numbers from 0 to 9')
for i in range(10):
 print(i)


Cheers,
Vern



thank you.

i am currently reading a byte of a python.

thanks.

--
Elegbede Muhammed Oladipupo
OCA
+2348077682428
+2347042171716
www.dudupay.com 
Mobile Banking Solutions | Transaction Processing | Enterprise 
Application Development





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


--
This time for sure!
   -Bullwinkle J. Moose
-
Vern Ceder, Director of Technology
Canterbury School, 3210 Smith Road, Ft Wayne, IN 46804
vce...@canterburyschool.org; 260-436-0746; FAX: 260-436-5137

The Quick Python Book, 2nd Ed - http://bit.ly/bRsWDW
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] PYTHON 3.1

2010-05-18 Thread Dipo Elegbede
I AM CURRENTLY LEARNING WITH PYTHON 3.0
just about now, you are all blowing my minds.
this is great.

On Tue, May 18, 2010 at 2:49 PM, Dave Angel  wrote:

> (Please don't top-post.  Add your comments to the end of the portion you're
> quoting.)
>
>
> Dipo Elegbede wrote:
>
>> thanks a lot.
>>
>> i was almost going to abandon this python again out of frustration. i have
>> done it before but with you guys around, it would never happen again.
>>
>> i have a pdf version of python programming for absolute beginners, could
>> anyone please help me with its accompaning CD content?
>>
>> thanks as i anticipate responses.
>>
>> regards.
>>
>>
> I don't know the version that your CD was written for.
>
> If you're going to use a tutorial, it's smart to get a matching version of
> Python.  So if your tutorial is for 2.x, you should get Python 2.6 (or soon,
> 2.7).  Otherwise, you'll be frequently frustrated by the differences.
>
> They're not that bad, once you know the language.  But while you're
> learning, try to match your learning materials with your version.
>
> DaveA
>
>


-- 
Elegbede Muhammed Oladipupo
OCA
+2348077682428
+2347042171716
www.dudupay.com
Mobile Banking Solutions | Transaction Processing | Enterprise Application
Development
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] PYTHON 3.1

2010-05-18 Thread Walter Prins
IMHO: If you're new to Python and just trying to learn the language, I'd
suggest sticking to Python 2.x for now, as the vast majority of Python
material out there still use and refer to Python 2.x syntax.   IMHO it'll be
a lot easier learning and coping with what's changed in Python 3 only once
you are already comfortable with Python 2.x syntax, rather than trying to
use materials and books referencing 2.x on 3.x and then consequently running
into unexpected issues as above, and never being sure whether issues you run
into is due to some mistake on your part or a difference between 2.x and
3.x.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] PYTHON 3.1

2010-05-18 Thread Dipo Elegbede
That's a good one Sir, i started out with 2.x series but left it for a
while.
Coming back now, i'm getting on well just for this few changes but I think
with a forum like this, I'd fare well in this pythonic journey.
Thanks.

On Tue, May 18, 2010 at 2:56 PM, Walter Prins  wrote:

> IMHO: If you're new to Python and just trying to learn the language, I'd
> suggest sticking to Python 2.x for now, as the vast majority of Python
> material out there still use and refer to Python 2.x syntax.   IMHO it'll be
> a lot easier learning and coping with what's changed in Python 3 only once
> you are already comfortable with Python 2.x syntax, rather than trying to
> use materials and books referencing 2.x on 3.x and then consequently running
> into unexpected issues as above, and never being sure whether issues you run
> into is due to some mistake on your part or a difference between 2.x and
> 3.x.
>



-- 
Elegbede Muhammed Oladipupo
OCA
+2348077682428
+2347042171716
www.dudupay.com
Mobile Banking Solutions | Transaction Processing | Enterprise Application
Development
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] what is wrong with this syntax?

2010-05-18 Thread Dipo Elegbede
all worked well.
thanks all.

On Tue, May 18, 2010 at 2:47 PM, alex gunn wrote:

> its the "the" part
>
> print('Here are the numbers from 0 to 9')
> # for i in the range(10):  #your version
> for i in range(10): #try this
> print(i)
>
> im still learning myself, so be gentle if im wrong but it worked for me.
>
> Alex
>



-- 
Elegbede Muhammed Oladipupo
OCA
+2348077682428
+2347042171716
www.dudupay.com
Mobile Banking Solutions | Transaction Processing | Enterprise Application
Development
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] what is wrong with this syntax?

2010-05-18 Thread Steven D'Aprano
On Tue, 18 May 2010 11:36:02 pm Dipo Elegbede wrote:
> ples help me figure out what is wrong with this syntax?
>
>
> print('Here are the numbers from 0 to 9')
> for i in the range(10):
> print(i)
>
> thank you.

Others have already given you the answer, but more important is for you 
to learn *how* to get the answer.

Look at the error message Python prints:

>>> for i in the range(10):
  File "", line 1
for i in the range(10):
 ^
SyntaxError: invalid syntax


You get a SyntaxError, which tells you that what you've written makes no 
sense to the Python compiler. It also tells you that the error has 
nothing to do with either of the print lines.

Unfortunately Python isn't smart enough to recognise that the problem is 
with "the" rather than "range(10)", but it points you to the correct 
line.



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


Re: [Tutor] what is wrong with this syntax?

2010-05-18 Thread Dipo Elegbede
thanks Steven. I'll always be mindful of that.
By the way, I need someone to briefly explain to me how the while loop works.
a little on break will also do.
thanks.

On 5/18/10, Steven D'Aprano  wrote:
> On Tue, 18 May 2010 11:36:02 pm Dipo Elegbede wrote:
>> ples help me figure out what is wrong with this syntax?
>>
>>
>> print('Here are the numbers from 0 to 9')
>> for i in the range(10):
>> print(i)
>>
>> thank you.
>
> Others have already given you the answer, but more important is for you
> to learn *how* to get the answer.
>
> Look at the error message Python prints:
>
 for i in the range(10):
>   File "", line 1
> for i in the range(10):
>  ^
> SyntaxError: invalid syntax
>
>
> You get a SyntaxError, which tells you that what you've written makes no
> sense to the Python compiler. It also tells you that the error has
> nothing to do with either of the print lines.
>
> Unfortunately Python isn't smart enough to recognise that the problem is
> with "the" rather than "range(10)", but it points you to the correct
> line.
>
>
>
> --
> Steven D'Aprano
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>


-- 
Elegbede Muhammed Oladipupo
OCA
+2348077682428
+2347042171716
www.dudupay.com
Mobile Banking Solutions | Transaction Processing | Enterprise
Application Development
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] what is wrong with this syntax?

2010-05-18 Thread Dipo Elegbede
A LITTLE EXPLANATIONS ON CONTINUE WOULD BE APPRECIATED TOO.
in a recap, i would appreciate any brief explanation on
1. break
2. continue
3. while loop

how they work and application in writing codes.

thank you all.

On 5/18/10, Dipo Elegbede  wrote:
> thanks Steven. I'll always be mindful of that.
> By the way, I need someone to briefly explain to me how the while loop
> works.
> a little on break will also do.
> thanks.
>
> On 5/18/10, Steven D'Aprano  wrote:
>> On Tue, 18 May 2010 11:36:02 pm Dipo Elegbede wrote:
>>> ples help me figure out what is wrong with this syntax?
>>>
>>>
>>> print('Here are the numbers from 0 to 9')
>>> for i in the range(10):
>>> print(i)
>>>
>>> thank you.
>>
>> Others have already given you the answer, but more important is for you
>> to learn *how* to get the answer.
>>
>> Look at the error message Python prints:
>>
> for i in the range(10):
>>   File "", line 1
>> for i in the range(10):
>>  ^
>> SyntaxError: invalid syntax
>>
>>
>> You get a SyntaxError, which tells you that what you've written makes no
>> sense to the Python compiler. It also tells you that the error has
>> nothing to do with either of the print lines.
>>
>> Unfortunately Python isn't smart enough to recognise that the problem is
>> with "the" rather than "range(10)", but it points you to the correct
>> line.
>>
>>
>>
>> --
>> Steven D'Aprano
>> ___
>> Tutor maillist  -  Tutor@python.org
>> To unsubscribe or change subscription options:
>> http://mail.python.org/mailman/listinfo/tutor
>>
>
>
> --
> Elegbede Muhammed Oladipupo
> OCA
> +2348077682428
> +2347042171716
> www.dudupay.com
> Mobile Banking Solutions | Transaction Processing | Enterprise
> Application Development
>


-- 
Elegbede Muhammed Oladipupo
OCA
+2348077682428
+2347042171716
www.dudupay.com
Mobile Banking Solutions | Transaction Processing | Enterprise
Application Development
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Loop basics (was Re: what is wrong with this syntax?)

2010-05-18 Thread Steve Willoughby
I'm changing the subject line because this is going into a different topic.

On Tue, May 18, 2010 at 05:39:50PM +0100, Dipo Elegbede wrote:
> A LITTLE EXPLANATIONS ON CONTINUE WOULD BE APPRECIATED TOO.
> in a recap, i would appreciate any brief explanation on
> 1. break
> 2. continue
> 3. while loop

These are the basic constructs in many languages for repeating a set of
tasks over and over, as long as some condition remains true.  Say you had
a function which asks the user a yes or no question and returns True if
they said 'yes' or False if they said 'no'.  

You want to play a game as long as they keep saying they're willing to
play, so assuming a function play_game() which does the actual playing,
making Python keep doing this repeatedly would look like this:

while ask_yes_or_no('Do you want to play a game?'):
  play_game()

If you get into the loop and decide you want to bail out early rather
than waiting for the condition to become False on its own, you can
just put a break statement inside the loop.  As soon as Python encounters
that break, it will stop the loop.

while ask_yes_or_no('Do you want to play a game?'):
  print 'Okay, that will be fun.'
  if not ask_yes_or_no('Are you sure, though?'):
break
  play_game()


continue is like break in that it upsets the normal flow of the loop
body, but whereas break stops the loop completely, continue abandons
only THIS run through the loop, jumps immediately back to the top,
and continues from there, testing the condition to see if another trip
through the loop is allowed at this point.

For example, you might write the ask_yes_or_no function like this:

def ask_yes_or_no(prompt):
  while True:
answer = raw_input(prompt)
if answer == 'both':
  print 'Now that's just silly, try again.'
  continue
if answer == 'yes':
  return True
if answer == 'no':
  return False
print 'Please answer "yes" or "no".'


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


Re: [Tutor] PYTHON 3.1

2010-05-18 Thread spir ☣
On Tue, 18 May 2010 14:53:45 +0100
Dipo Elegbede  wrote:

> I AM CURRENTLY LEARNING WITH PYTHON 3.0
> just about now, you are all blowing my minds.
> this is great.

Please don't write your replies on top. Write them instead just after the 
part(s) of the message you're replying to; and delete the rest. By doing so, 
you help keeping the flow of the discussion; else, everything gets messed up 
after 2-3 replies.

Denis


vit esse estrany ☣

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


Re: [Tutor] PYTHON 3.1

2010-05-18 Thread Alan Gauld


"Dipo Elegbede"  wrote 


please confirm this is a new syntax for print.
thank you.

i will put up morte concerns as they arrive.


Please read the Whats New in Python v3 documents first.
Version 3 of Python is a major change in the language with 
many big changes. Do not just try stuff and send it here 
every time something breaks. 


Read the documents first so you know what to expect.

--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk

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


Re: [Tutor] Loop basics (was Re: what is wrong with this syntax?)

2010-05-18 Thread Dipo Elegbede
thanks Steve, this response came handy.
I would have to take this home and read. if i encounter difficulties,
I'd get back to the house.
I'm grateful.
If I get more explanations though, it would be great.
Regards,

On 5/18/10, Steve Willoughby  wrote:
> I'm changing the subject line because this is going into a different topic.
>
> On Tue, May 18, 2010 at 05:39:50PM +0100, Dipo Elegbede wrote:
>> A LITTLE EXPLANATIONS ON CONTINUE WOULD BE APPRECIATED TOO.
>> in a recap, i would appreciate any brief explanation on
>> 1. break
>> 2. continue
>> 3. while loop
>
> These are the basic constructs in many languages for repeating a set of
> tasks over and over, as long as some condition remains true.  Say you had
> a function which asks the user a yes or no question and returns True if
> they said 'yes' or False if they said 'no'.
>
> You want to play a game as long as they keep saying they're willing to
> play, so assuming a function play_game() which does the actual playing,
> making Python keep doing this repeatedly would look like this:
>
> while ask_yes_or_no('Do you want to play a game?'):
>   play_game()
>
> If you get into the loop and decide you want to bail out early rather
> than waiting for the condition to become False on its own, you can
> just put a break statement inside the loop.  As soon as Python encounters
> that break, it will stop the loop.
>
> while ask_yes_or_no('Do you want to play a game?'):
>   print 'Okay, that will be fun.'
>   if not ask_yes_or_no('Are you sure, though?'):
> break
>   play_game()
>
>
> continue is like break in that it upsets the normal flow of the loop
> body, but whereas break stops the loop completely, continue abandons
> only THIS run through the loop, jumps immediately back to the top,
> and continues from there, testing the condition to see if another trip
> through the loop is allowed at this point.
>
> For example, you might write the ask_yes_or_no function like this:
>
> def ask_yes_or_no(prompt):
>   while True:
> answer = raw_input(prompt)
> if answer == 'both':
>   print 'Now that's just silly, try again.'
>   continue
> if answer == 'yes':
>   return True
> if answer == 'no':
>   return False
> print 'Please answer "yes" or "no".'
>
>
>


-- 
Elegbede Muhammed Oladipupo
OCA
+2348077682428
+2347042171716
www.dudupay.com
Mobile Banking Solutions | Transaction Processing | Enterprise
Application Development
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] what is wrong with this syntax?

2010-05-18 Thread bob gailer

On 5/18/2010 11:23 AM, Steven D'Aprano wrote:

Others have already given you the answer, but more important is for you
to learn *how* to get the answer.

Look at the error message Python prints:

   

for i in the range(10):
 

   File "", line 1
 for i in the range(10):
  ^
SyntaxError: invalid syntax


You get a SyntaxError, which tells you that what you've written makes no
sense to the Python compiler. It also tells you that the error has
nothing to do with either of the print lines.

Unfortunately Python isn't smart enough to recognise that the problem is with "the" 
rather than "range(10)"
   


To be more specific - Python is "happy" with "for i in the ". It is 
"expecting"either : or some operator. "range" is neither - so that is 
where the error pointer is.


Example:

the = [1,2,3]
for i in the:
  print(i)
for i in the + [4]:
  print(i)

--
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] PYTHON 3.1

2010-05-18 Thread Dipo Elegbede
ok

On 5/18/10, spir ☣  wrote:
> On Tue, 18 May 2010 14:53:45 +0100
> Dipo Elegbede  wrote:
>
>> I AM CURRENTLY LEARNING WITH PYTHON 3.0
>> just about now, you are all blowing my minds.
>> this is great.
>
> Please don't write your replies on top. Write them instead just after the
> part(s) of the message you're replying to; and delete the rest. By doing so,
> you help keeping the flow of the discussion; else, everything gets messed up
> after 2-3 replies.
>
> Denis
> 
>
> vit esse estrany ☣
>
> spir.wikidot.com
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>


-- 
Elegbede Muhammed Oladipupo
OCA
+2348077682428
+2347042171716
www.dudupay.com
Mobile Banking Solutions | Transaction Processing | Enterprise
Application Development
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] what is wrong with this syntax?

2010-05-18 Thread Alan Gauld


"Dipo Elegbede"  wrote

By the way, I need someone to briefly explain to me how the while 
loop works.

a little on break will also do.


Your tutorial should do that but you can also look at the Loops
section of my tutorial - use the V3 version - for a discussion of 
while loops.


It does not cover break/continue because they are not really necessary
to write programs, simply convenience features so I don't cover them
till much later.

--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/


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


Re: [Tutor] what is wrong with this syntax?

2010-05-18 Thread spir ☣
On Wed, 19 May 2010 01:23:55 +1000
Steven D'Aprano  wrote:

> On Tue, 18 May 2010 11:36:02 pm Dipo Elegbede wrote:
> > ples help me figure out what is wrong with this syntax?
> >
> >
> > print('Here are the numbers from 0 to 9')
> > for i in the range(10):
> > print(i)
> >
> > thank you.
> 
> Others have already given you the answer, but more important is for you 
> to learn *how* to get the answer.
> 
> Look at the error message Python prints:
> 
> >>> for i in the range(10):
>   File "", line 1
> for i in the range(10):
>  ^
> SyntaxError: invalid syntax
> 
> 
> You get a SyntaxError, which tells you that what you've written makes no 
> sense to the Python compiler. It also tells you that the error has 
> nothing to do with either of the print lines.
> 
> Unfortunately Python isn't smart enough to recognise that the problem is 
> with "the" rather than "range(10)", but it points you to the correct 
> line.

And logically, if the error is not at the pointed word/line, it will be just 
before.

This means that when analysing your code, python passed on the real error 
cause, because of a possible ambiguity; but then the rest makes no sense, so it 
stops and points where it got blocked, immediately after the error.
In the code above, "the" could be a name you gave to a list, for instance; 
since an expression starting like "for i in listName" is correct, Python cannot 
stop on "the"... but then the rest of the line makes no more sense for it.

(Fortunately, python 3.2, planned for April 1, 2011, will be informed that 
"the" is an english article. This is possible since there is no ambiguity with 
"thé" (fr), thank to Python's clever diacritic-awareness. Only remains then the 
problematic case of "a".)


Denis


vit esse estrany ☣

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


Re: [Tutor] [SOLVED] Different between pass & continue

2010-05-18 Thread M. Bashir Al-Noimi

Thanks

On 18/05/2010 02:20 م, Steven D'Aprano wrote:

On Tue, 18 May 2010 10:34:16 pm M. Bashir Al-Noimi wrote:
   

Hi All,


I couldn't understand the difference between pass and continue
keywords, could you explain to me?
 


"pass" is a do-nothing statement. It literally does nothing.

"continue" is only allowed inside a for-loop or while-loop, and
means "jump to the start of the loop". It is related to "break".

Consider the difference between these three loops:


   

for x in (1,2,3):
 

... print(x)
... pass
... print(x, "again")
...
1
1 again
2
2 again
3
3 again
   


for x in (1,2,3):
 

... print(x)
... continue
... print(x, "again")
...
1
2
3
   


for x in (1,2,3):
 

... print(x)
... break
... print(x, "again")
...
1
   
 



   


--
Best Regards
Muhammad Bashir Al-Noimi
My Blog: http://mbnoimi.net

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


[Tutor] Unit testing command-line options from argparse or optparse

2010-05-18 Thread Serdar Tumgoren
Hello all,

Does anyone have advice for writing unit tests against variables set by
command-line options?

I have a program I'd like to run in either "debug" or "live" mode, with
various settings associated with each. Below is some pseudo-code that shows
what I'd like to do:

<>
mode = p.parse_args() #always set to either --debug or --live

if mode.live:
recipients = ['jsm...@email.com', 'jane...@email.com']
# set logging to a file
elif mode.debug:
recipients = ['ad...@admin.com']
# log to stdout

The "live" and "debug" attributes are set by command-line flags passed to
the argparse module. What I'd like to do is write tests that check whether
various settings (recipients, logging, etc.) are configured properly based
on the command-line options.

But if "mode" is not set until runtime, I clearly can't import it into my
suite of unit tests, right? Is there some standard testing approach to this
problem (perhaps mocking?) that you all can recommend?

I'd greatly appreciate it.
Serdar
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] what is wrong with this syntax?

2010-05-18 Thread Steven D'Aprano
On Wed, 19 May 2010 03:29:46 am spir ☣ wrote:
> (Fortunately, python 3.2, planned for April 1, 2011, will be informed
> that "the" is an english article. This is possible since there is no
> ambiguity with "thé" (fr), thank to Python's clever
> diacritic-awareness. Only remains then the problematic case of "a".)

I know you are joking, but that's exactly what Apple's Hypertalk 
programming language did. In Hypertalk, you could write:

  get the second field
  put it before the third field 
  go to the last card of the next background

or:

  get second field
  put it before third field 
  go to last card of next background



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


Re: [Tutor] Unit testing command-line options from argparse or optparse

2010-05-18 Thread Knacktus

Am 18.05.2010 22:49, schrieb Serdar Tumgoren:

Hello all,

Does anyone have advice for writing unit tests against variables set 
by command-line options?


I have a program I'd like to run in either "debug" or "live" mode, 
with various settings associated with each. Below is some pseudo-code 
that shows what I'd like to do:


<>
mode = p.parse_args() #always set to either --debug or --live

if mode.live:
recipients = ['jsm...@email.com ', 
'jane...@email.com ']

# set logging to a file
elif mode.debug:
recipients = ['ad...@admin.com ']
# log to stdout

The "live" and "debug" attributes are set by command-line flags passed 
to the argparse module. What I'd like to do is write tests that check 
whether various settings (recipients, logging, etc.) are configured 
properly based on the command-line options.


But if "mode" is not set until runtime, I clearly can't import it into 
my suite of unit tests, right? Is there some standard testing approach 
to this problem (perhaps mocking?) that you all can recommend?


I'd greatly appreciate it.
Serdar


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
   
I just had a look at the optparse documentation ... huuu, quite heavier 
than I have expected But to your question:


You could reorganise your main module. Put all your code which is on 
module level into a function called "main" with mode as argurment and 
add the neat "if __name__ == "__main__" condition at the end of your 
module to parse the command line options and call your main function. 
When you import your module to your test, you have to call the "main" 
function "manually" and can pass a mock for the mode as required. Let's 
say your main module is called "serdars_main_module"


serdars_main_module.py:
--

def main(mode):
# all the program logic
 if mode.live:
recipients = ['jsm...@email.com ', 
'jane...@email.com ']

# set logging to a file
 elif mode.debug:
recipients = ['ad...@admin.com ']
# log to stdout
# ...

if __name__ == "__main__":
mode = p.parse_args() #always set to either --debug or --liv
main(mode)
#

Then your test module could look like:

serdars_test_module.py:
-
#
import serdars_main_module
import unittest

class ArgParseMock(object):
def __init__(self, live, debug):
self.live = live
self.debug = debug

class TestDebugMode(unittest.TestCase):
def test_live_mode(self):
mode = ArgParseMock(True, False) # create the mock for the 
arguments

serdars_main_module.main(mode) # call the main logic with the mock
# 
def test_debug_mode(self):
mode = ArgParseMock(False, True) # create the mock for the 
arguments

serdars_main_module.main(mode) # call the main logic with the mock
# 
##

Hope that helps,

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