On Mon, 23 Oct 2006 18:56:21 -0700, Paul Rubin wrote:
> Steven D'Aprano <[EMAIL PROTECTED]> writes:
>> def display(**kwargs):
>> fs = format(kwargs['argument'])
>> return fs % kwargs
>
> def display(**kwargs):
> fs = format(kw
Announcing argparse 0.2
---
argparse home:
http://argparse.python-hosting.com/
argparse single module download:
http://argparse.python-hosting.com/file/trunk/argparse.py?format=raw
argparse bundled downloads at PyPI:
http://www.python.org/pypi/argparse/
About this releas
Larry Bates wrote:
> I would venture to guess that this is the one I would lean towards
> if I needed SOAP support:
>
> http://www.effbot.org/downloads/#elementsoap
>
> I know is says "experimental" but Fredrik Lundh's idea of experimental
> always seems to be everyone else's idea of a shipping p
Kenneth McDonald wrote:
> I would like to avoid putting this up on sourceforge as I think it would
> do much better at a site aimed specifically at Python development.
I've been using python-hosting.com for the argparse module and found it
to be a pretty good solution. They offer free Trac/Subv
[EMAIL PROTECTED] wrote:
> Recently I've had some problems with PythonWin when I switched to
> Py2.5, tooka long hiatus, and came back. So now I'm without my god sent
> helper, and I'm looking for a cool replacement, or some advocation to
> reinstall/setup PyWin. But the Python website's list is ir
Cameron Walsh wrote:
> Which brings me to the question, would this solution:
>
> B = set(B)
> A = B + list(x for x in A if x not in B)
>
> be faster than this solution:
>
> B = set(B)
> A.sort(key=B.__contains__, reverse=True)
>
> My guess is yes, since while the __contains__ method is only run
ad the final word and Python now has bools.
Take particular note of her description of Python distinguishing between
Something ("cat", 4, [0, 1, 2] etc) and Nothing ("", 0, [] etc).
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
Paul Rubin wrote:
> Steven Bethard <[EMAIL PROTECTED]> writes:
>> Cameron Walsh wrote:
>>> Which brings me to the question, would this solution:
>>> B = set(B)
>>> A = B + list(x for x in A if x not in B)
>>> be faster than this solution:
>>
of True/False, but that is less common than you might
think.
> So IMO it would have
> been better if python had made the distinction between True and
> False and so made the programmer code the Something/Nothing
> disctinction explicitly.
I don't understand what you are saying here, unless it is that you
believe that Python should have strict Pascal-style Booleans.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
sh.
But in this specific instance, I don't see any advantage to explicitly
testing the length of a list. Antoon might think that is sufficiently
polymorphic, but it isn't. He cares whether the object has zero _length_,
but for true polymorphism, he should be caring about whether the ob
t;
>> bugger off
>>
>> Clearly this is not true. (Google Cliff/Dyer open source: only 11
>> hits.), but the string is *something* so the if block gets evaluated.
>>
> >>> if "The above example was bollocks":
> ... print "You don
On Fri, 27 Oct 2006 17:35:58 +, Antoon Pardon wrote:
> On 2006-10-27, Steven D'Aprano <[EMAIL PROTECTED]> wrote:
>
>> But in this specific instance, I don't see any advantage to explicitly
>> testing the length of a list. Antoon might think that is suffici
t; B maps to max(0, A-B)
or more verbosely, "Remove B items from A items, stopping when there are
no more items to remove. What is left over? Something or Nothing?"
Likewise, A < B maps to max(0, B-A).
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, 27 Oct 2006 11:25:09 -0700, Carl Banks wrote:
> Steven D'Aprano wrote:
>> But in this specific instance, I don't see any advantage to explicitly
>> testing the length of a list. Antoon might think that is sufficiently
>> polymorphic, but it isn't.
ttributeError: 'function' object has no attribute 'bar'
but it doesn't work as I expected.
where do nested functions live? How can you access them, for example, to
read their doc strings?
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
f there is no way of accessing them externally, should I make
them mere # comments?
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
type questions. It would be
a funny sort of learning process that forced students to live in a
vacuum, never discussing their topic with anyone else, never asking the
most trivial questions.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
st is created in the
time period between checking if it exists and attempting the rename.
Is there any way to prevent this? Or do I just try to keep the check and
the rename as close together as possible, minimizing the chances and
hoping for the best?
--
Steven.
--
http://mail.python.org/ma
On Sat, 28 Oct 2006 11:42:42 +0200, Marc 'BlackJack' Rintsch wrote:
> In <[EMAIL PROTECTED]>, Steven
> D'Aprano wrote:
>
>> On Fri, 27 Oct 2006 11:25:09 -0700, Carl Banks wrote:
>>
>>> Iterators do have overlapping uses with lists, but
the built in types and checked how many
have a length versus how many work in a truth-context?
>>> import types
>>> if types:
... print "Modules work with bool"
...
Modules work with bool
>>> if len(types)>0:
... print "Modules work with len"
...
Traceback (most recent call last):
File "", line 1, in ?
TypeError: len() of unsized object
"if len(a)>0:" only works for objects that define __len__.
"if a:" works for any object that doesn't go to the trouble of
specifically prohibiting it, as numpy arrays deliberately do. That's the
Python way, and it is a deliberate design.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
he destination
*doesn't* exist, so there is no destination file to open. How will it help
me to lock the source file? Have I misunderstood?
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
condition" -- that was the term I was looking for ... now maybe
I'll have some better results with Google.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
On Sun, 29 Oct 2006 00:29:06 +0200, Wolfgang Draxinger wrote:
> Steven D'Aprano wrote:
>
>> Open "the" file? There are potentially two files -- the source
>> and destination. I only want to do the rename if the
>> destination *doesn't* exist, so there
On Sun, 29 Oct 2006 00:31:23 -0700, Carl Banks wrote:
> Steven D'Aprano wrote:
>> Carl Banks:
>> > Overall, your objections don't really apply, since you're arguing what
>> > ought to be whereas my argument is pragmatic. Practically speaking, in
>>
ut this doesn't
> work:
Unfortunately my crystal ball is back at the shop being repaired, so
you'll have to explain what "doesn't work" means in this case. Does it
raise an exception? If so, please post the exception. Does it do something
different from what you expected? Then what did you expect, and what did
it do?
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
nsideration." (Stan Kelly-Bootle)
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
licated? What's wrong with using __import__ to get
a module object?
>>> mod = __import__("math")
>>> mod
The only advantage (or maybe it is a disadvantage?) I can see to your
function is that it doesn't search the Python path and you can specify an
absolute file name.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
one, continue the rest of the program
That's not exactly what Python does, of course, it is much more efficient,
but that's a good picture of what happens.
> - where the "while 1:"-loop is quitted.
The while 1 loop is escaped when the function hits the return statement.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, 31 Oct 2006 12:44:50 +0100, Fredrik Lundh wrote:
> Steven D'Aprano wrote:
>
>> The only advantage (or maybe it is a disadvantage?) I can see to your
>> function is that it doesn't search the Python path and you can specify an
>> absolute file name.
>
On Tue, 31 Oct 2006 22:53:56 +1100, Ben Finney wrote:
> "Steven D'Aprano" <[EMAIL PROTECTED]> writes:
>
>> On Tue, 31 Oct 2006 11:00:52 +1100, Ben Finney wrote:
>>
>> > If you want a solution that gives you an actual module object,
>> > he
to open the file
>
> Or you can simply use 'os.path.exists', as has been suggested several
> times in this thread.
But there can be a race condition between os.path.exists returning True
and you trying to open the file, if some other process deletes or renames
the file in the meantime.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
On Thu, 02 Nov 2006 12:59:32 +0100, Anton81 wrote:
> When I execute the program it
> complains that it can't find an operator "/" for "instance" and "integer".
How about if you post the actual traceback you get, rather than
paraphrasing? That way, we don
python-dev Summary for 2006-09-16 through 2006-09-30
.. contents::
[The HTML version of this Summary is available at
http://www.python.org/dev/summary/2006-09-16_2006-09-30]
=
Summaries
=
---
Import features
python-dev Summary for 2006-09-01 through 2006-09-15
.. contents::
[The HTML version of this Summary is available at
http://www.python.org/dev/summary/2006-09-01_2006-09-15]
=
Announcements
=
null).timeit()
0.7631678581237793
>>> ftimer(null, [], {})
1.8860080242156982
>>> ftimer2(null) # version that doesn't pass *args and **kwargs
0.90903997421264648
Can anyone help me understand these results? Why is the overhead
associated with timeit apparently so much smaller than the overhead in my
ftimer functions?
Am I barking up the wrong tree here? Is there a flaw in my reasoning, and
I'm measuring execution time the wrong way?
Or is it that the timeit module and my ftimer functions are measuring
subtly different things?
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, 03 Nov 2006 18:02:37 -0800, Carl Banks wrote:
>>>> import timeit
>>>> timeit.Timer("foo(1)","from __main__ import foo")
> 1.1497418880462646
Well, that was scarily simple.
Thank you.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
import pi
Or just import const and refer to const.pi. That's arguably clearer,
although again there is a tiny performance cost.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
mputations
# define some constants
G = 1.0 # gravity is strong in this universe...
# define some functions
def force_of_gravity(m1, m2, r):
return G*m1*m2/r**2
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
n"
app = creApp()
print "done creApp"
creWin()
print "done creWin"
from twisted.internet import reactor
print "done import"
reactor.run()
print "done reactor.run; exiting main"
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
ore experienced programmers could whack
> into shape if they were interested. or not...
Something like this would probably go very well on Useless Python, or the
Cheeseshop:
http://www.uselesspython.com/
http://cheeseshop.python.org/pypi
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
rg/2005/03/11/web-scraping-with-python-part-ii/
http://wiki.tcl.tk/2915 (not focused on Python, but may still be useful).
> Ultimately I would like someone to write a script for me.
Are you offering to hire a developer?
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
g(instance) => tuple containing instance
g(tuple) => tuple containing tuple
You could write something like this:
def g(*arg):
# Detect the special case of a single tuple argument
if len(arg) == 1 and type(arg[0]) == tuple:
return arg[0]
else:
return arg
but now tuple arguments are treated differently to all other data. Why do
you think you need that?
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
> so how should I get from
> {'a':('ASLIB','Aslib'),'j':('JDOC','jdoc')}
> to
> ('Aslib','ASLIB','JDOC','jdoc')
Assuming you don't care what order the strings are in:
r = {'a':('ASLIB','Aslib'),'j':('JDOC','jdoc')}
result = sum(r.values(), ())
If you do care about the order:
r = {'a':('ASLIB','Aslib'),'j':('JDOC','jdoc')}
keys = r.keys()
keys.sort()
result = []
for key in keys:
result.extend(r[key])
result = tuple(result)
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
quot;hello world")
({}, None, 1, -1.2, 'hello world')
Actually, they aren't *quite* identical: your function rips lists apart,
which is probably not a good idea.
>>> f("foo", [1,2,3], None) # three arguments turns into five
('foo', 1, 2, 3, None)
>>> shortf("foo", [1,2,3], None) # three arguments stays three
('foo', [1, 2, 3], None)
I still don't understand why you are doing this. Can we have an example of
why you think you need to do this?
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
Simon Wittber wrote:
> I want to build a Python2.5 interpreter for an embedded system. I only
> have 4MB of RAM to play with, so I want to really minimise the python
> binary.
[snip]
> Google tells me that people have done this before, back in Python1.5.2
> days. Has anyone tried to do this recentl
explain *what* you want to do, but not *why* you
want to do it.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
think it will be too complex to be fun.
> Or maybe there's some way to loop through two lists (the stats and the
> attributes) and assign them that way? I was thinking of a nested for
> statement but that didn't seem to work.
def __init__(self, stats):
names = ['strength', 'dexterity', 'intelligence', 'luck']
for name, stat in zip(names, stats):
setattr(self, name, stat)
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
Python, and it fills much the same role.
This is true for old-style classes.
> It says the __init__ is called immediately after an instance of the
> class is created. What dose "immediately" mean?
Once the __new__ method creates the instance and returns, before anything
else happens, the instance's __init__ method is called.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, 07 Nov 2006 12:54:36 +0200, Alistair King wrote:
> Does anyone knows of a simple way of
> determining how much processer time it takes to do these calculations?
See the timeit module.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
ould have been bothered
by it in the least!
Out of curiosity, do you think the spammer actually reads comp.lang.python?
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
ed attributes as well?
**kwargs flexibility carries a risk. You may consider it worthwhile or not.
> Or does this matter as long as you are handling the processing yourself
> internally and not allowing users access to the Character class?
Only you can decide whether **kwargs' convenience and flexibility
outweighs its risk.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
apping object for some other reason, then well and good, pass it into the
function. Otherwise, well, I believe the correct container for
character attributes is a Character, not a dict.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
On Thu, 09 Nov 2006 10:36:07 +, Antoon Pardon wrote:
> On 2006-11-09, Steven D'Aprano <[EMAIL PROTECTED]> wrote:
>> On Thu, 09 Nov 2006 12:27:12 +1100, Ben Finney wrote:
>>
>>> John Salerno <[EMAIL PROTECTED]> writes:
>>>
>>>> Ben
On Thu, 09 Nov 2006 03:31:02 -0800, John Machin wrote:
>
> Bruno Desthuilliers wrote:
>> Gabriel Genellina wrote:
>> > At Wednesday 8/11/2006 22:29, zeal elite wrote:
>> >
>> >> I am looking for substring search python program without using the
>> >> built in funtions like find, or 'in'.
>> >
>>
d just for the avoidance of doubt, Python "x == blue or red or yellow"
is semantically equivalent to:
(x == blue) or bool(red) or bool(yellow)
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
the case.
When you've done your own usability testing, comparable to that already
done, then please feel free to let us know whether the evidence matches
your intuitions.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
27;ll find that
> programming without the colons just simply feels more "natural".
And maybe you're even correct. But one major reason of using the colon is
to make it easier for _inexperienced_ programmers. Your suggestion that
programming in Ruby for a while should b
essional butchers who don't think that using a sharp knife is a
good idea.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, 10 Nov 2006 22:41:53 -0600, skip wrote:
>
> Steven> The world seems to be flat, the sun appears to rotate around the
> Steven> Earth, and mushrooms look like they are more closely related to
> Steven> plants than to animals, but none of these things are
On Sat, 11 Nov 2006 01:13:03 -0600, Ron Adam wrote:
> Steven D'Aprano wrote:
>> On Fri, 10 Nov 2006 21:24:50 +0100, Bjoern Schliessmann wrote:
>>
>>> Marc 'BlackJack' Rintsch wrote:
>>>
>>>> No it doesn't -- look again at the e
>
> Is this a reasonable approach overall?
> (Including the last line.)
(1) If there really is no alternative to a class with many arguments;
(2) and instances can vary those arguments unpredictably;
then this approach seems reasonable to me. But I really suggest you
rethink your class design.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
rison, the way I read the Original Poster, he was sincere if
misguided -- but Doug's bullshit response is a typical attempt to throw
petrol on an already hot situation.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
runswick 3056.00
Clifton Hill 3068.00
Sydney 2000.00
St Johns Park 2176.00
and so forth. You can't have too much precision with those floating point
post/ZIP codes!
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
4, 9, 8, 7]]
Repeat after me:
"Not everything has to be a one-liner."
If sum() is too slow, because your sub-lists are huge, you can easily
factor that out and replace it with something using extend.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
returns self, just don't bother.)
Even more fundamentally, any time you need to pass the instance to a
function, you need an explicit self. (Delegation is a special case of this.)
def __str__(self):
# I like semicolons and dislike square brackets.
return ';'.join(self)
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
On Sun, 12 Nov 2006 20:38:31 +1100, Ben Finney wrote:
> But you try to tell people overseas about this legislation, and they
> just don't believe you.
Ha! You were lucky. When I was a lad, we had to write our postcodes on
envelopes in balanced ternary.
--
Steven.
--
http://mail
tchas are vulnerable to the old
distributed hybrid human-machine network trick: "We'll give you a free
account on our porn site if you spend fifteen minutes a day solving
captchas for our bot network." The only solution to that, I fear, is open
season on spammers and anyone who buys from a spammer.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
Chris Brat wrote:
> I've seen a few posts, columns and articles which state that one of the
> advantages of Python is that code can be developed x times faster than
> languages such as <>.
>
> Does anyone have any comments on that statement from personal
> experience?
I had to work at a laborator
once in a while.
Does anyone have generic advice for the testing and development of this
sort of function?
--
Steven D'Aprano
--
http://mail.python.org/mailman/listinfo/python-list
.width", "from __main__ import Rect; r =
>>> Rect(1,2,3,4)").timeit()
2.3775210380554199
Now you know how to test how fast code runs, you can write some code to
test.
--
Steven D'Aprano
--
http://mail.python.org/mailman/listinfo/python-list
se the computer parser doesn't need it.
Evidence given: "it seems to me" repeated loudly until our ears bleed.
People's intuition is notoriously poor at judging usability. I don't say I
give it zero credence, but I give it very little.
--
Steven D'Aprano
--
http://mail.python.org/mailman/listinfo/python-list
ur character classes!)
And last but most certainly not least, you can separate the adjustment
values into (say) an INI file, read them in at run-time and pass those
values to the factory function above. Then write another function which
walks through the INI file, adjusting the values in pl
r not. But since cost-free redundancies don't exist,
or at least are very rare, we should prefer to remove redundancies UNLESS
they offer some advantage.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
they can hardly be said to choose Java because it works best for them
if they know no other languages to compare it to!
(The same naturally goes for those who only know Python, or any other
language.)
--
Steven D'Aprano
--
http://mail.python.org/mailman/listinfo/python-list
+= 2
# now get all the even numbers up to 15
L = [n for n in evens() if n < 15]
--
Steven D'Aprano
--
http://mail.python.org/mailman/listinfo/python-list
;t control.
He wants to run this untrusted (hostile or buggy or both) code in an
environment where it can't do bad things. "Bad things" include Denial of
Service attacks. So, Timmy, let's hear your brilliant scheme for
preventing DoS attacks when running hostile c
open and dispose of 20 subshells, even with the "for
line in shellOut" loop.
I think you need some more fine-grained testing to determine whether the
slowdown is actually happening inside the "for line in shellOut" loop or
inside the while loop or when the while loop completes.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
;> get_close_matches("apple", _keyword.kwlist)
[]
>>> get_close_matches("accept", _keyword.kwlist)
['except']
Those example, by the way, come from here:
>>> help(get_close_matches)
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
Seems to work for me.
And if you think that's bad, check out this:
>>> '+'.join ( [ 'a' , 'b' ] )
'a+b'
How to write legal but unreadable code in Python.
--
Steven D'Aprano
--
http://mail.python.org/mailman/listinfo/python-list
e search string with the fewest differences.
As for getting a feel of what constitutes a match, I really can't make any
better suggestion than just try lots of examples with the interactive
Python shell.
--
Steven D'Aprano
--
http://mail.python.org/mailman/listinfo/python-list
ments
>>>
>>> for block in t.get_matching_blocks():
... print "a[%d] and b[%d] match for %d elements" % block
...
a[0] and b[0] match for 4 elements
a[5] and b[4] match for 1 elements
a[6] and b[6] match for 2 elements
a[8] and b[8] match for 0 elements
>>>
I think what you are seeing is an artifact of the precise details of the
pattern matcher. Feel free to subclass the SequenceMatcher or Differ
classes to get the results you expect :-)
--
Steven D'Aprano
--
http://mail.python.org/mailman/listinfo/python-list
David Isaac wrote:
> 2. Is this a good argmax (as long as I know the iterable is finite)?
> def argmax(iterable): return max(izip( iterable, count() ))[1]
In Python 2.5:
Python 2.5a2 (trunk:46491M, May 27 2006, 14:43:55) [MSC v.1310 32 bit
(Intel)] on win32
>>> iterable = [5, 8, 2, 11, 6]
>>>
[EMAIL PROTECTED] wrote:
> i'm looking for a way to have a list of number grouped by consecutive
> interval, after a search, for example :
>
> [3, 6, 7, 8, 12, 13, 15]
>
> =>
>
> [[3, 4], [6,9], [12, 14], [15, 16]]
Know your itertools. From the examples section[1]:
"""
# Find runs of consecut
A.M wrote:
> Do we have the conditional expressions in Python 2.4?
bruno at modulix wrote:
> No, AFAIK they'll be in for 2.5
Yep:
Python 2.5a2 (trunk:46491M, May 27 2006, 14:43:55) [MSC v.1310 32 bit
(Intel)] on win32
>>> "Yes" if 1 == 1 else "No"
'Yes'
> In the meanwhile, there are (sometim
Gerard Flanagan wrote:
> [EMAIL PROTECTED] wrote:
>> hello,
>>
>> i'm looking for a way to have a list of number grouped by consecutive
>> interval, after a search, for example :
>>
>> [3, 6, 7, 8, 12, 13, 15]
>>
>> =>
>>
>> [[3, 4], [6,9], [12, 14], [15, 16]]
>>
>> (6, not following 3, so 3 => [3:
James J. Besemer wrote:
> I propose that we extend the semantics of "print" such that if the
> object to be printed is a generator then print would iterate over the
> resulting sequence of sub-objects and recursively print each of the
> items in order.
I don't feel like searching for the specif
[EMAIL PROTECTED] wrote:
>> ... _, first_n = group[0]
>
> what is the meaning of the underscore "_" ? is it a special var ? or
> should it be readed as a way of unpacking a tuple in a non useful var ?
> like
>
> lost, first_n = group[0]
Yep, it's just another name. "lost" would have wo
jj_frap wrote:
> I'm new to programming in Python and am currently writing a three-card
> poker simulator. I have completed the entire simulator other than
> determining who has the best hand (which will be far more difficult
> than the aspects I've codes thus far)...I store each player's hand in a
Robert Kern wrote:
> Steven Bethard wrote:
>> Can you do something like::
>>
>> max_val, max_index = max((x, i) for i, x in enumerate(my_list))
>>
>> ? If any two "x" values are equal, this will return the one with the
>> lower index. Do
python-dev Summary for 2006-03-16 through 2006-03-31
.. contents::
[The HTML version of this Summary is available at
http://www.python.org/dev/summary/2006-03-16_2006-03-31]
=
Announcements
=
---
Pyth
me rewriting of the tools that currently do string
extraction using ``_()``, so the idea was rejected.
Contributing thread:
- `The "i" string-prefix: I18n'ed strings
<http://mail.python.org/pipermail/python-dev/2006-April/063488.html>`__
---
PEP 359:
python-dev Summary for 2006-04-16 through 2006-04-30
.. contents::
[The HTML version of this Summary is available at
http://www.python.org/dev/summary/2006-04-16_2006-04-30]
=
Announcements
=
python-dev Summary for 2006-05-01 through 2006-05-15
.. contents::
[The HTML version of this Summary is available at
http://www.python.org/dev/summary/2006-05-01_2006-05-15]
=
Announcements
=
---
Pyth
[EMAIL PROTECTED] wrote:
> This summary is tagged as being in ISO-8859-1 encoding:
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
> However, it really is in UTF-8
Hmm... I guess Gmail's automatic encoding selection isn't working for
the summaries. I've changed my Gmail settings
Emanuele Aina wrote:
> [EMAIL PROTECTED] dettagliò:
>
>>> Someone can explain me why?
>> The list's __contains__ method is very simple
>
> [...]
>
>> So if you define "__lt__" in your object then the type gets a richcmp
>> function and your == test implicit in the 'in' search always incurs the
>
[EMAIL PROTECTED] wrote:
> # I have a list of names:
> names = ['clark', 'super', 'peter', 'spider', 'bruce', 'bat']
>
> # and another set of names that I want to insert into
> # the names list at some indexed locations:
> surnames = { 1: 'kent', 3:'parker', 5:'wayne' }
>
> # The thing I couldn't
levent wrote:
> Thanks for the answers. Enumerating in reverse is indeed quite a smart
> idea.
>
> The fact is though, I overly simplified the task in the super-hero
> example. In the real case, the dictionary keys are not necessarily the
> indices for inserts; that is to say, the inserts do not n
I have some plain text data and some SGML markup for that text that I
need to align. (The SGML doesn't maintain the original whitespace, so I
have to do some alignment; I can't just calculate the indices directly.)
For example, some of my text looks like:
TNF binding induces release of AIP1
Gerard Flanagan wrote:
> Steven Bethard wrote:
>> I have some plain text data and some SGML markup for that text that I
>> need to align. (The SGML doesn't maintain the original whitespace, so I
>> have to do some alignment; I can't just calculate the indices direc
Scott David Daniels wrote:
> Roberto Bonvallet wrote:
>> imho <[EMAIL PROTECTED]>:
>>> map(lambda x:"" , [i for i in [a,b,c] if i in ("None",None) ])
>> You don't need map when using list comprehensions:
>>["" for i in [a, b, c] if i in ("None", None)]
>>
> More like:
>
> [(i, "")[i in ("N
9601 - 9700 of 15567 matches
Mail list logo