Re: multiple raw_inputs

2005-11-24 Thread Fredrik Lundh
Satya Kiran wrote: > I m a python newbie,infact,I m a newbie to programming and I was suggested > it was a good idea to start it with python. > > I was trying a program which needs three integers from the user.I got it by > using raw_input thrice. > Is there a better way(s) to do it? if you want

Re: Why is dictionary.keys() a list and not a set?

2005-11-24 Thread Mike Meyer
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: >> Not all tuples can be elements of a set. Elements of a set have to be >> hashable. Tuples compute their hash by hashing their contents. If >> their contents aren't hashable, the tuple isn't hashable, and hence >> can't be an element of a set. If th

Re: The imp module and cyclic imports

2005-11-24 Thread Fredrik Lundh
Matthias Kramm wrote: > I'm having a little bit of trouble using the "imp" module to > dynamically import modules. It seems that somehow cyclic > references of modules don't work. the problem you're seeing appears also if you use "import web.one" or "from web import one" or "__import__('web.one')

Re: Why is dictionary.keys() a list and not a set?

2005-11-24 Thread [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote: > Mike Meyer wrote: > > "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > > > Christoph Zwerschke wrote: > > >> [EMAIL PROTECTED] schrieb: > > >> > You can already get a set from a dictionary's keys in an efficient > > >> > manner: > > >> l = dict.fromkeys(range(10))

Re: Why is dictionary.keys() a list and not a set?

2005-11-24 Thread [EMAIL PROTECTED]
Mike Meyer wrote: > "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > > Christoph Zwerschke wrote: > >> [EMAIL PROTECTED] schrieb: > >> > You can already get a set from a dictionary's keys in an efficient > >> > manner: > >> l = dict.fromkeys(range(10)) > >> set(l) > >> > Set([0, 1, 2, 3,

Re: Draw a triangle...

2005-11-24 Thread The Eternal Squire
PyGame is your best bet for pure graphics. Simple shapes can be done in just a few statements. The Eternal Squire -- http://mail.python.org/mailman/listinfo/python-list

Re: python gui using boa

2005-11-24 Thread ash
Thanks Brian, I could do it. actually it needs all the three mouse events - LeftDown, LeftUp and MouseMove. with regards, Ashoka -- http://mail.python.org/mailman/listinfo/python-list

Re: Why is dictionary.keys() a list and not a set?

2005-11-24 Thread [EMAIL PROTECTED]
Mike Meyer wrote: > "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > > Christoph Zwerschke wrote: > >> [EMAIL PROTECTED] schrieb: > >> > You can already get a set from a dictionary's keys in an efficient > >> > manner: > >> l = dict.fromkeys(range(10)) > >> set(l) > >> > Set([0, 1, 2, 3,

Re: Why is dictionary.keys() a list and not a set?

2005-11-24 Thread Mike Meyer
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > Christoph Zwerschke wrote: >> [EMAIL PROTECTED] schrieb: >> > You can already get a set from a dictionary's keys in an efficient manner: >> l = dict.fromkeys(range(10)) >> set(l) >> > Set([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) >> Good point. I expe

Re: Making immutable instances

2005-11-24 Thread Mike Meyer
"Giovanni Bajo" <[EMAIL PROTECTED]> writes: > Mike Meyer wrote: >>> Björn Lindström wrote: >>> Why do you think we have a frozenset, for instance? By Mike's >>> argument, we shouldn't have it. >> Not *my* arguments, certainly. Not unless you're seriously >> misinterpreting them. > Sorry then, I pro

Re: Making immutable instances

2005-11-24 Thread Mike Meyer
Paul Rubin writes: > "Giovanni Bajo" <[EMAIL PROTECTED]> writes: >> > However, when you prevent a client from adding an attribute, you're >> > not merely making your objects immutable, you're making them >> > static. > No I don't believe that. If an object is immutable,

Re: Making immutable instances

2005-11-24 Thread Mike Meyer
"Giovanni Bajo" <[EMAIL PROTECTED]> writes: > Mike Meyer wrote: >> And I have no problems with that. If you believe your class should >> throw an error if someone calls an instances pop() method when it's >> empty, do so. >> Likewise, if you want to make it so a client can't change your >> attribut

Re: Guification of console app

2005-11-24 Thread Peter Hansen
metiu wrote: > Say I have a console app that does something in three steps: > - opens a file > - transfers the file through a serial port > - does some elaborations > > and I want to build a GUI around it that, for example, sets the file > name to open or starts the different steps. > > I started

Re: wxPython Licence vs GPL

2005-11-24 Thread Ed Jensen
Paul Boddie <[EMAIL PROTECTED]> wrote: >> I'm aware of this concern. I don't think it's justified. Unless >> you'd like to point out all those closed, proprietary Python >> implementations that are destroying civilization as we know it. > Well, there was some concern voiced at EuroPython that a

Re: Why is dictionary.keys() a list and not a set?

2005-11-24 Thread [EMAIL PROTECTED]
Christoph Zwerschke wrote: > [EMAIL PROTECTED] schrieb: > > You can already get a set from a dictionary's keys in an efficient manner: > l = dict.fromkeys(range(10)) > set(l) > > Set([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) > > Good point. I expected that set(l) = set(l.items()) and not > set(l.key

Re: Why are there no ordered dictionaries?

2005-11-24 Thread dcalvelo
"hacer" probablemente. DCA. Piet van Oostrum wrote: > > Christoph Zwerschke <[EMAIL PROTECTED]> (CZ) escribió: > > >CZ> Eso es exactamente lo que yo queria haber! > > ¿Haber? ¿Tener? :=( > -- > Piet van Oostrum <[EMAIL PROTECTED]> > URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4] > Priv

Re: Draw a triangle...

2005-11-24 Thread jmdeschamps
JustSomeGuy wrote: > Hi I'm writing a python application on my windows box and I want to draw > a simple triangle on the screen... How can I do this. > Am I going to have to use tcl/tk? Take a look at Tkinter, Python's wrapper around Tk - you'll find many things if you Google this! It's hard to t

OT: loop help

2005-11-24 Thread noah bedford
On Thu, 27 Oct 2005 07:00:34 GMT Gorlon the Impossible <[EMAIL PROTECTED]> wrote: >I am using Python 2.3.5 with IDLE 1.0.5 on a Windows98 PC. Just had to say it... MicroSoft makes PCs now? -\n -- http://mail.python.org/mailman/listinfo/python-list

Re: Making immutable instances

2005-11-24 Thread Giovanni Bajo
Mike Meyer wrote: >> Björn Lindström wrote: >> Why do you think we have a frozenset, for instance? By Mike's >> argument, we shouldn't have it. > > Not *my* arguments, certainly. Not unless you're seriously > misinterpreting them. Sorry then, I probably am. There must be a misunderstanding somew

Re: Making immutable instances

2005-11-24 Thread Giovanni Bajo
Paul Rubin wrote: > "Giovanni Bajo" <[EMAIL PROTECTED]> writes: [pay attention to the quoting, I didn't write that :) ] >>> Mike Meyer wrote: >>> >>> However, when you prevent a client from adding an attribute, you're >>> not merely making your objects immutable, you're making them >>> static. >

Re: Making immutable instances

2005-11-24 Thread Paul Rubin
"Giovanni Bajo" <[EMAIL PROTECTED]> writes: > > However, when you prevent a client from adding an attribute, you're > > not merely making your objects immutable, you're making them > > static. No I don't believe that. If an object is immutable, then obj.serialize() should return the same string e

sending all key events to wx.panel?

2005-11-24 Thread KvS
Hi all, I have a wxPython GUI consisting of a wxWindow -> wxPanel -> set of widgets. I need to catch pressed keys no matter which widget has focus, so I've attached an event handler to the panel but I can't seem to find a way to do some kind of collective "sending through" of the key event from al

Re: Making immutable instances

2005-11-24 Thread Giovanni Bajo
Mike Meyer wrote: > And I have no problems with that. If you believe your class should > throw an error if someone calls an instances pop() method when it's > empty, do so. > > Likewise, if you want to make it so a client can't change your > attributes, feel free to do so. > > However, when you pr

Re: Making immutable instances

2005-11-24 Thread Alex Martelli
Giovanni Bajo <[EMAIL PROTECTED]> wrote: ... > > As I said before, I think you're confusing the (in Python pretty > > non-existent) concept of encapsulation with Python's immutable types, > > which are immutable because the implementation demands it. (A fact I > > hope will disappear at some poi

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

2005-11-24 Thread [EMAIL PROTECTED]
Magnus Lycka wrote: > [EMAIL PROTECTED] wrote: > > Oh, find a need to shut other up ? > > > Oh, find a need to get the last word? > like you ? -- http://mail.python.org/mailman/listinfo/python-list

Re: Why is dictionary.keys() a list and not a set?

2005-11-24 Thread Christoph Zwerschke
Martin v. Löwis wrote: > It follows from what is documented. set() creates a > set that contains all elements in the iterable object: > http://docs.python.org/lib/built-in-funcs.html#l2h-63 > Now, is a dictionary an iterable object? Yes, it is: > http://www.python.org/peps/pep-0234.html > Together

Re: Making immutable instances

2005-11-24 Thread Mike Meyer
"Giovanni Bajo" <[EMAIL PROTECTED]> writes: > Björn Lindström wrote: > Why do you think we have a frozenset, for instance? By Mike's argument, we > shouldn't have it. Not *my* arguments, certainly. Not unless you're seriously misinterpreting them. http://www.mired.org

Re: Making immutable instances

2005-11-24 Thread Mike Meyer
"Giovanni Bajo" <[EMAIL PROTECTED]> writes: > Mike Meyer wrote: Note that this property of __slots__ is an implementation detail. You can't rely on it working in the future. >>> I don't "rely" on it. I just want to catch bugs in my code. >> I certainly hope you're not relying on it t

Re: Making immutable instances

2005-11-24 Thread Giovanni Bajo
Mike wrote: >> There's a big difference. An immutable object has a totally different >> semantic, >> compared to a mutable object. If you document it to be immutable, and >> maybe >> even provide __eq__ /__hash__, adding attributes from it is surely >> an user bug. >> And surely a bug for which I'

Re: Why is dictionary.keys() a list and not a set?

2005-11-24 Thread Christoph Zwerschke
Paul Rubin schrieb: > Yes, it's not considered terribly troublesome. Set theory (and > arithmetic) are generally accepted as being consistent but incomplete. > So there will always be something for mathemeticians to do ;-). Somehow I found this being comforting. Even in the realm of Mathematics

Re: Making immutable instances

2005-11-24 Thread Giovanni Bajo
Björn Lindström wrote: >> My feeling is that you're trying to get too much out of my words. I'm >> not trying to handcuff anyone. You seem to concentrate on me trying >> to avoid people adding attributes to my precious objects. It's not >> that. If I write a class and want it to be immutable, it i

Re: Why is dictionary.keys() a list and not a set?

2005-11-24 Thread Christoph Zwerschke
Martin v. Löwis schrieb: > Your original question was "could it be changed, and should it be > changed?" As the answer to the first part is already "no", the > second part really doesn't raise. Right of course. The second part of the question was rather hypothetical (in the sense of "if we co

Draw a triangle...

2005-11-24 Thread JustSomeGuy
Hi I'm writing a python application on my windows box and I want to draw a simple triangle on the screen... How can I do this. Am I going to have to use tcl/tk? -- http://mail.python.org/mailman/listinfo/python-list

Re: wxPython Licence vs GPL

2005-11-24 Thread Mike Meyer
Paul Rubin writes: > Mike Meyer <[EMAIL PROTECTED]> writes: >> On the other hand, so long as the price is lower than the cost of >> recreating the software for someone, then it's better for society as >> a whole if it exists at all. > I don't think that's correct. Having

Re: Why is dictionary.keys() a list and not a set?

2005-11-24 Thread Christoph Zwerschke
Mike Meyer wrote: > Well, I just made a suggestion. You found the problem - you want to do > the PR, or should I? Please go ahead if you have the time. By the way, the doco may be also inexact about the keys of dictionaries. > # Untested code > class Hash(object): >def __new__(cls, obj):

Re: Making immutable instances

2005-11-24 Thread Paul Rubin
[EMAIL PROTECTED] (Björn Lindström) writes: > As I said before, I think you're confusing the (in Python pretty > non-existent) concept of encapsulation with Python's immutable types, > which are immutable because the implementation demands it. (A fact I > hope will disappear at some point.) What i

Re: Understanding Python Documentation

2005-11-24 Thread Colin J. Williams
Shalabh Chaturvedi wrote: > Josh Cronemeyer wrote: > >> Hi, >> >> I have very little experience programming in python but considerable >> experience with java. One thing that is frustrating me is the >> differences in the documentation style. Javadocs, at the top level >> are just a list of p

Re: Making immutable instances

2005-11-24 Thread Björn Lindström
"Giovanni Bajo" <[EMAIL PROTECTED]> writes: > My feeling is that you're trying to get too much out of my words. I'm > not trying to handcuff anyone. You seem to concentrate on me trying to > avoid people adding attributes to my precious objects. It's not > that. If I write a class and want it to b

Re: Making immutable instances

2005-11-24 Thread Giovanni Bajo
Mike Meyer wrote: >>> Note that this property of __slots__ is an implementation detail. >>> You >>> can't rely on it working in the future. >> I don't "rely" on it. I just want to catch bugs in my code. > > I certainly hope you're not relying on it to catch bugs. You should do > proper testing ins

multiple raw_inputs

2005-11-24 Thread Satya Kiran
Hi there! I m a python newbie,infact,I m a newbie to programming and I was suggested it was a good idea to start it with python. I was trying a program which needs three integers from the user.I got it by using raw_input thrice. Is there a better way(s) to do it? Can a user be prompted thrice wit

Re: defining the behavior of zip(it, it)

2005-11-24 Thread Alex Martelli
<[EMAIL PROTECTED]> wrote: ... > > >>> d=deque([1,2,3]) > > >>> d[:] > > Traceback (most recent call last): > > File "", line 1, in ? > > TypeError: sequence index must be integer > > >>> deque(d) > > deque([1, 2, 3]) > > >>> > > > > I.e., NOT all sequences implement the unreadable x[:] form.

Re: wxPython Licence vs GPL

2005-11-24 Thread Paul Rubin
Mike Meyer <[EMAIL PROTECTED]> writes: > On the other hand, so long as the price is lower than the cost of > recreating the software for someone, then it's better for society as > a whole if it exists at all. I don't think that's correct. Having nothing can be better than having something, becaus

Re: wxPython Licence vs GPL

2005-11-24 Thread Mike Meyer
"Martin P. Hellwig" <[EMAIL PROTECTED]> writes: > Mike Meyer wrote: > >> Well, they chose to make it available to others for reuse. But >> software "unavailable to those who can't afford it" is better than "no >> software at all" > That I do not agree with, I think it depends on which your side of

Re: Why is dictionary.keys() a list and not a set?

2005-11-24 Thread Mike Meyer
"Martin v. Löwis" <[EMAIL PROTECTED]> writes: > Mike Meyer wrote: >>>I trusted the doco which defines a set as "an unordered collection of >>>immutable values" (http://docs.python.org/lib/types-set.html). >> If the hash changes, you've screwed up the set. What it really should >> say is "collection

Re: python gui using boa

2005-11-24 Thread Brian Victor
ash wrote: > I have another query for you - how can i make a captionless frame > draggable in wxWindows? If you look at the wxPython demo, there's a Shaped Window demo under Miscellaneous that does this. The key portion is on line 86 in my version: #v+ def OnMouseMove(self, evt): if evt.Drag

Re: defining the behavior of zip(it, it)

2005-11-24 Thread rurpy
Alex Martelli wrote: > <[EMAIL PROTECTED]> wrote: >... > > cookbook recipies of which there are already several good > > collections, but shorter things like, copy(sequence) is spelled > > "sequence[:]". > > No way: > > >>> from collections import deque > >>> d=deque([1,2,3]) > >>> d[:] > Trac

Guification of console app

2005-11-24 Thread metiu
Say I have a console app that does something in three steps: - opens a file - transfers the file through a serial port - does some elaborations and I want to build a GUI around it that, for example, sets the file name to open or starts the different steps. I started using wxPython (actually boa-c

Re: Why is dictionary.keys() a list and not a set?

2005-11-24 Thread Martin v. Löwis
Mike Meyer wrote: >>I trusted the doco which defines a set as "an unordered collection of >>immutable values" (http://docs.python.org/lib/types-set.html). > > > If the hash changes, you've screwed up the set. What it really should > say is "collection of objects with fixed hashes", or words to th

Re: Why is dictionary.keys() a list and not a set?

2005-11-24 Thread Paul Rubin
[EMAIL PROTECTED] (Alex Martelli) writes: > Peano's axioms are perfectly abstract, as far as I recall. Russell and > Whitehead did try to construct naturals from sets (defining, e.g., '5' > as "the set of all sets with five items"), but that was before the > inherent contradictions of set theory w

Re: Why is dictionary.keys() a list and not a set?

2005-11-24 Thread Martin v. Löwis
Christoph Zwerschke wrote: > Sorry. Your answer was good; I missed the point and thought you wrote > set(d.keys()). Is it documented anywhere that set(d) = set(d.keys())? I > think this should go into the Python Doco where keys() are explained. It follows from what is documented. set() creates a

Re: wxPython Licence vs GPL

2005-11-24 Thread Martin P. Hellwig
Mike Meyer wrote: > > Well, they chose to make it available to others for reuse. But > software "unavailable to those who can't afford it" is better than "no > software at all" That I do not agree with, I think it depends on which your side of the fence you are. For instance I have a specific

Re: return in loop for ?

2005-11-24 Thread Steven D'Aprano
On Thu, 24 Nov 2005 12:51:34 +, Duncan Booth wrote: > Steven D'Aprano wrote: > >>> While outwardly they apear to offer a technique for making software >>> more reliable there are two shortcomings I'm leery of. First, no >>> verification program can verify itself; >> >> That's not a problem

Re: Why is dictionary.keys() a list and not a set?

2005-11-24 Thread Martin v. Löwis
Christoph Zwerschke wrote: > I know. But this does not answer the question: If the keys *are* already > a set according to their semantics, why aren't they returned as a set > from the beginning? Notice that this was not the question you originally asked. This one has a clear answer: because tha

Re: Why is dictionary.keys() a list and not a set?

2005-11-24 Thread Alex Martelli
Christoph Zwerschke <[EMAIL PROTECTED]> wrote: > Alex Martelli wrote: > > > An alternative theory, of course, is "God made the natural numbers; all > > else is the work of man" -- and that one is by a German, too (Kronecker, > > if I recall correctly). > > Yes, it was Kronecker. But even natural

Re: 2.4.2 on AIX fails compiling _codecs_cn.c

2005-11-24 Thread Martin v. Löwis
Paul Watson wrote: > I also note that compiles occurring after the complaint about not > finding Tcl/Tk do not appear to get the OPT= setting I specified on the > 'make' command line. It starts with compilation of structmodule.c and > includes the _codecs_??.c files. Does this have any signifi

Re: Python as Guido Intended

2005-11-24 Thread Mike Meyer
[EMAIL PROTECTED] writes: > "Mike Meyer" <[EMAIL PROTECTED]> writes: >> [EMAIL PROTECTED] writes: >> > Different programming styles are appropriate for different >> > tasks, different times and different places, different people. >> > And like morality, government, or economics, I do not believe >>

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

2005-11-24 Thread Steve Holden
[EMAIL PROTECTED] wrote: > "Fredrik Lundh" <[EMAIL PROTECTED]> wrote: > >>[EMAIL PROTECTED] wrote: >> >> the thing that's in favour is "then-if-else", not "if-then-else". >>> >>>Sorry if I confused you, I though it was clear that I meant the >>>concept, not a specific syntactical implementatio

Re: Why is dictionary.keys() a list and not a set?

2005-11-24 Thread Mike Meyer
Christoph Zwerschke <[EMAIL PROTECTED]> writes: > Mike Meyer schrieb: >> If the hash changes, you've screwed up the set. What it really should >> say is "collection of objects with fixed hashes", or words to that >> effect. Do you want to file a PR on this? > I fear I have not enough understanding

Re: wxPython Licence vs GPL

2005-11-24 Thread Mike Meyer
"Martin P. Hellwig" <[EMAIL PROTECTED]> writes: > Those who can not afford the software are excluded for that end > product even though they may have worked on the source where 99,99% of > the restricted licensed software is based on. Well, they chose to make it available to others for reuse. But

RE: Python as Guido Intended

2005-11-24 Thread Delaney, Timothy (Tim)
Ben Sizer wrote: > I agree with you that sometimes, the responses here can come across as > a bit condescending. I don't think this is intentional, as everybody > seems friendly enough, but I do see a pattern of people replying to a > query and implying that the original poster should know better

The imp module and cyclic imports

2005-11-24 Thread Matthias Kramm
Hi All, I'm having a little bit of trouble using the "imp" module to dynamically import modules. It seems that somehow cyclic references of modules don't work. I'm unable to get the following to work: I've got the following files: web/__init__.py web/one.py web/two.py testimport.py >From which

Profiling with hotshot and wall clock time

2005-11-24 Thread Geert Jansen
Hi! I'm trying to profile an application that I believe is blocking on I/O for a significant amount of time. In trying to dig down where this happens, I profiled the application with hotshot. The results are not really usable however as it seems to display the amount of CPU time which for my a

Re: Why is dictionary.keys() a list and not a set?

2005-11-24 Thread Christoph Zwerschke
Alex Martelli wrote: > An alternative theory, of course, is "God made the natural numbers; all > else is the work of man" -- and that one is by a German, too (Kronecker, > if I recall correctly). Yes, it was Kronecker. But even natural numbers are usually constructed with sets using Peano's axio

Re: the PHP ternary operator equivalent on Python

2005-11-24 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote >> dictionary accesses don't involve passes over the dictionary. > > I was actually thinking of the effects of hardware > memory cache... yeah, sure. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python as Guido Intended

2005-11-24 Thread rurpy
"Mike Meyer" <[EMAIL PROTECTED]> writes: > [EMAIL PROTECTED] writes: > > Different programming styles are appropriate for different > > tasks, different times and different places, different people. > > And like morality, government, or economics, I do not believe > > that one style of programming

Re: Why is dictionary.keys() a list and not a set?

2005-11-24 Thread Christoph Zwerschke
Mike Meyer schrieb: > If the hash changes, you've screwed up the set. What it really should > say is "collection of objects with fixed hashes", or words to that > effect. Do you want to file a PR on this? I fear I have not enough understanding of Python's hashing concepts to make a suggestion fo

Re: python gui using boa

2005-11-24 Thread ash
Thanks Brian, that was a good introduction. I have another query for you - how can i make a captionless frame draggable in wxWindows? -- http://mail.python.org/mailman/listinfo/python-list

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

2005-11-24 Thread rurpy
"Fredrik Lundh" <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > > > the thing that's in favour is "then-if-else", not "if-then-else". > > > > Sorry if I confused you, I though it was clear that I meant the > > concept, not a specific syntactical implementation. > > yup, but if you care r

Re: the PHP ternary operator equivalent on Python

2005-11-24 Thread rurpy
Fredrik Lundh wrote: > [EMAIL PROTECTED] wrote: > > > I don't find your code any more readable than the OP's > > equivalent code: > > the OP's question was > > How you do this in a practic way without > the use of one-line code ? I know. But you compared the readability of code with one-

Re: the PHP ternary operator equivalent on Python

2005-11-24 Thread rurpy
Steven D'Aprano wrote: > [EMAIL PROTECTED] wrote: > > > Fredrik Lundh wrote: > > > >>def convert(old): > >> > >>new = dict( > >>CODE=old['CODEDATA'], > >>DATE=old['DATE'] > >>) > >> > >>if old['CONTACTTYPE'] == 2: > >>new['CONTACT'] = old['FIRSTCONTACT'] > >

Iterators everywhere in Python 3000 (was: Why is dictionary.keys() a list and not a set?)

2005-11-24 Thread Robert Brewer
Title: Iterators everywhere in Python 3000 (was: Why is dictionary.keys() a list and not a set?) Alex Martelli wrote: > The typical reason I'm asking for .values() is because each > value is a count (e.g. of how many time the key has occurred) > and I want the total, so the typical idiom is s

Re: Why is dictionary.keys() a list and not a set?

2005-11-24 Thread Alex Martelli
Christoph Zwerschke <[EMAIL PROTECTED]> wrote: > mathematics, everything is a set and set theory is the "theory of > everything". When I grew up pedagogues here in Germany even believed it > would be best if kids learn set theory and draw venn diagrams before An alternative theory, of course, i

Re: wxPython Licence vs GPL

2005-11-24 Thread Martin P. Hellwig
Mike Meyer wrote: > > Is that software really unavailable, or just unavailable for free? If > the latter, then it's not unavailabe. If the former, the it didn't > become unavailable, as it was never available in the first place. > In the latter case, you could also use those examples to similarly

Re: Software keyboard

2005-11-24 Thread Mike
You need to call keybd_event which is (or was in win3.x - win95 at least) in USER32.DLL. Simulate return keypress: keybd_event(VK_RETURN,0,0,0); keybd_event(VK_RETURN,0,KEYEVENTF_KEYUP,0); Google turned this up: http://www.howtodothings.com/viewarticle.aspx?article=395 Note: This is ol

Re: Why is dictionary.keys() a list and not a set?

2005-11-24 Thread Christoph Zwerschke
Alex Martelli wrote: > Absolutely not in my use cases. The typical reason I'm asking for > .values() is because each value is a count (e.g. of how many time the > key has occurred) and I want the total, so the typical idiom is > sum(d.values()) -- getting a result set would be an utter disaster,

Re: return in loop for ?

2005-11-24 Thread Magnus Lycka
Mike Meyer wrote: > This isn't noticably different than the original. Of course, if you > want to *do* something after the for loop, you have to test > the conditional again (or use a flag variable): > > def f(): > for i in range(20): > if i > 10: break > inloop() > if not

Re: FTP over TLS

2005-11-24 Thread Dima Barsky
Carl Waldbieser <[EMAIL PROTECTED]> wrote: > Does anyone know of any good examples for writing client side code > to upload files over a secure FTP connection? I am referring to > FTPS, *not* SFTP, which I found out the hard way are two different > things. Look at the CURL library, the manual

Re: about sort and dictionary

2005-11-24 Thread Alex Martelli
Magnus Lycka <[EMAIL PROTECTED]> wrote: > Alex Martelli wrote: > > I don't think these headaches and difficulties justify dumping the whole > > field of reasoning about programs, nor the subfield of PbC. The concept > > of "immutable" is really just a tiny corner of these fields, and it's a > > l

Re: Why is dictionary.keys() a list and not a set?

2005-11-24 Thread Mike Meyer
Christoph Zwerschke <[EMAIL PROTECTED]> writes: >>>- Because sets can only contain immutable values > > Mike Meyer wrote: > >> Not true. Sets can only contain *hashable* objects, which isn't the >> same thing. > > I trusted the doco which defines a set as "an unordered collection of > immutable va

Re: about sort and dictionary

2005-11-24 Thread Magnus Lycka
Alex Martelli wrote: > I don't think these headaches and difficulties justify dumping the whole > field of reasoning about programs, nor the subfield of PbC. The concept > of "immutable" is really just a tiny corner of these fields, and it's a > long way from being the hardest or most problematic

Re: about sort and dictionary

2005-11-24 Thread Björn Lindström
Magnus Lycka <[EMAIL PROTECTED]> writes: > As I understand it, Ruby's "!" isn't quite like "procedure" in Pascal, > or "not const" in C/C++, but rather a marker for surprising behaviour, In my experience, ! is used in Ruby much the same way as it is in Scheme, signifying that a method/function is

Re: Why is dictionary.keys() a list and not a set?

2005-11-24 Thread Alex Martelli
Christoph Zwerschke <[EMAIL PROTECTED]> wrote: > Mike Meyer wrote: > > Are you sure dict.values() should be a set? After all, values aren't > > guaranteed to be unique, so dict(a = 1, b = 1).values() currently > > returns [1, 1], but would return set([1]) under your proposal. > > Good point. Cont

Re: Why is dictionary.keys() a list and not a set?

2005-11-24 Thread Christoph Zwerschke
>>- Because sets can only contain immutable values Mike Meyer wrote: > Not true. Sets can only contain *hashable* objects, which isn't the > same thing. I trusted the doco which defines a set as "an unordered collection of immutable values" (http://docs.python.org/lib/types-set.html). Anyway,

Re: Understanding Python Documentation

2005-11-24 Thread Shalabh Chaturvedi
Josh Cronemeyer wrote: > Hi, > > I have very little experience programming in python but considerable > experience with java. One thing that is frustrating me is the differences in > the documentation style. Javadocs, at the top level are just a list of > packages. Drilling down on a package

Re: wxPython Licence vs GPL

2005-11-24 Thread Mike Meyer
"Martin P. Hellwig" <[EMAIL PROTECTED]> writes: >> "Martin P. Hellwig" <[EMAIL PROTECTED]> writes: >>> If the non-techie is still interested, I'll rave on about that I >>> understand why GPL is a good way to ensure availability of IP >>> especially if the software is a collaborated effort in the ac

Re: Why are there no ordered dictionaries?

2005-11-24 Thread Christoph Zwerschke
Fuzzyman schrieb: > d.keys() will still return a copy of the list, so d.keys()[i] will > still be slower than d.sequence[i] Right, I forgot that. Bengt suggested to implement __call__ as well as __getitem__ and __setitem__ for keys, values and items. In this case, you could very effectively acc

Re: Locking a file under Windows

2005-11-24 Thread Guy Lateur
Correction: it's probably best to use the Flock class by John Nielsen. Much cleaner and working great. Info can be found here: http://aspn.activestate.com/ASPN/docs/ActivePython/2.4/pywin32/Windows_NT_Files_.2d.2d_Locking.html Best regards, g "Guy Lateur" <[EMAIL PROTECTED]> schreef in berich

Re: Why are there no ordered dictionaries?

2005-11-24 Thread Christoph Zwerschke
Bengt Richter schrieb: >>d.setvalues((13, 14)) ==> d = OrderedDict((1, 13), (2, 14)) > The implication above is that OrderedDict takes an *args argument, > but really it takes a single argument that is a sequence of k,v pairs, > (and maybe some keyword options). Right. Interpret it as a short no

Re: Why is dictionary.keys() a list and not a set?

2005-11-24 Thread Mike Meyer
Christoph Zwerschke <[EMAIL PROTECTED]> writes: > - Because sets can only contain immutable values Not true. Sets can only contain *hashable* objects, which isn't the same thing. > This, of course, in turn raises the question ;-) Would it be desirable > to have an additional, more general set dat

Re: Locking a file under Windows

2005-11-24 Thread Gregory Piñero
I'd be more worried about two users writing to the file at the same time.  I don't have much experience in that area though so maybe someone could chime in on if that's a legitimate worry or not. -Greg On 11/24/05, Tim Golden <[EMAIL PROTECTED]> wrote: [Guy Lateur]> I'm working on an application t

Re: Making immutable instances

2005-11-24 Thread Alex Martelli
Ben Finney <[EMAIL PROTECTED]> wrote: ... > > A type implemented in C offers different possibilities than one > > implemented in Python -- no deep conceptual reason, just practical > > ones. > > So, in the hypothetical situation that all Python types were > implemented in pure Python, what woul

Re: return in loop for ?

2005-11-24 Thread Mike Meyer
Roy Smith <[EMAIL PROTECTED]> writes: > In any case, in a language which has exceptions, it's almost impossible to > really have true SESE, since an exception could be thrown from almost > anywhere. To be fair, there are those who use this to argue that > exceptions themselves are a bad thing.

Re: about sort and dictionary

2005-11-24 Thread Alex Martelli
Magnus Lycka <[EMAIL PROTECTED]> wrote: ... > > I think you mean volatile or mutable rather than transient? "transient" ... > Right, volatile it is. It's really great that I can program so much > Python now that I forget my C++! :) Thanks Alex (both for reminding me > of forgotten C++ syntax

Re: Python as Guido Intended

2005-11-24 Thread Mike Meyer
Antoon Pardon <[EMAIL PROTECTED]> writes: >> The usual response is "That's not the Python way." That's not calling >> someone dumb, just pointing out that they don't yet fully understand >> the Python way. > "That is not the Python way", is just saying "Python doesn't have it" > in other words. So

Re: Writing big XML files where beginning depends on end.

2005-11-24 Thread Magnus Lycka
Ben Sizer wrote: > output = [] > > def write_tree(node): > output.append("") > sum = 0 > for child in reversed(node.children): > if child.type = leaf: > output.extend(["", "%d" % node.value, ""]) > sum += node.value > else: > sum += w

Re: backslash plague: paths containing "\a" somewhere

2005-11-24 Thread Fredrik Lundh
"tim" <[EMAIL PROTECTED]> wrote: > trying to work with a directory in windows, that has "\a" in the full > pathname > > this works: > > >>> c = string.replace('c:\content\ce\cw\cvd', '\\', '\\') > >>> c > 'c:\\content\\ce\\cw\\cvd' > > this doesn't: > > >>> c = string.replace('c:\content\a\a\av

Re: Making immutable instances

2005-11-24 Thread Mike
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > Mike Meyer wrote: >> "Giovanni Bajo" <[EMAIL PROTECTED]> writes: >> > Mike Meyer wrote: >> >> Note that this property of __slots__ is an implementation detail. You >> >> can't rely on it working in the future. >> > I don't "rely" on

Re: 2.4.2 on AIX fails compiling _codecs_cn.c

2005-11-24 Thread Paul Watson
Martin v. Löwis wrote: > Paul Watson wrote: > >> It appears that _ALL_SOURCE gets defined in the >> /usr/include/standards.h file. If we could #define _ANSI_C_SOURCE or >> _POSIX_SOURCE, it appears that it would eleminate _ALL_SOURCE. > > > Ah, ok - this should be easy enough. Python would no

Re: Help me to catch this exception :-)

2005-11-24 Thread Mardy
Le die Thu, 24 Nov 2005 07:09:26 -0800, Fuzzyman ha scribite: > I don't know the answer, but I like the problem. :-) > > What happens with the standard CGIHttpServer ? The standard CGIHttpServer uses fork() on Unix and popen() on Windows; since both these functions run the module in a separate p

Re: Making immutable instances

2005-11-24 Thread Mike Meyer
Ben Finney <[EMAIL PROTECTED]> writes: > I'm looking for a "consenting adults" restriction: classes will have > immutable instances only where it makes sense from the class protocol. > I'm not going to lose sleep over users who go looking for trouble. I think you're defining immutable differently

  1   2   3   >