Re: [Tutor] the and command

2007-08-24 Thread Mike Hansen
 

 -Original Message-
 
...
  for num in l2:
   if num in l3 and num in l4 and num in l5 and num in l6:
   possible.append(num)

Yikes! Glancing at the code, I was reading l3, l4, l5, l6 as the numbers
13, 14, 15, 16..(Thirteen, Fourteen, Fifteen, Sixteen). I'd avoid using
variables named like that since the lowercase L looks like a one (l, 1)
in many fonts.

Mike
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] FAQ [Was Re: Python Book Recommendations [Was:....]]

2007-08-16 Thread Mike Hansen
 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Alan Gauld
 Sent: Tuesday, August 14, 2007 10:06 AM
 To: tutor@python.org
 Subject: Re: [Tutor] FAQ [Was Re: Python Book Recommendations 
 [Was:]]
 
 
 Tim Michelsen [EMAIL PROTECTED] wrote
 
  is there a FAQ for this list where we could put all these 
  recommendations?
 
 Someone (Mike Hansen?) started one a while back, but like most such
 ventures the trick is in maintaining it! I'm not sure where it is or 
 what the
 status is.
 
 Alan G 
 

I'm a couple of days behind on my reading of the tutor list. The tutor
FAQ used to reside at http://pyfaq.infogami.com/, but its new home is
http://effbot.org/pyfaq/tutor-index.htm. I thought I remember seeing
some of the questions on the python.org site, but I can't seem to find
them now. I thought the original intent was to make it into a wiki to
allow it to be easily updated, but I'm not sure what became of that. I
just compiled the content and got list member's feedback. I got the ball
rolling and hoped others would update and add questions as desired. Of
course, I also hoped that it would be a good resource to direct people
to common questions.

Kent's suggestion of updating the following wiki pages is probably best:

http://wiki.python.org/moin/PythonBooks
http://wiki.python.org/moin/BeginnersGuide/NonProgrammers
http://wiki.python.org/moin/BeginnersGuide/Programmers  

Mike
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Bookpool sale on Addison Wesley

2007-08-09 Thread Mike Hansen
 -Original Message-
 From: Bill Campbell
 Sent: Thursday, August 09, 2007 10:54 AM
 To: tutor@python.org
 Subject: Re: [Tutor] Bookpool sale on Addison Wesley
 
 I've found bookpool.com to generally have better prices on
 technical books than Amazon or Powells.  They're generally the
 first place I look.
 
 (my only assocation with any of them is as a customer).
 
 ...
 Bill

Bookpool is pretty good. Half.com and nerdbooks.com are other places I
look for cheaper tech books.

Mike
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] comparing two numpy arrays

2007-08-07 Thread Mike Hansen
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Andy Cheesman
 
 Hi people,
 
 If I've two numpy arrays, is there a non-looping way of finding common
 values. (the example below has identical shapes for the 
 arrays but this
 may not be the case in my scenario)
 
 e.g
 a = array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
 b = array([ 5,  6,  7,  8,  9, 10, 11, 12, 13, 14])
 
 answer = array([ 5,6,7,8,9])
 
 Thanks
 
 Andy

You might try sets.

http://docs.python.org/lib/types-set.html

I'm guessing that you'd need to convert the arrays to sets. Maybe
convert the arrays to lists or tuples then to sets? Maybe you might be
able to directly convert the numpy arrays to sets? I haven't used numpy,
so you'll need to experiment. 

Mike
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Large Scale Python websites

2007-08-07 Thread Mike Hansen
  Is anyone aware of any large scale web apps developed in Python? 
  Please let
  me know of any that you know of...

I think that reddit.com switched from LISP to Python a while back.

Mike
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] while Loop

2007-07-26 Thread Mike Hansen
 -Original Message-
 Subject: Re: [Tutor] while Loop
 
 Oops, didn't notice the uppercase U, thanks Luke.
 
 - Original Message - 
 Subject: Re: [Tutor] while Loop
 
 
  define it with usedPocketsOne = 192000?
  no, I said UsedPocketsOne was not defined.  Note the 
 different starting 
  letter.
  Python is case senstitive, meaning usedPocketsOne is not 
 the same as 
  UsedPocketsOne.
  So yes, you defined usedPocketsOne with the assignment to 
 192000, but 
  you did not define UsedPocketsOne.
  

I've been out of the office for the last week, so I'm catching up.

You might use something like PyChecker, PyLint, or PyFlakes. Those
utilities would catch errors like this.

I have a hotkey in VIM that kicks off PyFlakes on the current buffer. 

Also, I'm not 100% sure, but I think Komodo IDE would catch this as
well.

Mike
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] curses

2007-07-13 Thread Mike Hansen
 
 ok after reading a few tutorials i think i know enough to write my  
 program
 here it  is
 not commented yet though sorry:
 

For me, I need to put comments in while I'm coding or I'll never put
them in. I _try_ to put in a doc string for every class and
function/method. With Python being so readable, I don't put comments
that explain what I'm doing, but I _try_ to put comments on why I'm
doing something. I'm sure I could do better at commenting my code.

Always code as if the guy who ends up maintaining your code will be a
violent psychopath who knows where you live.

Even if the code you are writing is supposed to be a one off that will
never be used again(famous last words), it's best to keep up the
practice of commenting your code.

Mike
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] file methods

2007-07-10 Thread Mike Hansen
 

 -Original Message-
[...] 
 I have a file like this one:
 
 command = func_babara 
 parameter_1 = 300
 parameter_2 = 300
 parameter_3 = 50
 parameter_4 = 0
 parameter_5 = 0
 parameter_6 = 0
 
 
 ,as you see, i need to process it one line at a time and use 
 this .ini file as a configuration file. 
 

Take a look at the ConfigParser module. It can read ini files easily.

Mike
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] how long?

2007-07-03 Thread Mike Hansen
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Ben Waldin
 Sent: Tuesday, July 03, 2007 1:47 AM
 To: tutor@python.org
 Subject: [Tutor] how long?
 
 How long will it take until I successfully create my own 
 working program that is useful? I have crated the address 
 book ones in the tutors and just want to know how long it 
 takes before I start to create my own thought up programs 
 that will be useful. Thanks Ben   
 

What kind of programs do you have in mind? Maybe you can break down a
program you want into pieces and work on a piece of it. Maybe you want
some sort of GUI program. Well, first you can create a command line
version on it. Then later you can make it a GUI program. The tutor list
can help when you have questions.

Mike
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Regular Expression help

2007-06-27 Thread Mike Hansen
Argh... My e-mail program really messed up the threads. I didn't notice
that there was already multiple replies to this message.

Doh!

Mike
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Invoking Python from Vim

2007-06-08 Thread Mike Hansen
 

  -Original Message-
  Date: Fri, 8 Jun 2007 00:19:39 +0100
  From: Alan Gauld [EMAIL PROTECTED]
  Subject: Re: [Tutor] Invoking Python from Vim
  To: tutor@python.org
  Message-ID: [EMAIL PROTECTED]
  Content-Type: text/plain; format=flowed; charset=iso-8859-1;
  reply-type=original
  
  
  Matt Smith [EMAIL PROTECTED] wrote
  
   Do any Vim users have a better way of running a Python 
 program while
   it
   is being edited in Vim?
  
  My personal preference is to have 3 windows open:
  
  1) gvim for editing the files
  2) a console for running the files using command recall to do so
  3) a console running a python shell prompt
  (actually nowadays I'm using a a PyCrust shell)
  
  And I alt-tab between the windows.

I also use the three window solution(VIM, IPython, and shell to run
program.)

You might look at Pida which turns VIM into a IDE. I'm not sure, but I
think it's Python friendly since it's written in Python.

http://pida.co.uk/

Mike
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] New programming tutorials

2007-06-04 Thread Mike Hansen
I was just looking at the Daily Python URL and there are two new Python
tutorials:

Building Skills in Programming
How To Write Your Own Software Using Python
http://homepage.mac.com/s_lott/books/nonprog/htmlchunks/index.html

Hands-on Python
http://www.cs.luc.edu/~anh/python/hands-on/

Mike
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Design Question

2007-06-01 Thread Mike Hansen
 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Alan Gauld
 Sent: Friday, June 01, 2007 12:24 PM
 To: tutor@python.org
 Subject: Re: [Tutor] Design Question
  remove_question(self,question) -- returns True if the question
  was removed, False otherwise
 
 Doesn't sound like, better to use a question style name like
 is_removed(question)
 

Would it be better to have remove_question remove the question or raise
an exception if it can't remove the question? Then you'd put the call to
remove question in a try except block.

Mike
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] python exercises

2007-05-30 Thread Mike Hansen
 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Michael Revelle
 
 Anyone know where I can get some python excercises, like
 labs/someone's old homework assignments? 

There are some ideas at

http://effbot.org/pyfaq/tutor-im-learning-python-what-should-i-program.h
tm

or http://tinyurl.com/yalvar

Mike
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] smtplib howto send with a subject line

2007-05-23 Thread Mike Hansen
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Daniel McQuay
 Sent: Wednesday, May 23, 2007 1:49 PM
 To: tutor@python.org
 Subject: [Tutor] smtplib howto send with a subject line
 
 Hey Guys, I'm having a problem with my script that sends out 
 an email using smtplib. Whats happening now is when it is 
 send I get a (no subject) where the subject line should be. I 
 checked a few places such as effbot and some other online doc 
 but couldn't find any thing about the subject line. 
 
 Any help would be much appreciated.
 
 ###
 #Created by: Daniel McQuay  
 #This script will send and email  
 #to verify if the backup was  
 #successful or not.   
 ###
 
 import smtplib
 import sys
 
 emmssg = /tmp/backup.log
 smtpserver = 'localhost'
 AUTHREQUIRED = 0
 smtpuser = '' 
 smtppass = ''  
 
 #Recipients who will be getting the emails
 RECIPIENTS = ['[EMAIL PROTECTED]']
 
 SENDER = 'Saint_Richards'
 
 #This does not work?
 SUBJECT = 'Backup_Log' 
 
 emmssg = open('/tmp/backup.log','r').read()
 
 session = smtplib.SMTP(smtpserver)
 if AUTHREQUIRED:
 session.login(smtpuser, smtppass)
 smtpresult = session.sendmail(SENDER, RECIPIENTS, SUBJECT, emmssg) 
 
 if smtpresult:
 errstr = 
 for recip in smtpresult.keys():
 errstr = Could not delivery mail to: %s
 
 Server said: %s
 %s
 
 %s % (recip, smtpresult[recip][0], smtpresult[recip][1], errstr) 
 raise smtplib.SMTPException, errstr
 
 Thanks in advance,
 
 -- 
 Daniel McQuay
 Jaluno.com
 H: 814.825.0847
 M: 814-341-9013 
 

It seems a little easier to use the email module along with the smtp
module to create and send a message. 

http://docs.python.org/lib/node162.html

Mike
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] smtplib howto send with a subject line

2007-05-23 Thread Mike Hansen
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Daniel McQuay
 Sent: Wednesday, May 23, 2007 3:52 PM
 Cc: tutor@python.org
 Subject: Re: [Tutor] smtplib howto send with a subject line
 
 Thanks Mike, it seems that I'll be easy to incorporate that 
 into my script as well. 
 
 I'll give it a try. I'm still open to other suggestions, though.
 

Take a look at this link again(I think you said you looked at it.)

http://effbot.org/librarybook/smtplib.htm

Notice that the body string has From:, To:, Subject: followed by the
from, to, and subject.

body = string.join((
From: %s % FROM,
To: %s % TO,
Subject: %s % SUBJECT,
,
BODY), \r\n)

You might need to do something similar to get your subject line although
without the string module since the string methods are built in. 

I'm no expert on how to construct e-mail messages, so take this with a
grain of salt. I'm but a simple caveman programmer(*). 

Mike

* - Phil Hartman I'm but a simple caveman lawyer SNL
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] MS SQL Connection

2007-05-21 Thread Mike Hansen
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Leon Keylin
 Sent: Monday, May 21, 2007 3:52 PM
 To: tutor@python.org
 Subject: [Tutor] MS SQL Connection
 
 Been trying to do a very small and simple select via Python. 
 First I tried a module that looked clean but it couldn't 
 truncate tables. 
 
 Then I started sifting through docs at python.org and 
 couldn't find a simple
 way of communicating with a MS SQL via Python program. 
 
 Do I have to use ODBC? 
 
 Any examples would be awesome. Thanks!
 

I did a quick search on Google for MS SQL Python, and this came up. It
looks like it will do the trick.

http://pymssql.sourceforge.net/

Mike
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] GRUMPY?

2007-05-18 Thread Mike Hansen
 No, but we will all hereby remember you forever for posting a new
 thread without a proper subject on this list. Perhaps at the same time
 as our eyes will start peering.
 

I would imagine that the original poster didn't have any remnants of the
previous thread. Yes, the poster should have put a subject. On the other
hand, we need to be nicer too. More like... Glad you figured it out.
Hey, could you do us a favor next time and put a subject on your
message?

Mike
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] words and lengths

2007-05-16 Thread Mike Hansen
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Emad Nawfal
 Sent: Wednesday, May 16, 2007 9:40 AM
 To: Tutor@python.org
 Subject: [Tutor] words and lengths
 
 Hi All,
 I'm beginning to learn Python for linguistic research using 
 the Natural Language Toolkit. I want to write a small piece 
 of code to count lengths of words and print them a long with 
 the words. I've tried this but it does not work. What's wrong 
 with it, and how can I fix it? 
  
 
 phrase2 = ['colorless', 'green', 'ideas', 'sleep', 'furiously']
 lengths = {}
 for word in phrase2:
 lengths = lengths[word, len(word)] 
 
 print lengths
 
 
 Thank you in anticipation

Instead of
lengths = lengths[word, len(word)]

I think it should be
lengths[word] = len(word) # dictionary[key] = value

Mike
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] File access by os.system

2007-05-15 Thread Mike Hansen
 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Alan Gauld
 Sent: Tuesday, May 15, 2007 1:44 AM
 To: tutor@python.org
 Subject: Re: [Tutor] File access by os.system
 
 
 lohith madireddy [EMAIL PROTECTED] 
 
 I have files named 'x.pdb', 'y.pdb',. in one directory. I am
  using python to read the files in that directory and do a system
  operation on each of the file using os.system. When I use this, it
  always gives an error saying 'could not read the file'.
 
 There are several likely problems.
 The first is that the files might not have security pernissions set 
 for you to manipulate - can you do the system() command from 
 the OS prompt oK?
 
 Second, you are only passing the name of the file not the full 
 path so the system command can't find the file. 
 
 Third you could be passing something other than a 
 file - eg another directory - to the command.
 
  import sys,os,tempfile,shutil
  Pdbs = os.listdir(os.getcwd())
  temp1=tempfile.TemporaryFile()
  for Pdb in Pdbs:
 
 You probably need to use stat here to check that the item 
 really is a file and that it has permissions.
 
 Alternatively use a try except clause and if an exception 
 is raised simply use continue to start the next loop iteration.
 (possibly after printing an error message with the pdb name 
 in it so you can check why it failed later)
 
 print(type(Pdb))
 os.system(dsspcmbi -v Pdb temp1)

Should the os.system command be something like
command = dsspcmbi -v %s %s %(Pdb, temp1)
os.system(command)

?

Mike
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] .NET web services

2007-05-11 Thread Mike Hansen
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Kent Johnson
 Sent: Friday, May 11, 2007 4:18 AM
 To: shiv k
 Cc: tutor@python.org
 Subject: Re: [Tutor] .NET web services
 
 shiv k wrote:
  Dear All,
  I want to implement web services in Python for our project 
 and i want to 
  use these frm .NET framework. pls tell me how the .Net 
 platform will 
  interact with my these services.
 
 You might be interested in IronPython which is integrated with .NET
 http://www.codeplex.com/Wiki/View.aspx?ProjectName=IronPython
 
 Kent

Did the original poster mean to create a web service and have a .NET
program consume it?

Mike
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Generating simple HTML from within Python

2007-05-10 Thread Mike Hansen
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Duncan Gibson
 Sent: Thursday, May 10, 2007 10:25 AM
 To: tutor@python.org
 Subject: [Tutor] Generating simple HTML from within Python
 
 
 I'm updating an application at the moment that generates simple HTML
 files. However, it's all done using plain strings and brute force.
 It's hard to read, and isn't very robust in the face of special
 characters and matching start and end tags.
 
 I've been searching for a module to allow simple HTML generation, but
 most of them appear to be more concerned with *parsing* HTML and XML.
 The only one that looks promising from reviews dating back to 1998 or
 so is HTMLgen, but the link on starship.python.net appears long dead.
 
 So my question is, what is the preferred way of generating simple HTML
 or XHTML files these days? Is there a 'son of HTMLgen' or 
 similar module?
 
 Cheers
 Duncan
 
 PS. Apologies if this shows up twice. My first post seems to be MIA.

Did you search the Cheese Shop. I did a search for html generator, and
there's a few couple of modules mike html 0.4.0 and markup.py 1.6.1 that
look like they might do the trick.

http://www.python.org/pypi

Mike
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Type Conversion

2007-05-09 Thread Mike Hansen
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On 
 Behalf Of Jessica Brink
 Sent: Wednesday, May 09, 2007 12:38 PM
 To: Teresa Stanton; Python Tutor
 Subject: [Tutor] Type Conversion
 
 I am doing a simple program that takes input from the user (a 
 temp. in degrees Celsius) and converts it to a temperature in 
 Fahrenheit.  The following program works:
  
 def conversion ():
 C = input (Enter the temperature in degrees Celcius:\n)
 F = (9.0 / 5.0) * C + 32
 print F
  
 conversion ()
 
 However, if I try to use the raw_input function, and then 
 convert the variable to an integer, it does not work:
  
 def conversion ():
 C = raw_input (Enter the temperature in degrees Celcius:\n)
 int (C)
 F = (9.0 / 5.0) * C + 32
 print F
  
 conversion ()
 
 Am I missing a step on converting the variable C from a 
 string to an integer, or is it not possible to do this?  I 
 get the error that it is not possible to concatenate a str and int.
  
 Thanks!
  
 Jessica Brink
 Business/Computer Teacher
 Northland Pines High School
 Eagle River, WI
 715-479-4473 ext. 0701

Instead of int(C), I think you need C = int(C)

Mike
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Another string-manipulation question

2007-05-09 Thread Mike Hansen
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Alan Gilfoy
 Sent: Wednesday, May 09, 2007 2:42 PM
 To: tutor@python.org
 Subject: [Tutor] Another string-manipulation question
 
 Given a string, how would I?:
 
 1. Make sure only the first letter string_name[0], is capitalized.
 This would involve using string_name.lower() to lowercase everything  
 else, but how do I use .upper(), or some other method, to capitalize  
 only the first character?

There's a string method called capitalize, so you can use
string_name.capitalize()

In [27]: x = rakaNishu

In [28]: x = x.capitalize()

In [29]: x
Out[29]: 'Rakanishu'


 
 2. Make sure that there are no symbols (non-letter, 
 non-number) in the  
 string, and, if one is found, remove it.
 
 Pseudocode time, as to a potential approach-
 
 for each character in the string:
  if character not in  
 abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ:
  remove it


Someone may have a better idea on this one. Off the top of my head, you
can build a new string while checking each character using another
string method isalpha. You might want to check the string first before
even bothering with the loop. i.e. if not string_name.isalpha()...then
enter this loop below...

In [38]: x = rakan345ishu

In [39]: newx = 

In [40]: for chr in x:
   :if chr.isalpha():
   :newx += chr
   :

In [41]: print newx
rakanishu

Mike
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] IDE / development environment

2007-04-23 Thread Mike Hansen
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Rohan Deshpande
 Sent: Sunday, April 22, 2007 2:51 AM
 To: tutor@python.org
 Subject: [Tutor] IDE / development environment
 
 Hey guys,
 
 I've been using Linux for a long time but this is my first 
 foray into app development.  Therefore, I have never had to 
 properly set up a development environment for myself.  I am 
 partial to vim as an editor, and have configured it for the 
 python templating language i'm using with Pylons called Mako, 
 as well as using python.vim.  However, I have not figured out 
 how to do file management in a productive manner, quickly 
 switching between files.
 
 What does everyone use as their development environment for 
 Python, particularly web dev? 
 
 Thanks much.
 
 Always looking for a faster way,
 Rohan
 

I primarily use VIM. What do you mean by switching between files? You
might look at the mini-buffer explorer plug-in. It makes it easy to
switch between buffers.

Mike
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Question about cgi module

2007-04-20 Thread Mike Hansen
Part of the web app that I'm writing will allow users to upload small
images to be stored in a database. Is there a way to limit how big of a
file that the user can upload? Is there some cgi setting that would
prevent a user from upload a huge file, or stop at a certain size and
error? 

Mike
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Error in my code

2007-04-17 Thread Mike Hansen
If what you posted is exactly what your code looks like, then you've got
an indentation problem. Since Python doesn't use {}'s for code blocks,
it uses indentation instead, and it's somewhat picky about indentation.

I think all the code after the first conn.request should line up with
the conn.request.

def WEP40_KEY(n):
  params = urllib.urlencode({})
  headers = {Connection: Keep-Alive,Authorization: }
  conn = httplib.HTTPConnection(HOST)
  conn.request (GET, /w_sec.htm HTTP/1.1, params, headers)
  response = conn.getresponse()
  print response.status, response.reason
  params =
urllib.urlencode({'wsecurity':WEP,'wep_auth':Shared+Key,'wepenc':12
8+bit,'wep_key_no':key1,'ascii_key1':12345678901234567890123456,'as
cii_key2':,'ascii_key3':,'ascii_key4':,'passphrase':,'wpa_psk':
12345678,'key_lifetime':65535,'wpa_enc':TKIP,'save':Save,'message
': ,'todo':}) 
  headers = {Connection: Keep-Alive,Authorization: }
  conn = httplib.HTTPConnection(HOST)
  conn.request(POST, w_sec.htm, params, headers) 
  response = conn.getresponse()
  print response.status, response.reason
  conn.close() 

It looks like your indenting 2 spaces. I believe the recommendation is 4
spaces. You might read the style guide.

http://www.python.org/doc/essays/styleguide.html

Out of curiosity, what editor are you using to write your code? You can
configure many editors to automatically indent for you, change tabs to
spaces, and set tabs to 4 spaces.

Mike

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of govind goyal
 Sent: Tuesday, April 17, 2007 9:29 AM
 To: tutor@python.org
 Subject: [Tutor] Error in my code
 
 Hi,
  
 I am executing following lines of code:
  
 def WEP40_KEY(n):
   params = urllib.urlencode({})
   headers = {Connection: Keep-Alive,Authorization: }
   conn = httplib.HTTPConnection(HOST)
   conn.request (GET, /w_sec.htm HTTP/1.1, params, headers)
 response = conn.getresponse()
 print response.status, response.reason
  params = 
 urllib.urlencode({'wsecurity':WEP,'wep_auth':Shared+Key,'w
 epenc':128+bit,'wep_key_no':key1,'ascii_key1':12345678901
234567890123456,'ascii_key2':,'ascii_key3':,'ascii_key4':,'passph
rase':,'wpa_psk':1234567
8,'key_lifetime':65535,'wpa_enc':TKIP,'save':Save,'mess
 age': ,'todo':}) 
 headers = {Connection: Keep-Alive,Authorization: }
 conn = httplib.HTTPConnection(HOST)
 conn.request(POST, w_sec.htm, params, headers) 
 response = conn.getresponse()
 print response.status, response.reason
 conn.close()
 
 WEP40_KEY(sys.argv)
  
  
  
 I am getting following error:
  
 
 C:\Documents and 
 Settings\Govindadya\Desktop\MarvellMarvell_WEP40.py 192.168.1.
 16
   File C:\Documents and 
 Settings\Govindadya\Desktop\Marvell\Marvell_WEP40.py,
 line 41
 response = conn.getresponse()
 ^
 IndentationError: unindent does not match any outer indentation level
 
  
 
 Can anybody help me out on this?
 
 Best Regards,
 
 Govind
 
  
 
 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Learning Python in cooperative, challenging way.

2007-04-17 Thread Mike Hansen
 

 -Original Message-
 
 To clarify point #2: Python - as any learning - IS 
 challenging, but as I am
 learning it just for fun and without any real need to 
 fulfil, I don't have any
 operational challenge, if that makes any sense in English... :-/
 
 So far the best I could find has been: #1 -- this mailing list #2 --
 http://www.pythonchallenge.com
 
 Any more suggestions from your side?
 
 Thank you very much in advance,
 Mac.

You look at some of the ideas at this page.

http://effbot.org/pyfaq/tutor-im-learning-python-what-should-i-program.h
tm

or http://tinyurl.com/yalvar

Mike
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Python books on sale

2007-04-11 Thread Mike Hansen
 

 -Original Message-
 
 Kent Johnson [EMAIL PROTECTED] wrote
 
  Also the TurboGears book is 51% off:
  http://www.bookpool.com/sm/0132433885
 

Safari(http://safari.oreilly.com) has both the TurboGears book and Core
Python book, so you can check them out before deciding if you want the
dead tree version.

Mike 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Question about exception

2007-04-05 Thread Mike Hansen
When doing a try/except block, is it possible to return a list as part
of the exception?

try:
check_someting()
except CheckSomethingError, e:
for each_error in e:
   # do something

Can 'e' be a list of errors? If so, how do you construct your exception
class?


Is it better to do it like this?

(errors) = check_something()
if errors:
   # do something 
 

Mike head zoned out due to allergies   
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Question about exception

2007-04-05 Thread Mike Hansen
 If the Exception is defined as a class, e will be an instance of
 that class so you can have pretty much anything available:
 
 class MyException(Exception):
 def __init__(self, msg, mylist)
 self.msg = msg
 self.mylist = mylist
 Exception.__init__(self, msg)
 
 try:
 check_something()
 except MyException, e:
 for entry in e.mylist: ...
 
 Bill
 --
 INTERNET:   [EMAIL PROTECTED]  Bill Campbell; Celestial Software LLC
 URL: http://www.celestial.com/  PO Box 820; 6641 E. Mercer Way
 FAX:(206) 232-9186  Mercer Island, WA 98040-0820; 
 (206) 236-1676
 
 ``I don't make jokes, I just watch the Government and report 
 the facts...''
 Will Rogers

Doh! It was right in front of me, but I wasn't connecting the dots. 

Thanks,

Mike
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] cookie expiration date format

2007-03-19 Thread Mike Hansen
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Luke Paireepinart
 Sent: Friday, March 16, 2007 8:31 PM
 To: Tim Johnson
 Cc: tutor@python.org
 Subject: Re: [Tutor] cookie expiration date format
 
 Tim Johnson wrote:
  Hi:
  I want to be able to expire a cookie programmatically.
  In other languages, I just set the expiration date to 'yesterday'.
  If I look at the documentation at:
  http://docs.python.org/lib/node644.html
  for the Cookie object, I see the following:
  ---
  expires
  Integer expiry date in seconds since epoch,
  ---
  I'm not clear what datatype is needed here.
  Can anyone clarify this for me?

 Sounds like it's an integer or float, such as returned by time.time()
   import time
   time.time()
 1174098190.796 #seconds since epoch
   _ / 60
 19568303.17992#minutes since epoch
   _ / 60
 326138.386332 #hours ..
   _ / 24
 13589.099430509259# days
   _ / 365.25
 37.204926572236161 #years
   .205 * 1.2
 0.24597  #months ( fractional part of year )
  
 
 So today is 37 years 2.5 months from January 1, 1970.
 1970 + 37 = 2007, and January 1 + 2.5 months = March 16.
 
 If you wanted the cookie to expire 24 hours from now,
 time.time() + 3600 * 24 #(seconds in a day)
 
 See http://en.wikipedia.org/wiki/Unix_epoch for more info on 
 the epoch.
 look into the time and the datetime modules, there should be 
 an easy way 
 to find the seconds since epoch for whatever date you want.
 HTH,
 -Luke

Some of the modules in the Python standard library make things a little
more difficult than other languages.(Perl, Ruby, ...) This is a good
example of it. Are there any 3rd party modules that let you set the
expiration date to 'yesterday'? I know I could write a wrapper, but I'd
rather not re-invent the wheel and save some time.

Another example is ftplib. Other language's ftp modules/libraries allow
you do something like sendaciifile(fh) or sendbinaryfile(fh) yet you
need to build your own wrapper functions in Python.
http://effbot.org/librarybook/ftplib.htm 

Mike
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Digital-to- Roman (pseudocode)

2007-03-08 Thread Mike Hansen
I think Dive Into Python has examples of digital to Roman and it might
have Roman to digital. Might be worth looking at after you've come up
with a solution.

Mike

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] recommendation for good OO book?

2007-03-07 Thread Mike Hansen
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On 
 Behalf Of Jeff Peery
 Sent: Wednesday, March 07, 2007 10:15 AM
 To: tutor@python.org
 Subject: [Tutor] recommendation for good OO book?
 
 Hello, I've been using python for a few years now and I 
 really like it. Although i am beginning to realize I really 
 don't utilize this object oriented stuff in a good way. Does 
 anyone have a favorite book regarding the basics/intro to 
 object oriented programming, how to write good OO code??
 
 thanks,
 Jeff
 

I liked The Object Oriented Thought Process. It uses Java and C#(I
think) as examples. I then reread the chapters in Learning Python on OO
to get a better understanding of the Python way of doing it.

Mike

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] help:find a string in a text and replace it with a anotherstring

2007-03-07 Thread Mike Hansen
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of mastjeptor regli
 Sent: Wednesday, March 07, 2007 10:34 AM
 To: tutor@python.org
 Subject: [Tutor] help:find a string in a text and replace it 
 with a anotherstring
 
 Hi,folks.
  At first ,I have a question that I want to ask for 
 help,it is how can I search a specific string in a text (such 
 a in a word document) and replace it with another string?
  Second,if the text is changed dynamicly,can I use a 
 variable string(has been assigned a string) to search in the 
 text and replace it with another variable string.for example, 
 Regex Substitution: s/email/e-mail ,if  the string of email 
 and e-mail are both changed from time to time,can we apply
 variable string (which has been assigned a value of string 
 type) instead of constant string of email and e-mail to 
 construct a regex substitution expression ?
   Please reply with experience in using  regular 
 expression or python library functions to find and replace a 
 string in a text to help me.   Thank you for your attention.
 

You might not need regular expressions. You can use replace method.

In [11]: x = Bozo

In [12]: z = Bozo The Clown

In [13]: y = Krusty

In [14]: z.replace(x,y)
Out[14]: 'Krusty The Clown'

You could probably populate a dictionary of the words you want to
replace and their replacements. Then use the replace method on the
strings.

Note that Word documents are binary gibberish, so you'd need to use
win32 python windows stuff making this more complicated. On plain text
files, it wouldn't be too bad.

Mike 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] FW: isinstance - instance

2007-02-26 Thread Mike Hansen
Oops...I replied instead of replied all. 

 -Original Message-
 From: Mike Hansen 
 Sent: Monday, February 26, 2007 2:43 PM
 To: 'Bernard Lebel'
 Subject: RE: [Tutor] isinstance - instance
 
  
 
  -Original Message-
  From: [EMAIL PROTECTED] 
  [mailto:[EMAIL PROTECTED] On Behalf Of Bernard Lebel
  Sent: Monday, February 26, 2007 2:34 PM
  To: Tutor
  Subject: [Tutor] isinstance - instance
  
  Hello,
  
  Following the guidelines here, at the bottom of the page:
  http://www.python.org/dev/peps/pep-0008/
  
  I'm using isinstance() to test the type of some data.
  Now the thing is that, what is the name to use for a class instance?
  
  For example, say I run this:
  
  class A:
  def __init__( self ):
  self.a = 'a'
  
  a = A()
  
  print type( a )
  
  Outputs:
  type 'instance'
  
  
  
  
  Now if I test against the instance type like I would for integer,
  strings and the likes:
  
  isinstance( a, instance )
  
  Outputs:
  NameError: name 'instance' is not defined
  
  
  So I'm a bit at a loss here. I don't want to know if the instance is
  an instance of a specific class, I just want to know if it's an
  instance.
  
  
  Thanks
  Bernard
 
 Shouldn't that be
 
 isinstance(a, A)
 
 ?
 
 Mike 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Convert my .bat and .vbs to .py

2007-02-15 Thread Mike Hansen
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Mark Bystry
 Sent: Thursday, February 15, 2007 10:04 AM
 To: tutor@python.org
 Subject: [Tutor] Convert my .bat and .vbs to .py
 
 Hello,
 
 This is my first post. I have just begun to code with python. 
 My goal is to convert about a dozen or 
 so DOS/Windows batch scripts(.bat) and vbscripts(.vbs) that I 
 use on a day-to-day basis to python so 
 that they can be run on either my windows or linux workstations.
 
 The first things that I want to learn is how to do basic 
 stuff like copying, moving, and deleting 
 files around from folder to folder. I have been in the help 
 section of python (copyfile section) 
 but I do not understand what I am doing wrong.
 
 
 Here is my simple DOS batch file...
 
 ##
 copy D:\PDF_Holding\*PRODUCTION.pdf Z:\
 copy D:\PDF_Holding\*ILLUSTRATION.pdf 
 H:\MARKETING\ILLUSTRATIONS\PRODUCT
 pause
 
 del *.pdf
 ##
 
 Basically, it copies the production and illustration pdf 
 files to certain folders than deletes 
 the left over pdf files when done. Yes, I could move them 
 instead of copying them.
 
 I'm no asking for anyone to write this for me but if someone 
 could lead me i the right direction, I 
 would be grateful.
 
 Thank-you.
 
 Mark

Maybe there's a way to use shutil's copytree function with os module's
remove function or shutil's rmtree function? If not, use the glob module
to gather the file names and then walk the results of the glob with a
for loop and use shutil's copyfile function.

Mike
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Replying to the tutor-list

2007-02-14 Thread Mike Hansen
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Rikard Bosnjakovic
 Sent: Wednesday, February 14, 2007 9:21 AM
 To: tutor@python.org
 Subject: [Tutor] Replying to the tutor-list
 
 All texts that I reply to this list are automatically sent to the
 author, or - by selecting Reply all in my mail client - the
 tutorlist gets a CC.
 
 Why is there no reply-to-tag in all the posts, making the list
 recipient at all times?
 
 
 -- 
 - Rikard.
 ___
 Tutor maillist  -  Tutor@python.org
 http://mail.python.org/mailman/listinfo/tutor
 

The following tutor faq has an explanation:

http://www.python.org/infogami-faq/tutor/tutor-why-do-my-replies-go-to-t
he-person-who-sent-the-message-and-not-to-the-list/

Or 

http://tinyurl.com/uns5q

Mike
-

  NOTICE:  This e-mail transmission and any documents or files attached to
  it contain information for the sole use of the above-identified individual or 
entity.

  Its contents may be privileged, confidential, and exempt from disclosure 
under the law.
  Any dissemination, distribution, or copying of this communication is strictly 
prohibited.

  Please notify the sender immediately if you are not the intended recipient.

FGNS
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] VOT - Similar list for Ruby?

2007-02-01 Thread Mike Hansen
 

 -Original Message-
 
 Hello all,
 
 I may be about to switch jobs to an environment in which the main
 utility language is Ruby.  I've found this group to be brilliant in
 the last few years, and wondered if anyone on the list is also a Ruby
 user, and could recommend a similarly helpful, patient and informative
 list?
 
 Thanks,
 
 S.

When I started getting interested in Ruby, the only list I found was
Ruby Talk. See this page for a list of mail lists:

http://www.ruby-lang.org/en/community/mailing-lists/

Maybe someone deeper into the Ruby community might have a better
suggestion.

Mike
-

  NOTICE:  This e-mail transmission and any documents or files attached to
  it contain information for the sole use of the above-identified individual or 
entity.

  Its contents may be privileged, confidential, and exempt from disclosure 
under the law.
  Any dissemination, distribution, or copying of this communication is strictly 
prohibited.

  Please notify the sender immediately if you are not the intended recipient.

FGNS
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Best IDE for Python

2007-01-25 Thread Mike Hansen
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Shadab Sayani
 Sent: Wednesday, January 24, 2007 8:12 PM
 To: tutor@python.org
 Subject: [Tutor] Best IDE for Python
 
 Hi,
 I am using vim editor to code my project in python.Is there a 
 good IDE  where in I type the name of the class object and 
 then dot then all the attributes of the object are displayed 
 so on.I tried to install IDLE but I have no idea how to 
 install tkinter?
 Any help that enables me to use good IDE as soon as possible 
 is appreciated
 Thanks and Regards,
 Shadab
 

Someone mentioned that VIM 7 does this. You might need to pick up the
latest python.vim file from vim.org.

Activestate just released Komodo Edit and Komodo IDE. I believe both do
auto-completion that shows a list of possibilities. Komodo Edit is free
and Komodo IDE cost some $$.

Mike
-

  NOTICE:  This e-mail transmission and any documents or files attached to
  it contain information for the sole use of the above-identified individual or 
entity.

  Its contents may be privileged, confidential, and exempt from disclosure 
under the law.
  Any dissemination, distribution, or copying of this communication is strictly 
prohibited.

  Please notify the sender immediately if you are not the intended recipient.

FGNS
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Best IDE for Python

2007-01-25 Thread Mike Hansen
 

 
  Activestate just released Komodo Edit and Komodo IDE. I 
 believe both do
  auto-completion that shows a list of possibilities. Komodo 
 Edit is free
  and Komodo IDE cost some $$.
 
 IMHO: If one programs in more than one programming language, the
 ultimate would be an editor/IDE that can accommodate all with similar
 functionality and behavior for all. 
 
 MTCW
 tim 

I agree. Depending on what I'm doing, I toggle between VIM and Komodo. I
like that both can handle multiple languages. 

Mike
-

  NOTICE:  This e-mail transmission and any documents or files attached to
  it contain information for the sole use of the above-identified individual or 
entity.

  Its contents may be privileged, confidential, and exempt from disclosure 
under the law.
  Any dissemination, distribution, or copying of this communication is strictly 
prohibited.

  Please notify the sender immediately if you are not the intended recipient.

FGNS
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Perfect Python web stack?

2007-01-17 Thread Mike Hansen
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of OkaMthembo
 Sent: Wednesday, January 17, 2007 3:59 AM
 To: tutor
 Subject: [Tutor] Perfect Python web stack?
 
 Ok pythonistas!
 
 Please help me to decide. I might have asked some of you 
 before, so please bear with me.
 
 I want to build a database driven python web app and i need 
 to decide, so please vote on the best components (im 
 developing on XP SP2): 
 
 1) MySQL vs PostGRES
 2) Lighttpd + FastCGI vs Apache + mod_python
 3) Pylons + Cheetah + Kid/Mochikit/Dojo vs Django/Turbogears
 
 This is not to light fires, its for my sole information :-)
 
 Thanks in advance, gurus.
 
 Shortash

I think I recently read the you need to purchase MySQL to get a binary
for Windows, but don't quote me. 

Postgre + Apache + Cheetah + Dojo is working for me. Sometime soon, I
want to experiment with Django.

I'm not familiar with Lighttpd, FastCGI, mod_python, Pylons, or Kid.
When I was looking for a JavaScript toolkit, I took a look at Mochikit
and Dojo. I was able to understand Dojo better although I hear that
Mochikit is more Python-like. shrug /

Mike 
-

  NOTICE:  This e-mail transmission and any documents or files attached to
  it contain information for the sole use of the above-identified individual or 
entity.

  Its contents may be privileged, confidential, and exempt from disclosure 
under the law.
  Any dissemination, distribution, or copying of this communication is strictly 
prohibited.

  Please notify the sender immediately if you are not the intended recipient.

FGNS
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] python query

2007-01-16 Thread Mike Hansen
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Alexander Kapshuk
 Sent: Tuesday, January 16, 2007 2:50 AM
 To: tutor@python.org
 Subject: Re: [Tutor] python query
 
 Dear All,
 
  
 
 My name is Alexander Kapshuk. I'm interested in learning to 
 program in Python. I have very little programming experience. 
 I've learnt some basics of programming with Logo. 
 
  
 
 I've downloaded Python 2.5 for Windows XP Professional.
 
  
 
 I would appreciate any advice on what to do next. What 
 books/tutorials to use? 
 
  
 
 I understand that learning a programming language involves 
 practice. So, I suppose, I could use a book/tutorial with 
 loads of practical code samples to try out.
 
  
 
 Any other practical advice you may deem feasible would be welcome.
 
  
 
 Thanking you in advance.
 
  
 
 Alexander Kapshuk.

Here's some good books to read.

http://www.python.org/infogami-faq/tutor/tutor-what-are-some-good-books-
on-python/

Feel free to post questions to this list too.

Mike
-

  NOTICE:  This e-mail transmission and any documents or files attached to
  it contain information for the sole use of the above-identified individual or 
entity.

  Its contents may be privileged, confidential, and exempt from disclosure 
under the law.
  Any dissemination, distribution, or copying of this communication is strictly 
prohibited.

  Please notify the sender immediately if you are not the intended recipient.

FGNS
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Creating folders

2007-01-10 Thread Mike Hansen
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Toon Pieton
 Sent: Wednesday, January 10, 2007 2:31 PM
 To: tutor
 Subject: [Tutor] Creating folders
 
 Hey friendly users!
 
 My question is pretty simple. How can I create a folder with 
 Python? Trying to make a program which will allow me to save 
 my notes (txt files) quickly and cleanly. Having to create 
 folder manually would really make it a bit obsolete. 
 
 Thanks in advance!
 


http://docs.python.org/lib/os-file-dir.html

os.mkdir

Mike 
-

  NOTICE:  This e-mail transmission and any documents or files attached to
  it contain information for the sole use of the above-identified individual or 
entity.

  Its contents may be privileged, confidential, and exempt from disclosure 
under the law.
  Any dissemination, distribution, or copying of this communication is strictly 
prohibited.

  Please notify the sender immediately if you are not the intended recipient.

FGNS
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] need help with sending email

2007-01-05 Thread Mike Hansen
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of shawn bright
 Sent: Friday, January 05, 2007 10:18 AM
 To: tutor-python
 Subject: [Tutor] need help with sending email
 
 lo there all.
 
 i am in a tight spot because i need to send an email that it 
 mime encoded plain-text ( not html or anything )
 no attachements, no images, just text from a string. like 
 message = 'some message' 
 all the tutorials i find out there, and the cookbook recipies 
 are for sending multipart messages, attachments, etc..
 this needs to be simple, but needs to be able to reach a 
 large variety of cell phone text message receivers. 
 
 anyone know of a good tutorial or recipe out there ?
 
 thanks,
 shawn
 

This might help:

http://effbot.org/librarybook/smtplib.htm 

Also, the docs on smtplib:

http://docs.python.org/lib/module-smtplib.html

Mike
-

  NOTICE:  This e-mail transmission and any documents or files attached to
  it contain information for the sole use of the above-identified individual or 
entity.

  Its contents may be privileged, confidential, and exempt from disclosure 
under the law.
  Any dissemination, distribution, or copying of this communication is strictly 
prohibited.

  Please notify the sender immediately if you are not the intended recipient.

FGNS
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] python web dev

2007-01-04 Thread Mike Hansen
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On 
 Behalf Of OkaMthembo
 Sent: Thursday, January 04, 2007 9:12 AM
 To: tutor@python.org
 Subject: [Tutor] python web dev
 
 hi pythonistas!
 
 this is my first post. please could you tell me which is the 
 best lightweight python web framework? also, which is the 
 best templating language for python? (which can handle other 
 data formats in addition to text). so far im lured by 
 Cheetah, although i havent done any web dev with python yet. 
 
 i absolutely love python syntax, but web dev in python is 
 murky water. it seems unneccesarily hard, even compared to 
 php and asp.net
 
 thanks,
 
 Shortash

I'm using Cheetah on a current project. I really like it. I like that
you can compile the template and then use it as a module to populate it.

I want to check out Django next.

Mike
-

  NOTICE:  This e-mail transmission and any documents or files attached to
  it contain information for the sole use of the above-identified individual or 
entity.

  Its contents may be privileged, confidential, and exempt from disclosure 
under the law.
  Any dissemination, distribution, or copying of this communication is strictly 
prohibited.

  Please notify the sender immediately if you are not the intended recipient.

FGNS
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] SPE - Stani's Python Editor ?

2007-01-03 Thread Mike Hansen
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Chris Hengge
 Sent: Tuesday, January 02, 2007 4:57 PM
 To: Dick Moores
 Cc: tutor@python.org
 Subject: Re: [Tutor] SPE - Stani's Python Editor ?
 
 I've recently started playing with Eclipse and the two PyDev 
 plugin's over the holidays. I'm seriously liking it... but my 
 likes are more closely related to Visual Studio as an editor, 
 so this is like the perfect environment for me.. 
 
 http://www.showmedo.com/videos/series?name=PyDevEclipseList
 
 This link shows you two video's on how pydev works, and how to setup. 
 

I played with Eclipse a little bit. I got annoyed that the plugins would
nickel and dime you to death. Pydev is free, but the additional features
in Pydev Extensions cost $. I heard there was a plugin for vi emulation.
Unfortunately, it was another plugin that you had to pay for.

I decided to stick with VIM where the plugins are free. I recently
starting using VIM's snippets.emu plugin. It emulates TextMate's
snippets. TextMate is an editor for OS X that is getting a lot of
attention. There are people working on TextMate-like editors for Windows
and Linux.

Mike

  
-

  NOTICE:  This e-mail transmission and any documents or files attached to
  it contain information for the sole use of the above-identified individual or 
entity.

  Its contents may be privileged, confidential, and exempt from disclosure 
under the law.
  Any dissemination, distribution, or copying of this communication is strictly 
prohibited.

  Please notify the sender immediately if you are not the intended recipient.

FGNS
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Python cgi scripting

2006-12-27 Thread Mike Hansen
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Troy
 Sent: Tuesday, December 26, 2006 10:01 PM
 To: tutor@python.org
 Subject: [Tutor] Python cgi scripting
 
 Hello.  I'm just starting to learn Python, and want to do some python
 cgi scripting.  Can someone recommend a good web site or online
 reference (beginner level)?
 
 Thank you.
 

Check out the docs on the cgi module
http://docs.python.org/lib/module-cgi.html

Also, devshed has an article on cgi programming with Python
http://www.devshed.com/c/a/Python/Writing-CGI-Programs-in-Python/

Mike
-

  NOTICE:  This e-mail transmission and any documents or files attached to
  it contain information for the sole use of the above-identified individual or 
entity.

  Its contents may be privileged, confidential, and exempt from disclosure 
under the law.
  Any dissemination, distribution, or copying of this communication is strictly 
prohibited.

  Please notify the sender immediately if you are not the intended recipient.

FGNS
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] ***SPAM*** List to dictionary

2006-12-07 Thread Mike Hansen
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Luke Paireepinart
 Sent: Wednesday, December 06, 2006 10:54 PM
 To: tutor@python.org
 Subject: Re: [Tutor] ***SPAM*** List to dictionary
 
 Also, why is there now a **SPAM* in the subject heading?
 
 Wonderingly,
 -Luke
 

Maybe Bill was labeling it SPAM since it was posted twice to the list?
shrug /
Wed Dec 6 17:00:18 CET 2006
Thu Dec 7 04:31:55 CET 2006

Also, I tried to explain in my reply yesterday. The next statement
(temp[i] = 0) is where I get confused.
Can someone please explain what is happening here. 

I'm confused. %)
-

  NOTICE:  This e-mail transmission and any documents or files attached to
  it contain information for the sole use of the above-identified individual or 
entity.

  Its contents may be privileged, confidential, and exempt from disclosure 
under the law.
  Any dissemination, distribution, or copying of this communication is strictly 
prohibited.

  Please notify the sender immediately if you are not the intended recipient.

FGNS
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Integer?

2006-12-06 Thread Mike Hansen
  How can I check if a variable is an integer?
 
 Luke and John have answered your question, but we should also 
 ask, why 
 do you want to do that? Explicit type testing is a code 
 smell, perhaps 
 there is a better way to do what you want.
 
 Kent
 

Kent,

Can you explain further? Refactoring is in my queue of books to read. In
a web app I'm writing, I'm checking the input kind of like this...

try:
form_value = int(form.getvalue('num_widgets')
except ValueError:
display_error(Number of Widgets must be a number)

Mike 
-

  NOTICE:  This e-mail transmission and any documents or files attached to
  it contain information for the sole use of the above-identified individual or 
entity.

  Its contents may be privileged, confidential, and exempt from disclosure 
under the law.
  Any dissemination, distribution, or copying of this communication is strictly 
prohibited.

  Please notify the sender immediately if you are not the intended recipient.

FGNS
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] List to dictionary question

2006-12-06 Thread Mike Hansen
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Morpheus
 Sent: Wednesday, December 06, 2006 9:00 AM
 To: tutor@python.org
 Subject: [Tutor] List to dictionary question
 
 I'm new to programming, and trying to learn the Python language.  
 The following code does what I want it to do, but I have not 
 idea how it
 works.  
 
 def scanList(names,temp):
 for i in names:
 temp[i] = 0
 print temp
 
 Names = []
 temp = {}
 
 I have a list of names (Names[]) and want to remove duplicate names in
 the list.  Here is what I think is happening (please correct me if I'm
 wrong, or using the wrong technical terminology):  I'm passing the
 variables Names and temp as arguments to the scanList function.  The
 statement (for i in names:) is an iteration going through each item in
 the list.  The next statement (temp[i] = 0) is where I get confused.
 Can someone please explain what is happening here.  
 
 Thanks for your help.
 

temp is a dictionary. Dictionaries have unique keys. scanList goes
through each item in names and sets the key of the temp dictionary to
the item. If there are more than one item of the same value, it just
sets the key of the dictionary again. The statement temp[i] = 0 is
setting the value of the key 'i' to 0. (temp[key] = value) To get your
list without duplicates just get the keys of the dictionary after the
list has been run through function.
temp.keys()

If you have names = [1,2,3,2,4]
The temp dictionaries keys become 1,2,3,4.
In the scanList function above
temp[1] = 0
temp[2] = 0
temp[3] = 0
temp[2] = 0 - It's just setting the same key to zero again.
temp[4] = 0

temp.keys() 
[1,2,3,4]

I hope that makes some sense. 

I think a more explicit way of removing duplicates from a list is using
sets.

In [1]: x = ['a', 'a', 'b', 'c', 'd', 'e', 'f', 'f', 'f']

In [2]: se = set(x)

In [3]: se
Out[3]: set(['a', 'c', 'b', 'e', 'd', 'f'])

In [4]: sel = list(se)

In [5]: sel
Out[5]: ['a', 'c', 'b', 'e', 'd', 'f']
-

  NOTICE:  This e-mail transmission and any documents or files attached to
  it contain information for the sole use of the above-identified individual or 
entity.

  Its contents may be privileged, confidential, and exempt from disclosure 
under the law.
  Any dissemination, distribution, or copying of this communication is strictly 
prohibited.

  Please notify the sender immediately if you are not the intended recipient.

FGNS
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] OT: Vim was: free IDE for Python?

2006-11-17 Thread Mike Hansen
 



From: [EMAIL PROTECTED] on behalf of [EMAIL PROTECTED]
Sent: Thu 11/16/2006 10:32 PM
To: [EMAIL PROTECTED]
Cc: tutor@python.org
Subject: Re: [Tutor] OT: Vim was: free IDE for Python?



Hi Alan,
Greetings.

Alan Gauld wrote:
 I have to chuckle when you recommend Vim for ease of use.

 Me too, and I've been a vi/elvis/viper/vim user for over 20 years(*).
 vi/vim could never be described as easy to learn, but...

I too use vim for a variety of editing tasks. From xml, python to normal
text editing, not  a power user yet.
Do you have any tips/tricks to share for python on vim. Your vimrc file
or any plugins you use.

How would you run the python script from vim?
- !python %
OR any other way? I dislike the command line window popup to execute the
scripts. (and press Enter key twice).
I kindda wish, that Hot-Key for !python % should :split the window and
display the results for non-interactive run.
If interactive session, the cmd.exe could stay open..

What the settings of ppl using vim for python?

--
Senthil
___


Here's what I'm doing. Not sure if it's that helpful to you.

I use the mini-buffer explorer plug-in and the taglist plugin.

set smartindent

 shuts off the annoying # comment in smartindent to jump to col 1
inoremap # Xc-h#

autocmd BufRead *.py set smartindent 
cinwords=if,elif,else,for,while,try,except,finally,def,class

I've mapped a key to run pyflakes and display the results in a different buffer

:new | r!pyflakes #

Mike

-

  NOTICE:  This e-mail transmission and any documents or files attached to
  it contain information for the sole use of the above-identified individual or 
entity.

  Its contents may be privileged, confidential, and exempt from disclosure 
under the law.
  Any dissemination, distribution, or copying of this communication is strictly 
prohibited.

  Please notify the sender immediately if you are not the intended recipient.

FGNS
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] free IDE for Python?

2006-11-16 Thread Mike Hansen
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Alan Gauld
 Sent: Wednesday, November 15, 2006 4:49 PM
 To: tutor@python.org
 Subject: Re: [Tutor] free IDE for Python?
 
 
 wesley chun [EMAIL PROTECTED] wrote 
  Eclipse
 http://pydev.sourceforge.net
 http://www.eclipse.org/
 
 Has anyone got an idiot's guide to getting Eclipse working 
 with python?
 
 I've tried a couple of times but ran out of patience. In fact I 
 haven't really got vanilla Eclipse working for Java yet, it all 
 seems a lot of work for an IDE! NetBeans was so much 
 easier but my friends all laughed at me and said I should
 be using Eclipse... :-)
 
 Alan (the impatient) G.
 

I found the getting started docs got me going with Eclipse and Pydev.

http://www.fabioz.com/pydev/manual_101_root.html

I still find myself using VIM more than Eclipse. I'll need to play with
Eclipse some more to make a decision if I want to stick with it or just
stay with VIM.

Mike
-

  NOTICE:  This e-mail transmission and any documents or files attached to
  it contain information for the sole use of the above-identified individual or 
entity.

  Its contents may be privileged, confidential, and exempt from disclosure 
under the law.
  Any dissemination, distribution, or copying of this communication is strictly 
prohibited.

  Please notify the sender immediately if you are not the intended recipient.

FGNS
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] how to extract time from datetime.date.time()

2006-11-16 Thread Mike Hansen
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Asrarahmed Kadri
 Sent: Thursday, November 16, 2006 10:29 AM
 To: tutor-python
 Subject: [Tutor] how to extract time from datetime.date.time()
 
 Hi,
  
 I want to extract hh:mm:ss from below mentioned code:
  
 import datetime
  t = datetime.datetime.now()
  print t
 2006-11-16 16:59:02.843000
  
 How to do it?
  
 TIA.
 Regards,
 Asrarahmed
 
 -- 
 To HIM you shall return. 


http://docs.python.org/lib/datetime-datetime.html

I believe datetime.datetime.now() returns a datetime object. You can
just look at the attributes of the object.

In [6]: import datetime

In [7]: t = datetime.datetime.now()

In [8]: t.hour
Out[8]: 10

In [10]: t.minute
Out[10]: 33

In [11]: t.second
Out[11]: 37
-

  NOTICE:  This e-mail transmission and any documents or files attached to
  it contain information for the sole use of the above-identified individual or 
entity.

  Its contents may be privileged, confidential, and exempt from disclosure 
under the law.
  Any dissemination, distribution, or copying of this communication is strictly 
prohibited.

  Please notify the sender immediately if you are not the intended recipient.

FGNS
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] free IDE for Python?

2006-11-16 Thread Mike Hansen
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of William 
 O'Higgins Witteman
 Sent: Thursday, November 16, 2006 12:08 PM
 To: tutor@python.org
 Subject: Re: [Tutor] free IDE for Python?
 
 On Thu, Nov 16, 2006 at 08:36:25AM -0700, Mike Hansen wrote:
 
 I found the getting started docs got me going with Eclipse and Pydev.
 
 http://www.fabioz.com/pydev/manual_101_root.html
 
 I still find myself using VIM more than Eclipse. I'll need 
 to play with
 Eclipse some more to make a decision if I want to stick with 
 it or just
 stay with VIM.
 
 You don't have to choose, use the viPlugin for Eclipse:
 
 http://www.eclipseplugincentral.com/Web_Links-index-req-viewli
 nk-cid-103.html
 -- 
 
 yours,
 
 William

That looks interesting. This looks better than eclim. On the surface,
Eclim looked kind of strange to set up and use.

Thanks,

Mike 
-

  NOTICE:  This e-mail transmission and any documents or files attached to
  it contain information for the sole use of the above-identified individual or 
entity.

  Its contents may be privileged, confidential, and exempt from disclosure 
under the law.
  Any dissemination, distribution, or copying of this communication is strictly 
prohibited.

  Please notify the sender immediately if you are not the intended recipient.

FGNS
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] question about __init__ in a class

2006-11-13 Thread Mike Hansen
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of shawn bright
 Sent: Monday, November 13, 2006 11:45 AM
 To: tutor-python
 Subject: [Tutor] question about __init__ in a class
 
 Hello there all.
 i have a class that i need to load some class variables 
 depending on what is passed to the class, it would either be 
 set up using one variable or another. The values for the 
 class variables would be loaded from a database. But how it 
 is looked up depends on how its called. Like this: 
 
 class Sensor_Object(object):
 def __init__(self, id, monitor):
 if id:
self.id = id
load values from the database
value1 = somevalue 
value2 = someOthervalue
 else:
self.monitor = monitor
get some values from database
value1 = somevalue
value2 = someothervalue
 
 now i could call it like this: 
 
 new_monitor = sensor.Sensor('', 'XJ191')
 or
 new_monitor = sensor.Sensor('3433', '')
 to load based on the other variable.
 
 i think that this would work, but i was thinking that there 
 must be a cleaner way to do it. 
 any suggestions ?
 
 sk

I don't know if it's cleaner, but it might be easier to read if you use
default named arguments.
def __init__(self, id = None, monitor = None):

Calling it
new_monitor = sensor.Sensor(monitor = 'XJ191')
new_monitor = sensor.Sensor(id = '3433')

Check to make sure one or the other arguments is supplied. Otherwise
throw an exception.

Maybe there'll be some better ideas from other posters.

Mike



-

  NOTICE:  This e-mail transmission and any documents or files attached to
  it contain information for the sole use of the above-identified individual or 
entity.

  Its contents may be privileged, confidential, and exempt from disclosure 
under the law.
  Any dissemination, distribution, or copying of this communication is strictly 
prohibited.

  Please notify the sender immediately if you are not the intended recipient.

FGNS
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] free IDE for Python?

2006-11-13 Thread Mike Hansen
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Vadhri, Srinivas
 Sent: Monday, November 13, 2006 4:03 PM
 To: tutor@python.org
 Subject: [Tutor] free IDE for Python?
 
 Hi
 
  
 
 A newbie to Python. What is the free IDE for Python 
 development activities? ActiveState's Komodo IDE needs a 
 license and a fee. 
 
  
 
 Any recommendations?
 
  
 
 Regards,
 
 Srinivas Vadhri
 

http://www.python.org/infogami-faq/tutor/tutor-whats-the-best-editor-ide
-for-python/

Or tinyurl ..http://tinyurl.com/yxjxgc

I use VIM. I've been experimenting with Eclipse and Pydev. You'll get
almost as many answers as there are people on this list.

Mike
-

  NOTICE:  This e-mail transmission and any documents or files attached to
  it contain information for the sole use of the above-identified individual or 
entity.

  Its contents may be privileged, confidential, and exempt from disclosure 
under the law.
  Any dissemination, distribution, or copying of this communication is strictly 
prohibited.

  Please notify the sender immediately if you are not the intended recipient.

FGNS
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] First realscript + Game of Life

2006-11-10 Thread Mike Hansen
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Luke Paireepinart
 Sent: Friday, November 10, 2006 12:08 AM
 To: Carlos
 Cc: tutor@python.org
 Subject: Re: [Tutor] First realscript + Game of Life
 
 
  Since there has been some talk about the list itself, when 
 some of you 
  reply to my posts sometimes I get a mail straight to my 
 account. This 
  is very useful because it lets me see the reply before it 
 is posted on 
  the list and because in this way is easier to keep track of 
 the info 
  that is useful for me. The question is: is this a personal 
 option from 
  the person who replys? I would like to have all my answers 
 this way, 
  is it possible?
 You get a direct mail when people use the 'reply-all' feature.
 I use that exclusively.
 I figure if enough people are aggravated by it, they'll get 
 the admin to 
 add reply-munging so replies
 only go straight to the whole list like on Pygame.
 Otherwise, I use reply-all so I don't have to type in 
 'tutor@python.org' 
 every time.
 The side effect of other people getting the e-mails is 
 generally not too 
 annoying,
 because the list is smart enough to not send you an extra copy anyway.
 So unless you use the Digest method, you shouldn't notice a 
 difference 
 at all.
 
  Thanks a lot for your help.
 Sure thing.
 
  Happy coding,
 You too.
  Carlos
 -Luke

http://www.python.org/infogami-faq/tutor/tutor-why-do-my-replies-go-to-t
he-person-who-sent-the-message-and-not-to-the-list/

Or 

http://tinyurl.com/uns5q
-

  NOTICE:  This e-mail transmission and any documents or files attached to
  it contain information for the sole use of the above-identified individual or 
entity.

  Its contents may be privileged, confidential, and exempt from disclosure 
under the law.
  Any dissemination, distribution, or copying of this communication is strictly 
prohibited.

  Please notify the sender immediately if you are not the intended recipient.

FGNS
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] SAX, DOM, XSLT api

2006-11-10 Thread Mike Hansen
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Picio
 Sent: Friday, November 10, 2006 8:03 AM
 To: tutor@python.org
 Subject: [Tutor] SAX, DOM, XSLT api
 
 Hello,
 what are the equivalent Pyhton tools you suggest to handle:
 SAX
 DOM
 
 and which api for XSLT ?
 
 I know that this is a really newbie question...But I'm a true 
 python newbie ;) !
 Daniele
 
 P.s: I know I can also google-it a little bit to find those answers
 but your advices are better.
 ___
 Tutor maillist  -  Tutor@python.org
 http://mail.python.org/mailman/listinfo/tutor
 

Here's a list of all the XML parsing modles that come with Python 2.5.
Element Tree seems to be the more popular way of parsing XML in Python.
I believe you can download Element Tree for older vesions of Python.

http://docs.python.org/lib/markup.html

Here's an article on XSLT tools for Python...

http://uche.ogbuji.net/tech/akara/nodes/2003-01-01/python-xslt


Mike

-

  NOTICE:  This e-mail transmission and any documents or files attached to
  it contain information for the sole use of the above-identified individual or 
entity.

  Its contents may be privileged, confidential, and exempt from disclosure 
under the law.
  Any dissemination, distribution, or copying of this communication is strictly 
prohibited.

  Please notify the sender immediately if you are not the intended recipient.

FGNS
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] winsound mac

2006-11-10 Thread Mike Hansen
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of max .
 Sent: Friday, November 10, 2006 9:01 AM
 To: tutor@python.org
 Subject: [Tutor] winsound mac
 
 i am starting a small useless program i got from the show 
 lost but cant find 
 a module on mac to make beeping noises i know windows has 
 winsound *never 
 used it but heard about it* but eather way is thair anything 
 like winsound 
 for mac
 
 
 
 ^_^  s33 y4
 

If you don't get any answers here, you might try the Python Mac Sig.

http://www.python.org/community/sigs/current/pythonmac-sig/

Mike
-

  NOTICE:  This e-mail transmission and any documents or files attached to
  it contain information for the sole use of the above-identified individual or 
entity.

  Its contents may be privileged, confidential, and exempt from disclosure 
under the law.
  Any dissemination, distribution, or copying of this communication is strictly 
prohibited.

  Please notify the sender immediately if you are not the intended recipient.

FGNS
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Mapping to object attributes

2006-11-01 Thread Mike Hansen
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Alan Gauld
 Sent: Tuesday, October 31, 2006 4:47 PM
 To: tutor@python.org
 Subject: Re: [Tutor] Mapping to object attributes
 
 
 Mike Hansen [EMAIL PROTECTED] wrote
 
  I've got a web form with a lot of form fields. I'd like to be able 
  to map
  the form fields to an object's attributes. I'm having a little 
  trouble
  figuring out how.
 
 John has answered that bit.
 
  There will be some fields I'll need to validate(boolean or 
 int), but 
  the
  majority are just text fields that can be passed to the object.
 
 One thing you can do is store the validation functions in the
 dictionary with the value.
 
 def intValidator(i):
  try: return int(i)
  except: return None
 
 def boolValidator(b):
  try: return b and True or False
  except: return None
 
 mapping = { 'field': (intvalue, intValidator),
   'another': (boolvalue,boolValidator)...}
 
 You can then access the validator like so:
 
 value = mapping[fieldname][0]
 validator = mapping[fieldname][1]
 value = validator(value)
 if value == None: #ooops!
 
 or more concisely:
 
 value = mapping[fieldname][1](mapping[fieldname]0])
 
 This style of validation has the benefit (or side-effect if you 
 prefer)
 of converting compatible types into true types. eg. validating a 
 string
 or float representation of an integer returns the actual integer 
 value.
 
 HTH,
 
 -- 
 Alan Gauld
 Author of the Learn to Program web site
 http://www.freenetpages.co.uk/hp/alan.gauld 
 

Thanks John and Alan. Your suggestions will make my code less nested.

Mike
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Mapping to object attributes

2006-10-31 Thread Mike Hansen
I've got a web form with a lot of form fields. I'd like to be able to map
the form fields to an object's attributes. I'm having a little trouble
figuring out how.

I was thinking of something like this..

form = cgi.FieldStorage()
widget = Widget() 

form_field_object_map = {'widget_name' : widget.name, 
 'alt_widget_name' : widget.alt_name,
 ...}
 
for form_field in form_field_object_map.keys():
form_field_object_map[form_field]...er

I'd like to avoid a pile if elif elifs. It seems like there should be a
cleaner way.

if form_field == 'widget_name':
widget.widget_name = form.getvalue(form_field)
elif form_field == 'alt_widget_name':
widget.alt_name = form.getvalue(form_field)
elif ...


There will be some fields I'll need to validate(boolean or int), but the
majority are just text fields that can be passed to the object.

Anyone got any ideas on how to do this?

Thanks,

Mike

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Generic Application Frameworks?

2006-10-19 Thread Mike Hansen
 
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Chris Hengge
Sent: Thursday, October 19, 2006 1:22 PM
To: PyTutor
Subject: Re: [Tutor] Generic Application Frameworks?


Just incase anyone doesn't want to see that document to know
what I'm asking about...

Razor/Carbon includes:
Auto Update
Plugin System with management
Error reporting

Its got a few other features, but these are my focus. 


On 10/19/06, Chris Hengge [EMAIL PROTECTED] wrote: 

I was curious if there are any frameworks around like
carbon/razor implimented in razor? 

Here's a link with information about razor (.net 1.1
versin of carbon)
http://www.codeproject.com/cs/design/razorpt1.asp

If not, is there any reason why? (limitation of python?)

---

You might ask on comp.lang.python.
You might also do a search at http://cheeseshop.python.org/pypi

I did a search for 'application framework' and came up with 
http://cheeseshop.python.org/pypi/PlugBoard/0.2

Most of the other hits were for web application frameworks.

Do you feel you need an application framework?

I don't believe there's any limitation in python. I suspect it's mostly
philosophical.

Mike


  

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Generic Application Frameworks?

2006-10-19 Thread Mike Hansen
 [...]

I don't believe there's any limitation in python. I suspect it's
mostly 
philosophical. -- What did you mean by this Mike?



import this

Simple is better than complex.
Complex is better than complicated.

I'm kind of torn on using frameworks. I'm but a simple caveman
programmer(*), and some of these frameworks seem pretty complicated. On
the other hand, they sound like they can speed up development. One of
these days I'll probably take a good look at Django(**), and see if I
can whip out a CRUD(***) web app.

* - Phil Hartman SNL(I'm but a simple caveman lawyer)
** - A web application framework
*** - CRUD...Create Update Delete

Mike


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Exception and sys.exit() in a cgi script

2006-10-16 Thread Mike Hansen
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Paulino
 Sent: Sunday, October 15, 2006 10:10 AM
 To: tutor@python.org
 Subject: [Tutor] Exception and sys.exit() in a cgi script
 
 This is a peace of a CGI script i have.
 
 1 import cgi
 2 form=cgi.FieldStorage()
 3 try :
 4 ano=form[ano].value
 5 conta=form[conta].value
 6 except KeyError :
 7 print 'htmlbrbrbodypPlease enter values in the
 fields/p/body/html '
 8 sys.exit(0)
 
 
 When the excption occurs, no message is shown on the browser.
 
 If I run the script with IDLE, the message is printed and then the
 script exits.
 
 What's wrong here?
 
 
 
 ___
 Tutor maillist  -  Tutor@python.org
 http://mail.python.org/mailman/listinfo/tutor
 

I'm catching up on the weekend's tutor messages.

import cgitb; cgitb.enable()
That spits errors to the web page which is great for debugging cgi
scripts.

I think you need
print Content-Type: text/html\n\n
Before your print html statement.

http://docs.python.org/lib/cgi-intro.html

http://docs.python.org/lib/node560.html

Mike

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Equivalent to perl -e

2006-10-16 Thread Mike Hansen
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of wesley chun
 Sent: Monday, October 16, 2006 12:51 AM
 To: Chris Lasher
 Cc: Python Tutor
 Subject: Re: [Tutor] Equivalent to perl -e
 
  His lab maintains a significant amount of Perl code
 
 this sounds like a full-time job on its own.  everyone brings up a
 good point... use the right tool for the job.  if it's one-liners,
 that's what perl -e is made for.  for everything else that you
 mentioned above, Python is the the one, preferably the only one
 --obvious way to do it.  :-)
 
 one perl'y thing that i *do* use is perl -c, for checking your syntax.
  i don't believe there's an equivalent way to do that from the Python
 cmd-line (correct me if i'm wrong!), but i wrote up a short script I
 called (pydashc.py) which just uses compile() to get the same
 effect... very useful for when i don't want to *run* something to see
 if i made any typos.
 
 regards,
 -- wesley

I had this same issue when I moved from Perl to Python. You might take a
look at pyflakes, pychecker, or pylint.

Mike
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] python equivalent of perl readlink()?

2006-10-16 Thread Mike Hansen
[...]
 
 I certainly wouldn't like to see python breaking backwards
 compatibility, which is probably my primary gripe about open
 source software (although Bell Labs was equally guilty when they
 did things like change the ``grep -y'' option to ``grep -i'').
 
 Bill

From what I understand, Python 3000 is going to break backwards
compatibility. However, I think I read that someone is writing a utility
that will translate your pre-Python 3000 code to Python 3000 code.

Mike

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] VIM Python

2006-10-11 Thread Mike Hansen
This is slightly off topic...

I use VIM to write my Python programs. I usually have a shell open to run
pyflakes on the file I just edited. Is there a way to run pyflakes from
within VIM and have it display the errors in another buffer?

The :make stuff is confusing me.

Mike


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] VIM Python

2006-10-11 Thread Mike Hansen
 

 -Original Message-
 From: Carlos Hanson [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, October 11, 2006 10:50 AM
 To: Mike Hansen
 Cc: tutor@python.org
 Subject: Re: [Tutor] VIM  Python
 
 
 On Tue, October 10, 2006 1:44 pm, Mike Hansen wrote:
  This is slightly off topic...
 
  I use VIM to write my Python programs. I usually have a 
 shell open to
   run pyflakes on the file I just edited. Is there a way to run
  pyflakes from within VIM and have it display the errors in another
  buffer?
 
  The :make stuff is confusing me.
 
  Mike
 
 Because I also use vim, I looked into this.  I found the answer on the
 following site:
 
   http://www.rayninfo.co.uk/vimtips.html
 
 Try the following:
 
   :new | r!pyflakes #
 
 -- 
 Carlos Hanson
 Web and System Administrator
 Tigard-Tualatin School District
 503.431.4053
 

Interesting page. Works great! Thanks!

Mike
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] VIM Python

2006-10-11 Thread Mike Hansen
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Alan Gauld
 Sent: Wednesday, October 11, 2006 2:41 PM
 To: tutor@python.org
 Subject: Re: [Tutor] VIM  Python
 
  I use VIM to write my Python programs. I usually have a shell open 
  to run
  pyflakes on the file I just edited. Is there a way to run pyflakes 
  from
  within VIM and have it display the errors in another buffer?
 
 I'm being lazy and not doing a search, but what is pyflakes?
 
 Alan G
 Another vim user... 
 

No problem.

http://www.divmod.org/projects/pyflakes

Pyflakes is a simple program which checks Python source files for
errors. It is similar to PyChecker in scope, but differs in that it does
not execute the modules to check them. This is both safer and faster,
although it does not perform as many checks. Unlike PyLint, Pyflakes
checks only for logical errors in programs; it does not perform any
checks on style. - From the pyflakes web site.

Mike
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Creating folders in windows...

2006-10-11 Thread Mike Hansen


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Chris Hengge
Sent: Wednesday, October 11, 2006 4:00 PM
To: Python Tutor
Subject: [Tutor] Creating folders in windows...


I found this from a 2004 mailing on this list..
os.path.mkdir('folder') 
Doesn't work... there is no mkdir in os.path (old style maybe?)

 os.path.mkdir('folder')
Traceback (most recent call last):

File input, line 1, in ?
AttributeError: 'module' object has no attribute 'mkdir'


 dir(os.path)
['__all__', '__builtins__', '__doc__', '__file__', '__name__',
'abspath', 'altsep', 
'basename', 'commonprefix', 'curdir', 'defpath', 'devnull',
'dirname', 'exists', 
'expanduser', 'expandvars', 'extsep', 'getatime', 'getctime',
'getmtime', 'getsize', 
'isabs', 'isdir', 'isfile', 'islink', 'ismount', 'join',
'lexists', 'normcase', 
'normpath', 'os', 'pardir', 'pathsep', 'realpath', 'sep',
'split', 'splitdrive', 
'splitext', 'splitunc', 'stat', 'supports_unicode_filenames',
'sys', 'walk']

Anyways... could someone please point me in the right direction?

I can use os.system('md test'), but that isn't cross platform...
Hopefully nothing is wrong with my python installation.

Thanks!
 

You might try os.mkdir instead of os.path.mkdir
 
Mike 



___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] module loading

2006-10-05 Thread Mike Hansen
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED]
 Sent: Thursday, October 05, 2006 12:06 AM
 To: tutor@python.org
 Subject: [Tutor] module loading
 
 Newbie BioGrad student here (again):
 
 First, thanks for the help on the root node variable last time. It was
 most helpful!
 
 Now, I am trying to load a new module into MacPython, but 
 after doing $
 python setup.py install, or $ python setup.py build, then $ python
 setup.py
 
 the files on the module I downloaded are the following:
 
 DEVELOPERS  Legal.htm   PKG-INFOSrc
 customize.pyrpm_build.sh
 DemoLib PackagesTest   
 makeclean.shrpm_install.sh
 INSTALL MANIFESTREADME  build  
 makedist.batsetup.cfg
 Include MiscRPM.README  changes.txt
 makedist.sh setup.py
 
 
 The INSTALL file says I don't need to configure the module if 
 I'm running
 versions greater than OSX, which I am, but when I run the 
 setup file in
 the last line of a bunch of erros it tells me the gcc failed.
 
 
 Thanks again for your help. You guys rock.
 
 
 
 Hugo Alamillo
 265 Eastlick
 Biological Sciences
 PO Box 644236
 Pullman, WA 99164-4236
 509-432-6869
 https://www.wsu.edu/~halamillo/
 
 

You might try asking this on the python mac mail list. They are
extremely helpful.

http://www.python.org/community/sigs/current/pythonmac-sig/

Mike
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] [Fwd: Re: database web app, what tool?]

2006-10-03 Thread Mike Hansen
 To:   Liam Clarke [EMAIL PROTECTED]
 References:   [EMAIL PROTECTED] 
 [EMAIL PROTECTED] [EMAIL PROTECTED]
 
 
 
 Thank you Liam,
 
 
 Our web server is IIS, but it would be no problem to use 
 another one for this
 particular purpose.
 
 I'v been looking for information on how to design tables for 
 the web with
 python, without succes so far. Can you point me any tutorial?
 
 
 Paulino
 
 

Do you mean HTML tables? If so, it'd probably be best to use a
templating system like cheetah. If you want to do it the hard way, you
can do it from your python program with print statements.(print
tabletr...) I think there's a module out there that can generate
HTML for you.

I'm not sure how far you've gone with doing web programming with python.
You might look at this article

http://www.devshed.com/c/a/Python/Writing-CGI-Programs-in-Python/

Mike
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] What is a Python project?

2006-10-03 Thread Mike Hansen
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Dick Moores
 Sent: Tuesday, October 03, 2006 12:52 AM
 To: tutor@python.org
 Subject: [Tutor] What is a Python project?
 
 I tried out Wing IDE Personal 
 (http://wingware.com/wingide-personal) off and on for 30 days, and 
 then, finding it easy to use (probably because it's designed for 
 Python), decided to buy it. I'm happy with it, and very pleased with 
 the fast response from technical support available by email.
 
 I've never written anything in Python other than single-file scripts. 
 WingIDE has the ability to handle projects, which apparently 
 consist of files and packages. But what is a project? What does a 
 project have that can't be put into a single .py file script?
 
 Thanks,
 
 Dick Moores
 
 ___
 Tutor maillist  -  Tutor@python.org
 http://mail.python.org/mailman/listinfo/tutor


When your apps start getting larger, you'll find that you want to put
common functions into modules that you can hopefully reuse for other
programs. 

http://docs.python.org/tut/node8.html

I've been doing some web programming, so my projects consist of
cheetah template files, CSS, config files, a handful of python
modules...

I hope that helps.

Mike 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] What is a Python project?

2006-10-03 Thread Mike Hansen
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Dick Moores
 Sent: Tuesday, October 03, 2006 12:41 PM
 To: tutor@python.org
 Subject: Re: [Tutor] What is a Python project?
 
 At 10:01 AM 10/3/2006, Mike Hansen wrote:
 
 
   -Original Message-
   From: [EMAIL PROTECTED]
   [mailto:[EMAIL PROTECTED] On Behalf Of Dick Moores
   Sent: Tuesday, October 03, 2006 12:52 AM
   To: tutor@python.org
   Subject: [Tutor] What is a Python project?
  
   I tried out Wing IDE Personal
   (http://wingware.com/wingide-personal) off and on for 
 30 days, and
   then, finding it easy to use (probably because it's designed for
   Python), decided to buy it. I'm happy with it, and very 
 pleased with
   the fast response from technical support available by email.
  
   I've never written anything in Python other than 
 single-file scripts.
   WingIDE has the ability to handle projects, which apparently
   consist of files and packages. But what is a project? 
 What does a
   project have that can't be put into a single .py file script?
  
   Thanks,
  
   Dick Moores
  
   ___
   Tutor maillist  -  Tutor@python.org
   http://mail.python.org/mailman/listinfo/tutor
  
 
 When your apps start getting larger, you'll find that you want to put
 common functions into modules that you can hopefully reuse for other
 programs.
 
 Yes, I already have done this. But in scripts I write I simply import 
 the functions I want from that module. I don't think in terms of 
 making a project. Maybe I've missed your point?
 
 http://docs.python.org/tut/node8.html
 
 Now, that page has a lot of stuff I didn't know. Thanks! Maybe I 
 should read the whole tutorial. I see that's it's been updated for 
 2.5. And it's by GvR. http://docs.python.org/tut/tut.html
 
 I've been doing some web programming, so my projects consist of
 cheetah template files, CSS, config files, a handful of python
 modules...
 
 Why do you make python modules part of a project? They can be used 
 without copying them around, can't they? Or is it that by a project 
 is meant in part a list of pointers to all the files you mean for 
 that program to use, and you don't actually have to copy or move them 
 so they are all in the same folder/directory?
 
 Thanks, Mike.
 
 Dick
 

I use Komodo and VIM. With Komodo, a project is just a collection of
related files. I'd imagine that WingIDE does something similar. You set
up a project and add files to them. It's just a way to keep organized.

As far as the python modules in my project, they are ones that I've
written not 3rd party stuff. If the day comes that I use my own modules
in more than one application/project, I'll probably move them to site
packages.

Mike
 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Python CGI Script

2006-09-21 Thread Mike Hansen
 

 -Original Message-
 From: Alan Gauld [mailto:[EMAIL PROTECTED] 
 Sent: Thursday, September 21, 2006 2:51 AM
 To: Mike Hansen; tutor@python.org
 Subject: Re: [Tutor] Python CGI Script
 
 sql_statement = INSERT INTO images (image) VALUES (%s)
 cur.execute(sql_statement, (data_obj, ))
 
 Is it just moving the variable substitution to the execute statement 
 as
  a tuple, so it will perform the proper quoting?
 
 Nope, the syntax changes slightly, and I believe depends on the
 database driver you use. For SqlLite (and I think for MySql) its a
 question mark
 
 sql_statement = INSERT INTO images (image) VALUES (?)
 cur.execute(sql_statement, data_obj)
 
 And I don;t think you need the tuple form unless you have multiple 
 values.
 And you can do it in one line too:
 
 cur.execute(INSERT INTO images (image) VALUES (?), data_obj)
 
 Alan G. 
 


In my case, I'm using psycopg2 for PostgreSQL. I just did a test, and it
doesn't seem to like the ? syntax. I'll check the documentation to see
if there's a setting to have it use the ? syntax. 

Thanks,

Mike 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] module file copy ?

2006-09-21 Thread Mike Hansen
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Dave S
 Sent: Thursday, September 21, 2006 2:41 PM
 To: Python Tutor
 Subject: [Tutor] module file copy ?
 
 OK have I missed it - but which module is file copy in ? I 
 looked all around 
 OS but no luck - I can find rename(src, dst) but that's about it.
 
 Cheers
 
 Dave
 
 ___
 Tutor maillist  -  Tutor@python.org
 http://mail.python.org/mailman/listinfo/tutor
 

I think I had the same problem when I started using Python.

It's the shutil module.
shutil.copyfile(src, dst)

Mike
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Python CGI Script

2006-09-20 Thread Mike Hansen
 

 -Original Message-
 Subject: Re: [Tutor] Python CGI Script
 
 query1 = SELECT ABC FROM %s limit %s,%s\
   % (self.tableid,self.rangeid1,self.rangeid2)
 
 Just as a note: please don't do this!  *grin*
 
 Don't build query strings up like this: this is very prone to an SQL 
 injection attack.  See:
 
  http://mail.python.org/pipermail/tutor/2003-April/022010.html
 
 which talks about this a bit more.
 ___


I just wanted to verify what I believe to be correct way of doing this.

sql_statement = INSERT INTO images (image) VALUES (%s)
cur.execute(sql_statement, (data_obj, ))

Is it just moving the variable substitution to the execute statement as
a tuple, so it will perform the proper quoting?

Thanks,

Mike
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Hi All

2006-09-05 Thread Mike Hansen
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Amit Rane
 Sent: Saturday, September 02, 2006 4:52 AM
 To: tutor@python.org
 Subject: [Tutor] Hi All
 
 Hi , 
 This is Amit from India ...
 i have just started working on Python ...
 please let me know the books to refer to start
 learning 
 python ..as of now i am going thru online books ...
 please let me know if any additional books are there .
 
 
 
 Thanks  Regards ,
 Amit Rane
 
 

This question gets asked a lot, so here's a tinyurl link to the FAQ on
this topic.

http://tinyurl.com/kl9bu

which is
http://pyfaq.infogami.com/tutor-what-are-some-good-books-on-python
**
IMPORTANT: The contents of this email and any attachments are confidential. 
They are intended for the 
named recipient(s) only.
If you have received this email in error, please notify the system manager or 
the sender immediately and do 
not disclose the contents to anyone or make copies thereof.
*** eSafe scanned this email for viruses, vandals, and malicious content. ***
**

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] omnicomplete vim python

2006-08-29 Thread Mike Hansen
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Alan Gauld
 Sent: Tuesday, August 29, 2006 1:26 AM
 To: anil maran
 Cc: tutor@python.org
 Subject: Re: [Tutor] omnicomplete vim python
 
[...]
 
 This isn't answering Anil's question but I'm curious.
 I've had access to editors that do this kind of thing since 1988
 when I first encountered DECs LSE(Language Sensitive Editor)
 for the VAX. and in a more limited form C and Lisp modes on emacs.
 Then it became popular on PC editors in Visual Studio and
 the Borland tools.
 
 But does anyone actually use this feature? I know I don't, in
 fact I usually turn it off because I find it distracting! I usually
 know what attributes or methods I need to call, and the
 parameters that I need to pass often depend on context anyway
 so the tools often get it wrong.
 
 So I'm curious, how many folks actively use these so-called
 productivity features like intellisense/omnicomplete?
 
 BTW I don't mind toopltips - where they tell you the signature
 of a function but don't fill it in... Its the autocomplete feature 
 I've
 never found helpful.
 
 Alan G

I switch between Komodo and VIM. Komodo has autocomplete. I've never
found it distracting. It's kind of useful. I haven't explored
omnicomplete in VIM yet. I still just ctrl-n instead of using the new
omnicomplete stuff. I like the background syntax checking in Komodo. It
has been helping me clean up problems before I get around to running
Pyflakes on the program. 

BTW, the next version of Komodo will have vi key-bindings!

Mike  
**
IMPORTANT: The contents of this email and any attachments are confidential. 
They are intended for the 
named recipient(s) only.
If you have received this email in error, please notify the system manager or 
the sender immediately and do 
not disclose the contents to anyone or make copies thereof.
*** eSafe scanned this email for viruses, vandals, and malicious content. ***
**

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] making independent program?

2006-08-28 Thread Mike Hansen
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Kay
White
Sent: Monday, August 28, 2006 1:45 PM
To: tutor@python.org
Subject: [Tutor] making independent program?


Hello again,

Can you make programs that don't require an installation of
Python to run? I want my little program to run on other peoples'
computers, without them having to install Python to use it. I've
searched through tutorials and there doesn't seem to be any information
about this. 






http://pyfaq.infogami.com/tutor-how-do-i-make-an-executable-out-of-my-py
thon-program

or
 
http://tinyurl.com/gtrpa
 
if the url is too long.

Mike
**
IMPORTANT: The contents of this email and any attachments are confidential. 
They are intended for the 
named recipient(s) only.
If you have received this email in error, please notify the system manager or 
the sender immediately and do 
not disclose the contents to anyone or make copies thereof.
*** eSafe scanned this email for viruses, vandals, and malicious content. ***
**

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] tkinter events: B1-Motion

2006-08-24 Thread Mike Hansen
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Zsiros Levente
 Sent: Thursday, August 24, 2006 2:21 PM
 To: Danny Yoo
 Cc: python tutor
 Subject: Re: [Tutor] tkinter events: B1-Motion
 
 If we're talking about data hiding, let me ask: why Python doesn't 
 implement data hiding (I mean 'private' and 'protected')? I 
 consider it 
 a very important OOP feature, because that makes OOP different from 
 structural programming.
 

This might explain...

http://pyfaq.infogami.com/tutor-how-do-i-make-public-and-private-attribu
tes-and-methods-in-my-classes

Mike
**
IMPORTANT: The contents of this email and any attachments are confidential. 
They are intended for the 
named recipient(s) only.
If you have received this email in error, please notify the system manager or 
the sender immediately and do 
not disclose the contents to anyone or make copies thereof.
*** eSafe scanned this email for viruses, vandals, and malicious content. ***
**

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] python processing of web html forms

2006-08-03 Thread Mike Hansen
 __

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Jeff Peery
Sent: Thursday, August 03, 2006 11:38 AM
To: tutor@python.org
Subject: [Tutor] python processing of web html forms


Hello, I want to use python to process information input into a
HTML form on my website. how is this typically performed? I saw cherrypy
and also quixote for web python stuff... I have no experience with
python on the web. Thanks.

jeff




You might want to take a look at the cgi module. 
Devshed has an article on getting started with it.
http://www.devshed.com/c/a/Python/Writing-CGI-Programs-in-Python/

IMO, I think if you want to do web stuff, you should learn the basics
first(cgi), then move on to cherrypy, quixote, django, turbo gears...

Mike
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] IDE for Python

2006-07-25 Thread Mike Hansen
 




From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Basavaraj SP.
Sent: Tuesday, July 25, 2006 9:05 AM
To: tutor@python.org
Subject: [Tutor] IDE for Python



Dear All,

I am new to Python.

I want to know which IDE I should use for programming.

If so from where can I get it?

Thanks in advance.   

- Raj

I personally use VIM. The closest thing to an IDE I've used is Komodo.
You might check out these links.

http://pyfaq.infogami.com/tutor-whats-the-best-editor-ide-for-python

Mike
http://users.adelphia.net/~mahansen/programming/editorides.html
 

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] need problems to solve

2006-07-12 Thread Mike Hansen





  
  Hi,
  I was wondering where I could get problems in python for 
practicing.
  Thanks
  Regards
  
  Devayani
  
  http://pyfaq.infogami.com/tutor-im-learning-python-what-should-i-programhas 
  some suggestions.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] classes and functions

2006-06-30 Thread Mike Hansen
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of anil maran
 Sent: Thursday, June 29, 2006 12:51 PM
 To: Tutor
 Subject: [Tutor] classes and functions
 
 how to use classes and functions in python
 thanks

What do you need to know? Have you read the tutorial?
http://pytut.infogami.com/

The tutorial wiki has some info about functions
http://pytut.infogami.com/node6.html

There's also some information on classes
http://pytut.infogami.com/node11-baseline.html

Post specific questions if these links aren't clear enough, and we can
probably help. I hope these links help you.

Mike
http://users.adelphia.net/~mahansen/programming/ 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] projects for beginners

2006-06-19 Thread Mike Hansen





  
  
  From: [EMAIL PROTECTED] 
  [mailto:[EMAIL PROTECTED] On Behalf Of josipSent: 
  Monday, June 19, 2006 8:39 AMTo: 
  tutor@python.orgSubject: [Tutor] projects for 
  beginners
  
  Hi!
  
  I have read learning python and mede some smaller examples.
  Now I want to make smoe project, I'm thinking about text editor.
  Can someone give me pointers like (where and how to start, etc.)?
  Or maybe another project suitable for beginners.
  
  
  http://pyfaq.infogami.com/tutor-im-learning-python-what-should-i-program
  
  Has 
  a couple of ideas for projects.
  
  Mike
  http://users.adelphia.net/~mahansen/programming/ 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] If then else question

2006-06-14 Thread Mike Hansen
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Andrew Robert
 Sent: Wednesday, June 14, 2006 12:41 PM
 To: Python Tutor
 Subject: [Tutor] If then else question
 
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1
 
 Hi Everyone,
 
 In the middle of an if then else, I have the following line
 
   elif ch_val == '040' or ch_val == '011' or ch_val == '012':
 
 
 The line works but it is a little ungainly.
 
 Anyone have a better way of accomplishing the same thing?
 
 
 - --
 Thank you,
 Andrew Robert
 

Maybe...

elif ch_val in ['040', '011', '012']:

Mike
http://users.adelphia.net/~mahansen/programming/ 

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] die or exit function?

2006-06-13 Thread Mike Hansen
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On 
 Behalf Of Andy Koch
 Sent: Tuesday, June 13, 2006 8:42 AM
 To: tutor@python.org
 Subject: [Tutor] die or exit function?
 
 Bkgd: I've been doing PHP for the last several years.
 
 Q: In PHP there are functions die and exit which terminate 
 processing of 
 a script with an optional string output.  Is there something 
 similar to 
 this in Python?
 


sys.exit(something bad happened)

Although it's probably better to catch the exception and deal with it and
then sys.exit() if need be.

Mike
http://users.adelphia.net/~mahansen/programming/

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Python related mags

2006-06-12 Thread Mike Hansen

On Jun 12, 2006, at 5:53 AM, Andrew Robert wrote:

 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 Hi everyone,

 Does anyone know of any Python related magazines available that would 
 be
 worth subscribing to?

 Ideally, a free one, but I would not object to a reasonably priced one
 either.

 I was able to find pyzine located at www.pyzine.com but it appears to 
 be
   defunct.


I don' think there's much out  there. Sometime Linux Journal will have 
Python related articles, sometimes Dr. Dobbs. As popular as Python is, 
it's probably not popular enough to sustain a magazine devoted just to 
it.

Mike

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] making a python program part of xhtml

2006-06-08 Thread Mike Hansen
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Emily Fortuna
 Sent: Thursday, June 08, 2006 7:20 AM
 To: tutor@python.org
 Subject: [Tutor] making a python program part of xhtml
 
 Hola everyone,
 I'm working on creating a webpage in which a user can submit 
 data into 
 fields to be held in a database (there are other details, but this is 
 the gist of the idea), and I need to use python.  I am 
 unfamiliar with 
 manipulating data and web apps as a whole (and new to 
 python), so I have 
 been encountering much unfamiliar terrain.  I _think_ I want 
 to somehow 
 embed the python into the page, but I'm really not sure how 
 to do it.  
 After googling I found some programs that generate xhtml from python, 
 but I don't think that is what I want, or is it?  Your help 
 is appreciated!
 Emily


Although you can embed python in a web page to be run on a server, you
probably don't want to do that.(It can get pretty messy.)

What I'd suggest is creating a web page that calls a python program on the
server and processes form fields in the web page. The python program would
save the data in the database.

[web page] - [python program on server] - [database]

Look at the FORM tag in HTML/XHTML. Also look at the cgi module for Python.
I think there's some web topics on the Python web site that might point to
articles about doing simple cgi stuff in Python.

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

http://www.devshed.com/index2.php?option=contenttask=viewid=198pop=1page
=0hide_js=1

Is an article on cgi programming with Python.

Mike

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Tutor FAQ

2006-05-17 Thread Mike Hansen
Here's a small batch of questions/answers for the tutor FAQ.

Let me know if you have any corrections or clarifications. I'll post 
them to the web site in a couple of days.

Mike

-
How much code should I post?

Post as much relevent code as you can. However, the consensus seems to 
be that the more code you post, the less likely you'll get someone to 
review it. A max of 100 lines is suggested. If you have more code, you 
might post your code at
http://www.rafb.net/paste or a similar site.

-
How do I dynamically name my objects? How do I name my objects based on 
user input?

Rather than performing voodoo by dynamically creating variables, your 
best bet is to use a dictionary with the keys being the name of the 
object or user input and the values being the objects.

-
Why doesn't my special method add, init, or cmp.. work?

Remember to use two underscores before and after the method name 
__add__, __init__, __cmp__.

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Tutor FAQ

2006-05-03 Thread Mike Hansen
Well, I posted a few questions to http://pyfaq.infogami.com/tutor-index 
late last week. Since the next questions and answers are a bit on the 
long side, I'll send them to this list in multiple messages. Please let 
me know if you have any corrections or clarifications. Below is a 
reworked question from last week.

-
How do I make public and private attributes and methods in my classes?

Python followws the philosophy of we're all adults here with respect 
to hiding attributes and methods. i.e. trust the other programmers who 
will use your classes. You should use plain attributes whenever 
possible.

You might be tempted to use getters and setters, but the only reason to 
use getters and setters is so you can change the implementation later 
if you need to.  However, Python
allows you to do this with properties

http://www.python.org/download/releases/2.2.3/descrintro/#property

If you really must hide an attribute or method, Python does do name 
mangling. By putting two underscores before the attribute or method 
name and not putting two underscores after the name, Python will mangle 
the name by putting the class name in front of it.

For an short example see
http://en.wikipedia.org/wiki/Name_mangling#Name_mangling_in_Python

[Paraphrased from a post to comp.lang.python by Steven Bethard]

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Tutor FAQ

2006-05-03 Thread Mike Hansen
-
What's the difference between import foo and from foo import *?

import sys

This brings the *name* sys into your module.
It does not give you access to any of the names inside sys itself (such 
as
exit for example). To access those you need to prefix them with sys, as 
in

sys.exit()

from sys import *

This does NOT bring the name sys into your module, instead it brings 
all
of the names inside sys(like exit for example) into your module. Now 
you can
access those names without a prefix, like this:

exit()

So why not do that instead of

import sys?

The reason is that the second form will overwrite and names you have 
already
declared - like exit say.
exit = 42
from sys import *   # hides my exit variable.

OR more likely, the other way round

from sys import *
exit = 42   # now hides the sys.exit function so I can't use it.

Of course some of these are obvious but there can be a lot of names in a
module, and some modules have the same name in them, for example:

from os import *
from urllib import *

open(foo)   # which open gets called, os.open or urllib.open?

Can you see how it gets confusing.
Bottom line is it is usually better to accept the extra typing and use

import foo

or for just a few names

from foo import bar,baz

[from a post on Python Tutor by Alan Gauld]

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Tutor FAQ

2006-05-03 Thread Mike Hansen
I need some help with this question and answer. It appears that useless 
Python is gone. uselesspython.com. Is it still around? Does anyone have 
any ideas on this one?

-
I'm learning Python. What should I program?

If you have a personal itch to scratch, it's probably best to scratch 
it. You'll probably be more interested and motivated to program if it's 
something you want to accomplish.

However, if you don't have any ideas, you can try the Python Challenge
http://www.pythonchallenge.com/

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Tutor FAQ

2006-05-03 Thread Mike Hansen
-
What are some good books on Python?

See the Python wiki http://wiki.python.org/moin/PythonBooks or search 
comp.lang.python or the tutor archives since this is a very frequently 
asked.

If you have no programming experience, try Alan Gauld's book
Learn To Program http://www.freenetpages.co.uk/hp/alan.gauld/

If you have some programming experience try
Learning Python http://www.oreilly.com/catalog/lpython2/index.html
Dive Into Python http://diveintopython.org/
Beginning Python: From Novice to Professional  
http://www.apress.com/book/bookDisplay.html?bID=10013
Core Python Programming  http://starship.python.net/crew/wesc/cpp/

Good Python reference books are
The Essential Python Reference 
http://www.samspublishing.com/title/0672328623
Python in a Nutshell http://www.oreilly.com/catalog/pythonian/index.html
Python Cookbook http://www.oreilly.com/catalog/pythoncook2/

A note to Perl programmers who are learning Python. Don't start with 
Programming Python. It is not the same as Programming Perl. Start with 
Learning Python, then move on to Programming Python.

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Tutor FAQ

2006-05-03 Thread Mike Hansen
-
What is if __name__ == __main__ for?

The 'if __name__ == __main__:  ... trick exists in Python so that our
Python files can act as either reusable modules, or as standalone
programs.  As a toy example, let's say that we have two files:

##
mumak:~ dyoo$ cat mymath.py
def square(x):
 return x * x

if __name__ == '__main__':
 print test: square(42) ==, square(42)


mumak:~ dyoo$ cat mygame.py
import mymath

print this is mygame.
print mymath.square(17)
##

In this example, we've written mymath.py to be both used as a utility
module, as well as a standalone program.  We can run mymath standalone 
by
doing this:

##
mumak:~ dyoo$ python mymath.py
test: square(42) == 1764
##


But we can also use mymath.py as a module; let's see what happens when 
we
run mygame.py:

##
mumak:~ dyoo$ python mygame.py
this is mygame.
289
##

Notice that here we don't see the 'test' line that mymath.py had near 
the
bottom of its code.  That's because, in this context, mymath is not the
main program.  That's what the 'if __name__ == __main__: ...' trick is
used for.

[From a post to Python Tutor by Danny Woo]

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Cheetah

2006-04-26 Thread Mike Hansen
I'm having a little trouble populating a cheetah template. I thought I'd ask
here first before checking the cheetah mailing list or c.l.p.

I have a simple template

!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
html lang=en
head
titleThis is a test/title
/head
body
h1$titleh1

#for $item in $items
pcategory: $item.category/p
pname: $item.name /p
pprice: $item.price/p
#end for
/body
/html

That I compiled using cheetah.

Here's the python code that uses it:

#!/usr/bin/env python

import testform
import cgitb; cgitb.enable()

class ReqItem(object):
def __init__(self, category, name, price):
self.category = category
self.name = name
self.price = price

t = testform.testform()
t.title = this and that

items = []

category = little stuff
name = hotwheel
price = 2

item = ReqItem(category, name, price)

items.append(item)

category = big stuff
name = monster truck
price = 3

item = ReqItem(category, name, price)

items.append(item)

t.items = items

print Content-Type: text/html\n\n
print str(t)


However, I get the following error:

Traceback (most recent call last):
  File ./testit.py, line 36, in ?
print str(t)
  File testform.py, line 100, in respond
__v = VFFSL(SL,item.category,True)
NotFound: cannot find 'category' while searching for 'item.category'

Does anyone know what I'm doing wrong?

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Tutor FAQ

2006-04-26 Thread Mike Hansen
Here's the next batch of questions and answers for the tutor FAQ. If  
you have any clarifications or corrections, please let me know. I'll  
try to post this on the web site in a couple of days.

-
How do I get data out of HTML?

Try Beautiful Soup.
http://www.crummy.com/software/BeautifulSoup/

Beautiful Soup is more forgiving than other parsers in that it won't  
choke on bad markup.

-
What's the best editor/IDE for Python?

It's really a matter of preference. There are many features of an  
editor or IDE such as syntax highlighting, code completion, code  
folding, buffers, tabs,  ... Each editor or IDE has some or all of  
these features, and you'll have to decide which features are important  
to you.
See http://wiki.python.org/moin/PythonEditors for a list of editors.
Also http://wiki.python.org/moin/IntegratedDevelopmentEnvironments has  
a list of IDEs.

-
How do I make public and private attributes and methods in my classes?

Python followws the philosophy of we're all adults here with respect  
to hiding attributes and methods. i.e. trust the other programmers who  
will use your classes. You can't really hide variables and methods in  
Python. You can give clues to other programmers. Python does do name  
mangling. By putting two underscores before the attribute or method  
name and not putting two underscores after the name, Python will mangle  
the name by putting the class name in front of it.

For an short example see
http://en.wikipedia.org/wiki/Name_mangling#Name_mangling_in_Python

-
Why doesn't my regular expression work?

Typically, it's an isssue between re.match and re.search. Match matches  
the beginning only and search checks the entire string. See the regular  
expression HOWTO for more details.

http://www.amk.ca/python/howto/regex/

-
How do I perform matrix operations using Python?

The Python FAQ has an entry on how to create multidimensional lists:
http://python.org/doc/faq/programming.html#how-do-i-create-a- 
multidimensional-list

You may want to look into the 'numarray' third party module:
http://www.stsci.edu/resources/software_hardware/numarray

-
How do I make an executable out of my Python program?

Although it isn't necessary to turn your Python programs into  
executables, many people want to be able to put their Python programs  
on other machines that don't have Python installed.

Py2exe makes an executable of your Python program. For Windows only.
http://sourceforge.net/projects/py2exe/

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Tutor FAQ

2006-04-26 Thread Mike Hansen
Thanks Kent. I'll make those additions/corrections and rework the 
question about private and public attributes and methods.

Mike

On Apr 26, 2006, at 7:42 PM, Kent Johnson wrote:

 Mike Hansen wrote:
 Here's the next batch of questions and answers for the tutor FAQ. If
 you have any clarifications or corrections, please let me know. I'll
 try to post this on the web site in a couple of days.

 Thanks Mike!

 -
 What's the best editor/IDE for Python?

 It's really a matter of preference. There are many features of an
 editor or IDE such as syntax highlighting, code completion, code
 folding, buffers, tabs,  ... Each editor or IDE has some or all of
 these features, and you'll have to decide which features are important
 to you.
 See http://wiki.python.org/moin/PythonEditors for a list of editors.
 Also http://wiki.python.org/moin/IntegratedDevelopmentEnvironments has
 a list of IDEs.
 This question is asked every few weeks on comp.lang.python so searching
 the archives will yield many opinions.

 -
 How do I make public and private attributes and methods in my classes?

 Python followws the philosophy of we're all adults here with respect
 to hiding attributes and methods. i.e. trust the other programmers who
 will use your classes. You can't really hide variables and methods in
 Python. You can give clues to other programmers.
 By convention, a name that starts with a single underscore is an
 implementation detail that may change and should not be used by client 
 code.
 Python does do name
 mangling. By putting two underscores before the attribute or method
 name and not putting two underscores after the name, Python will 
 mangle
 the name by putting the class name in front of it.
 IMO this needs work but not by me tonight...

 For an short example see
 http://en.wikipedia.org/wiki/Name_mangling#Name_mangling_in_Python

 -
 Why doesn't my regular expression work?

 Typically, it's an isssue between re.match and re.search. Match 
 matches
 the beginning only and search checks the entire string. See the 
 regular
 expression HOWTO for more details.

 http://www.amk.ca/python/howto/regex/

 Python comes with a handy program for testing regular expressions,
 Tools\Scripts\redemo.py.

 -
 How do I perform matrix operations using Python?

 The Python FAQ has an entry on how to create multidimensional lists:
 http://python.org/doc/faq/programming.html#how-do-i-create-a-
 multidimensional-list

 You may want to look into the 'numarray' third party module:
 http://www.stsci.edu/resources/software_hardware/numarray
 Numarray is being replaced with numpy - we should refer people there
 You may want to look into the 'numpy' module which contains many
 resources for scientific computing including powerful matrix 
 operations:
 http://numeric.scipy.org/

 Kent

 ___
 Tutor maillist  -  Tutor@python.org
 http://mail.python.org/mailman/listinfo/tutor


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


  1   2   >