[Tutor] Pygraphics crashed

2013-05-16 Thread Jim Mooney
How do I uninstall modules? I installed Pygraphics, which worked fine,
along with some other mods, like numpy, but when I installed 64 bit py
2.7
I get the message The _imaging C module is not installed when
running a prog that worked fine before. I think I have a higher
dot-version - Py 2.7.4 as opposed to 2.7.3  - what's the easiest way
to fix this? Will uninstalling and reinstalling the modules do
anything or do I have to revert to an older Py (I'm on Win 7)

And regardless of the answer to that I still want to know how to
uninstall modules. Do I just find and delete them? And are they all in
the same place?

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


[Tutor] Can't install latest PIL

2013-05-16 Thread Jim Mooney
Okay, I'm trying to install the latest PIL on win 7. It claims Python
2.7 was not found in the registry, although it's installed, on a path,
and works fine. The install box lets you type in a directory but won't
accept typing. I'm stumped.

I guess the way around this is to know what I have to put in the registry.

-- 
Jim Mooney

“For anything that matters, the timing is never quite right, the
resources are always a little short, and the people who affect the
outcome are always ambivalent.”
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Can't install latest PIL

2013-05-16 Thread eryksun
On Thu, May 16, 2013 at 2:12 AM, Jim Mooney cybervigila...@gmail.com wrote:
 Okay, I'm trying to install the latest PIL on win 7. It claims Python
 2.7 was not found in the registry, although it's installed, on a path,
 and works fine. The install box lets you type in a directory but won't
 accept typing. I'm stumped.

 I guess the way around this is to know what I have to put in the registry.

Make sure you have the correct architecture. The builds from
PythonWare are 32-bit. Christoph Gohlke has 64-bit builds here:

http://www.lfd.uci.edu/~gohlke/pythonlibs/#pil

As far as the registry goes, installing for everyone uses HKLM (local
machine), else an installation uses HKCU (current user). The installed
versions are in subkeys of [HKLM|HKCU]\Software\Python\PythonCore.
Also, for WoW64 processes (i.e. 32-bit running on 64-bit Windows) the
Software key is redirected to Software\Wow64Node.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Can't install latest PIL

2013-05-16 Thread Walter Prins
Hi,


On 16 May 2013 07:12, Jim Mooney cybervigila...@gmail.com wrote:

 Okay, I'm trying to install the latest PIL on win 7. It claims Python
 2.7 was not found in the registry, although it's installed, on a path,
 and works fine. The install box lets you type in a directory but won't
 accept typing. I'm stumped.


Are you using Python 32-bit or Python 64-bit?   I'm guessing/seem to
remember from your other posts, it's 64-bit and I'm guessing you're trying
to install PIL for 32-bit Windows, which behaves in the way you describe if
you try to use it on a Python 64-bit build.  If I'm right, and you're
indeed running 64-bit Windows, then you need to instead get a 64-bit build
of PIL to match your Python build.   Unfortunately the official PIL page
does not contain 64-bit builds, however you can get an unofficial (meaning,
done by a third party) version here:
http://www.lfd.uci.edu/~gohlke/pythonlibs/#pil

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


Re: [Tutor] Pygraphics crashed

2013-05-16 Thread eryksun
On Thu, May 16, 2013 at 2:06 AM, Jim Mooney cybervigila...@gmail.com wrote:

 And regardless of the answer to that I still want to know how to
 uninstall modules. Do I just find and delete them? And are they all in
 the same place?

You should be able to uninstall msi or exe packages just like any
other Windows program. pip has an uninstall command if you used it to
install a package. If you used easy_install, you'll have to manually
delete associated eggs and egg-info directories from
Lib\site-packages, defunct scripts in Scripts, and also edit
Lib\site-packages\easy-install.pth to remove deleted cruft. It's
definitely not easy_uninstall.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] question already discussed with oscar benjamin

2013-05-16 Thread Oscar Benjamin
On 7 May 2013 21:10, Linsey Raaijmakers lm.raaijmak...@gmail.com wrote:
 Hi,

 Im trying to work with the help Oscar provided me, but I still get stuck :(

For the benefit of everyone else here, this is referring to a question
that was asked on python-list. The discussion there went off-list and
I recommended that it take place on-list but on this list instead of
python-list.

 So what I'm trying to do now is write the program with the following input
 and output:

The input/output specification below was my own suggestion of a
subproblem to solve. The idea is that actions with integer identifiers
have integer start/apex/end times and the program should read a file
containing those and identify when actions are occurring
simultaneously. The events in the file appear in order of start time.

 Input:
 action,start,apex,stop
 3, 12, 13, 15
 4, 15, 15, 15
 3, 20, 21, 25
 5, 21, 23, 30
 ...

 And when you run your program it prints out:
 actions, start, stop
 [3], 12, 13
 [], 14,15
 [4], 15, 15
 [], 16, 19
 [3], 20, 21
 [3, 5], 21, 21
 [5], 22, 23
 ...

 I don't want to use the stop. Only the start till apex is important.

 This is the code I have now:

Not it's not. This code doesn't work. Can you post a complete program
that actually runs rather than just a segment of it? See here:
http://sscce.org/


 now = onset_list[0]
 end = apex_list[0]
 active = action_list[0]

 for i in range(1,len(onset_list)):
   next_start = onset_list[i]
   next_end = apex_list[i]
   next_active = action_list[i]
   prev_end = apex_list[i-1]

   while next_start  end:
 print active+\t+now+'\t'+end
 end = next_end
 now = next_start
 active = next_active
   print active+','+next_active+'\t'+now+'\t'+next_end

This will just print each event and the following event. That is not
what you want. You need to keep a list of currently active events and
as you loop forward through the times you should remove events that
have finished and add events that have started.

 But my output will print now:

 31213
 4,4  1515
 4 1515
 3,3   2021
 3,5   2025

 How do I fix that it doesn't print out the double ones?

The problem is not that it prints the double ones. The problem is that
it does not keep track of a list of currently active events. I'll make
the problem a bit simpler: make a program that gives the following
input/output.

Input:
action,start,apex,stop
3, 12, 13, 15
4, 15, 15, 15
3, 20, 21, 25
5, 21, 23, 30
...

And when you run your program it prints out:
actions, time
[3], 12
[3], 13
[], 14
[4], 15
[], 16
[], 17
[], 18
[], 19
[3], 20
[3, 5], 21
[5], 22
[5], 23
...

The first column in this output is the list of active events at the
times given in the second column. Your code will need to actually have
a list that it adds and removes from as events start and stop


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


Re: [Tutor] Looking for python 3 tutorial

2013-05-16 Thread Alan Gauld

On 08/05/13 03:30, Sky Flyinz wrote:

Where can I find a  web programming python tutorial online either book?


How do you define web programming?
Do you mean building web sites? Or scraping web sites?
Or do you mean using web APIs?

There is a web programming HowTo on the python web site that will get 
you started but without context its hard to recommend anything.


At a general level the book Python Network Programming covers the basics.


  Are social media, email, live talk, and etc that called web
programming for browser?


They are all on the web and you can do programming on a browser but 
that's usually via JavaScript. Alternatively you can emulate a browser 
which is usually called web scraping. OTOH if you want to create a 
social media platform then that would be server side programming.


Its not clear what exactly you want to find out.

--
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


[Tutor] Web forms was: Re: (no subject)

2013-05-16 Thread Alan Gauld
Please use a meaningful subject when posting it makes it easier to find 
things in the archives and identify related posts.


On 10/05/13 21:44, Krish Nagpal wrote:

I have a quick question based on python 2.7. Do you know how to write a
web server with a form.


I have no idea what you mean.
A web server reacts to http requests and responds with HTML.
HTML defines how to create forms. You just need to output the 
appropriate HTML text and your user will see a form.



When the webserver gets a GET request,
I need to serve the HTML document with a form. In response to a POST, i
want to write the resulting data to a form.


How do you distinguish between serving the form and writing data
to the form? I don't understand the difference? Do you mean you want the 
same form but in some cases populated with data and in others blank?



Do you know how to do this. Can you please help me quickly.


The clearer you express the problem the quicker you will get an answer.

HTH
--
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] Making a Primary Number List generator

2013-05-16 Thread eryksun
On Thu, May 16, 2013 at 1:42 AM, eryksun eryk...@gmail.com wrote:
 On the other hand a BufferedWriter will buffer the remaining 3000
 bytes that can't be written. You won't find out until an exception is
 raised when the file is closed:

Actually it was buffering all 4000 bytes. I forgot about the fast path
that initially fills the buffer. The default buffer size is 4 KiB to
match the block size on my ext4 file system. So if I limit file size
to 1000 bytes, I can 'write' 5096 bytes before it raises an exception:

 resource.setrlimit(resource.RLIMIT_FSIZE, (1000, -1))
 f = open('temp.bin', 'wb')
 f.write(b'spam'*1274)
5096
 f.write(b's')
Traceback (most recent call last):
  File stdin, line 1, in module
OSError: [Errno 27] File too large
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Python Idle Crashing

2013-05-16 Thread kyle seebohm
I recently created a program that searches through a computer's drive to make a 
list of all the files in that drive. However, the drive I am attempting to 
parse through is extremely large and when I run my program, it runs for about 5 
or 10 minutes then proceeds to not respond and not finish parsing through the 
entire drive. Is there a way around this or does the drive just contain too 
many files?___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Python Idle Crashing

2013-05-16 Thread frederico Batista
I don't think running this on Idle is the best.
Did you try to run your program in the command line?
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Issue with string method: str(variable ** n)

2013-05-16 Thread Rafael Knuth
Hej,

I wrote a tiny little program which I was hoping would take a number as
input, square and print it:

square = input (Enter a number. )
print (str(square) +  squared is  + str(square ** 2))

It seems I can't work with variables within the str() string method, and I
was wondering if anyone can help?

PS. I am using Python 3.3.0

Thank you in advance!

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


Re: [Tutor] Issue with string method: str(variable ** n)

2013-05-16 Thread Dave Angel

On 05/16/2013 02:58 PM, Rafael Knuth wrote:

Hej,

I wrote a tiny little program which I was hoping would take a number as
input, square and print it:

square = input (Enter a number. )
print (str(square) +  squared is  + str(square ** 2))

It seems I can't work with variables within the str() string method, and I
was wondering if anyone can help?

PS. I am using Python 3.3.0

Thank you in advance!

Rafael


In Python 3.3.0, input returns a string.  So square is a string.  There 
isn't any meaning to squaring a string.



You probably want either:

square = float(input(Enter a number.)
or
square = int(input(Enter a number.)

Suggestion for next time - include the error traceback.

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


Re: [Tutor] Issue with string method: str(variable ** n)

2013-05-16 Thread Zachary Ware
On Thu, May 16, 2013 at 1:58 PM, Rafael Knuth rafael.kn...@gmail.com wrote:
 Hej,

Hi Rafael,

 I wrote a tiny little program which I was hoping would take a number as
 input, square and print it:

 square = input (Enter a number. )
 print (str(square) +  squared is  + str(square ** 2))

 It seems I can't work with variables within the str() string method, and I
 was wondering if anyone can help?

 PS. I am using Python 3.3.0

In the future, it's always very helpful to post any tracebacks you
get, everything from Traceback (most recent call last): to the last
thing printed.

In this case, it seems that your problem is that in Python3, input()
returns the input as a string.  Python2's input() function would
actually evaluate the input, which was incredibly insecure.

You can fix your program by calling int() on square at the end of your
print call.  If I were writing this myself, I would do this, though:

number = int(input(Enter a number. ))
print({} squared is {}.format(number, number**2))

You might find the tutorial page on Input and Output[1] instructive,
particularly about the format method I used above.

Hope this helps,

Zach

[1] http://docs.python.org/3/tutorial/inputoutput.html


 Thank you in advance!

 Rafael




 ___
 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] Python Idle Crashing

2013-05-16 Thread Dave Angel

On 05/16/2013 02:17 PM, kyle seebohm wrote:

I recently created a program that searches through a computer's drive to make a 
list of all the files in that drive. However, the drive I am attempting to 
parse through is extremely large and when I run my program, it runs for about 5 
or 10 minutes then proceeds to not respond and not finish parsing through the 
entire drive. Is there a way around this or does the drive just contain too 
many files?





Not clear why you would think that Idle had anything to do with it.  It 
didn't crash, it hung, or maybe is just taking a very long time, or 
maybe it has an infinite loop in the code, or you're thrashing after 
filling up memory?


Still, if you think it was IDLE, it's simple to just run the program 
without IDLE.


What's your environment, besides extremely large drive?  What OS, what 
version of Python?  And what's your code look like?


What does top say?  Is the disk light still blinking?  Do you have any 
symbolic links and does your code handle them correctly?



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


Re: [Tutor] Issue with string method: str(variable ** n)

2013-05-16 Thread Rafael Knuth
Thank you - that makes perfectly sense.

Also, I am new to the list, and I appreciate your suggestion.
I will include error tracebacks in the future.

All the best,
Rafael


On Thu, May 16, 2013 at 9:14 PM, Dave Angel da...@davea.name wrote:

 On 05/16/2013 02:58 PM, Rafael Knuth wrote:

 Hej,

 I wrote a tiny little program which I was hoping would take a number as
 input, square and print it:

 square = input (Enter a number. )
 print (str(square) +  squared is  + str(square ** 2))

 It seems I can't work with variables within the str() string method, and I
 was wondering if anyone can help?

 PS. I am using Python 3.3.0

 Thank you in advance!

 Rafael


  In Python 3.3.0, input returns a string.  So square is a string.  There
 isn't any meaning to squaring a string.


 You probably want either:

 square = float(input(Enter a number.)
 or
 square = int(input(Enter a number.)

 Suggestion for next time - include the error traceback.

 --
 DaveA

 __**_
 Tutor maillist  -  Tutor@python.org
 To unsubscribe or change subscription options:
 http://mail.python.org/**mailman/listinfo/tutorhttp://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] Word Jumble - Chpt4 (Explanation)

2013-05-16 Thread Arvind Virk
Hi guys!
This is my first post so go gentle. I'm just getting into Python programming 
and am having an issue understanding the Word Jumble Game.
import random
WORDS = ('python','jumble','easy','difficult','lower','high')word = 
random.choice(WORDS)correct = wordjumble = 
while word:position = random.randrange(len(word))jumble += 
word[position]word = word[:position] + word[(position+1):]  
==
I cannot understand what it is trying to do in the while loop.If the word was 
python and position lets say was 3 then jumble would = python(3). I cannot 
understand what the next line does! Please help!
Thanks in advance!

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


Re: [Tutor] Python Idle Crashing

2013-05-16 Thread Prasad, Ramit
Dave Angel wrote:
 On 05/16/2013 02:17 PM, kyle seebohm wrote:
  I recently created a program that searches through a computer's drive to 
  make a list of all the
 files in that drive. However, the drive I am attempting to parse through is 
 extremely large and when I
 run my program, it runs for about 5 or 10 minutes then proceeds to not 
 respond and not finish parsing
 through the entire drive. Is there a way around this or does the drive just 
 contain too many files?
 
 
 
 
 Not clear why you would think that Idle had anything to do with it.  It
 didn't crash, it hung, or maybe is just taking a very long time, or
 maybe it has an infinite loop in the code, or you're thrashing after
 filling up memory?
 
 Still, if you think it was IDLE, it's simple to just run the program
 without IDLE.
 
 What's your environment, besides extremely large drive?  What OS, what
 version of Python?  And what's your code look like?
 
 What does top say?  Is the disk light still blinking?  Do you have any
 symbolic links and does your code handle them correctly?
 

Also, what version of Python? What OS? What file system? Do you have any 
logging (actual logs or even just print statements to console)?


~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] Word Jumble - Chpt4 (Explanation)

2013-05-16 Thread Prasad, Ramit
Arvind Virk wrote:
 Hi guys!
 
 This is my first post so go gentle. I'm just getting into Python programming 
 and am having an issue
 understanding the Word Jumble Game.
 
 import random
 
 WORDS = ('python','jumble','easy','difficult','lower','high')
 word = random.choice(WORDS)
 correct = word
 jumble = 
 
 while word:
     position = random.randrange(len(word))
     jumble += word[position]
     word = word[:position] + word[(position+1):]
 
 ==
 
 I cannot understand what it is trying to do in the while loop.
 If the word was python and position lets say was 3 then jumble would = 
 python(3). I cannot understand
 what the next line does! Please help!
 
 Thanks in advance!
 

The best way to understand a program is to watch what it is 
doing and follow through the code. This is called debugging.
Simple programs like this you might be able to debug in your
mind but in a real program chances are you will need a debugger
or some other method. A very common way to debug is to put in 
print statements so you can follow the actions of data. Look
at the code I put below and the output. Can you follow?

 word = 'python'
 jumble = 
 while word:
... position = random.randrange(len(word))
... print 'position {0} | jumble {1}'.format( position, jumble )
... tempchar = word[position]
... jumble += tempchar
... word = word[:position] + word[(position+1):]
... print 'After jumble {0} | word {1} | tempchar {2}'.format( jumble, 
word, tempchar )
... 
position 5 | jumble 
After jumble n | word pytho | tempchar n
position 2 | jumble n
After jumble nt | word pyho | tempchar t
position 3 | jumble nt
After jumble nto | word pyh | tempchar o
position 1 | jumble nto
After jumble ntoy | word ph | tempchar y
position 0 | jumble ntoy
After jumble ntoyp | word h | tempchar p
position 0 | jumble ntoyp
After jumble ntoyph | word  | tempchar h


So based on the above output I would say that it is removing a 
random character from word and adding it to jumble to create a 
jumbled version of the word. Of course, the std library
can do it for you better. :) I leave the exercise of actually
understanding the character manipulation to you as a learning
exercise, but if you get stuck feel free to post back.

 t = list(python)
 random.shuffle(t)
 ''.join(t)
'optynh'


~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] Can't install latest PIL

2013-05-16 Thread Jim Mooney
Make sure you have the correct architecture. The builds from
PythonWare are 32-bit. Christoph Gohlke has 64-bit builds here:

http://www.lfd.uci.edu/~gohlke/pythonlibs/#pil

==
Okay, I installed the 64 bit for Py 2.7, it installed, I see  PIL
directory in Site-Packages. (Actually, it's the Pillow fork, but it
still seems to be named PIL)  I tried import image from pil and got
the following error: SyntaxError   invalid syntax (python_init.py,
line 1)

I don't see where that prog is, so it's an install somewhere and I
don't want to mess with it anyway.

Oh well, be nice to get back to learning Python after wrestling with
editors, installs, and Windows ;')

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


Re: [Tutor] Pygraphics crashed

2013-05-16 Thread Devin Jeanpierre
On Thu, May 16, 2013 at 2:06 AM, Jim Mooney cybervigila...@gmail.com wrote:
 How do I uninstall modules? I installed Pygraphics, which worked fine,
 along with some other mods, like numpy, but when I installed 64 bit py
 2.7
 I get the message The _imaging C module is not installed when
 running a prog that worked fine before. I think I have a higher
 dot-version - Py 2.7.4 as opposed to 2.7.3  - what's the easiest way
 to fix this? Will uninstalling and reinstalling the modules do
 anything or do I have to revert to an older Py (I'm on Win 7)

On windows it's generally easiest to use a 32 bit Python. If you
uninstall python, and install a 32 bit version and the 32 bit modules
and so on, it should work.

By the way, do you mind if I ask why you're using PyGraphics? It's
only meant to be used for education (and even there, AFAIK the only
users are the University of Toronto (and even there, I think they
stopped using it because they switched to Python 3 for Coursera and
didn't care enough to upgrade PyGraphics (I am mad about this))).

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


Re: [Tutor] Pygraphics crashed

2013-05-16 Thread Jim Mooney
 By the way, do you mind if I ask why you're using PyGraphics? It's
 only meant to be used for education (and even there, AFAIK the only
 users are the University of Toronto (and even there, I think they
 stopped using it because they switched to Python 3 for Coursera and
 didn't care enough to upgrade PyGraphics (I am mad about this))).


Yeah, I'm tired of fighting 64 bit windows. I'm going to uninstall
everything and use 32 bit I was reading some advice to use 64 bit for
speed but I'm only learning - I don't need to keep wrestling with this
crap just get top speed for twenty line programs ;')

PyGraphics was an import in a program right at the front of a book I'm
using. Worked fine for displaying jpgs very easily, before I started
fooling with 64 bit. Let me see, the book is called:
Practical Progamming - an introduction to computer science using
Python by Jennifer Campbell, et al.

It's not my main book - it's just for doing something more active
while I slug through Guttag's MIT open courseware on Python. Guttag
covers all the bases, but in the meantime I want to see pretty
pictures and see what Python can do ;')

Right now I'm using both Py 2.7 and Py 3.3 since I want to learn 3.3
but half the good libs are still in 2.7.

Actually, neither the book or Guttag is pure Python, but just using
Python to teach computer science. I'm a retired webmaster and hacked
away just enough at javascript, jquery, and php to get something done
on a site, but I figured I'd actually learn this from the ground up
now that I have time and don't have to be hustling a site all the
time, and just grab some jquery and get it done. I may have to look at
a dedicated Python book for detail, since the book and course I have
admit they just scant Python to get on with computer science.

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


Re: [Tutor] Can't install latest PIL

2013-05-16 Thread James Reynolds
You may want to consider pillow. Oil hasn't been maintained in some time.
 On May 16, 2013 6:12 PM, Jim Mooney cybervigila...@gmail.com wrote:

 Make sure you have the correct architecture. The builds from
 PythonWare are 32-bit. Christoph Gohlke has 64-bit builds here:

 http://www.lfd.uci.edu/~gohlke/pythonlibs/#pil

 ==
 Okay, I installed the 64 bit for Py 2.7, it installed, I see  PIL
 directory in Site-Packages. (Actually, it's the Pillow fork, but it
 still seems to be named PIL)  I tried import image from pil and got
 the following error: SyntaxError   invalid syntax (python_init.py,
 line 1)

 I don't see where that prog is, so it's an install somewhere and I
 don't want to mess with it anyway.

 Oh well, be nice to get back to learning Python after wrestling with
 editors, installs, and Windows ;')

 Jim
 ___
 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] Word Jumble - Chpt4 (Explanation)

2013-05-16 Thread Marc Tompkins
On Thu, May 16, 2013 at 1:03 PM, Arvind Virk arvind.s.v...@hotmail.co.ukwrote:

 import random

 WORDS = ('python','jumble','easy','difficult','lower','high')
 word = random.choice(WORDS)
 correct = word
 jumble = 

 while word:
 position = random.randrange(len(word))
 jumble += word[position]
 word = word[:position] + word[(position+1):]

 ==

 I cannot understand what it is trying to do in the while loop.
 If the word was python and position lets say was 3 then jumble would =
 python(3). I cannot understand what the next line does! Please help!

 First, about while word - A 'while' loop runs as long as its condition
evaluates to True; an explanation of what evaluates to True can be found
here: http://docs.python.org/2/library/stdtypes.html, but for our purposes
it boils down to as long as 'word' is not an empty string, keep going.

Second, what it's doing inside that while loop - it's picking a random
letter out of 'word', adding it to the end of 'jumble', and then removing
it from 'word'.  It's doing it by means of slices:  it takes all of 'word'
up to (but not including) 'position', then adds all of 'word' starting one
character AFTER 'position'.  'word' is now one character shorter than it
started out; keep this up long enough and you'll be left with an empty
string, which evaluates to False - and the 'while' loop terminates.

This is definitely not the most efficient way to do things, but it's a
pretty good introduction to slices (which are awesome, by the way.)
There's a very good introduction to Python's slice notation about halfway
down this page: http://docs.python.org/2/tutorial/introduction.html, in
section 3.1.2 Strings.  Just remember that lists and indices start with
0, not 1, and you'll be on your way.

Finally, as Ramit mentioned, print statements (or print() functions, if
you're on Python 3) are your friend!  Don't be afraid or ashamed to put in
lots of them whenever you're not sure what your code is doing!  (Just
remember to take out the unnecessary one when you're done.)
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Can't install latest PIL

2013-05-16 Thread Jim Mooney
On 16 May 2013 16:11, James Reynolds eire1...@gmail.com wrote:
 You may want to consider pillow. Oil hasn't been maintained in some time.

Actually, I installed Pillow. But then I deleted everything and
started over with 32 bit. I got greedy figuring I'd get the fastest Py
with 64 bit, but there are too many kludges involved and I'm tired of
it so heave-ho on all the 64 bit.

Back to 32 bit. All modules and showing pretty pictures with Py work
again. It doesn't pay to be greedy (except with regular expressions,
of course)

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


Re: [Tutor] Python Idle Crashing

2013-05-16 Thread Alan Gauld

On 16/05/13 19:17, kyle seebohm wrote:

I recently created a program that searches through a computer's drive to
make a list of all the files in that drive. However, the drive I am
attempting to parse through is extremely large and when I run my
program, it runs for about 5 or 10 minutes then proceeds to not respond
and not finish parsing through the entire drive.


First, don't run programs on real data using IDLE. IDLE is for 
developing programs not running them.


Second, 5-10 minutes is not that long, how do you know it had stopped? 
Do you have progress markers printed that stopped printing? If not I 
suggest you add them - just a dot after each file (or each 10, 100, etc 
files) will do. Have you checked Task Manager (assuming windows, top on 
*nix) to see if the process is still using CPU?



--
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] Word Jumble - Chpt4 (Explanation)

2013-05-16 Thread Alan Gauld

On 16/05/13 21:03, Arvind Virk wrote:


This is my first post so go gentle. I'm just getting into Python
programming and am having an issue understanding the Word Jumble Game.


Welcome.
First thing is we have no idea what Chapter 4 refers to so please tell 
us the source you are working from (alsoi OS and Python version helps too)
Secondly tell us what happens when you run it and what you expected and 
what you got and why you are surprised/puzzled.




import random

WORDS = ('python','jumble','easy','difficult','lower','high')
word = random.choice(WORDS)
correct = word


FWIW I don't understand the above line. It does nothing useful and 
correct is not used again...



jumble = 

while word:
 position = random.randrange(len(word))
 jumble += word[position]
 word = word[:position] + word[(position+1):]



Also since there are no print statements it all seems a tad pointless, 
are you sure that's the whole program?



--
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] Can't install latest PIL

2013-05-16 Thread eryksun
On Thu, May 16, 2013 at 6:12 PM, Jim Mooney cybervigila...@gmail.com wrote:
 I tried import image from pil and got the following error:
 SyntaxError   invalid syntax (python_init.py, line 1)

If you see a syntax error, that means your code could not be compiled.
Python's parser doesn't grok import image from pil. In natural
language we have the freedom to swap the order of clauses, but
programming languages are generally more rigid. The correct order is
from pil import image -- but actually it has to be from PIL import
Image.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Pygraphics crashed

2013-05-16 Thread eryksun
On Thu, May 16, 2013 at 6:15 PM, Jim Mooney cybervigila...@gmail.com wrote:
 How do I install PIL with easy-install? I used that once but forget
 how.  I seem to recall reading it installs a version that is Py native
 and doesn't choke on your OS. Or did I read that wrong?

I recommend pip instead of easy_install because it allows you to
easily uninstall.

First install distribute:
http://python-distribute.org/distribute_setup.py

Next install pip:
https://raw.github.com/pypa/pip/master/contrib/get-pip.py

Quickstart guide:
http://www.pip-installer.org/en/1.3.1/quickstart.html

On Windows, pip and easy_install are a bit limited. I gather that the
new Wheel package format (.whl) and compatibility tags should solve
the problem (see PEPs 427 and 425). The development version of pip
supports Wheel. As is, pip works just fine for installing pure Python
packages from source. easy_install also supports binary eggs, but I
dislike not having an easy way to uninstall. At least an exe/msi
installer lets you uninstall using the Windows control panel.

If you have a supported C compiler configured, you can use pip to
install packages that have self-contained C extensions (i.e. no
dependencies -- such as psutil or cython). Visual Studio [Express] is
recommended (2008 for 2.6-3.2; 2010 for 3.3), especially if C++ is
used, but MinGW-w64 can be made to work. The big problem here is
Windows lacks dependency management for installing libraries and
development files (headers and import libs) to known system locations.
So compiling an extension module that has dependencies needs to be
configured manually.

PIL has a lot of dependencies: libjpeg, libtiff, zlib, freetype2,
littleCMS, libwebp, and Tcl/Tk. Building it is a moderately
challenging process on Windows -- not really suited for a beginner.
Building NumPy/SciPy would be even more work since they need a Fortran
compiler, too. Fortunately for Windows users, Christoph Gohlke has
already done all the hard work for dozens of the most popular
packages.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor