Re: [Tutor] File IO
How do you know? Where are you looking for the file? Are you sure its not a Path issue? no no the file shows up in the same directory as the .py file and i no it works cause i read the text file OK, In that case can you show us what puzzleanswers looks like? On 8/29/06, Kent Johnson [EMAIL PROTECTED] wrote: I would print filename print puzzleanswers to make sure you know what should happen. Also, if the code is not too long can you post it too? Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] DOM using python
Hi all, I'm using python 2.3; I want to learn dom implementation in python right from the very basics do i need to install pyxml or anything else? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] About cholesky funtion
李 建强 wrote: Hi, In my procedure, I use the cholesky(a) function in the scipy.linalg.decomp model. I may be wrong, but I don't think we have any SciPy experts on this list. You'll probably do better on the SciPy users mailing list: http://www.scipy.org/Mailing_Lists Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] DOM using python
devayani barve wrote: Hi all, I'm using python 2.3; I want to learn dom implementation in python right from the very basics do i need to install pyxml or anything else? The standard Python install includes a simple DOM implementation in the xml.dom packages. PyXML adds more capabilities. If you are just starting and don't specifically require DOM, you might want to consider something else. Many people (including me) prefer to use a more Pythonic XML processing package. ElementTree is very popular and is included in the standard library as of Python 2.5 but there are many others as well. http://effbot.org/zone/element.htm http://docs.python.org/dev/whatsnew/modules.html#SECTION000142 Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] SAX and Python
Hi,I have written a small code in python for reading xml using SAX.I am importing xml.sax using the following:from xml.sax import saxlib, saxextsOn executing the code I get the following error:ImportError: cannot import name saxlibBoth python-xml and pyxml are installed on my machine along with python 2.4.What am I missing here?ThanksAkanksha All-new Yahoo! Mail - Fire up a more powerful email and get things done faster.___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] SAX and Python
On Wed, Aug 30, 2006 at 05:25:59AM -0700, Akanksha Govil wrote: Hi, I have written a small code in python for reading xml using SAX. I am importing xml.sax using the following: from xml.sax import saxlib, saxexts On executing the code I get the following error: ImportError: cannot import name saxlib Both python-xml and pyxml are installed on my machine along with python 2.4. I believe that there have been a few changes to the organization of the SAX modules and the interfaces of the classes themselves. Attached is a simple SAX example that should help get you started, if you haven't already groped your way through it. Also, you will want to read the following and the pages it links to: http://docs.python.org/lib/module-xml.sax.html http://docs.python.org/lib/module-xml.sax.xmlreader.html http://docs.python.org/lib/module-xml.sax.handler.html Etc. Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman import sys, string import xml.sax.handler as handler import xml.sax class MySaxDocumentHandler(handler.ContentHandler): def __init__(self, outfile):# [2] self.outfile = outfile self.level = 0 def startDocument(self): print Document Start def endDocument(self): print Document End def startElement(self, name, attrs): self.level += 1 self.printLevel() self.outfile.write('Element: %s\n' % name) self.level += 2 for attrName in attrs.keys(): self.printLevel() self.outfile.write('Attribute -- Name: %s Value: %s\n' % \ (attrName, attrs.get(attrName))) self.level -= 2 def endElement(self, name): self.level -= 1 def characters(self, chrs): if chrs.strip() != '': self.level += 2 self.printLevel() self.outfile.write('Content: %s\n' % chrs) self.level -= 2 def printLevel(self): for idx in range(self.level): self.outfile.write(' ') # # Create a handler and a parser, then parse the file. # def test(infilename): handler = MySaxDocumentHandler(sys.stdout) parser = xml.sax.make_parser() parser.setContentHandler(handler) parser.parse(infilename) # # A simpler way to do the same thing as test(). # def test_simple(infilename): handler = MySaxDocumentHandler(sys.stdout) xml.sax.parse(infilename, handler) def main(): args = sys.argv[1:] if len(args) != 1: print 'usage: test_sax.py infile.xml' sys.exit(1) test_simple(args[0]) if __name__ == '__main__': main() ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] omnicomplete vim python
On Tue, 29 Aug 2006, Alan Gauld wrote: But does anyone actually use this feature? I have, in Visual Basic. Its advantage to me wasn't so much that it saved me from typing, but saved me from typing the the incorrect thing, ii.e., if I's been using a variable name fluid_boiling_pt I won't, later in the program, type fluid_boiling_point. I realize that, if I was coding in nice small modules, like I should, I wouldn't have this problem, because the whole code unit would fit on the screen; but this was for a particular course where the fact that I knew enough about programming to have opinions like this was best kept hidden! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] File IO
the code is way to long but i can post the output of puzzleanswers Answer: 6 1 4 2 9 3 8 5 7 8 5 9 1 6 7 2 3 4 2 3 7 8 5 4 9 1 6 7 8 6 9 1 2 5 4 3 4 2 1 3 7 5 6 9 8 3 9 5 4 8 6 1 7 2 9 4 3 5 2 8 7 6 1 5 6 8 7 4 1 3 2 9 1 7 2 6 3 9 4 8 5 for those of you who dont know its a sudoku puzzle if you guys want i can attach the .py file.On 8/30/06, Alan Gauld [EMAIL PROTECTED] wrote: How do you know? Where are you looking for the file? Are you sure its not a Path issue? no no the file shows up in the same directory as the .py file and i no it works cause i read the text fileOK, In that case can you show us what puzzleanswers looks like? On 8/29/06, Kent Johnson [EMAIL PROTECTED] wrote: I would print filename print puzzleanswers to make sure you know what should happen.Also, if the code is not too long can you post it too?Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Can you tell me whats wrong with this code?
On 31/08/06, Amadeo Bellotti [EMAIL PROTECTED] wrote: first of all i have random.randint imported as rand like this: from random import randint as rand it is giving me an error at the line space = rand(1,82) the error its giving me is Traceback (most recent call last): File sudoku.py, line 1050, in ? space = rand(1,82) TypeError: 'int' object is not callable It's telling you that rand is an int. Since it didn't start off like that, I suspect you have assigned to rand somewhere. Have a look through your code; are there any lines starting with: rand = ? Also, in my opinion, it's a bad idea to rename standard library functions like that. If another python programmer looked at your code, they would probably be familiar with randint and understand what it does, but they won't know exactly what rand does without looking through the rest of your code. -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Can you tell me whats wrong with this code?
Thank you sooo much thats exactly what went wrong thank you so muchOn 8/30/06, John Fouhy [EMAIL PROTECTED] wrote: On 31/08/06, Amadeo Bellotti [EMAIL PROTECTED] wrote: first of all i have random.randint imported as rand like this: from random import randint as rand it is giving me an error at the line space = rand(1,82) the error its giving me is Traceback (most recent call last): File sudoku.py, line 1050, in ? space = rand(1,82) TypeError: 'int' object is not callable It's telling you that rand is an int.Since it didn't start offlike that, I suspect you have assigned to rand somewhere.Have a look through your code; are there any lines starting with: rand =?Also, in my opinion, it's a bad idea to rename standard libraryfunctions like that.If another python programmer looked at yourcode, they would probably be familiar with randint and understand what it does, but they won't know exactly what rand does without lookingthrough the rest of your code.--John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor