Re: List of disk drives on Windows?

2008-05-20 Thread Christian Heimes
Mike Driscoll schrieb: > On May 20, 2:45 pm, Tim Golden <[EMAIL PROTECTED]> wrote: >> Bob Greschke wrote: >>> This MUST have been asked before, but I can't seem to Google the right >>> thing. How can I get a list of drives on a Windows box, like ["C:\", >>> "D:\"], like I can if I do something lik

Re: How do I know when all threads are done?

2008-05-22 Thread Christian Heimes
Zerge schrieb: > I can launch threads just fine, but then I have to do a time.sleep(n) > so the main thread from which they where launched will wait for all > the threads to return. > > How can I detect when all threads are done and then return control to > the main threads? import threading thr

Re: code of a function

2008-05-29 Thread Christian Heimes
Dark Wind schrieb: > Hi, > > Is there any command in Python which gives the code for a function like just > typing the name of a function (say svd) in R returns its code. Yes, it's posible to retrieve the source code IFF the function is implemented in Python and the .py file is available, too. >

Re: seg. fault with Py_BuildValue?

2008-05-29 Thread Christian Heimes
Christian Meesters schrieb: > Hi > > I'm having trouble with Py_BuildValue. I was able to pinpoint the following > statement as the one causing a seg. fault with my script: > > static PyObject * funcname(PyObject *self, PyObject *args) { > > return Py_BuildValue("(OO)", x, y); > } > where

Re: Writing Empty folders into ZipFile

2008-06-03 Thread Christian Heimes
[EMAIL PROTECTED] schrieb: > Hello. > > I'm having situation writing folders structure into > a zip file. Folders contain no files. > > Is it possible to do in python ? As far as I remember the zip format it's not possible at all. Folders are created implicitly. The zip format doesn't support

Re: Q about object identity

2008-06-03 Thread Christian Heimes
[EMAIL PROTECTED] schrieb: > Hello, > > I am testing object identity. > > If I do it from the interpreter, I get strange results. > print [] is [] > False > print id([]), id([]) > 3083942700 3083942700 > > > > Why is that? Isn't this an error? No, it's not an error. You are gettin

Re: How to make py2.5 distutil to use VC2005?

2008-06-04 Thread Christian Heimes
甜瓜 schrieb: > Howdy, > This problem have puzzled me for a long time. I usually use > python2.5 in Windows, while VC2005 is installed. > However python25.lib is compiled by VC2003. When I use disutil to > build some C extensions, it complaints that > there is no VC2003. > Well, IMO, the form

Re: Trying to extend Python with C: undefined reference to `Py_BuildValue'

2008-06-04 Thread Christian Heimes
[EMAIL PROTECTED] schrieb: > Can anyone help? I am including Python.h, so why does it not find > Py_BuildValue? Read your error message again. It says the dynamic linker (ld) can't find the name. You have to link against the Python library. Christian -- http://mail.python.org/mailman/listinfo

Re: multiprocessing module (PEP 371)

2008-06-04 Thread Christian Heimes
sturlamolden schrieb: > There is a well known C++ implementation of cow-fork on Windows, which > I have slightly modified and ported to C. But as the new WDK (Windows > driver kit) headers are full of syntax errors, the compiler choke on > it. :( I am seriously considering re-implementing the whole

Re: How to get System.Timers.Timer

2008-06-08 Thread Christian Heimes
John Machin wrote: > One grabs one's googler and goes a-huntin' ... > ==>> http://msdn.microsoft.com/en-us/library/system.timers.aspx > Looks like part of .NET so one might expect that one already have it. > However one would need to use IronPython to access it ... Or the PythonDotNET extension fo

Re: Question by someone coming from C...

2008-06-10 Thread Christian Heimes
John Krukoff wrote: > Since you probably want access to these from many different places in > your code, I find the simplest way is to create a logging module of your > own (not called logging, obviously) and instantiate all of your loggers > in that namespace, then import that one module as needed

Re: value is in list?

2008-06-12 Thread Christian Heimes
David Hláčik wrote: > Hello , > following scenario > > list_current = [ "welcome", "search", "done", "result"] > list_ldap = [ "welcome", "hello"] > > result: > > list_toadd = [ "hello"] > > by words said , i want to check if list item from list_ldap exists in > list_current if not i want to ad

Re: Python 3000 vs. Python 2.x

2008-06-13 Thread Christian Heimes
[EMAIL PROTECTED] wrote: > As a new comer to Python I was wondering which is the best to start > learning. I've read that a number of significant features have > changed between the two versions. Yet, the majority of Python > programs out in the world are 2.x and it would be nice to understand >

Re: numpy: handling float('NaN') different in XP vs. Linux

2008-06-14 Thread Christian Heimes
John [H2O] wrote: > I have a script: > > from numpy import float > OutD=[] > v=['3','43','23.4','NaN','43'] > OutD.append([float(i) for i in v[1]]) > > > On linux: > Python 2.5.1 (r251:54863, Mar 7 2008, 04:10:12) > [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 > [EMAIL P

Re: os.walk Value Error?

2008-06-14 Thread Christian Heimes
[EMAIL PROTECTED] wrote: > Is there any other reason I might get that error? Yes, you are using it the wrong way. The correct way is for root, dirs, files in os.walk(path): do something os.walk returns an iterator which yields root, dirs and files for each iteration. Christian -- http://ma

Re: marshal.dumps quadratic growth and marshal.dump not allowing file-like objects

2008-06-15 Thread Christian Heimes
Raymond Hettinger wrote: > When more space is needed, the resize operation over-allocates by > double the previous need plus 1K. This should give amortized O(1) > performance just like list.append(). > > However, when that strategy requests more than 32Mb, the resizing > becomes less aggressive a

Re: 32 bit or 64 bit?

2008-06-15 Thread Christian Heimes
[EMAIL PROTECTED] wrote: > Does it mean that even now it does arithmetic in 64 bit? > I'm not getting enough precision. Is there any way to increase it? Buy a good book about numerics or take a course. ;) Seriously, computers and IEEE 754 floating point numbers have a lot of pit falls. If you cho

Re: 32 bit or 64 bit?

2008-06-15 Thread Christian Heimes
[EMAIL PROTECTED] wrote: > I have a physical system set up in which a body is supposed to > accelerate and to get very close to lightspeed, while never really > attaining it. After approx. 680 seconds, Python gets stuck and tells > me the object has passed lightspeed. I put the same equations in >

Re: -1/2

2008-06-22 Thread Christian Heimes
Serve Lau wrote: > What is the expected result of -1/2 in python? 0 Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: 2to3 bug and question

2008-06-23 Thread Christian Heimes
Helmut Jarausch wrote: > Hi, > > is this the right group to ask / report problems with python3.0 ? While the general Python list is the right place to discuss bugs it's not sensible to report them here. Most Python core developers except Martin, me and a few more aren't reading this list at all.

Re: [2to3] Bug converting import

2008-06-23 Thread Christian Heimes
Helmut Jarausch wrote: > Now, when I invoke Master.py I get > > Traceback (most recent call last): > File "Master.py", line 2, in > from . import Slave > ValueError: Attempted relative import in non-package > > > thanks for looking into it, The cause of the bug is in fixes/fix_import.py pro

Re: Use of the "is" statement

2008-06-27 Thread Christian Heimes
Joel Corbin wrote: > I'm trying to clarify what exactly the behaviour of the is statement is (or > should be). ... People often think that "is" is part of the comparison operator set. The "is" statement does not compare two objects. Never ever use "is" to compare strings or numbers. Christian

Re: Use of the "is" statement

2008-06-27 Thread Christian Heimes
Gary Herron wrote: > In short: *never* use "is". Never use "is" unless you want to check "if something is None or something is not None" Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: Use of the "is" statement

2008-06-27 Thread Christian Heimes
Joel Corbin wrote: > Thank you Gary, Cédric, Christian. When *would *one use "is"? As I said: The "is" statement should only be used when you want to check of something is exactly and identical to None like "a is None" or "b is not None". For everything else you should use == or !=. There are some

Re: Finding IP address of localhost via socket API (or other API)

2008-08-05 Thread Christian Heimes
David York wrote: How do I find out my machine's IP address as visible to the outside world? Thanks a lot. Most modern routers home routers support the IGD part of UPnP (http://en.wikipedia.org/wiki/Internet_Gateway_Device_Protocol). You can use an UPnP client software to query the router for

Re: pyprocessing/multiprocessing for x64?

2008-08-05 Thread Christian Heimes
Benjamin Kaplan wrote: I'm not an expert on this, but I think that anything written for x86 (32 bit) machines can run on x64 machines. Become an export - say the opposite :) -- http://mail.python.org/mailman/listinfo/python-list

Re: pyprocessing/multiprocessing for x64?

2008-08-05 Thread Christian Heimes
Benjamin Kaplan wrote: I don't have a 64-bit machine, so I can only go off of what I read. This is from the AMD64 FAQ Welcome to the world of marketing. The FAQ just explains that AMD64 compatible proc

Re: how to find out if an object is a class?

2008-08-08 Thread Christian Heimes
szczepiq wrote: Pardon me for most likely a dummy question but how do I find out if an object is a class? For God's sake don't reinvent the wheel! The 'inspect' module (part of the Python standard library) has a functions isclass(). It does the proper tests for new style and old style classes

Re: maybe a stupid question

2008-08-08 Thread Christian Heimes
Strato wrote: I have an app installed in /usr/lib/python2.5/site-package/MyApp I have a symlink in /usr/local/bin that points to /usr/lib/python2.5/site-package/MyApp/myscript.py Then, when I launch my script from anywhere using the symlink, how to determine that the script is located in /u

Re: Wouldn't it be nice if this worked?

2008-08-10 Thread Christian Heimes
Calvin Spealman wrote: dont quote me but i do think this check is being removed. No, the check hasn't been removed - technically speaking. In Python 3.0 the behavior of the method descriptor has been changed. aclass.somemethod doesn't give you an instancemethod wrapper any more. It's a plain

Re: Help counting the total number of dictionaries inside a list that contain a specified key value

2008-08-12 Thread Christian Heimes
Jon Bowlas wrote: For example I'd like to kow how many dictionaries there are with a level 1, 2 , 23 & 3 etc. How would one go about achieveing this? Hope someone can help. sum(u'Level 2 Courses' in dct for dct in yourlist) Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: Help counting the total number of dictionaries inside a list that contain a specified key value

2008-08-12 Thread Christian Heimes
Jon Bowlas wrote: I'm afraid I can't use Peters suggestion as I'm using python 2.3 and it doesn't have the collection module. Thanks anyway. Python 2.3 is the reason. It doesn't support the generator expression syntax. Try sum([u'Level 2 Courses' in dct for dct in yourlist]) or len([1 for dct

Re: Checking a file's time stamp.

2008-08-12 Thread Christian Heimes
William Purcell wrote: Hi all, I am wanting to check to see the last time a file was edited. For example, I have a directory containing two text files, file1.txt and file2.txt. I want to be able to process these files but only if they have been edited since the last time they were processed. I

Re: passing a variable argument list to a function

2008-08-12 Thread Christian Heimes
Scott wrote: I suspect there's a simple bit of syntax that I'm missing -- can anyone give me a hand? Yeah. It's so easy and obvious that you are going to bang your head against the wall. :) The single star does not only collect all arguments in a function definition. It also expands a sequenc

Re: strptime and timezones

2008-08-13 Thread Christian Heimes
Tom Anderson wrote: Secondly, do you really have to do this just to parse a date with a timezone? If so, that's ridiculous. No, you don't. :) Download the pytz package from the Python package index. It's *the* tool for timezone handling in Python. The time zone definition are not part of the

Re: Factory for Struct-like classes

2008-08-13 Thread Christian Heimes
eliben wrote: Ruby's 'Scruct' class (http://ruby-doc.org/core/classes/Struct.html) does this. I suppose it can be done with 'exec', but is there a more Pythonic way ? Try named tuple http://code.activestate.com/recipes/500261/ A named tuple implementation is part of Python 2.6 and 3.0. For ol

Re: any function to fill zeros to the right?? zfill??

2008-08-13 Thread Christian Heimes
Johnny wrote: if I want to fill zeros to the right, what function can help?? ex: '1.23'=>'1.2300' but '1.23'.zfill(6)=>'001.23' Use string formatting: >>> "%0.6f" % 1.5 '1.50' Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: I am worried about Python 3

2008-04-09 Thread Christian Heimes
jmDesktop schrieb: > If I continue in Python 2.5.x, am I making a mistake? Is it really > that different? I'm speaking as a long time Python user and Python core developer here. You are safe to ignore Python 3.0 for now. :] You can start worrying about the 3.x series in 2010 when Python 3.1 is o

Re: Multiple independent Python interpreters in a C/C++ program?

2008-04-12 Thread Christian Heimes
Diez B. Roggisch schrieb: > AFAIK there was a thread a few month ago that stated that this is > actually possible - but mostly 3rd-party-c-extension aren't capable of > supporting that. Martin von Loewis had a word in that, maybe googling > with that in mind reveals the discussion. > > And of c

Re: str(bytes) in Python 3.0

2008-04-12 Thread Christian Heimes
Gabriel Genellina schrieb: > On the last line, str(x), I would expect 'abc' - same as str(x, 'ascii') > above. But I get the same as repr(x) - is this on purpose? Yes, it's on purpose but it's a bug in your application to call str() on a bytes object or to compare bytes and unicode directly. Sev

Re: accessing individual characters in unicode strings

2008-04-12 Thread Christian Heimes
Peter Robinson schrieb: > Dear list > I am at my wits end on what seemed a very simple task: > I have some greek text, nicely encoded in utf8, going in and out of a > xml database, being passed over and beautifully displayed on the web. > For example: the most common greek word of all 'kai' (o

Re: str(bytes) in Python 3.0

2008-04-12 Thread Christian Heimes
Carl Banks schrieb: > I believe the Zen in effect here is, "In the face of ambiguity, refuse > the temptation to guess." How do you know if the bytes are utf-8 > encoded? Indeed > I'm not sure if str() returning the repr() of a bytes object (when not > passed an encoding) is the right thing, but

Re: str(bytes) in Python 3.0

2008-04-12 Thread Christian Heimes
John J. Lee schrieb: > Why hasn't the one-argument str(bytes_obj) been designed to raise an > exception in Python 3? See for yourself: $ ./python Python 3.0a4+ (py3k:0, Apr 11 2008, 15:31:31) [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 Type "help", "copyright", "credits"

Re: Tremendous slowdown due to garbage collection

2008-04-12 Thread Christian Heimes
[EMAIL PROTECTED] schrieb: > which made me suggest to use these as defaults, but then > Martin v. Löwis wrote that > >> No, the defaults are correct for typical applications. > > At that point I felt lost and as the general wish in that thread was > to move > discussion to comp.lang.python, I bro

Re: What parts of string module will disappear in Python 3.0?

2008-04-14 Thread Christian Heimes
[EMAIL PROTECTED] schrieb: > I understand that many portions of the string module are redundant with > the native methods of strings and will removed in Python 3.0. Makes > sense to me. > > But what will happen to the portions of the string module that are not > covered by native string methods -

Re: why function got dictionary

2008-04-19 Thread Christian Heimes
[EMAIL PROTECTED] schrieb: > A: everything (or almost) in Python is an object. Including functions, > classes, modules etc. Everything you can access from or through Python code must be an object. Every object has at least a type and a reference count. Christian -- http://mail.python.org/mailma

Re: manipulating class attributes from a decorator while the class is being defined

2008-04-19 Thread Christian Heimes
Wilbert Berendsen schrieb: > Hi, is it possible to manipulate class attributes from within a decorator > while the class is being defined? > > I want to register methods with some additional values in a class attribute. > But I can't get a decorator to change a class attribute while the class is

Re: Alternate indent proposal for python 3000

2008-04-20 Thread Christian Heimes
Eric Wertman schrieb: > I was considering putting together a proposal for an alternate block > syntax for python, and I figured I'd post it here and see what the > general reactions are. I did some searching, and while I found a lot > of tab vs space debates, I didn't see anything like what I'm th

Re: "Help needed - I don't understand how Python manages memory"

2008-04-20 Thread Christian Heimes
Gabriel Genellina schrieb: > Apart from what everyone has already said, consider that FreqDist may import > other modules, store global state, create other objects... whatever. > Pure python code should not have any memory leaks (if there are, it's a bug > in the Python interpreter). Not-carefull

Re: "Help needed - I don't understand how Python manages memory"

2008-04-20 Thread Christian Heimes
Hank @ITGroup schrieb: > In order to deal with 400 thousands texts consisting of 80 million > words, and huge sets of corpora , I have to be care about the memory > things. I need to track every word's behavior, so there needs to be as > many word-objects as words. > I am really suffering from the

Re: "Help needed - I don't understand how Python manages memory"

2008-04-20 Thread Christian Heimes
Martin v. Löwis schrieb: > Can you give an example, please? http://trac.edgewall.org/ contains at least one example of a reference leak. It's holding up the release of 0.11 for a while. *scnr* The problem is also covered by the docs at http://docs.python.org/dev/library/sys.html#sys.exc_info Chr

Re: sys.maxint in Python 3

2008-04-21 Thread Christian Heimes
[EMAIL PROTECTED] schrieb: > In some algorithms a sentinel value may be useful, so for Python 3.x > sys.maxint may be replaced by an improvement of the following infinite > and neginfinite singleton objects: Python 3.0 doesn't have sys.maxint any more since Python 3's ints are of arbitrary length.

Re: [Python 2.4/2.5] subprocess module is sorely deficient?

2008-04-22 Thread Christian Heimes
Harishankar schrieb: > 2. Kill the subprocess in a platform independent manner (i.e. no third party > modules and no hacks). I've added the feature to the Popen class a few days ago. The new methods are kill(), terminate() and send_signal(sig). On Windows all methods just fall back to _subprocess

Re: [Python 2.4/2.5] subprocess module is sorely deficient?

2008-04-22 Thread Christian Heimes
Nick Craig-Wood schrieb: > Nothing apart from the fact it doesn't work on windows. The buffering > will cause you grief too. If you want to do this properly under unix > use pexpect not subprocess. > > http://www.noah.org/wiki/Pexpect > > Proper non blocking IO is an absolute nightmare under

Re: [Python 2.4/2.5] subprocess module is sorely deficient?

2008-04-22 Thread Christian Heimes
Martin v. Löwis schrieb: >> 2. Kill the subprocess in a platform independent manner (i.e. no third party >> modules and no hacks). > > What's wrong with the .terminate method of the Popen object? It's brand new ;) Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: python has memory leak?

2008-04-22 Thread Christian Heimes
[EMAIL PROTECTED] schrieb: > The version of my python is: > Python 2.4.4 Stackless 3.1b3 060516 (#71, Oct 31 2007, 14:22:28) [MSC ^ This is the wrong list to ask for memory leaks of Stackless ;) Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: [Python 2.4/2.5] subprocess module is sorely deficient?

2008-04-23 Thread Christian Heimes
Harishankar schrieb: > Is there any platform independent way to launch a terminal window from a > desktop (Windows, Linux, etc.)? No, there isn't. It usually not possible to create a graphical terminal window on a remote server. Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: Subprocess module

2008-04-23 Thread Christian Heimes
[EMAIL PROTECTED] schrieb: > Hello all > > I want to convert a tex file into a pdf by using pdflatex. For that, I > thought the 'subprocess' module might be a good option. My code doesn't work > at all tho: > > Import os, subprocess > > def main(): > scriptpath = os.path.dirname(__file

Re: How to get inner exception traceback

2008-04-24 Thread Christian Heimes
[EMAIL PROTECTED] schrieb: > On 24 Apr, 13:20, Thomas Guettler <[EMAIL PROTECTED]> wrote: >> Hi, >> >> How can you get the traceback of the inner exception? >> >> try: >> try: >> import does_not_exit >> except ImportError: >> raise Exception("something wrong") >> except:

Re: Subclassing datetime.date does not seem to work

2008-04-25 Thread Christian Heimes
Rick King schrieb: > I would like to subclass datetime.date so that I can write: > > d = date2('12312008') > > I tried: > > from datetime import date > class date2(date): > def __init__( self, strng ): > mm,dd,yy = int(strng[:2]), int(strng[2:4]), int(strng[4:]) > date.__init

Re: Why is None <= 0

2008-04-25 Thread Christian Heimes
> In my humble opinion, I think that comparisons involving None should > return None, but I trust that the designers came up with this for very > good reasons. As far as I know I've never been bitten by it. It's fixed in Python 3.x. Python 3.x refuses to compare objects unless one of both objects

Re: Python(2.5) reads an input file FASTER than pure C(Mingw)

2008-04-26 Thread Christian Heimes
SL schrieb: > Is there an implementation of f.readlines on the internet somewhere? > interested to see in how they implemented it. I'm pretty sure they did > it smarter than just reserve 100meg of data :) Of course it is. Checkout the Python sources :) Christian -- http://mail.python.org/mailman

Re: Zope/DTML Infuriating...

2008-04-29 Thread Christian Heimes
Jens schrieb: > Hello Everyone. > > I am relatively new to Zope(using it for a work project) and I was > wondering if someone here could help me out or at least refer me to a > decent documentationg for Zope/DTML/Python (at the detail level of > php.net or Java API reference). > http://www.zope.

Re: Sending Cntrl-C ??

2008-04-29 Thread Christian Heimes
gamename schrieb: > Hi, > > I really like this recipe for controlling subprocesses: > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440554 > > However, I can't figure out how I can send the equivalent of "Cntrl-C" > to the subprocess. How can that be done? import os import signal impo

Re: Sending Cntrl-C ??

2008-04-29 Thread Christian Heimes
gamename schrieb: > Thanks, Christian. Would that work on win32 as well? No, Windows doesn't support the same, rich set of signal as Unix OSes. Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 2.6 and wrapping C libraries on Windows

2008-04-30 Thread Christian Heimes
L. Lindstrom schrieb: > I have read that Python extension modules must link to the same C > run-time as the Python interpreter. This I can appreciate. But does this > requirement extend to the C libraries an extension module wraps. The > case in point is Pygame and SDL. The Pygame extension modules

Re: Is vs Equality Operator

2008-05-01 Thread Christian Heimes
Good Z schrieb: > Hello, > I am having problem in using is. Here is what i am doing. > > x='' > if x is None or x is '': > return 1 > > The above statement does not return value 1. > > If i changed the above check to > if x == None or x == '': > return 1 > Now it works fine. >

Re: Python 2.6 and wrapping C libraries on Windows

2008-05-01 Thread Christian Heimes
illume schrieb: > Hi, > > after a little research it appears that win9x is not supported by the > msvcr90.dll run time. > > Can you confirm this Lenard? > > Has anyone tested the new python binaries that link to msvcr90.dll on > win9x machines? It doesn't matter to use because Python 2.6 and 3.

Re: Problems with Cheese Shop

2008-05-01 Thread Christian Heimes
Torsten Bronger schrieb: > Hallöchen! > > How can I authorise to the Python Cheese Shop in order to use > setup.py upload? Currently, I get > > Upload failed (401): You must be identified to edit package information Try "python setup.py register sdist upload" Christian -- http://mail.python.or

Re: where do I begin with web programming in python?

2008-05-01 Thread Christian Heimes
jmDesktop schrieb: > I have been to the main python site, but am still confused. I have > been using .net, so it may be obvious how to do this to everyone > else. I am aware there are various frameworks (Django, Pylons, etc.), > but I would like to know how to create web pages without these. If

Re: dropping win98 support?

2008-05-01 Thread Christian Heimes
illume schrieb: > Ah, why is that? > > There's still at least 1.1% of people using win98, if you believe this > source of stats: > http://www.w3schools.com/browsers/browsers_os.asp > > I just noticed that win9x winme and win nt are all being dropped from > python. > > I know they are old and cru

Re: dropping win98 support? was Re: Python 2.6 and wrapping C libraries on Windows

2008-05-02 Thread Christian Heimes
illume schrieb: > There are still *lots* of people who still use win95, 98, 98se, me, > and win2k - as shown by the statistics I linked to in a previous > post. If you want more statistics about the number of people using > what OS they are fairly easy to find with a search engine. One day > win9

Re: no cleanup on TERM signal

2008-05-02 Thread Christian Heimes
Laszlo Nagy schrieb: > For sensitive resources, instead of writing __del__ methods, you should > create a "close()" method. Python does this with file objects, DB API > 2.0 with database connection objects etc. Then you can do > > res = create_resource() > try: >use_resource() > finally: >

Re: portable /dev/null

2008-05-02 Thread Christian Heimes
Brendan Miller schrieb: > Hi, > > I have functions that take a file object and write to it. In some cases I > just want to throw out what is written to that file object. I want > something like open('/dev/null', 'w'), but portable. import os null = open(os.devnull, "wb") :) Christian -- http://

Re: IPv6 and Python

2008-05-02 Thread Christian Heimes
Giampaolo Rodola' schrieb: > I'm not sure if this is a question about python programming, system > administration or sockets in general... > I have the FTP server in my signature to which I'd want to add IPv6 > support. > My hosting company provides me a common IPv4 address. > I'd like to set up my

Re: 'property' builtin does not work for me

2008-05-02 Thread Christian Heimes
Alex Fainshtein schrieb: > As you see, getter works properly. But when assigning to property, setter is > not called, as I would expect. prop is simply replaced with whatever is > assigned and ceased being a property. properties work only for new style classes. You have to subclass your class from

Re: Visual Studio 6 compile of 2.5.2 fails with missing db.h

2008-05-05 Thread Christian Heimes
brucoder schrieb: > Any pointers? A prerequisite that I might be missing? The source is > the Python-2.5.2.tar.gz from the Python.org site. The tar.gz doesn't contain the dependencies like the bsddb files or sqlite3, bzip2 and more. You have to download and unpack the correct versions into the c

Re: select.poll() and WSAPoll

2008-05-06 Thread Christian Heimes
inhahe schrieb: > select.poll isn't supported on Windows, because Windows doesn't have such a > feature, or at least it didn't until Vista. Vista implements the same thing > but called WSAPoll, an article is here > http://blogs.msdn.com/wndp/archive/2006/10/26/WSAPoll.aspx > I hope that the ne

Re: open filename with spaces in path

2008-05-06 Thread Christian Heimes
Michael Robertson schrieb: > I'm having trouble opening a file in linux, whose path has spaces in it. > > $ mkdir my\ test > $ echo test > my\ test/test.txt > $ python > open('./my test/test.txt') > Exception Works for me >>> open('./my test/test.txt') Christian -- http://mail.python.or

Re: subprocess wait() waits forever, but os.system returns

2008-05-07 Thread Christian Heimes
grayaii schrieb: > There are so many threads on this subject, but I ran across a > situation on Windows that I can't figure out. > > I'm trying to run this little command-line exe and when I launch like > this, it hangs: > import subprocess command = r'c:\mydir\foo.exe' run = subpr

Re: subprocess wait() waits forever, but os.system returns

2008-05-07 Thread Christian Heimes
grayaii schrieb: > Awesome! That worked! > And your comment just led me down another exploration path on why the > following doesn't work: > - > while(returncode is None): > returncode = run.poll() > time.sleep(1) > > out = run.stdout.readlines() > err = run.stderr.

Re: Mathematics in Python are not correct

2008-05-08 Thread Christian Heimes
Luis Zarrabeitia schrieb: 0**0 > 1 > > That 0^0 should be a nan or exception, I guess, but not 1. No, that's correct for floats. Read the wikipedia article or the C99 standard for more information. Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: RELEASED Python 2.6a3 and 3.0a5

2008-05-09 Thread Christian Heimes
Kay Schluehr schrieb: > http://www.python.org/ftp/python/3.0/python-3.0a5.msi > Error 404: File Not Found > http://www.python.org/ftp/python/3.0/python-3.0a5.amd64.msi > Error 404: File Not Found The Windows binaries usually take a while. I'm adding Martin to the CC list. His is most like build

Re: Free Memory

2008-05-09 Thread Christian Heimes
Dark Wind schrieb: > Hi, > > How can I free all the memory in python by deleting all variables. I am > looking for the equivalent of 'clear' from Matlab. > > I know del x deletes a variable x, but it doesn't free all the available > memory. del doesn't free an object. It only removes one referen

Re: Getting stdout using ctypes.

2008-08-14 Thread Christian Heimes
Grant Edwards wrote: If he's running Unix, he needs to replace the stdout file descriptor (fd 1), with something that's connected to the "write" end of a pipe. Then he needs to read the other ("read") end of the pipe in his application. You do that using the dup2() system call: It's dangerous

Re: Trying ZODB, background in Relational: mimic auto_increment?

2008-08-14 Thread Christian Heimes
Diez B. Roggisch wrote: But that's a great deal more complicated! It requires merging, and while this of course is possible, you should have mentioned it because otherwise the OP might run into problems. A lock doesn't do the job at all. ZODB supports clustering through ZEO. Multiple ZEO clie

Re: negative numbers are not equal...

2008-08-14 Thread Christian Heimes
ariel ledesma wrote: i read that 'is' compares if they are really the same object, but i don't that's it because then why does -5 return True? of course i could only use == to compare, but still, what am i missing here? Rule of thumb: Never use 'is' with any kind of string or numeric object.

Re: getattr nested attributes

2008-08-15 Thread Christian Heimes
Gregor Horvath wrote: any help? I guess you missunderstood the sentence "For example, getattr(x, 'foobar') is equivalent to x.foobar.". getattr(x, "foo.bar") is not equivalant to x.foo.bar. -- http://mail.python.org/mailman/listinfo/python-list

Re: Handling Property and internal ('__') attribute inheritance and creation

2008-08-15 Thread Christian Heimes
Bruno Desthuilliers wrote: How often do you really need to override a property ? (hint : as far as I'm concerned, it never happened so far). Now you have two solutions : either redefine the whole property in the derived class, or, if you really intend your property to be overriden, provide a "t

Re: negative numbers are not equal...

2008-08-15 Thread Christian Heimes
ariel ledesma wrote: well, i'm glad i stumbled upon this detail early on (i only had to fix about one page of code)... i'll just stick to 'is' when it concerns checking if it is the *same* object (memorywise) instead of an *equivalent* one... just before wrapping up, the special methods __eq__

Re: Good python equivalent to C goto

2008-08-16 Thread Christian Heimes
Kurien Mathew wrote: Hello, Any suggestions on a good python equivalent for the following C code: There are various ways to write your example in Python. For example while loopCondition: condition = 1 while condition: if condition1: break if condition2:

Re: how to add property "dynamically"?

2008-08-16 Thread Christian Heimes
akonsu wrote: i am not an expert in python, would someone please tell me what i am doing wrong? You can't add properties to an instance. They must be specified on the type (aka new style class). Descriptors and magic methods are only looked up on classes for various reasons - mostly performan

Re: Basic importing question

2008-08-20 Thread Christian Heimes
Hussein B wrote: Thank you both for your kind help and patience :) Built-in modules are compiled but even if they are so, when importing them (sys for example), Python will run their code in order to create bindings and objects, right? I'm learning Python and I want to learn it well, so that I'm

Re: Basic importing question

2008-08-20 Thread Christian Heimes
Bruno Desthuilliers wrote: As the name imply, built-in modules are built in the interpreter - IOW, they are part of the interpreter *exposed* as modules[1]. Unless you have a taste for gory implementation details, just don't worry about this. Other "ordinary" modules need of course to be execu

Re: Negative integers

2008-08-20 Thread Christian Heimes
johnewing wrote: but that fails when one of the numbers is 0. I'm sure that there is an easy way to do this. Any suggestions? For the not-so-distant future: Python 2.6 and 3.0 have a new function "copysign" in the math module. I added it during the revamp of the math module. copysign(x, y)

Re: Should Python raise a warning for mutable default arguments?

2008-08-22 Thread Christian Heimes
Steven D'Aprano wrote: I suggest that Python should raise warnings.RuntimeWarning (or similar?) when a function is defined with a default argument consisting of a list, dict or set. (This is not meant as an exhaustive list of all possible mutable types, but as the most common ones that I expect

Re: dict views implementation

2008-08-22 Thread Christian Heimes
[EMAIL PROTECTED] wrote: Where can I find an explanation of how the new light dict views of Python 3 are implemented (or what's the name of the C source file to look inside for their implementation)? The views are implemented next to the dict object. Grepping for PyTypeObject in http://svn.pyt

Re: property() usage - is this as good as it gets?

2008-08-22 Thread Christian Heimes
David Moss wrote: Hi, I want to manage and control access to several important attributes in a class and override the behaviour of some of them in various subclasses. Below is a stripped version of how I've implemented this in my current bit of work. It works well enough, but I can't help feel

Re: Should Python raise a warning for mutable default arguments?

2008-08-22 Thread Christian Heimes
MRAB wrote: Could there be a new special method __mutable__? Why should we add a new method? Seriously, why should Python be cluttered and slowed down to warn about mutable arguments. It's neither a design flaw nor a surprising feature *ONCE* you have understood how functions work. I agree t

Re: Return a string result with out breaking loop

2008-08-25 Thread Christian Heimes
Andrew wrote: Hi I was wondering if there is anyway with XML RPC to send a string of text from the server to the client with out calling return thus breaking my loop for example def somefunc(): for action, files in results: full_filename = os.path.join(path_to_watch, fil

<    2   3   4   5   6   7   8   9   10   11   >