Re: Strange IO Error when extracting zips to a network location

2006-05-17 Thread Serge Orlov
Hari Sekhon wrote: > Hi, >I've written a script to run on windows to extract all zips under a > given directory path to another directory path as such: > > python extractzips.py files under this dir> > > The purpose of this script is to retrieve backup files which are > individually zipped un

Re: Python script windows servcie

2006-05-17 Thread Serge Orlov
Mivabe wrote: > Mivabe formulated the question : > > > > Google helped me discovering that it has something to do something with > > 'CTRL_LOGOFF_EVENT'. I know what it means but i don't know how to solve it. > > Is that something i have to configure in the script? > > > > I'n totally new to Python

Re: WTF? Printing unicode strings

2006-05-18 Thread Serge Orlov
Ron Garret wrote: > In article <[EMAIL PROTECTED]>, > Robert Kern <[EMAIL PROTECTED]> wrote: > > > Ron Garret wrote: > > > > > I forgot to mention: > > > > > sys.getdefaultencoding() > > > > > > 'utf-8' > > > > A) You shouldn't be able to do that. > > What can I say? I can. > > > B) Don't do

Re: WTF? Printing unicode strings

2006-05-18 Thread Serge Orlov
Ron Garret wrote: > In article <[EMAIL PROTECTED]>, > "Serge Orlov" <[EMAIL PROTECTED]> wrote: > > > Ron Garret wrote: > > > In article <[EMAIL PROTECTED]>, > > > Robert Kern <[EMAIL PROTECTED]> wrote: &g

Re: WTF? Printing unicode strings

2006-05-18 Thread Serge Orlov
Ron Garret wrote: > > > I'm using an OS X terminal to ssh to a Linux machine. > > > > In theory it should work out of the box. OS X terminal should set > > enviromental variable LANG=en_US.utf-8, then ssh should transfer this > > variable to Linux and python will know that your terminal is utf-8. >

Re: newb: comapring two strings

2006-05-18 Thread Serge Orlov
manstey wrote: > Hi, > > Is there a clever way to see if two strings of the same length vary by > only one character, and what the character is in both strings. > > E.g. str1=yaqtil str2=yaqtel > > they differ at str1[4] and the difference is ('i','e') > > But if there was str1=yiqtol and str2=yaqt

Re: import woe

2006-05-18 Thread Serge Orlov
[EMAIL PROTECTED] wrote: > hello, > > i have a problem. i would like to import python files above and below > my current directory. > > i'm working on /home/foo/bar/jar.py > > i would like to import /home/foo/car.py and >/home/foo/bar/far.py > > how can i do this? $ cat >>

Re: WTF? Printing unicode strings

2006-05-19 Thread Serge Orlov
Ron Garret wrote: > In article <[EMAIL PROTECTED]>, > "Serge Orlov" <[EMAIL PROTECTED]> wrote: > > > Ron Garret wrote: > > > > > I'm using an OS X terminal to ssh to a Linux machine. > > > > > > > > In theory it s

Re: WTF? Printing unicode strings

2006-05-19 Thread Serge Orlov
Serge Orlov wrote: > Ron Garret wrote: > > In article <[EMAIL PROTECTED]>, > > "Serge Orlov" <[EMAIL PROTECTED]> wrote: > > > > > Ron Garret wrote: > > > > > > I'm using an OS X terminal to ssh to a Linux machine. > &

Re: Encode exception for chinese text

2006-05-19 Thread Serge Orlov
Vinayakc wrote: > Hi all, > > I am new to python. > > I have written one small application which reads data from xml file and > tries to encode data using apprpriate charset. > I am facing problem while encoding one chinese paragraph with charset > "gb2312". > > code is: > > encoded_str = str_data.

Re: Encode exception for chinese text

2006-05-19 Thread Serge Orlov
Vinayakc wrote: > Yes serge, I have removed the first character but it is still giving > encoding exception. Then I guess this character was used as a poor man indentation tool at least in the beginning of your text. It's up to you to decide what to do with that character, you have several choices

Re: the tostring and XML methods in ElementTree

2006-05-19 Thread Serge Orlov
George Sakkis wrote: > > > I'm currently using > > > (a variation of) the workaround below instead of ET.tostring and it > > > works fine for me: > > > > > > def tostring(element, encoding=None): > > > text = element.text > > > if text: > > > if not isinstance(text, basestring): > >

Re: NEWB: reverse traversal of xml file

2006-05-22 Thread Serge Orlov
manstey wrote: > Hi, > > I have an xml file of about 140Mb like this: > > > > ... > 1 > > > ... > 2 > > > ... > 1 > > > > I want to traverse it from bottom to top and add another field to each > record 1 > which would give the highest value of wordpartWT

Re: No math module??

2006-05-22 Thread Serge Orlov
WIdgeteye wrote: > I have been trying to run a python program and I get the following > error: > Traceback (most recent call last): > Fil e "", line 39, in ? That doesn't look like a python program, File "" means it's an embedded script. When a script is embedded it is responsibility of the calle

Re: NEWB: reverse traversal of xml file

2006-05-23 Thread Serge Orlov
manstey wrote: > But will this work if I don't know parts in advance. Yes it will work as long as the highest part number in the whole file is not very high. The algorithm needs only store N records in memory, where N is the highest part number in the whole file. > I only know parts > by reading

Re: Python Version Testing Tool?

2006-05-24 Thread Serge Orlov
Michael Yanowitz wrote: > Hello: > >Is there a version testing tool available for Python > such that I can check to see if my code will still run in > versions 2.2, 2.3, 2.4.3, and 1.1 (for example) (or whatever) > without having to install all these different versions on my > computer? Such t

Re: deploying big python applications

2006-05-24 Thread Serge Orlov
AndyL wrote: > Hi, > > let me describe how I do that today. There is standard python taken from > python.org installed in a c:\python23 with at least dozen different > additional python packages (e.g. SOAPpy, Twisted, wx, many smaller ones > etc) included. Also python23.dll moved from c:\windows

Re: Customizing character set conversions with an error handler

2006-03-12 Thread Serge Orlov
Jukka Aho wrote: > When converting Unicode strings to legacy character encodings, it is > possible to register a custom error handler that will catch and process > all code points that do not have a direct equivalent in the target > encoding (as described in PEP 293). > > The thing to note here is

Re: recycling internationalized garbage

2006-03-14 Thread Serge Orlov
[EMAIL PROTECTED] wrote: > Unless someone has any other ideas I'm > giving up now. Frederick also suggested http://chardet.feedparser.org/ that is port of Mozilla's character detection algorithm to pure python. It works pretty good for web pages, since I haven't seen garbled russian text for year

Re: accessing a USB HID

2006-03-16 Thread Serge Orlov
[EMAIL PROTECTED] wrote: > I've been teaching myself Python as part of my senior design project at > university. > > The obstacle our group currently faces is communicating with a > microcontroller (ACS USB Servo II) that appears in Windows as a USD > HID. Unfortunately, the vendor's sample code is

Re: Use of Python with GDAL. How to speed up ?

2006-03-17 Thread Serge Orlov
Julien Fiore wrote: > Hi, > I wrote a function to compute openness (a digital elevation model > attribute). The function opens the gdal-compatible input raster and > reads the values in a square window around each cell. The results are > stored in a "1 line buffer". At the end of the line, the buff

Re: Python vs. Java gzip performance

2006-03-17 Thread Serge Orlov
Bill wrote: > Is there something that can be improved in the Python version? Seems like GzipFile.readlines is not optimized, file.readline works better: C:\py>python -c "file('tmp.txt', 'w').writelines('%d This is a test\n' % n for n in range(1))" C:\py>python -m timeit "open('tmp.txt').read

Re: System Information

2006-03-19 Thread Serge Orlov
[EMAIL PROTECTED] wrote: > in the online-documentation for this and had no luck. I imagine it is > quite easy and may even be as simple as a boolean variable...? In general it's not so simple, since a computer can have many power sources. > All I want to be able to tell is whether or not my compu

Re: whats your favourite object relational mapper?

2006-03-19 Thread Serge Orlov
Flavio wrote: > With so many object relational mappers out there, I wonder which one is > the preferred tool among the Pythonists... is there a favourite? > > Sqlobject, PyDO, SQLAlchemy, dejavu, etc... Google results: Sqlobject ORM: about 17,100 PyDO ORM: 469 SQLAlchemy ORM: 571 dejavu ORM: 659

Re: whats your favourite object relational mapper?

2006-03-19 Thread Serge Orlov
Jean-Paul Calderone wrote: > On 19 Mar 2006 17:52:19 -0800, Serge Orlov <[EMAIL PROTECTED]> wrote: > >Flavio wrote: > >> With so many object relational mappers out there, I wonder which one is > >> the preferred tool among the Pythonists... is there a fav

Re: Use of Python with GDAL. How to speed up ?

2006-03-22 Thread Serge Orlov
Julien Fiore wrote: > Thanks for the psyco information, Serge. > > > 2) Rewrite the code to be vectorized (don't use psyco) Right now your > > code *doesn't* get any speed benefit from numpy > > I do not understand this point. How to rewrite the code ? vectorized code means one operation work on m

Re: python linking

2006-03-22 Thread Serge Orlov
Nancy wrote: > When i link with python2.4.a i get this error. > > ld: Dwarf Error: Invalid or unhandled FORM value: 14. > > I am NOT using the gcc compiler but the linux icc compiler. Google > hits blame it on gcc compiler binutils being out of date. i dont think > thats the problem here. > thank

Re: encoding problems (é and è)

2006-03-24 Thread Serge Orlov
Martin v. Löwis wrote: > John Machin wrote: > >> and, for things like u'\u0565\u0582' (ARMENIAN SMALL LIGATURE ECH > >> YIWN), it does not even work. > > > > Sorry, I don't understand. > > 0565 is stand-alone ECH > > 0582 is stand-alone YIWN > > 0587 is the ligature. > > What doesn't work? At first

Re: Use of Python with GDAL. How to speed up ?

2006-03-24 Thread Serge Orlov
Julien Fiore wrote: > Thank you Serge for this generous reply, > > Vectorized code seems a great choice to compute the distance. If I > understand well, vectorized code can only work when you don't need to > access the values of the array, but only need to know the indices. You can access array el

Re: encoding problems (é and è)

2006-03-24 Thread Serge Orlov
Jean-Paul Calderone wrote: > On Fri, 24 Mar 2006 09:33:19 +1100, John Machin <[EMAIL PROTECTED]> wrote: > >On 24/03/2006 8:36 AM, Peter Otten wrote: > >> John Machin wrote: > >> > >>>You can replace ALL of this upshifting and accent removal in one blow by > >>>using the string translate() method wi

Re: Python multithreading problem

2006-03-26 Thread Serge Orlov
abhinav wrote: > //A CRAWLER IMPLEMENTATION > please run this prog. on the shell and under the control of debugger > when this prog. is run normally the prog. does not terminate .It > doesn't come out of the cond. if c<5: so this prog. continues > infinitely How do you know? Have you waited *infin

Re: What's the best way to learn perl for a python programmer?

2006-03-26 Thread Serge Orlov
vj wrote: > I've been given a project which requires writing scripts that need to > be run on over 3000 servers. Only about 15% of them have python > installed on them. While all/most of them will have perl. I used to work for a company with hundreds of development workstations and build/test serv

Re: FTP not Returning (Python on Series 60 Nokia)

2006-03-29 Thread Serge Orlov
[EMAIL PROTECTED] wrote: > I'm using the ftp library (layer on top of sockets) to transfer files > from a series 60 to an ftp site. everything works fine, the whole > file gets uploaded but the command never returns! so > i call: > > ftp.storbinary('STOR ' + filename,F,1024) # store the image >

Re: FTP not Returning (Python on Series 60 Nokia)

2006-03-29 Thread Serge Orlov
[EMAIL PROTECTED] wrote: > Thanks, but that didn't help either. Since storbinary is being called > from the main script, I can't see where else it could be getting hung > up. Are there any other debugging techniques I could explore? > > I'm sending a 24k image and it is viewable on the destinatio

Re: FTP not Returning (Python on Series 60 Nokia)

2006-03-29 Thread Serge Orlov
[EMAIL PROTECTED] wrote: > Right. You know I took your suggestion for more print statements and > found the offending line. > > [SNIP] > print "close start" > conn.close() > print "close end" > #return self.voidresp() > print "end of everything" > > self.voi

Re: Try Python!

2006-03-29 Thread Serge Orlov
Michael Tobis wrote: > We had some discussion of this in the edu-sig meeting at PyCon. > > I alleged that I had read that there is no such thing as a Python > sandbox. Others claimed that one could simply preprocess and disallow > "dangerous" constructs. My allegation was based on an argument from

Re: How can i design a band-pass filter with scipy?

2006-04-03 Thread Serge Orlov
LabWINC wrote: > Hi all, > i would like to design a high pass filter with scipy.signal module. > ... I think you'd better ask scipy people at . Your question requires a lot of field specific knowledge. -- http://mail.python.org/mailman/listinfo/python-list

Re: Can't detect EOF from stdin on windows console

2006-04-03 Thread Serge Orlov
Dmitry Anikin wrote: > I want to read stdin in chunks of fixed size until EOF > I want to be able (also) to supply data interactively in console > window and then to hit Ctrl+Z when finished [snip fighting with windows] > Read at most size bytes from the file (less if the read hits EOF before >

Re: binascii.a2b_binary

2006-04-03 Thread Serge Orlov
Ed Swarthout wrote: > Why is there no binascii.a2b_binary(bitstr) which returns the binary data > represented by the bit string? Like: > > >>> binascii.a2b_binary('0011001100110101') > '35' > > perl has pack("B*", "0011001100110101"); > > What is the python way to do this? to post a question on c

Re: urllib.urlencode wrongly encoding ± character

2006-04-05 Thread Serge Orlov
[EMAIL PROTECTED] wrote: > Hi, I'm trying to make a gui for a web service. Site using ± > character in value of some fields. But I can't encode this character > properly. > > > >>> data = {'key':'±'} > >>> urllib.urlencode(data) > 'key=%C2%B1' > > but it should be only %B1 not %C2%B1. It should b

Re: Convertion of Unicode to ASCII NIGHTMARE

2006-04-05 Thread Serge Orlov
Roger Binns wrote: > "Fredrik Lundh" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > Roger Binns wrote: > > > >> SQLite only accepts Unicode so a Unicode string has to be supplied. > > > > fact or FUD? let's see: > > Note I said SQLite. For APIs that take/give strings, you can eit

Re: Convertion of Unicode to ASCII NIGHTMARE

2006-04-06 Thread Serge Orlov
Roger Binns wrote: > "Serge Orlov" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > I have an impression that handling/production of byte order marks is > > pretty clear: they are produced/consumed only by two codecs: utf-16 and > > utf-8-sig. W

Re: urllib.urlencode wrongly encoding ± character

2006-04-06 Thread Serge Orlov
[EMAIL PROTECTED] wrote: > you are right. but when I capture traffic in firefox via > livehttpheaders extension, it shows me that ± is encoded to %B1. It depends on whether user entered url into address bar or clicked on submit button on a page. In the first case there were no standard how to deal

Re: pre-PEP: The create statement

2006-04-06 Thread Serge Orlov
bruno at modulix wrote: > Steven Bethard wrote: > > The PEP below should be mostly self explanatory. I'll try to keep the > > most updated versions available at: [snip] > > Seems mostly clean. +1. > That's what Trojans said when they saw a wooden horse at the gates of Troy ;) Serge. -- http

Re: Quickie: converting r"\x2019" to int

2006-04-07 Thread Serge Orlov
Robin Haswell wrote: > Hey guys. This should just be a quickie: I can't figure out how to convert > r"\x2019" to an int - could someone give me a hand please? >>> int(r'\x2019'.decode('string_escape')) 19 -- http://mail.python.org/mailman/listinfo/python-list

Re: calculating system clock resolution

2006-04-07 Thread Serge Orlov
[EMAIL PROTECTED] wrote: > Hello all > > I have the problem of how to calculate the resolution of the system > clock. > Its now two days of head sratching and still there is nothing more than > these few lines on my huge white sheet of paper stiring at me. Lame I > know. > > import time > > t1 = ti

Re: How to call functions in Advapi32.dll using ctypes

2006-04-07 Thread Serge Orlov
Podi wrote: > I have ctypes version 0.9.6 and Python 2.4.2 running on Windows XP > Professional. > > When I tried to use some functions in the Advapi32.dll, some functions > are available and some are not. Is this a bug or feature by design? Most likely feature by design. What you see in documenta

Re: a unicode question?

2006-04-10 Thread Serge Orlov
[EMAIL PROTECTED] wrote: > Mr. John Machin > > This question come form the flow codes. I use the PyXml to build a DOM > tree. > > from xml.dom.ext.reader import HtmlLib > doc = > HtmlLib.FromHtmlUrl('http://stock.business.sohu.com/q/nbcg.php?code=600028') > title_elem = doc.documentElement.getElem

Re: Convertion of Unicode to ASCII NIGHTMARE

2006-04-10 Thread Serge Orlov
ChaosKCW wrote: > Roger Binns wrote: > > > > > No. APSW converts it *to* Unicode. SQLite only accepts Unicode > > so a Unicode string has to be supplied. If you supply a non-Unicode > > string then conversion has to happen. APSW asks Python to > > supply the string in Unicode. If Python can't

Help on exceptions (was: Convertion of Unicode to ASCII NIGHTMARE)

2006-04-10 Thread Serge Orlov
ChaosKCW wrote: > Ok I get it now. Sorry for the slowness. I have to say as a lover of > python for its simplicity and clarity, the charatcer set thing has been > harder than I would have liked to figure out. I think there is a room for improvement here. In my opinion the message is too confusing

Re: list.clear() missing?!?

2006-04-11 Thread Serge Orlov
Martin v. Löwis wrote: > Felipe Almeida Lessa wrote: > > I love benchmarks, so as I was testing the options, I saw something very > > strange: > > > > $ python2.4 -mtimeit 'x = range(10); ' > > 100 loops, best of 3: 6.7 msec per loop > > $ python2.4 -mtimeit 'x = range(10); del x[:]' > > 10

Re: list.clear() missing?!?

2006-04-12 Thread Serge Orlov
Martin v. Löwis wrote: > Felipe Almeida Lessa wrote: > > I love benchmarks, so as I was testing the options, I saw something very > > strange: > > > > $ python2.4 -mtimeit 'x = range(10); ' > > 100 loops, best of 3: 6.7 msec per loop > > $ python2.4 -mtimeit 'x = range(10); del x[:]' > > 1

Re: list.clear() missing?!?

2006-04-12 Thread Serge Orlov
Felipe Almeida Lessa wrote: > Em Qua, 2006-04-12 às 11:36 +1000, Steven D'Aprano escreveu: > > On Tue, 11 Apr 2006 19:15:18 +0200, Martin v. Löwis wrote: > > > > > Felipe Almeida Lessa wrote: > > >> I love benchmarks, so as I was testing the options, I saw something very > > >> strange: > > >> > >

Re: A question about the urllib2 ?

2006-04-12 Thread Serge Orlov
Bo Yang wrote: > Hi , > Recently I use python's urllib2 write a small script to login our > university gateway . > Usually , I must login into the gateway in order to surf the web . So , > every time I > start my computer , it is my first thing to do that open a browser to > login the gateway ! >

Re: Should I learn Python instead?

2006-04-14 Thread Serge Orlov
fyleow wrote: > Hi guys, > > I'm a student/hobbyist programmer interested in creating a web project. > It's nothing too complicated, I would like to get data from an RSS > feed and store that into a database. I want my website to get the > information from the database and display parts of it dep

Re: py2exe problem

2006-04-15 Thread Serge Orlov
bwaha wrote: > First time trying to create an executable with py2exe. I have a small > program which makes use of python23 (2.3.5?), wxpython ('2.6.2.1'), > matplotlib ('0.83.2'), win32com (latest?), Numeric ('23.7') on Windows XP & > Win2000. The program runs without problem but as an exe it does

Re: Announce: Construct's wiki!

2006-04-15 Thread Serge Orlov
[EMAIL PROTECTED] wrote: > tomer> so now we have one place where people can share inventory > tomer> constructs, questions-and-answers, patches, documentation and > tomer> more. enjoy. > > I've never seen Construct before, but when you say "parser" I think of > parsing programming language

Re: My python can not get addr info

2006-04-15 Thread Serge Orlov
一首诗 wrote: > socket.gaierror: (10104, 'getaddrinfo failed') You're using a buggy firewall, write to your firewall vendor about this bug. IDLE shell is making a connection over loopback network interface in other words making a connection from your computer to your computer, this type of connection

Re: py2exe problem

2006-04-16 Thread Serge Orlov
bwaha wrote: > Thanks for the suggestion, but I definitely have only one version installed. > In fact I uninstalled it and installed an earlier version (2.5.5.1) to see > if it was specifically wxPython related. No change. Then why don't you try to print what is passed to SetValue in the exe, just

Re: attaching an excel file using MIME in smtp

2006-04-17 Thread Serge Orlov
Kun wrote: > does anyone know how to attach an excel file to send out using smtplib > and MIME? There is an example in the python documentation how to send entire content of a directory: http://docs.python.org/lib/node597.html -- http://mail.python.org/mailman/listinfo/python-list

<    1   2   3