Re: [Tutor] Python 2.4 IDLE Windows 2000

2004-12-03 Thread Mike Hansen
That rooted out the problem. A while ago, I changed the colors to kind 
of match my VIM color theme(ps_color). When I did 
idlelib.PyShell.main(), IDLE came up with my custom color theme. 
However, there was a bunch of warnings about my theme. From IDLE, I 
deleted the theme. Now IDLE will launch normally. I'll set up the color 
theme later. Maybe older color themes aren't compatible with the newer 
IDLE? The color theme must have been laying around. I didn't brute force 
it in or anything like that.

I appreciate the help.
Mike
Danny Yoo wrote:
 

Yowza; that's some bug.  Danny, do you happen to know the bug number?
I can't find it on sourceforge.
 

It's been like that since 2.3 as far as I know. It generates a
connection to localhost to run code in a separate environment.
   

Hi Mike,
I wish I knew what the problem was in better detail.  IDLE is a
part of the Standard Library, so it's actually possible to try turning on
individual pieces of it, one after the other.  Maybe that will help us
debug what's going on.
Start up your console version of Python, and try:
###
 

import idlelib.PyShell
idlelib.PyShell.main()
   

###
That should start IDLE up manually, and if anything bad happens, at least
we should see some errors pop up that will help us debug the situation.
Let's make sure this doesn't fail quietly.  *grin*
Good luck to you!
 

___
Tutor maillist  -  [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Python 2.4 IDLE Windows 2000

2004-12-07 Thread Mike Hansen
Danny Yoo wrote:
On Fri, 3 Dec 2004, Mike Hansen wrote:
 

That rooted out the problem. A while ago, I changed the colors to kind
of match my VIM color theme(ps_color). When I did
idlelib.PyShell.main(), IDLE came up with my custom color theme.
However, there was a bunch of warnings about my theme. From IDLE, I
deleted the theme. Now IDLE will launch normally. I'll set up the color
theme later. Maybe older color themes aren't compatible with the newer
IDLE? The color theme must have been laying around. I didn't brute force
it in or anything like that.
   


Hi Mike,
Ah, whew, I'm glad that actually worked.  *grin*
The information about the color theme problem is valuable to know: can you
send a message to the IDLE developers with a summary of the situation?
It's possible that a lot of other folks might be running into a similar
startup problem.  Let's make sure that no one else has to go through hoops
to get IDLE working again.  The IDLE development list is:
   http://mail.python.org/mailman/listinfo/idle-dev
Good luck to you!
 

Hi Danny,
I put in a bug report on the python sourceforge site. The idle-dev mail 
list didn't seem appropriate. It seems like a mail list for idle 
developers to discuss the IDLE development plan not for users to post 
about bugs.

Thanks again for your help on this issue.
Mike
___
Tutor maillist  -  [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Objects, persistence & getting

2005-01-17 Thread Mike Hansen

Subject:
Re: [Tutor] Objects, persistence & getting
From:
"Alan Gauld" <[EMAIL PROTECTED]>
Date:
Mon, 17 Jan 2005 07:48:28 -
To:
"Liam Clarke" <[EMAIL PROTECTED]>, "Tutor Tutor" 
To:
"Liam Clarke" <[EMAIL PROTECTED]>, "Tutor Tutor" 

Well, one thing learning Java is good for is for thoroughly
demystifying OOP.
   


I'd have to disagree here because Java's version of OOP has
very little to do with real OOP. Java just uss classes as
a kind of modularisation mechanism and does not make much
use of tthe real OO features. In fact it doesn't even
support several of the things that enable real OO
programming.
And its class library, a strong feature because it is a
standard, is dreadful from an OOP p[erspective. In fact
I usually refer to Java as a Class Oriented Programming
rather than Object Oriented.
It is possible to use Java in an OOP way (read Brice Eckel's
"Thinking in Java" to see how) but the language itself
encourages a style of programming that is much more like
Pythons modules than true OOP.
 

It's not some magical acronym of programming
goodness, it's just an 'organic' way to organise code.
   

Certainly in Java thats true, and indeed even at the
higher level OOP is a way of organizing code - by
finding high level abstractions and building tree
structures based on common intefaces. But Java doesn't
encourage that structuring as much as Python does!

 

Alan G.
 

I've been reading The Object Oriented Thought Process, and it's been 
clearing up the OOP mystery for me. After reading a big chunk of it, I 
re-read the OOP sections in Learning Python. It's making a lot more 
sense now.

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


[Tutor] Re: Newbie question.

2005-03-04 Thread Mike Hansen

Subject:
Re: [Tutor] Newbie question.
From:
Gwyn Evans <[EMAIL PROTECTED]>
Date:
Fri, 4 Mar 2005 09:37:21 +
To:
tutor@python.org
To:
tutor@python.org
On Fri, 28 Jan 2005 09:42:07 +0200, Adriaan Louw
<[EMAIL PROTECTED]> wrote:
 

I want to learn python as quick as possible, for web programming at first,
and applications later on. Any leads? 
   

Hi,
 I'd start with the basic python tutorials, then have a look at
something like CherryPy (http://www.cherrypy.org/) or Quixote
(http://www.quixote.ca/) for the initial web stuff - there are others,
too. Try & read around each a bit, e.g. web site/mailing lists, then
download & give ones you fancy a try.
 

I would politely disagree here. You need to walk before you can run. If 
you haven't done _any_ web programming before, it's probably best to do 
a small web app using just python's cgi module. I would think that 
CherryPy and Quixote are complex web tools/frameworks that I wouldn't 
recommend to someone new to web programming until they got their feet 
wet doing some basic web programming. After that, then explore more 
advanced web programming with CherryPy or Quixote.

If you have done some basic web programming in other languages, then 
ignore this message.

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


Re: [Tutor] What is the best book to start?

2005-04-01 Thread Mike Hansen

Subject:
Re: [Tutor] What is the best book to start?
From:
"Alan Gauld" <[EMAIL PROTECTED]>
Date:
Fri, 1 Apr 2005 09:05:16 +0100
To:
"Hoffmann" <[EMAIL PROTECTED]>, 
To:
"Hoffmann" <[EMAIL PROTECTED]>, 

I am starting to studying Python. I have some previous
experience with C (beginner level).

Probably the standard tutorial on the web site is the best
place for you to start.

"Learning Python" by Lutz & Ascher,

And this is very good supporting material.

"Python How to Program" by Deitel and others.

And this is particularly good as an intro into the wider areas
such as PyGame, XML/HTML GUIs and Network programming. The early
chapters are done better IMHO by Lutz, aand the official tutor.
Your next purchase should be either or both of:
Python in a Nutshell - a great 'pocket' reference and
Python Programming on Win32 - but only if you are using Windows of
course!
You have more than enough beginner material already.
Alan G.
I'd also try to fit in Dive Into Python [http://diveintopython.org/]. This book 
really got me hooked on Python. It assumes you know some programming.

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


[Tutor] Pychecker

2005-04-22 Thread Mike Hansen
I had a frustrating time yesterday with a small Python program I wrote. I wasn't 
getting the results I expected, so I sprinkled print statements through it. I 
wasn't getting anywhere. I tossed it into Komodo to see if the background syntax 
checker would pick up something I was missing. I then stepped through it and 
finally noticed that I had messed up a variable name.

firstlist = [listItem[:12] for listItem in firstList]
 ^
when I meant
firstList = [listItem[:12] for listItem in firstList]
 ^
doh!
Later, I realized that I should have run it through Pychecker which would have 
picked it up immediately.

With that experience of learning the hard way, I'd recommend that you always run 
your code through Pychecker just after editing it and before running it.

In Perl, you can perl -c somehardtoreadperlprogram.pl that will just check the 
syntax. The above problem would have been caught in Perl since I always use 
strict. Is there a command line option in Python to do a Pychecker-like syntax 
check? I see a -t to check the tabs, but nothing to tell it to check the syntax 
but don't run it. If not, should Pychecker be part of the standard distribution? 
Am I missing something?

Mike
Go ahead and reply to me AND the list since I just get the digest.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Pychecker

2005-04-22 Thread Mike Hansen
Thanks Danny.
I'll make sure I use pychecker so I don't shoot myself in the foot with not so 
easy to catch typos in variable names and syntax blunders.

I might check with the pychecker devs to see if there's any effort to get it put 
into the standard distribution. I think it's too handy to not have it in the 
standard distribution.

Mike
Danny Yoo wrote:
On Fri, 22 Apr 2005, Danny Yoo wrote:

In Perl, you can perl -c somehardtoreadperlprogram.pl that will just
check the syntax. The above problem would have been caught in Perl
since I always use strict. Is there a command line option in Python to
do a Pychecker-like syntax check?
Hi Mike,
Unfortunately, no, because there are some really funky things that one
can do in Python that you can't do easily in Perl.

Yikes.  I should correct myself before I get someone angry at me. You can
do this sort of late-binding stuff in Perl too, and in many other
languages.  (Java's reflection mechanism is another kind of late-binding
mechanism, for example.)
But Python makes it extraordinarly easy --- perhaps too much so.  *grin*
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Use Strict or Use Warnings was ( Lists of files)

2005-05-17 Thread Mike Hansen
> 
> 
> Subject:
> Re: [Tutor] Lists of files
> From:
> William O'Higgins <[EMAIL PROTECTED]>
> Date:
> Mon, 16 May 2005 15:50:37 -0400
> 
> 
[...]
> 
> One last thing - is there an equivalent of the "use strict" and "use
> warnings" pragmas in Python?  Thanks.

The closest thing I've found is PyChecker. It's kind of like
perl -c hardtoreadperlscript.pl

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


[Tutor] Python debugger under Tiger?

2005-05-19 Thread Mike Hansen
> Subject:
> Re: [Tutor] Python debugger under Tiger?
> From:
> Mike Hall <[EMAIL PROTECTED]>
> Date:
> Wed, 18 May 2005 15:54:18 -0700
> To:
> [EMAIL PROTECTED]
> 
> To:
> [EMAIL PROTECTED]
> CC:
> tutor@python.org
> 
> 
> I should of specified that I'm looking for an IDE with full  debugging. 
> Basically something like Xcode, but with Python support.
> 
> 
> On May 18, 2005, at 3:10 PM, [EMAIL PROTECTED] wrote:
> 
>> Quoting Mike Hall <[EMAIL PROTECTED]>:
>>
>>
>>> Does anyone know of a Python debugger that will run under OSX 10.4?
>>> The Eric debugger was looked at, but it's highly unstable under
>>> Tiger. Thanks.
>>>
>>
>> pdb should work :-)
>>
>> -- 
>> John.
>> ___
>> Tutor maillist  -  Tutor@python.org
>> http://mail.python.org/mailman/listinfo/tutor
>>

It's too bad that Activestate doesn't have a version of Komodo that runs under 
OS X. They have Windows, Linux, and Solaris, but not OS X.

I wonder if Eclipse using PyDev has visual debugging/stepping/watching that you 
are looking for?

You might want to ask on the python mac mail list
http://mail.python.org/mailman/listinfo/pythonmac-sig

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


Re: [Tutor] Filtering Spreadsheet Data

2005-05-24 Thread Mike Hansen
> Subject:
> [Tutor] Filtering Spreadsheet Data
> From:
> Luke Jordan <[EMAIL PROTECTED]>
> Date:
> Mon, 23 May 2005 15:30:33 -0500
> To:
> tutor@python.org
> 
> To:
> tutor@python.org
> 
> 
> Hi All,
> 
> I have several frighteningly cumbersome reports to review at my new
> job. I would like to write a python program to help me with my
> analysis. The goal of the program is to filter out information that
> doesn't meet certain requirements and print  relevant results back to
> a legible report that I can do detailed research and analysis on. The
> reports come to me in Excel format.
> 
> I have a solid understanding of basic programming.
> 
> Any guidance/advice/starting points would be greatly appreciated.
> 
> Thanks!
> 
> Luke
> 

Excel has some nice database-like queries itself. Take a look at Advanced 
Filter 
in Help. You can essentially query a worksheet and even send the results to a 
different worksheet. I'd imagine that once you got the query working, you could 
automate it using VBA or Python.

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


Re: [Tutor] Planning a program with algorithm?

2005-06-01 Thread Mike Hansen

> 
> 
> Subject:
> [Tutor] Planning a program with algorithm?
> From:
> ". ," <[EMAIL PROTECTED]>
> Date:
> Sun, 29 May 2005 19:21:33 +
> To:
> tutor@python.org
> 
> To:
> tutor@python.org
> 
> 
> I know how to write a prog.
> 
> But, I don't know how to plan a prog. with algorithm.
[...]
> 
> Any useful advice for algorithm would be appreciated.
> 
> Thanks.

You might want to take a look at the book Code Complete. It really covers the 
nuts and bolts of software construction.

http://www.cc2e.com/

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


[Tutor] question about "hiding" a function/method in a class

2005-06-03 Thread Mike Hansen
I haven't done much OO in Python yet. For various web apps we write, we usually 
write up a DB schema in a spreadsheet. Then we write the sql script that would 
create the tables in the database. I thought it would be neat to save the 
spreadsheet as a csv file and have python write the sql script. So I started to 
write the Python program.

-
#!/usr/bin/env python

"""
SQLGEN takes a csv file of a database schema and writes the sql script that 
will 
create the
tables and fields in the database

Mike Hansen Jun 2005

"""

class DBField(object):
 def __init__(self, fieldName):
 self.fieldName = fieldName
 self.type = ""
 self.size = 0
 self.notNull = False
 self.unique = False
 self.references = ""
 self.default = ""

 def printField(self):
 self.fieldStr = "%s %s" %(self.fieldName, self.type)
 if self.size > 0:
 self.fieldStr = "%s(%s)" %(self.fieldStr, self.size)
 if self.notNull:
 self.fieldStr = "%s NOT NULL" %self.fieldStr
 if self.unique:
 self.fieldStr = "%s UNIQUE" %self.fieldStr
 if self.default:
 self.fieldStr = "%s DEFAULT %s" %(self.fieldStr, self.default)
 # if self.references
 return self.fieldStr

 def __getattr__(self, attrname):
 if attrname == "fieldStr":
 return self.printField()
 else:
 raise AttributeError, attrname

def main():
 pass

def test():
 areas = DBField("area")
 areas.type = "VARCHAR"
 areas.size = 80
 areas.notNull = True
 areas.unique = True
 print areas.fieldStr
 stuff = DBField("stuff")
 stuff.type = "INTEGER"
 stuff.notNull = True
 print stuff.fieldStr


if __name__ == "__main__":
 # main()
 test()
---

I was wondering if I should "hide" the printField function, so I or someone 
else 
won't do x.printField() in the main program but use the x.fieldStr attribute. 
If 
so, how would I do that, def __printField(self):? How would I call it from 
__getattr__? I know I'm not really hiding it ;just mangling it. On the other 
hand, I guess it doesn't matter. What do you think?

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


Re: [Tutor] question about "hiding" a function/method in a class

2005-06-03 Thread Mike Hansen
> Subject:
> Re: [Tutor] question about "hiding" a function/method in a class
> From:
> Kent Johnson <[EMAIL PROTECTED]>
> Date:
> Fri, 03 Jun 2005 09:45:20 -0400
> 
> CC:
> tutor@python.org
> 
> 
> Mike Hansen wrote:
> 
>> class DBField(object):
>>  def __init__(self, fieldName):
>>  self.fieldName = fieldName
>>  self.type = ""
>>  self.size = 0
>>  self.notNull = False
>>  self.unique = False
>>  self.references = ""
>>  self.default = ""
>>
>>  def printField(self):
>>  self.fieldStr = "%s %s" %(self.fieldName, self.type)
>>  if self.size > 0:
>>  self.fieldStr = "%s(%s)" %(self.fieldStr, self.size)
>>  if self.notNull:
>>  self.fieldStr = "%s NOT NULL" %self.fieldStr
>>  if self.unique:
>>  self.fieldStr = "%s UNIQUE" %self.fieldStr
>>  if self.default:
>>  self.fieldStr = "%s DEFAULT %s" %(self.fieldStr, 
>> self.default)
>>  # if self.references
>>  return self.fieldStr
>>
>>  def __getattr__(self, attrname):
>>  if attrname == "fieldStr":
>>  return self.printField()
>>  else:
>>  raise AttributeError, attrname
>> ---
>>
>> I was wondering if I should "hide" the printField function, so I or 
>> someone else won't do x.printField() in the main program but use the 
>> x.fieldStr attribute. If so, how would I do that, def 
>> __printField(self):? How would I call it from __getattr__? I know I'm 
>> not really hiding it ;just mangling it. On the other hand, I guess it 
>> doesn't matter. What do you think?
> 
> 
> Python programmers tend to take the attitude "We're all adults here" 
> towards things like this. We use conventions to put warning labels where 
> appropriate, then trust the client programmer to do what is right for them.
> 
> So, to answer your direct question, yes, you could call the method 
> __printField(), which nominally hides the name from other modules, or 
> _printField(), which by convention marks the method as for internal use 
> only (a warning label). You would call it from __getattr__() as 
> __printField() or _printField(). (A quick experiment would have answered 
> this part of the question.)
> 
> However, for your particular usage of dynamically computing the value of 
> a field, there is a better way to do this - use a property.
> 
> class DBField(object):
>  def _printField(self):
>...
> 
>  # Create a read-only fieldStr attribute whose value is computed by 
> _printField()
>  fieldStr = property(_printField)
> 
>  # Remove _printField so it can't be called directly
>  del _printField
> 
> 
> A few more comments:
> - The name _printField() is a bit of a misnomer since nothing is 
> printed; _getFieldStr() might be a better name.
> - Another, simpler way to do this is to define __str__() instead of 
> _printField() and fieldStr; then clients can just call str(field) to get 
> the string representation. This will work well if you don't need any 
> other string representation.
> - Of course you could also just define getFieldStr() and forget about 
> the fieldStr attribute entirely. This is also a very simple, 
> straightforward approach.
> 
> Kent
> 

Doh, I forgot about properties! If I had read a little more in Learning Python 
on the page with __getattr__, I might have noticed properties.

I might go with the "Simple is better than complex" approach using 
getFieldStr().

I agree that printField wasn't sounding like a good name.

Thanks for the comments.

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


Re: [Tutor] question about "hiding" a function/method in a class

2005-06-03 Thread Mike Hansen

Alan G wrote:
>>I haven't done much OO in Python yet. For various web apps we write,
> 
> we usually
> 
>>write up a DB schema in a spreadsheet.
> 
> 
> Wow! How exactly do you represent a schema in a spreadsheet?
> I confess I cannot conceive of such a thing. Can you send a
> representative sample to illustrate?
> 

Maybe it's not a "schema" exactly.

|Table Name|Fields  |Type   |Size|Primary Key|Not Null|Unique|Foreign Key| ...
|areas |area_id |serial ||x  |x   |x |   |
|  |area|varchar|80  |   |x   |x |   |
|  |enabled |boolean||   |x   |  |   |

|'s represent each cell. It's just a way to organize your thoughts, and have 
something a little more readable than an SQ script for a DB schema. There's 
been 
less than 20 tables in a database for most of these applications that we write. 
It's clear enough to see the relations(there's another column references).

> 
>>create the tables in the database. I thought it would be neat to
> 
> save the
> 
>>spreadsheet as a csv file and have python write the sql script. So I
> 
> started to
> 
>>write the Python program.
> 
> 
> You do know that there are lots of ERD programs that allow you to draw
> the schema as an ERD and generate the SQL DDL directly? In fact even
> Visio
> can do that.
> 
> Alan G.
> 

Can you point me to some Open Source/Free ERD programs that work with 
Postgre?(I'll google after I send this message.) I'd certainly would like to 
look at ways to do this better. Last time I looked at Visio which was Visio 
2000, the ERD stuff cost extra and was very unstable.

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


Re: [Tutor] Controlling Where My Program Ends

2005-06-15 Thread Mike Hansen
> Subject:
> Re: [Tutor] Controlling Where My Program Ends
> From:
> Don Parris <[EMAIL PROTECTED]>
> Date:
> Tue, 14 Jun 2005 23:03:59 -0400
> To:
> tutor@python.org
> 
> To:
> tutor@python.org
> 
> 
> On Wed, 15 Jun 2005 00:59:24 -
> "DC Parris" <[EMAIL PROTECTED]> wrote:
> 
> 
>>Never mind.  I found it - sys.exit()
>>
>>Sorry to have wasted the bandwidth/time.
>>-- 
> 
> 
> This was in reference to a post about exiting from a program.  I couldn't
> figure out why my program wouldn't let me exit from within a sub-menu of the
> console interface.  Since my webmail client goofed up the "from" header, it
> never showed up, and I've cancelled it to avoid wasting everyone's time
> further. I found sys.exit() in the library reference, which allows me to do
> what I want.
> 
> Don
> 

If you use the if __name__ == '__main__': idiom, then you can just use return 
instead of sys.exit()

def main():
 lotsa interesting python code
 if somethinorother:
 # sys.exit()
 return
 more interesting python code

if __name__ == '__main__':
 main()

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


[Tutor] loading an image into a Postgre database

2005-06-21 Thread Mike Hansen
I'm having trouble loading an image into a Postgre database. The code is below 
as well as the traceback in the apache log. Is something up with my 
sqlStatement? Do I need to use something other than %s? How can I avoid that 
type error?

Thanks,

Mike


#! /usr/bin/env python

import cgi
from pyPgSQL import PgSQL
# from pyPgSQL.PgSQL import PgBytea

def main():
 form = cgi.FieldStorage()
 if form.has_key("filename"):
 item = form["filename"]
 imageName = form["imagename"]
 if item.file:
 data = item.file.read()
 data_obj = PgSQL.PgBytea(data)
 connectdb =PgSQL.connect('server:port:database:username:password')
 cur = connectdb.cursor()
 sqlStatement = """INSERT INTO images (image)
   VALUES (%s);
""" % (data_obj)
 cur.execute(sqlStatement)
 cur.close()
 connectdb.commit()
 print "Content-type: text/html\n\n"
 print "image loaded"


if __name__ == '__main__':
 main()


Traceback (most recent call last):
   File "/var/www/htdocs/mtest/imagetest.py", line 28, in ?
 main()
   File "/var/www/htdocs/mtest/imagetest.py", line 20, in main
 cur.execute(sqlStatement)
   File "/usr/lib/python2.3/site-packages/pyPgSQL/PgSQL.py", line 3038, in 
execute
 self.res = self.conn.conn.query(_qstr)
TypeError: query() argument 1 must be string without null bytes, not str
[Tue Jun 21 14:34:46 2005] [error] [client 10.95.100.11] Premature end of 
script 
headers: /var/www/htdocs/mtest/imagetest.py10.95.100.11] Premature end of script
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] loading an image into a Postgre database

2005-06-22 Thread Mike Hansen
Thanks Danny. That did the trick. I think I had thought about putting the 
variables in the execute statement, but I didn't run across any examples. I'll 
need to read the DB API 2.0 docs some more.

Mike

Danny Yoo wrote:
>>Thankfully, you don't have to change much to fix the formatting bug.  The
>>only thing you'll need to do is let the SQL cursor do the value formatting
>>for you:
>>
>>##
>>sqlStatement = """INSERT INTO images (image)
>>  VALUES (%s);
>>cur.execute(sqlStatement, (data_obj))
>>##
> 
> 
> 
> Hi Mike,
> 
> 
> Gaaa.  I was a little sloppy there, wasn't I?  Let me fix that:
> 
> ##
> sqlStatement = """INSERT INTO images (image)
>   VALUES (%s);"""
> cur.execute(sqlStatement, (data_obj,))
> ##
> 
> 
> My apologies!
> 

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


[Tutor] getting an image out of a postgre database

2005-06-23 Thread Mike Hansen
Well, I've managed to get an image into a postgre database, but now I'm having 
trouble getting it out.

#! /usr/bin/env python

from pyPgSQL import PgSQL

def main():
 connectdb = PgSQL.connect('server:port:database:username:password')
 cur = connectdb.cursor()
 sqlStatement = """SELECT image from images where image_id = 1"""
 cur.execute(sqlStatement)
 rec = cur.fetchone()
 # TODO make temp file name include image_id.
 # TODO use tempfile module
 # TODO clean up old temp files
 tempFileName = "1.jpg"
 tempFile = open(tempFileName, "w")
 tempFile.write(rec[0])
 tempFile.close()
 cur.close()

 print "Content-type: text/html\n\n"
 print 
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>

http://www.w3.org/1999/xhtml";>










"""

if __name__ == '__main__':
 main()

Traceback (most recent call last):
   File "./dispimage.py", line 39, in ?
 main()
   File "./dispimage.py", line 16, in main
 tempFile.write(rec[0])
TypeError: argument 1 must be string or read-only character buffer, not instance

So, rec[0] is an instance, but an instance of what? Since I needed to use the 
PgSQL.PgBytea method on the image before inserting it into the database, do I 
need to use a similar method to undo what PgBytea did to it, or am I 
incorrectly 
writing this binary data? I tried PgSQL.PgUnQuoteBytea(rec[0]), but that didn't 
work.

If this is more appropriate for another mail list, let me know.

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


[Tutor] generating documentation for a module

2005-07-07 Thread Mike Hansen
Is there a utility that generates documentation for your python 
modules/scripts/programs based on their doc strings that looks similar to the 
library documentation on the python web site?

What do you use to generate documentation for your python 
modules/scripts/programs?

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


Re: [Tutor] generating documentation for a module

2005-07-07 Thread Mike Hansen
> Subject:
> Re: [Tutor] generating documentation for a module
> From:
> Wolfram Kraus <[EMAIL PROTECTED]>
> Date:
> Thu, 07 Jul 2005 16:17:11 +0200
> To:
> tutor@python.org
> 
> To:
> tutor@python.org
> 
> 
> Mike Hansen wrote:
> 
>> Is there a utility that generates documentation for your python 
>> modules/scripts/programs based on their doc strings that looks similar 
>> to the library documentation on the python web site?
>>
>> What do you use to generate documentation for your python 
>> modules/scripts/programs?
>>
>> Mike
> 
> 
> Never used it, but this should do what you want:
> 
> http://docs.python.org/lib/module-pydoc.html
> 
> Batteries included ;-)
> HTH,
> Wolfram
> 

Duh... I should have noticed that. The html output is pretty good.

Thanks,

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


[Tutor] Confused "from module import Name" better than "import module"?

2005-07-11 Thread Mike Hansen
I'm confused. I was just reading the URL below..

http://jaynes.colorado.edu/PythonGuidelines.html

and this statement confused me: "Always use from module import Name, Name2, 
Name3.. syntax instead of import module or from module import *. This is more 
efficient, reduces typing in the rest of the code, and it makes it much easier 
to see name collisions and to replace implementations."

To me, import module is more explicit.
It seems to easier to read CoolModule.niceFunction() than just niceFunction(). 
You know exactly where niceFunction comes from especially when you've imported 
many modules. Don't you avoid namespace pollution too by using import module 
instead of from module import * or from module import Name, Name2, Name3...?

What is the preferred/better way to import modules?

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


Re: [Tutor] Confused "from module import Name" better than "import module"?

2005-07-11 Thread Mike Hansen
> Subject:
> Re: [Tutor] Confused "from module import Name" better than "import module"?
> From:
> Kent Johnson <[EMAIL PROTECTED]>
> Date:
> Mon, 11 Jul 2005 12:30:16 -0400
> 
> CC:
> tutor@python.org
> 
> 
> Mike Hansen wrote:
> 
>> I'm confused. I was just reading the URL below..
>>
>> http://jaynes.colorado.edu/PythonGuidelines.html
>>
>> and this statement confused me: "Always use from module import Name, 
>> Name2, Name3.. syntax instead of import module or from module import 
>> *. This is more efficient, reduces typing in the rest of the code, and 
>> it makes it much easier to see name collisions and to replace 
>> implementations."
>>
>> To me, import module is more explicit.
>> It seems to easier to read CoolModule.niceFunction() than just 
>> niceFunction(). You know exactly where niceFunction comes from 
>> especially when you've imported many modules. Don't you avoid 
>> namespace pollution too by using import module instead of from module 
>> import * or from module import Name, Name2, Name3...?
> 
> 
> from module import * is problematic and discouraged. It causes namespace 
> pollution and makes it harder to find out where a name is defined.
> 
> Other than that I think it is personal preference.
> 
> I often use from module import name because it reduces typing at the 
> point of use. It is still easy to find out where a name comes from by 
> searching for the name in the module. This adds a few names to the 
> global namespace but it is just the ones you use, nothing like what you 
> can get with from module import *.
> 
> I'm not sure what efficiency he is talking about - it might be faster to 
> look up a global name than to look up a name in a module but I would 
> want to test that. Anyway it is clearly a premature optimization and if 
> you have code where the cost of name lookup is hurting you then you will 
> want to convert the name to a local name, not a global.
> 
> I guess it could be easier to replace the implementation, for example if 
> you split a module you could change
> from module import Name1, Name1
> to
> from module1 import Name1
> from module2 import Name2
> and the rest of the client code wouldn't have to change.
> 
> my two cents
> Kent
> 

It's interesting. I still like the more explicit import Module. Even if you 
split the module, it wouldn't be hard to replace all occurrences of 
module1.sillyfunction with module2.sillyfunction. I'm sure vim and emacs can do 
this even across multiple files.

I suppose if you were only interested in one specific function from a module 
that you'd use from module import Name1.

Like you said, it's personal preference.

Thanks,

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


[Tutor] deleting files that are older than x days old

2005-07-13 Thread Mike Hansen
 From a python program, I want to delete certain files that are older than x 
days old.

To get the time that the file was last modified, it looks like I need to use 
os.path.getmtime(path). This gives you the time represented in the number of 
seconds from the epoch.

I'd like to convert this into a datetime object, but I can't seem to figure out 
how. Once it's a datetime object, I can do simple (datetime.datetime.today() - 
filedatetime).days to figure out the days old.

How do you convert a time represented in seconds from the epoch into a datetime 
object?

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


Re: [Tutor] deleting files that are older than x days old

2005-07-13 Thread Mike Hansen
> Subject:
> Re: [Tutor] deleting files that are older than x days old
> From:
> Kent Johnson <[EMAIL PROTECTED]>
> Date:
> Wed, 13 Jul 2005 13:50:47 -0400
> 
> CC:
> tutor@python.org
> 
> 
> Mike Hansen wrote:
> 
>> How do you convert a time represented in seconds from the epoch into a 
>> datetime object?
> 
> 
> Use datetime.datetime.fromtimestamp():
> 
>  >>> import os, datetime
>  >>> t=os.path.getmtime('build.xml')
>  >>> t
> 1115045692
>  >>> d=datetime.datetime.fromtimestamp(t)
>  >>> d
> datetime.datetime(2005, 5, 2, 10, 54, 52)
> 
> Kent
> 

The docs for fromtimestamp weren't clear to me. i.e. not spelling it out that 
it 
converts from seconds from the epoch(which must be the POSIX timestamp it's 
referring to).

Thanks! And thanks to the others that replied on how to do this without using 
datetime.

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\Marvell>Marvell_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


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


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


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


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


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


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] Regular Expression help

2007-06-27 Thread Mike Hansen
 

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Gardner, Dean
> Sent: Wednesday, June 27, 2007 3:59 AM
> To: tutor@python.org
> Subject: [Tutor] Regular Expression help
> 
> Hi 
> 
> I have a text file that I would like to split up so that I 
> can use it in Excel to filter a certain field. However as it 
> is a flat text file I need to do some processing on it so 
> that Excel can correctly import it.
> 
> File Example: 
> tag descVR  VM 
> (0012,0042) Clinical Trial Subject Reading ID LO 1 
> (0012,0050) Clinical Trial Time Point ID LO 1 
> (0012,0051) Clinical Trial Time Point Description ST 1 
> (0012,0060) Clinical Trial Coordinating Center Name LO 1 
> (0018,0010) Contrast/Bolus Agent LO 1 
> (0018,0012) Contrast/Bolus Agent Sequence SQ 1 
> (0018,0014) Contrast/Bolus Administration Route Sequence SQ 1 
> (0018,0015) Body Part Examined CS 1 
> 
> What I essentially want is to use python to process this file 
> to give me 
> 
> 
> (0012,0042); Clinical Trial Subject Reading ID; LO; 1 
> (0012,0050); Clinical Trial Time Point ID; LO; 1 
> (0012,0051); Clinical Trial Time Point Description; ST; 1 
> (0012,0060); Clinical Trial Coordinating Center Name; LO; 1 
> (0018,0010); Contrast/Bolus Agent; LO; 1 
> (0018,0012); Contrast/Bolus Agent Sequence; SQ ;1 
> (0018,0014); Contrast/Bolus Administration Route Sequence; SQ; 1 
> (0018,0015); Body Part Examined; CS; 1 
> 
> so that I can import to excel using a delimiter. 
> 
> This file is extremely long and all I essentially want to do 
> is to break it into it 'fields' 
> 
> Now I suspect that regular expressions are the way to go but 
> I have only basic experience of using these and I have no 
> idea what I should be doing.
> 
> Can anyone help. 
> 
> Thanks 
> 

H... You might be able to do this without the need for regular
expressions. You can split the row on spaces which will give you a list.
Then you can reconstruct the row inserting your delimiter as needed and
joining the rest with spaces again.

In [63]: row = "(0012,0042) Clinical Trial Subject Reading ID LO 1"

In [64]: row_items = row.split(' ')

In [65]: row_items
Out[65]: ['(0012,0042)', 'Clinical', 'Trial', 'Subject', 'Reading',
'ID', 'LO',
'1']

In [66]: tag = row_items.pop(0)

In [67]: tag
Out[67]: '(0012,0042)'

In [68]: vm = row_items.pop()

In [69]: vm
Out[69]: '1'

In [70]: vr = row_items.pop()

In [71]: vr
Out[71]: 'LO'

In [72]: desc = ' '.join(row_items)

In [73]: new_row = "%s; %s; %s; %s" %(tag, desc, vr, vm, )

In [74]: new_row
Out[74]: '(0012,0042); Clinical Trial Subject Reading ID; LO; 1'

Someone might think of a better way with them thar fancy lambdas and
list comprehensions thingys, but I think this will work. 

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] 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] 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] 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] 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] 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] 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] 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] How do you organize code snippets?

2005-09-20 Thread Mike Hansen
> 
> 
> Subject:
> Re: [Tutor] How do you organize code snippets?
> From:
> Poor Yorick <[EMAIL PROTECTED]>
> Date:
> Sun, 18 Sep 2005 13:28:10 -0400
> 
> CC:
> tutor@python.org
> 
> 
> List wrote:
> 
>> Is there a way of naming or organizing snippets that might help? (For 
>> example, file i/o snippets, text processing snippets, etc.)
>>
> 
> If you really want to have fun, you can use LEO, 
> http://webpages.charter.net/edreamleo/front.html to store your code 
> snippets and generate files from them.  The fun part is that you can 
> clone each node which may contain some code and move the clone to a 
> different point in the hierarchy.  When you change your code in any of 
> the clones, it gets changed in all of the clones.  At the most basic 
> level, you can use LEO as on outliner, like Treepad.  If you decide to 
> get more complicated, you can use LEO as a templating tool to generate 
> your resulting .py files from your snippets.
> 
> -- 
> Poor Yorick

I'm facing a similar problem. I was hoping to find some sort of snippets 
plug-in 
for VIM, but haven't come across anything. I found a couple of open source 
snippet database programs for Windows. One kept crashing on my machine and the 
other was kind of klunky. LEO looks promising. I'm reading through the tutorial 
now.

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


Re: [Tutor] HTTP GET Request

2005-09-27 Thread Mike Hansen
> Subject:
> Re: [Tutor] HTTP GET Request
> From:
> paul brian <[EMAIL PROTECTED]>
> Date:
> Tue, 27 Sep 2005 17:04:46 +0100
> To:
> Jerl Simpson <[EMAIL PROTECTED]>
> 
> To:
> Jerl Simpson <[EMAIL PROTECTED]>
> CC:
> tutor@python.org
> 
> 
>>Basicall, what I need is a stand alone CGI.  Instead of the program passing
>>the data off to a CGI, I want it to parse and handle the request directly.
> 
> 
> instead of which program ?
> 
> Http requests are served by a web server (ie Apache), which depending
> on the type of request passes the request to wherever.
> 
> As such any HTTP request *must* be handled first by a web server, and
> cgi scripts traditionally lived in cgi-bin directory on the server so
> a URL would look like http://www.example.com/cgi-bin/myscript.py
> 
> I think you have 3 options
> 
> 1. use the cgi module in python to create scripts like the one above.
> They will not be fast but it gives you a lowlevel access to the request
> However cgi was out of date about 8 years ago - it has some
> seriouslimitations mostly on speed/capacity.
> 

 From what others have told me, I wouldn't say that cgi is out of date. The 
couple of apps I've done perform just fine. Also, I'd recommend that every 
programmer do at least a little app using cgi to get a good understanding of 
the 
basics before jumping into alternative methods like mod_python or one of the 
million python web frameworks where things get more complex.

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


Re: [Tutor] web development

2005-09-28 Thread Mike Hansen
> Subject:
> [Tutor] web development
> From:
> Don Jennings <[EMAIL PROTECTED]>
> Date:
> Tue, 27 Sep 2005 22:13:30 -0400
> To:
> tutor@python.org
> 
> To:
> tutor@python.org
> 
> 
> Earlier this month, Kent posted that Jython and Velocity are a good way 
> to develop dynamic web sites. After a little searching, it seems that 
> there are quite a few options for web development in Python (perhaps too 
> many?). So, rather than ask for recommendations of which one to use, 
> what I would really like to know are how people decided to use any 
> particular framework.
> 
> Thanks!
> Don
> 
> P.S. As an aside, does anyone have any experience with django? (I really 
> like the name since I am fond of django reinhardt, the jazz guitarist.)
> 

I've looked at a few of the web development frameworks for Python. I'm thinking 
I'm going with CherryPy on my next project. Reading the docs, it seems to click 
with me. Mapping URLs directly to python functions seems pretty simple and 
flexible. The POST and GET parameters just show up as arguments to your 
functions. You can even decide weather or not you want to expose the function 
or 
not. You can use any HTML templating toolkit you want with it. I'm still 
deciding on the templating toolkit to use.

Here's my take on some of the other frameworks

Zope
It seems too big for my purposes. If your web apps are going to be high volume, 
Zope is probably the answer.

Quixote
It seems a little weird and complex to me. I may look at it again someday.

Django
Uses the MVC philosophy, and appears to build a directory structure to 
facilitate that philosophy. I'm not sure I want to go there yet in that you 
need 
to work its way and not your way. I've heard that it's very similar to Ruby on 
Rails.

Nevow
If I recall, it extracted woven from the Twisted Framework so that it could 
work 
on it's own. Kind of reminded me of Quixote.

There are many others that I passed on for various reasons.

For me, if it looked like a steep learning curve, then I thought I'd be better 
off with something else. I also wanted something that's been around for a 
while(stable) with a good size community to help if I got stuck. It had to be 
fairly easy to install and configure. I didn't want to spend all my time 
getting 
it up and running on a development server. Then having problems when it's time 
to install on a production server or other servers at different locations.

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


Re: [Tutor] Book recommendations?

2005-09-30 Thread Mike Hansen
> Subject:
> Re: [Tutor] Book recommendations?
> From:
> Kent Johnson <[EMAIL PROTECTED]>
> Date:
> Fri, 30 Sep 2005 05:57:51 -0400
> 
> CC:
> Python Tutor list 
> 
> 
> Andrew P wrote:
> 
>> Does anybody have any recommendations for other books on programming 
>> practices in general?  Any fun or philosophical reads on software 
>> architecture/design?
> 
> 
> Some of the highlights from my bookshelf:
> 
> Hunt & Thomas, The Pragmatic Programmer
> http://pragmaticprogrammer.com/ppbook/index.shtml
> 
> (and the other books from  the Pragmatic Bookshelf)
> http://pragmaticprogrammer.com/bookshelf/index.html
> 
> Martin, Agile Software Development
> http://www.objectmentor.com/resources/bookstore/books/AgileSoftwareDevelopmentPPP
>  
> 
> 
> Fowler, Refactoring: Improving the Design of Existing Code
> http://martinfowler.com/books.html#refactoring
> 
> Beck, Extreme Programming Explained
> http://www.amazon.com/exec/obidos/ASIN/0201616416/ref%3Dnosim/armaties/102-7636110-6481700
>  
> 
> 
> Kent

All of the above are great picks. I'd also recommend Joel On Software. It's a 
collection of his articles from his web site.

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


Re: [Tutor] __slots__

2005-10-13 Thread Mike Hansen
> Subject:
> Re: [Tutor] __slots__
> From:
> Kent Johnson <[EMAIL PROTECTED]>
> Date:
> Wed, 12 Oct 2005 18:22:46 -0400
> 
> CC:
> Python Tutor Mailing List 
> 
> 
> Liam Clarke wrote:
> 
>> Well, all I can say is, don't use them unless you need them, they're a
>> lot of hassle.
> 
> 
> I think the conventional advice is something like, if you don't 
> understand why using slots is a bad idea, you have no business using 
> them :-)
> 

Can you tell us the pros and cons of using slots? Although I haven't used them 
yet, they seem like a way to lock down a class so you don't accidentally add 
new 
attributes to that class. (emp.name vs emp.nmae) Might be handy when working on 
a team too. Although something like Pychecker would most likely catch those 
accidents.  I dunno.

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


[Tutor] RSH?

2005-11-03 Thread Mike Hansen
Anyone know of a way to have Python run a command on a remote machine? In my 
particular case, I want to run a python program on Windows and run a command on 
VMS. Would the telnetlib module do it, or is there something better?

Mike

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


Re: [Tutor] RSH?

2005-11-04 Thread Mike Hansen
If we had Python on VMS(which I'm working on), I'd definitely look into Pyro.

Thanks,

Mike

> Subject:
> Re: [Tutor] RSH?
> From:
> Pujo Aji <[EMAIL PROTECTED]>
> Date:
> Thu, 3 Nov 2005 18:44:11 +0100
> To:
> Mike Hansen <[EMAIL PROTECTED]>
> 
> To:
> Mike Hansen <[EMAIL PROTECTED]>
> CC:
> tutor@python.org
> 
> 
> try pyro.
>  
> Cheers,
> pujo
> 
>  
> On 11/3/05, *Mike Hansen* <[EMAIL PROTECTED] 
> <mailto:[EMAIL PROTECTED]>> wrote:
> 
> Anyone know of a way to have Python run a command on a remote
> machine? In my
> particular case, I want to run a python program on Windows and run a
> command on
> VMS. Would the telnetlib module do it, or is there something better?
> 
> Mike
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] RSH?

2005-11-04 Thread Mike Hansen
That's exactly what I'm looking for!

Thanks,

Mike

> Subject:
> Re: [Tutor] RSH?
> From:
> Bernard Lebel <[EMAIL PROTECTED]>
> Date:
> Thu, 3 Nov 2005 14:16:40 -0500
> To:
> tutor@python.org
> 
> To:
> tutor@python.org
> 
> 
> I use plink
> http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
> 
> Basically you send a system command (os.system) to the plink
> executable. The actuall command will take this form:
> 
> os.system( 'plink -pw %s -ssh [EMAIL PROTECTED] %s' % ( password, user, 
> hostIP, command ) )
> 
> 
> Now, if you want to run a python script on the remote machine, you
> will have to send two commands (afaik). The first one to cd to the
> python script file, the second to send the python execution command:
> 
> os.system( 'plink -pw %s -ssh [EMAIL PROTECTED] %s' % ( password, user, 
> hostIP,
> 'cd /blah/blah/' ) )
> os.system( 'plink -pw %s -ssh [EMAIL PROTECTED] %s' % ( password, user, 
> hostIP,
> 'python scriptname.py' ) )
> 
> 
[...]
>>On 11/3/05, Mike Hansen <[EMAIL PROTECTED]> wrote:
>>
>>>Anyone know of a way to have Python run a command on a remote machine? In
>>
>>my
>>
>>>particular case, I want to run a python program on Windows and run a
>>
>>command on
>>
>>>VMS. Would the telnetlib module do it, or is there something better?
>>>
>>>Mike
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] python-based system programming and admin?

2006-01-23 Thread Mike Hansen
> 
> 
> Subject:
> [Tutor] python-based system programming and admin?
> From:
> Neal McBurnett <[EMAIL PROTECTED]>
> Date:
> Fri, 20 Jan 2006 21:01:03 -0700 (MST)
> To:
> tutor 
> 
> To:
> tutor 
> 
> 
> I'm an experienced linux guy, with lots of python interest and some
> python experience.
> 
> I'm helping a colleague develop software to run on our linux server.
> He has python skill, but doesn't know the shell or linux very well at
> all.
> 
> I'd like to give him a secure, safe, flexible development environment
> on the serve, (which does audio streaming and other fun things).
> 
> At the moment, he has an account and can connect from his mac via ssh,
> and copy files back and forth (ftp-like stuff - I forget which ssh
> client).  But he doesn't want to log in to a bash shell and learn a
> whole new way to do things.  But he does want to run programs.
> 
> Editing python scripts spawned by cron is one of the goals.
> But developing them by waiting for cron to fire and send the output
> via email is pretty painful
> 
> The server currently doesn't need to run a web server, and I'm
> reluctant to introduce new services that have much security risk
> associated with them, but something like that seems like a
> possibility.
> 
> One idea that just popped in my brain is to give him a python login
> shell on linux - any advice on how to do that?
> 
> Other possibilities, I guess:
> 
>  - An https-based web server with and mod-python, somehow configured
>so that his jobs run as him.
> 
>  - a pure-python server (via twisted?) running as him
> 
>  - moinmoin or the like
> 
>  - zope or plone (not sounding very simple any more, but I've done a
>bit of this )
> 
> What would be the safest, simplest solution that was adequate for
> providing a reasonable development environment?
> 
> Any ideas I haven't thought of yet?
> 
> Cheers,
> 
> Neal McBurnett http://bcn.boulder.co.us/~neal/

Sorry to pop in late on this discussion. I get the digest and it's sent to my 
work, so I got all weekend's digests to catch up on.

Rather than having you bend over backwards setting up a weird environment, I 
think your colleague should learn some basic unix commands. Since he's running 
a 
Mac(I'm assuming OS X), the basic commands will help him with Darwin OS which 
is 
underneath the Mac GUI. Darwin is a flavor of BSD, and BSD is a flavor of unix. 
There's not a lot to learn. Basic file management(copy, delete, move, rename), 
setting the permissions(chmod, chown), navigating the directory structure(cd, 
ls), and finally running a python program.

Some editors have FTP built into them, so he could write the code on his mac 
and 
have the editor FTP the file to his account on the server. He could then telnet 
to the server and run the script.

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


[Tutor] templates

2006-01-27 Thread Mike Hansen
For some of the web programming I've done in Python, I've used htmltmpl. I had 
some experience with it in Perl, and found a Python version.

http://htmltmpl.sourceforge.net/

I like that there's nearly a complete separation between the presentation and 
the code. This is great when one person is designing the pages and another is 
writing the code to drive those pages. However, that's usually not the case for 
me. I'm usually doing both, and I'm thinking there's got to be something 
possibly better out there. I'm curious about other templating systems. I 
wouldn't be opposed to a little bit of code in the template. I just don't want 
to go the other extreme of something like PHP or ASP. i.e. all code in the 
template.

What web templating systems do you use and why?

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


Re: [Tutor] IDE - Editors - Python

2006-02-06 Thread Mike Hansen
> Subject:
> [Tutor] IDE - Editors - Python
> From:
> Paul Kraus <[EMAIL PROTECTED]>
> Date:
> Mon, 6 Feb 2006 09:46:42 -0500
> To:
> tutor@python.org
> 
> To:
> tutor@python.org
> 
> 
> Which editors does everyone use and why. Please keep the discussion to IDE's 
> rather then any editors. I am well versed on Emacs and VI so anything beyond 
> them would be appreciative. Why you like the editor and how it helps reduce 
> your development time would be productive and helpfull.
> 
> TIA,

I use VIM, and sometimes Komodo. The personal edition of Komodo is ~$30. I like 
the debugging and the output window in Komodo. I suppose I could get VIM to do 
this, but I haven't looked into it enough.

Many swear by Eric3, WingIDE, SPE, or Dr. Python. I want to take a another look 
at Eclipse and PyDev. At the time I looked at PyDev, it was still in it's 
infancy.

Personally, I'd stick to VIM or Emacs instead of messing around with IDEs.

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


[Tutor] Object Oriented Programmin

2006-03-28 Thread Mike Hansen
> Subject:
> [Tutor] Object Oriented Programmin
> From:
> "Kaushal Shriyan" <[EMAIL PROTECTED]>
> Date:
> Tue, 28 Mar 2006 12:57:58 +0530
> To:
> tutor@python.org
> 
> To:
> tutor@python.org
> 
> 
> Hi ALL
> 
> I have gone through the object oriented programming in Python, I am
> not able to understand OOP concept in python,
> 
> is there a methodical way to understand it and simplfy things
> 
> Thanks in Advance
> 
> Regards
> 
> Kaushal
> 

If you are reading Learning Python(2nd Ed), the OOP section was a little 
thick to me. I read the book, The Object Oriented Thought Process. Then 
I went back and read the chapters on OOP in Learning Python, and it made 
a lot more sense.

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


[Tutor] OT: Tutor Digest and Outlook 2003

2006-03-30 Thread Mike Hansen
The company I work for is moving to Outlook 2003 and Exchange server. I used
to use Thunderbird. Anyway, when digest messages show up in Outlook 2003,
all the posts are attachments. Does anyone know how to get them to display
in-line?

Thanks,

Mike

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


Re: [Tutor] Protected methods/variables

2006-04-04 Thread Mike Hansen

> > - you can use __slots__ to restrict arbirtrary creation of 
> (dynamic) 
> > instrance attributes
> 
> You can do this, but it is generally considered a misuse of 
> __slots__ and potentially problematic.
> 

I'll bite. What is the proper/intended use of __slots__? Does it have
something to do with memory?

Mike

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


Re: [Tutor] Database Connectivity

2006-04-11 Thread Mike Hansen
  
> Kaushal Shriyan wrote:
> > Hi ALL
> > 
> > How do i connect my python program to MySQL DB or Oracle DB 
> or can you 
> > please specify the URL which gives a detailed explanation on this.
> 
> Basic connectivity is through modules that implement the 
> DB-API standard. Read the spec and find implementations here:
> http://www.python.org/doc/topics/database/
> 
> There are several popular packages that layer on top of this 
> basic functionality such as SQLObject and SQLAlchemy.
> 
> Kent

The DB-API spec would go a long way if it had a couple of examples. Poking
around the database topics, I came across an article in Linux Journal that
seems to help http://www.linuxjournal.com/article/2605

Also, the MySQLdb module has some examples
http://sourceforge.net/docman/display_doc.php?docid=32071&group_id=22307#som
e-examples

The module for Postgre called psycopg has a nice PDF about the DB-API
http://initd.org/pub/software/psycopg/dbapi20programming.pdf

Mike


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


[Tutor] Tutor FAQ?

2006-04-20 Thread Mike Hansen
I'd like to send a big Thank You to Danny, Alan, Kent and others(whos names
escape me) for being such an asset to the Python community by relentlessly
answering questions on the tutor list.(Do these guys sleep? They must work
in shifts.) This list is one of the most civilized and responsive lists I
have ever read. When many pop onto the list and ask what may seem like some
of the most obvious questions, you guys calmly answer and nudge them in the
right direction without ever losing your patience. It's a great list.

Anyway, I've been reading the list for a couple of years now, and I wonder
if a Tutor FAQ would be helpful. I don't believe one exists. Should there be
something on the Python wiki that would list the most common questions to
the tutor list along with their answers? It would be a FAQ about the tutor
list as well as common questions to the tutor list.

FAQ about the Tutor List would include
- The policy on answering homework assignment
- Why the reply-to is set that way.
- Post code and exact error message.
(A lot of this might be in that initial message you get from mailman when
joining the list, but it might be a good idea to put it on the wiki)

FAQ for common questions to the list would include
- ord() and chr()
- Common GUI programming questions
- String module is deprecated, use string methods
- ???

I'm sure you can come up with more of the common questions. Does this sound
like a reasonable idea?

Mike

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


Re: [Tutor] Tutor FAQ?

2006-04-20 Thread Mike Hansen
 
> Thanks! I do sleep but I have my email tied in to my clock 
> radio so whenever an email arrives on the tutor list I am 
> awakened to answer it ;)

Hmmm.. I wouldn't be surprised if there's an X10 module that does that. =)

[...]

> Maybe this could be integrated with the main Python FAQ in a 
> beginner's section? Fredrik Lundh is experimenting with a FAQ 
> wiki here:
> http://pyfaq.infogami.com/

I'll take a look at this.

> Sounds good to me. Are you volunteering?

Yes, I'll get the ball rolling. I'll most likely do something on the site
above. I'll post to this list when I have something worth looking at.

Mike

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


Re: [Tutor] Invoking Excel Macro

2006-04-21 Thread Mike Hansen



In the macro, you might try Application.DisplayAlerts = 
False  and reset it to True after you save.
I think it might be trying to display a dialog box before 
it saves. 
 
Mike

  
  
  From: [EMAIL PROTECTED] 
  [mailto:[EMAIL PROTECTED] On Behalf Of arunSent: 
  Friday, April 21, 2006 1:44 AMTo: 
  tutor@python.orgSubject: Re: [Tutor] Invoking Excel 
  Macro
  I'm sorry , there is something realy wrong with 'Run-time error 
  1004':. I have fixed it now but still it throws an error while trying to save 
  the workbook.
  On 4/21/06, arun 
  <[EMAIL PROTECTED]> 
  wrote: 
  

Hi, 
I tried invoking a macro from my python script and  It is 
 throwing  an error message that reads 'Run-time error 
1004':
 
"This operation requires the merged cells to be identically 
sized"
 
My script looks like this 
 
from win32com.client import Dispatchxl = 
Dispatch('Excel.Application')xl.Workbooks.Add('E:\Templates\sample.xls')
xl.Run('Import_file')  # name of the macro
 
Also while (running the macro)opening the workbook it  names 
it as  "sample1.xls' ,and so 
It says there is no such file sample.xls
 
"
Filename =  Myexcel.xls
Workbooks("sample.xls").SaveAs Filename
"
 
Can somebody help me with this issue : (
 
 
Thanx

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


Re: [Tutor] Tutor FAQ?

2006-04-21 Thread Mike Hansen
 

> > Maybe this could be integrated with the main Python FAQ in a 
> > beginner's section? Fredrik Lundh is experimenting with a 
> FAQ wiki here:
> > http://pyfaq.infogami.com/
> 
> Actually I put something about this on PyFAQ just the other day. 
> Fredrik was quite keen on the idea, but I've been busy the 
> last couple of days and haven't got around to doing anything about it.
> 
> Mike, if you're volunteering that would be perfect.  If 
> anyone here has ideas for questions that get asked a lot 
> (like "How do I write a program that prints a word 
> backwards") then just posting them in this thread would be a 
> good start.
> 
> I assume Kent, Alan and Danny don't mind their answers being 
> reused in the wiki, but it would probably best to get 
> explicit permission from them (and other people) to re-use 
> text from their answers.
> 
> Ed
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>

Yep, I'm volunteering. Forgive my ignorance, but I couldn't seem to figure
out how to edit/add pages to http://pyfaq.infogami.com/. The tutorial wiki
has the edit, but the pyfaq page doesn't. I am logged in using my reddit
login. 

Below is what little I slapped together last night. I copied the content
from the Python tutor mailman page for the first question. 

=
Python Tutor FAQ
-
What is Python Tutor?

This list is for folks who want to ask questions regarding how to learn
computer programming with the Python language.

Python (http://www.python.org) is a programming language which many feel is
a good first language, because it makes it easy to express the fundamental
concepts of programming such as data structures and algorithms with a syntax
which many find easy to read and write.

Folks interested in learning about programming with Python are encouraged to
join, as are folks interested in helping others learn. While the list is
called tutor, anyone, whether novice or expert, can answer questions.

If individuals wish to start off-line conversations about a particular
concept and become one-on-one tutor/tutee, that's fine. If either party
wants to summarize what they learned for others to benefit, that's fine too.

There is a searchable interface to archived Tutor messages on Activestate's
web site at
http://aspn.activestate.com/ASPN/Mail/Browse/Threaded/python-Tutor.

To see the collection of prior postings to the list, visit the Tutor
Archives at http://mail.python.org/pipermail/tutor/

Using Tutor
To post a message to all the list members, send email to tutor@python.org

-
I need help; I'm getting an error in my program. What should I do?

If you are getting an error in your Python program that you don't
understand, post the error message and any relevant code. Post the exact
error message. Don't paraphrase the error message. The error message has
details that can help resolve the issue that caused the error.

-
What is the policy on homework?

Although those on the Python tutor mail list are eager to help, they don't
want to hand you the answers to your homework. They want to help you find
the answers. If you are having difficulty with your homework, send a message
to the list about the problem and what you have tried. The tutors will try
to nudge you in the right direction.

-
Why do my replies go to the person who sent the message and not to the list?

This is by design. 
See http://www.unicom.com/pw/reply-to-harmful.html

Also see this explanation
http://mail.python.org/pipermail/tutor/2005-July/039889.html

=

Unless anyone has any more, I think the above covers the FAQs about the
tutor list.

Here's some of the FAQs that I came across scanning the list:

ord and chr
parsing html beautifulsoup
editors/ides
getters and setters
regex match and find
maxtrix operations
how do I make an exe out of a python script 
books 
what should I program?
unicode/encoding 

Mike

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


Re: [Tutor] Tutor FAQ?

2006-04-21 Thread Mike Hansen
> -
> > I need help; I'm getting an error in my program. What should I do?
> > 
> > If you are getting an error in your Python program that you don't 
> > understand, post the error message and any relevant code. Post the 
> > exact error message. Don't paraphrase the error message. The error 
> > message has details that can help resolve the issue that 
> caused the error.
> 
> Instead of "Post the exact error message." I would say "Copy 
> and paste the entire error message into your email, including 
> the traceback."
> 
> Kent
> 

That's good. It didn't occur to me since I considered the error message as
including the traceback.

-
I need help; I'm getting an error in my program. What should I do?

If you are getting an error in your Python program that you don't
understand, post the error message and any relevant code. Copy and paste the
entire error message into your email, including the traceback. Don't
paraphrase the error message. The error message has details that can help
resolve the issue that caused the error.

Mike

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


Re: [Tutor] Tutor FAQ?

2006-04-24 Thread Mike Hansen

On Apr 22, 2006, at 3:15 AM, Fredrik Lundh wrote:

> Ed wrote:
>
>> I don't think the FAQ is open to public editing yet.  I'm not sure
>> when it will be, but Fredrik might be able to give a timescale.
>
> There are a few known conversion issues to deal with (the FAQ uses
> a lot more "looks like markdown syntax" than the tutorial, which con-
> fused the converter).  I've made some progress, but it'll probably take
> another week before everything's sorted out.
>
> When Ed brought up the tutor/tutorial FAQ idea, my first thought
> was that Ed and other volunteers could add pages in a separate
> "tutor-" namespace (to avoid collisions with material from the
> existing FAQ), and ended up writing a couple of paragraphs on
> how to manually convert titles to page names.  When I found that
> I had written "this isn't quite as hard as it may look", I realized
> that it would be better if I just wrote a script that did this.
>
> So, while I'm working on that script, I suggest that you start adding
> stuff the "tutor suggestion" page that I just set up:
>
> http://pyfaq.infogami.com/suggest-tutor
>
> One entry per comment; use "## title" to mark the first line as the
> FAQ entry.  I've added Mike's examples.
>
> cheers /F
>

Hi,

I'll post the questions and answers to the list first. If I don't get 
any corrections or clarifications in a day or so after posting, I'll 
add it to the tutor suggestion page. Ed mentioned that you are using 
restructured text. Should I put the entry in restructured text? I spent 
some time last night reading up on restructured text and docutils.

Thanks,

Mike

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


Re: [Tutor] Invoking Excel Macro

2006-04-24 Thread Mike Hansen
I guess I'm confused. You mentioned that it still throws and error 
while trying to save the workbook. hmmm Do you get this error when 
trying to close Excel in the macro? Many times, Excel pops up a dialog 
box when closing it if there's still a workbook open even if it has 
been saved. That's where the Application.DisplayAlerts comes in. So I 
may have been a little off on the part of saving. It might be the 
closing of Excel. Other than that, I'm stumped.

Mike

On Apr 24, 2006, at 7:32 AM, arun wrote:

> Hi Mike,
>    It doesn't  display any dialog box rather it gives a temporary name 
> to the file.
> Ex
>  newsheet.xls as newsheet1.xls
> So i'm not able to save it. Is  there an alternative to invoke the  
> macro and save the file from my script itself .(saving it through 
> macro wud be a better option : )  )
>  
> Thanx  and Regards,
> arun
>
>  
> On 4/21/06, Mike Hansen <[EMAIL PROTECTED]> wrote: In the macro, 
> you might try Application.DisplayAlerts = False  and reset it to True 
> after you save.
>> I think it might be trying to display a dialog box before it saves.
>>  
>> Mike
>>
>>> From: [EMAIL PROTECTED] [mailto: [EMAIL PROTECTED] On 
>>> Behalf Of arun
>>> Sent: Friday, April 21, 2006 1:44 AM
>>> To: tutor@python.org
>>> Subject: Re: [Tutor] Invoking Excel Macro
>>>
>>>  I'm sorry , there is something realy wrong with 'Run-time error 
>>> 1004':. I have fixed it now but still it throws an error while 
>>> trying to save the workbook.
>>
>> On 4/21/06, arun <[EMAIL PROTECTED]> wrote: Hi,
>>> I tried invoking a macro from my python script and  It is  throwing  
>>> an error message that reads 'Run-time error 1004':
>>>  
>>> "This operation requires the merged cells to be identically sized"
>>>  
>>> My script looks like this
>>>  
>>> from win32com.client import Dispatch
>>> xl = Dispatch('Excel.Application')
>>> xl.Workbooks.Add('E:\Templates\sample.xls')
>>> xl.Run('Import_file')  # name of the macro
>>>  
>>> Also while (running the macro)opening the workbook it  names it as 
>>>  "sample1.xls' ,and so
>>> It says there is no such file sample.xls
>>>  
>>> "
>>> Filename =  Myexcel.xls
>>> Workbooks("sample.xls").SaveAs Filename
>>> "
>>>  
>>> Can somebody help me with this issue : (
>>>  
>>>  
>>> Thanx
>>> arun 
>>>  
>>>  
>>>
>>>
>>>  
>>
>>
>> -- 
>> arun
>
>
>
> -- 
> arun___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

___
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




This is a test


$title

#for $item in $items
category: $item.category
name: $item.name 
price: $item.price
#end for



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


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


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=content&task=view&id=198&pop=1&page
=0&hide_js=1

Is an article on cgi programming with Python.

Mike

___
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] 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] 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] 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] (no subject)

2006-06-26 Thread Mike Hansen
 

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of shane davin
> Sent: Monday, June 26, 2006 9:15 AM
> To: Tutor@python.org
> Subject: [Tutor] (no subject)
> 
> Stop the emails???
> im getting more than i need
> regards
> 
> _
> The new MSN Search Toolbar now includes Desktop search! 
> http://join.msn.com/toolbar/overview
> 
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>

Go to
http://mail.python.org/mailman/listinfo/tutor

See the bottom of the page to unsubscribe.

Mike 
___
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] 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-program has 
  some suggestions.
___
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] 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] Community documentation framework?

2006-08-08 Thread Mike Hansen
 

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Bob Nienhuis
Sent: Sunday, August 06, 2006 3:56 PM
To: tutor@python.org
Subject: [Tutor] Community documentation framework?



Have you had the experience of finding a nifty bit of code on
the
web, trying it out, and then discovering that technique
only worked in version X.YY, or requires module Z that
is no longer available?

Well perhaps we can address this situation.

I would like to see an online system that facilitates
the collaborative production, cataloging and updating of 
community documentation. See an article, "Rethinking Community 
Documentation" by Andy Oram 

.

Features I would like to see:
A Wikipedia-like capacity for community
update-ability/modifiability
of documentation submissions.

Database for cataloging available packages, modules, FAQs,
How-Tos
tutorials, cookbook code fragments etc. Should have capacity
for 
developers to add and others to add to their contributions. 

Oram suggests a rating system for submissions so users can
assess
the quality of submissions, and point to parts that need
modification
or clarification..

Might use TurboGears, Django AJAX or other web framework?

I think main Python documentation is great, but there is a lot
of stuff out there that isn't documented so well, or needs
updating. This project is intended to adress that need.

What would you like to see?


You might take a look at

http://pyfaq.infogami.com/

Mike

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


Re: [Tutor] Which Book

2006-08-17 Thread Mike Hansen
> 
> Hi All,
> 
> I have very little programming experience, I have decided to learn
> Python..there are tons of material and refernces on the web-pages, can
> you guys please suggest what is the best way to start or which ONE
> book which I should follow to start.
> 
> thanks..
> 
> Nagendra

http://pyfaq.infogami.com/tutor-what-are-some-good-books-on-python 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] tkinter events:

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: 
> 
> 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] tkinter events:

2006-08-28 Thread Mike Hansen
Yep...across multiple lines. 

Here's a tinyurl of it

http://tinyurl.com/n93au

Mike

> -Original Message-
> From: Zsiros Levente [mailto:[EMAIL PROTECTED] 
> Sent: Friday, August 25, 2006 11:37 PM
> To: Mike Hansen
> Cc: python tutor
> Subject: Re: [Tutor] tkinter events: 
> 
> The link is broken.
> 
> Mike Hansen wrote:
> 
> > 
> >
> >  
> >
> >>-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: 
> >>
> >>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-priv
> ate-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] 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] 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


  1   2   >