Python and RTF
Does anyone have a good rtf library for python, have exprience with pyRTF or a link to a good tutorial? thx Stephane -- http://mail.python.org/mailman/listinfo/python-list
cannot __getitem__ from DB reply list
Hi,
i have the following function:
def getGNUPlotInputFeaturesVersion(self):
s=""
bugCommits=0
trdocCommits=0
featCommits=0
ct=CommitType()
for version in self.releaseVersionsList_:
self.execQuery("SELECT
msg,prssedDevsFileNum,prssedMakesFileNum,prssedDocsFileNum,prssedGraphsFileNum
FROM Commit WHERE \
projVersion=\""+version+"\";");
for tuple in self.dbcursor_.fetchall():
print tuple
On the "print tuple" part, i get:
[EMAIL PROTECTED]:~/workspace/SVNLog2DB$ jython 2LaunchQueries.py
Connection established to database...
Traceback (innermost last):
File "2LaunchQueries.py", line 5, in ?
File "/home/kostas/workspace/SVNLog2DB/QueryExecutor.py", line 80, in
getGNUPlotInputFeaturesVersion
AttributeError: __getitem__
As far as i have read, this means, that there is a problem getting
something from the list, because it might be FOR EXAMPLE , that
"self.dbcursor_.fetchall()" doesn't return a list -i know it does.
However, i did a "print self.dbcursor_.fetchall()" and i got a huge list
of tuples...
Why can't i iterate the list? Any advice?
--
http://mail.python.org/mailman/listinfo/python-list
Re: distutils, extensions, and missing headers
Gary Jefferson wrote: > My setup.py (with extension) seems to work great for build and > install, but for bdist_rpm, compilation of the extension fails because > some of the headers needed to build the extension aren't in the bdist > tarball. > > I've tried adding a 'depends=[]' to the Extension definition with > these header files present, but they still don't get put in the > tarball. > > What's the key to getting headers or other [non-python] files included > in a bdist? Use the "headers" keyword to setup() to list the header files you want installed. For other files, it depends on where you need them to go. If you want the data files to be inside the package, you should use the "package_data" keyword. It was introduced in Python 2.4, so if you need to support pre-2.4 Pythons, there are recipes floating around to do so more nicely. http://docs.python.org/dist/node12.html For other things (and hopefully, you can live with package data), use "data_files": http://docs.python.org/dist/node13.html -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list
Re: Sets in Python
On Thu, 20 Sep 2007 03:46:08 +, prikar20 wrote:
> On Sep 19, 5:25 pm, Mark Dickinson <[EMAIL PROTECTED]> wrote:
>> On Sep 19, 7:26 pm, Karthik Gurusamy <[EMAIL PROTECTED]> wrote:
>>
>> > If I did, a = [10, 20] and I did d[a]= 'foo', then a.append(30).
>> > If dict complains key error on d[a] now, I won't be surprised. If I do
>> > d[[10, 20, 30]], I will be surprised if it doesn't find the item. Of
>> > course, in today's behavior the above is syntax error.
>>
>> It sounds as though you're proposing something like the following:
>>
>> >>> k = mylist([1, 2])
>> >>> d = {k : 'test'}
>> >>> d[k]
>> 'test'
>> >>> k.append(3)
>> >>> d[k]
>>
>> Traceback (most recent call last):
>> File "", line 1, in
>> KeyError: [1, 2, 3]
>>
>> So far, so good. But how do you explain the following to a confused
>> newcomer?
>>
>> >>> d.keys()
>> [[1, 2, 3]]
>> >>> k in d.keys()
>> True
>> >>> k in d
>> False
>> >>> d[k]
>>
>> Traceback (most recent call last):
>> File "", line 1, in
>> KeyError: [1, 2, 3]
>>
>> In other words, to repeat Sion Arrowsmith's question, what would you
>> expect d.keys() to return after a key of d has been modified?
>
> In the new model, it should be the value at the time of addition.
> That is [1,2] (not [1,2,3]). This does mean a copy of key in
> maintained internally in the dict.
A copy!? That has to be a deep copy. Which would make `dict`\s alot
slower and use more memory. Plus you can't store objects that can't be
copied anymore. That doesn't sound like a good trade off to me.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
Re: Google and Python
"TheFlyingDutchman" <[EMAIL PROTECTED]> wrote: > Around 2000 I heard that Google was using Python to some extent. Now I > see that Guido Van Rossum works for them as well as Alex Martellis 8< - - It seems that shortening "Alessandro" to "Alex" was not enough. I wonder if the Flying Dutchman is another van der Decker? - Hendrik -- http://mail.python.org/mailman/listinfo/python-list
Re: Tutorial or Example (or Tutorial) of Using Canvas to Producea Plot
"W. Watson" <[EMAIL PROTECTED]> wrote: > I'm just trying to get some feel for how canvas works. I'm about to modify a > program I use for meteor work. It uses canvas to display images, and I plan > to draw on the image. For example, I plan to draw compass headings on a > circle every 30 degrees. Just warming up to the task. Don't be surprised if you can't draw a full circle - I have never managed it, but 359.99 degrees works fine - Hendrik -- http://mail.python.org/mailman/listinfo/python-list
Re: Will Python 3.0 remove the global interpreter lock (GIL)
"Steven D'Aprano" <[EMAIL PROTECTED]> wrote: > > I think a better question is, how much faster/slower would Stein's code > be on today's processors, versus CPython being hand-simulated in a giant > virtual machine made of clockwork? This obviously depends on whether or not the clockwork is orange - Hendrik -- http://mail.python.org/mailman/listinfo/python-list
Re: os.popen and lengthy operations
On Thu, 20 Sep 2007 10:31:43 +0400, Dmitry Teslenko wrote: > I'm using os.popen to perform lengthy operation such as building some > project from source. > It looks like this: > def execute_and_save_output( command, out_file, err_file): > > import os > > def execute_and_save_output( command, out_file, err_file): > (i,o,e) = os.popen3( command ) > try: > for line in o: > out_file.write( line ) > > for line in e: > err_file.write( line ) > finally: > i.close() > o.close() > e.close() > > ... > execute_and_save_output( '', out_file, err_file) > > Problem is that script hangs on operations that take long to execute > and have lots of output such as building scripts. Your code reads from the process' stdout until there is nothin to read anymore and then from stderr. The process might output something to both. The output is buffered. And when the stderr buffer is full the process blocks until your application reads something from `e`. That's where the whole thing hangs. You wait for something on `o` and the process waits for you to read from `e` → deadlock. You have to use threads to read both `o` and `e` or the `select` module to look which file has something to read. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
Re: Sets in Python
On Sep 20, 6:02 am, Karthik Gurusamy <[EMAIL PROTECTED]> wrote:
> On Sep 19, 7:17 pm, Steven D'Aprano <[EMAIL PROTECTED]
>
[...]
> > (2) Allow the hash of mutable objects to change, which means you can use
> > mutable objects as keys in dicts but if you change them, you can no
> > longer find them in the dict. They'll still be there, using up memory,
> > but you can't get to them.
>
> In the new model, at the time of addition, you need to remember the
> key at that time. If it's a list, you make a copy of the items.
Eek! Barf! Gag me with a spoon! etc. etc. :-)
And you mean a deep-copy, not just a copy, right?
Or perhaps you were thinking of something like this (mdict ::= mutable
dict):
class mdict(dict):
def __setitem__(self, k, val):
super(mdict,self).__setitem__(`k`, val)
def __getitem__(self, k):
return super(mdict,self).__getitem__(`k`)
def __contains__(self, k):
return super(mdict,self).__contains__(`k`)
def keys(self):
return list(eval(k) for k in super(mdict,self).keys())
def __iter__(self):
for k in super(mdict,self).__iter__():
yield eval(k)
def items(self):
return list((eval(k),v) for k,v in super(mdict,self).items())
def __repr__(self):
items = ', '.join('%s: %s' % (k,repr(v)) for k,v in
self.items())
return '{' + items + '}'
I think it does what you want..?:
>>> m = mdict()
>>> a, b = [], [1,2]
>>> print m
{}
>>> m[a] = a
>>> m[b] = b
>>> m
{[1, 2]: [1, 2], []: []}
>>> m.keys()
[[1, 2], []]
>>> for k in m:
... m[k].append('foo')
...
>>> m
{[1, 2]: [1, 2, 'foo'], []: ['foo']}
>>> m.items()
[([1, 2], [1, 2, 'foo']), ([], ['foo'])]
>>> m.values()
[[1, 2, 'foo'], ['foo']]
>>> a in m
False
>>> a
['foo']
>>> b
[1, 2, 'foo']
>>> [] in m
True
>>> [1,2] in m
True
>>> m[{'key':['val']}] = 'this works too'
It'll work for all keys, k, where eval(`k`) == k, and repr(a) ==
repr(b) when a == b (I'm pretty sure the latter isn't always true for
dicts, although I haven't looked at the implementation.)
-- bjorn
--
http://mail.python.org/mailman/listinfo/python-list
Re: Sets in Python
On Sep 20, 9:50 am, thebjorn <[EMAIL PROTECTED]> wrote: it's bad form to reply to myself, I know, but > def __iter__(self): > for k in super(mdict,self).__iter__(): > yield eval(k) should probably be def __iter__(self): return (eval(k) for k in super(mdict,self).__iter__()) I'm still getting used to the power of generator expressions :-) -- bjorn -- http://mail.python.org/mailman/listinfo/python-list
Re: Google and Python
TheFlyingDutchman asked of someone: > Would you know what technique the custom web server uses > to invoke a C++ app No, I expect he would not know that. I can tell you that GWS is just for Google, and anyone else is almost certainly better off with Apache. > (ditto for Java and Python) CGI is supposed to be too slow > for large sites. Sort of. The more queries a site answers, the more benefit to reducing the per-request overhead. But if one thinks Google could not afford so much machine time: On average, a single query on Google reads hundreds of megabytes of data and consumes tens of billions of CPU cycles. http://labs.google.com/papers/googlecluster.html Another quote from that paper: We also produce all our software in-house [...] There's a saying in the Navy that there are three ways to do anything: the right way, the wrong way, and the Navy way. How does GWS invoke a Java app? The Google way. How does Google use Python? As their scripting-language of choice. A fine choice, but just a tiny little piece. Maybe Alex will disagree with me. In my short time at Google, I was uber-nobody. -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list
Python for NSLU2
Hello, I am Rafael Marin Perez, and work as a researcher in University of Murcia (Spain). We are using the Network Storage Link for USB2.0 (NSLU2) device to desploy a wireless sensor network (WSN). And I need to install a bootstrap-loader of MSP430 in my NSLU2 to transfer the compiled images to the nodes. This bootstrap work over python. Therefore, I'm trying to install and compile modules of python2.4 for the ARM architecture of NSLU2 device. But I don't get to compile correctly. I'm using the cross compiler: http://peter.korsgaard.com/articles/crosstool-armv5b-softfloat-gcc-3.3.4-glibc-2.2.5.tar.gz Any idea, How can I do this? Thanks for your help. Regards, Rafa. -- http://mail.python.org/mailman/listinfo/python-list
Re: super() doesn't get superclass
Ben Finney <[EMAIL PROTECTED]> writes: >> The definition of superclass is not the issue, the issue is >> "superclass *of which class*"? You expect super(A, self) to iterate >> only over superclasses of A, even when self is an instance of a >> subtype of A. > > Yes. Those are the specific parameters to the function call, so that > *is* what I expect. The specific parameters are a type and an instance. Those same parameters can and do allow for an implementation that accesses supertypes of type(self). That is in fact more logical; otherwise one could simply iterate over A.__bases__ and we wouldn't need an elaborate 'super' construct. Not iterating only over A's superclasses is the entire *point* of super. The only deficiency of super I see in this thread is incomplete documentation. -- http://mail.python.org/mailman/listinfo/python-list
Re: Using python to create windows apps that everyone can use?
On Sep 19, 9:46 pm, Simon Hibbs <[EMAIL PROTECTED]> wrote: > On 9/18/07, Thomas Harding <[EMAIL PROTECTED]> wrote: > > > Hi guys, sorry to post another topic on this, as I am aware that it > has > > already been posted a few times, but not with specifically what I > am looking > > for. I want an app that makes a gui interface for python (similar > to > > Microsoft visual studio or qt designer, not a code based one) and/ > or an app > > that can make this into a .exe that can be opened by any person on > any > > computer without python installed. > > For windows only, there's always Iron Python. This allows you to use > Visual Studio, the commercial or the express version, to create the > GUI in VB or C# and from that call Python code that does all the heavy > lifting. Any pointers to that. I might have to get started soon with Visual Studio, as our company *might* move to an all-windows development environment *sigh* /me still hopes that I can convince them that 1) developing on Linux is at all not too shabby, and that 2) Python is a great Language! ;) So far I am making good progress on point 2. :) > > I'd second the recommendation for QtDesigner if you want cross- > platform capability. > > Simon Hibbs -- http://mail.python.org/mailman/listinfo/python-list
Re: limiting memory consumption of Python itself or a dict in a Python program
Jonas Maurus wrote: > I want to write a Python program that receives messages via SMTP and > stores them in a dict or an array. For my purposes it would be > important that all received mail would be kept in RAM and not cached > out to disk. If a new message comes in that can't fit in the allocated > memory, a number of old messages would be discarded. > > As the server needs to have room for other tasks, I'd like to limit > the overall memory consumption to a certain amount. Since your data is all in one place, why not write a dict or list wrapper which keeps track of the total space of the items stored (using len on the strings)? It could automatically clean out old entries when the memory usage becomes too much. Jeremy -- Jeremy Sanders http://www.jeremysanders.net/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and RTF
On 20 Set, 09:01, Rufman <[EMAIL PROTECTED]> wrote: > Does anyone have a good rtf library for python, have exprience with > pyRTF or a link to a good tutorial? > > thx Stephane I have just used PyRtf to create a "report" with table and simple images. What is your question? Marco Bonifazi http://www.bonifazi.eu -- http://mail.python.org/mailman/listinfo/python-list
Re: Will Python 3.0 remove the global interpreter lock (GIL)
On 20 Sep, 00:59, TheFlyingDutchman <[EMAIL PROTECTED]> wrote: > > Paul it's a pleasure to see that you are not entirely against > complaints. Well, it seems to me that I'm usually the one making them. ;-) > The very fastest Intel processor of the last 1990's that I found came > out in October 1999 and had a speed around 783Mhz. Current fastest > processors are something like 3.74 Ghz, with larger caches. True, although you're paying silly money for a 3.8 GHz CPU with a reasonable cache. However, as always, you can get something not too far off for a reasonable sum. When I bought my CPU two or so years ago, there was a substantial premium for as little as 200 MHz over the 3.0 GHz CPU I went for, and likewise a 3.4 GHz CPU seems to be had for a reasonable price these days in comparison to the unit with an extra 400 MHz. Returning to the subject under discussion, though, one big difference between then and now is the availability of dual core CPUs, and these seem to be fairly competitive on price with single cores, although the frequencies of each core are lower and you have to decide whether you believe the AMD marketing numbers: is a dual 2.2 GHz core CPU "4200+" or not, for example? One can argue whether it's better to have two cores, especially for certain kinds of applications (and CPython, naturally), but if I were compiling lots of stuff, the ability to do a "make -j2" and have a decent speed-up would almost certainly push me in the direction of multicore units, especially if the CPU consumed less power. And if anyone thinks all this parallelism is just hypothetical, they should take a look at distcc to see a fairly clear roadmap for certain kinds of workloads. > Memory is also faster and larger. It appears that someone running a non-GIL > implementation of CPython today would have significantly faster > performance than a GIL CPython implementation of the late 1990's. > Correct me if I am wrong, but it seems that saying non-GIL CPython is > too slow, while once valid, has become invalid due to the increase in > computing power that has taken place. Although others have picked over these arguments, I can see what you're getting at: even if we take a fair proportion of the increase in computing power since the late 1990s, rather than 100% of it, CPython without the GIL would still faster and have more potential for further speed increases in more parallel architectures, rather than running as fast as possible on a "sequential" architecture where not even obscene amounts of money will buy you significantly better performance. But I don't think it's so interesting to consider this situation as merely a case of removing the GIL and using lots of threads. Let us return to the case I referenced above: even across networks, where the communications cost is significantly higher than that of physical memory, distributed compilation can provide a good performance curve. Now I'm not arguing that every computational task can be distributed in such a way, but we can see that some applications of parallelisation are mature, even mainstream. There are also less extreme cases: various network services can be scaled up relatively effectively by employing multiple processes, as is the UNIX way; some kinds of computation can be done in separate processes and the results collected later on - we do this with relational databases all the time. So, we already know that monolithic multithreaded processes are not the only answer. (Java put an emphasis on extensive multithreading and sandboxing because of the requirements of running different people's code side-by-side on embedded platforms with relatively few operating system conveniences, as well as on Microsoft Windows, of course.) If the programmer cost in removing the GIL and maintaining a GIL-free CPython ecosystem is too great, then perhaps it is less expensive to employ other, already well-understood mechanisms instead. Of course, there's no "global programmer lock", so everyone interested in doing something about removing the GIL, writing their own Python implementation, or whatever they see to be the solution can freely do so without waiting for someone else to get round to it. Like those more readily parallelisable applications mentioned above, more stuff can get done provided that everyone doesn't decide to join the same project. A lesson from the real world, indeed. Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: Mixin classes and single/multiple inheritance
On Thu, 20 Sep 2007 14:52:50 +1000, Ben Finney wrote: > Can you give a code example of how you think mixins should be > implemented in Python, assuming the absence of multiple inheritance? I'll take a shot at it... use automatic delegation to the mixin class. class Parrot(object): def fly(self): return "The parrot can fly short distances." def talk(self): return "I'm pining for the fjords." class Albatross(object): def fly(self): return "The albatross is known to fly enormous distances." # Now I want a talking Albatross, without using multiple inheritance. class TalkingAlbatross(Albatross): def __init__(self, *args, **kwargs): # avoid triggering __setargs__ self.__dict__['mixin'] = Parrot() # avoid using super() so Ben doesn't get cranky self.__class__.__base__.__init__(self, *args, **kwargs) def __getattr__(self, name): return getattr(self.mixin, name) def __hasattr__(self, name): return hasattr(self.mixin, name) def __delattr__(self, name): return delattr(self.mixin, name) def __setattr__(self, name, value): return setattr(self.mixin, name, value) Am I close? -- Steven. -- http://mail.python.org/mailman/listinfo/python-list
Re: [Tutor] Finding prime numbers
Shawn Milochik <[EMAIL PROTECTED]> wrote: > Any improvements anyone? >>> import gmpy >>> for x in range(3,1000,2): ... if gmpy.is_prime(x): ... print x,"is prime" ... 3 is prime 5 is prime 7 is prime [...] >>> gmpy.is_prime(2**607-1) 1 >>> gmpy.is_prime(2**608-1) 0 Cheating perhaps! Note is_prime will be a probabalistic test for large numbers... -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list
Re: compile for ARM
Paul Boddie <[EMAIL PROTECTED]> wrote: > On 19 Sep, 20:36, Paul McGuire <[EMAIL PROTECTED]> wrote: > The inquirer might also consider crosstool, which is good at building > cross-compilers for GNU/Linux targeting "Embedded Linux": > > http://www.kegel.com/crosstool/ > > As for building Python itself, searching the Python bug tracker for > "cross-compile" might provide some patches and advice: You could also do the build using qemu which can emulate an ARM system. Debian do a complete ARM userspace, so you can install that under qemu and do native builds. Cross compilers work well though - we build our app which has python embedded for ARM using a cross compiler running under debian. -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list
Killing A Process By PID
Hello Guys,
I've got some code here which I'm using to kill a process if it freezes.
However I have no real way of testing it as I can't force a freeze on my
application. So thought I would run the code past you lot to see if anything
jumps out as not being quite right.
Now, my main application when it starts creates a lock file containing its
process ID using the following code:
file('/var/lock/Application.lock', 'w').write(str(os.getpid()))
Which to be honest appears to run just fine, when I look in that file it
always contains the correct process ID, for instance, 3419 or something like
that. This application also writes a date stamp to a log file every 10
seconds or so, and it's this date stamp that I use to determine if the
application has crashed.
def doCheck():
try:
f = open('/pblue/new/Logs/Alive.log','r')
try:
timestamp = f.read()
finally:
f.close()
except Exception, e:
logging.error(str(e))
nowdatetime = timestuff.now()
filedatetime = timestuff.strptime(timestamp, '%Y-%m-%d %H:%M:%S')
if timestuff.RelativeDateTimeDiff(nowdatetime,filedatetime).minutes > 1:
killApplication()
def killApplication():
pid = file('/var/lock/Application.lock').read().strip()
if file('/proc/%s/cmdline' % pid).read().endswith('python'):
os.system('kill %s' % pid)
Now, this second script is run every minute on the system, the idea is to
check that time stamp file, and if it hasn't been updated in the past
minute, then kill the process, inittab can then pick it back up and it will
be as right as rain again. Now the problem is that I'm unable to test it
properly, and from what I've seen so far, when the app does freeze, the
process isn't being killed, which leads me to believe something isn't quite
right in my second script above.
Does anyone spot anything that sticks out? Or perhaps something I could be
doing a little better?
Thanks guys,
Rob
--
http://mail.python.org/mailman/listinfo/python-list
Re: Sets in Python
Karthik Gurusamy wrote: > On Sep 19, 7:17 pm, Steven D'Aprano <[EMAIL PROTECTED] > cybersource.com.au> wrote: >> On Wed, 19 Sep 2007 20:58:03 +, Karthik Gurusamy wrote: >>> While it's easy to explain the behavior, I think the decision to dis- >>> allow mutable items as keys is a bit arbitrary. There is no need for >>> dict to recompute hash >> What??? >> >> Of course it does. How else can it look up the key? Because it (somehow) >> just recognizes that it has seen the key before? How? By magic? > > You answered it yourself later. For a mapping service, hash is just > one way to do things. What you need is for each item in the > collection, a unique key. > How you go from the key to the value is not something a programmer > needs to know. > Your mind is set on thinking on hash alone and hence you don't see > beyond it. > There's a reason for that: the developers (and particularly Tim Peters) have, to use a phrase Tim is fond of "optimized the snot" out of dict, and the mechanism is fundamental to much of Python's internals. So don't expect to be able to tamper wiht it without adversely affectinf performance. >>> (first of all, a user doesn't even need to know >>> if underneath 'hashing' is used -- the service is just a mapping between >>> one item to another item). >> The user doesn't need to know the mechanism, but the dict does. Dicts are >> implemented as hash tables. I suppose they could be implemented as >> something else (what? linear lists? some sort of tree?) but the same >> considerations must be made: > > Oh yes. If the keys are all integers (or any set of items that can be > ordered), why not an avl. It has guaranteed O(log N) while a hash in > worst case is O(N). Why you want to tie yourself to the drawbacks of > one datastructure? Understand your goal is not to provide a hash; but > to provide a mapping service. > Possibly so, but the goals also include "excellent speed" and "as wide a set of keys as is (practically) possible". How would you suggest Python avoids "[tying itself] to the drawbacks of one data structure"? Implement different strategies according to the key values used? That'll surely speed things up, not. Python provides you with plenty of tools to implement optimized data structures for your own applications. Arguing for making them language primitives merely reveals your design inexperience. > > the dict must be able to find keys it has >> seen before. How is the dict supposed to recognise the key if the key has >> changed? >> >>> Since we know hashing is used, all that is needed is, a well-defined way >>> to construct a hash out of a mutable. "Given a sequence, how to get a >>> hash" is the problem. >> Nonsense. That's not the problem. The problem is how to get exactly the >> same hash when the sequence has changed. > > Yes, if you keep thinking hash is the only tool you got. > >> In other words, if you have two mutable objects M1 and M2, then you >> expect: >> > > No. I don't expect. I expect the hash to be different. Why do you keep > thinking it's the mappings responsibility to take care of a changing > key. > Because mappings must do precisely that. Do you actually know what a mapping *is*? >> hash(M1) == hash(M2) if and only if M1 and M2 are equal >> hash(M1) != hash(M2) if M1 and M2 are unequal >> >> but also: >> >> if M1 mutates to become equal to M2, hash(M1) must remain the same while >> still being different from hash(M2). >> >> That means that hash() now is a non-deterministic function. hash([1,2,3]) >> will vary according to how the list [1,2,3] was constructed! >> >> Obviously something has to give, because not all of these things are >> mutually compatible. >> >>> If later the given sequence is different, that's >>> not the dict's problem. >> Data structures don't have problems. Programmers do. And language >> designers with sense build languages that minimize the programmers >> problems, not maximize them. > > Yes, here you talk about a different goal altogether. Here comes the > 'arbitrary' part I mentioned. > >>> So if the list changes, it will result in a different hash and we will >>> get a hash-miss. I doubt this is in anyway less intuitive than dis- >>> allowing mutable items as keys. >> The choices for the language designer are: >> >> (1) Invent some sort of magical non-deterministic hash function which >> always does the Right Thing. > > Nope, just say if the new sequence is different, you don't find the > item in the dict. > >> (2) Allow the hash of mutable objects to change, which means you can use >> mutable objects as keys in dicts but if you change them, you can no >> longer find them in the dict. They'll still be there, using up memory, >> but you can't get to them. > > In the new model, at the time of addition, you need to remember the > key at that time. If it's a list, you make a copy of the items. > Right. Simple. And completely impractical. >> (3) Simply disallow mutable objects as keys. >> >> Alternative 1 is
Re: ONYX
On 19 Set, 21:02, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > > I don't know what's "onyx-style" xml, i'm not used to xml, so for me onyx is just a mess... http://www.onyx.com/Products/xml.asp > but if it's xml, any xml parser > will parse it, and any validating parser should be able to validate it > given the correct DTD. For example?where do I find a good validating parser? thanx again -- http://mail.python.org/mailman/listinfo/python-list
I MEANT ONIX.... [it was Re: ONYX]
i'm such a lame... i meant onix... not onyx... http://xml.coverpages.org/onix.html the questions remain the same ones... thanx On 20 Set, 12:01, [EMAIL PROTECTED] wrote: > On 19 Set, 21:02, Bruno Desthuilliers > > <[EMAIL PROTECTED]> wrote: > > > I don't know what's "onyx-style" xml, > > i'm not used to xml, so for meonyxis just a > mess...http://www.onyx.com/Products/xml.asp > > > but if it's xml, any xml parser > > will parse it, and any validating parser should be able to validate it > > given the correct DTD. > > For example?where do I find a good validating parser? > > thanx again -- http://mail.python.org/mailman/listinfo/python-list
AIX - Python - db2.py
Hi, I am getting the following error while installing PyDB2 package on AIX machine. So can anybody give me the requirements list and a procedure to install PyDb2 package on AIX. [EMAIL PROTECTED]:/home/xn75/PyDB2-1.1.0> python setup.py install Your DB2 root is: WARNING: it seems that you did not install 'Application Development Kit'. Compilation may fail. running install running build running build_py not copying DB2.py (output up-to-date) running build_ext building '_db2' extension cc_r -O -Iinclude -I/usr/local/include/python2.1 -c _db2_module.c -o build/temp.aix-5.3-2.1/_db2_module.o "_db2_module.c", line 24.10: 1506-296 (S) #include file not found. "_db2_module.c", line 25.10: 1506-296 (S) #include file not found. "_db2_module.c", line 47.9: 1506-046 (S) Syntax error. "_db2_module.c", line 52.11: 1506-045 (S) Undeclared identifier SQL_BIGINT. "_db2_module.c", line 52.33: 1506-026 (S) Number of initializers cannot be greater than the number of aggregate members. "_db2_module.c", line 53.11: 1506-045 (S) Undeclared identifier SQL_BINARY. "_db2_module.c", line 53.33: 1506-026 (S) Number of initializers cannot be greater than the number of aggregate members. "_db2_module.c", line 54.11: 1506-045 (S) Undeclared identifier SQL_BLOB. "_db2_module.c", line 54.33: 1506-026 (S) Number of initializers cannot be greater than the number of aggregate members. "_db2_module.c", line 55.11: 1506-045 (S) Undeclared identifier SQL_BLOB_LOCATOR. "_db2_module.c", line 55.33: 1506-026 (S) Number of initializers cannot be greater than the number of aggregate members. "_db2_module.c", line 56.11: 1506-045 (S) Undeclared identifier SQL_CHAR. "_db2_module.c", line 56.33: 1506-026 (S) Number of initializers cannot be greater than the number of aggregate members. "_db2_module.c", line 57.11: 1506-045 (S) Undeclared identifier SQL_CLOB. "_db2_module.c", line 57.33: 1506-026 (S) Number of initializers cannot be greater than the number of aggregate members. "_db2_module.c", line 58.11: 1506-045 (S) Undeclared identifier SQL_CLOB_LOCATOR. "_db2_module.c", line 58.33: 1506-026 (S) Number of initializers cannot be greater than the number of aggregate members. "_db2_module.c", line 59.11: 1506-045 (S) Undeclared identifier SQL_TYPE_DATE. "_db2_module.c", line 59.33: 1506-026 (S) Number of initializers cannot be greater than the number of aggregate members. "_db2_module.c", line 60.11: 1506-045 (S) Undeclared identifier SQL_DBCLOB. "_db2_module.c", line 60.33: 1506-026 (S) Number of initializers cannot be greater than the number of aggregate members. "_db2_module.c", line 61.11: 1506-045 (S) Undeclared identifier SQL_DBCLOB_LOCATOR. "_db2_module.c", line 61.33: 1506-026 (S) Number of initializers cannot be greater than the number of aggregate members. "_db2_module.c", line 62.11: 1506-045 (S) Undeclared identifier SQL_DECIMAL. "_db2_module.c", line 62.33: 1506-026 (S) Number of initializers cannot be greater than the number of aggregate members. "_db2_module.c", line 63.11: 1506-045 (S) Undeclared identifier SQL_DOUBLE. "_db2_module.c", line 63.33: 1506-026 (S) Number of initializers cannot be greater than the number of aggregate members. "_db2_module.c", line 64.11: 1506-045 (S) Undeclared identifier SQL_FLOAT. "_db2_module.c", line 64.33: 1506-026 (S) Number of initializers cannot be greater than the number of aggregate members. "_db2_module.c", line 65.11: 1506-045 (S) Undeclared identifier SQL_GRAPHIC. "_db2_module.c", line 65.33: 1506-026 (S) Number of initializers cannot be greater than the number of aggregate members. "_db2_module.c", line 66.11: 1506-045 (S) Undeclared identifier SQL_INTEGER. "_db2_module.c", line 66.33: 1506-026 (S) Number of initializers cannot be greater than the number of aggregate members. "_db2_module.c", line 67.11: 1506-045 (S) Undeclared identifier SQL_LONGVARCHAR. "_db2_module.c", line 67.33: 1506-026 (S) Number of initializers cannot be greater than the number of aggregate members. "_db2_module.c", line 68.11: 1506-045 (S) Undeclared identifier SQL_LONGVARBINARY. "_db2_module.c", line 68.33: 1506-026 (S) Number of initializers cannot be greater than the number of aggregate members. "_db2_module.c", line 69.11: 1506-045 (S) Undeclared identifier SQL_LONGVARGRAPHIC. "_db2_module.c", line 69.33: 1506-026 (S) Number of initializers cannot be greater than the number of aggregate members. "_db2_module.c", line 70.11: 1506-045 (S) Undeclared identifier SQL_NUMERIC. "_db2_module.c", line 70.33: 1506-026 (S) Number of initializers cannot be greater than the number of aggregate members. "_db2_module.c", line 71.11: 1506-045 (S) Undeclared identifier SQL_REAL. "_db2_module.c", line 71.33: 1506-026 (S) Number of initializers cannot be greater than the number of aggregate members. "_db2_module.c", line 72.11: 1506-045 (S) Undeclared identifier SQL_SMALLINT. "_db2_module.c", line 72.33: 1506-026 (S) Number of initializers cannot be greater than the number of aggregate members. "_db2_module.c", line
unittest tutorial
does anyone know some good tutorial for unittest? (with examples how unit work)? thank you -- http://mail.python.org/mailman/listinfo/python-list
Re: I MEANT ONIX.... [it was Re: ONYX]
[EMAIL PROTECTED] a écrit : (top-post corrected) > On 20 Set, 12:01, [EMAIL PROTECTED] wrote: >> On 19 Set, 21:02, Bruno Desthuilliers >> >> <[EMAIL PROTECTED]> wrote: >> >>> I don't know what's "onyx-style" xml, >> i'm not used to xml, so for meonyxis just a >> mess...http://www.onyx.com/Products/xml.asp > i'm such a lame... i meant onix... not onyx... > http://xml.coverpages.org/onix.html > > the questions remain the same ones... > > >>> but if it's xml, any xml parser >>> will parse it, and any validating parser should be able to validate it >>> given the correct DTD. >> For example?where do I find a good validating parser? First question : do you *really* need a validating parser ? Second question : did you try to google for "+Python +validating +XML +parser" -- http://mail.python.org/mailman/listinfo/python-list
Re: Sets in Python
On Sep 19, 10:58 pm, Bryan Olson <[EMAIL PROTECTED]> wrote: > Bad news: Python 3000 has no immutable type for byte-strings. > The new bytes type cannot serve for dict keys or set members. > Many things one would want to hash are unhashable -- for > example, the results of the hash functions in hashlib. Are you serious -- http://mail.python.org/mailman/listinfo/python-list
Re: Sets in Python
On Thu, 20 Sep 2007 04:02:03 +, Karthik Gurusamy wrote:
> On Sep 19, 7:17 pm, Steven D'Aprano <[EMAIL PROTECTED]
> cybersource.com.au> wrote:
>> On Wed, 19 Sep 2007 20:58:03 +, Karthik Gurusamy wrote:
>> > While it's easy to explain the behavior, I think the decision to dis-
>> > allow mutable items as keys is a bit arbitrary. There is no need for
>> > dict to recompute hash
>>
>> What???
>>
>> Of course it does. How else can it look up the key? Because it
>> (somehow) just recognizes that it has seen the key before? How? By
>> magic?
>
> You answered it yourself later. For a mapping service, hash is just one
> way to do things. What you need is for each item in the collection, a
> unique key.
And does the mapping get access to that unique key (the key's key)? It
can't keep a mapping of object:key, because if it could do that, it
wouldn't need the key, it could just keep object:payload.
Since the mapping can't know the key's key, it has to ask the key, and
that's what the __hash__ method does.
> How you go from the key to the value is not something a programmer needs
> to know.
You are correct. All you need to know is that in Python, you can't use
lists and sets as keys directly.
You only need to know about the details of the way dicts look up keys if
you are writing your own class, and you aren't happy with Python's
default hash for instance objects. It isn't a common task.
> Your mind is set on thinking on hash alone and hence you don't see
> beyond it.
No, these issues exist regardless of the implementation of the mapping.
Whether you use a hash table or a binary tree of some sort, or a linear
linked list, or a database, or folders in a filing cabinet.
The behaviour of mutable objects in a mapping is always problematic,
regardless of the mapping implementation.
>> > (first of all, a user doesn't even need to know if underneath
>> > 'hashing' is used -- the service is just a mapping between one item
>> > to another item).
>>
>> The user doesn't need to know the mechanism, but the dict does. Dicts
>> are implemented as hash tables. I suppose they could be implemented as
>> something else (what? linear lists? some sort of tree?) but the same
>> considerations must be made:
>
> Oh yes. If the keys are all integers (or any set of items that can be
> ordered), why not an avl. It has guaranteed O(log N) while a hash in
> worst case is O(N).
But both the best and average cases are O(1), which beats AVL trees by a
lot. Since dicts are used for Python's internals, they are HIGHLY
optimized and VERY fast. Their O(1) will beat the O(log N) of AVL trees
easily.
Hash tables can also use keys even if they can't be ordered: {1+2j: None}
> Why you want to tie yourself to the drawbacks of one
> datastructure? Understand your goal is not to provide a hash; but to
> provide a mapping service.
No, the goal of a good language designer is to provide the fastest, most
lightweight, simplest, most flexible mapping as a built-in. Any old slow,
heavyweight, complicated, inflexible mapping will not do the job. That
goal is best provided by a hash table.
If people want additional mappings as well, they can be added as
libraries. If those libraries are very useful, they can be added to the
standard library. If they are HUGELY useful, they will become built-ins.
AVL trees are not as flexible or fast as hash tables, and even if they
were, you would *still* need to resolve the difficulties that occur if
the keys mutate.
>> the dict must be able to find keys it has
>> seen before. How is the dict supposed to recognise the key if the key
>> has changed?
>>
>> > Since we know hashing is used, all that is needed is, a well-defined
>> > way to construct a hash out of a mutable. "Given a sequence, how to
>> > get a hash" is the problem.
>>
>> Nonsense. That's not the problem. The problem is how to get exactly the
>> same hash when the sequence has changed.
>
> Yes, if you keep thinking hash is the only tool you got.
Fine, let me re-word it in terms of an AVL.
Suppose you have two lists in an AVL:
L1 = [1, 2, 3]
L2 = [4, 5, 6]
M = avl((L1, True), (L2, False))
The tree M (for mapping) has L1 at the top of the tree, and L2 as the
right node.
But now, EVERY time ANY mutable object changes, Python has to check
whether it is a key in EVERY avl, and if so, re-built the tree. Otherwise
the tree can become corrupt because the AVL invariants are no longer true.
(Consider what happens if we say L1[0] = 999. Now L1 > L2. If you don't
reorder the avl, M[L2] cannot be reached except by an exhaustive search
of every node. That means it is no longer an AVL tree, just an inordered
tree. Might as well save memory and use a linear linked list.)
Needless to say, this will slow down Python just a tad.
Look, you can go back to the archives of 1993 when this was first
discussed. Nothing has changed since then. Mutable keys are still
problematic, regardless of the implementation, and the simplest
Re: Will Python 3.0 remove the global interpreter lock (GIL)
TheFlyingDutchman a écrit : (snip) > I am confused about the benefits/disadvantages of the "GIL removal". > Is it correct that the GIL is preventing CPython from having threads? > > Is it correct that the only issue with the GIL is the prevention of > being able to do multi-threading? http://docs.python.org/lib/module-thread.html http://docs.python.org/lib/module-threading.html -- http://mail.python.org/mailman/listinfo/python-list
Re: lxml and identification of elements in source
Laurent Pointal wrote: > I use lxml to parse a document, modify some elements in the tree, run > xinclude on it (thanks to Stefan Behnel for the pointer), and finally use > the data to feed my sax-aware tool. > > To report warnings/errors to the user (not related to XML itself, but to > things like missing source for a cross-reference by example), is there a > way to get the source-file and line/column of an element ? > > [note: these informations are available when lxml parse the source, but are > they kept anywhere in the document tree ?] The lxml mailing list is a good place to ask these questions - although having the name come up in c.l.py from time to time makes for some good advertising :) Elements have a "sourceline" property that returns the line the Element was parsed from. It returns None if the Element was created through the API. Also, lines may become meaningless when you merge documents, e.g. xincluded elements will refer to the line in the xincluded document, not some magically calculated line in the target document. The column is not stored for an Element after parsing is finished (no, we can't change that). You can call getroottree() on an Element to retrieve it's root ElementTree, which knows about the URL (and other things) in its docinfo property. Stefan -- http://mail.python.org/mailman/listinfo/python-list
Re: I MEANT ONIX.... [it was Re: ONYX]
[EMAIL PROTECTED] schrieb: > i'm such a lame... i meant onix... not onyx... > http://xml.coverpages.org/onix.html > > the questions remain the same ones... lxml is a validating parser for python. Diez -- http://mail.python.org/mailman/listinfo/python-list
writing to lists within a dictionary
I am trying to write a basic anagram system, that takes a text file
line by line and by sorting the string into its alphabetical form
compares it to keys within a dictionary.
If it matches a key I want to add it (in its unordered form) to a list
for that key.
So far this is what I have
import sys, string, fileinput
# takes an item (string) and converts it to its basic alphabetical
form
def getChar( item ):
item_chars = []
for i in range(len(item)):
item_chars.append(item[i])
item_chars.sort()
return string.join(item_chars, "")
anagramDict = {}
for line in fileinput.input("fakelist.txt"):
myLine = line.replace("\n", "") #remove the carriage returns
myString = getChar(myLine) #get the alphabetical form
for k in anagramDict.items(): #iterator through the keys in the
dictionary
if k[0] == myString: #if the key matches our string
anagramDict[k].append([myLine])#append that k and add
the value
this line
else:
anagramDict[myString] = [myLine] #else there is no key the same
so
make a new one
print anagramDict
--
http://mail.python.org/mailman/listinfo/python-list
Re: I MEANT ONIX.... [it was Re: ONYX]
On 20 Set, 12:55, Bruno Desthuilliers wrote:
>
> First question : do you *really* need a validating parser ?
>
that's what they told me ("they" being "da boss")... I mean: i have to
validate and to parse... i guess you can't do it at the same time, can
you?
> Second question : did you try to google for
>"+Python +validating +XML +parser"
I've already googled it, and found pyRXP... but I was looking for
someone/something already experienced with onix...
--
http://mail.python.org/mailman/listinfo/python-list
Re: I MEANT ONIX.... [it was Re: ONYX]
On 20 Set, 14:29, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > > lxml is a validating parser for python. > > Diez thank u, i'll take a look -- http://mail.python.org/mailman/listinfo/python-list
Re: I MEANT ONIX.... [it was Re: ONYX]
[EMAIL PROTECTED] schrieb:
> On 20 Set, 12:55, Bruno Desthuilliers [EMAIL PROTECTED]> wrote:
>
>> First question : do you *really* need a validating parser ?
>>
> that's what they told me ("they" being "da boss")... I mean: i have to
> validate and to parse... i guess you can't do it at the same time, can
> you?
>
>
>> Second question : did you try to google for
>>"+Python +validating +XML +parser"
>
> I've already googled it, and found pyRXP... but I was looking for
> someone/something already experienced with onix...
Well, it's XML with a DTD. Not much to see there. Nobody is going to
help you generate and/or process it, as the application is _very_
domain-specific and unlikely to have some pre-built support libs.
However, using python you should be in an excellent position to create
one for yourself - and maybe share, if "da boss" allows it.
Diez
--
http://mail.python.org/mailman/listinfo/python-list
Re: Using python to create windows apps that everyone can use?
On Sep 20, 10:08 am, "exhuma.twn" <[EMAIL PROTECTED]> wrote: > On Sep 19, 9:46 pm, Simon Hibbs <[EMAIL PROTECTED]> wrote: > > > > > On 9/18/07, Thomas Harding <[EMAIL PROTECTED]> wrote: > > > > Hi guys, sorry to post another topic on this, as I am aware that it > > has > > > already been posted a few times, but not with specifically what I > > am looking > > > for. I want an app that makes a gui interface for python (similar > > to > > > Microsoft visual studio or qt designer, not a code based one) and/ > > or an app > > > that can make this into a .exe that can be opened by any person on > > any > > > computer without python installed. > > > For windows only, there's always Iron Python. This allows you to use > > Visual Studio, the commercial or the express version, to create the > > GUI in VB or C# and from that call Python code that does all the heavy > > lifting. > > Any pointers to that. I might have to get started soon with Visual > Studio, as our company *might* move to an all-windows development > environment *sigh* > For an example of a *great* looking application written in IronPython, checkout Resolver: http://www.resolversystems.com :-) We create our dialogs with the Visual Studio designer (using the free Visual Studio Express) and then subclass them in IronPython to implement behaviour. For Windows development, Windows Forms is a great GUI library. For a reference to IronPython you could checkouit "IronPython in Action": http://www.manning.com/foord :-) Michael Foord http://www.ironpython.info/ > /me still hopes that I can convince them that 1) developing on Linux > is at all not too shabby, and that 2) Python is a great Language! ;) > > So far I am making good progress on point 2. :) > > > > > I'd second the recommendation for QtDesigner if you want cross- > > platform capability. > > > Simon Hibbs -- http://mail.python.org/mailman/listinfo/python-list
Re: AIX - Python - db2.py
On Thu, 2007-09-20 at 16:05 +0530, Shilavantar, Praveen wrote: > Hi, > > I am getting the following error while installing PyDB2 package on > AIX machine. > So can anybody give me the requirements list and a procedure to > install PyDb2 package on AIX. > > > [EMAIL PROTECTED]:/home/xn75/PyDB2-1.1.0> python setup.py install > Your DB2 root is: > WARNING: it seems that you did not install 'Application Development > Kit'. > Compilation may fail That warning message seems to be fairly clear about the requirements. Have you installed the DB2 Application Development Client? -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list
Re: how to convert xml file to word document.
prajwala wrote: >I want to convert xml file to a word document using python. Is > there > any built in module available? >or Is there any other way to convert xml file to word document. Insofar as it is textual, an xml file *is* a Word document. Just open it up in Word and see. I assume you mean something else, but at the moment you're not telling us what that is. TJG -- http://mail.python.org/mailman/listinfo/python-list
Re: Sets in Python
> Steven D'Aprano <[EMAIL PROTECTED]> (SD) wrote: >SD> In other words, if you have two mutable objects M1 and M2, then you >SD> expect: >SD> hash(M1) == hash(M2) if and only if M1 and M2 are equal >SD> hash(M1) != hash(M2) if M1 and M2 are unequal Huh? Unequal things may hash to the same value. That one of the essential properties of a hash function. -- Piet van Oostrum <[EMAIL PROTECTED]> URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4] Private email: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: frange() question
George Trojan wrote: > A while ago I found somewhere the following implementation of frange(): . . . > return (limit1 + n*increment for n in range(count)) > > I am puzzled by the parentheses in the last line. Somehow they make > frange to be a generator: > But I always thought that generators need a keyword "yield". What is > going on here? That's what's known as a generator expression: http://docs.python.org/ref/genexpr.html http://www.python.org/dev/peps/pep-0289/ TJG -- http://mail.python.org/mailman/listinfo/python-list
Re: frange() question
On Thu, 20 Sep 2007 09:08:17 -0400, George Trojan wrote: > A while ago I found somewhere the following implementation of frange(): > > def frange(limit1, limit2 = None, increment = 1.): > """ > Range function that accepts floats (and integers). Usage: > frange(-2, 2, 0.1) > frange(10) > frange(10, increment = 0.5) > The returned value is an iterator. Use list(frange) for a list. > """ > if limit2 is None: > limit2, limit1 = limit1, 0. > else: > limit1 = float(limit1) > count = int(math.ceil(limit2 - limit1)/increment) return (limit1 + > n*increment for n in range(count)) > > I am puzzled by the parentheses in the last line. Somehow they make > frange to be a generator: > >> print type(frange(1.0, increment=0.5)) > > But I always thought that generators need a keyword "yield". What is > going on here? > > George Consider the following: def foo(): yield 1 def bar(): return foo() Still, ``type(bar())`` would be a generator. I don't want to tell you anything wrong because I don't know how generators are implemented on the C level but it's more like changing foo's (or frange's, in your example) return value. HTH, Stargaming -- http://mail.python.org/mailman/listinfo/python-list
how to convert xml file to word document.
I want to convert xml file to a word document using python. Is there any built in module available? or Is there any other way to convert xml file to word document. Please suggest me. This is very urgent now. Thanks, prajwala -- http://mail.python.org/mailman/listinfo/python-list
frange() question
A while ago I found somewhere the following implementation of frange(): def frange(limit1, limit2 = None, increment = 1.): """ Range function that accepts floats (and integers). Usage: frange(-2, 2, 0.1) frange(10) frange(10, increment = 0.5) The returned value is an iterator. Use list(frange) for a list. """ if limit2 is None: limit2, limit1 = limit1, 0. else: limit1 = float(limit1) count = int(math.ceil(limit2 - limit1)/increment) return (limit1 + n*increment for n in range(count)) I am puzzled by the parentheses in the last line. Somehow they make frange to be a generator: >> print type(frange(1.0, increment=0.5)) But I always thought that generators need a keyword "yield". What is going on here? George -- http://mail.python.org/mailman/listinfo/python-list
Re: Will Python 3.0 remove the global interpreter lock (GIL)
On 9/19/07, TheFlyingDutchman <[EMAIL PROTECTED]> wrote: > On Sep 19, 5:08 pm, "Terry Reedy" <[EMAIL PROTECTED]> wrote: > > "Terry Reedy" <[EMAIL PROTECTED]> wrote in message > > This is a little confusing because google groups does not show your > original post (not uncommon for them to lose a post in a thread - but > somehow still reflect the fact that it exists in the total-posts > number that they display) that you are replying to. > > > > > > This assumes that comparing versions of 1.5 is still relevant. As far as I > > know, his patch has not been maintained to apply against current Python. > > This tells me that no one to date really wants to dump the GIL at the cost > > of half Python's speed. Of course not. The point of dumping the GIL is to > > use multiprocessors to get more speed! So with two cores and extra > > overhead, Stein-patched 1.5 would not even break even. > > > > Quad (and more) cores are a different matter. Hence, I think, the > > resurgence of interest. > > I am confused about the benefits/disadvantages of the "GIL removal". > Is it correct that the GIL is preventing CPython from having threads? > No. Python has threads, and they're wrappers around true OS level system threads. What the GIL does is prevent *Python* code in those threads from running concurrently. > Is it correct that the only issue with the GIL is the prevention of > being able to do multi-threading? > This sentence doesn't parse in a way that makes sense. > If you only planned on writing single-threaded applications would GIL- > removal have no benefit? > Yes. > Can threading have a performance benefit on a single-core machine > versus running multiple processes? > A simple question with a complicated answer. With the qualifier "can", I have to say yes to be honest although you will only see absolute performance increases on a single core from special purposed APIs that call into C code anyway - and the GIL doesn't effect those so GIL removal won't have an effect on the scalability of those operations. Pure CPU bound threads (all pure Python code) will not increase performance on a single core (there's CPU level concurrency that can, but not OS level threads). You can improve *perceived* performance this way (latency at the expense of throughput), but not raw performance. Very, very few operations are CPU bound these days, and even fewer of the ones were Python is involved. The largest benefits to the desktop user of multiple cores are the increase in cross-process performance (multitasking), not single applications. Servers vary more widely. However, in general, there's not a huge benefit to faster threading when you can use multiple processes instead. Python is not especially fast in terms of pure CPU time, so if you're CPU bound anyway moving your CPU bound code into C (or something else) is likely to reap far more benefits - and sidestepping the GIL in the process. In short, I think any problem that would be directly addressed by removing the GIL is better addressed by other solutions. > > So now this question for you: "CPython 2.5 runs too slow in 2007: true or > > false?" > > I guess I gotta go with Steven D'Aprano - both true and false > depending on your situation. > > > If you answer false, then there is no need for GIL removal. > > OK, I see that. > > > If you answer true, then cutting its speed for 90+% of people is bad. > > OK, seems reasonable, assuming that multi-threading cannot be > implemented without a performance hit on single-threaded applications. > Is that a computer science maxim - giving an interpreted language > multi-threading will always negatively impact the performance of > single-threaded applications? > It's not a maxim, per se - it's possible to have lockless concurrency, although when you do this it's more like the shared nothing process approach - but in general, yes. The cost of threading is the cost of the locking needed to ensure safety, and the amount of locking is proportional to the amount of shared state. Most of the common uses of threading in the real world do not improve absolute performance and won't no matter how many cores you use. > > > > | Most people are not currently bothered by the GIL and would not want its > > | speed halved. > > > > And another question: why should such people spend time they do not have to > > make Python worse for themselves? > > > Saying they don't have time to make a change, any change, is always > valid in my book. I cannot argue against that. Ditto for them saying > they don't want to make a change with no explanation. But it seems if > they make statements about why a change is not good, then it is fair > to make a counter-argument. I do agree with the theme of Steven > D'Aprano's comments in that it should be a cordial counter-argument > and not a demand. > > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
pdb attach?
Hello, please, is there something like 'attach' in pdb yet? My application uses threads and when it freezes (e.g. due to a deadlock situation), I'd like to get the traceback of all threads and inspect at which point did the application get into problems. Or could I send a signal to such a python process so that it would output backtraces from all threads before terminating? Because currently, if a thread runs into deadlock problems (or a thread fails on an exception and the other thread can't join it), I have no way of determining what went wrong. Such processes are not possible to terminate via CTRL-C in the interpreter, so I can't get the backtrace this way. Furthermore, I also need to debug subprocesses, so these are difficult to invoke interactively. I'm happy for any suggestions. Thank you, Hynek Hanke -- http://mail.python.org/mailman/listinfo/python-list
Re: unittest tutorial
Gigs_ <[EMAIL PROTECTED]> wrote: > does anyone know some good tutorial for unittest? (with examples > how unit work)? There is one in Dive into Python http://www.diveintopython.org/unit_testing/index.html Buy the book is my advice! -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list
Re: Freetype bindings, finally?
On 2007-09-19, Jason Yamada-Hanff <[EMAIL PROTECTED]> wrote: > Hi all, > I'm working on a project that would benefit very much from Python > Freetype2 bindings (the Fonty Python project). I don't want to > duplicate efforts and wrap the library again if we don't have to. > Interestingly, it seems like there have been lots of attempts at doing > this. I would like a freetype library as well, but neither have I done Python/C interfaces. If you have time to put into this, I would suggest starting a mailing list on the project, as well as continuing the discussion here. I would certainly susbscribe, and contribute as time and talent permit. -Bill -- Sattre Press Tales of War http://sattre-press.com/ by Lord Dunsany [EMAIL PROTECTED] http://sattre-press.com/tow.html -- http://mail.python.org/mailman/listinfo/python-list
pdb attach?
Hello, please, is there something like 'attach' in pdb yet? My application uses threads and when it freezes (e.g. due to a deadlock situation), I'd like to get the traceback of all threads and inspect at which point did the application get into problems. Or could I send a signal to such a python process so that it would output backtraces from all threads before terminating? Because currently, if a thread runs into deadlock problems (or a thread fails on an exception and the other thread can't join it), I have no way of determining what went wrong. Such processes are not possible to terminate via CTRL-C in the interpreter, so I can't get the backtrace this way. Furthermore, I also need to debug subprocesses, so these are difficult to invoke interactively. I'm happy for any suggestions. Thank you, Hynek Hanke -- http://mail.python.org/mailman/listinfo/python-list
Re: distutils, extensions, and missing headers
Robert, thanks for the help! On Sep 20, 1:22 am, Robert Kern <[EMAIL PROTECTED]> wrote: > > Use the "headers" keyword to setup() to list the header files you want > installed. I've tried "headers=['header1.h', 'header2.h']" in setup() as well as in Extension(), and neither seem to get the files into the bdist or bdist_rpm tarball. Am I doing it wrong? I can't seem to find any examples that use this via google. > For other files, it depends on where you need them to go. If you want the data > files to be inside the package, you should use the "package_data" keyword. It > was introduced in Python 2.4, so if you need to support pre-2.4 Pythons, there > are recipes floating around to do so more nicely. > > http://docs.python.org/dist/node12.html > > For other things (and hopefully, you can live with package data), use > "data_files": > > http://docs.python.org/dist/node13.html I also tried using data_files to get the headers included, but can't seem to get that to work either. No errors are reported for either method. Thanks, Gary -- http://mail.python.org/mailman/listinfo/python-list
Re: os.popen and lengthy operations
On 20 sep, 08:31, "Dmitry Teslenko" <[EMAIL PROTECTED]> wrote:
> I'm using os.popen to perform lengthy operation such as building some
> project from source.
> def execute_and_save_output( command, out_file, err_file):
> (i,o,e) = os.popen3( command )
You should consider using the higher-level "subprocess" module:
import subprocess
def run(command, output, error, bufsize=None):
popen = subprocess.Popen(command.split(), bufsize=bufsize,
stdout=output, stderr=error)
popen.communicate()
return popen.returncode
example:
create = lambda path: open(path, "w")
run("ls /etc/services abc", create("/tmp/output"), create("/tmp/
error"))
Check how to use the "bufsize" parameter in the docs:
http://docs.python.org/lib/node529.html
arnau
--
http://mail.python.org/mailman/listinfo/python-list
Lookup values from one table to another based on a value
If I wanted to accomplish looking up values from one table based on a value from another table or file, how would I go about doing this in Python? Would I build a dictionary or an array? exp: Table1: Site = 103 Lane = 2 Dir = ? # Get this from Table2 Table2: Site, Lane, Direction, 103, 1, 1 103, 2, 1 103, 3, 5 103, 4, 5 Normally in Access I would just use a Dlookup and be done with it, or use a Recordset in VB. Thanks guys. Kou -- http://mail.python.org/mailman/listinfo/python-list
Re: Will Python 3.0 remove the global interpreter lock (GIL)
On 2007-09-20, TheFlyingDutchman <[EMAIL PROTECTED]> wrote: > Is the only point in getting rid of the GIL to allow multi-threaded > applications? That's the main point. > Can't multiple threads also provide a performance boost versus > multiple processes on a single-core machine? That depends on the algorithm, the code, and the synchronization requirements. > OK, have to agree. Sounds like it could be a good candidate > for a fork. One question - is it a computer science maxim that > an interpreter that implements multi-threading will always be > slower when running single threaded apps? I presume you're referring to Amdahl's law. http://en.wikipedia.org/wiki/Amdahl's_law Remember there are reasons other than speed on a multi-processor platorm for wanting to do multi-threading. Sometimes it just maps onto the application better than a single-threaded solution. -- Grant Edwards grante Yow! I want you to MEMORIZE at the collected poems of visi.comEDNA ST VINCENT MILLAY ... BACKWARDS!! -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and RTF
On 2007-09-20, Rufman <[EMAIL PROTECTED]> wrote: > Does anyone have a good rtf library for python, pyRTF is the only one I found. > have exprience with pyRTF Yes. > or a link to a good tutorial? Just the examples that come with pyRTF. FWIW, I've added support for EMF graphics and enhanced the scaling options for graphics: http://groups.google.com/group/comp.lang.python.announce/browse_thread/thread/c56ccb0f65eae5da/e9997d47b4303547 -- Grant Edwards grante Yow! Uh-oh!! I'm having at TOO MUCH FUN!! visi.com -- http://mail.python.org/mailman/listinfo/python-list
Re: unittest tutorial
On Sep 20, 6:48 am, Gigs_ <[EMAIL PROTECTED]> wrote: > does anyone know some good tutorial for unittest? (with examples how unit > work)? > > thank you http://www.onlamp.com/pub/a/python/2005/02/03/tdd_pyunit2.html -- http://mail.python.org/mailman/listinfo/python-list
Re: super() doesn't get superclass
Michele Simionato <[EMAIL PROTECTED]> writes: > I am not against mixins (even if I am certainly very much against the > *abuse* of mixins, such as in Zope 2). What I would advocate (but I > realize that it will never happen in Python) is single inheritance + > mixins a la Ruby. Ruby might be a bad example here. Although the Ruby language syntax only supports single inheritance, mixins are implemented as multiple inheritance under the hood. That is, inheriting from a class and including a class as a mixin modifies the sub-/mixing class in exactly the same way. -Marshall -- http://mail.python.org/mailman/listinfo/python-list
Re: Will Python 3.0 remove the global interpreter lock (GIL)
Steven D'Aprano <[EMAIL PROTECTED]> writes: > That's why your "comparatively wimpy site" preferred to throw extra web > servers at the job of serving webpages rather than investing in smarter, > harder-working programmers to pull the last skerricks of performance out > of the hardware you already had. The compute intensive stuff (image rendering and crunching) has already had most of those skerricks pulled out. It is written in C and assembler (not by us). Only a small part of our stuff is written in Python: it just happens to be the part I'm involved with. > But Python speed ups don't come for free. For instance, I'd *really* > object if Python ran twice as fast for users with a quad-core CPU, but > twice as slow for users like me with only a dual-core CPU. Hmm. Well if the tradeoff were selectable at python configuration time, then this option would certainly be worth doing. You might not have a 4-core cpu today but you WILL have one soon. > What on earth makes you think that would be anything more than a > temporary, VERY temporary, shutdown? My prediction is that the last of > the machines wouldn't have even been unplugged Of course that example was a reductio ad absurdum. In reality they'd use the speedup to compute 2x as much stuff, rather than ever powering any servers down. Getting the extra computation is more valuable than saving the electricity. It's just easier to put a dollar value on electricity than on computation in an example like this. It's also the case for our specfiic site that our server cluster is in large part a disk farm and not just a compute farm, so even if we sped up the software infinitely we'd still need a lot of boxes to bolt the disks into and keep them spinning. > Now there's a thought... given that Google: > > (1) has lots of money; > (2) uses Python a lot; > (3) already employs both Guido and (I think...) Alex Martelli and > possibly other Python gurus; > (4) is not shy in investing in Open Source projects; > (5) and most importantly uses technologies that need to be used across > multiple processors and multiple machines > > one wonders if Google's opinion of where core Python development needs to > go is the same as your opinion? I think Google's approach has been to do cpu-intensive tasks in other languages, primarily C++. It would still be great if they put some funding into PyPy development, since I think I saw something about the EU funding being interrupted. -- http://mail.python.org/mailman/listinfo/python-list
Building Python with VC8 on x64 Vista
Hi all, So I'm working on a C++ application that will eventually embed or extend Python using Boost.Python, but I first need to get Python compiled correctly for my platform. I've got a Windows Vista 64-bit machine with a Core 2 processor, and I'm compiling with a VC8. I downloaded the Python 2.5.1 source from python.org, and I opened the Visual Studio solution file that was in the PCbuild8 directory. I created a new x64 platform and managed to successfully compile the 'pythoncore' and 'python' projects (both in Debug and Release configurations), resulting in working executables. (Aside: When launched, the python console says "Python 2.5.1 [MSC v.1400 64 bit (AMD64)] on win32" up top. Does that seem right?) So, this program I'm writing with Boost.Python (that worked correctly on x86 with home-built libraries) won't compile with these x64 libraries. I keep getting 'unresolved external symbols.' But, I'm certain I'm linking in the library correctly. Here's a snippet from the output (with /verbose:lib) when compiling: 1>Searching libraries 1> 1>Searching ..\..\..\3rdParty\boost_1_34_0\lib_x64\libboost_python- vc80-mt-gy-1_34.lib: 1> 1>Searching ..\..\..\3rdParty\Python25\libs_x64\python25_d.lib: 1>Finished searching libraries 1>py_dyn_test.obj : error LNK2001: unresolved external symbol _Py_NoneStruct 1>vector_py.obj : error LNK2001: unresolved external symbol _Py_NoneStruct 1>volume_py.obj : error LNK2001: unresolved external symbol _Py_NoneStruct 1>py_dyn_test.obj : error LNK2001: unresolved external symbol _Py_RefTotal 1>vector_py.obj : error LNK2001: unresolved external symbol _Py_RefTotal 1>volume_py.obj : error LNK2001: unresolved external symbol _Py_RefTotal 1>volume_py.obj : error LNK2001: unresolved external symbol PyExc_IndexError If I switch to the Release configuration, I see fewer errors: 1>py_dyn_test.obj : error LNK2001: unresolved external symbol _Py_NoneStruct 1>volume_py.obj : error LNK2001: unresolved external symbol PyExc_IndexError Note that none of my own code is Debug-specific. Also, the code in my files is correct, because (as stated above), it worked fine for x86. Though I don't know how useful it is, I did open the python libraries in wordpad, and though most of the file wasn't legible, I did find strings "Py_NoneStruct," "Py_RefTotal," and "PyExc_IndexError." I suspect that I set up my "x64" platform configuration incorrectly, or missed something. It's basically the same as the Win32 configuration, except with the /MACHINE:X64 flag instead of / MACHINE:X86. One of the things I'm noticing just now, as I post this, is that the preprocessor flag "WIN32" is still defined in the x64 configuration. Maybe if I change that to "WIN64," I'll have better luck. Any advice you have on what the "correct" way to do this is would be appreciated. -Dan -- http://mail.python.org/mailman/listinfo/python-list
Re: writing to lists within a dictionary
[EMAIL PROTECTED] wrote:
> I am trying to write a basic anagram system, that takes a text file
> line by line and by sorting the string into its alphabetical form
> compares it to keys within a dictionary.
>
> If it matches a key I want to add it (in its unordered form) to a list
> for that key.
>
> So far this is what I have
>
> import sys, string, fileinput
>
> # takes an item (string) and converts it to its basic alphabetical
> form
> def getChar( item ):
> item_chars = []
> for i in range(len(item)):
> item_chars.append(item[i])
> item_chars.sort()
> return string.join(item_chars, "")
>
> anagramDict = {}
>
> for line in fileinput.input("fakelist.txt"):
> myLine = line.replace("\n", "") #remove the carriage returns
> myString = getChar(myLine) #get the alphabetical form
> for k in anagramDict.items(): #iterator through the keys in the
> dictionary
> if k[0] == myString: #if the key matches our string
> anagramDict[k].append([myLine])#append that k and add
> the value
> this line
> else:
> anagramDict[myString] = [myLine] #else there is no key the same
> so
> make a new one
>
> print anagramDict
>
A few suggestions.
Use string methods, rather than the string module.
Replace getChar with a simple one-liner (check out the builtin 'sorted'
function).
Consider whether it's really necessary to iterate over all the
dictionary keys.
Check out the setdefault method of dictionaries.
Duncan
--
http://mail.python.org/mailman/listinfo/python-list
Re: Will Python 3.0 remove the global interpreter lock (GIL)
On 20 Sep 2007 07:43:18 -0700, Paul Rubin <"http://phr.cx"@nospam.invalid> wrote: > Steven D'Aprano <[EMAIL PROTECTED]> writes: > > That's why your "comparatively wimpy site" preferred to throw extra web > > servers at the job of serving webpages rather than investing in smarter, > > harder-working programmers to pull the last skerricks of performance out > > of the hardware you already had. > > The compute intensive stuff (image rendering and crunching) has > already had most of those skerricks pulled out. It is written in C > and assembler (not by us). Only a small part of our stuff is written > in Python: it just happens to be the part I'm involved with. > That means that this part is also unaffected by the GIL. > > But Python speed ups don't come for free. For instance, I'd *really* > > object if Python ran twice as fast for users with a quad-core CPU, but > > twice as slow for users like me with only a dual-core CPU. > > Hmm. Well if the tradeoff were selectable at python configuration > time, then this option would certainly be worth doing. You might not > have a 4-core cpu today but you WILL have one soon. > > > What on earth makes you think that would be anything more than a > > temporary, VERY temporary, shutdown? My prediction is that the last of > > the machines wouldn't have even been unplugged > > Of course that example was a reductio ad absurdum. In reality they'd > use the speedup to compute 2x as much stuff, rather than ever powering > any servers down. Getting the extra computation is more valuable than > saving the electricity. It's just easier to put a dollar value on > electricity than on computation in an example like this. It's also > the case for our specfiic site that our server cluster is in large > part a disk farm and not just a compute farm, so even if we sped up > the software infinitely we'd still need a lot of boxes to bolt the > disks into and keep them spinning. > I think this is instructive, because it's pretty typical of GIL complaints. Someone gives an example where the GIL is limited, but upon inspection it turns out that the actual bottleneck is elsewhere, that the GIL is being sidestepped anyway, and that the supposed benefits of removing the GIL wouldn't materialize because the problem space isn't really as described. > > Now there's a thought... given that Google: > > > > (1) has lots of money; > > (2) uses Python a lot; > > (3) already employs both Guido and (I think...) Alex Martelli and > > possibly other Python gurus; > > (4) is not shy in investing in Open Source projects; > > (5) and most importantly uses technologies that need to be used across > > multiple processors and multiple machines > > > > one wonders if Google's opinion of where core Python development needs to > > go is the same as your opinion? > > I think Google's approach has been to do cpu-intensive tasks in other > languages, primarily C++. It would still be great if they put some > funding into PyPy development, since I think I saw something about the > EU funding being interrupted. > -- At the really high levels of scalability, such as across a server farm, threading is useless. The entire point of threads, rather than processes, is that you've got shared, mutable state. A shared nothing process (or Actor, if you will) model is the only one that makes sense if you really want to scale because it's the only one that allows you to distribute over machines. The fact that it also scales very well over multiple cores (better than threads, in many cases) is just gravy. The only hard example I've seen given of the GIL actually limiting scalability is on single server, high volume Django sites, and I don't think that the architecture of those sites is very scalable anyway. -- http://mail.python.org/mailman/listinfo/python-list
Re: Will Python 3.0 remove the global interpreter lock (GIL)
"Chris Mellon" <[EMAIL PROTECTED]> writes: > No. Python has threads, and they're wrappers around true OS level > system threads. What the GIL does is prevent *Python* code in those > threads from running concurrently. Well, C libraries can release the GIL if they are written for thread safety, but as far as I know, most don't release it. For example I don't think cElementTree releases the GIL, and it's a huge CPU consumer in some of the code I run, despite being written in C pretty carefully. Also, many of the most basic builtin types (such as dicts) are implemented in C and don't release the GIL. > Very, very few operations are CPU bound these days, and even fewer of > the ones were Python is involved. The largest benefits to the desktop > user of multiple cores are the increase in cross-process performance > (multitasking), not single applications. If you add up all the CPU cycles being used by Python everywhere, I wonder how many of them are on desktops and how many are on servers. > Python is not especially fast in terms of pure CPU time, so > if you're CPU bound anyway moving your CPU bound code into C (or > something else) is likely to reap far more benefits - and sidestepping > the GIL in the process. If moving code into C is so easy, why not move all the code there instead of just the CPU-bound code? Really, coding in C adds a huge cost in complexity and unreliability. Python makes life a lot better for developers, and so reimplementing Python code in C should be seen as a difficult desperation measure rather than an easy way to get speedups. Therefore, Python's slowness is a serious weakness and not just a wart with an easy workaround. > In short, I think any problem that would be directly addressed by > removing the GIL is better addressed by other solutions. It does sound like removing the GIL from CPython would have very high costs in more than one area. Is my hope that Python will transition from CPython to PyPy overoptimistic? -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and RTF
On 20 Set, 16:40, Grant Edwards <[EMAIL PROTECTED]> wrote: > On 2007-09-20, Rufman <[EMAIL PROTECTED]> wrote: > > > Does anyone have a good rtf library for python, > > pyRTF is the only one I found. > > > have exprience with pyRTF > > Yes. > > > or a link to a good tutorial? > > Just the examples that come with pyRTF. > > FWIW, I've added support for EMF graphics and enhanced the > scaling options for graphics: > > http://groups.google.com/group/comp.lang.python.announce/browse_threa... > > -- > Grant Edwards grante Yow! Uh-oh!! I'm having > at TOO MUCH FUN!! >visi.com Oh, wonderful! Is licensed with the GPL and LGPL as like the previous versions are? Then, can I put in my closed software and at the end of my development make a donation? Marco Bonifazi -- http://mail.python.org/mailman/listinfo/python-list
Re: Python-list Digest, Vol 48, Issue 301
Hello, is there a way to do something like for i,j in l1, l2: print i,j ? Thanks in advance, Chris -- M.Sc. Christoph Scheit Institute of Fluid Mechanics FAU Erlangen-Nuremberg Cauerstrasse 4 D-91058 Erlangen Phone: +49 9131 85 29508 -- http://mail.python.org/mailman/listinfo/python-list
Re: Python-list Digest, Vol 48, Issue 301
Zip do what you want? Python 2.5 (r25:51918, Sep 19 2006, 08:49:13) [GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> l1 = [1,2,3,4,5] >>> l2 = ['a', 'b', 'c', 'd', 'e'] >>> for i,j in zip(l1, l2): ... print i,j ... 1 a 2 b 3 c 4 d 5 e >>> You can also do the same thing using itertools.izip, but it will return an iterator as opposed to building a new list. -Jeff On 9/20/07, Christoph Scheit <[EMAIL PROTECTED]> wrote: > Hello, > > is there a way to do something like > for i,j in l1, l2: > print i,j > > ? > Thanks in advance, > Chris > > -- > > > M.Sc. Christoph Scheit > Institute of Fluid Mechanics > FAU Erlangen-Nuremberg > Cauerstrasse 4 > D-91058 Erlangen > Phone: +49 9131 85 29508 > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: Finding prime numbers
On Sep 19, 1:31 pm, "Shawn Milochik" <[EMAIL PROTECTED]> wrote: > > If you'd just search the archives, you would have found this: > > >http://groups.google.com/group/comp.lang.python/browse_thread/thread/... > > Yeah, but that's no fun. ;o) Yes! Never do what you can fool others into doing for you. Mike -- http://mail.python.org/mailman/listinfo/python-list
os.path.getmtime() and compare with a date type
Hi, I am new to python and are tryint to write a simple program delete log files that are older than 30 days. So I used os.path.getmtime(filepath) and compare it with a date but it does not compile. threshold_time = datetime.date.today() - datetime.timedelta(days=30) mod_time = os.path.getmtime(file_path) if( mod_time < threshold_time): #delete file However the interpreter complains at the if line, say "can't comapre datetime.date to int How can I covert one of them to make it work? Thank you! -- http://mail.python.org/mailman/listinfo/python-list
Re: super() doesn't get superclass
On Sep 20, 4:31 pm, "Marshall T. Vandegrift" <[EMAIL PROTECTED]> wrote: > Michele Simionato <[EMAIL PROTECTED]> writes: > > I am not against mixins (even if I am certainly very much against the > > *abuse* of mixins, such as in Zope 2). What I would advocate (but I > > realize that it will never happen in Python) is single inheritance + > > mixins a la Ruby. > > Ruby might be a bad example here. Although the Ruby language syntax > only supports single inheritance, mixins are implemented as multiple > inheritance under the hood. That is, inheriting from a class and > including a class as a mixin modifies the sub-/mixing class in exactly > the same way. > > -Marshall The difference is that there is no cooperation, so you don't need to bang your head in order to understand the method resolution order. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list
Re: how to convert xml file to word document.
On Sep 20, 1:59 pm, prajwala <[EMAIL PROTECTED]> wrote: >I want to convert xml file to a word document using python. Is > there > any built in module available? >or Is there any other way to convert xml file to word document. > Please suggest me. This is very urgent now. > > Thanks, > prajwala XML to XHTML via XSLT ? - loads of X's but I'd slip Python and elementtree in there somewhere. - Paddy. -- http://mail.python.org/mailman/listinfo/python-list
Re: Finding prime numbers
On 9/20/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > On Sep 19, 1:31 pm, "Shawn Milochik" <[EMAIL PROTECTED]> wrote: > > > If you'd just search the archives, you would have found this: > > > > >http://groups.google.com/group/comp.lang.python/browse_thread/thread/... > > > > Yeah, but that's no fun. ;o) > > Yes! Never do what you can fool others into doing for you. > > Mike > Maybe for some people, but for me it's more fun to figure it out on my own. By the "no fun" part, I meant that it wouldn't be fun to just find the answer in an old thread instead of writing code to find primes myself. -- http://mail.python.org/mailman/listinfo/python-list
Re: Will Python 3.0 remove the global interpreter lock (GIL)
"Chris Mellon" <[EMAIL PROTECTED]> writes: > > The compute intensive stuff (image rendering and crunching) has > > already had most of those skerricks pulled out. It is written in C > > and assembler > That means that this part is also unaffected by the GIL. Right, it was a counterexample against the "speed doesn't matter" meme, not specifically against the GIL. And that code is fast because someone undertook comparatively enormous effort to code it in messy, unsafe languages instead of Python, because Python is so slow. > At the really high levels of scalability, such as across a server > farm, threading is useless. The entire point of threads, rather than > processes, is that you've got shared, mutable state. A shared nothing > process (or Actor, if you will) model is the only one that makes sense > if you really want to scale because it's the only one that allows you > to distribute over machines. The fact that it also scales very well > over multiple cores (better than threads, in many cases) is just > gravy. In reality you want to organize the problem so that memory intensive stuff is kept local, and that's where you want threads, to avoid the communications costs of serializing stuff between processes, either between boxes or between cores. If communications costs could be ignored there would be no need for gigabytes of ram in computers. We'd just use disks for everything. As it is, we use tons of ram, most of which is usually twiddling its thumbs doing nothing (as DJ Bernstein put it) because the cpu isn't addressing it at that instant. The memory just sits there waiting for the cpu to access it. We actually can get better-than-linear speedups by designing the hardware to avoid this. See: http://cr.yp.to/snuffle/bruteforce-20050425.pdf for an example. > The only hard example I've seen given of the GIL actually limiting > scalability is on single server, high volume Django sites, and I don't > think that the architecture of those sites is very scalable anyway. The stuff I'm doing now happens to work ok with multiple processes but would have been easier to write with threads. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python-list Digest, Vol 48, Issue 301
Christoph Scheit wrote: > Hello, > > is there a way to do something like > for i,j in l1, l2: > print i,j I'm assuming that l1 and l2 are in fact lists (or at least sequences). If that's the case: l1 = [1, 2, 3] l2 = ['a', 'b', 'c'] for i, j in zip (l1, l2): print i, j TJG -- http://mail.python.org/mailman/listinfo/python-list
Re: Lookup values from one table to another based on a value
[EMAIL PROTECTED] a écrit : > If I wanted to accomplish looking up values from one table based on a > value from another table or file, how would I go about doing this in > Python? Would I build a dictionary or an array? > > exp: > > Table1: > > Site = 103 > Lane = 2 > Dir = ? # Get this from Table2 > > Table2: > > Site, Lane, Direction, > 103, 1, 1 > 103, 2, 1 > 103, 3, 5 > 103, 4, 5 > > Normally in Access I would just use a Dlookup and be done with it, or > use a Recordset in VB. Thanks guys. What about using a database ? Like SQLite ? Else, the canonical data structure for quick lookups is of course the dict. -- http://mail.python.org/mailman/listinfo/python-list
Re: os.path.getmtime() and compare with a date type
[EMAIL PROTECTED] wrote: > Hi, > I am new to python and are tryint to write a simple program delete log > files that are older than 30 days. > > So I used os.path.getmtime(filepath) and compare it with a date but it > does not compile. > > threshold_time = datetime.date.today() - datetime.timedelta(days=30) > mod_time = os.path.getmtime(file_path) > > if( mod_time < threshold_time): > #delete file > > However the interpreter complains at the if line, say "can't comapre > datetime.date to int > > How can I covert one of them to make it work? > > Thank you! > > You are looking for datetime.datetime.fromtimestamp(mod_time) -- http://mail.python.org/mailman/listinfo/python-list
Re: Lookup values from one table to another based on a value
On Sep 20, 10:34 am, Bruno Desthuilliers wrote: > [EMAIL PROTECTED] a écrit : > > > > > > > If I wanted to accomplish looking up values from one table based on a > > value from another table or file, how would I go about doing this in > > Python? Would I build a dictionary or an array? > > > exp: > > > Table1: > > > Site = 103 > > Lane = 2 > > Dir = ? # Get this from Table2 > > > Table2: > > > Site, Lane, Direction, > > 103, 1, 1 > > 103, 2, 1 > > 103, 3, 5 > > 103, 4, 5 > > > Normally in Access I would just use a Dlookup and be done with it, or > > use a Recordset in VB. Thanks guys. > > What about using a database ? Like SQLite ? > > Else, the canonical data structure for quick lookups is of course the dict.- > Hide quoted text - > > - Show quoted text - Ah, yes, that would appear to be a better means to retrieve data. I visited the site, which version should I download? Thanks. Kou -- http://mail.python.org/mailman/listinfo/python-list
Re: os.path.getmtime() and compare with a date type
On Sep 20, 5:31 pm, [EMAIL PROTECTED] wrote: > Hi, > I am new to python and are tryint to write a simple program delete log > files that are older than 30 days. > > So I used os.path.getmtime(filepath) and compare it with a date but it > does not compile. > > threshold_time = datetime.date.today() - datetime.timedelta(days=30) > mod_time = os.path.getmtime(file_path) > > if( mod_time < threshold_time): > #delete file > > However the interpreter complains at the if line, say "can't comapre > datetime.date to int > > How can I covert one of them to make it work? > > Thank you! would putting it within int() work? I've not had much experience with time module, but I guess it must have a similar function... -- http://mail.python.org/mailman/listinfo/python-list
Re: os.path.getmtime() and compare with a date type
[EMAIL PROTECTED] wrote: > Hi, > I am new to python and are tryint to write a simple program delete log > files that are older than 30 days. > > So I used os.path.getmtime(filepath) and compare it with a date but it > does not compile. > > threshold_time = datetime.date.today() - datetime.timedelta(days=30) > mod_time = os.path.getmtime(file_path) > > if( mod_time < threshold_time): > #delete file > > However the interpreter complains at the if line, say "can't comapre > datetime.date to int > > How can I covert one of them to make it work? > > Thank you! > > You are looking for datetime.datetime.fromtimestamp(mod_time) -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and RTF
On 2007-09-20, Marco Bonifazi <[EMAIL PROTECTED]> wrote: >> FWIW, I've added support for EMF graphics and enhanced the >> scaling options for graphics: >> >> http://groups.google.com/group/comp.lang.python.announce/browse_threa... > Oh, wonderful! Is licensed with the GPL and LGPL as like the > previous versions are? Yes. > Then, can I put in my closed software and at the end of my > development make a donation? I'm really sure how the LGPL applies to Python applications. AFAICT, it's been abandoned by the original developer, so I doubt he's going to sue you. ;) If you fix any bugs or add any features, it would be nice if you'd send me a patch. -- Grant Edwards grante Yow! There's enough money at here to buy 5000 cans of visi.comNoodle-Roni! -- http://mail.python.org/mailman/listinfo/python-list
Re: Tutorial or Example (or Tutorial) of Using Canvas to Producea Plot
That's odd; however, it's likely close enough. Hendrik van Rooyen wrote: > "W. Watson" <[EMAIL PROTECTED]> wrote: > > >> I'm just trying to get some feel for how canvas works. I'm about to modify a >> program I use for meteor work. It uses canvas to display images, and I plan >> to draw on the image. For example, I plan to draw compass headings on a >> circle every 30 degrees. Just warming up to the task. > > Don't be surprised if you can't draw a full circle - I have never managed it, > but 359.99 degrees works fine > > - Hendrik > -- Wayne Watson (Nevada City, CA) Web Page: -- http://mail.python.org/mailman/listinfo/python-list
An Editor that Skips to the End of a Def
Is there an editor that allows one to position to put the cursor and then by pushing some button goes to the end of the def? -- Wayne Watson (Nevada City, CA) Web Page: -- http://mail.python.org/mailman/listinfo/python-list
Re: os.path.getmtime() and compare with a date type
Thanks, that works perfectly! On 9/20/07, Anthony Greene <[EMAIL PROTECTED]> wrote: > > [EMAIL PROTECTED] wrote: > > Hi, > > I am new to python and are tryint to write a simple program delete log > > files that are older than 30 days. > > > > So I used os.path.getmtime(filepath) and compare it with a date but it > > does not compile. > > > > threshold_time = datetime.date.today() - datetime.timedelta(days=30) > > mod_time = os.path.getmtime(file_path) > > > > if( mod_time < threshold_time): > > #delete file > > > > However the interpreter complains at the if line, say "can't comapre > > datetime.date to int > > > > How can I covert one of them to make it work? > > > > Thank you! > > > > > You are looking for datetime.datetime.fromtimestamp(mod_time) > -- http://mail.python.org/mailman/listinfo/python-list
Re: An Editor that Skips to the End of a Def
W. Watson a écrit : > Is there an editor that allows one to position to put the cursor and > then by pushing some button goes to the end of the def? Emacs. And you don't even have to "push some button" (just remember the correct key sequence !-) -- http://mail.python.org/mailman/listinfo/python-list
Re: An Editor that Skips to the End of a Def
"W. Watson" <[EMAIL PROTECTED]> writes: > Is there an editor that allows one to position to put the cursor and > then by pushing some button goes to the end of the def? C-M-e in emacs/python-mode. -- http://mail.python.org/mailman/listinfo/python-list
Re: Lookup values from one table to another based on a value
[EMAIL PROTECTED] a écrit : > On Sep 20, 10:34 am, Bruno Desthuilliers [EMAIL PROTECTED]> wrote: >> [EMAIL PROTECTED] a écrit : (snip) >>> Normally in Access I would just use a Dlookup and be done with it, or >>> use a Recordset in VB. Thanks guys. >> What about using a database ? Like SQLite ? > > Ah, yes, that would appear to be a better means to retrieve data. I > visited the site, which version should I download? Thanks. The latest, unless you have reasons to choose an old one !-) -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and RTF
On 2007-09-20, Grant Edwards <[EMAIL PROTECTED]> wrote: > I'm really sure how the LGPL applies to Python applications. That should have read I'm _not_ really sure how the LGPL applies to Python applications. There are clauses about providing a way for the user to replace the library and whatnot. I think that simply defining the API and allowing the user to replace the .pyc file would be sufficient. -- Grant Edwards grante Yow! ... or were you at driving the PONTIAC that visi.comHONKED at me in MIAMI last Tuesday? -- http://mail.python.org/mailman/listinfo/python-list
Re: super() doesn't get superclass
Steven D'Aprano wrote: > class super(object) > | super(type) -> unbound super object > | super(type, obj) -> bound super object; requires isinstance(obj, > | type) super(type, type2) -> bound super object; requires > | issubclass(type2, type) Typical use to call a cooperative > | superclass method: class C(B): > | def meth(self, arg): super(C, self).meth(arg) . . . but from the documentation on the website: super(type[, object-or-type]) Return the superclass of type. I do think this should be changed, since it really isn't true. It should probably say something like "return the next element after "type" in the MRO of "element-or-type". -- --OKB (not okblacke) Brendan Barnwell "Do not follow where the path may lead. Go, instead, where there is no path, and leave a trail." --author unknown -- http://mail.python.org/mailman/listinfo/python-list
Re: Sets in Python
On 2007-09-20, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: >> In the new model, it should be the value at the time of >> addition. That is [1,2] (not [1,2,3]). This does mean a copy >> of key in maintained internally in the dict. > > A copy!? That has to be a deep copy. Which would make > `dict`\s alot slower and use more memory. Plus you can't store > objects that can't be copied anymore. That doesn't sound like > a good trade off to me. Python's dict implementation is so deeply unorthoganal (is that a word?) to Python's basic assignment semantics and clever type hierarchy that it's hard to even sensibly promote anything other than the current implementation without completely redesigning Python. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list
Re: An Editor that Skips to the End of a Def
Thanks, but no thanks. The learning curve is way too steep. Paul Rudin wrote: > "W. Watson" <[EMAIL PROTECTED]> writes: > >> Is there an editor that allows one to position to put the cursor and >> then by pushing some button goes to the end of the def? > > C-M-e in emacs/python-mode. -- Wayne Watson (Nevada City, CA) Web Page: -- http://mail.python.org/mailman/listinfo/python-list
Re: Sets in Python
Steven D'Aprano wrote: > But of course you can't look up the dict by value, only by > identity. But that's what you wanted. Actually, if I understand the OP's examples right, he wants to look up only by value, not by identity. -- --OKB (not okblacke) Brendan Barnwell "Do not follow where the path may lead. Go, instead, where there is no path, and leave a trail." --author unknown -- http://mail.python.org/mailman/listinfo/python-list
Re: Sets in Python
On 9/20/07, Dustan <[EMAIL PROTECTED]> wrote: > On Sep 19, 10:58 pm, Bryan Olson <[EMAIL PROTECTED]> wrote: > > Bad news: Python 3000 has no immutable type for byte-strings. > > The new bytes type cannot serve for dict keys or set members. > > Many things one would want to hash are unhashable -- for > > example, the results of the hash functions in hashlib. > > Are you serious > It's a little Chicken Little. The current version of py3k has no immutable bytes type, but there's work being done even as we speak to implement it. -- http://mail.python.org/mailman/listinfo/python-list
Re: An Editor that Skips to the End of a Def
"W. Watson" <[EMAIL PROTECTED]> writes: > Thanks, but no thanks. The learning curve is way too steep. Up to you but, these days emacs comes with all sorts of pointing-clicky-menu-y type things - you don't really have to learn anything to get started. (It even gives useful advice on top-posting if you use it as a news client :/) -- http://mail.python.org/mailman/listinfo/python-list
Re: Sets in Python
On 9/20/07, OKB (not okblacke) <[EMAIL PROTECTED]> wrote: > Steven D'Aprano wrote: > > > But of course you can't look up the dict by value, only by > > identity. But that's what you wanted. > > Actually, if I understand the OP's examples right, he wants to look > up only by value, not by identity. > He's switched at least twice, as I understand his writing. Currently, he appears to want to look up by value, copying lists on insertion, and is ignoring what happens if you mutate the key. -- http://mail.python.org/mailman/listinfo/python-list
Tapping into the access of an int instance
Hi, Does anyone know how to interrupt the lookup of an integer value? I know I need to subclass int, since builtin types can't be altered directly... Below is how far I've come... What I want is to tap into the access of instance i's value 1... >>> class Int(int): def __init__(self, *a, **k): super(Int, self).__init__(self, *a, **k) >>> i = Int(1) >>> i 1 Regards, Tor Erik -- http://mail.python.org/mailman/listinfo/python-list
Re: python-mcrypt install on Mac OSX
On Sep 19, 2007, at 11:04 PM, Diez B. Roggisch wrote:
> Ahmad ㋡ Baitalmal schrieb:
>> Hi,
>> I'm having a hard time getting python-mcrypt extension to build.
>> I installed libmcrypt with --prefix=/usr and I checked that the
>> library
>> exists
>>
>> -rwxr-xr-x 1 root wheel352K Sep 19 16:53
>> /usr/lib/libmcrypt.4.4.8.dylib*
>> lrwxr-xr-x 1 root wheel 21B Sep 19 16:53
>> /usr/lib/libmcrypt.4.dylib@ -> libmcrypt.4.4.8.dylib
>> lrwxr-xr-x 1 root wheel 21B Sep 19 16:53
>> /usr/lib/libmcrypt.dylib@ -> libmcrypt.4.4.8.dylib
>> -rwxr-xr-x 1 root wheel801B Sep 19 16:53 /usr/lib/
>> libmcrypt.la*
>>
>> But this is the output from setting up python-mcrypt
>>
>> # python setup.py build
>> running build
>> running build_ext
>> building 'mcrypt' extension
>> creating build
>> creating build/temp.macosx-10.3-fat-2.5
>> gcc -arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk
>> -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd
>> -fno-common -dynamic -DNDEBUG -g -O3 -DVERSION="1.1" -I/usr/include
>> -I/Library/Frameworks/Python.framework/Versions/2.5/include/
>> python2.5 -c
>> mcrypt.c -o build/temp.macosx-10.3-fat-2.5/mcrypt.o
>> creating build/lib.macosx-10.3-fat-2.5
>> gcc -arch i386 -arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk -g
>> -bundle -undefined dynamic_lookup
>> build/temp.macosx-10.3-fat-2.5/mcrypt.o -lmcrypt -o
>> build/lib.macosx-10.3-fat-2.5/mcrypt.so
>> /usr/bin/ld: for architecture ppc
>> /usr/bin/ld: can't locate file for: -lmcrypt
>> collect2: ld returned 1 exit status
>> /usr/bin/ld: for architecture i386
>> /usr/bin/ld: can't locate file for: -lmcrypt
>> collect2: ld returned 1 exit status
>> lipo: can't open input file: /var/tmp//ccGRKjU2.out (No such file or
>> directory)
>> error: command 'gcc' failed with exit status 1
>>
>>
>> What am I missing here? I linked PHP with the same libmcrypt library
>> just fine. This is only happening for this extension only.
>
> Try setting the DYLD_LIBRARY_PATH might help. Or altering the setup.py
> to add -L/usr/lib.
>
> Diez
> --
> http://mail.python.org/mailman/listinfo/python-list
Nope, that didn't do it.
The first clue I got that something is wrong was that mcrypt.h could
not be found. Even though it exists in /usr/include. So I added the
include_dirs and library_dirs to setup.py
mcrypt=Extension(
"mcrypt",
sources=["mcrypt.c"],
include_dirs=['/usr/include'],
libraries=["mcrypt"],
library_dirs=["/usr/lib"],
define_macros=[("VERSION", '"%s"'%VERSION)]
)
setup(name="python-mcrypt",
version = VERSION,
description = "Python interface to mcrypt library",
author = "Gustavo Niemeyer",
author_email = "[EMAIL PROTECTED]",
license = "LGPL",
long_description = \
"""
Python interface to mcrypt library.
""",
ext_modules = [mcrypt],
)
I'm still getting the same output:
unning build
running build_ext
building 'mcrypt' extension
gcc -arch i386 -arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk -g
-bundle -undefined dynamic_lookup build/temp.macosx-10.3-fat-2.5/
mcrypt.o -L/usr/lib -lmcrypt -o build/lib.macosx-10.3-fat-2.5/mcrypt.so
/usr/bin/ld: for architecture ppc
/usr/bin/ld: can't locate file for: -lmcrypt
collect2: ld returned 1 exit status
/usr/bin/ld: for architecture i386
/usr/bin/ld: can't locate file for: -lmcrypt
collect2: ld returned 1 exit status
lipo: can't open input file: /var/tmp//ccqN4eHR.out (No such file or
directory)
error: command 'gcc' failed with exit status 1
It makes no sense, so I went to another brand new mac, installed
XCode and Python 2.5 and libmcrypt-2.5.8. I got the same results. So
I'm at a loss, how can ld not see libmcrypt.
I'm digging into disutils.sysconfig to see what is the build
environment that disutils is using.
Does anyone know how to build an extension manually? without using
distutils. If I can get it to build outside of distutils I might be
able to figure out what need to be done.
Thx
--
http://mail.python.org/mailman/listinfo/python-list
Internationalize a Tkinter application
I'm investigating the possibility of internationalizing a Tkinter application that I develop. Tcl/Tk provides facilities for internationalizing applications via its msgcat package, documented in "how-to" fashion below: http://www.tcl.tk/doc/howto/i18n.html As far as I can tell, Tkinter does not wrap the msgcat library. Instead I've found the gettext module in the Python standard library. Is this the preferred package for implementing localized strings in a Tkinter application, or am I missing something? -- Kevin Walzer Code by Kevin http://www.codebykevin.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Sets in Python
"Chris Mellon" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | On 9/20/07, Dustan <[EMAIL PROTECTED]> wrote: | > On Sep 19, 10:58 pm, Bryan Olson <[EMAIL PROTECTED]> wrote: | > > Bad news: Python 3000 has no immutable type for byte-strings. | > > The new bytes type cannot serve for dict keys or set members. | > > Many things one would want to hash are unhashable -- for | > > example, the results of the hash functions in hashlib. | > | > Are you serious | > | | It's a little Chicken Little. The current version of py3k has no | immutable bytes type, but there's work being done even as we speak to | implement it. To reinforce this comment: CPython3.0 will not be released for at least 9 months. The current 3.0.a1 is openly *experimental*. 3.0.a2 should be released within a few weeks with an invitation for anyone concerned with the final product to experiment with it. GvR's development strategy has been to start small and add what is clearly useful (rather than start large and trim). 3.0 is being trimmed bit. Where too much is trimmed, something can get added back. -- http://mail.python.org/mailman/listinfo/python-list
Re: distutils, extensions, and missing headers
Gary Jefferson wrote: > On Sep 20, 1:22 am, Robert Kern <[EMAIL PROTECTED]> wrote: >> Use the "headers" keyword to setup() to list the header files you want >> installed. > > I've tried "headers=['header1.h', 'header2.h']" in setup() as well > as in Extension(), and neither seem to get the files into the bdist or > bdist_rpm tarball. Am I doing it wrong? I can't seem to find any > examples that use this via google. You might need an accurate relative path. I'm assuming that you don't actually keep header1.h and header2.h in the top-level directory next to the setup.py. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list
Re: python-mcrypt install on Mac OSX
On Sep 19, 2007, at 11:04 PM, Diez B. Roggisch wrote: > Ahmad ㋡ Baitalmal schrieb: >> Hi, >> I'm having a hard time getting python-mcrypt extension to build. >> I installed libmcrypt with --prefix=/usr and I checked that the >> library >> exists >> >> -rwxr-xr-x 1 root wheel352K Sep 19 16:53 >> /usr/lib/libmcrypt.4.4.8.dylib* >> lrwxr-xr-x 1 root wheel 21B Sep 19 16:53 >> /usr/lib/libmcrypt.4.dylib@ -> libmcrypt.4.4.8.dylib >> lrwxr-xr-x 1 root wheel 21B Sep 19 16:53 >> /usr/lib/libmcrypt.dylib@ -> libmcrypt.4.4.8.dylib >> -rwxr-xr-x 1 root wheel801B Sep 19 16:53 /usr/lib/ >> libmcrypt.la* >> >> But this is the output from setting up python-mcrypt >> >> # python setup.py build >> running build >> running build_ext >> building 'mcrypt' extension >> creating build >> creating build/temp.macosx-10.3-fat-2.5 >> gcc -arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk >> -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd >> -fno-common -dynamic -DNDEBUG -g -O3 -DVERSION="1.1" -I/usr/include >> -I/Library/Frameworks/Python.framework/Versions/2.5/include/ >> python2.5 -c >> mcrypt.c -o build/temp.macosx-10.3-fat-2.5/mcrypt.o >> creating build/lib.macosx-10.3-fat-2.5 >> gcc -arch i386 -arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk -g >> -bundle -undefined dynamic_lookup >> build/temp.macosx-10.3-fat-2.5/mcrypt.o -lmcrypt -o >> build/lib.macosx-10.3-fat-2.5/mcrypt.so >> /usr/bin/ld: for architecture ppc >> /usr/bin/ld: can't locate file for: -lmcrypt >> collect2: ld returned 1 exit status >> /usr/bin/ld: for architecture i386 >> /usr/bin/ld: can't locate file for: -lmcrypt >> collect2: ld returned 1 exit status >> lipo: can't open input file: /var/tmp//ccGRKjU2.out (No such file or >> directory) >> error: command 'gcc' failed with exit status 1 >> >> >> What am I missing here? I linked PHP with the same libmcrypt library >> just fine. This is only happening for this extension only. > > Try setting the DYLD_LIBRARY_PATH might help. Or altering the setup.py > to add -L/usr/lib. > > Diez > -- > http://mail.python.org/mailman/listinfo/python-list Ok, I got it to work, but it still makes no sense. I had to install libmcrypt with --prefix=/usr/local. If I do it with --prefix=/usr then for some reason ld won't find it when building python-mcrypt. Obviously I had to also change the include_dirs and library_dirs in the setup.py file. I thought I'd share that so hopefully someone can explain what that's all about. Thx -- http://mail.python.org/mailman/listinfo/python-list
Re: Will Python 3.0 remove the global interpreter lock (GIL)
"Paul Rubin" <"http://phr.cx"@NOSPAM.invalid> wrote in message news:[EMAIL PROTECTED] | funding into PyPy development, since I think I saw something about the | EU funding being interrupted. As far as I know, the project was completed and promised funds paid. But I don't know of any major follow-on funding, which I am sure they could use. -- http://mail.python.org/mailman/listinfo/python-list
Re: Will Python 3.0 remove the global interpreter lock (GIL)
"Paul Rubin" <"http://phr.cx"@NOSPAM.invalid> wrote in message news:[EMAIL PROTECTED] | It does sound like removing the GIL from CPython would have very high | costs in more than one area. Is my hope that Python will transition | from CPython to PyPy overoptimistic? I presume you mean 'will the leading edge reference version transition... Or more plainly, "will Guido switch to PyPy for further development of Python?" I once thought so, but 1) Google sped the arrival of Py3.0 by hiring Guido with a major chunk of time devoted to Python development, so he started before PyPy was even remotely ready (and it still is not); and 2) PyPy did not focus only or specifically on being a CPython replacement but became an umbrella for a variety of experiment (including, for instance, a Scheme frontend). -- http://mail.python.org/mailman/listinfo/python-list
Re: Will Python 3.0 remove the global interpreter lock (GIL)
Ben Finney a écrit : (snip) > One common response to that is "Processes are expensive on Win32". My > response to that is that if you're programming on Win32 and expecting > the application to scale well, you already have problems that must > first be addressed that are far more fundamental than the GIL. Lol ! +1 QOTW ! -- http://mail.python.org/mailman/listinfo/python-list
