[Tutor] critique my script!

2006-08-02 Thread Christopher Spears
I created a function that takes a pattern and a base path and then uses os.walk and glob to traverse directories starting from the base path and place files that match the glob pattern in a dictionary. #!/usr/bin/python import os, os.path, glob def glob_files(pattern, base = '.'): path_l

[Tutor] smtp error from cgi script

2006-08-02 Thread Rob
Hi, can someone help me interpret the error output below?   I can't tell whether this is a coding error, or a configuration error, in which case, it would be up to my host provider.   For privacy reasons, I have changed the actual email addresses to [EMAIL PROTECTED] and [EMAIL PROTECTED]. 

Re: [Tutor] Notes on namespaces, scopes, etc

2006-08-02 Thread Alan Gauld
Looks good Dave. Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] os.walk()

2006-08-02 Thread Christopher Spears
I'm creating a function that traverses a directory tree and prints out paths to files: #!/usr/bin/python import os, os.path, glob def traverse(base = '.'): for root,dirs,files in os.walk(base): for name in files: path = os.path.join(root, name)

Re: [Tutor] Notes on namespaces, scopes, etc

2006-08-02 Thread Dave Kuhlman
On Fri, Jul 28, 2006 at 02:36:08PM -0700, Danny Yoo wrote: > > If there were really such a thing as nested scopes/namespaces, we would > > have a function that would give us access to them, similar to the way > > that locals() and globals() give us access to the local and global > > namespace. >

Re: [Tutor] latin-1 to unicode in python

2006-08-02 Thread Kent Johnson
anil maran wrote: > 'ascii' codec can't encode character u'\x96' in position 213: ordinal > not in range(128) > > now i m getting this error Please show your code and the traceback and reply on list, not to me personally. Kent > > */Kent Johnson <[EMAIL PROTECTED]>/* wrote: > > anil maran w

Re: [Tutor] latin-1 to unicode in python

2006-08-02 Thread Kent Johnson
anil maran wrote: > how to determine > wat encoding it is in > for eg i m might not know it is in latin-1 This is hard. It is better by far to know what encoding your data is in. There is no way to determine for sure what encoding it is by looking at the data. The best you can do is rule out some

Re: [Tutor] latin-1 to unicode in python

2006-08-02 Thread Kent Johnson
anil maran wrote: > In [1]: s='\x92' > > In [3]: s.decode('latin-1').encode('utf-8') > > > Out[3]: '\xc2\x92' > > is this some kind of python shell, pls clarify Yes, it's IPython. http://ipython.scipy.org/ Kent > > */Kent Johnson <[EMAIL PROTECTED]>/* wrote: > > anil maran wrote: > > Unico

Re: [Tutor] When am I ever going to use this?

2006-08-02 Thread Alan Gauld
> Lately, I have been learning about abstract data types > (linked lists, stacks, queues, trees, etc.). While I > do enjoy the challenge of creating these objects, I am > not sure what they are used for. To be honest, with the possible exception of trees, not very often! Most of these data type

Re: [Tutor] latin-1 to unicode in python

2006-08-02 Thread Kent Johnson
anil maran wrote: > Unicode? > im getting this error: > invalid byte sequence for encoding "UTF8": 0x92 > > since the db is not handling latin-1 and is set to use UTF8 how do i > handle this If you have a latin-1 string and you want utf-8, convert it to Unicode and then to utf-8 using decode() a

[Tutor] latin-1 to unicode in python

2006-08-02 Thread anil maran
Unicode?im getting this error:invalid byte sequence for encoding "UTF8": 0x92 since the db is not handling latin-1 and is set to use UTF8 how do i handle thisthanks a lot Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls. Great rates starting at 1¢/min.__

[Tutor] Update BLOB with odbc

2006-08-02 Thread Ron Phillips
It must be easier than I am making it. sql = "UPDATE sa2.outfalls SET photo_content = %s WHERE pppoint_id ='"+record[0].strip()+"';" newsql = sql%pstuff print newsql[:150] cursor.execute(newsql) __ the print newsql[:

Re: [Tutor] When am I ever going to use this?

2006-08-02 Thread Michael P. Reilly
On 8/1/06, Christopher Spears <[EMAIL PROTECTED]> wrote: I've been working through a tutorial:http://www.ibiblio.org/obp/thinkCSpy/index.htm.Lately, I have been learning about abstract data types(linked lists, stacks, queues, trees, etc.).  While I do enjoy the challenge of creating these objects,