Re: Module import path when embedding python in C

2008-09-26 Thread Christian Heimes
ng the sys module and then doing the append? The PySys_Get/SetObject methods are faster than PyImport. The methods access the sys module directly without going through the import API. The funcitons weren't documented because they were simply forgotten. Christian -- http://mail.python.org/m

Re: str() should convert ANY object to a string without EXCEPTIONS !

2008-09-28 Thread Christian Heimes
Steven D'Aprano wrote: str(b'123') # b prefix is added "b'123'" Perhaps I'm misinterpreting it, but from here it looks to me that str() is doing what repr() used to do, and I'm really not sure that's a good thing. I would have expected that str(b'123') in Python 3 should do the same thing a

Re: Unable to write % character to a file using writelines() method

2008-09-28 Thread Christian Heimes
[EMAIL PROTECTED] wrote: Hi, I'm using the writelines() method to write some lines to a text file. But I'm unable to write the % character to the file using the following format: fdTolFile.writelines("\n\tdiff Not in %s '%' range" %(toleranceInPer))

Re: What is not objects in Python?

2008-09-28 Thread Christian Heimes
process wrote: What is not an object in Python? Everything that is not part of Python's syntax is an object, including all string and number types, classes, metaclasses, functions, models, code and more. It's technically not possible to have something like e.g. an int that isn't an object.

Re: Detecting dir (tree) changes fast?

2008-09-29 Thread Christian Heimes
support for IO notifications. For example pynotify on Linux, kqueue on BSD or ReadDirectoryChanges on Windows. You can also use polling and check the directories yourself every few seconds but that's expensive and doesn't scale. Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: OS.SYSTEM ERROR !!!

2008-09-30 Thread Christian Heimes
) Try this: import subprocess retval = subprocess.call( ['Myprogram.exe', '1', '1', 'acc', '0'], cwd='C:\myprogramfolder\run') Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: OS.SYSTEM ERROR !!!

2008-09-30 Thread Christian Heimes
large program or library. Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: Wait or not?

2008-10-01 Thread Christian Heimes
. It's going to take several months to years until the majority of 3rd party software supports the 3.x series. Christian -- http://mail.python.org/mailman/listinfo/python-list

Licensing question

2006-03-09 Thread Christian Ehrlicher
ode (apart from the calls to CreateFileMapping/MapViewOfFile) but it would be nice to see what problems you had so we don't need to investigate them once more... Thx, Christian -- Echte DSL-Flatrate dauerhaft für 0,- Euro*! "Feel free" mit GMX DSL! http://www.gmx.net/de/go/dsl --

Re: strange math?

2006-03-18 Thread Christian Stapfer
to my suprise, it yielded the result I expected. So, I tried > it again, and viola, the right answer. So, I decided to really try and > throw it for a loop, f(010), and it produced 50. I expected 52 > (42+10). Why doesn't python ignore the first zero and produce a result > of 52? That's because python interprets 010 as *octal* 10 which is *decimal* 8. Thus 42+010 = 42+8 = 50 which is quite as it should be... Regards, Christian -- http://mail.python.org/mailman/listinfo/python-list

Strange metaclass behaviour

2006-03-23 Thread Christian Eder
Hi, I think I have discovered a problem in context of metaclasses and multiple inheritance in python 2.4, which I could finally reduce to a simple example: Look at following code: class M_A (type) : def __new__ (meta, name, bases, dict) : print "M.__new__", meta, name, bases

Re: Strange metaclass behaviour

2006-03-23 Thread Christian Eder
Ziga Seilnacht wrote: > I hope that above explanation helps. > Thanks for your support. I now understand what happens here, but I'm not really happy with the situation. Your solution is a nice workaround, but in a quite huge and complex class framework with a lot a custom metaclasses you don't

Re: Strange metaclass behaviour

2006-03-23 Thread Christian Eder
Michele Simionato wrote: > Still, it is an interesting exercise if you are willing to risk the > melting of your brain, > so here is the code ;) I tried your code and it fixes the double execution, but the __new__ is executed in context of M_A instead of M_B which would be the more specific typ

Re: * for generic unpacking and not just for arguments?

2009-11-29 Thread Christian Heimes
998 (!!), but can't find a concise answer > as to why it is limited to args. The feature is available in Python 3.x: >>> a, b, *c = 1, 2, 3, 4, 5 >>> a, b, c (1, 2, [3, 4, 5]) >>> a, *b, c = 1, 2, 3, 4, 5 >>> a, b, c (1, [2, 3, 4], 5) Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: os.remove() permission problem

2009-11-30 Thread Christian Heimes
ory (x) and to modify (w) the directory entry. Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: Inspect module - getargspec raise TypeError for built-in functions

2009-12-01 Thread Christian Heimes
cessary metadata. Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: os.remove() permission problem

2009-12-01 Thread Christian Heimes
It's like in the real world. You may be allowed to modify a document (w permission on the file) but you may not be allowed to remove it from its cabinet (w permission on the directory). Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: "file" does not work with the "with" statement!

2009-12-10 Thread Christian Heimes
Michele Simionato wrote: > Python 2.5, but it could be an artifact of the way I am looking if a > file is closed. > I have subclassed the file builtin, added a .close method and it was > not called by the > "with" statement. This during debugging, but now I have found another > reason to explain wh

Re: insert unique data in a list

2009-12-15 Thread Christian Tismer
gt;> s1 == s2 True >>> d = {} >>> d[s1] = 3 >>> d[s2] = 5 >>> d {Set([1]): 3, Set([1]): 5} >>> Equality is kept for comparison, but what is it worth to hash them by id? On the original problem: You could turn you lists into tuples. This would be cle

Re: Which version of MSVC?90.DLL's to distribute with Python 2.6 based Py2exe executables?

2009-12-17 Thread Christian Heimes
ide-by-side assembly (SxS). You can't just copy a SxS assembly to another computer. You must at least ship the manifest file, too. The easiest way to get your program running is the installation of the MSVCR redistributable installer. Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: Python (and me) getting confused finding keys

2009-12-22 Thread Christian Heimes
ntimeError "dictionary changed size during iteration". With keys() you see the snapshot of edges's keys when keys() is called. Christian PS: Use "e in edges" instead of "edges.has_key(e)". It's faster. -- http://mail.python.org/mailman/listinfo/python-list

Re: IOError - cannot create file (linux daemon-invoked script)

2010-01-02 Thread Christian Heimes
? IIRC you have to set the effective user id with os.seteuid() and os.setegid(). Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: Writing a string.ishex function

2010-01-14 Thread Christian Heimes
gits) def ishex(s): return set(s).issubset(hexdigits) --- If you are also interested in the integer value of a hex string: --- def gethex(s): try: return int(s, 16) except ValueError: return None --- Check for "gethex(s) is not None" to see if s is a hex

Re: list.pop(0) vs. collections.dequeue

2010-01-22 Thread Christian Heimes
ternal array must be shifted. appending is much faster because the internal array is overallocated meaning it contains free slots at the tail of the data structure. A linked list of pointers requires more memory and iteration is slower since since it can't utilize the CPU's cache as good a

Re: list.pop(0) vs. collections.dequeue

2010-01-22 Thread Christian Heimes
gt; The pointer arithmetic for accessing each element would still work in O > (1), right? You mean it's an impossible trick unless you come up with your own memory management system. Realloc(), the standard function to change the size of chunk of allocated memory in C, doesn't support

Re: list.pop(0) vs. collections.dequeue

2010-01-22 Thread Christian Heimes
he implementation makes the implementation less memory hungry than a standard double linked list with just one element for each block. Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: list.pop(0) vs. collections.dequeue

2010-01-22 Thread Christian Heimes
ch effectively moves about a million bytes around for > no reason. The simplicity of Python is gained with some performance drawbacks. You have to learn to use Python algorithms. You can't simply re implement a fast C algorithm and expect it to be fast in Python, too. Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: list.pop(0) vs. collections.dequeue

2010-01-23 Thread Christian Heimes
Steve Howell wrote: > Another benchmark is that deques are slower than lists for accessing > elements. deques are optimized for accessing, inserting and removing data from both ends. For anything else it's slower than the list type. The fact was explained in this very thread yesterday.

Re: Default path for files

2010-01-24 Thread Christian Heimes
iple ways to modify the list of importable locations, either globally, for the current user or the current application. Use them wisely! Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: Broken Python 2.6 installation on Ubuntu Linux 8.04

2010-01-24 Thread Christian Heimes
thon with "make install", use "make altinstall"! Your /usr/local/bin/python binary masks the original python command in /usr/bin. You should remove all /usr/local/bin/py* binaries that do not end with 2.6. Otherwise you may and will break existing programs on your system. Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: myths about python 3

2010-01-27 Thread Christian Heimes
fy several issues in 3.0 beta while he was porting mod_wsgi to Python 3.0. (Personally I neither see MySQL as mission critical nor as a powerful RDBMS. Just try to combine foreign keys with triggers and you'll see what I'm talking about. *scnr*) Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 3.1 simplejson install

2010-01-29 Thread Christian Heimes
6 already have a JSON package called "json". Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: myths about python 3

2010-01-30 Thread Christian Heimes
didn't know that and I'm a Python core dev as well as a PSF member ... *scnr* Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: pep370 python 2.6?

2009-09-27 Thread Christian Heimes
Neal Becker wrote: > Is pep370 (per-user site-packages) available on 2.6? Yes -- http://mail.python.org/mailman/listinfo/python-list

Re: module path?

2009-10-06 Thread Christian Heimes
Dave Angel wrote: > The property is called __file__ > > So in this case,filename = settings.__file__ Actually it's an attribute set by Python's import machine. Since the __file__ attribute may contain a relative path it's a good idea to use os.path.abspath(__file_

Re: mktime, how to handle dates before 01-01-1970 ?

2009-10-06 Thread Christian Heimes
n.wikipedia.org/wiki/JDN) for dates long before or after the unix epoch. The conversion from JDN as float to a datetime object is trivial. Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: how to use WSGI applications with apache

2009-10-07 Thread Christian Heimes
Chris Colbert wrote: > if you want to use it with apapache, you need mod_wsgi. Or you can use mod_proxy alone or with mod_rewrite if you want to stick to the builtin webserver of cherrypy. Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: mktime, how to handle dates before 01-01-1970 ?

2009-10-07 Thread Christian Heimes
M.-A. Lemburg schrieb: > Christian Heimes wrote: >> Ben Finney wrote: >>> If you're committed to changing the epoch anyway, I would recommend >>> using http://en.wikipedia.org/wiki/Astronomical_year_numbering> >>> (epoch at 4004 BCE) since it is widel

Re: How to install 64-bit python on Ubuntu

2009-10-07 Thread Christian Heimes
ur Ubuntu installation is 32bit, too. You need a 64bit installation of Ubuntu in order to run a 64bit version of Python. By default Python is compiled in the same flavor as the OS. What does "uname -m" show? It should print "x86_64" for a 64bit version of Linux. --enable-universalsdk and --with-universal-archs have no function on Linux. They are Mac OS X only options. Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: No threading.start_new_thread(), useful addition?

2009-10-08 Thread Christian Heimes
ading framework. The is no good reason to use this function in favor of threading.Thread(). Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: No threading.start_new_thread(), useful addition?

2009-10-08 Thread Christian Heimes
f active thread doesn't work because threads started by thread.start_new_thread are invisible for the rest of the interpreter * you have to roll your own system to join a thread * probably more stuff In Python 3.0 the thread module has been renamed to _thread in order to reflect the nature of

Re: No threading.start_new_thread(), useful addition?

2009-10-08 Thread Christian Heimes
our tool box: def daemonthread(target, name=None, autostart=True, args=(), kwargs=None): """Start a thread as daemonic thread """ thread = Thread(target=target, name=name, args=args, kwargs=kwargs) thread.setDaemon(True) if autostart: thre

Re: Is there a better way to code variable number of return arguments?

2009-10-08 Thread Christian Heimes
s there a cleaner way to accomplish the same thing? You can simply "return result". If you want to make sure that you return a copy of the internal list, do "return list(result)" or "return tuple(result)". Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: No threading.start_new_thread(), useful addition?

2009-10-09 Thread Christian Heimes
d will lead to surprising and hard to debug bugs. A well designed application loads its modules first and then initializes its components explicitly. You don't want to fire up threads randomly! Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: What is the correct way to define __hash__?

2009-10-12 Thread Christian Heimes
of a tuple is based on the hash of its values. A common way to define a hash method is: def __hash__(self): return hash((self._a, self._b)) Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: id( ) function question

2009-10-14 Thread Christian Heimes
tegers, strings with one character and some other objects. It uses a free list for tuples, lists and dicts. This leads to effects like: >>> {} is {} False >>> id({}) == id({}) True Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: id( ) function question

2009-10-14 Thread Christian Heimes
be singletons, all builtin types and exceptions can be considered as singletons, too. Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: id( ) function question

2009-10-14 Thread Christian Heimes
to create two distinct dict objects. "id({}) == id({})" returns True under most circumstances because the reference count of the first dict drops to zero as soon as the id() function returns its memory address. The second call to id() retrieves the very same template from the dict type&#x

Re: id( ) function question

2009-10-15 Thread Christian Heimes
uot; doesn't return true because Python creates a new method wrapper for every attribute access: >>> class Example(object): ... def func(self): ... pass ... >>> Example.func >>> Example.func is Example.func False Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: Tracking down DLL load errors in Windows ?

2009-10-15 Thread Christian Heimes
Fred P wrote: > Is there any tool and/or methodology I could use to at least pinpoint the > exact DLL that libpyexiv2 is failing to load, and ideally also the reason > why ?... The depencency walker http://www.dependencywalker.com/ works fine for me. Christian -- http://mail.p

Re: How to schedule system calls with Python

2009-10-16 Thread Christian Heimes
mpty when it > tries to get a command, then it terminates. Threads aren't necessary here and the OP shouldn't use os.system() either. The subprocess module is superior and makes the solution much either without the need for threads. Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: restriction on sum: intentional bug?

2009-10-16 Thread Christian Heimes
instead] > > Of course it is not a good way to join strings, > but it should work, should it not? Naturally, It's not a bug. sum() doesn't work on strings deliberately. ''.join() *is* the right and good way to concatenate strings. Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: restriction on sum: intentional bug?

2009-10-16 Thread Christian Heimes
Alan G Isaac schrieb: > On 10/16/2009 3:40 PM, Tim Chase wrote: >> What's always wrong is giving me an *error* when the semantics are >> perfectly valid. > > > Exactly. > Which is why I expected this to be fixed in Python 3. It's not going to happen.

Re: restriction on sum: intentional bug?

2009-10-17 Thread Christian Heimes
Alan G Isaac wrote: > On 10/16/2009 5:03 PM, Christian Heimes wrote: >> It's not going to happen. > > That's a prediction, not a justification. It's not a prediction, it's a statement. It's not going to happend because it violates Guido's gut fe

Re: Reverse Iteration Through Integers

2009-10-18 Thread Christian Heimes
Benjamin Middaugh schrieb: > I'm trying to make an integer that is the reverse of an existing integer > such that 169 becomes 961. I guess I don't know enough yet to figure out > how to do this without a ton of awkward-looking code. I've tried for > loops without much success. I guess I need a g

Re: problem with pythonw.exe

2009-10-23 Thread Christian Heimes
cygwin for this application. Any idea as to what might be the problem? Windows GUI programs don't have any standard streams. stdin, stdout and stderr aren't attached so any print statement or traceback isn't shown. Could this explain the behavior? Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: Error building Python 2.6.3 and 2.6.4rc2

2009-10-24 Thread Christian Heimes
rror: 'module' object has no attribute 'lib' > make: *** [sharedmods] Error 1 You have a broken or malformed .pth file on your system. Add a line with "print fullname, line" right before "exec line" to debug your issue. Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: C++: Py_CompileString crash

2009-10-26 Thread Christian Heimes
Py_Finalize(); > system("PAUSE"); > return 0; > } > > On running, it immediately crashes. 0 is wrong here, see http://docs.python.org/c-api/veryhigh.html?highlight=py_compilestring#Py_CompileStringFlags Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: lmlx & & caracter

2009-10-27 Thread Christian Heimes
gt; product=firefox-3.5&os=win&lang=fr" /> > > > = > > i know that & is a special caracter in xml Because & has a special meaning in XML you have to quote a literal & as & Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: Are *.pyd's universal?

2009-10-29 Thread Christian Heimes
hitecture. Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: How to get a unique function name for methods

2009-10-29 Thread Christian Heimes
Philip Guo wrote: > Does anyone know how to get this information either from a code object or > from a related object? I am hacking the interpreter, so I have full access > to everything. Does this help? >>> class A(object): ... def method(self): ... pass ... >>> A.method.im_class >

Re: If a class Child inherits from Parent, how to implement Child.some_method if Parent.some_method() returns Parent instance ?

2009-10-29 Thread Christian Heimes
ass Egg(object): @classmethod def spam(cls): return cls(...) Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: Are *.pyd's universal?

2009-10-29 Thread Christian Heimes
Lawrence D'Oliveiro schrieb: > In message , Christian > Heimes wrote: > >> On Linux and several other Unices the suffix is .so and not .pyd. > > Why is that? Or conversely, why isn't it .dll under Windows? .so is the common suffix of shared libraries on Linux. I

Re: Firebird DBs use Kinterbasdb or sqlalchemy?

2009-10-30 Thread Christian Heimes
Jorge wrote: > Hi, > to access firebird data bases which shall I use kinterbasdb or sqlalchemy. You have to use kinterbasdb. SQLAlchemy is not a DBA but an ORM. Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: How convert string '1e7' to an integer?

2009-11-07 Thread Christian Heimes
Peng Yu wrote: > It seems that int() does not convert '1e7'. I'm wondering what > function to use to convert '1e7' to an integer? 1e7 is a way to express a float in science and math. Try float("1e7") Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: Threaded import hang in cPickle.dumps

2009-11-11 Thread Christian Heimes
at are referred inside your pickled data before you unpickle. Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: How can a module know the module that imported it?

2009-11-11 Thread Christian Heimes
nvironment, use a mock up system. Please read http://www.voidspace.org.uk/python/articles/mocking.shtml if you don't know the term. Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: python with echo

2009-11-12 Thread Christian Heimes
Diez B. Roggisch wrote: > with open("/sys/class/net/wlan1/device/tx_power", "w") as f: > f.write("%i" % POWER) IIRC the sys and proc virtual file system requires new line at the end of a modifier. At least echo appends \n unless it's told otherwis

Re: overriding __getitem__ for a subclass of dict

2009-11-15 Thread Christian Heimes
is the most important and speed critical type in Python it has some special behaviors. If you are going to overwrite __getitem__ of a dict subclass then you have to overwrite all methods that call __getitem__, too. These are get, pop, update and setdefault. Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: WindowsError is not available on linux?

2009-11-18 Thread Christian Heimes
ust catch OSError and you are on the safe side. Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: adding a directory to sys.path

2009-11-23 Thread Christian Heimes
> And it had no effect on sys.path when I ran Idle. See my blog posting: http://lipyrary.blogspot.com/2009/08/how-to-add-new-module-search-path.html Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: Relative versus absolute paths on Windows

2009-11-23 Thread Christian Heimes
uot;) True >>> ntpath.join("ignored", "\\bar") '\\bar' Posixpath follows the same rules, too. >>> posixpath.join("..", "egg", "/var") '/var' >>> posixpath.join("..", "egg", "var") '../egg/var' Christian -- http://mail.python.org/mailman/listinfo/python-list

Help with error on self.show

2009-11-25 Thread Christian Grise
n32.c:1089: SetWindowLong failed: Not enough storage is available to process this command. If anyone knows what this means, any info would be greatly appreciated. Thanks, Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: Modules failing to add runtime library path info at link time

2010-02-01 Thread Christian Heimes
uot;/path/to/library/dir" and you are good. Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: Optimized bytecode in exec statement

2010-02-01 Thread Christian Heimes
Terry Reedy wrote: > Currently, as far as I know, -0 just removes asserts. -O (not -0) also sets __debug__ to False. Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: new.instancemethod __iter__

2010-02-06 Thread Christian Heimes
ur class, you need to proxy the method call: class MyObject(object): def __iter__(self): return self.myiter() obj = MyObject() obj.myiter = myiter That should do the trick. Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: max / min / smallest float value on Python 2.5

2010-02-06 Thread Christian Heimes
floats. Python's float type is build upon C's double precision float type on both 32 and 64 bit builds. The simple precision 32bit float type isn't used. The DBL_MIN and DBL_MAX values are equal on all platforms that have full IEEE 754 float point support. The radix may be different, though. Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: ANN: obfuscate

2010-02-08 Thread Christian Heimes
eresting for everybody who has read Simon Sing's "The Code Book: The Science of Secrecy from Ancient Egypt to Quantum". Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: ANN: obfuscate

2010-02-09 Thread Christian Heimes
x27;t look like in Robert Harris "Fatherland" today. Oh, and we go computers, too. ;) Grab pycrypto, m2crypto or one of the other packages if you need a minimum amount of security. Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: ANN: obfuscate

2010-02-11 Thread Christian Heimes
Gregory Ewing wrote: > Actually I gather it had a lot to do with the fact that > the Germans made some blunders in the way they used the > Enigma that seriously compromised its security. There > was reportedly a branch of the German forces that used > their Enigmas differently, avoiding those mista

Re: Bizarre arithmetic results

2010-02-11 Thread Christian Heimes
nitude and the > variable version return a complex? The binary power operator has a higher precedence than the unary negative operator. -0.1 ** 0.1 is equal to -(0.1**0.1) Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: python crash on windows but not on linux

2010-02-12 Thread Christian Heimes
* > the information about the error is a windows dump. I suggest you install some sort of debugger on your system (e.g. Visual Studio) and do a post mortem analysis of your stack trace. Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: Python version of perl's "if (-T ..)" and "if (-B ...)"?

2010-02-12 Thread Christian Heimes
a -B file; otherwise it's a -T > file. Also, any file containing null in the first block is > considered a binary file. [ ... ] That's a butt ugly heuristic that will lead to lots of false positives if your text happens to be UTF-16 encoded or non-english tex

Re: Please help with MemoryError

2010-02-12 Thread Christian Heimes
mk wrote: > Hmm how about "call by label-value"? Or "call by guido"? How do you like "call like a dutch"? :] -- http://mail.python.org/mailman/listinfo/python-list

Re: MemoryError, can I use more?

2010-02-12 Thread Christian Heimes
mory. At least that's the story on Linux and several other Unix-like OSes. I'm not sure how Windows deals with memory. If your program needs more than 2 GB of RAM you should switch to a 64bit OS and a 64bit version of Python. Windows AMD64 builds for Python are available on python. C

Re: Fighting with subprocess.Popen

2010-02-14 Thread Christian Heimes
hell=True because the shell is not able to interpret the list form. It's recommended that you don't use shell=True unless you need a shell. Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: killing own process in windows

2010-03-07 Thread Christian Heimes
! You can terminate a Python process with os._exit() but I recommend that you find another way. os._exit() is a hard termination. It kills the process without running any cleanup code like atexit handlers and Python's internal cleanups. Open files aren't flushed to disk etc. Christ

Re: Use python and Jython together? (newbie)

2010-03-13 Thread Christian Heimes
thon and Python in one program. But you can use other means to create bindings for Java code. JCC (http://pypi.python.org/pypi/JCC/2.5.1) is a very powerful code generator for CPython. Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: How to add a library path to pythonpath ?

2010-03-16 Thread Christian Heimes
if and only if the path passed in "is a root". So MS stat() doesn't understand "/python/", and doesn't understand "d:" either. The former doesn't tolerate a (back)slash, while the latter requires one. Christian [1] http://mail.python.org/pipermail/python-bugs-list/2002-April/011099.html -- http://mail.python.org/mailman/listinfo/python-list

Re: datetime string conversion error

2010-03-16 Thread Christian Heimes
= datetime.strptime(date,"%Y-%m-%j %H:%M:%S.%f") > > print date > print olddate > > I get: > 2010-03-16 14:46:38.409137 > 2010-01-16 14:46:38.409137 > > notice the 01 in the second date from what I could tell everything is > formatted correctly. %j is documtend as

Re: Structure accessible by attribute name or index

2010-03-17 Thread Christian Heimes
Wes Santee wrote: > I am very new to Python, and trying to figure out how to create an > object that has values that are accessible either by attribute name, > or by index. For example, the way os.stat() returns a stat_result or > pwd.getpwnam() returns a struct_passwd. > > In trying to figure it

Re: What Does sys.platform Return On 64 Bit Windows Systems?

2010-03-17 Thread Christian Heimes
64bit build? >>> import struct >>> struct.calcsize("P") * 8 64 Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: How to automate accessor definition?

2010-03-21 Thread Christian Heimes
Steve Holden wrote: > You may well find that namedtuple is faster than what you put together > yourself, as the collections module is implemented in C. But namedtuple isn't, Steve. Namedtuple is a class generator that creates fast and efficient classes. -- http://mail.python.org/mailman/listinfo

Improved timedelta attributes/methods

2010-03-25 Thread Christian Ştefănescu
Hello dear Python-wielding developers! I generally like date/time handling in Python very much, especially how date operations result in Timedelta objects. But I find it somewhat impractical, that you can only get days, seconds and mi

Re: Don't understand behavior; instance form a class in another class' instance

2010-03-25 Thread Christian Heimes
ject as TEST2.__instance_one.one until you change where the label TEST2.__instance_one.one points to. Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: Cannot Remove File: Device or resource busy

2010-11-17 Thread Christian Heimes
le.close() on the other hand, fails to solve the problem. You have to close the file explicitly, for example with a proper with block. with open(outputFile, "rb") as fh: pdf_pypdf = PdfFileReader(fh) # process the PDF file here Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: is id(self) constant over an object lifetime ?

2010-12-03 Thread Christian Heimes
as it stays inside a single process. However if you use some sort of persistence layer like pickles or an IPC mechanism like multiprocessing the id is definitely not constant. If you need something stable, I suggest you look at the uuid module. Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: kinterbasdb error connection

2010-12-07 Thread Christian Heimes
permission of database: > $ls -l /media/VINACCIA.FDB > -rw-r--r-- 1 grappale grappale 1720320 2010-12-06 17:33 /media/VINACCIA.FDB > > Where am i wrong? Please. Thank you! Are you using classic mode or super mode? I have no experience with classic mode but for super mode, the fire

Re: Python creates "locked" temp dir

2010-12-08 Thread Christian Heimes
need a file with a name, use the NamedTemporaryFile feature of the tempfile module. Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: Python creates "locked" temp dir

2010-12-08 Thread Christian Heimes
want to share it then tempfile is not the right module > for you. There isn't a way to limit access to a single process. mkdtemp creates the directory with mode 0700 and thus limits it to the (effective) user of the current process. Any process of the same user is able to access the d

<    12   13   14   15   16   17   18   19   20   >