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 directly.)
[snip]
> Note that the SGML i
janama wrote:
> can such a thing be done somehow?
>
> aaa = self.aaa
> bbb = %s.%s % ('parent', 'bbb')
>
> Can you use strings or %s strings like in the above or
>
> aaa = 'string'
> aaa.%s() % 'upper'
Use the getattr() function::
>>> class parent(object):
... class bbb(object):
[EMAIL PROTECTED] wrote:
> Is there a simple python function to return the list index of the
> minimum entry in a list of lists?
> ie, for [[3,3,3,3], [3,3,3,1], [3,3,3,3]] to return 2,4.
> Or, same question but just for a list of numbers, not a list of lists.
In Python 2.5:
Python 2.5a2 (trun
[EMAIL PROTECTED] wrote:
> [EMAIL PROTECTED] wrote:
>> Is there a simple python function to return the list index of the
>> minimum entry in a list of lists?
>> ie, for [[3,3,3,3], [3,3,3,1], [3,3,3,3]] to return 2,4.
>> Or, same question but just for a list of numbers, not a list of lists.
>
>
Alex A. Naanou wrote:
> The object's __dict__ can only be a dict derivative and at that none of
> the Python's mapping API will be used (the dict is accessed directly).
[snip]
> I wrote a patch some time back, it appears rather stable and is being
> production tested.
>
> you can download it here:
bayerj wrote:
> I want to make a registry of methods of a class during creation.
I think you're going to need a metaclass for this, e.g.::
>>> import inspect
>>> def registered(func):
... func.registered = True
... return func
...
>>> class RegisterFuncs(type):
... def __init__(cls
ightly less sloppy,
infinitesimals are zero, but not all the same zero.
When doing calculus with complex numbers, it is very important to
distinguish which direction you are taking your limits in, and so
lim z -> 0+0i is not necessarily the same as lim z -> 0-0i.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
Network Ninja wrote:
> I want to restart the environment occasionally to default (like I
> restarted pythonwin). I wrote this script. I know why it doesn't work,
> cause it deletes my variable (item) on each iteration. My question is:
> is it possible to do this? What other things might I try?
>
>
On Sat, 24 Jun 2006 05:36:17 -0700, Filip Wasilewski wrote:
> Steven D'Aprano wrote:
>> On Fri, 23 Jun 2006 02:17:39 -0700, Filip Wasilewski wrote:
>>
>> > [EMAIL PROTECTED] wrote:
>> >
>> >> Logically, I should be able to enter x[-2:-0] to get th
e of
the values is negative. In either case the first test will fail.
There are no circumstances where each of x, y and z are greater than 10
but the sum is zero; nor are there any circumstances where the sum is
zero but x, y and z are still all greater than 10.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
On Sat, 24 Jun 2006 21:15:17 -0700, Erik Max Francis wrote:
> Steven D'Aprano wrote:
>
>> In mathematics, well, maybe... certainly in the Real number system, there
>> is no difference, and +0 and -0 are just two ways of writing the same
>> thing. In the hyperreals
Ritesh Raj Sarraf wrote:
> Now if someone uses it as:
> ./foo --my-option a b c
>
> I want somehow to store all the three arguments
Currently optparse doesn't support options with an arbitrary number of
arguments. I'm currently working on a optparse-inspired replacement
which does support this
John Henry wrote:
> I have a list of strings (some 10,000+) and I need to concatenate them
> together into one very long string. The obvious method would be, for
> example:
>
> alist=["ab","cd","ef",.,"zzz"]
> blist = ""
> for x in alist:
>blist += x
>
> But is there a cleaner and faster
I have an optparse-like module and though I have a full unittest-style
suite of tests for it, I'd also like to be able to run doctest on the
documentation to make sure my examples all work. However, I see that
doctest (1) doesn't capture anything from sys.stderr, and (2) unlike the
normal inte
python-dev Summary for 2006-05-16 through 2006-05-31
.. contents::
[The HTML version of this Summary is available at
http://www.python.org/dev/summary/2006-05-16_2006-05-31]
=
Announcements
=
On Tue, 04 Jul 2006 07:01:55 -0700, Roman wrote:
> I would appreciate it if somebody could tell me where I went wrong in
> the following snipet:
>
> When I run I get no result
What do you mean? Does it print None?
> cnt = 0
> p=[]
> reader = csv.reader(file("f:\webserver\inp.txt"), dialect="exc
-- maybe it will help.
If you explain your needs in a little more detail, perhaps people can give
you answers which are a little more helpful.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
squares curve fitting" and "linear
regression". That's just two methods out of many.
Some curve-fitting methods also estimate the error between the predicted
curve and the data points; you could then try all of the methods and pick
the one with the least error.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
t this piece of code was made
up of 24 lines of actual code (including lines containing only a single
brace) but 29 lines of legalise?
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
ule
uses. That means zip has to convert every one of those 800,000 floats
into rich Python float objects. This won't matter for small sets of data,
but with 800,000 of them, it all adds up.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
tring.replace can't/doesn't
> handle non-ascii chars. i'm still looking for a way to search/replace
> non-ascii chars...
Seems to work for me:
>>> c = u'\xa0'
>>> s = "hello " + c + " world"
>>> s
u'hello \xa0 world'
>>> s.replace(c, "?")
u'hello ? world'
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
built-in types without needing to write the
same bit of code for each and every method?
Am I approaching this the wrong way? Is there a better design I could be
using?
Thanks,
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
g from unicode to ordinary strings is
NOT the same -- the *character* chr(160) is not a valid ASCII character,
since ASCII only uses the range chr(0) through chr(127).
If this is confusing to you, you're not alone.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
thing is that each of the inner lists are DIFFERENT lists that just happen
to share the same value (ten None items), rather than the same list
repeated ten times.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, 04 Jul 2006 19:26:36 +0200, Bruno Desthuilliers wrote:
> Steven D'Aprano wrote:
>> I'm having problems with sub-classes of built-in types.
>>
>> Here is a contrived example of my subclass. It isn't supposed
>> to be practical, useful code, b
I meant -- it was a copy-and-paste and I didn't
clean it up correctly.
Thanks,
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, 05 Jul 2006 14:01:27 +0200, Marco Wahl wrote:
> Hi,
>
> I want to give a tuple to a function where the function
> expects the respective tuple-size number of arguments.
>
> The following session illustrates what I want to do and
> the respective failure.
>
> Python 2.4.1 (#7, Aug 3 20
gt; would be something like:
That's great, thanks. You've given me an angle of attack to take and see
where it leads.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, 05 Jul 2006 11:41:47 +0200, Bruno Desthuilliers wrote:
> Steven D'Aprano wrote:
>> On Tue, 04 Jul 2006 19:26:36 +0200, Bruno Desthuilliers wrote:
>>
>>
>>>Steven D'Aprano wrote:
>>>
>>>>I'm having problems with sub-cla
'aeiou'
> CONS = ''bcdfgh'
Why don't you just do that?
VOWELS = 'aeiou'
CONS = 'bcdfgh'
What benefit do you gain by stuffing your variables into tuples?
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
found."
else:
print "No items found."
However, keep in mind that "in" has a subtly different effect in strings
and tuples.
"x" in ("x", "y") is true, but "x" in ("xy", "yy") is not, as you would
expect. However, the situation for strings isn't quite the same:
"x" in "x y" is true, but so is "x" in "xx yy".
One way around that is to convert your string a into a list:
a = 'xfsdfyysd asd x'
a = a.split() # split on any whitespace
and now your tests will behave as you expected.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
",")
key1, value1 = a.strip().split(":")
key2, value2 = b.strip().split(":")
return {key1.strip(): value1.strip(), key2.strip(): value2.strip()}
def parse_list(s):
"""Parse a list with two items exactly."""
s = s.strip()
assert s.startswith("[")
assert s.endswith("]")
a, b = s[1:-1].split(",")
return [a.strip(), b.strip()]
# Expected format is something like:
# [tuple(string, integer), tuple(string, dict(string: string)]
L = parse_list(s)
T0 = parse_tuple(L[0])
T1 = parse_tuple(L[1])
T0 = (T0[0], int(T0[1]))
T1 = (T1[0], parse_dict(T1[1]))
return [T0, T1]
That's a bit more work than eval, but I believe it is worth it.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
Jim wrote:
> Is there some easy way to split a line, keeping together double-quoted
> strings?
>
> I'm thinking of
> 'a b c "d e"' --> ['a','b','c','d e']
> . I'd also like
> 'a b c "d \" e"' --> ['a','b','c','d " e']
> which omits any s.split('"')-based construct that I could come up with.
tac-tics wrote:
> Python is a crazy language when it comes to object versatility. I know
> I can do:
>
class test:
> ...def __init__(self):
> ... pass
x = test()
def fun():
> ... print "fun"
x.fun = fun
x.fun()
> fun
>
> However, experimenting shows that t
On Fri, 07 Jul 2006 19:57:02 +0200, Fredrik Lundh wrote:
> Steven D'Aprano wrote:
>
>> Personally, I would never use eval on any string I didn't write myself. If
>> I was thinking about evaluating a user-string, I would always write a
>> function to parse the s
ions -- my rule of thumb (yours may be different) is that any time
I expect arbitrary data, eval is the right tool for the job, but if I
expect *specific* data, I use something else.
Imagine if the only way to get an integer was by calling eval on the
string -- I think we'd all agree that would be a bad move. Instead we have
a function which does nothing but convert strings (well, any object
really) to integers: int. It would be great if Python included tools to do
the same for dicts and lists, reducing the need for people to use a
sledge-hammer.
Anyway, my point was that you, the developer, have to weigh up the costs
and benefits of eval over a custom parser. The benefit is that eval is
already there, built-in and debugged. The costs are that it can be
insecure, and that it doesn't give you fine control over what data you
parse or how forgiving the parser is.
After that, the decision is yours.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
John Machin wrote:
> Injecting a "private" method into a particular instance is not much more
> complicated:
>
> >>> def own(self, arg):
> ...print "own"
> ...self.ozz = arg
> ...
> >>> p = K()
> >>> import types
> >>> p.metho = types.MethodType(own, p)
> >>> p.metho("plugh")
> own
>
python-dev Summary for 2006-06-01 through 2006-06-15
.. contents::
[The HTML version of this Summary is available at
http://www.python.org/dev/summary/2006-06-01_2006-06-15]
=
Announcements
=
---
Pyth
:
self.attribs = self.default_attribs.copy()
Now there is one copy of default character attributes, shared by the class
and all it's instances, plus each instance has it's own unique set of
values which can be modified without affecting the defaults.
Hope this clears things up for you.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
t you post the complete stack trace of the exception? Chances are
it will contain much useful information.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
cts" when I try to pickle a method. Possibly
that's just a change in error message, which is not guaranteed to be
constant across Python versions.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
):
self.L = [1, "a", X.method] # note the lack of ()s
pop = X()
Otherwise, I'm working blind without knowing more about your class.
Here's a thought: comment out every attribute in your class, and then try
pickling it. If it succeeds, uncomment just *one* attrib
Gregory Guthrie wrote:
> For example,
>- why is len() not a member function of strings? Instead one says len(w).
Why would ``x.len()`` be any more convenient than ``len(x)``? Your
preference here seems pretty arbitrary.
> - Why doesn't sort() return a value?
>
> This would allow thing
ing else? Be prepared to justify
why your choice is suitable not just for *this* dictionary, but for *all*
dictionaries.
> I am curious why these "obvious" conveniences are not present. :-)
> Thansk for any context or insight.
Perhaps the best way to understand the Python philosophy is to call up an
interpreter and execute "import this" at the prompt.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
a recent (version 2.2 I think?)
addition to Python. You have to think about the functionality
available back in the days when the decision to make len() a function was
made, not based on what functionality is available a decade later.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
guthrie wrote:
> Steven Bethard wrote:
>> Why would ``x.len()`` be any more convenient than ``len(x)``? Your
>> preference here seems pretty arbitrary.
> -- Perhaps;
> but having all standard operations as a method seems more regular (to
> me), and allows a simple chain
Terry Reedy wrote:
> "Gregory Guthrie" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
>> - why is len() not a member function of strings? Instead one says
>> len(w).
>
> Consider
map(len, ('abc', (1,2,3), [1,2], {1:2}))
> [3, 3, 2, 1]
>
> Now try to rewrite this using meth
ay to solve the problem.
Of course, another right way would be to have mutable strings in Python.
I understand why strings need to be immutable in order to work with dicts,
but is there any reason why (hypothetical) mutable strings should be
avoided in situations where they aren't needed as dictionary keys? Python
has mutable lists and immutable tuples, mutable sets and immutable frozen
sets, but no mutable string type.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
On Mon, 10 Jul 2006 15:23:36 +0100, Sion Arrowsmith wrote:
> Steven D'Aprano <[EMAIL PROTECTED]> wrote:
>>Of course, another right way would be to have mutable strings in Python.
>
> What significant advantage would mutable strings have over StringIO
> and wrappin
er, I should point out that the methods available to
array.array('c') are quite limited compared to the methods available to
strings. Still, it would make a good basis to start with, and far better
than my initial thought of a list of chars.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
Bryan wrote:
> Steven Bethard wrote:
>
>> The advantage of a functional form over a method shows up when you
>> write a function that works on a variety of different types. Below are
>> implementations of "list()", "sorted()" and "join()&q
Paul Rubin wrote:
> Steven Bethard <[EMAIL PROTECTED]> writes:
>> If len() were a method of string objects, you could try using the
>> unbound method and writing this as::
>>
>> >>> sorted(['aaa', 'bb', 'c'], key=str
the worst that can happen is that people will write
inefficient code, and they'll be caught out by the same sort of things
that surprise newbies about lists. E.g. using a list as a default value
in function definitions.
> Use them only when their benefits outweigh their risks.
That goes with
quot; or similar. But they are comparatively rare.
Why force simple true/false tests into that idiom?
> My own feeling is that I am willing to work with the behaviours defined
> by Python, and treat the use of len in these cases as excessive
> duplication (this is however, quite a minor
*hard*. As far as I know,
even Microsoft has never attempted it. And for all of Sun's resources and
talent, security holes are sometimes found even in Java.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, 23 Aug 2006 11:16:17 +0200, Sybren Stuvel wrote:
> Steven D'Aprano enlightened us with:
>> But an upside is that it would enable more useful error messages, at least
>> sometimes. Here's some trivial pseudo-code:
>>
>> def foo(a):
>> assert
On Wed, 23 Aug 2006 12:16:45 +0200, Fredrik Lundh wrote:
> Steven D'Aprano wrote:
>
>> Here's a traceback. One of the arguments to spam() is too small. Can you
>> tell which one just by looking at the traceback?
>>
>>>>> a, b, c, d = range(4)
>
one of the nice things about the
language: it *suggests* what to do, but doesn't *insist* it knows what you
want better than you do.
--
Steven D'Aprano
--
http://mail.python.org/mailman/listinfo/python-list
Sylvain Ferriol wrote:
> hello everybody,
>
> i want to talk with you about a question i have in mind and i do not
> find a answer. it 's simple:
> why do we not have a beatiful syntax for object definition as we have
> for class definition ?
>
> we can define a class in python in 2 ways:
> 1. b
Sylvain Ferriol wrote:
> with the 'make' syntax, it will be really easy to translate a program or
> a data structure defined in XML format into python syntax.
Only if there are no ordering constraints and no need for multiple
elements with the same name. The make statement was built to mirror t
David Isaac wrote:
> Le mercredi 06 septembre 2006 16:33, Alan Isaac a écrit :
>>> Suppose a class has properties and I want to change the
>>> setter in a derived class. If the base class is mine, I can do this:
>>> http://www.kylev.com/2004/10/13/fun-with-python-properties/
>>> Should I? (I.e., i
George Sakkis wrote:
> Steven Bethard wrote:
>
>> David Isaac wrote:
>>> Le mercredi 06 septembre 2006 16:33, Alan Isaac a écrit :
>>>>> Suppose a class has properties and I want to change the
>>>>> setter in a derived class. If the base class
Maric Michaud wrote:
> Le jeudi 07 septembre 2006 15:33, Steven Bethard a écrit :
>> Well, lambda's not going away[1],
>
> Sure, they won't.
>
>> but there's no *need* for lambda here.
>> It could be written as::
>
> Le jeudi 07 septem
Lex Hider wrote:
> try:
> opts, args = getopt.getopt(sys.argv[1:], "l:",
> ["latest=", "notfound"])
> except getopt.GetoptError:
> sys.exit(2)
> #usage()
>
> for opt, arg in opts:
> if opt in (
Kamilche wrote:
> Is there any reason NOT to do this that I may be unaware of?
[snip]
> # --- Module 2.py
> # 'Self' module processing
> import sys
> var = 0
> self = sys.modules[__name__]
>
> def MyRoutine():
> self.var = 1
>
> MyRoutine()
> print var
Looks basically fi
Hari Sekhon wrote:
> I am writing a wrapper to a binary command to run it and then do
> something with the xml output from it.
>
> What is the best way of making sure that the command is installed on the
> system before I try to execute it, like the python equivalent of the
> unix command "whic
I'd like to be able to pickle instancemethod objects mainly because I
want to be able to delay a call like ``foo(spam, badger)`` by dumping
``foo``, ``spam`` and ``badger`` to disk and loading them again later.
Sometimes the callable ``foo`` is actually a bound method, e.g.
``bar.baz``, but in
Martin v. Löwis wrote:
> Steven Bethard schrieb:
>> Does this approach seem sound? Am I going to run into some weird
>> problems doing it this way?
>
> It's good, but I think rebuilding the object through
> new.instancemethod should be even better.
>
> py>
George Sakkis wrote:
> * [personal preference]: Don't leave space between *every* operator in
> expressions, group them based on precedence. E.g. instead of "(n *
> sigmaSq - sigma * sigma) / (n * n)", I read it easier as "(n*sigmaSq -
> sigma*sigma) / (n*n).
The spaced-out version is more `PEP 8`
omplain that they want to have identifiers in bold too, why can't they
create a name "\x0breturn", and somebody will come up with an even more
complicated scheme for accommodating them... wash, rinse, repeat.
--
Steven D'Aprano
--
http://mail.python.org/mailman/listinfo/python-list
ou get the memory size of each object?
--
Steven D'Aprano
--
http://mail.python.org/mailman/listinfo/python-list
(u))
p = str(soup.findAll('span', "sale"))
for row in re.findall('\$\d+\.\d\d', p):
ws.write(r,0,row) # what's r? did you mean rx?
Now call this:
for rx in range(sh.nrows):
rx += 1 # but see my comments above...
try:
Diez B. Roggisch wrote:
> Gleb Rybkin wrote:
>
>> I searched online, but couldn't really find a standard package for
>> working with Python and XML -- everybody seems to suggest different
>> ones.
>>
>> Is there a standard xml package for Python? Preferably high-level, fast
>> and that can parse i
Martin v. Löwis wrote:
> Gleb Rybkin schrieb:
>> I searched online, but couldn't really find a standard package for
>> working with Python and XML -- everybody seems to suggest different
>> ones.
>>
>> Is there a standard xml package for Python? Preferably high-level, fast
>> and that can parse in-
Steve Holden wrote:
> [EMAIL PROTECTED] wrote:
>> I think I read a suggestion somewhere to wrap the code where a Python
>> script starts in a main() function, so one has
>>
>> def main():
>> print "hi"
>>
>> main()
>>
>> instead of
>>
>> print "hi"
>>
>> What are the advantages of doing this?
>
r you if your
users just stop using the software and use a competing product instead.
If the answer is Yes, then go on to question 2:
Q2. Are you sure?
If the answer is still Yes, then read this and see if it helps:
http://en.wikipedia.org/wiki/Keygen
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
th, sort of as
if we could say in English "therearelanguageswhichallowyou" to
"sticktogetherwordsintoasinglewordofindefinitelength". Such languages
might be said to have an infinite number of words, in some sense.)
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
lt
Is it safe for me to pass -1 as the default to maxsplit, meaning
"unlimited splits"? Should the docs be fixed to mention that?
Thanks,
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
optimization. Your computer has probably got well in excess of 100MB, and
you're worried about duplicating a few hundred or thousand (or even
hundred thousand) bytes for a few milliseconds (just long enough to grab
the length)?
--
Steven D'Aprano
--
http://mail.python.org/mailman/listinfo/python-list
like a password and ask the user to type it
twice. That will protect against simple typos and input errors.
For everything else, send to it and see what happens.
--
Steven D'Aprano
--
http://mail.python.org/mailman/listinfo/python-list
lit(*args)
> post_processing()
> return result
Thanks Fredrik, that's *exactly* the sort of insight I was lacking. And
now that you've shown me, I can't believe how obvious it is.
--
Steven D'Aprano
--
http://mail.python.org/mailman/listinfo/python-list
metaperl wrote:
> I was shocked to see the personal insults hurled in this thread:
> http://groups.google.com/group/comp.lang.python/browse_thread/thread/d0758cb9545cad4b
I see that this is a Fredrik Lundh thread. I've felt the same way
before, but Fredrik has been around a long time[1] and if y
pect the (presumed) bad behaviour can be
fixed gradually?
Now that we've got that out of the way, can we CALMLY and RATIONALLY
discuss whether cgi.escape is or isn't broken?
Or, more specifically, UNDER WHAT CIRCUMSTANCES it does the wrong thing?
--
Steven D'Aprano
--
http://mail.python.org/mailman/listinfo/python-list
On Mon, 25 Sep 2006 16:11:38 +0200, Christophe wrote:
> Steven D'Aprano a écrit :
>> By memory, in an thread about the same topic just a few days ago, Fredrik
>> Lundh posted a link to Perl's FAQs that suggests a method for "validating"
>> email addres
ily
one of those, but that's not up to me to decide.)
--
Steven D'Aprano
--
http://mail.python.org/mailman/listinfo/python-list
e is worthless), they can. But the point is, I
see no ethical nor legal reason why a user can't create a script which is
called MANUALLY by the user and does what a browser does, namely send and
receive data from websites (which may or may not include Google).
And that, it seems to me, is what the Original Poster wanted.
--
Steven D'Aprano
--
http://mail.python.org/mailman/listinfo/python-list
and there's countless other people I know here in Melbourne in
> the same position.
Countless people? Are we talking aleph-zero people (countable infinity) or
one of the uncountable infinities?
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, 27 Sep 2006 09:17:28 -0400, Roy Smith wrote:
> In article
> <[EMAIL PROTECTED]>,
> Steven D'Aprano <[EMAIL PROTECTED]> wrote:
>
>> On Tue, 26 Sep 2006 22:00:55 +1000, Anthony Baxter wrote:
>>
>> > This seems to be a very, very silly
def __str__(self):
return self.name
def __gt__(self, other):
return len(str(self)) > len(str(other))
and then you'll have problems:
>>> bottom = Funny("Bottom")
>>> Top > bottom
True
>>> bottom > Top
True
As far as I can see, the only way to avoid edge cases like this is for Top
(and Bottom) to be built-ins that are special-cased by Python.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
at depends on just how often you need
to convert days to or from seconds.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
rick wrote:
> Consider the following piece of code:
>
> parser = optparse.OptionParser(usage="usage: %prog
> [options]", add_help_option=False)
> parser.add_option("-d", type="string", action="store", dest="DELIM",
> default="|", help="single character delimiter in quotes (default: |)")
> (opt
David Isaac wrote:
> Does George's example raise the question:
> why do dictionaries not implement efficient creation
> for two common cases?
>
> - Making a dict from two sequences of the same length.
> - Making a dict from a sequence and a function
> (as in George's example in this thread).
Ma
[EMAIL PROTECTED] wrote:
> I'm trying to get this bit of code to work without triggering the
> IndexError.
>
> import shutil, os, sys
>
> if sys.argv[1] != None:
> ver = sys.argv[1]
> else:
> ver = '2.14'
Something like::
if len(sys.argv) > 1:
ver = sys.argv[1]
else:
ou have to make a copy of the list on every iteration because you are
changing it in place; otherwise you change the values you are testing
against, and the second iteration onwards doesn't have to remove anything.
(All code above untested. Use at own risk.)
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, 17 Nov 2006 20:08:25 -0800, jim wrote:
> Is there such thing as a free decompile that I can run in windows xp
Yes.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
On Sat, 18 Nov 2006 07:42:58 -0800, jim wrote:
> where can I find a free decompile that I can run in windows xp
Here:
http://catb.org/esr/faqs/smart-questions.html
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
it, but strings returns different error messages.
Is it possible this is a bug in strings?
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
On Sun, 19 Nov 2006 13:18:39 +0100, Bjoern Schliessmann wrote:
> Imbaud Pierre wrote:
>
>> tf = tempfile.NamedTemporaryFile()
>> tfName = tf.name
>> [...]
>> print >> sys.stderr, '%s: %s' % (tfName, ['no',
>> 'yes'][os.path.exists(tfName)])
>> s
ice would be so much cleaner if it took keyword
arguments.)
> heads(iterable) -> iterator over all heads
> tails(iterable) -> iterator over all tails
What would you use these for?
> fcain(funct,*functs) -> function(...,***)
> fcain(f1,f2,...,fn)(*args,*kwargs) equals f1(f2(...fn(*args,*kwargs)))
The usual term for this is function composition.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
here will be such a dictionary in any
> future CPython version.
> (Would be good.)
Why would it be good?
How many bugs have you found that were caused by this behaviour?
--
Steven D'Aprano
--
http://mail.python.org/mailman/listinfo/python-list
9701 - 9800 of 15567 matches
Mail list logo