Re: Creating a temporary file in Python

2007-10-31 Thread looping
On Oct 31, 2:16 pm, Sion Arrowsmith <[EMAIL PROTECTED]> wrote: > " [ ... ] Whether the name can be used to open the file a second time, > while the named temporary file is still open, varies across platforms > (it can be so used on Unix; it cannot on Windows NT or later)." I didn't notice this lim

Re: Creating a temporary file in Python

2007-10-31 Thread looping
On Oct 31, 2:16 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > I'm not an expert, but I think you need to close the file first - you under > windows here, which can be picky about such stuff AFAIK. Or maybe there is > some other mode-specifier. > > Diez Actually closing the file delete it wi

Creating a temporary file in Python

2007-10-31 Thread looping
Hi, I want to create a temporary file, read it in an external command and finally delete it (in Windows XP). I try to use tempfile module but it doesn't work, the file couldn't be open by my other process (error like: SP2-0310: unable to open file "c: \docume~1\looping\locals

Re: Regular Expression question

2007-10-25 Thread looping
On Oct 25, 9:25 am, Peter Otten <[EMAIL PROTECTED]> wrote: > > You want a "negative lookahead assertion" then: > Now I feel dumb... I've seen the (?!...) dozen times in the doc but never figure out that it is what I'm looking for. So this one is the winner: s = re.search(r'create\s+or\s+replace\s

Re: Regular Expression question

2007-10-25 Thread looping
On Oct 25, 8:49 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > > needle = re.compile(r'create\s+or\s+replace\s+package(\s+body)?\s+', > re.IGNORECASE) What I want here is a RE that return ONLY the line without the "body" keyword. Your RE return both. I know I could u

Regular Expression question

2007-10-24 Thread looping
Hi, It's not really a Python question but I'm sure someone could help me. When I use RE, I always have trouble with this kind of search: Ex. I've a text file: """ create or replace package XXX ... create or replace package body XXX ... """ now I want to search the position (line) of this two st

Re: Twisted (or for loops ?) madness

2007-10-15 Thread looping
On Oct 15, 1:51 pm, Michele Simionato <[EMAIL PROTECTED]> wrote: > On Oct 15, 1:01 pm, looping <[EMAIL PROTECTED]> wrote: > > > So if I understand what Michele wrote (thanks too), when a function is > > defined (with def), no scope is saved and every variable value

Re: Twisted (or for loops ?) madness

2007-10-15 Thread looping
On Oct 15, 12:33 pm, Michele Simionato <[EMAIL PROTECTED]> wrote: > is a design decision, in the sense that Python always do late binding. > If you > you will get funclist[0]() == funclist[1]() == funclist[2]() == 3 (you > get the latest > binding of "i"). As you see, it has nothing to do with lam

Re: Twisted (or for loops ?) madness

2007-10-15 Thread looping
On Oct 15, 9:46 am, looping <[EMAIL PROTECTED]> wrote: > l = [ct1, ct2, ct3] > for c in l: > d.addCallback(lambda result: c.compile()) > > reactor.callLater(20, reactor.stop) > reactor.run() > > Output: > > Compile : *OBJECT 1* > <__main__.CompilerThre

Twisted (or for loops ?) madness

2007-10-15 Thread looping
Hi, Probably not the best group to post my question but I'm sure there is some people here that use Twisted. First here is the beginning of my source code: from twisted.internet import reactor, defer, threads import time class CompilerThread(object): def __init__(self, task, delay): s

operator overloading

2007-04-04 Thread looping
Hi, for the fun I try operator overloading experiences and I didn't exactly understand how it works. Here is my try: >>> class myint(int): def __pow__(self, value): return self.__add__(value) >>> a = myint(3) >>> a ** 3 6 OK, it works. Now I try different way to achieve t

cx_Oracle and unicode data

2007-03-15 Thread looping
Hi, I need to get data from an Oracle DB that contains unicode data (chinese text). But the chinese data that I receive is wrong (only ¿). After a look at the Oracle documentation I've found an environment variable called NLS_LANG that you could set to define what charset the DB client use and it

Re: pytz2007c error

2007-03-06 Thread looping
On Mar 6, 9:51 am, "looping" <[EMAIL PROTECTED]> wrote: > Hi, > Why this error ? > > >>> from pytz import timezone > >>> eastern = timezone('US/Eastern') > > Traceback (most recent call last): > File "", line 1, in &g

pytz2007c error

2007-03-06 Thread looping
Hi, Why this error ? >>> from pytz import timezone >>> eastern = timezone('US/Eastern') Traceback (most recent call last): File "", line 1, in File "C:\Python25\lib\site-packages\pytz-2007c-py2.5.egg\pytz \__init__.py", line 93, in timezone File "C:\Python25\lib\site-packages\pytz-2007c-py2

Return type of operator on inherited class

2007-03-05 Thread looping
Hi, my question is on this example: class MyStr(str): def hello(self): print 'Hello !' s1 = MyStr('My string') s2 = MyStr('My second string') s1.hello() s2.hello() s = s1 + s2 s.hello() >>> Hello ! Hello ! Traceback (most recent call last): File "", line 204, in run_nodebug Fi

Using ctypes with Windows API to get FileVersion of a file

2006-11-14 Thread looping
Hi, I need to get the FileVersion of some files on Windows. The best way look like to use function GetFileVersionInfo from the Windows API. I first try with pywin32 and it work well, but with ctypes now included in Python 2.5, use it look like a good idea. So I write the code below that work fine,

Re: Big speed boost in os.walk in Python 2.5

2006-10-13 Thread looping
Fredrik Lundh wrote: > looping wrote: > > > > > Very nice, but somewhat strange... > > Is Python 2.4.3 os.walk buggy ??? > > > Why are you asking if something's buggy when you've already figured out > what's been improved? > You're r

Big speed boost in os.walk in Python 2.5

2006-10-13 Thread looping
Hi, I noticed a big speed improvement in some of my script that use os.walk and I write a small script to check it: import os for path, dirs, files in os.walk('D:\\FILES\\'): pass Results on Windows XP after some run to fill the disk cache (with ~59000 files and ~3500 folders): Python 2.4.3 :

Re: Add NTLM proxy authentication to urllib2

2006-09-08 Thread looping
Thanks for the answers. I've done some tests with urllib2 and pywin32 and managed to partialy implement the NTLM authentication, but it look like you need a persistent connection (http 1.1 or 'Keep-Alive') to complete the authentication. Unfortunatly, urllib2 use a new connection for each request

Add NTLM proxy authentication to urllib2

2006-09-05 Thread looping
Hi, I have to make internet connections through an ISA proxy server that use NTLM or Kerberos authorization method. I've found a program in python called ntlmaps that act like a proxy and could make the NTLM authentication, but you have to run it and make all your connection through it, not an opti

Re: Dispatch with multiple inheritance

2006-07-19 Thread looping
looping wrote: > Michael J. Fromberger wrote: > > > > Is there a better (i.e., more elegant) way to handle the case marked > > (**) above? > > > > You have to call super in each method __init__, if you don't, the call > chain break before the end: >

Re: Dispatch with multiple inheritance

2006-07-18 Thread looping
Michael J. Fromberger wrote: > > Is there a better (i.e., more elegant) way to handle the case marked > (**) above? > You have to call super in each method __init__, if you don't, the call chain break before the end: class A (object): def __init__(self): super(A, self).__init__()

Re: Way for see if dict has a key

2006-06-30 Thread looping
Michele Petrazzo wrote: > Bruno Desthuilliers wrote: > >> but what the better > > > > Depends on the context. > > > > If know only one context: see if the key are into the dict... What other > context do you know? > > Michele Why do you want to do that ? if key in dict: value = dict[key] else:

Re: Includeing Python in text files

2006-05-22 Thread looping
Paolo Pantaleo wrote: > I am working on this: > > I have a text file, containig certain section in the form >python code here > py?> > > I parse the text file and substitute the python code with its result > [redirecting sys.stdin to a StringIO]. It something like php or > embedded perl. > >

Re: Question about exausted iterators

2006-05-18 Thread looping
Christophe wrote: > Ok, call me stupid if you want but I know perfectly well the "solution" > to that problem ! Come on, I was showing example code of an horrible > gotcha on using iterators. > OK, your are stupid ;-) Why asking questions when you don't want to listen answers ? > > > Instead of

Re: can anyone advise me

2006-04-27 Thread looping
try something like this: x = 0 while x < 10: z = 0 print '-' + str(x) + '-' x = x + 1 while z < x: print '.' + str(z) + '.', z = z + 1 -- http://mail.python.org/mailman/listinfo/python-list

Re: Why new Python 2.5 feature "class C()" return old-style class ?

2006-04-11 Thread looping
Georg Brandl wrote: > If you have many classes in a module, putting > > __metaclass__ = type > > at the top can save you these keystrokes. > > Georg We could do that ? Nice trick that I've never thoughts about myself. Thanks Georg. -- http://mail.python.org/mailman/listinfo/python-list

Re: Why new Python 2.5 feature "class C()" return old-style class ?

2006-04-11 Thread looping
bruno at modulix wrote: > looping wrote: > > Peter Hansen wrote: > > > >>Georg Brandl wrote: > >> > >>>class C(): > >>> > >>>is meant to be synonymous with > >>> > >>>class C: > >>> > >

Re: Why new Python 2.5 feature "class C()" return old-style class ?

2006-04-11 Thread looping
Peter Hansen wrote: > Georg Brandl wrote: > > class C(): > > > > is meant to be synonymous with > > > > class C: > > > > and therefore cannot create a new-style class. > > I think "looping" understands that, but is basically asking wh

Why new Python 2.5 feature "class C()" return old-style class ?

2006-04-11 Thread looping
For Python developers around. >From Python 2.5 doc: The list of base classes in a class definition can now be empty. As an example, this is now legal: class C(): pass nice but why this syntax return old-style class, same as "class C:", and not the new style "class C(object):" ? Old-style

Re: XMLRPCServer issues

2006-03-27 Thread looping
Fredrik Lundh wrote: > "looping" wrote: > > > > 2. You might want to transmit integers as strings rather than use the > > > XML-RPC integer type (which is limited to numbers between -2147483648 > > > and 2147483647). > > > > Is it a limit

Re: XMLRPCServer issues

2006-03-27 Thread looping
Brian Quinlan wrote: > 1. Is there on option to get cx_Oracle to return string data as unicode > rather than strings objects? XML-RPC aside, dealing with unicode objects > might be better than dealing with encoded strings. I don't think cx_Oracle can return unicode string, so my code to convert s

XMLRPCServer issues

2006-03-27 Thread looping
Hi, I had some issues with XMLRPCServer and I try to validate my workaround. My first try was this (somewhat self explaining code): from DocXMLRPCServer import DocXMLRPCServer from cx_Oracle import connect def get_task_list(user): sql = """ select ISS.ISS_ISSUE_NUMBER

How to create a Visual SourceSafe plugin in Python

2006-03-14 Thread looping
Hi, I try to create a COM object with win32com to track events in Visual SourceSafe. I tried to modify ExcelAddin.py demo but with no luck. I've now a Delphi DLL that make that job so I know it's possible. If someone have an exemple, please help me. Best regards. Kadeko -- http://mail.python.or

Re: pysqlite problem

2006-03-01 Thread looping
OK, it's better. You use relative path to your file 'ex1', are you really sure that you open the right file and not creating another DB in another path ? Try to use absolute path (r'c:\temp\ex1'). -- http://mail.python.org/mailman/listinfo/python-list

Re: pysqlite problem

2006-03-01 Thread looping
Is it the complete code ? If so then you have to create the table each time you connect to the DB. You use an in-memory DB (":memory:") so all the data of the DB is lost when you close the connection, including the schema of the DB. -- http://mail.python.org/mailman/listinfo/python-list

Re: TypeError when subclassing 'list'

2006-02-27 Thread looping
Gerard Flanagan wrote: > Hello all > > Could anyone shed any light on the following Exception? The code which > caused it is below. Uncommenting the 'super' call in 'XmlNode' gives > the same error. If I make XmlNode a subclass of 'object' rather than > 'list' then the code will run. > > Thanks in