Antoon Pardon wrote:
> On 2005-12-10, Steven Bethard <[EMAIL PROTECTED]> wrote:
>
>>Antoon Pardon wrote:
>>
>>>So lets agree that tree['a':'b'] would produce a subtree. Then
>>>I still would prefer the possibility to do something like
[EMAIL PROTECTED] wrote:
> Every time I use dir(some module) I get a lot of attributes with double
> underscore, for example __add__. Ok, I thought __add__ must be a method
> which I can apply like this
>
5.__add(8)
>
> However Python responded
> SyntaxError: invalid syntax
>
> I tried
>
>>
Laszlo Zsolt Nagy wrote:
>
> Hello,
>
> Is it possible to tell, which instance was used to call the classmethod
> that is currently running?
>
[snip]
>
> processor = SQLProcessors.StdOutProcessor() # Print to stdout
> PostgreSQLConnection.process_create_tables(processor,dbdef) # This
> soul
Laszlo Zsolt Nagy wrote:
> In my methods, most code is about string manipulation and calling other
> classmethods.
> There are only a few places where I can use an instance, but it is not
> required.
> I would like to reuse as most code as possible, so I do not want to
> create two different
> m
Paul Rubin wrote:
> Chris Mellon <[EMAIL PROTECTED]> writes:
>
>>As someone who does a tremendous amount of event-driven GUI
>>programming, I'd like to take a moment to speak out against people
>>using us as a testament to the virtues of lamda. Event handlers are
>>the most important part of event
Tuvas wrote:
> I need a function that will tell if a given variable is a character or
> a number. Is there a way to do this? Thanks!
What's your use case? This need is incommon in Python...
STeVe
--
http://mail.python.org/mailman/listinfo/python-list
Steven D'Aprano wrote:
> Judging by the tone of the original poster's question, I'd say for sure he
> is an utter Python newbie, probably a newbie in programming in general,
> so I bet that what (s)he really wants is something like this:
>
> somefunction("6")
> -> It is a number.
>
> somefunction
Pierre Quentel wrote:
> In some program I was testing if a variable was a boolean, with this
> test : if v in [True,False]
>
> My script didn't work in some cases and I eventually found that for v =
> 0 the test returned True
This seems like a strange test. What is this code trying to do?
If
Nathan Gilbert wrote:
> Has there been any work done lately on the Python Graph API?
Well there doesn't really seem to be a standard one. The wiki was last
updated in August.
http://wiki.python.org/moin/PythonGraphApi
STeVe
--
http://mail.python.org/mailman/listinfo/python-list
Andy Leszczynski wrote:
> How can do elegantly in Python:
>
> if condition:
>a=1
> else:
>a=2
>
> like in C:
>
> a=condition?1:2
Step (1): Wait for Python 2.5[1]
Step (2): Write the code::
a = 1 if condition else 2
STeVe
[1]http://www.python.org/peps/pep-0308.html
--
http://mai
Mike Meyer wrote:
> The url is http://www.mired.org/home/mwm/try_python/. Reports of
> problems would appreciated.
You're probably already aware of this, but the online help utility
doesn't work. It exits before you can type anything into it:
Darren Dale wrote:
> I would like to test that latex is installed on a windows, mac or linux
> machine. What is the best way to do this? This should work:
>
> if os.system('latex -v'):
> print 'please install latex'
>
> but I dont actually want the latex version information to print to screen
Mike Meyer wrote:
> [EMAIL PROTECTED] writes:
>
>> My question is, what reasons are left for leaving the current default
>> equality operator for Py3K, not counting backwards-compatibility?
>> (assume that you have idset and iddict, so explicitness' cost is only
>> two characters, in Guido's examp
Mike Meyer wrote:
> Steven Bethard writes:
>
>> Not to advocate one way or the other, but how often do you use
>> heterogeneous containers?
>
> Pretty much everything I do has heterogenous containers of some sort
> or another.
Sorry, I should have been a lit
David Hirschfield wrote:
> Here's an example that's giving me trouble, I know it won't work, but it
> illustrates what I want to do:
>
> class A(object):
>_v = [1,2,3]
> def _getv(self):
>if self.__class__ == A:
>return self._v
>return super(self.__class__,sel
aurora wrote:
> I have some unicode string with some characters encode using python
> notation like '\n' for LF. I need to convert that to the actual LF
> character. There is a 'unicode_escape' codec that seems to suit my purpose.
>
encoded = u'A\\nA'
decoded = encoded.decode('unicod
Larry Hastings wrote:
> Of course, it's not the most important thing in the world--after all,
> I'm the first person to even *notice*, right? But it seems a shame
> that
> one can break the build so easily. If it pleases the stewards of
> Python, I would be happy to submit patches that fix the no
Antoon Pardon wrote:
> Why don't we give slices more functionality and use them.
> These are a number of ideas I had. (These are python3k ideas)
>
> 1) Make slices iterables. (No more need for (x)range)
>
> 2) Use a bottom and stop variable as default for the start and
>stop attribute. top wo
Paul Rubin wrote:
> Hmm,
>
>x[a][b][c][d] = e# x is a "magic" dict
>
> becomes
>
>x.setdefault(a,{}).setdefault(b,{}).setdefault(c,{})[d] = e
>
> if I understand correctly. Ugh.
Agreed. I really hope that Python 3.0 applies Raymond Hettinger's
suggestion "Improved default value
Gregory Petrosyan wrote:
> Hey guys, this proposal has already been rejected (it is the PEP 204).
No, this is a subtly different proposal. Antoon is proposing *slice*
literals, not *range* literals. Note that "confusion between ranges and
slice syntax" was one of the reasons for rejection of `
Steve Holden wrote:
> Steven Bethard wrote:
>> Agreed. I really hope that Python 3.0 applies Raymond Hettinger's
>> suggestion "Improved default value logic for Dictionaries" from
>> http://wiki.python.org/moin/Python3%2e0Suggestions
>>
>> Th
Alex Martelli wrote:
> Tom Anderson <[EMAIL PROTECTED]> wrote:
>> Sounds good. More generally, i'd be more than happy to get rid of list
>> comprehensions, letting people use list(genexp) instead. That would
>> obviously be a Py3k thing, though.
>
> I fully agree, but the BDFL has already (tentat
Steven Bethard wrote:
> Agreed. I really hope that Python 3.0 applies Raymond Hettinger's
> suggestion "Improved default value logic for Dictionaries" from
> http://wiki.python.org/moin/Python3%2e0Suggestions
>
> This would allow you to make the setdef
ut the BDFL has already (tentatively, I hope)
> Pronounced that the [...] form will stay in Py3K as syntax sugar for
> list(...). I find that to be a truly hateful prospect, but that's the
> prospect:-(.
Steven Bethard wrote:
> I'm not sure I find it truly hateful, but definitely u
Steven D'Aprano wrote:
> Steven Bethard wrote:
>
>> I'm not sure I find it truly hateful, but definitely unnecessary.
>> TOOWTDI and all...
>
[snip]
>
> Even when people mean One Obvious and not Only One, it is still harmful
> because the emphasis is wr
Carl Cerecke wrote:
> Python has no goto.
Not in the standard library. You have to download the module:
http://www.entrian.com/goto/
;)
STeVe
--
http://mail.python.org/mailman/listinfo/python-list
Matthias Kaeppler wrote:
> I have to say I am confused about the documentation on pyxml.sf.net.
> When I want to use DOM, I effectively am using a class called Sax2? ^^
> I also have to catch SAXExceptions, which reside in xml.sax._exceptions.
>
> I thought DOM and SAX are two completely different
tation of this module, so the APIs are
still subject to change. If you find it of interest, and you'd like to
help improve it, I'd be glad to open the project up to more
developers.
Bug reports can be made through Trac at:
http://argparse.python-hosting.com/newticket
Steven Bethard
--
http://mail.python.org/mailman/listinfo/python-list
python-dev Summary for 2006-06-16 through 2006-06-30
.. contents::
[The HTML version of this Summary is available at
http://www.python.org/dev/summary/2006-06-16_2006-06-30]
=
Announcements
=
---
Pyth
Leonel Gayard wrote:
> Hi all,
>
> I had to write a small script, and I did it in python instead of
> shell-script. My script takes some arguments from the command line,
> like this.
>
> import sys
> args = sys.argv[1:]
> if args == []:
> print """Concat: concatenates the arguments with a col
Ben Finney wrote:
> "Leonel Gayard" <[EMAIL PROTECTED]> writes:
>
>> import sys
>> args = sys.argv[1:]
>> if args == []:
>> print """Concat: concatenates the arguments with a colon (:) between
>> them
>> Usage: concat arg1 [arg2...]
>> Example: concat a b c prints \"a.jar:b.jar:c/\
>>
John Salerno wrote:
> I understand the difference, but I'm just curious if anyone has any
> strong feelings toward using one over the other? I was reading that a
> disadvantage to the more general usage (i.e. env) is that it finds the
> first python on the path, and that might not be the proper
John Salerno wrote:
> Here's my new project: I want to write a little script that I can type
> at the terminal like this:
>
> $ scriptname package1 [package2, ...]
>
> where scriptname is my module name and any subsequent arguments are the
> names of Linux packages to install. Running the scrip
John Salerno wrote:
> Steven Bethard wrote:
>> scriptname.py
>> import argparse # http://argparse.python-hosting.com/
>> import subprocess
>> import sys
>>
>> def outputfile(filename):
>>
Yu-Xi Lim wrote:
> Steven Bethard wrote:
>> import argparse # http://argparse.python-hosting.com/
>> import subprocess
>> import sys
>
> Why not the standard lib's optparse?
The page referenced above gives a variety of reasons, but the two most
important thin
Ken Schutte wrote:
> I want an int-derived class that is initilized to one greater than what
> it's constructor is given:
>
> class myint(int):
> def __new__(cls, intIn):
> newint = int(intIn+1)
> return int.__new__(cls, newint)
Or simply:
class myint(int):
def __new__(cls, int_i
python-dev Summary for 2006-07-01 through 2006-07-15
.. contents::
[The HTML version of this Summary is available at
http://www.python.org/dev/summary/2006-07-01_2006-07-15]
=
Announcements
=
---
Pyth
python-dev Summary for 2006-07-16 through 2006-07-31
.. contents::
[The HTML version of this Summary is available at
http://www.python.org/dev/summary/2006-07-16_2006-07-31]
=
Announcements
=
---
Pyth
Ken Schutte wrote:
> Steven Bethard wrote:
>>
>> The __new__ method is for immutable types. So things like str and int
>> do their initialization in __new__. But for regular mutable types,
>> you should do your initialization in __init__::
>
> I see...
Roman Bertle wrote:
> Hello,
>
> there is an example how to use groupby in the itertools documentation
> (http://docs.python.org/lib/itertools-example.html):
>
> # Show a dictionary sorted and grouped by value
from operator import itemgetter
d = dict(a=1, b=2, c=1, d=2, e=1, f=2, g=3)
>
python-dev Summary for 2006-08-01 through 2006-08-15
.. contents::
[The HTML version of this Summary is available at
http://www.python.org/dev/summary/2006-08-01_2006-08-15]
=
Summaries
=
Mix
Announcing argparse 0.1
---
argparse home:
http://argparse.python-hosting.com/
argparse at PyPI:
http://www.python.org/pypi/argparse/0.1.0
argparse module download:
http://argparse.python-hosting.com/file/trunk/argparse.py?format=raw
About this release
===
Steven Bethard wrote:
> Announcing argparse 0.1
> ---
>
> argparse home:
> http://argparse.python-hosting.com/
>
> argparse at PyPI:
> http://www.python.org/pypi/argparse/0.1.0
>
> argparse module download:
> http://argparse.python-h
I was trying to get elementsoap_ working with just xml.etree from Python
2.5 (and no standalone elementtree installation). I think I got
everything working by changing the imports and copying in the
FancyTreeBuilder class (since only TreeBuilder and XMLTreeBuilder are in
the xml.etree.ElementT
Will McGugan wrote:
> Is there a naming convention regarding alternative constructors? ie
> static methods where __new__ is called explicity.
Are you really using staticmethod and calling __new__? It's often much
easier to use classmethod, e.g.::
class Color(object):
...
hg wrote:
> How about a thread on GOTOs ? ;-)
A thread? No need! There's a module:
http://entrian.com/goto/
;-)
STeVe
--
http://mail.python.org/mailman/listinfo/python-list
Count László de Almásy wrote:
> Is there a standard way with optparse to include a blurb of text after
> the usage section, description, and the list of options? This is
> often useful to include examples or closing comments when the help
> message is printed out. Many of the GNU commands do this
Duncan Booth wrote:
from optparse import OptionParser
usage = "usage: %prog [options] arg1 arg2"
epilog = "that's all folks!"
parser = OptionParser(usage=usage, epilog=epilog)
parser.parse_args(['', '--help'])
> Usage: [options] arg1 arg2
>
> Options:
> -h, --help show
I'm trying to solve a constraint-satisfaction problem, and I'm having
some troubles framing my problem in such a way that it can be
efficiently solved.
Basically, I want to build groups of two teachers and four students such
that [1]:
* Students are assigned to exactly one group
* Teachers are
abcd wrote:
> x = None
> result = (x is None and "" or str(x))
> print result, type(result)
>
> ---
> OUTPUT
> ---
> None
>
>
[snip]
> ...what's wrong with the first operation I did with x?
You weren't using Python 2.5:
Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MS
python-dev Summary for 2006-08-16 through 2006-08-31
.. contents::
[The HTML version of this Summary is available at
http://www.python.org/dev/summary/2006-08-16_2006-08-31]
=
Announcements
=
Daniel Nogradi wrote:
>> > How to execute a linux command by python?
>> > for example: execute "ls" or "useradd oracle"
>> > Who can help me?
>>
>> start here:
>>
>> http://www.python.org/doc/lib/
>
> And continue here:
>
> http://www.python.org/doc/lib/os-process.html
You probably should
Chris wrote:
> Why can pickle serialize references to functions, but not methods?
Here's the recipe I use::
def _pickle_method(method):
func_name = method.im_func.__name__
obj = method.im_self
cls = method.im_class
return _unpickle_method, (func_name, obj,
Carl Banks wrote:
> Steven Bethard wrote:
>> Basically, I want to build groups of two teachers and four students such
>> that [1]:
>>
>> * Students are assigned to exactly one group
>> * Teachers are assigned to approximately the same number of groups
>>
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
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:
>>
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
=
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
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
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
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
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?
>
>
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
=
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
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
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
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
901 - 1000 of 1538 matches
Mail list logo