Cmd Module

2005-11-22 Thread Godwin Burby
Dear Pythoneer, I was just curious about using the cmd module for building my own command line interface. i saw a problem. The script is as follows: from cmd import Cmd import getpass class CmdTest(cmd): def __init__(self): super(CmdTest, self).__init__() def do_login(sel

Re: about sort and dictionary

2005-11-22 Thread Steven D'Aprano
[EMAIL PROTECTED] wrote: > 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

Mac OSX oddities (compiling Python plus tkinter)

2005-11-22 Thread MichaelW
I've been Python (2.3.4) plus Tkinter happily under MacOX 10.3, having compiled them from scatch. (Tkinter is based on tcl/tk 8.4.1, which were compiled from source via Fink). I then moved my laptop over the 10.4, and things are now breaking. Using the Python shipped with 10.4 (which has Tkinter b

Re: 2.4.2 on AIX 4.3 make fails on threading

2005-11-22 Thread Donn Cave
Quoth Paul Watson <[EMAIL PROTECTED]>: | 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, b

Re: hex string to hex value

2005-11-22 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > Fredrik Lundh's solution works if the hex string starts with "0x" that's what "interpret [it] as a Python literal" meant. > (which it will when the string is created with the hex function). > > >>> int(hex(m),0) > 66 > > But it won't work without the "0x". > > >>> int(

Re: Problem printing in Win98

2005-11-22 Thread Tim Roberts
Dale Strickland-Clark <[EMAIL PROTECTED]> wrote: > >I presume this .ps file is a preformed postscript file that should be sent >to a postscript printer without further modification? > >In this case, I think you should use copy instead of print. Something like >this: > >win32api.ShellExecute(0, "cop

Problems with threaded Hotkey application

2005-11-22 Thread Rsrany
I've been working on a few gtk applications and need to tie a hot key catcher into a thread. I am currently finding threaded user32.GetMessageA do not work. I have included two programs: 1) a non-threaded version that works 2) a threaded version that doesnt work. Any constructive suggestion

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

2005-11-22 Thread [EMAIL PROTECTED]
Steven Bethard wrote: > [EMAIL PROTECTED] wrote: > >> > ii. The other problem is easier to explain by example. > >> > Let it=iter([1,2,3,4]). > >> > What is the result of zip(*[it]*2)? > >> > The current answer is: [(1,2),(3,4)], > >> > but it is impossible to determine this from the docs, > >> >

Re: PIL FITs image decoder

2005-11-22 Thread jbrewer
I tried following your simple example (I already had something similar) but with no luck. I'm completely stumped as to why this doesn't work. I even tried manually scaling the data to be in the range 0-255 out of desperation. The data is definitely contiguous and 32 bit floating point. At this p

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

2005-11-22 Thread Steven Bethard
[EMAIL PROTECTED] wrote: >> > ii. The other problem is easier to explain by example. >> > Let it=iter([1,2,3,4]). >> > What is the result of zip(*[it]*2)? >> > The current answer is: [(1,2),(3,4)], >> > but it is impossible to determine this from the docs, >> > which would allow [(1,3),(2,4)] inste

Re: Why are there no ordered dictionaries?

2005-11-22 Thread [EMAIL PROTECTED]
Alex Martelli wrote: > [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: >... > > But I can also record these changes in a seperate table which then > > becomes a "sorted" case ? > > somedict['x']='y', per se, does no magic callback to let you record > anything when type(somedict) is dict. You can

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Alex Martelli
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: ... > But I can also record these changes in a seperate table which then > becomes a "sorted" case ? somedict['x']='y', per se, does no magic callback to let you record anything when type(somedict) is dict. You can wrap or subclass to your heart's c

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

2005-11-22 Thread Alex Martelli
Steven Bethard <[EMAIL PROTECTED]> wrote: ... > Unfortunately, no, this is basically what I currently have. Instead of > a.name printing 'test', it should print '__main__'. I want the name of > the module in which the *instance* is created, not the name of the > module in which the *class* is

Re: Why are there no ordered dictionaries?

2005-11-22 Thread [EMAIL PROTECTED]
Alex Martelli wrote: > What you can obtain (or anyway easily simulate in terms of effects on a > loop) through an explicit call to the 'sorted' built-in, possibly with a > suitable 'key=' parameter, I would call "sorted" -- exactly because, as > Bengt put it, there IS a sorting algorithm which, et

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

2005-11-22 Thread Amit Khemka
thanks for you suggestions :-) .. cheers, On 11/23/05, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > 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:

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Alex Martelli
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Bengt Richter wrote: > > For me the implication of "sorted" is that there is a sorting algorithm > > that can be used to create an ordering from a prior state of order, > > whereas "ordered" could be the result of arbitrary permutation, e.g., > > manu

Re: What a curious assignment.

2005-11-22 Thread Naveed
"A.i" is a class attribute. "a.i" at first is the same as "A.i". Once you set a.i = 2, you are actually creating a new data attribute called i for the instance a. This happens on the fly. So then when you reference a.i, it uses the instance data attribute, instead of the class attribute. This

Re: What a curious assignment.

2005-11-22 Thread [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote: > [test 1] > >>> class A: > ...i = 1 > ... > >>> a = A() > >>> A.i > 1 > >>> a.i > 1 > >>> A.i = 2 > >>> A.i > 2 > >>> a.i > 2 > >>> > > [test2] > >>> class A: > ...i = 1 > ... > >>> a = A() > >>> A.i > 1 > >>> a.i > 1 > >>> a.i = 2 > >>> A.i > 1 > >>> a.i > 2 > >>

Re: What a curious assignment.

2005-11-22 Thread Mike Meyer
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > [test 1] class A: > ...i = 1 > ... a = A() A.i > 1 a.i > 1 A.i = 2 A.i > 2 a.i > 2 > > [test2] class A: > ...i = 1 > ... a = A() A.i > 1 a.i > 1 a.i = 2 A.i > 1 a.i

Re: bsddb185 question

2005-11-22 Thread thakadu
Thanks Martin However the line: del db[key] results in an error: (1, 'Operation not permitted') (only tested on Python 2.3.5) Could this be because the .del() method of the dictionary has not been implemented either? In fact in my tests any attempt at altering the db by use of normal dictionary me

Re: 2.4.2 on AIX 4.3 make fails on threading

2005-11-22 Thread Neal Norwitz
Paul Watson wrote: > 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. Perhaps you need to add -lpthread to the link line. This should be able

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Ganesan Rajagopal
> Alex Martelli <[EMAIL PROTECTED]> writes: > Ordered *by order of key insertion*: Java, PHP > Ordered *by other criteria*: LISP, C++ Java supports both ordered by key insertion (LinkedHashMap) as well as ordered by key comparison (TreeMap). Ganesan -- Ganesan Rajagopal (rganesan at

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

2005-11-22 Thread Mike Meyer
[EMAIL PROTECTED] (Bengt Richter) writes: >>I'm not sure exactly what you mean by "grabbing sublass inst d contens >>directly", but if dict(d.items()) does it, the above class should do >>it as well. Of course, *other* ways of initializing a dict won't work >>for this class. >> > It's not initializ

Re: email module documentation

2005-11-22 Thread David Bear
Robert Kern wrote: > David Bear wrote: >> I'm confused about how to use the email module in python 2.4.x >> >> I'm using python packaged with suse 9.3. >> >>>From the module documetation at http://docs.python.org/lib/node597.html I >> found the following example (items cut): >> >> import email

What a curious assignment.

2005-11-22 Thread [EMAIL PROTECTED]
[test 1] >>> class A: ...i = 1 ... >>> a = A() >>> A.i 1 >>> a.i 1 >>> A.i = 2 >>> A.i 2 >>> a.i 2 >>> [test2] >>> class A: ...i = 1 ... >>> a = A() >>> A.i 1 >>> a.i 1 >>> a.i = 2 >>> A.i 1 >>> a.i 2 >>> Is there somthing wrong -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Ganesan Rajagopal
> [EMAIL PROTECTED] com <[EMAIL PROTECTED]> writes: > what would be the definition of "sorted" and "ordered", before we can > go on ? Sorted would be ordered by key comparison. Iterating over such a container will give you the keys in sorted order. Java calls this a SortedMap. See http://

Re: Why are there no ordered dictionaries?

2005-11-22 Thread [EMAIL PROTECTED]
Bengt Richter wrote: > For me the implication of "sorted" is that there is a sorting algorithm > that can be used to create an ordering from a prior state of order, > whereas "ordered" could be the result of arbitrary permutation, e.g., > manual shuffling, etc. Of course either way, a result can b

Re: about sort and dictionary

2005-11-22 Thread rurpy
Alex Martelli wrote: > <[EMAIL PROTECTED]> wrote: >... > > language, yea, I guess I think it's bad. A general > > purpose language should strive to support as wide a > > varity of styles as possible. > > Definitely NOT Python's core design principle, indeed the reverse of it. Priciples are f

Re: Anyway to clarify this code? (dictionaries)

2005-11-22 Thread [EMAIL PROTECTED]
Mike Meyer wrote: > First, remember the warnings about premature optimization. Which is why I said the one-liner(your first one) is clean and clear, and bug free in one go. > > use = set(another) - set(keys) > return dict([[k, another[k]] for k in use if another[k] >= x] > > Though I

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

2005-11-22 Thread rurpy
[EMAIL PROTECTED] wrote: > [EMAIL PROTECTED] wrote: > > Well, I do too mostly. On rereading my post, it seems I overreacted > > a bit. But the attitude I complained about I think is real, and has > > led to more serious flaws like the missing if-then-else expression, > > something I use in virtu

Re: Anyway to clarify this code? (dictionaries)

2005-11-22 Thread Mike Meyer
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > Mike Meyer wrote: >> def my_search(another, keys, x): >>return dict([[k, v] for k, v in another.items() if v >= x and k in keys]) >> But then you're looking through all the keys in another, and searching >> through keys multiple times, which pr

Re: about sort and dictionary

2005-11-22 Thread [EMAIL PROTECTED]
Alex Martelli wrote: > [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: >... > > intuitive seems to be a very subjective matter, depends on once > > background etc :-) > > That's a strong point of Ruby, actually -- allowing an exclamation mark > at the end of a method name, which conventionally is

Re: email module documentation

2005-11-22 Thread Robert Kern
David Bear wrote: > I'm confused about how to use the email module in python 2.4.x > > I'm using python packaged with suse 9.3. > >>From the module documetation at http://docs.python.org/lib/node597.html I > found the following example (items cut): > > import email > > ... > msg = email.messag

Re: about sort and dictionary

2005-11-22 Thread rurpy
Alex Martelli wrote: > <[EMAIL PROTECTED]> wrote: >... > > language, yea, I guess I think it's bad. A general > > purpose language should strive to support as wide a > > varity of styles as possible. > > Definitely NOT Python's core design principle, indeed the reverse of it. Priciples are f

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

2005-11-22 Thread [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote: > Well, I do too mostly. On rereading my post, it seems I overreacted > a bit. But the attitude I complained about I think is real, and has > led to more serious flaws like the missing if-then-else expression, > something I use in virtually every piece of code I write, a

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Bengt Richter
On 22 Nov 2005 19:15:42 -0800, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > >Alex Martelli wrote: >> However, since Christoph himself just misclassified C++'s std::map as >> "ordered" (it would be "sorted" in this new terminology he's now >> introducing), it seems obvious that the terminologic

email module documentation

2005-11-22 Thread David Bear
I'm confused about how to use the email module in python 2.4.x I'm using python packaged with suse 9.3. >From the module documetation at http://docs.python.org/lib/node597.html I found the following example (items cut): import email ... msg = email.message_from_file(fp) .. Yet, when I try thi

Accessing a database from a multithreaded application

2005-11-22 Thread Alan Kemp
Hi, I have a problem that is half python, half design. I have a multithreaded network server working, each client request spawns a new thread which deals with that client for as long as it is connected (think ftp style rather than http style connections here). Each thread gets passed a reference

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

2005-11-22 Thread rurpy
[EMAIL PROTECTED] wrote: > [EMAIL PROTECTED] wrote: > > > * It is bug-prone -- zip(x,x) behaves differently when x is a sequence > > > and when x is an iterator (because of restartability). Don't leave > > > landmines for your code maintainers. > > > > Err thanks for the advice, but they are *my*

Re: about sort and dictionary

2005-11-22 Thread Alex Martelli
<[EMAIL PROTECTED]> wrote: ... > language, yea, I guess I think it's bad. A general > purpose language should strive to support as wide a > varity of styles as possible. Definitely NOT Python's core design principle, indeed the reverse of it. > But this is getting rather off-topic. Yep. If

Re: about sort and dictionary

2005-11-22 Thread Alex Martelli
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: ... > intuitive seems to be a very subjective matter, depends on once > background etc :-) That's a strong point of Ruby, actually -- allowing an exclamation mark at the end of a method name, which conventionally is always used to indicate that the m

Re: Anyway to clarify this code? (dictionaries)

2005-11-22 Thread [EMAIL PROTECTED]
Bengt Richter wrote: > >>> def my_search(another, keys, x): return dict((k,another[k]) for k in > keys if another[k]>x) > ... > >>> my_search(another, 'cb', .3) > {'b': 0.35806602909756235} > >>> my_search(another, 'abcd', .4) > {'a': 0.60649466203365532, 'd': 0.77440643221840166} > Do you

Re: Anyway to clarify this code? (dictionaries)

2005-11-22 Thread [EMAIL PROTECTED]
Mike Meyer wrote: > def my_search(another, keys, x): > new = dict() > for k in keys: > if another[k] >= x: > new[k] = another[k] > return new > BTW, this would raise exception if k is not in another. -- http://mail.python.org/mailman/listinfo/python-list

Re: Anyway to clarify this code? (dictionaries)

2005-11-22 Thread Bengt Richter
On 22 Nov 2005 17:58:28 -0800, "javuchi" <[EMAIL PROTECTED]> wrote: >I've been searching thru the library documentation, and this is the >best code I can produce for this alogorithm: > >I'd like to return a dictionary which is a copy of 'another' dictionary >whoes values are bigger than 'x' and ha

Re: Anyway to clarify this code? (dictionaries)

2005-11-22 Thread [EMAIL PROTECTED]
Mike Meyer wrote: > def my_search(another, keys, x): >return dict([[k, v] for k, v in another.items() if v >= x and k in keys]) > > But then you're looking through all the keys in another, and searching > through keys multiple times, which probably adds up to a lot more > wasted work than inde

Re: Anyway to clarify this code? (dictionaries)

2005-11-22 Thread Mike Meyer
"javuchi" <[EMAIL PROTECTED]> writes: > I've been searching thru the library documentation, and this is the > best code I can produce for this alogorithm: > > I'd like to return a dictionary which is a copy of 'another' dictionary > whoes values are bigger than 'x' and has the keys 'keys': > > def

Re: Why are there no ordered dictionaries?

2005-11-22 Thread [EMAIL PROTECTED]
Alex Martelli wrote: > However, since Christoph himself just misclassified C++'s std::map as > "ordered" (it would be "sorted" in this new terminology he's now > introducing), it seems obvious that the terminological confusion is > rife. Many requests and offers in the past for "ordered dictionar

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Alex Martelli
Tom Anderson <[EMAIL PROTECTED]> wrote: ... > > have a certain order that is preserved). Those who suggested that the > > "sorted" function would be helpful probably thought of a "sorted > > dictionary" rather than an "ordered dictionary." > > Exactly. > > Python could also do with a sorted d

Re: about sort and dictionary

2005-11-22 Thread rurpy
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. Well, there are many languages that promote a specific sty

Re: Converting a flat list to a list of tuples

2005-11-22 Thread [EMAIL PROTECTED]
Bengt Richter wrote: > On 22 Nov 2005 16:32:25 -0800, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > > > > >Bengt Richter wrote: > >> On 22 Nov 2005 07:42:31 -0800, "George Sakkis" <[EMAIL PROTECTED]> wrote: > >> > >> >"Laurent Rahuel" wrote: > >> > > >> >> Hi, > >> >> > >> >> newList = zip(aLis

Re: Converting a flat list to a list of tuples

2005-11-22 Thread Bengt Richter
On 22 Nov 2005 16:32:25 -0800, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > >Bengt Richter wrote: >> 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 >> >> [(

Re: drawline

2005-11-22 Thread Eugene Druker
Hi Ben, if I understood your questions properly, this code gives some answers (on XP): from Tkinter import * lines = [ [ (100, 200, 350, 200), LAST, "red",'' ], [ (100, 0, 100, 200), FIRST, "green", 'a' ], [ (100, 200, 300, 100), LAST, "purple", 'b' ], ] ClickMax = len(

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Bengt Richter
On Tue, 22 Nov 2005 22:06:12 +0100, Christoph Zwerschke <[EMAIL PROTECTED]> wrote: >> 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 con

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

2005-11-22 Thread [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote: > > * It is bug-prone -- zip(x,x) behaves differently when x is a sequence > > and when x is an iterator (because of restartability). Don't leave > > landmines for your code maintainers. > > Err thanks for the advice, but they are *my* code maintainers and > I am the best

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

2005-11-22 Thread Warren Francis
> If you go right to the foot of my code, you'll find a simple test routine, > which shows you the skeleton of how to drive the code. Oops... my request just got that much more pitiful. :-) Thanks for the help. Warren -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Alex Martelli
Christoph Zwerschke <[EMAIL PROTECTED]> wrote: ... > * C++ has a Map template in the STL which is ordered (a "Sorted > Associative Container"). Ordered *by comparisons on keys*, NOT by order of insertion -- an utterly and completely different idea. > So ordered dictionaries don't seem to be s

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

2005-11-22 Thread rurpy
[EMAIL PROTECTED] wrote: > > > ii. The other problem is easier to explain by example. > > > Let it=iter([1,2,3,4]). > > > What is the result of zip(*[it]*2)? > > > The current answer is: [(1,2),(3,4)], > > > but it is impossible to determine this from the docs, > > > which would allow [(1,3)

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

2005-11-22 Thread [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote: > IIRC, this was discussednd rejected in an SF bug report. It should not > be a defined behavior for severals reasons: > > * It is not communicative to anyone reading the code that zip(it, it) > is creating a sequence of the form (it0, it1), (it2, it3), . . . IOW, > it

Re: How can I package a python script and modules into a single script?

2005-11-22 Thread Noah
Alex Martelli wrote: > > > This is because zipimport can only import from file paths. > > It can import from a file, and the file (like all zipfiles) can have a prefix > That prefix is where you put the "boot" script. > See http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/215301 Unfortunate

Anyway to clarify this code? (dictionaries)

2005-11-22 Thread javuchi
I've been searching thru the library documentation, and this is the best code I can produce for this alogorithm: I'd like to return a dictionary which is a copy of 'another' dictionary whoes values are bigger than 'x' and has the keys 'keys': def my_search (another, keys, x): temp = anoth

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Tom Anderson
On Tue, 22 Nov 2005, Christoph Zwerschke wrote: > 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

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Tom Anderson
On Tue, 22 Nov 2005, Christoph Zwerschke wrote: > 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 Foord/Larosa's odict, the keys are exposed as a public member which > also seem

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Bengt Richter
On Tue, 22 Nov 2005 20:37:40 +0100, Christoph Zwerschke <[EMAIL PROTECTED]> wrote: >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

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Tom Anderson
On Tue, 22 Nov 2005, Carsten Haese wrote: > 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 dic

a new design pattern for Python Library?

2005-11-22 Thread The Eternal Squire
Hi, I tend to use this design pattern a lot in order to aid in compartmentalizing interchangeable features in a central class that depend on the central class's data. I know that explicit class friendship designs syntactic sugar, but I am thinking this should be a standard design pattern to make

Re: Using gettext to provide different language-version of a script

2005-11-22 Thread Martin v. Löwis
Thomas W wrote: > Hmmm ... any hints? I think gettext needs environment variables (e.g. LANG) to be set. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list

Re: user-defined operators: a very modest proposal

2005-11-22 Thread Tom Anderson
On Tue, 22 Nov 2005 [EMAIL PROTECTED] wrote: > Each unicode character in the class 'Sm' (Symbol, > Math) whose value is greater than 127 may be used as a user-defined operator. EXCELLENT idea, Jeff! > Also, to accomodate operators such as u'\N{DOUBLE INTEGRAL}', which are not > simple unary or b

Re: hex string to hex value

2005-11-22 Thread Grant Edwards
On 2005-11-23, tim <[EMAIL PROTECTED]> wrote: >int(hex(m),16) > > >>66 >> >>Fredrik Lundh's solution works if the hex string starts with "0x" >>(which it will when the string is created with the hex function). >> > aren't you converting from a hex string to a decimal value here

Re: Built windows installers and Cygwin

2005-11-22 Thread Martin v. Löwis
SPE - Stani's Python Editor wrote: > Is there any way for these kind of installers to be used with cygwin. No. The bdist_wininst packages link against Microsoft's C library; the cygwin Python against Cygwin's. If there is no native code in the package, it would be possible to *use* them - install

Re: linking one extension module to another (Mac OSX)

2005-11-22 Thread Martin v. Löwis
[EMAIL PROTECTED] wrote: > I have C Extension classes distributed across several modules with > non-trivial interdependancies. I guess you are saying I should have > these in backend libraries and then put the module specific functions > in the module itself. It's going to be tricky because I am us

Re: Using gettext to provide different language-version of a script

2005-11-22 Thread Tony Nelson
In article <[EMAIL PROTECTED]>, "Thomas W" <[EMAIL PROTECTED]> wrote: > I'm trying to wrap my head around the docs at python.org related to the > gettext-module, but I'm having some problem getting it to work. Is > there any really simple, step-by-step on how to use this module > available? > >

Re: bsddb185 question

2005-11-22 Thread Martin v. Löwis
thakadu wrote: > It seems it doesnt implement ALL of the dictionary interface though. > dir({}) yields many more methods than dir(bsddb185.open(f)). > So bsddb185 is missing many of the methods that I am used > to in bsddb. I mentioned some above that are missing, pop() > in particular would be use

Re: Embedded Python interpreter and sockets

2005-11-22 Thread wahn
Hi, actually that didn't solve the problem. As soon as you do something with the socket module it fails. Well, the solution I came up with is simply link the ../_socket.so into my Houdini plugin DSO which is ugly but solves the problem for the moment ... Happy hacking, Jan -- http://mail.pytho

Re: user-defined operators: a very modest proposal

2005-11-22 Thread Joseph Garvin
Tom Anderson wrote: >Jeff Epler's proposal to use unicode operators would synergise most >excellently with this, allowing python to finally reach, and even surpass, >the level of expressiveness found in languages such as perl, APL and >INTERCAL. > >tom > > > What do you mean by unicode operat

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

2005-11-22 Thread rhettinger
> > ii. The other problem is easier to explain by example. > > Let it=iter([1,2,3,4]). > > What is the result of zip(*[it]*2)? > > The current answer is: [(1,2),(3,4)], > > but it is impossible to determine this from the docs, > > which would allow [(1,3),(2,4)] instead (or indeed > > other

Re: best cumulative sum

2005-11-22 Thread [EMAIL PROTECTED]
Michael Spencer wrote: > David Isaac wrote: > for a solution when these are available. > > Something like: > > def cumreduce(func, seq, init = None): > > """Return list of cumulative reductions. > > > > > This can be written more concisely as a generator: > > >>> import operator > >>> de

Re: user-defined operators: a very modest proposal

2005-11-22 Thread Tom Anderson
On Tue, 22 Nov 2005, Steve R. Hastings wrote: > User-defined operators could be defined like the following: ]+[ Eeek. That really doesn't look right. Could you remind me of the reason we can't say [+]? It seems to me that an operator can never be a legal filling for an array literal or a subscr

Re: best cumulative sum

2005-11-22 Thread Michael Spencer
David Isaac wrote: for a solution when these are available. > Something like: > def cumreduce(func, seq, init = None): > """Return list of cumulative reductions. > > This can be written more concisely as a generator: >>> import operator >>> def ireduce(func, iterable, init): ...

Re: user-defined operators: a very modest proposal

2005-11-22 Thread jepler
On Tue, Nov 22, 2005 at 04:08:41PM -0800, Steve R. Hastings wrote: > Actually, that's a better syntax than the one I proposed, too: > > __+__ > # __add__ # this one's already in use, so not allowed > __outer*__ Again, this means something already. >>> __ = 3 >>> __+__ 6 >>> __outer = 'x' >>>

Re: Converting a flat list to a list of tuples

2005-11-22 Thread [EMAIL PROTECTED]
Bengt Richter wrote: > 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 g

moving mouse?

2005-11-22 Thread dado
I'm implementing a "self-tutorial" into my app, and wondering if there's a way of moving a mouse cursor on command? probably using sys,os modules? -- http://mail.python.org/mailman/listinfo/python-list

Re: [Fwd: Re: hex string to hex value]

2005-11-22 Thread tim
Brett g Porter wrote: > tim wrote: > >> >> 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 to replace the 0x42 in the line >>

Re: [Fwd: Re: hex string to hex value]

2005-11-22 Thread Brett g Porter
tim wrote: > > 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 to replace the 0x42 in the line midi.note_off(channel=0, > note=0

Re: [Fwd: Re: hex string to hex value]

2005-11-22 Thread Rocco Moretti
tim wrote: > 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

Re: hex string to hex value

2005-11-22 Thread tim
[EMAIL PROTECTED] wrote: >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 conve

Simple photo collage using Python and PIL

2005-11-22 Thread Callum Prentice
i need a "script" that i can use locally as well as online that will: * create a large (maybe something like 2k x 2k) master image in memory * open a text file and read all the lines from it (maybe 1000 lines max) * each line is composed of an x, y, name and a png image filename * for each line,

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

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: 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

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 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

[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: 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. >

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: 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: 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: 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: 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 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: 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

  1   2   3   >