Re: Launcher for 64 bits doesnt work
Thsnk you for your response, the pip installer doesnt work, only for the launcher for 32 bits. But my mainproblem is that I cant connect pygresql. I can download the package but after it says that it cant find the module Enviado desde mi iPhone > El 4 apr 2016, a las 22:39, Zachary Ware > escribió: > > Hi Gustaf, > > On Mon, Apr 4, 2016 at 9:38 PM, Gustaf Nilsson > wrote: >> Hi! >> >> The only 3.5.1 versio that works for me is the 32 bits version, will it be >> a problem to use the 32 bits version for 64 bits computer? > > From your mention of a 'launcher' I'm assuming you're on Windows. > It's perfectly fine to use 32-bit Python on 64-bit Windows. However, > how exactly does the launcher for the 64-bit version not work? What > happens? What did you expect to happen that didn't? What error > message do you get? It's entirely possible that your version of > Windows is in fact 32-bit, even though the computer itself has a > 64-bit processor. > > Hope this helps, > -- > Zach -- https://mail.python.org/mailman/listinfo/python-list
Method needed for skipping lines
Hi all, Just for fun, I'm working on a script to count the number of lines in source files. Some lines are auto-generated (by the IDE) and shouldn't be counted. The auto-generated part of files start with "Begin VB.Form" and end with "End" (first thing on the line). The "End" keyword may appear inside the auto-generated part, but not at the beginning of the line. I imagine having a flag variable to tell whether you're inside the auto-generated part, but I wasn't able to figure out exactly how. Here's the function, without the ability to skip auto-generated code: # Count the lines of source code in the file def count_lines(f): file = open(f, 'r') rows = 0 for line in file: rows = rows + 1 return rows How would you modify this to exclude lines between "Begin VB.Form" and "End" as described above? Gustaf -- http://mail.python.org/mailman/listinfo/python-list
Re: Method needed for skipping lines
Yu-Xi Lim wrote: > David Mertz's Text Processing in Python might give you some more > efficient (and interesting) ways of approaching the problem. > > http://gnosis.cx/TPiP/ Thank you for the link. Looks like a great resource. Gustaf -- http://mail.python.org/mailman/listinfo/python-list
Re: Method needed for skipping lines
Bruno Desthuilliers wrote: > Here's a straightforward solution: Thank you. I learned several things from that. :-) Gustaf -- http://mail.python.org/mailman/listinfo/python-list
Launcher for 64 bits doesnt work
Hi! The only 3.5.1 versio that works for me is the 32 bits version, will it be a problem to use the 32 bits version for 64 bits computer? -- https://mail.python.org/mailman/listinfo/python-list
xml.sax in Python 2.3.4
After a long break with Python I'm trying to get started again. I need to do some SAX processing, but it seems things have changed, and I can't find any docs describing how to make things work *today*. The SAX example in the XML HOWTO [1] doesn't work anymore. I get this error: D:\Test>python comics.py Traceback (most recent call last): File "comics.py", line 5, in ? class FindIssue(saxutils.DefaultHandler): AttributeError: 'module' object has no attribute 'DefaultHandler' I hope someone here can explain what has changed and how a working example looks today. My needs are very simple, so don't want to install any packages on top of the standard distribution. 1. http://pyxml.sourceforge.net/topics/howto/node12.html -- Gustaf -- http://mail.python.org/mailman/listinfo/python-list
"encoding specified in XML declaration is incorrect"
I'm using xml.sax.parseString to read an XML file. The XML file contains
a few words in Russian, and is encoded in UTF-8 using C#. In the example
below, MyParser() is my SAX ContentHandler class. My first try was:
f = open('words.xml', 'r')
s = f.read()
xml.sax.parseString(s, MyParser())
This produced the following error:
Traceback (most recent call last):
File "sax5.py", line 87, in ?
xml.sax.parseString(s, MyParser())
File "D:\Python\lib\xml\sax\__init__.py", line 49, in parseString
parser.parse(inpsrc)
File "D:\Python\lib\xml\sax\expatreader.py", line 107, in parse
xmlreader.IncrementalParser.parse(self, source)
File "D:\Python\lib\xml\sax\xmlreader.py", line 125, in parse
self.close()
File "D:\Python\lib\xml\sax\expatreader.py", line 218, in close
self._cont_handler.endDocument()
File "sax5.py", line 81, in endDocument
f.write(header + self.all + footer)
UnicodeEncodeError: 'ascii' codec can't encode characters in position
745-751: ordinal not in range(128)
The XML declaration should be enough to tell the encoding. Anyway, I
read some previous posts, and found that the unicode() function may help:
f = open('words.xml', 'r')
s = f.read()
u = unicode(s, "utf-8")
xml.sax.parseString(u, MyParser())
But I just got another error:
Traceback (most recent call last):
File "sax5.py", line 87, in ?
xml.sax.parseString(u, MyParser())
File "D:\Python\lib\xml\sax\__init__.py", line 49, in parseString
parser.parse(inpsrc)
File "D:\Python\lib\xml\sax\expatreader.py", line 107, in parse
xmlreader.IncrementalParser.parse(self, source)
File "D:\Python\lib\xml\sax\xmlreader.py", line 123, in parse
self.feed(buffer)
File "D:\Python\lib\xml\sax\expatreader.py", line 211, in feed
self._err_handler.fatalError(exc)
File "D:\Python\lib\xml\sax\handler.py", line 38, in fatalError
raise exception
xml.sax._exceptions.SAXParseException: :1:30: encoding
specified in XML declaration is incorrect
I see nothing wrong with my XML declaration:
And the file is indeed in UTF-8 (or I wouldn't be able to open it in IE
and FF). I tried removing the BOM, but it didn't help. What more can be
wrong?
Gustaf
--
http://mail.python.org/mailman/listinfo/python-list
