pythonpath in ipython console

2017-07-12 Thread christoph
hello, I am a bit confused, i use spyder, when i execute in ipython console program start fails with message 'Attribute error' when I start same program via python console everything works fine, even start from terminal workes fine. It seems that i python does not load Pythonpath, although wdir

Re: Cycle around a sequence

2012-02-07 Thread Christoph Hansen
Mark Lawrence schrieb: I'm looking at a way of cycling around a sequence i.e. starting at some given location in the middle of a sequence and running to the end before coming back to the beginning and running to the start place. About the best I could come up with is the following, any better id

Re: problem with bcd and a number

2011-08-04 Thread Christoph Hansen
nephish schrieb: thanks for any tips on this. I'll try. In BCD a (decimal) digit is stored in a halfbyte (or a 'nibble'). So, in a byte you can store two decimal digits. For instance 42 would be nibble1 nibble2 0100 0010 42 >>> c=0b0110 >>> c 66 >>> c >> 4

Re: problem with bcd and a number

2011-08-04 Thread Christoph Hansen
MRAB schrieb: The value is MSB * 100 + (LSB>> 4) * 10 + (LSB& 0xF) i would say (MSB >> 4)*100 + (MSB & 0xF)*10 + (LSB >> 4) but who knows -- http://mail.python.org/mailman/listinfo/python-list

Re: Converting an array of string to array of float

2011-03-25 Thread Christoph Brand
If you want to have it even shorter and you are using Python 2.5 or greater you can also use: list1 = [float(list_item) for list_item in list1] Am 25.03.2011 16:27, schrieb Jason Swails: I'm guessing you have something like list1=['1.0', '2.3', '4.4', '5.5', ...], right? You can do this: for

dict: retrieve the original key by key

2011-05-15 Thread Christoph Groth
alues in my dictionary. Is there a better solution? thanks, Christoph -- http://mail.python.org/mailman/listinfo/python-list

Re: dict: retrieve the original key by key

2011-05-15 Thread Christoph Groth
Chris Rebert writes: > On Sun, May 15, 2011 at 1:28 AM, Christoph Groth wrote: >> I use a huge python dictionary where the values are lists of that >> dictionary's keys (yes, a graph).  Each key is thus referenced >> several times. >> >> As the keys are

connect SIGINT to custom interrupt handler

2011-05-15 Thread Christoph Scheingraber
Hi, I am trying to connect SIGINT (^c) to a custom interrupt handler like this (no threading, just straightforward): if __name__ == "__main__": quit = False def interrupt_handler(signal, frame): global quit if not quit: print "blabla, i'll finish my task and quit kind of messag

Re: dict: retrieve the original key by key

2011-05-15 Thread Christoph Groth
Steven D'Aprano writes: > On Sun, 15 May 2011 11:11:41 +0200, Christoph Groth wrote: > >> I would like to avoid having _multiple_ objects which are equal (a == >> b) but not the same (a is not b). This would save a lot of memory. > > Based on the idea of intern

Re: connect SIGINT to custom interrupt handler

2011-05-15 Thread Christoph Scheingraber
result: File "/usr/local/bin/obspysod", line 586, in interrupt_handler signal.siginterrupt(signal.SIGINT, False) AttributeError: 'int' object has no attribute 'siginterrupt' Could there be a namespace problem? On 2011-05-15, Nobody wrote: > On Sun, 15 M

Re: connect SIGINT to custom interrupt handler

2011-05-15 Thread Christoph Scheingraber
On 2011-05-15, Thomas 'PointedEars' Lahn wrote: > > Obviously. `signal' refers to an `int' object, probably by something like > > signal = 42 > > before. E.g. `print' or a debugger will tell you, as you have not showed > the relevant parts of the code. The problem is that I am running someon

Re: connect SIGINT to custom interrupt handler

2011-05-18 Thread Christoph Scheingraber
On 2011-05-15, Miki Tebeka wrote: > Why not just catch KeyboardInterrupt? Would it be possible to continue my program as nothing had happened in that case (like I did before, setting a flag to tell main() to finish the running data download and quit instead of starting the next data download {it'

Re: strange import phenomenon

2005-09-22 Thread Christoph Zwerschke
that seems to work is setting __name__ = '__main__' in test2.py, but I don't know whether that is proper. Any idea? Thanks again, Christoph -- http://mail.python.org/mailman/listinfo/python-list

Re: strange import phenomenon

2005-09-23 Thread Christoph Zwerschke
>One idea that seems to work is setting __name__ = '__main__' Or, del sys.modules[__name__]. -- http://mail.python.org/mailman/listinfo/python-list

Best practices for dynamically loading plugins at startup

2005-09-25 Thread Christoph Haas
wonder what the best practice for this kind of problem is. I looked at the "supybot" IRC bot to get an idea how plugins are handled there. Unfortunately it was still a bit over my (python) head. Regards Christoph -- ~ ~ ~ ".signature" [Modified] 3 lines --100%--3,41 All -- http://mail.python.org/mailman/listinfo/python-list

Re: Best practices for dynamically loading plugins at startup

2005-09-26 Thread Christoph Haas
ying all the proposals to get an idea of which approach works best. Regards Christoph -- ~ ~ ~ ".signature" [Modified] 3 lines --100%--3,41 All -- http://mail.python.org/mailman/listinfo/python-list

Printing and prompting adds a mysterious extra space

2005-10-01 Thread Christoph Haas
hen I run the program and enter "foobar" it looks like this: ./test.py >foobar foobar ^--- where does this space come from? I wonder where the space comes from in the line where I print what the user typed. Does it have to do with the "," after the print which I use t

Re: Printing and prompting adds a mysterious extra space

2005-10-01 Thread Christoph Haas
On Sat, Oct 01, 2005 at 01:17:41PM -0700, [EMAIL PROTECTED] wrote: > Christoph Haas wrote: > > I'm writing a simple interactive program to maintain a database. > > The goal was to print "> " at the beginning of the line, wait for > > user input and

Re: Printing and prompting adds a mysterious extra space

2005-10-01 Thread Christoph Haas
s not at the beginning of a terminal line. Interesting. Again, thanks. I'll rest my case. Christoph -- I'm still confused - just on a higher level now. ~ ~ ".signature" [Modified] 1 line --100%--1,48 All -- http://mail.python.org/mailman/listinfo/python-list

Re: Looking for a Python mentor

2005-10-14 Thread Christoph Haas
#x27;s not too much active... I believe he meant irc.freenode.net :) Christoph -- ~ ~ ".signature" [Modified] 1 line --100%--1,48 All -- http://mail.python.org/mailman/listinfo/python-list

Re: Best way to handle cgi sessions

2005-10-14 Thread Christoph Haas
ted web site which uses a MySQL table to store session information. If there is interest I'll tidy it up a bit and make it publicly available. Cheers Christoph -- ~ ~ ".signature" [Modified] 1 line --100%--1,48 All -- http://mail.python.org/mailman/listinfo/python-list

Re: Best way to handle cgi sessions

2005-10-14 Thread Christoph Haas
. If it's deemed to be decent I could use some help making it a package that can be used by others as well. There is probably a bit of perlishness that I'd like to get rid of to make it look more snake-like. Regards Christoph -- ~ ~ ".signature" [Modified] 1 line --100%--

Re: get a copy of a string leaving original intact

2005-10-20 Thread Christoph Haas
ce... I stepped about this today: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/442460 Looks close to what you are trying. Kind Regards Christoph -- ~ ~ ".signature" [Modified] 1 line --100%--1,48 All -- http://mail.python.org/mailman/listinfo/python-list

Re: testing '192.168.1.4' is in '192.168.1.0/24' ?

2005-10-24 Thread Christoph Haas
t. But somehow nothing so far was a decent substitute for Perl's Net::IP. Christoph -- ~ ~ ".signature" [Modified] 1 line --100%--1,48 All -- http://mail.python.org/mailman/listinfo/python-list

Re: New User

2005-10-24 Thread Christoph Haas
or fun? Try http://diveintopython.org/installing_python/shell.html Otherwise please provide more information so we can help. Christoph -- ~ ~ ".signature" [Modified] 1 line --100%--1,48 All -- http://mail.python.org/mailman/listinfo/python-list

Re: difference after remove

2005-10-24 Thread Christoph Haas
; [0,0,5,1,1,1,9,7,7,7]] > print intMatrix2 > I removed one '\' and it still works. > So what is the use of '\'? It's a line continuation character. But you can omit it if it's clear to the interpreter that the line must continue - like when using brack

Re: simple send only command line jabber client in python?

2005-10-25 Thread Christoph Haas
jects and can't > find anything that fits the bill. What I did find I can't get to work > correctly, probably because everything is 2 years old and out of date. Try http://xmpppy.sourceforge.net/ Christoph -- ~ ~ ".signature" [Modified] 1 line --100%--1,4

Re: So, Which Version is Suitable for Beginners

2005-11-06 Thread Christoph Haas
e (I do) you can use "Kubuntu". If you haven't heard of Gnome or KDE yet... just try Ubuntu. Christoph -- |\ _,,,---,,_Famous last words of a sysadmin: /,`.-'`'-. ;-;;,_"We'll do the backup tomorrow." <|,4- ) )-,_..;\ ( `'-' '---''(_/--' `-'\_) -- http://mail.python.org/mailman/listinfo/python-list

Re: Regular Expressions and Dividing Strings

2005-11-08 Thread Christoph Haas
regular expression matching I need, but I'm not quite sure how I can > actually split this line up into two separate variables. You probably mean: a="root:root" b,c = a.split(":") b and c contain both sides of the colon. Christoph -- ~ ~ ".signature" [Modified] 1 line --100%--1,48 All -- http://mail.python.org/mailman/listinfo/python-list

Pythonising the vim (e.g. syntax popups)

2005-11-09 Thread Christoph Haas
ch macro sets help most here. Thanks, Christoph -- ~ ~ ".signature" [Modified] 1 line --100%--1,48 All -- http://mail.python.org/mailman/listinfo/python-list

Re: Pythonising the vim (e.g. syntax popups) -> vimpst

2005-11-10 Thread Christoph Haas
thon features in Vim have that built-in. But Vim scripting looked even evil for me... and I've been working with Perl for a decade. :) Thanks for your contribution. Christoph -- ~ ~ ".signature" [Modified] 1 line --100%--1,48 All -- http://mail.python.org/mailman/listinfo/python-list

Webware for Python 0.9 released

2005-11-14 Thread Christoph Zwerschke
Webware 0.9 has been released. Webware for Python is a suite of Python packages and tools for developing object-oriented, web-based applications. The suite uses well known design patterns and includes a fast Application Server, Servlets, Python Server Pages (PSP), Object-Relational Mapping, Tas

Why are there no ordered dictionaries?

2005-11-20 Thread Christoph Zwerschke
tandard lib sometime? -- Christoph -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are there no ordered dictionaries?

2005-11-20 Thread Christoph Zwerschke
the standard lib, since I simply don't know - has it not been demanded loud enough? - is it really not needed (if you need it it shows you are doing something wrong)? - because nobody presented a satisfying implementation yet? - are there hidden difficulties or controversial issues? -- Christoph -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are there no ordered dictionaries?

2005-11-20 Thread Christoph Zwerschke
7;name', 'sal') that holds the order. Ok, you could simply use a list instead of a dictionary: d = ( ('pid', 'Employee ID', 'int'), ('name', 'Employee name', 'varchar'), ('sal', 'Salary', 'float'

Re: Why are there no ordered dictionaries?

2005-11-20 Thread Christoph Zwerschke
ld have to define the ordered dictionary in the very same ugly way: d = odict(('pid', ('Employee ID', 'int')), ('name', ('Employee name', 'varchar')), ('sal', ('Salary', 'float'))) (Unless the Python syntax would be extend to use double curly braces or something for ordered dictionaries - but I understand that this is not an option.) -- Christoph -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are there no ordered dictionaries?

2005-11-20 Thread Christoph Zwerschke
rking", "popular", and "succifiently beneficial" and "proven (to the BDFL's criteria)". > Another possibility: ordered dictionaries are not needed when Python > 2.4 has the 'sorted' builtin. The 'sorted' function does not

Re: Why are there no ordered dictionaries?

2005-11-20 Thread Christoph Zwerschke
I haven't meditated about it very much. Do you have an example for different options of behavior? -- Christoph -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are there no ordered dictionaries?

2005-11-21 Thread Christoph Zwerschke
Ben Finney wrote: >>> Another possibility: ordered dictionaries are not needed when Python >>> 2.4 has the 'sorted' builtin. Christoph Zwerschke wrote: >> The 'sorted' function does not help in the case I have indicated, >> where "

Re: Why are there no ordered dictionaries?

2005-11-21 Thread Christoph Zwerschke
uglyness of having to maintain a dictionary plus a sequence, so it's rather an issue of convenience in writing and reading programs than a performance issue. It may be different if the ordered dict would be implemented directly as an ordered hash table in C. -- Christoph -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are there no ordered dictionaries?

2005-11-21 Thread Christoph Zwerschke
hange the order. If it does not exist: Append it to the sequence of keys. Deletion: Remove from the sequence of keys." I think this is also the behavior of associative arrays in PHP or Perl and could be considered as the "ONE unambiguous definition". -- Christoph -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are there no ordered dictionaries?

2005-11-21 Thread Christoph Zwerschke
ing: Iterate over it in a guaranteed order or access item, always refering to the same object, without needing to care about building and caching auxiliary objects with different names depending on what you are doing. -- Christoph -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Christoph Zwerschke
s in the standard lib. But anyway, if I find some time, I will research a little bit more about the issue and create such a package, because it seems to me that the existing packages and recipes are not really satisfying and you're right it seems to be reasonably easy. It's on my todo list now... -- Christoph -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Christoph Zwerschke
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 to be the primary problem people who complain > with "why no sprollificator mode?" quest

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Christoph Zwerschke
t is not an option. Why should you want odict behave different than dict? 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

Re: Python in Optimized mode with /usr/bin/env

2005-11-22 Thread Christoph Zwerschke
Paulo Eduardo Neves schrieb: > I want to run an optimized python using the portable /usr/bin/env, but > the obvious ways aren't working. Seems to be a Linux problems others also experienced: http://blog.ianbicking.org/shebang.html -- Christoph -- http://mail.python.org/mailman/list

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Christoph Zwerschke
consider it "the one" standard implementation for ordered dictionaries. Also, in the use cases mentioned (describing database columns, html form fields, configuration parameters etc.), the dictionary is usually only created once and then not changed, so different handling of re-insertion or deletion of keys would not even be relevant in these cases. -- Christoph -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Christoph Zwerschke
and an "ordered dictionary" (where the keys are not automatically ordered, but 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

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: Why are there no ordered dictionaries?

2005-11-22 Thread Christoph Zwerschke
e methods for sorting (like PHP's ksort()). This way, you could initialize an ordered dict from an ordinary dict, sort it, and from then on never care to call keys().sorted() or something when iterating over the dictionary. Probably there are other methods from lists that could b

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Christoph Zwerschke
; OrderedDict( (1, 11), (3, 13) ) d1.reverse() ==> OrderedDict( (3, 13), (2, 12), 1, 11) ) d1.insert(1, (4, 14)) ==> OrderedDict( (1, 11), (4, 14), (2, 12), 3, 13) ) etc. But no other way to directly manipulate the keys should be provided. -- Christoph -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Christoph Zwerschke
I have pointed out in another posting in this thread, all other implementations have the same semantics for the basic behavior. I cannot see three different groups. Again, what's so surprising as the "natural" semantics described here: http://mail.python.org/pipermail/python-dev/2005-Ma

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Christoph Zwerschke
full implementation, just the relevant part. Of course, a real implementation should also allow to build an ordered dict from another ordered dict or an ordinary dict. (In the latter case, maybe the keys should be automatically sorted.) But one or two case disctinctions would not make things ment

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: Why are there no ordered dictionaries?

2005-11-22 Thread Christoph Zwerschke
gt; OrderedDict( (1, 11), (3, 13) ) Ordered dictionaries could allow slicing and concatenation. -- Christoph -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Christoph Zwerschke
mance improvements - the internal keys list should be hidden - list methods should be mixed in instead -- Christoph -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are there no ordered dictionaries?

2005-11-22 Thread Christoph Zwerschke
nsiderations, since the keys must stay unique. A concatenation of ordered dicts with overlapping keys should probably give an IndexError. -- Christoph -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are there no ordered dictionaries?

2005-11-23 Thread Christoph Zwerschke
ns of convenience. So *if* they ever go to the standard lib, I'm not sure whether "collections" would be the right place. Or collections will need a different description - maybe there are other interesting basic collection types which are chosen for convenience, not for performance (for instance, ordered sets)? -- Christoph -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are there no ordered dictionaries?

2005-11-23 Thread Christoph Zwerschke
By the way, you will find the same terminology in Smalltalk, where "SortedCollection" is a subclass of "OrderedCollection". -- Christoph -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are there no ordered dictionaries?

2005-11-23 Thread Christoph Zwerschke
hat. It could lead to an awful confusion if the keys are integers. -- Christoph -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are there no ordered dictionaries?

2005-11-23 Thread Christoph Zwerschke
difference between "ordered" and "sorted" and now I wrote such a confusing sentence. You're right, C++ Maps are not an example for "ordered dictionaries", but for "sorted dictionaries". -- Christoph -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are there no ordered dictionaries?

2005-11-23 Thread Christoph Zwerschke
ehaviour. You're right with both. The ECMA language definition says object properties are an unordered collection, but MSIE and probably other browsers keep the order in which they were created. Of course one should not rely on that. -- Christoph -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are there no ordered dictionaries?

2005-11-23 Thread Christoph Zwerschke
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 re

Re: Why are there no ordered dictionaries?

2005-11-23 Thread Christoph Zwerschke
t will be inserted into the correct place by using the comparison function. -- Christoph -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are there no ordered dictionaries?

2005-11-23 Thread Christoph Zwerschke
(Otherwise, you would have to write "for field in d.keys()[1:]" etc.) -- Christoph -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are there no ordered dictionaries?

2005-11-23 Thread Christoph Zwerschke
Bengt Richter wrote: > >>> from odictb import OrderedDict > >>> d1 = OrderedDict([(1, 11), (2, 12), (3, 13)]) > >>> d1 > {1: 11, 2: 12, 3: 13} > >>> d1[1:] > {2: 12, 3: 13} > >>> d1[0:1] + d1[2:3] > {1: 11, 3: 13} > >>> d1.reverse() > >>> d1 > {3: 13, 2: 12, 1: 11} > >>> d1.insert(1, (

Re: Why are there no ordered dictionaries?

2005-11-23 Thread Christoph Zwerschke
not introduce new concepts or attributes if everything can be done intuitively with the existing Python methods and operators. -- Christoph -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are there no ordered dictionaries?

2005-11-23 Thread Christoph Zwerschke
then use this as the new sequence of keys, and similar with values(). This way, no new methods need to be introduced. -- Christoph -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are there no ordered dictionaries?

2005-11-23 Thread Christoph Zwerschke
(d.keys())) and d.asort() = d.values(sorted(d.values())) Anyway, I don't like "ksort" and "asort". If it must be, I'd rather use d.ksort() = d.sortkeys() d.asort() = d.sortvalues() d.sort() could default to one of them (not sure which one). -- Christoph -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are there no ordered dictionaries?

2005-11-23 Thread Christoph Zwerschke
said, I would not need to access the sequence, if I can write d1.sort() or d1.sortkeys() > If you don't want to modify sequence, don't. If you want a copy do : > seq = d1.sequence[:] This is not needed since you can do the same with: seq = d1.keys() -- Christoph -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are there no ordered dictionaries?

2005-11-23 Thread Christoph Zwerschke
Carsten Haese schrieb: > Thus quoth the Zen of Python: > "Explicit is better than implicit." > "In the face of ambiguity, refuse the temptation to guess." > > With those in mind, since an odict behaves mostly like a dictionary, [] > should always refer to keys. An odict implementation that wants

Re: Accessing a database from a multithreaded application

2005-11-23 Thread Christoph Zwerschke
ooling. DBUtils supports both. I plan to write a doco describing these ideas and the usage of DBUtils in detail. For now you need to get along with the inline docstrings. -- Christoph -- http://mail.python.org/mailman/listinfo/python-list

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

2005-11-23 Thread Christoph Zwerschke
a |= b == a = { 1:11, 2:22, 3:13 } a.intersection_update(b) == a &= b == a = { 2:22 } a.difference_update(b) == a -= b == a = { 1:11 } a.symmetric_difference_update(b) == a ^= b == a = { 1:11, 3:13 } Of these, a |= b may be particularly interesting as short notation for a.update(b).

Re: Why are there no ordered dictionaries?

2005-11-23 Thread Christoph Zwerschke
Here is another old posting I just found which again gives the same use cases and semantics: http://mail.python.org/pipermail/python-dev/2005-March/051974.html "Keys are iterated over in the order that they are added. Setting a value using a key that compares equal to one already in the dict rep

Re: Why are there no ordered dictionaries?

2005-11-24 Thread Christoph Zwerschke
Duncan Booth schrieb: > On IE this will go through elements in the order 0, 1, 2, 4, 3. Oops! I bet most people would not expect that, and it is probably not mentioned in most Javascript tutorials. I think this is a weakpoint of the ECMA definition, not MSIE. -- Christoph -- h

Re: Why are there no ordered dictionaries?

2005-11-24 Thread Christoph Zwerschke
Fuzzyman schrieb: > I'm going to add some of the sequence methods. I'm *not* going to allow > indexing, but I will allow slicing. > > You can also do d[d.keys()[i]] > > This provides two ways of fetching values by index, so I don't want to > add another. And this would be probably faster than d

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

2005-11-24 Thread Christoph Zwerschke
ta types. By the way, i wonder why the common mathematical notation { 1,2,3 } was not allowed for set((1,2,3)). It would not clash with the dictionary notation which requires additional colons. -- Christoph -- 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
made more clear by using sets. (Similar as the reason why you use False and True when you could use 0 and 1 instead.) -- Christoph -- 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
would have expected that set(d) returns set(d.items()), but as has been discussed, this would cause problems with mutable values. -- Christoph -- 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
but the latter would not work with mutable values. See discussion with Martin. -- Christoph -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are there no ordered dictionaries?

2005-11-24 Thread Christoph Zwerschke
e_of_items) > d1.sequence.sort() > > *but* it frees the squence attribute from any implementation details. You should also implement d1.sort() or d1.sortkeys() which will have no performance drawbacks. -- Christoph -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are there no ordered dictionaries?

2005-11-24 Thread Christoph Zwerschke
to implement comparisons. Wouldn't it be more performant to compare for d1.internal_dict==d2.internal_dict and d1.internal_sequence==d2.internal_sequence? You don't keep track of the item lists, they need to be built on every occasion. -- Christoph -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are there no ordered dictionaries?

2005-11-24 Thread Christoph Zwerschke
tively access it as d.values[i]. -- Christoph -- 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
ib/types-set.html). Anyway, the problems stays the same. -- Christoph -- 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
thing". When I grew up pedagogues here in Germany even believed it would be best if kids learn set theory and draw venn diagrams before they learn arithmetics... We were tortured with that kind of things in the first class. Probably I'm still suffering from the late damages of that treatment. -- Christoph -- 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
surely wouldn't want to do this to the list of items just to be able to return it as a set. -- Christoph -- 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
cle IS-AN ellipse" in > Euclidean geometry... but inheriting Circle from Ellipse doesn't work in > OO if the objects are changeable, since you can, e.g., change > eccentricity in an Ellipse but not in a Circle... Good example. -- Christoph -- 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
l may be equal (==)). This would not be what you expect from a set. -- Christoph -- 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
here is also another semantical issue: > If one element is skipped/dropped, which of these (a or b)? I should have read your posting fully before writing the above ;-) -- Christoph -- 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
of Mathematics there are things which can only be believed, but not be proven. Just as in Physics there are things which can only be predicted with a certain probability, but they are not predetermined completely. But now we're really getting off topic. -- Christoph -- http://mail

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

2005-11-24 Thread Christoph Zwerschke
print k, v instead of: for k in d: print k, d[k] What I wanted to say is that the doco could mention this possibility to get the keys as a set at the place where it explains the keys() method. -- Christoph -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are there no ordered dictionaries?

2005-11-25 Thread Christoph Zwerschke
Le ruego me perdone. replace('haber', random.choice('tener', 'hacer', 'lograr')) Mi espanol es peor que mi python. -- Christoph -- http://mail.python.org/mailman/listinfo/python-list

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

2005-11-25 Thread Christoph Zwerschke
7;s a good example showing that the term 'mutable' is not so well-defined as it may seem. If you set b=[]; a=(1,b); should a be considered mutable (because you can change its value by changing b), or should it be considered immutable (because it is a tuple)? -- Christoph -- http://mai

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

2005-11-25 Thread Christoph Zwerschke
/docs.python.org/lib/typesmapping.html -- Christoph -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are there no ordered dictionaries?

2005-11-25 Thread Christoph Zwerschke
idea in terms of using it (we could just > leave the sequence attribute as an alias for the new keys attribute - > for backwards compatibility). Yes, you could make it a deprecated feature. -- Christoph -- http://mail.python.org/mailman/listinfo/python-list

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

2005-11-25 Thread Christoph Zwerschke
objects hash the same. Otherwise, semantics would suffer, you could have dicts with non-unique keys (i.e. keys which are only distinct as objects, but not different as values). -- Christoph -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are there no ordered dictionaries?

2005-11-25 Thread Christoph Zwerschke
: http://pleac.sourceforge.net/pleac_python/hashes.html#AEN250 Anyway, I still favor the more common term "ordered dictionary". -- Christoph -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are there no ordered dictionaries?

2005-11-25 Thread Christoph Zwerschke
It seems everybody is in full agreement here. I have the same mixed feeling about letting keys/values/items become both managed list attributes and still returning copies of the lists when called in the usual way as methods. I don't know any precedent for doing things that way and i'm unsure w

Re: Why are there no ordered dictionaries?

2005-11-25 Thread Christoph Zwerschke
my argument was not good (avoiding new attributes names in order to keep the vocabulary small). And by the way, what both of us listed as strengths of Python will be probably claimed by protagonists of any other language as well. -- Christoph -- http://mail.python.org/mailman/listinfo/python-list

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

2005-11-25 Thread Christoph Zwerschke
st sentence, it was unclear whether "they" refered to the class or the instance. But anyway, what about the following class: class mylist(list): pass This class definitely has a __hash__ method. But instances of this class are not hashable. -- Christoph -- http://mail.python.org/mailman/listinfo/python-list

  1   2   3   4   5   >