Re: [Tutor] FYI: An Introduction to Interactive Programming in Python

2013-04-09 Thread Alan Gauld

On 09/04/13 04:20, Len Conrad wrote:


  Computer scientists develop video game that teaches how to program in
  Java*

http://phys.org/news/2013-04-scientists-video-game-java.html


As an engineer I used to be embarrassed that people called it software 
engineering. Now they are calling this computer *science* oh dear...



CodeSpells was influenced by research that Esper and Foster conducted on 
how successful programmers learn their trade. They surveyed 30 computer 
scientists and identified five characteristics that are key to learn 
programming outside a classroom setting: activities must be structured 
by the person who is trying to learn; learning must be creative and 
exploratory; programming is empowering; learners have difficulty 
stopping once they start; and learners spend countless hours on the 
activity.

===

Since when did 30 become a representative sample size?


--
Alan G
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] FYI: An Introduction to Interactive Programming in Python

2013-04-09 Thread Mark Lawrence

On 09/04/2013 04:20, Len Conrad wrote:


  *wrong teaching language!  :)

  Computer scientists develop video game that teaches how to program in
  Java*

http://phys.org/news/2013-04-scientists-video-game-java.html

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



Please tone down your language.  Using four letter words starting with 
'j' on a Python mailing list is a bit offputting first thing in the 
morning :)


--
If you're using GoogleCrap™ please read this 
http://wiki.python.org/moin/GoogleGroupsPython.


Mark Lawrence

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


[Tutor] How to make a python script run on startup

2013-04-09 Thread daedae11
On Windows, how to make a python script run on startup?
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How to make a python script run on startup

2013-04-09 Thread Dave Angel

On 04/09/2013 04:20 AM, daedae11 wrote:

On Windows, how to make a python script run on startup?




Windows has a system scheduler, which you can add entries to, specifying 
what time(s) a particular entry is to run.  One of the choices is system 
startup.



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


Re: [Tutor] How to make a python script run on startup

2013-04-09 Thread Alexander Mark
There is a startup folder, usually on the start menu, you can add the script 
to. 

--ame

On Apr 9, 2013, at 4:20, daedae11  wrote:

> On Windows, how to make a python script run on startup?
> 
> 
> ___
> 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] How to make a python script run on startup

2013-04-09 Thread Sayan Chatterjee
Anything executable inside the start-up folder will run on start up!


On 9 April 2013 15:24, Alexander Mark  wrote:

> There is a startup folder, usually on the start menu, you can add the
> script to.
>
> --ame
>
> On Apr 9, 2013, at 4:20, daedae11  wrote:
>
> On Windows, how to make a python script run on startup?
>
>
> ___
> 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
>
>


-- 


--
*Sayan  Chatterjee*
Dept. of Physics and Meteorology
IIT Kharagpur
Lal Bahadur Shastry Hall of Residence
Room AB 205
Mob: +91 9874513565
blog: www.blissprofound.blogspot.com

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


Re: [Tutor] How to make a python script run on startup

2013-04-09 Thread eryksun
On Tue, Apr 9, 2013 at 5:54 AM, Alexander Mark  wrote:
> There is a startup folder, usually on the start menu, you can add the script
> to.

current user:
"%USERPROFILE%\Start Menu\Programs\Startup"

all users:
"%ALLUSERSPROFILE%\Start Menu\Programs\Startup"

Updating the latter will probably require elevation, which you do via
ShellExecute with the "runas" verb, using either pywin32 or ctypes. If
you don't want a console use the .pyw extension.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Flip a coin

2013-04-09 Thread Najam Us Saqib
Hi,

This program is killing me, I have been working on it for last 3 hours, I have 
tried my best but can't make it work, please help me out. 

The Problem:

Create a program that flips a coin 100 times and than tells you the number of 
tails and heads.

My code:

# Flip a coin

import random

flip_coin = 100
head = ""
tail = ""
n_head = 0
n_tail = 0
the_num = (raw_input("Press enter key to flip the coin!"))


#raw_input("Please Flip the Coin")

while flip_coin != 100:
    flip_coin = random.randrange(100) +1 
    if flip_coin <= 50:
         
     print "head"
    
    else: 
     print "tail"
    
    the_num = (raw_input("Press Enter to flip the coin"))
    n_head += 1
    n_tail += 1
    
    

print "The total numbers of heads are" ,n_head
print "The total numbers of tails are" ,n_tail

raw_input("\n\nPress the enter key to exit, thank you")

Thank you very much, looking forward to hear from you.

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


Re: [Tutor] Flip a coin

2013-04-09 Thread Sayan Chatterjee
flip_coin = 100

and then after a while

while flip_coin != 100:

It is contradicting.So the while loop is never executed. Just put flip_coin
= 0 and remove
head = ""
tail = ""

They are not necessary.

It should work.

Cheers,
Sayan


On 9 April 2013 17:20, Najam Us Saqib  wrote:

> Hi,
>
> This program is killing me, I have been working on it for last 3 hours, I
> have tried my best but can't make it work, please help me out.
>
> The Problem:
>
> Create a program that flips a coin 100 times and than tells you the number
> of tails and heads.
>
> My code:
>
> # Flip a coin
>
> import random
>
> flip_coin = 100
> head = ""
> tail = ""
> n_head = 0
> n_tail = 0
> the_num = (raw_input("Press enter key to flip the coin!"))
>
>
> #raw_input("Please Flip the Coin")
>
> while flip_coin != 100:
> flip_coin = random.randrange(100) +1
> if flip_coin <= 50:
>
>  print "head"
>
> else:
>  print "tail"
>
> the_num = (raw_input("Press Enter to flip the coin"))
> n_head += 1
> n_tail += 1
>
>
>
> print "The total numbers of heads are" ,n_head
> print "The total numbers of tails are" ,n_tail
>
> raw_input("\n\nPress the enter key to exit, thank you")
>
> Thank you very much, looking forward to hear from you.
>
> Regards,
> Najam.
>
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>


-- 


--
*Sayan  Chatterjee*
Dept. of Physics and Meteorology
IIT Kharagpur
Lal Bahadur Shastry Hall of Residence
Room AB 205
Mob: +91 9874513565
blog: www.blissprofound.blogspot.com

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


Re: [Tutor] Flip a coin

2013-04-09 Thread Steven D'Aprano

On 09/04/13 21:50, Najam Us Saqib wrote:

Hi,

This program is killing me, I have been working on it for last 3 hours, I have 
tried my best but can't make it work, please help me out.



Would you like to tell us what it is doing wrong, or should we guess?

My guess is below:


flip_coin = 100


Here you set flip_coin to 100.


while flip_coin != 100:


Here you test whether flip_coin is not equal to 100. Since it is 100, the while 
loop is skipped, and nothing you write inside the while loop is executed at all.


If you want to run something 100 times, use a for loop:

for i in range(100):
do_something()


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


Re: [Tutor] FYI: An Introduction to Interactive Programming in Python

2013-04-09 Thread Steven D'Aprano

On 09/04/13 17:50, Alan Gauld wrote:

On 09/04/13 04:20, Len Conrad wrote:


  Computer scientists develop video game that teaches how to program in
  Java*

http://phys.org/news/2013-04-scientists-video-game-java.html


As an engineer I used to be embarrassed that people called it software 
engineering. Now they are calling this computer *science* oh dear...



Computer science is a science, or to be technical, a branch of mathematics. It 
has about as much to do with the every day practice of writing programs as 
science does to the every day practice of building televisions -- that is to 
say, depending on how you look at it, either *not at all* or *completely*.


But in this case, it's less computer science and more pedagogy, which is the 
science and art of teaching.





CodeSpells was influenced by research that Esper and Foster conducted on how 
successful programmers learn their trade. They surveyed 30 computer scientists 
and identified five characteristics that are key to learn programming outside a 
classroom setting: activities must be structured by the person who is trying to 
learn; learning must be creative and exploratory; programming is empowering; 
learners have difficulty stopping once they start; and learners spend countless 
hours on the activity.
===

Since when did 30 become a representative sample size?



If they are randomly selected, 30 is likely plenty for a representative sample 
size. In surveys, a sample size of 30 gives you a margin of error of about 15%, 
which isn't too bad. (To drop that margin of error to 10% means increasing the 
sample size to about 65, and to 5%, you need about 250 people.)

In this case, I would be suspicious of the results, not because 30 is too small 
a sample, but because:

1) it is likely to be a biased selection

2) both computer scientists and educators are prone to fashions, and Java is 
one such fashion.



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


Re: [Tutor] How to make a python script run on startup

2013-04-09 Thread Kevin Ndung'u
anybody know how to do this on linux?

On 4/9/13, eryksun  wrote:
> On Tue, Apr 9, 2013 at 5:54 AM, Alexander Mark 
> wrote:
>> There is a startup folder, usually on the start menu, you can add the
>> script
>> to.
>
> current user:
> "%USERPROFILE%\Start Menu\Programs\Startup"
>
> all users:
> "%ALLUSERSPROFILE%\Start Menu\Programs\Startup"
>
> Updating the latter will probably require elevation, which you do via
> ShellExecute with the "runas" verb, using either pywin32 or ctypes. If
> you don't want a console use the .pyw extension.
> ___
> 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] How to make a python script run on startup

2013-04-09 Thread Sayan Chatterjee
Hope this link helps.:)
http://stackoverflow.com/questions/8339555/how-to-run-a-script-at-the-start-up-of-ubuntu


On 9 April 2013 19:18, Kevin Ndung'u  wrote:

> anybody know how to do this on linux?
>
> On 4/9/13, eryksun  wrote:
> > On Tue, Apr 9, 2013 at 5:54 AM, Alexander Mark 
> > wrote:
> >> There is a startup folder, usually on the start menu, you can add the
> >> script
> >> to.
> >
> > current user:
> > "%USERPROFILE%\Start Menu\Programs\Startup"
> >
> > all users:
> > "%ALLUSERSPROFILE%\Start Menu\Programs\Startup"
> >
> > Updating the latter will probably require elevation, which you do via
> > ShellExecute with the "runas" verb, using either pywin32 or ctypes. If
> > you don't want a console use the .pyw extension.
> > ___
> > 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
>



-- 


--
*Sayan  Chatterjee*
Dept. of Physics and Meteorology
IIT Kharagpur
Lal Bahadur Shastry Hall of Residence
Room AB 205
Mob: +91 9874513565
blog: www.blissprofound.blogspot.com

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


Re: [Tutor] Flip a coin

2013-04-09 Thread Mitya Sirenef

On 04/09/2013 07:50 AM, Najam Us Saqib wrote:

Hi,

>
> This program is killing me, I have been working on it for last 3 
hours, I have tried my best but can't make it work, please help me out.

>
> The Problem:
>
> Create a program that flips a coin 100 times and than tells you the 
number of tails and heads.

>
> My code:
>
> # Flip a coin
>
> import random
>
> flip_coin = 100
> head = ""
> tail = ""
> n_head = 0
> n_tail = 0
> the_num = (raw_input("Press enter key to flip the coin!"))
>
>
> #raw_input("Please Flip the Coin")
>
> while flip_coin != 100:
> flip_coin = random.randrange(100) +1
> if flip_coin <= 50:
>
>  print "head"
>
> else:
>  print "tail"
>
> the_num = (raw_input("Press Enter to flip the coin"))
> n_head += 1
> n_tail += 1
>
>
>
> print "The total numbers of heads are" ,n_head
> print "The total numbers of tails are" ,n_tail
>
> raw_input("\n\nPress the enter key to exit, thank you")
>
> Thank you very much, looking forward to hear from you.
>
> Regards,
> Najam.
>


You shouldn't start with writing code when you're not clear on how it
needs to work -- instead, start with pseudo code. In the same way, if
you can lift 200lbs you can start with 100lbs and then work your way up.

The pseudo code is a lot simpler to write than code:

# assume 0 is heads and 1 is tails

num_heads = num_tails = 0

- repeat 100 times:
get input from user
if input == quit: break loop

flip = random integer out of 0 and 1

if flip:
print tails
num_tails += 1
else:
print heads
num_heads += 1
print num_heads, num_tails

print Exiting...


To find out how to pick a random integer, see:

http://docs.python.org/2/library/random.html


 -m


--
Lark's Tongue Guide to Python: http://lightbird.net/larks/

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


Re: [Tutor] How to make a python script run on startup

2013-04-09 Thread eryksun
On Tue, Apr 9, 2013 at 8:35 AM, daedae11  wrote:
> I refer the msdn for ShellExecute, there isn't a "runas" verb, only "edit",
> "find", "open", "print", "properties".

Adding a file to the all users startup folder probably doesn't even
require elevation. Maybe even a regular user can do it, given the
default ProgramData NTFS permissions. I don't remember what the
defaults are.

Background:

NT 6 (Vista) added User Account Control (UAC), which adds the "run as
administrator" option. This launches a process with an elevated access
token.

ShellExecute allows the same with the "runas" verb. You can verify
whether it exists on your system for the exefile filetype (e.g.
python.exe):

C:\>reg query hkcr\exefile\shell\runas\command

HKEY_CLASSES_ROOT\exefile\shell\runas\command
(Default)REG_SZ"%1" %*
IsolatedCommandREG_SZ"%1" %*

On a related note, the old "runas.exe" console command lets you launch
a process with the credentials of an administrator account. However,
it can't 'elevate' the process.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How to make a python script run on startup

2013-04-09 Thread eryksun
On Tue, Apr 9, 2013 at 9:48 AM, Kevin Ndung'u  wrote:
>
> anybody know how to do this on linux?

For a desktop environment that implements freedesktop.org standards (X
Desktop Group), such as GNOME, KDE and Xfce, you can add .desktop
files per user to "$HOME/.config/autostart". System wide it's
"$XDG_CONFIG_DIRS/autostart".

http://standards.freedesktop.org/autostart-spec/latest/ar01s02.html
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] FYI: An Introduction to Interactive Programming in Python

2013-04-09 Thread brian arb
One game  wrote along time ago when I was first learning Python and App
Engine is http://cdacabeecdebcabab.appspot.com/
It's kind of a  non-interactive Sudoku puzzle, the only really interaction
is to click "solve this" or "display next puzzle" then to watch the python
code written attempt to solve the puzzle you click on the button "next
iteration" until you reach a solution or the code fails to resolve any more
of the cells.




On Mon, Apr 8, 2013 at 7:58 PM, Steven D'Aprano  wrote:

> On 09/04/13 06:38, brian arb wrote:
>
>> An Introduction to Interactive Programming in PythonJoe Warren, Scott
>>
>> Rixner, Stephen Wong and John Greiner
>>
>> This course is designed to be a fun introduction to the basics of
>> programming in Python. Our main focus will be on building simple
>> interactive games such as Pong, Blackjack and Asteroids.
>>
>> https://www.coursera.org/**course/interactivepython
>>
>
> Thanks for the link Brian.
>
> As an aside, I wonder, apart from Conway's Game of Life, which isn't
> actually a game at all, what's a non-interactive game?
>
>
>
> --
> Steven
> __**_
> 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] How to make a python script run on startup

2013-04-09 Thread Dave Angel

On 04/09/2013 05:54 AM, Alexander Mark wrote:

On Apr 9, 2013, at 4:20, daedae11  wrote:


On Windows, how to make a python script run on startup?


_

(Top-posted comment moved AFTER the question)

> There is a startup folder, usually on the start menu, you can add the 
script to.

>

But does anything in the startup folder run BEFORE any user logs in? 
It's been a long time since I had to run Windows, but I didn't think so.



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


Re: [Tutor] Flip a coin

2013-04-09 Thread Dave Angel

On 04/09/2013 07:50 AM, Najam Us Saqib wrote:

Hi,

This program is killing me, I have been working on it for last 3 hours, I have 
tried my best but can't make it work, please help me out.

The Problem:

Create a program that flips a coin 100 times and than tells you the number of 
tails and heads.



Nowhere does that say to ask the user for input, or even to wait for 
user input.  So start with Miya's pseudo-code, remove the input stuff, 
and try to turn that into code.


Keep it very simple till it works, then consider whether any 
fancy-ing-up is useful.


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


Re: [Tutor] How to make a python script run on startup

2013-04-09 Thread Dave Angel

On 04/09/2013 06:58 AM, daedae11 wrote:

(Please don't top-post.  And don't forget to include the list in your 
cc.  I'm forwarding it for you)



Which module to should I use to add entries to that system scheduler?




The system scheduler is an interactive (gui) program that comes with the 
OS.  No idea what module would mean in this context.   And I haven't run 
Windows in a long time, except for occasionally helping others.


Every version of Windows does its best to move things around and confuse 
any administrative user.


For XP, try:
  http://support.microsoft.com/kb/308569

and notice there's a distinction between "When my computer starts" and 
"When a user logs on"


--
DaveA

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


[Tutor] Impossible Else as Exception

2013-04-09 Thread Jordan
I want to know what exception should be raised if there is a bug in my 
code that allows an else statement to be triggered, because the else 
condition in my code should be impossible, unless there is an error in 
my code.  What exception should I raise so that if my code is wrong it 
will raise an exception which will give me a trace back?  Which would be 
most Pythonic?


Example:

if condition is 1:
do something with 1
elif condition is 2:
do something with 2
else: # Impossible unless the code above is flawed.
Raise Exception
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Phyton script for fasta file (seek help)

2013-04-09 Thread Danny Yoo
Side note: I would strongly suggest using the biopython libraries for
the basic parsing.  FASTA parsing has been done and replicated so many
times that it's almost a hazing ritual for the practicing
bioinformatician.  The biopython folks have written a parser, so
perhaps you can reuse it.

http://biopython.org/wiki/Main_Page
http://biopython.org/DIST/docs/tutorial/Tutorial.html#htoc11


About reading from either standard input or as command line arguments,
see the 'fileinput' library:

http://docs.python.org/3/library/fileinput.html

It automatically handles reading either from sys.stdin, or by opening
up the name of the file passed as a command line argument.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How to make a python script run on startup

2013-04-09 Thread eryksun
On Tue, Apr 9, 2013 at 12:35 PM, Dave Angel  wrote:
> But does anything in the startup folder run BEFORE any user logs in? It's
> been a long time since I had to run Windows, but I didn't think so.

The contents of the startup folders are executed in the current
session after logon. The same applies to run keys such as
"HKLM\Software\Microsoft\Windows\CurrentVersion\Run".

I wasn't taking "startup" to mean literally before any user has logged
on. But yes, if that's the requirement, you can use the Task Scheduler
service to start a program as a batch process in session 0 (or instead
create your own service).

Just as an FYI, in the "Home" versions of Windows the task scheduler
can't store logon credentials, so to run at startup you have to use
LOCALSERVICE or SYSTEM.

To automate creating a task use the "schtasks" command. For example,
to create a task named "Python" that runs python.exe at startup under
the LOCALSERVICE account, execute the following from an elevated
shell:

schtasks /Create /TN Python /RU LOCALSERVICE /SC ONSTART /TR
C:\Python33\python.exe

This will run as a non-interactive service in session 0. There won't
be a visible GUI or console window to interact with in your desktop
session.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] FYI: An Introduction to Interactive Programming in Python

2013-04-09 Thread Alan Gauld

On 09/04/13 13:47, Steven D'Aprano wrote:


Since when did 30 become a representative sample size?


If they are randomly selected, 30 is likely plenty for a representative
sample size. In surveys, a sample size of 30 gives you a margin of error
of about 15%, which isn't too bad.


Hmm, if I'd gone to my manager (and especially the finance director) 
with a project proposal based on assumptions with a 15% margin they'd 
have thrown me out. And if I told them I'd developed 5 key assumptions 
based on that same proposal I'd probably have been fired! I'd be looking 
for something like 300+ samples for a project like this to claim that my 
5 key principles were valid. And its not like there is a shortage of 
computer scientists to ask (although admittedly harder to find ones with 
no formal computer training)!



1) it is likely to be a biased selection


My suspicion is they just asked around their local department!
But maybe I'm just overly suspicious...


2) both computer scientists and educators are prone to fashions, and
Java is one such fashion.


I don't care about the language since their 5 principles of learning are 
language independent. It was the idea that you could define 5 key 
principles needed to learn to program from a sample size of 30...


If they came to me to peer review that I'd have been telling them to go 
back and do a bigger survey!


--
Alan G
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] How to make a python script run on startup

2013-04-09 Thread Alan Gauld

On 09/04/13 09:20, daedae11 wrote:

On Windows, how to make a python script run on startup?


The same way you make anything run on startup there is nothing magical 
about Python code.


You can schedule it, add it to the registry or put it in the users 
startup folder if you want it at login rather than system start...


--
Alan G
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] Impossible Else as Exception

2013-04-09 Thread Mark Lawrence

On 09/04/2013 20:22, Jordan wrote:

I want to know what exception should be raised if there is a bug in my
code that allows an else statement to be triggered, because the else
condition in my code should be impossible, unless there is an error in
my code.  What exception should I raise so that if my code is wrong it
will raise an exception which will give me a trace back?  Which would be
most Pythonic?

Example:

if condition is 1:
 do something with 1
elif condition is 2:
 do something with 2
else: # Impossible unless the code above is flawed.
 Raise Exception
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor



The RuntimeError builtin see 
http://docs.python.org/3/library/exceptions.html#RuntimeError.


--
If you're using GoogleCrap™ please read this 
http://wiki.python.org/moin/GoogleGroupsPython.


Mark Lawrence

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


Re: [Tutor] FYI: An Introduction to Interactive Programming in Python

2013-04-09 Thread Prasad, Ramit
Alan Gauld wrote:
> 
> On 09/04/13 13:47, Steven D'Aprano wrote:
> 
> >> Since when did 30 become a representative sample size?
> >
> > If they are randomly selected, 30 is likely plenty for a representative
> > sample size. In surveys, a sample size of 30 gives you a margin of error
> > of about 15%, which isn't too bad.
> 
> Hmm, if I'd gone to my manager (and especially the finance director)
> with a project proposal based on assumptions with a 15% margin they'd
> have thrown me out. And if I told them I'd developed 5 key assumptions
> based on that same proposal I'd probably have been fired! I'd be looking
> for something like 300+ samples for a project like this to claim that my
> 5 key principles were valid. And its not like there is a shortage of
> computer scientists to ask (although admittedly harder to find ones with
> no formal computer training)!

Well, 15% error margin is from statistics and provable, but the layman
usually hears "30 people" and thinks "that's far too small". I certainly
did it too. :) 

Error margins are one of those surprising things like the Birthday 
Problem (at least to me). Seems like it should not be true but it is.
http://en.wikipedia.org/wiki/Birthday_problem

Honestly, with surveys the method of the survey itself makes a 
difference. This includes things like question wording, question
order, and even survey format (free form, multiple choice, etc).

Much like scientific studies, I am more interested in *how* it
was done than in some summarized (frequently sensationalized)
"findings". In my opinion, a flawed methodology is more 
frequently a problem than a small sample size. 

> 
> > 1) it is likely to be a biased selection
> 
> My suspicion is they just asked around their local department!
> But maybe I'm just overly suspicious... 

Overly suspicious or concerned based on experience? :)


~Ramit


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@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Retrieving data from a text file

2013-04-09 Thread Debashish Saha
In the following you can see data from a ephemeris.txt file. Now I want to
retrieve several columns(say, for example the column starting with 00:00,
27.69 and 44.1) and name the array as x,y,z. What do I have to I tried this

x, y, z = numpy.loadtxt("ephemeris.txt", unpack=True)
And  got this error

"ValueError: could not convert string to float: Date__(UT)__HR:MN"
Could you also help me in converting that HR:MN into minute only?

Date__(UT)__HR:MN R.A.__(a-apparent)__DEC\
**\
 2013-Jan-01 00:00 *   14 31 27.69 -12 29 44.1\
 2013-Jan-01 00:01 *   14 31 27.71 -12 29 44.1\
 2013-Jan-01 00:02 *   14 31 27.72 -12 29 44.2\
 2013-Jan-01 00:03 *   14 31 27.73 -12 29 44.2\
 2013-Jan-01 00:04 *   14 31 27.75 -12 29 44.3\
 2013-Jan-01 00:05 *   14 31 27.76 -12 29 44.3\
 2013-Jan-01 00:06 *   14 31 27.77 -12 29 44.4\
 2013-Jan-01 00:07 *   14 31 27.78 -12 29 44.4\
 2013-Jan-01 00:08 *   14 31 27.80 -12 29 44.4\
 2013-Jan-01 00:09 *   14 31 27.81 -12 29 44.5\p
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] building a website with python

2013-04-09 Thread Benjamin Fishbein
Hello. I learned Python this past year (with help from many of you) and wrote 
many programs for my small business. Now I want to build a website. I acquired 
the domain name through godaddy.com (bookchicken.com) but have not found 
hosting yet.
I learned html, css, and javascript via codeacademy.org, but have never built a 
website.
I would like to build it with Python, and was wondering if you could give me 
some pointers about what I need to learn first: Django is the thing to use? And 
do I need specific hosting to use python or are all hosts basically the same.
Thanks,
Ben


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


Re: [Tutor] building a website with python

2013-04-09 Thread Prasad, Ramit
Benjamin Fishbein wrote:
> 
> Hello. I learned Python this past year (with help from many of you) and wrote 
> many programs for my
> small business. Now I want to build a website. I acquired the domain name 
> through godaddy.com
> (bookchicken.com) but have not found hosting yet.
> I learned html, css, and javascript via codeacademy.org, but have never built 
> a website.
> I would like to build it with Python, and was wondering if you could give me 
> some pointers about what
> I need to learn first: Django is the thing to use? And do I need specific 
> hosting to use python or are
> all hosts basically the same.
> Thanks,
> Ben

http://wiki.python.org/moin/WebFrameworks

Lots of Python frameworks to choose from, though Django is the most 
famous/popular. There are
lighter frameworks too, depending on what you need.

Your hosting solution to support Python, and I do not believe all hosts support 
Python. You 
should double check with whatever host you choose.


~Ramit


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@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] building a website with python

2013-04-09 Thread Marc Tompkins
On Tue, Apr 9, 2013 at 2:54 PM, Prasad, Ramit wrote:

> Your hosting solution (needs) to support Python, and I do not believe all
> hosts support Python. You
> should double check with whatever host you choose.
>

Almost all commercial web hosts offer limited Python support (running as an
Apache module), but this is NOT sufficient to run the larger Python web
frameworks, such as Django.  What you need to check for is support for
"long-running processes"; as of the last time I checked, GoDaddy, 1and1,
and most of the budget hosts don't offer that - so no Django
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] building a website with python

2013-04-09 Thread Walter Prins
Hello Benjamin,

On 9 April 2013 22:31, Benjamin Fishbein  wrote:

> Hello. I learned Python this past year (with help from many of you) and
> wrote many programs for my small business. Now I want to build a website. I
> acquired the domain name through godaddy.com (bookchicken.com) but have
> not found hosting yet.
> I learned html, css, and javascript via codeacademy.org, but have never
> built a website.
> I would like to build it with Python, and was wondering if you could give
> me some pointers about what I need to learn first: Django is the thing to
> use? And do I need specific hosting to use python or are all hosts
> basically the same.
>

Django is good but arguably big and a bit intimidating if you're starting
out.  There are many alternatives, from so called "micro" frameworks like
"bottle" (which is implemented in a single Python file) to CherryPy to
Flask.  Personally, I'd suggest having a look at Web2Py.  It's not quite as
heavy as Django but very capable nonetheless.  It also deploys easily,
including to Google App Engine and elsewhere, and includes a very capable
Admin interface that also includes a basic IDE, thus allowing you to tweak
the site right from within the site should you have the need. Here's a nice
little presentation about Web2Py:
http://www.slideshare.net/blackthorne/web2pyweb-development-like-a-boss
... and a tutorial to get you going:
http://killer-web-development.com/section/1/0

Not all web hosts are the same -- you need to ensure you have Python
available with the host you use.  There are dedicated Python hosts out
there.  (PythonAnywhere comes to mind.)  As a slightly different
possibility, you might consider running your own virtual host in the cloud.
 You would need to learn a bit about administering a server box, but this
route does give you the ultimate control over your website and environment.
 Here's a link to Rackspace with which I've had good experiences thus far
for your review:
http://www.rackspace.com/cloud/servers/

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


Re: [Tutor] Impossible Else as Exception

2013-04-09 Thread Oscar Benjamin
On 9 April 2013 20:22, Jordan  wrote:
> I want to know what exception should be raised if there is a bug in my code
> that allows an else statement to be triggered, because the else condition in
> my code should be impossible, unless there is an error in my code.  What
> exception should I raise so that if my code is wrong it will raise an
> exception which will give me a trace back?  Which would be most Pythonic?
>
> Example:
>
> if condition is 1:
> do something with 1
> elif condition is 2:
> do something with 2
> else: # Impossible unless the code above is flawed.
> Raise Exception

AssertionError is raised when an assert statement fails. Since this
situation is essentially an implicit assert it would make sense to use
that.


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


Re: [Tutor] building a website with python

2013-04-09 Thread James Reynolds
As far as hosts, I use digital ocean. It's a cloud based thing like EC2,
but it's cheap (5/10/20 and up). You will of course have to configure
everything yourself, but that's not such a bad thing.

It will give you good experience configuring a linux box as well and
learning about deployment.

Since I'm a django developer, I'm going to suggest you learn that of
course. But, there are others out there. However, with Django you get the
Django eco system, which is large and very helpful.

For example, you can use fabric for easy deployment, south for database
migrations, celery for task management and so and so forth.

Even simple websites could find some use in south and fabric.


On Tue, Apr 9, 2013 at 6:06 PM, Walter Prins  wrote:

> Hello Benjamin,
>
> On 9 April 2013 22:31, Benjamin Fishbein  wrote:
>
>> Hello. I learned Python this past year (with help from many of you) and
>> wrote many programs for my small business. Now I want to build a website. I
>> acquired the domain name through godaddy.com (bookchicken.com) but have
>> not found hosting yet.
>> I learned html, css, and javascript via codeacademy.org, but have never
>> built a website.
>> I would like to build it with Python, and was wondering if you could give
>> me some pointers about what I need to learn first: Django is the thing to
>> use? And do I need specific hosting to use python or are all hosts
>> basically the same.
>>
>
> Django is good but arguably big and a bit intimidating if you're starting
> out.  There are many alternatives, from so called "micro" frameworks like
> "bottle" (which is implemented in a single Python file) to CherryPy to
> Flask.  Personally, I'd suggest having a look at Web2Py.  It's not quite as
> heavy as Django but very capable nonetheless.  It also deploys easily,
> including to Google App Engine and elsewhere, and includes a very capable
> Admin interface that also includes a basic IDE, thus allowing you to tweak
> the site right from within the site should you have the need. Here's a nice
> little presentation about Web2Py:
> http://www.slideshare.net/blackthorne/web2pyweb-development-like-a-boss
> ... and a tutorial to get you going:
> http://killer-web-development.com/section/1/0
>
> Not all web hosts are the same -- you need to ensure you have Python
> available with the host you use.  There are dedicated Python hosts out
> there.  (PythonAnywhere comes to mind.)  As a slightly different
> possibility, you might consider running your own virtual host in the cloud.
>  You would need to learn a bit about administering a server box, but this
> route does give you the ultimate control over your website and environment.
>  Here's a link to Rackspace with which I've had good experiences thus far
> for your review:
> http://www.rackspace.com/cloud/servers/
>
> Walter
>
> ___
> 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] Impossible Else as Exception

2013-04-09 Thread Alan Gauld

On 09/04/13 20:22, Jordan wrote:

I want to know what exception should be raised if there is a bug in my
code that allows an else statement to be triggered, because the else
condition in my code should be impossible,


class BuggyCodeError(StandardError): pass

Maybe?

Seriously, exceptions are not intended for handling buggy code.
You should be removing the bugs using assertions and tests.

The exception to raise is whatever is appropriate to how you
got into that else and that depends on the nature of the
conditions.

One option might be a ValueError or maybe an IOError.
I'm not sure I agree with the suggestion to use AssertionError because 
that implies it came from an assertion. I'd rather define a bespoke 
error class than use that.




if condition is 1:
 do something with 1
elif condition is 2:
 do something with 2
else: # Impossible unless the code above is flawed.
 Raise Exception


If its really impossible for the condition to be anything other than 1 
or 2 then an elif should not be needed. If it is possible to get another 
value think about what causes could exist to get the

other value ( even if it is a code error!!) and describe the cause(s).

--
Alan G
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] Impossible Else as Exception

2013-04-09 Thread Steven D'Aprano

On 10/04/13 05:22, Jordan wrote:

I want to know what exception should be raised if there is a bug in my code 
that allows an else statement to be triggered, because the else condition in my 
code should be impossible, unless there is an error in my code.  What exception 
should I raise so that if my code is wrong it will raise an exception which 
will give me a trace back?  Which would be most Pythonic?

Example:

if condition is 1:
 do something with 1
elif condition is 2:
 do something with 2
else: # Impossible unless the code above is flawed.
 Raise Exception



The above isn't a great example, because the sample code *is* flawed.
The short reason why it is flawed is this:

You use identity tests (using `is`) instead of equality tests (using
`==`) which makes the above code fragile and dependent on the exact
version and implementation of Python being used. There are two rules
for when to use `is`:

1) Only use `is` when comparing to None;

2) (For everything else) If you have to ask if you should use `is`,
   the answer is No.


As given, your question cannot be answered simply. It depends on the
circumstances. Here are the two most common cases:


1) You're testing data you receive from a user, the caller, or another
part of the program. You know what the data should be, but you can't be
sure that it will be. Here's a toy example:


def func(n):
"""Do something useful. Argument n must be 1 or 2."""
if n == 1:
do_this()
elif n == 2:
do_that()
else:
# Y U No Listen? I told you that n must be 1 or 2!
...


So what should I put in place of the dots? The answer depends on the
exact tests being performed, but the two most common cases are:

ValueError, if the argument has the wrong value;

TypeError, if the argument has the wrong type.


In this case, I would go with ValueError:

else:
 raise ValueError('n must be 1 or 2, not %r' % n)



1) You're testing the *internal logic* of your code. In this case, you're
sure of what the data will be, but out of some tiny lingering doubt that
maybe *you* have made a mistake, you want to check just to be sure. Here
is a toy example:


def spam(n):
"""Returns 'spam' n times. Guarantees to return spam."""
if n <= 0: n = 1
return ' '.join(['spam']*n)


def breakfast(hunger=3):
s = "toast and %s and eggs" % spam(hunger)
if "spam" in s:  # This should always be true.
return s
else:
# This can never happen!
raise RuntimeError('no spam in breakfast? yuck!')


So RuntimeError is a good choice for this. But if you are *sure* that
the error condition can *never* happen, but not *absolutely sure* and
you still want to check just in case you're mistaken, then an even
better way to write it is:

def breakfast(hunger=3):
s = "toast and %s and eggs" % spam(hunger)
assert "spam" in s, 'no spam in breakfast? yuck!'
return s



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


Re: [Tutor] FYI: An Introduction to Interactive Programming in Python

2013-04-09 Thread Steven D'Aprano

On 10/04/13 06:58, Prasad, Ramit wrote:


Much like scientific studies, I am more interested in *how* it
was done than in some summarized (frequently sensationalized)
"findings". In my opinion, a flawed methodology is more
frequently a problem than a small sample size.


+1000 on that.


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


Re: [Tutor] FYI: An Introduction to Interactive Programming in Python

2013-04-09 Thread Steven D'Aprano

On 10/04/13 06:04, Alan Gauld wrote:

On 09/04/13 13:47, Steven D'Aprano wrote:


Since when did 30 become a representative sample size?


If they are randomly selected, 30 is likely plenty for a representative
sample size. In surveys, a sample size of 30 gives you a margin of error
of about 15%, which isn't too bad.


Hmm, if I'd gone to my manager (and especially the finance director) with a 
project proposal based on assumptions with a 15% margin they'd have thrown me 
out.


The 15% figure comes from surveys where people are asked to rate something on 
some scale, say from 1 to 7. If your sample of 30 gives an average rating of 5, 
then a 15% margin of error corresponds to plus or minus 1: the true average is 
likely to be 4, 5 or 6. Given that the question being asking is fundamentally 
subjective, and you have no idea whether Fred's rating of 5 and Wilma's rating 
of 5 mean the same thing, I think that plus or minus 1 is pretty much as good 
as you can reasonably expect. Additional samples just adds spurious precision 
that looks good but doesn't *mean* anything.

But what do I know? :)




My suspicion is they just asked around their local department!
But maybe I'm just overly suspicious...


Nah, I reckon you've hit the nail right on the head.



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


Re: [Tutor] Impossible Else as Exception

2013-04-09 Thread Danny Yoo
>> if condition is 1:
>>  do something with 1
>> elif condition is 2:
>>  do something with 2
>> else: # Impossible unless the code above is flawed.
>>  Raise Exception
>
>
>
> The above isn't a great example, because the sample code *is* flawed.
> The short reason why it is flawed is this:
>
> You use identity tests (using `is`) instead of equality tests (using
> `==`) which makes the above code fragile and dependent on the exact
> version and implementation of Python being used.


I don't think we can say this.  The code above is not literal.
Otherwise, we should be technically obligated to raise the exact same
objection to "do something with 2".



Going back to the original question: perhaps an assertion here would
be sufficient.  Something like:

assert False, "Impossible situation"

would document that the case analysis above should be technically
exhaustive, and that reaching the assertion should be treated as an
internal error.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] building a website with python

2013-04-09 Thread Steven D'Aprano

On 10/04/13 07:31, Benjamin Fishbein wrote:

Hello. I learned Python this past year (with help from many of you) and wrote 
many programs for my small business. Now I want to build a website. I acquired 
the domain name through godaddy.com (bookchicken.com) but have not found 
hosting yet.
I learned html, css, and javascript via codeacademy.org, but have never built a 
website.
I would like to build it with Python, and was wondering if you could give me 
some pointers about what I need to learn first: Django is the thing to use? And 
do I need specific hosting to use python or are all hosts basically the same.



Django is an excellent product but pretty heavyweight. Consider CherryPy for a 
lighter experience with a more gentle learning curve.

http://www.cherrypy.org/



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


Re: [Tutor] Chapter 3 Projects

2013-04-09 Thread ALAN GAULD
Forwarded to group. Please use ReplyAll when responding to tutor posts.


>
> From: Mariel Jane Sanchez 
>To: Alan Gauld  
>Sent: Wednesday, 10 April 2013, 1:06
>Subject: Re: [Tutor] Chapter 3 Projects
> 
>
>
>Thank you so much, I finally figured out the 2nd project. I still have 
>problems with 1 and 3 so I'll try to be more clear. 
>
>It would help if you posted your code. It shouldn't be long and its much 
>easier to see where you are getting confused if we can see the code!
Chapter 3 Booklet PDF is attached
>
>Chapter 3 
>Project 1 on page 90 on the PDF
>"1. Write a program that gets a score from the player and rates it on the 
>following:
>- Given a score between 0-999, the program should display the message, 
>'Nothing to brag about."
>- Given a score between 1000-, the program should display the message, 
>'Good score.'
>- Given a score over , the program should display the message, 'Very 
>impressive!"
>- If the score is a negative number, the program should display the message, 
>'That is not a legal score!'"
>
>I'd do it like this

score = raw_input('score? ')
if score < 0: print 'That is not a legal score'
elif score > : print 'Very impressive'
elif  >= score >= 1000: print 'Good score.'
elif  # student to complete...


>
>I tried using range as another tutor suggested which would make sense since 
>it's dealing with ranges but I still get the same result as before. Can you 
>explain how to do this step by step, if you don't mind?
>
>You can use range by substituting the elif lines above with:

elif score in range(1000,1): print 'Good score.'

Project 3 (Guess My Number code on page 35)
>"Modify the Guess My Number program from the chapter so that the player has 
>only five guesses. If the player runs out of guesses, the program should end 
>the game and display an appropriately chastising message"
>For my case, I somehow, accidentally programmed it to have only 5 tries and 
>also put a message that says " You ran out of tries," which I think is a good 
>progress. However, on the last try; when I put my guess, hit enter and got the 
>guess wrong, the message loops. 
>
>I  showed you the structure for this last time.
Without seeing your code I have no idea what you did wrong.


When you first started on Python, how did you do this project so there's no 
loop at the end?
>
>I did not do those projects because I did not do the course that you are 
>doing. 
I did not in fact do any courses, I just read the official documents and made 
up my own projects. So I can't tell you how I did it. I can only comment on how 
I might 
do it now.
 
Alan Gauld
Author of the Learn To Program website

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] Impossible Else as Exception

2013-04-09 Thread eryksun
On Tue, Apr 9, 2013 at 8:17 PM, Danny Yoo  wrote:
>
> Going back to the original question: perhaps an assertion here would
> be sufficient.  Something like:
>
> assert False, "Impossible situation"

Like "if __debug__" statements, assert statements are skipped by the
compiler if optimization is enabled. If you want an AssertionError
here even for optimized code, then explicitly raise
AssertionError('Impossible situation').
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] building a website with python

2013-04-09 Thread Don Jennings

On Apr 9, 2013, at 5:31 PM, Benjamin Fishbein wrote:

> Hello. I learned Python this past year (with help from many of you) and wrote 
> many programs for my small business. Now I want to build a website. I 
> acquired the domain name through godaddy.com (bookchicken.com) but have not 
> found hosting yet.
> I learned html, css, and javascript via codeacademy.org, but have never built 
> a website.
> I would like to build it with Python,

So, are you really just wanting to use python to build a static site? If so, 
you can run a python web framework on your local machine and then deploy the 
static files to any decent host you find. For example, there are instructions 
for setting up this scenario using flask, jinja2 and markdown[1]. If you have 
experience with ReStructuredText (here's a comparison of the two markups [2]), 
it's fairly easy to use docutils to produce the html files.
 
> and was wondering if you could give me some pointers about what I need to 
> learn first: Django is the thing to use? And do I need specific hosting to 
> use python or are all hosts basically the same.

If you do want python web apps, I've had pleasant results from webfaction.com 
(though I don't do anything terribly difficult :>).

You've gotten some good feedback, but I suspect you will get better information 
if you provide more information about your goals for the site.

Take care,
Don

[1] 
https://nicolas.perriault.net/code/2012/dead-easy-yet-powerful-static-website-generator-with-flask/
[2] http://www.unexpected-vortices.com/doc-notes/markdown-and-rest-compared.html
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Set Reply-To field to Tutor@python.org

2013-04-09 Thread DoanVietTrungAtGmail
FWIW, I'd like to reverse my answer, and now I agree with Oscar's 29 Jan
suggestion to make "Reply-to-tutor-list" the default.

Lately, several times a tutor had to forward to the list an email meant for
the list but sent to him only, by mistake. On the other hand, the
wrote-to-1-person-but-mistakenly-sent-to-list scenario that I had in mind
is rarer, therefore Oscar's suggestion is better than my previous reply.

Trung


On Wed, Jan 30, 2013 at 6:33 AM, Nick W  wrote:

> My personal opinion (with whatever limited weight that has on this list
> since I've only answered a few questions - and probably half of them I've
> accidentally only sent to the op)/how I read it is that RFC 2822 actually
> allows lists to set reply-to header; by my view the list software is
> forwarding to everyone else and therefor counts as the most recent
> sender/author. I admit that that is a somewhat different conclusion to
> others that I've read as to the meaning of 2822, but that seems logical to
> me and also my personal preference is for having the reply-to header be set
> to the list address.
> Nick
>
>
> On Tue, Jan 29, 2013 at 7:44 AM, Albert-Jan Roskam wrote:
>
>>
>>
>> >
>> > To summarize existing opinions on this matter:
>> >
>> > http://marc.merlins.org/netrants/listreplyto.html
>> >
>> > You might want to familiarize yourself with existing literature on the
>> > matter before starting a new flame war.
>>
>> Hmmm... False alarm?
>>
>> Page blocked
>>
>> The page you've been trying to access was blocked.
>> Reason: Access Denied! The requested URL is a Spyware site.
>> Transaction ID is 5107F01CFF920603D57F.
>> ___
>> 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 maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] building a website with python

2013-04-09 Thread Amit Saha
On Wed, Apr 10, 2013 at 12:03 PM, Don Jennings  wrote:
>
> On Apr 9, 2013, at 5:31 PM, Benjamin Fishbein wrote:
>
>> Hello. I learned Python this past year (with help from many of you) and 
>> wrote many programs for my small business. Now I want to build a website. I 
>> acquired the domain name through godaddy.com (bookchicken.com) but have not 
>> found hosting yet.
>> I learned html, css, and javascript via codeacademy.org, but have never 
>> built a website.
>> I would like to build it with Python,
>
> So, are you really just wanting to use python to build a static site? If so, 
> you can run a python web framework on your local machine and then deploy the 
> static files to any decent host you find. For example, there are instructions 
> for setting up this scenario using flask, jinja2 and markdown[1]. If you have 
> experience with ReStructuredText (here's a comparison of the two markups 
> [2]), it's fairly easy to use docutils to produce the html files.

Good suggestion. I wrote this article showing how you can do that
using Sphinx. Please take a look [1]. The advantage of using something
like Sphinx is that it gives you static HTML, which you can simply
copy and paste. As you will see in the article, it is also very easy
to upload your HTML to GitHub pages.

[1] http://amitsaha.github.io/site/notes/articles/sphinx/static_html.html

Hope it is a solution which suits you. Also, getting familiar with
Sphinx may also help you in your future Python projects - since it is
*the* de-facto standard for documenting Python projects.

Best,
Amit.

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


Re: [Tutor] building a website with python

2013-04-09 Thread Amit Saha
On Wed, Apr 10, 2013 at 7:31 AM, Benjamin Fishbein
 wrote:
> Hello. I learned Python this past year (with help from many of you) and wrote 
> many programs for my small business. Now I want to build a website. I 
> acquired the domain name through godaddy.com (bookchicken.com) but have not 
> found hosting yet.
> I learned html, css, and javascript via codeacademy.org, but have never built 
> a website.
> I would like to build it with Python, and was wondering if you could give me 
> some pointers about what I need to learn first: Django is the thing to use? 
> And do I need specific hosting to use python or are all hosts basically the 
> same.

Django is great, but like others have suggested, so called "micro"
frameworks may be a good start. I personally would suggest Flask [1].
The documentation is extensive and excellent.


[1] http://flask.pocoo.org/docs/

-Amit.

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


Re: [Tutor] building a website with python

2013-04-09 Thread Amit Saha
On Wed, Apr 10, 2013 at 12:47 PM, Amit Saha  wrote:
> On Wed, Apr 10, 2013 at 7:31 AM, Benjamin Fishbein
>  wrote:
>> Hello. I learned Python this past year (with help from many of you) and 
>> wrote many programs for my small business. Now I want to build a website. I 
>> acquired the domain name through godaddy.com (bookchicken.com) but have not 
>> found hosting yet.
>> I learned html, css, and javascript via codeacademy.org, but have never 
>> built a website.
>> I would like to build it with Python, and was wondering if you could give me 
>> some pointers about what I need to learn first: Django is the thing to use? 
>> And do I need specific hosting to use python or are all hosts basically the 
>> same.
>
> Django is great, but like others have suggested, so called "micro"
> frameworks may be a good start. I personally would suggest Flask [1].
> The documentation is extensive and excellent.
>
>
> [1] http://flask.pocoo.org/docs/

And, I will add Frozen-Flask (http://pythonhosted.org/Frozen-Flask/),
which basically gives you a set of static files, which you can just
dump on any host with no "special" features. I haven't tried it
myself, though.

-Amit.


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


Re: [Tutor] building a website with python

2013-04-09 Thread Benjamin Fishbein
> 
> You've gotten some good feedback, but I suspect you will get better 
> information if you provide more information about your goals for the site.
> 

Thanks for your help, everyone. There are some specific things I want the site 
to do, and I'm not sure which would be the best developing tool or hosting for 
these.
The python software I developed is for selling used books.
It takes book ISBN numbers as input and returns the best prices being offered.
It uses the selenium module...I'm not sure how that would translate into a 
website.
There are many websites that offer similar book price comparisons, but mine is 
different...it's user-friendly. Any volunteer at a thrift shop or library can 
use it...just a series of simple directions and yes/no questions, taking the 
user all the way from scanning or typing in an ISBN to dropping the parcel off 
at the post office. (The local libraries I worked with more than doubled their 
used-book revenues.) I want to expand this nationwide, and bookchicken.com 
seems to be the way to do it.
So much of the program is simple enough. But there's two parts of the program 
that I anticipate being important to what host, development tool I use:
1. ISBNs (the books the thrift shop/ library has) being sent to various 
websites and returning the data to my site to be analyzed by my program.
2. Maneuvering through the website of the company buying the books. I don't 
want to send the user off to a warehouse's site with a list of books to sell to 
them. They'll still be entering their address and name, but it'll be on my 
site, that I then send to the warehouse's page, get a packing slip and shipping 
label from the warehouse, and give these documents to the user to print out.

I'm not sure if this changes anyone's ideas about which host/ developer I 
should use. Please let me know.
Thanks,
Ben


 


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


Re: [Tutor] Chapter 3 Projects

2013-04-09 Thread Dave Angel

On 04/09/2013 08:29 PM, ALAN GAULD wrote:

Forwarded to group. Please use ReplyAll when responding to tutor posts.




From: Mariel Jane Sanchez 
To: Alan Gauld 
Sent: Wednesday, 10 April 2013, 1:06
Subject: Re: [Tutor] Chapter 3 Projects



Thank you so much, I finally figured out the 2nd project. I still have problems 
with 1 and 3 so I'll try to be more clear.

It would help if you posted your code. It shouldn't be long and its much easier 
to see where you are getting confused if we can see the code!

Chapter 3 Booklet PDF is attached


Chapter 3
Project 1 on page 90 on the PDF
"1. Write a program that gets a score from the player and rates it on the 
following:
- Given a score between 0-999, the program should display the message, 'Nothing to 
brag about."
- Given a score between 1000-, the program should display the message, 
'Good score.'
- Given a score over , the program should display the message, 'Very 
impressive!"
- If the score is a negative number, the program should display the message, 'That 
is not a legal score!'"

I'd do it like this


score = raw_input('score? ')


That would need to be:
score = int(raw_input('score? ')


if score < 0: print 'That is not a legal score'
elif score > : print 'Very impressive'
elif  >= score >= 1000: print 'Good score.'
elif  # student to complete...




I tried using range as another tutor suggested which would make sense since 
it's dealing with ranges but I still get the same result as before. Can you 
explain how to do this step by step, if you don't mind?

You can use range by substituting the elif lines above with:


elif score in range(1000,1): print 'Good score.'

Project 3 (Guess My Number code on page 35)

"Modify the Guess My Number program from the chapter so that the player has only 
five guesses. If the player runs out of guesses, the program should end the game and 
display an appropriately chastising message"
For my case, I somehow, accidentally programmed it to have only 5 tries and also put a 
message that says " You ran out of tries," which I think is a good progress. 
However, on the last try; when I put my guess, hit enter and got the guess wrong, the 
message loops.

I  showed you the structure for this last time.

Without seeing your code I have no idea what you did wrong.


When you first started on Python, how did you do this project so there's no 
loop at the end?


I did not do those projects because I did not do the course that you are doing.

I did not in fact do any courses, I just read the official documents and made
up my own projects. So I can't tell you how I did it. I can only comment on how 
I might
do it now.

Alan Gauld
Author of the Learn To Program website

http://www.alan-g.me.uk/



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




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


Re: [Tutor] Impossible Else as Exception

2013-04-09 Thread Jordan
Thank you all for the feedback and suggestions.  I have never used an 
assertion, before so I will read up on the concept.  But this last email 
about the optimizations makes me want to go with an AssertionError 
exception, since assert is skipped if the compiler is told to optimize.
Alan you are right, the code should be better tested, but test driven 
development seems like it would take me forever to complete even small 
tasks, there is so much to be tested.  I have limited time to program 
with my wife and kids, but do you think test driven development is still 
the way to go?


On 04/10/2013 02:43 AM, eryksun wrote:

On Tue, Apr 9, 2013 at 8:17 PM, Danny Yoo  wrote:

Going back to the original question: perhaps an assertion here would
be sufficient.  Something like:

 assert False, "Impossible situation"

Like "if __debug__" statements, assert statements are skipped by the
compiler if optimization is enabled. If you want an AssertionError
here even for optimized code, then explicitly raise
AssertionError('Impossible situation').
___
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