Entry widget -- how to prevent change

2005-11-22 Thread wanwan
let's say I already have some content. How do I set the widget so user cannot change it/? -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Stuart McGraw
"Fredrik Lundh" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Stuart McGraw wrote > > > > What would improve the Cheese Shop's interface for you? > > > > Getting rid of those damn top level links to old versions. > > Seeing a long list of old versions, when 99% of visitors are > >

PIL FITs image decoder

2005-11-22 Thread jbrewer
I'm trying to read in a FITs image file for my research, and I decided that writing a file decoder for the Python imaging library would be the easiest way to accomplish this for my needs. FITs is a raw data format used in astronomy. Anyway, I followed the example in the PIL documentation online,

Re: python win32 and COM? for internet monitoring

2005-11-22 Thread Graham Fawcett
Matthew Thorley wrote: > Greetings, I have a question I hope some one with more back ground can > give me a little help with. > > I want to write a simple internet monitoring script for windows that > watches out bound http traffic and keeps a list of all the site visited. > > I am thinking that I

Re: Entry widget -- how to prevent change

2005-11-22 Thread Grant Edwards
On 2005-11-22, wanwan <[EMAIL PROTECTED]> wrote: > let's say I already have some content. How do I set the widget so user > cannot change it/? Most widgets have some sort of "read-only" or "edit enable" attribute you can set. Look at the documentation for the widget in question. Since you don'

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Bengt Richter
On Tue, 22 Nov 2005 10:06:07 +0100, Christoph Zwerschke <[EMAIL PROTECTED]> wrote: >Bengt Richter schrieb: >> Ok, so if not in the standard library, what is the problem? Can't find what >> you want with google and PyPI etc.? Or haven't really settled on what your >> _requirements_ are? That seems

Re: Timeout for regular expression

2005-11-22 Thread Fredrik Lundh
<[EMAIL PROTECTED]> wrote > Is there a way to set a timeout interval when executing with a > re.search ? Sometimes (reason being maybe a "bad" pattern), > the search takes forever and beyond... not directly. the only reliable way is to run it in a separate process, and use the resource module to

Re: Dictionary string parser

2005-11-22 Thread Sebastjan Trepca
Wow, this helps a LOT! It's just what I needed, thank you very much! :) Sebastjan On 22/11/05, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Sebastjan Trepca wrote: > > > is there any library or some way to parse dictionary string with list, > > string and int objects into a real Python dictionary?

Re: Entry widget -- how to prevent change

2005-11-22 Thread Fredrik Lundh
"wanwan" <[EMAIL PROTECTED]> wrote: > let's say I already have some content. How do I set the widget so user > cannot change it/? assuming that you're talking about the Tkinter Entry widget, setting the state option to "readonly" should do the trick: e = Entry(...) e.config(state="reado

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Fredrik Lundh
Stuart McGraw wrote: > Hmm, so two versions means one is a development version, > and the other is a stable version? I did not know that, and did > not see it documented on the site. I would say documenting > that would be an interface improvement. well, that's up to the developer. when you up

Re: python win32 and COM? for internet monitoring

2005-11-22 Thread Matthew Thorley
Graham Fawcett wrote: > You might want to look into PCAP (a.k.a libpcap), which is the > network-sniffing libary used by Ethereal, among other programs. Much > more portable than COM, and there are Python wrappers for it, IIRC. > > You could also implement an HTTP proxy server in Python; Google s

Re: PIL FITs image decoder

2005-11-22 Thread Fredrik Lundh
"jbrewer" wrote: > I'm trying to read in a FITs image file for my research, and I decided > that writing a file decoder for the Python imaging library would be the > easiest way to accomplish this for my needs. FITs is a raw data format > used in astronomy. > > Anyway, I followed the example in t

wxPython Licence vs GPL

2005-11-22 Thread John Perks and Sarah Mount
we have some Python code we're planning to GPL. However, bits of it were cut&pasted from some wxPython-licenced code to use as a starting point for implementation. It is possible that some fragments of this code remains unchanged at the end. How should we refer to this in terms of copyright statem

Re: bsddb185 question

2005-11-22 Thread skip
thakadu> It seems it doesnt implement ALL of the dictionary interface thakadu> though. dir({}) yields many more methods than thakadu> dir(bsddb185.open(f)). So bsddb185 is missing many of the thakadu> methods that I am used to in bsddb. I mentioned some above that thakadu> ar

Re: PIL FITs image decoder

2005-11-22 Thread Robert Kern
jbrewer wrote: > I'm trying to read in a FITs image file for my research, and I decided > that writing a file decoder for the Python imaging library would be the > easiest way to accomplish this for my needs. FITs is a raw data format > used in astronomy. http://www.stsci.edu/resources/software_h

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Bengt Richter
On 22 Nov 2005 03:07:47 -0800, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > >Bengt Richter wrote: >> Ok, so if not in the standard library, what is the problem? Can't find what >> you want with google and PyPI etc.? Or haven't really settled on what your >> _requirements_ are? That seems to be

Re: PIL FITs image decoder

2005-11-22 Thread jbrewer
>http://www.stsci.edu/resources/software_hardware/pyfits I know and love PyFits, but I need to be able to do draw shapes on a FITs image (and perhaps some other operations), and I don't believe that PyFits allows these kinds of operations. It might be possible to import the data into a numarray o

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Bengt Richter
On Tue, 22 Nov 2005 10:26:22 +0100, Christoph Zwerschke <[EMAIL PROTECTED]> wrote: >Bengt Richter wrote: > > > d = OrderedDict(); d[1]='one'; d[2]='two' =>> list(d) => [1, 2] > > ok, now we do d[1]='ein' and what is the order? list(d) => [2, 1] ?? > > Or do replacements not count as "insertions"?

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Christoph Zwerschke
Alex Martelli wrote: > Perl's _arrays_ are a bit like Python _lists_, and ordered; it's the > _hashes_ that are a bit like Python _dicts_, and unordered. PHP's use > of "array" for both concepts may indeed be a bit confusing. Perl's _hashes_ have been also called _associative arrays_ original

Re: Hot to split string literals that will across two or more lines ?

2005-11-22 Thread Steve Holden
Paul McGuire wrote: > "Ben Finney" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > >>Xiao Jianfeng <[EMAIL PROTECTED]> wrote: >> >>>I need to print a long sting, which is two long so it must expand >>>two lines. >> >>How is this string being constructed in the source? If it exists

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Christoph Zwerschke
Fuzzyman schrieb: > Of course ours is ordered *and* orderable ! You can explicitly alter > the sequence attribute to change the ordering. What I actually wanted to say is that there may be a confusion between a "sorted dictionary" (one where the keys are automatically sorted) and an "ordered dic

Re: Embedded Python interpreter and sockets

2005-11-22 Thread wahn
Hi Chris, Thanks for your help. I'll try that ... Cheers, Jan -- http://mail.python.org/mailman/listinfo/python-list

Re: Hot to split string literals that will across two or more lines ?

2005-11-22 Thread Steve Holden
Paul McGuire wrote: > "Ben Finney" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > >>Xiao Jianfeng <[EMAIL PROTECTED]> wrote: >> >>>I need to print a long sting, which is two long so it must expand >>>two lines. >> >>How is this string being constructed in the source? If it exists

interact with application installer prompts using Python

2005-11-22 Thread [EMAIL PROTECTED]
I've written a script that automatically executes a set of Windows installers sequentially. For example, it will install Eudora, Firefox, SpyBot, etc. However, I still have to interact with the installer prompt windows. Is there anyway to programmatically interact with these prompt windows? I want

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Christoph Zwerschke
Bengt Richter wrote: > I'm mostly friendly ;-) I'm pretty sure you are :-) -- Chris -- http://mail.python.org/mailman/listinfo/python-list

Re: PIL FITs image decoder

2005-11-22 Thread Robert Kern
jbrewer wrote: >>http://www.stsci.edu/resources/software_hardware/pyfits > > I know and love PyFits, but I need to be able to do draw shapes on a > FITs image (and perhaps some other operations), and I don't believe > that PyFits allows these kinds of operations. It might be possible to > import

Re: bsddb185 question

2005-11-22 Thread thakadu
Ok but if you read my original post I already said that! The issue is that I have an application that needs to share data with an existing Berekeley db 1.85 database and applications in perl. Sure if I was creating the database myself I would use the newer bsddbmodule but I can't require the perl c

Re: interact with application installer prompts using Python

2005-11-22 Thread Zem
Some applications installers written with Installshield allow you to do silent installs. This requires that you create a response file to store all of your default answers. Check this link out, maybe it'll work for you. http://documentation.installshield.com/robo/projects/helplib/IHelpSetup_EXECm

Re: Any royal road to Bezier curves...?

2005-11-22 Thread Warren Francis
For my purposes, I think you're right about the natural cubic splines. Guaranteeing that an object passes through an exact point in space will be more immediately useful than trying to create rules governing where control points ought to be placed so that the object passes close enough to where

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Christoph Zwerschke
Bengt Richter wrote: > After finally reading that the odict.py in PyPI by Larosa/Foord was what was > desired, > but slower in use than what Fredrik posted, I decided to see if I could speed > up odict.py. > I now have a version that I think may be generally faster. Hm, I wouldn't formulate it t

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Carsten Haese
On Tue, 2005-11-22 at 13:37, Christoph Zwerschke wrote: > Would the default semantics below really be that suprising? > > "An ordered dictionary remembers the order in which keys are first seen > [...] Overwriting an entry replaces > its value, but does not affect its position in the key order.

Re: Controlling windows gui applications from python

2005-11-22 Thread Simon Brunning
On 21/11/05, tim <[EMAIL PROTECTED]> wrote: > Thanks for this tip, this looks like exactly what I need. > > Is there a more extended documentation for watsup somewhere ? Err, not a lot, no. > I didn't find info on: > how to send keystrokes to a program. You don't do that. WATSUP uses WinGuiAuto,

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Kay Schluehr
Bengt Richter wrote: > On Mon, 21 Nov 2005 01:27:22 +0100, Christoph Zwerschke <[EMAIL PROTECTED]> > wrote: > > >Fredrik Lundh wrote: > >> if you restructure the list somewhat > >> d = ( > >> ('pid', ('Employee ID', 'int')), > >> ('name', ('Employee name', 'varchar')), > >>

Re: the name of a module in which an instance is created?

2005-11-22 Thread Steven Bethard
Mardy wrote: > I'm not sure I got your problem correctly, however see if this helps: > > $ cat > test.py > class myclass: > name = __module__ > ^D > [snip] > > >>> import test > >>> a = test.myclass() > >>> a.name > 'test' > > This works, as we define "name" to be a class attribute. > Is th

Re: wxPython Licence vs GPL

2005-11-22 Thread Andrea Gavana
Hello John & Sarah, > (This assumes the wxPython Licence is compatible with the GPL -- if not, > do we just cosmetically change any remaining lines, so none remain from > the orignal?) IIRC, wxPython license has nothing to do with GPL. Its license is far more "free" than GPL is. If you want to cr

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Christoph Zwerschke
One implementation detail that I think needs further consideration is in which way to expose the keys and to mix in list methods for ordered dictionaries. In http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/107747 the keys are exposed via the keys() method which is bad. It should be a co

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Christoph Zwerschke
Magnus Lycka schrieb: >> I still believe that the concept of an "ordered dictionary" ("behave >> like dict, only keep the order of the keys") is intuitive and doesn't >> give you so much scope for ambiguity. > Sure. Others think so too. The problem is that if you and these other > people actual

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Christoph Zwerschke
>>def __init__(self, init_val = ()): >> dict.__init__(self, init_val) >> self.sequence = [x[0] for x in init_val] Fuzzyman wrote: > But that doesn't allow you to create an ordered dict from another > ordered dict. Right; I did not want to present a full implementation, just the rel

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Carsten Haese
On Tue, 2005-11-22 at 14:37, Christoph Zwerschke wrote: > In Foord/Larosa's odict, the keys are exposed as a public member which > also seems to be a bad idea ("If you alter the sequence list so that it > no longer reflects the contents of the dictionary, you have broken your > OrderedDict"). T

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Christoph Zwerschke
Carsten Haese schrieb: > I don't think it's intuitive if you can't describe it without > contradicting yourself. If the order of the keys really were the order > in which they were first seen by the dictionary, deleting and recreating > a key should maintain its original position. Admitted that de

Re: Converting a flat list to a list of tuples

2005-11-22 Thread Bengt Richter
On 22 Nov 2005 11:11:23 GMT, Duncan Booth <[EMAIL PROTECTED]> wrote: >metiu uitem wrote: > >> Say you have a flat list: >> ['a', 1, 'b', 2, 'c', 3] >> >> How do you efficiently get >> [['a', 1], ['b', 2], ['c', 3]] > >That's funny, I thought your subject line said 'list of tuples'. I'll >answer

Re: bsddb185 question

2005-11-22 Thread skip
thakadu> Ok but if you read my original post I already said that! Sure, I did. I was recapping what the purpose of the bsddb185 module is and why its API is not likely to change. thadaku> The issue is that I have an application that needs to share thakadu> data with an existing Ber

Re: best cumulative sum

2005-11-22 Thread Paul Rubin
Here's a silly recursive version (don't really use, it's too slow): def csum(s): if len(s)==0: return s return csum(s[:-1]) + [sum(s)] -- http://mail.python.org/mailman/listinfo/python-list

Re: Converting a flat list to a list of tuples

2005-11-22 Thread Bengt Richter
On Tue, 22 Nov 2005 13:26:45 +0100, "Fredrik Lundh" <[EMAIL PROTECTED]> wrote: >Duncan Booth wrote: > >> That's funny, I thought your subject line said 'list of tuples'. I'll >> answer the question in the subject rather than the question in the body: >> >> >>> aList = ['a', 1, 'b', 2, 'c', 3] >> >

Re: Converting a flat list to a list of tuples

2005-11-22 Thread Bengt Richter
On Tue, 22 Nov 2005 13:37:06 +0100, =?ISO-8859-1?Q?Andr=E9?= Malo <[EMAIL PROTECTED]> wrote: >* Duncan Booth <[EMAIL PROTECTED]> wrote: > >> metiu uitem wrote: >> >> > Say you have a flat list: >> > ['a', 1, 'b', 2, 'c', 3] >> > >> > How do you efficiently get >> > [['a', 1], ['b', 2], ['c', 3]

Re: Looking for magic method to override to prevent dict(d) from grabbing subclass inst d contents directly

2005-11-22 Thread Bengt Richter
On Tue, 22 Nov 2005 09:30:49 -0500, Mike Meyer <[EMAIL PROTECTED]> wrote: >[EMAIL PROTECTED] (Bengt Richter) writes: >> Has anyone found a way besides not deriving from dict? >> Shouldn't there be a way? >> TIA >> (need this for what I hope is an improvement on the Larosa/Foord OrderedDict >> ;-)

Comp.Lang.Python Podcase

2005-11-22 Thread [EMAIL PROTECTED]
This is very experimental but here is a http://www.latedecember.com/sites/pythonpod/podcast.xml";>comp.lang.python Podcast. The backend is Python of course via PyTTS. It should be updated daily. Happy Listening! Comments welcome. Davy Mitchell Mood News - BBC News Headlines Auto-Classified as

Re: Hot to split string literals that will across two or more lines ?

2005-11-22 Thread Dave Hansen
On Tue, 22 Nov 2005 18:38:15 + in comp.lang.python, Steve Holden <[EMAIL PROTECTED]> wrote: [...] > >Of course there's also the alternative of escaping the newlines out in >the literal. The replace result above is exactly > >"""\ >lots of text hundreds of characters long\ >more text on anothe

Re: Embedded Python interpreter and sockets

2005-11-22 Thread wahn
Hey Chris, I fixed the problem in another way (don't ask me why that works). One detail I didn't talk about is that I use the Boost.Python library. So I just made sure that I load the socket module before I import my own Python script (using that socket module): ... object main_module((handle<>

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Christoph Zwerschke
Carsten Haese wrote: > That could easily be fixed by making the sequence a "managed property" > whose setter raises a ValueError if you try to set it to something > that's not a permutation of what it was. Ok, a managed attribute would be an option. You would allow people to do what they want wi

2.4.2 on AIX 4.3 make fails on threading

2005-11-22 Thread Paul Watson
When I try to build 2.4.2 on AIX 4.3, it fails on missing thread objects. I ran ./configure --without-threads --without-gcc. Before using --without-threads I had several .pthread* symbols missing. I do not have to have threading on this build, but it would be helpful if it is possible. The

Re: matching a string to extract substrings for which some function returns true

2005-11-22 Thread Mike Meyer
Amit Khemka <[EMAIL PROTECTED]> writes: > Well actually the problem is I have a list of tuples which i cast as > string and then > put in a html page as the value of a hidden variable. And when i get > the string again, > i want to cast it back as list of tuples: > ex: > input: "('foo', 1, 'foobar'

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Christoph Zwerschke
>>I still believe that the concept of an "ordered dictionary" ("behave >>like dict, only keep the order of the keys") is intuitive and doesn't >>give you so much scope for ambiguity. But probably I need to work on an >>implementation to become more clear about possible hidden subtleties. Bengt

Re: Converting a flat list to a list of tuples

2005-11-22 Thread Bengt Richter
On Tue, 22 Nov 2005 14:28:56 GMT, "David Isaac" <[EMAIL PROTECTED]> wrote: > >"Duncan Booth" <[EMAIL PROTECTED]> wrote in message >news:[EMAIL PROTECTED] >> >>> aList = ['a', 1, 'b', 2, 'c', 3] >> >>> it = iter(aList) >> >>> zip(it, it) >> [('a', 1), ('b', 2), ('c', 3)] > >That behavior is current

Re: Converting a flat list to a list of tuples

2005-11-22 Thread Dave Hansen
On Tue, 22 Nov 2005 20:12:52 GMT in comp.lang.python, [EMAIL PROTECTED] (Bengt Richter) wrote: >On Tue, 22 Nov 2005 13:26:45 +0100, "Fredrik Lundh" <[EMAIL PROTECTED]> wrote: > >>Duncan Booth wrote: >> >>> That's funny, I thought your subject line said 'list of tuples'. I'll >>> answer the questio

Re: wxPython Licence vs GPL

2005-11-22 Thread Scott David Daniels
John Perks and Sarah Mount wrote: > we have some Python code we're planning to GPL. However, bits of it were > cut&pasted from some wxPython-licenced code to use as a starting point > for implementation. It is possible that some fragments of this code > remains unchanged at the end. Well, you coul

Re: sort the list

2005-11-22 Thread Neil Hodgson
Nick Craig-Wood: > Since no-one mentioned it and its a favourite of mine, you can use the > decorate-sort-undecorate method, or "Schwartzian Transform" That is what the aforementioned key argument to sort is: a built-in decorate-sort-undecorate. >>> lst = [[1,4],[3,9],[2,5],[3,2]] >>> pri

Questions on embedding Python

2005-11-22 Thread Kenneth McDonald
We're looking at embedding Python into our product to provide users with the ability to write scripts for the programming. My knowledge of Python is excellent, I'm familiar with the concepts of converting back and forth between C and Python datatypes, but my knowledge of compiling and linki

Re: matching a string to extract substrings for which some function returns true

2005-11-22 Thread Paul Rubin
Mike Meyer <[EMAIL PROTECTED]> writes: > > put in a html page as the value of a hidden variable. And when i get > > the string again, i want to cast it back as list of tuples:... > This is a serious security risk, as you can't trust the data not to do > arbitrary things to your system when eval'ed.

Re: Converting a flat list to a list of tuples

2005-11-22 Thread Bengt Richter
On 22 Nov 2005 07:42:31 -0800, "George Sakkis" <[EMAIL PROTECTED]> wrote: >"Laurent Rahuel" wrote: > >> Hi, >> >> newList = zip(aList[::2], aList[1::2]) >> newList >> [('a', 1), ('b', 2), ('c', 3)] >> >> Regards, >> >> Laurent > >Or if aList can get very large and/or the conversion has to be >perf

Re: matching a string to extract substrings for which somefunctionreturns true

2005-11-22 Thread Fredrik Lundh
I wrote: > if you cannot cache session data on the server side, I'd > recommend inventing a custom record format, and doing your > own parsing. turning your data into e.g. > >"foo:1:foobar:3:0+foo1:2:foobar1:3:1+foo2:2:foobar2:3:2" > > is trivial, and the resulting string can be trivially par

Re: wxPython Licence vs GPL

2005-11-22 Thread John Perks and Sarah Mount
> IIRC, wxPython license has nothing to do with GPL. Its license is far more > "free" than GPL is. If you want to create commercial apps with wxPython, you > can do it without messing with licenses. This isn't a commercial app though, it's for a research project and apparently it's a requirement t

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Christoph Zwerschke
> d1[0:0] + d1[2:2] ==> OrderedDict( (1, 11), (3, 13) ) Oops, sorry, that was nonsense again. I meant d1[0:1] + d1[1:2] ==> OrderedDict( (1, 11), (3, 13) ) > Ordered dictionaries could allow slicing and concatenation. Some operations such as concatenation need of course special considerations,

Re: Questions on embedding Python

2005-11-22 Thread Fredrik Lundh
Kenneth McDonald wrote: > 1) When Python is embedded, is it typically compiled statically into > the program, or provided as a dynamic library? if your application is compatible with the Python (i.e. uses /MD on Windows, etc), using the DLL is a lot easier. > 2) If provided as a dynamic library,

Re: about sort and dictionary

2005-11-22 Thread Steven D'Aprano
On Tue, 22 Nov 2005 08:53:07 -0800, rurpy wrote: > I am not a complete newb at python, but I am still pretty new. > I too thought immediately that the output should be 3,2,1, 1,2,3. What you are saying is that a.reverse() should *both* change a in place *and* return a reference to the same list.

user-defined operators: a very modest proposal

2005-11-22 Thread Steve R. Hastings
I have been studying Python recently, and I read a comment on one web page that said something like "the people using Python for heavy math really wish they could define their own operators". The specific example was to define an "outer product" operator for matrices. (There was even a PEP, numbe

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Bengt Richter
On Tue, 22 Nov 2005 21:24:29 +0100, Christoph Zwerschke <[EMAIL PROTECTED]> wrote: >Carsten Haese wrote: > >> That could easily be fixed by making the sequence a "managed property" >> whose setter raises a ValueError if you try to set it to something >> that's not a permutation of what it was. >

Re: wxPython Licence vs GPL

2005-11-22 Thread Robert Kern
John Perks and Sarah Mount wrote: [Andrea Gavan wrote:] >>IIRC, wxPython license has nothing to do with GPL. Its license is far > more >>"free" than GPL is. If you want to create commercial apps with > wxPython, you >>can do it without messing with licenses. > > This isn't a commercial app thoug

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Bengt Richter
On Tue, 22 Nov 2005 20:15:18 +0100, Christoph Zwerschke <[EMAIL PROTECTED]> wrote: > >>def __init__(self, init_val = ()): > >> dict.__init__(self, init_val) > >> self.sequence = [x[0] for x in init_val] > >Fuzzyman wrote: > > > But that doesn't allow you to create an ordered dict from ano

Re: about sort and dictionary

2005-11-22 Thread OKB (not okblacke)
Fredrik Lundh wrote: > [EMAIL PROTECTED] wrote: > >> > so what would an entry-level Python programmer expect from this >> > piece of code? >> > >> > for item in a.reverse(): >> > print item >> > for item in a.reverse(): >> > print item >> > >> I would expect it to first pr

Re: PIL FITs image decoder

2005-11-22 Thread jbrewer
>If you can bear having two copies in memory, Image.frombuffer() >generally does the trick. What arguments do you pass to this function, and do you flatten the array from the FITs image? I this but got garbage out for the image. Jeremy -- http://mail.python.org/mailman/listinfo/python-list

Re: PIL FITs image decoder

2005-11-22 Thread jbrewer
>If you can bear having two copies in memory, Image.frombuffer() >generally does the trick. Also, does PIL have a contrast / scale option that is similar to zscale in ds9 or equalize in Image Magick? Jeremy -- http://mail.python.org/mailman/listinfo/python-list

Re: wxPython Licence vs GPL

2005-11-22 Thread Steven D'Aprano
On Tue, 22 Nov 2005 12:57:12 -0800, Scott David Daniels wrote: > I would, at the very least, acknowledge the wxPython origin of the code > whether any remains or not (credit is appreciated and cheap to give). Ha ha, don't ask movie director James Cameron about *that*. On the basis of a throw-away

Re: user-defined operators: a very modest proposal

2005-11-22 Thread Steven D'Aprano
On Tue, 22 Nov 2005 13:48:05 -0800, Steve R. Hastings wrote: > User-defined operators could be defined like the following: ]+[ [snip] > Examples of use: > > m = m0 ]*[ m1 > m = m0]*[m1 That looks to me like multiplying two lists. I have to look twice to see that the operands are merely m0 and

Re: wxPython Licence vs GPL

2005-11-22 Thread Mike Meyer
"John Perks and Sarah Mount" <[EMAIL PROTECTED]> writes: > How should we refer to this in terms of copyright statements and bundled > Licence files? Is there, say, a standard wording to be appended to the > GPL header in each source file? Does the original author need to be > named as one of the c

Re: PIL FITs image decoder

2005-11-22 Thread Robert Kern
jbrewer wrote: [I wrote:] >>If you can bear having two copies in memory, Image.frombuffer() >>generally does the trick. > > What arguments do you pass to this function, and do you flatten the > array from the FITs image? I this but got garbage out for the image. The array would have to be cont

defining the behavior of zip(it, it) (WAS: Converting a flat list...)

2005-11-22 Thread Steven Bethard
[Duncan Booth] > >>> aList = ['a', 1, 'b', 2, 'c', 3] > >>> it = iter(aList) > >>> zip(it, it) >[('a', 1), ('b', 2), ('c', 3)] [Alan Isaac] > That behavior is currently an accident. >http://sourceforge.net/tracker/?group_id=5470&atid=105470&func=detail&aid=1121416 [Bengt Richter] > That sa

Re: user-defined operators: a very modest proposal

2005-11-22 Thread jepler
If your proposal is implemented, what does this code mean? if [1,2]+[3,4] != [1,2,3,4]: raise TestFailed, 'list concatenation' Since it contains ']+[' I assume it must now be parsed as a user-defined operator, but this code currently has a meaning in Python. (This code is the first example

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Bengt Richter
On 22 Nov 2005 11:18:19 -0800, "Kay Schluehr" <[EMAIL PROTECTED]> wrote: >Bengt Richter wrote: >> On Mon, 21 Nov 2005 01:27:22 +0100, Christoph Zwerschke <[EMAIL PROTECTED]> >> wrote: > >> Note that is isn't hard to snap a few pieces together to make an ordered >> dict to your own specs. But IMO

Re: about sort and dictionary

2005-11-22 Thread [EMAIL PROTECTED]
Steven D'Aprano wrote: > There are four possibilities for a construction like list.sort(): > > (1) sort the list in place and return a reference to the same list; > (2) sort the list in place and return a copy of the same list; > (3) sort the list in place and return None; > (4) don't sort in plac

Re: about sort and dictionary

2005-11-22 Thread [EMAIL PROTECTED]
OKB (not okblacke) wrote: > Fredrik Lundh wrote: > > > [EMAIL PROTECTED] wrote: > > > >> > so what would an entry-level Python programmer expect from this > >> > piece of code? > >> > > >> > for item in a.reverse(): > >> > print item > >> > for item in a.reverse(): > >> > p

hex string to hex value

2005-11-22 Thread tim
This is probably another newbie question...but... even after reading quite some messages like '..hex to decimal', 'creating a hex value' , I can't figure this out: If i do >>> m=66 >>> n=hex(m) >>> n '0x42' i cannot use n as value for a variable that takes hex values, because it throws: error

Profiling from embedded C [newbie]

2005-11-22 Thread Dave Bronner
Hi all, I'm trying to profile a large collection of scripts called from a wrapper C program through the following call: compiled_obj = CompilePythonFile(filename); ... PyObject* result = PyEval_EvalCode(compiled_obj, globals, globals); Is there an easy way to wrap/edit these calls so that they i

Re: about sort and dictionary

2005-11-22 Thread rurpy
"Steven D'Aprano" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Tue, 22 Nov 2005 08:53:07 -0800, rurpy wrote: > > > I am not a complete newb at python, but I am still pretty new. > > I too thought immediately that the output should be 3,2,1, 1,2,3. > > What you are saying is that

Re: hex string to hex value

2005-11-22 Thread avnit
If you just want to convert a string to an integer, it would be: >>> int(n) in your case it would be: >>> m=66 >>> n=int(hex(m)) -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are there no ordered dictionaries?

2005-11-22 Thread [EMAIL PROTECTED]
Bengt Richter wrote: > On 22 Nov 2005 03:07:47 -0800, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > > > > >Bengt Richter wrote: > >> Ok, so if not in the standard library, what is the problem? Can't find what > >> you want with google and PyPI etc.? Or haven't really settled on what your > >> _

Re: user-defined operators: a very modest proposal

2005-11-22 Thread Dan Bishop
Steve R. Hastings wrote: > I have been studying Python recently, and I read a comment on one > web page that said something like "the people using Python for heavy math > really wish they could define their own operators". The specific > example was to define an "outer product" operator for matric

Re: hex string to hex value

2005-11-22 Thread Fredrik Lundh
"tim" <[EMAIL PROTECTED]> wrote: > This is probably another newbie question...but... > even after reading quite some messages like '..hex to decimal', > 'creating a hex value' , I can't figure this out: > If i do > >>> m=66 > >>> n=hex(m) > >>> n > '0x42' > i cannot use n as value for a variable t

Re: hex string to hex value

2005-11-22 Thread tim
but then i get : >>> m 66 >>> n=int(hex(m)) Traceback (most recent call last): File "", line 1, in ? ValueError: invalid literal for int(): 0x42 >>> what am I missing here ? thank you Tim avnit wrote: >If you just want to convert a string to an integer, it would be: > > > int(n)

Re: hex string to hex value

2005-11-22 Thread [EMAIL PROTECTED]
avnit wrote: > If you just want to convert a string to an integer, it would be: > > >>> int(n) That's what the OP tried and it didn't work. BECAUSE you have to tell the int function what base the string is in (even though it has "0x" at the start). >>> int(n,16) 66 > > in your case it would be

Re: Any royal road to Bezier curves...?

2005-11-22 Thread Tom Anderson
On Tue, 22 Nov 2005, Warren Francis wrote: > For my purposes, I think you're right about the natural cubic splines. > Guaranteeing that an object passes through an exact point in space will > be more immediately useful than trying to create rules governing where > control points ought to be pla

Re: Converting a flat list to a list of tuples

2005-11-22 Thread [EMAIL PROTECTED]
Bengt Richter wrote: > On Tue, 22 Nov 2005 13:37:06 +0100, =?ISO-8859-1?Q?Andr=E9?= Malo <[EMAIL > PROTECTED]> wrote: > > >* Duncan Booth <[EMAIL PROTECTED]> wrote: > > > >> metiu uitem wrote: > >> > >> > Say you have a flat list: > >> > ['a', 1, 'b', 2, 'c', 3] > >> > > >> > How do you efficient

Re: user-defined operators: a very modest proposal

2005-11-22 Thread Mike Meyer
"Steve R. Hastings" <[EMAIL PROTECTED]> writes: > I have been studying Python recently, and I read a comment on one > web page that said something like "the people using Python for heavy math > really wish they could define their own operators". The specific > example was to define an "outer prod

Re: user-defined operators: a very modest proposal

2005-11-22 Thread Steve R. Hastings
> Here is a thought: Python already supports an unlimited number of > operators, if you write them in prefix notation: And indeed, so far Python hasn't added user-defined operators because this has been adequate. > Here is some syntax that I don't object to, although that's not saying > much. >

[Fwd: Re: hex string to hex value]

2005-11-22 Thread tim
ok, but if i do >>> n=66 >>> m=hex(n) >>> m '0x42' >>> h=int(m,16) >>> h 66 >>> I end up with 66 again, back where I started, a decimal, right? I want to end up with 0x42 as being a hex value, not a string, so i can pas it as an argument to a function that needs a hex value. (i am trying t

Re: about sort and dictionary

2005-11-22 Thread Mike Meyer
[EMAIL PROTECTED] writes: > I think this is just another (admittedly minor) case of Python's > designers using Python to enforce some idea of programming > style purity. You say that as if it were a bad thing. http://www.mired.org/home/mwm/ Independent WWW/Perforce/FreeBSD/U

Re: hex string to hex value

2005-11-22 Thread [EMAIL PROTECTED]
tim wrote: > but then i get : > > >>> m > 66 > >>> n=int(hex(m)) > Traceback (most recent call last): > File "", line 1, in ? > ValueError: invalid literal for int(): 0x42 > >>> > > what am I missing here ? Avnit's solution was wrong. When converting a string, you must state what base you ar

Re: about sort and dictionary

2005-11-22 Thread [EMAIL PROTECTED]
Mike Meyer wrote: > [EMAIL PROTECTED] writes: > > I think this is just another (admittedly minor) case of Python's > > designers using Python to enforce some idea of programming > > style purity. > > You say that as if it were a bad thing. > I would say "interesting" thing. As it seems that quite

Built windows installers and Cygwin

2005-11-22 Thread SPE - Stani's Python Editor
A SPE user reported this on the SPE users forum (http://developer.berlios.de/forum/message.php?msg_id=21944): >My setup is as follows: >SPE-0.7.5 >Python 2.4 (from the Cygwin packages) > >Installer does not continue. "No Python installation found in the registry". > >Are there other workarounds fo

Re: user-defined operators: a very modest proposal

2005-11-22 Thread Steve R. Hastings
> if [1,2]+[3,4] != [1,2,3,4]: raise TestFailed, 'list concatenation' > Since it contains ']+[' I assume it must now be parsed as a user-defined > operator, but this code currently has a meaning in Python. Yes. I agree that this is a fatal flaw in my suggestion. Perhaps there is no syntax

<    1   2   3   >