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
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
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
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
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
alues in my
dictionary. Is there a better solution?
thanks,
Christoph
--
http://mail.python.org/mailman/listinfo/python-list
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
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
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
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
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
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'
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
>One idea that seems to work is setting __name__ = '__main__'
Or, del sys.modules[__name__].
--
http://mail.python.org/mailman/listinfo/python-list
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
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
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
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
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
#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
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
. 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%--
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
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
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
; [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
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
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
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
ch macro sets
help most here.
Thanks,
Christoph
--
~
~
".signature" [Modified] 1 line --100%--1,48 All
--
http://mail.python.org/mailman/listinfo/python-list
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 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
tandard lib sometime?
-- Christoph
--
http://mail.python.org/mailman/listinfo/python-list
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
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'
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
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
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
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 "
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
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
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
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
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
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
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
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
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
Bengt Richter wrote:
> I'm mostly friendly ;-)
I'm pretty sure you are :-)
-- Chris
--
http://mail.python.org/mailman/listinfo/python-list
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
; 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
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
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
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
gt; OrderedDict( (1, 11), (3, 13) )
Ordered dictionaries could allow slicing and concatenation.
-- Christoph
--
http://mail.python.org/mailman/listinfo/python-list
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
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
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
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
hat. It could lead to
an awful confusion if the keys are integers.
-- Christoph
--
http://mail.python.org/mailman/listinfo/python-list
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
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
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
t will be inserted into the correct
place by using the comparison function.
-- Christoph
--
http://mail.python.org/mailman/listinfo/python-list
(Otherwise, you would have to write "for field in d.keys()[1:]" etc.)
-- Christoph
--
http://mail.python.org/mailman/listinfo/python-list
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, (
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
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
(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
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
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
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
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).
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
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
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
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
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
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
but the latter would not work with mutable values. See
discussion with Martin.
-- Christoph
--
http://mail.python.org/mailman/listinfo/python-list
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
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
tively access it as d.values[i].
-- Christoph
--
http://mail.python.org/mailman/listinfo/python-list
ib/types-set.html).
Anyway, the problems stays the same.
-- Christoph
--
http://mail.python.org/mailman/listinfo/python-list
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
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
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
l may be equal (==)). This would not be what you expect from a set.
-- Christoph
--
http://mail.python.org/mailman/listinfo/python-list
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
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
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
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
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
/docs.python.org/lib/typesmapping.html
-- Christoph
--
http://mail.python.org/mailman/listinfo/python-list
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
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
:
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
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
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
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 - 100 of 418 matches
Mail list logo