Re: [Tutor] conditional execution

2014-04-02 Thread spir

On 04/01/2014 06:24 PM, Zachary Ware wrote:

Hi Patti,

On Tue, Apr 1, 2014 at 11:07 AM, Patti Scott  wrote:

I've been cheating:  comment out the conditional statement and adjust the
indents. But, how do I make my program run with if __name__ == 'main':
main() at the end?  I thought I understood the idea to run a module called
directly but not a module imported.  My program isn't running, though.


The simple fix to get you going is to change your ``if __name__ ==
'main':`` statement to ``if __name__ == '__main__':`` (add two
underscores on each side of "main").  To debug this for yourself, try
putting ``print(__name__)`` right before your ``if __name__ ...``
line, and see what is printed when you run it in different ways.

Hope this helps, and if you need any more help or a more in-depth
explanation of what's going on, please don't hesitate to ask :)


And you don't even need this idiom if your module is only to be executed (not 
imported). Just write "main()".


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


[Tutor] unittest decorators

2014-04-02 Thread Albert-Jan Roskam
Hi,
 
The unittest module has some really handy decorators: @unittest.skip
and @unittest.skipIf. I use the former for temporary TODO or FIXME things, but 
I use the latter for a more permanent thing: 
@unittest.skipif(sys.version_info()[0] > 2). Yet, in the test summary you just 
see error, skipped, failed. Is it possible to not count the skipIf tests? 
(other than using if-else inside the test --not really a bad solution either 
;-)?
 
Thanks!

Regards,

Albert-Jan




~~

All right, but apart from the sanitation, the medicine, education, wine, public 
order, irrigation, roads, a 

fresh water system, and public health, what have the Romans ever done for us?

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


Re: [Tutor] conditional execution

2014-04-02 Thread Patti Scott


Thank you Emile, Zach, Chris and d.
  I am actually catching lots of my typos before I try to run anything ...



 From: spir 
To: tutor@python.org 
Sent: Wednesday, April 2, 2014 3:18 AM
Subject: Re: [Tutor] conditional execution
 

On 04/01/2014 06:24 PM, Zachary Ware wrote:
> Hi Patti,
>
> On Tue, Apr 1, 2014 at 11:07 AM, Patti Scott  wrote:
>> I've been cheating:  comment out the conditional statement and adjust the
>> indents. But, how do I make my program run with if __name__ == 'main':
>> main() at the end?  I thought I understood the idea to run a module called
>> directly but not a module imported.  My program isn't running, though.
>
> The simple fix to get you going is to change your ``if __name__ ==
> 'main':`` statement to ``if __name__ == '__main__':`` (add two
> underscores on each side of "main").  To debug this for yourself, try
> putting ``print(__name__)`` right before your ``if __name__ ...``
> line, and see what is printed when you run it in different ways.
>
> Hope this helps, and if you need any more help or a more in-depth
> explanation of what's going on, please don't hesitate to ask :)

And you don't even need this idiom if your module is only to be executed (not 
imported). Just write "main()".


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


Re: [Tutor] Vending machine problem.

2014-04-02 Thread bob gailer

On 4/1/2014 5:09 PM, Sebastien Gomez wrote:
I have started my code but there are some errors including indentation 
and syntax, please fix it if you can:


Did you miss my request that you send a copy to the tutor list 
(tutor@python.org)?


Were there any more specifications in the assignment?

Please take care of these; then I will respond. Also keep in mind that 
our goal is to help you think for yourself, so we may not fix it but 
rather help you understand and  fix the problems.


What tool did you use to discover multiple errors? If you try to run the 
program directly the Python interpreter will report the first error it 
finds and then stop.


In general it is a good idea to tell us (so please do so now)
- your operating system
- Python version
- what you use to edit and run the program

I am sorry to be so wordy and rigorous but we really need to know if we 
are to help.

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


Re: [Tutor] Vending machine problem.

2014-04-02 Thread bob gailer

On 4/2/2014 5:06 PM, Sebastien Gomez wrote:

i am using python 3.2
windows vista

This is my last email to you. Communicating with you is way too time 
consuming; you consistently do not provide all the information I 
request, nor do you include the tutor list in your responses.


If you want any more help you will have to ask it from the tutor list.

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


Re: [Tutor] Fwd: Python bingo game.

2014-04-02 Thread zhijun long
>>> matrix = [
... [1, 2, 5, 7, 9],
... [25, 67, 78, 23, 34],
... [33, 22, 66, 88, 98],
... [32, 31, 41, 56, 78],
... [21, 34, 58, 99, 76],
... ]
>>> for item in [[row[i] for row in matrix] for i in range(5)]:
... print item
...
[1, 25, 33, 32, 21]
[2, 67, 22, 31, 34]
[5, 78, 66, 41, 58]
[7, 23, 88, 56, 99]
[9, 34, 98, 78, 76]
>>>


2014-03-31 22:36 GMT+08:00 Hardik Gandhi :

>
> > Hello,
> >
> > Can some one help me with displaying a matrix vertically.
> >
> > For example my output matrix is:-
> >
> > [1 2 5 7 9]
> > [25 67 78 23 34]
> > [33 22 66 88 98]
> > [32 31 41 56 78]
> > [21 34 58 99 76]
> >
> > And i want my matrix to look like this:-
> > [1 25 33 32 21]
> > [2 67 22 31 34]
> > [5 78 66 41 58]
> > [7 23 88 56 99]
> > [9 34 98 78 76]
> >
> > Please, help me with the code in eclipse using py-dev as preference.
> >
> > Thank you
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Gmane not picking up messages lately

2014-04-02 Thread DaveA
Gmane doesn't seem to be getting messages from either python tutor or python 
list, for the last day or two.

I'm using NNTP NewsReader on Android, and there's no new messages. 

I'm sure it's not just an extraordinary lull, because I am still getting tutor 
emails. 

Anybody else want to comment? Is the gateway broken or the particular Android 
software? 

-- 
DaveA


Sent from Samsung tablet___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor