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
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
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`
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?
>
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
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:
Ghido wrote:
> Hi all, i need to save in an object some variable for use in other
> parts of my software. it's possibile without create an istance of this
> class in every file? if yes how?
Create a module, say, ``config``. Then to save your object, you use
something like::
import config
python-dev Summary for 2006-10-01 through 2006-10-15
.. contents::
[The HTML version of this Summary is available at
http://www.python.org/dev/summary/2006-10-01_2006-10-15]
=
Announcements
=
python-dev Summary for 2006-11-01 through 2006-11-15
.. contents::
[The HTML version of this Summary is available at
http://www.python.org/dev/summary/2006-11-01_2006-11-15]
=
Announcements
=
python-dev Summary for 2006-10-16 through 2006-10-31
.. contents::
[The HTML version of this Summary is available at
http://www.python.org/dev/summary/2006-10-16_2006-10-31]
=
Announcements
=
Announcing argparse 0.3
---
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 thi
Prateek wrote:
> Basically, I really love the language and I'm looking for ways to get
> involved in the community and contribute.
If you're looking to help in the development of Python, the `python-dev
list`_ might be a little more appropriate. You might find that just
lurking on that list and
Steven Bethard wrote:
> .. _python-dev list: One really simple way to contribute that would be
Sorry, copy-paste error. This should have been:
.. _python-dev list: http://mail.python.org/mailman/listinfo/python-dev
STeVe
--
http://mail.python.org/mailman/listinfo/python-list
t on a semi-monthly basis. An archive_ of
previous summaries is available online.
An `RSS feed`_ of the titles of the summaries is available.
You can also watch comp.lang.python or comp.lang.python.announce for
new summaries (or through their email gateways of python-list or
python-announce, resp
Nick Maclaren wrote:
> I am defining a class, and I need to refer to that class when
> setting up its static data - don't ask - like this:
>
> Class weeble :
> wumpus = brinjal(weeble)
Duncan Booth wrote:
> Alternatively you can play tricks with metaclasses for a similar effect.
Nick Maclare
Brian Blais wrote:
> I have a couple of classes where I teach introductory programming using
> Python. What I would love to have is for the students to go through a
> lot of very small programs, to learn the basic programming structure.
> Things like, return the maximum in a list, making lists
Michele Petrazzo wrote:
> I'm trying optparse and I see a strange (for me) behavior:
>
> def store_value(option, opt_str, value, parser):
> setattr(parser.values, option.dest, value)
>
> parser = optparse.OptionParser()
> parser.add_option("-f", "--foo",
> action="callback",
Michele Petrazzo wrote:
> Ok, I have not understand the "trickle" for transform the
> action="callback" and provide a callback to a new action.
Yeah, you're not the only one. ;-)
> I believe, however, that the doc has to be more explicit about this
> strange behavior, because a not so expert dev
Adam Atlas wrote:
> Is it possible for an object, in its __init__ method, to find out if it
> is being assigned to a variable, and if so, what that variable's name
> is? I can think of some potentially ugly ways of finding out using
> sys._getframe, but if possible I'd prefer something less exotic.
Adam Atlas wrote:
> Isn't it a bit convoluted to use metaclasses?
Yep. It's a well known fact that putting "convoluted" and "metaclasses"
in the same sentence is repetitively redundant. ;-)
> someinstance.__class__.__name__ does the same thing.
No, not really::
>>> class C(object):
.
[EMAIL PROTECTED] wrote:
> I could have sworn someone was working on a module recently with a
> threading-like API that used subprocesses under the covers, but 10 minutes
> or so of googling didn't yield anything. Pointers appreciated.
http://www.python.org/dev/summary/2006-10-01_2006-10-15/#proc
Martin v. Löwis wrote:
> [EMAIL PROTECTED] schrieb:
>> I feel argparse has some useful things that optparse doesn't have. But
>> I can't find it argparse in python library reference. I'm wondering
>> when it will be available in the python standard installation.
>
> On its own, never. Somebody has
Martin v. Löwis wrote:
> Steven Bethard schrieb:
>> If someone has an idea how to include argparse features into optparse,
>> I'm certainly all for it. But I tried and failed to do this myself, so I
>> don't know how to go about it.
>
> It's not necessary
Steven Bethard schrieb:
> If someone has an idea how to include argparse features into optparse,
> I'm certainly all for it. But I tried and failed to do this myself, so
> I don't know how to go about it.
Martin v. Löwis wrote:
> It's not necessary that the imple
Announcing argparse 0.4
---
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/
New in this
[Thanks for looking through all these Martin!]
Martin v. Löwis wrote:
> Steven Bethard schrieb:
>> * alias ArgumentParser to OptionParser
>> * alias add_argument to add_option
>> * alias Values to Namespace
>> * alias OptionError and OptionValueError to ArgumentError
&
Stef Mientki wrote:
> Not sure I wrote the subject line correct,
> but the examples might explain if not clear
[snip]
> class pin2:
> def __init__ (self, naam):
> self.Name = naam
>
> aap2 = pin2('aap2') # seems completely redundant to me.
> print aap2.Name
You can use class statements
Scott David Daniels wrote:
> Dan Sommers wrote:
>> ...
>> longest_list, longest_length = list_of_lists[ 0 ], len(
>> longest_list )
>> for a_list in list_of_lists[ 1 : ]:
>> a_length = len( a_list )
>> if a_length > longest_length:
>> longest_list, longest_lengt
Steven W. Orr wrote:
>> From the tutorial, they said that the following construct will
> automatically close a previously open file descriptor:
>
> ---
> #! /usr/bin/python
> import sys
>
> for nn in range ( 1, len(sys.argv ) ):
> print "arg ", nn, "value = ", sys.argv[nn]
>
R. Bernstein wrote:
> Magnus Lycka informs:
>> [in response to my comment]:
>>> I see how I missed this. Neither disable_.. or enable_.. have document
>>> strings. And neither seem to described in the optparser section (6.21)
>>> of the Python Library (http://docs.python.org/lib/module-optparse.htm
Russell wrote:
> I want my code to be Python 3000 compliant, and hear
> that lambda is being eliminated. The problem is that I
> want to partially bind an existing function with a value
> "foo" that isn't known until run-time:
>
>someobject.newfunc = lambda x: f(foo, x)
>
> The reason a neste
Fredrik Lundh wrote:
>>
>> If you build it, they will come.
>>
>
> http://pydotorg.dyndns.org:8000
Very cool. I'd love to see something like this on the actual website...
Is the hope that in the real python.org version edits will show up
immediately, as they do in your version? Or that the
Andrew Gwozdziewycz wrote:
> I've been looking recently for date processing modules that can parse
> dates in forms such as "next week" or "6 days from next sunday".
This is, in fact, a fairly difficult problem in general. See the TERN_
competition that's currently held yearly on this task. Th
Ben Sizer wrote:
>> Likewise, the del keyword is fundamental -- if you
>> can't get, set, and del, then you need to go back to collections
>> school.
>
> I have hardly used the del keyword in several years of coding in
> Python. Why should it magically spring to mind in this occasion?
> Similarly
Kent Johnson wrote:
> Are there any best practice guidelines for when to use
> super(Class, self).__init__()
> vs
> Base.__init__(self)
> to call a base class __init__()?
>
[snip]
>
> 3. A third fix might be to change both Base and threading.Thread() to
> call super(...).__init__(). This mig
Jan Niklas Fingerle wrote:
> Steven Bethard <[EMAIL PROTECTED]> wrote:
>> Personally, I'd call the lack of the super calls in threading.Thread and
>> Base bugs.
>
> It can't be a bug since it wasn't a bug before super was introduced and
> you
Graham wrote:
> The way i'm controlling functionality is with some games and exec, so
> if 'code' was the text code you wanted to execute i run:
>
> exec code in {'__builtins__':None"}
>
> obviously this doesn't give you much to play with, but it does remove
> file access and importing as far as
[EMAIL PROTECTED] wrote:
> I think this is what you want:
>
> file = open(r'c:/test.txt','r')
>
> c = file.read(3)
> while c:
> print c
> c = file.read(3)
>
> file.close();
Or:
def read3():
return file.read(3)
for chars in iter(read3, ''):
... do something
Brian Blais wrote:
> Hello,
>
> I have two lists, one with strings (filenames, actually), and one with a
> real-number
> rank, like:
>
> A=['hello','there','this','that']
> B=[3,4,2,5]
>
> I'd like to sort list A using the values from B, so the result would be
> in this example,
>
> A=['this'
Ben Finney wrote:
> This PEP specifies an enumeration data type for Python.
>
> An enumeration is an exclusive set of symbolic names bound to
> arbitrary unique values. Values within an enumeration can be iterated
> and compared, but the values have no inherent relationship to values
> outside th
Nicolas Fleury wrote:
> I was wondering if it would make sense to make staticmethod objects
> callable, so that the following code would work:
>
> class A:
> @staticmethod
> def foo(): pass
> bar = foo()
Do you have a real-world use case? I pretty much never use
staticmethods (pref
Ben Finney wrote:
> Steven Bethard <[EMAIL PROTECTED]> writes:
>
>> Ben Finney wrote:
>>> This PEP specifies an enumeration data type for Python.
>>> An enumeration is an exclusive set of symbolic names bound to
>>> arbitrary unique values. Values
Steven D'Aprano wrote:
> So, based on this evidence, staticmethod() inside a class definition
> converts instance methods to functions. Outside a class definition,
> staticmethod() does one of two things: it either converts an instance
> method to a static method, or if the output is assigned to
Steven Bethard wrote:
> (For anyone else out there reading who doesn't already know this,
> Steven D'Aprano's comments are easily explained by noting that the
> __get__ method of staticmethod objects returns functions, and classes
> always call the __get__ method
Christoph Zwerschke wrote:
> But I wonder whether it is possible to put all this init code into one
> class initialization method, something like that:
>
> class A:
>
> @classmethod
> def init_class(self):
> sum = 0
> for i in range(10):
> sum += i
> s
[EMAIL PROTECTED] wrote:
> In PythonWin, is there any way to bulk-delete all objects without using
> "del object" for each, and without having to exit out of PythonWin?
I think you just want to modify the globals() dict:
>>> list(globals())
['__builtins__', 'text', 'glob', 'pywin', 're', 'match'
Leif K-Brooks wrote:
> Steven Bethard wrote:
>> class A(object):
>> def _get_sum():
>> return sum(xrange(10))
>> sum = _get_sum()
>
> What's wrong with sum = sum(xrange(10))?
Nothing, except that it probably doesn't ans
Kent Johnson wrote:
> Steven Bethard wrote:
>> I don't run into this often, but when I do, I usually go Jack
>> Diederich's route::
>>
>> class A(object):
>> class __metaclass__(type):
>> def __init__(cls, name, bases, class
[EMAIL PROTECTED] wrote:
> Steven, does your technique fix my problem? Would that delete the
> objects I've created within a program if I suffix my code with it?
I'm not certain I understand your problem, but I think so. Give it a try.
STeVe
--
http://mail.python.org/mailman/listinfo/python-lis
Sandra-24 wrote:
> I was reading over some python code recently, and I saw something like
> this:
>
> contents = open(file).read()
>
> And of course you can also do:
>
> open(file, "w").write(obj)
>
> Why do they no close the files? Is this sloppy programming or is the
> file automatically clos
Antoon Pardon wrote:
> I then took a look at http://docs.python.org/lib/module-exceptions.html
> which describes the exception heirarchy as follows:
>
> Exception
> +-- SystemExit
> +-- StopIteration
> +-- StandardError
> | +
> | + All kind of error exceptions
>
Lonnie Princehouse wrote:
> Non-trivial:
> Any time the user decides to (1) cache intermediary results for a cmp
> function or (2) define a __cmp__ function for the key return value.
> These arise when comparison of partial keys is often sufficient to
> establish order between two objects.
If yo
Lonnie Princehouse wrote:
> Right, but suppose it's expensive to generate each part of the key -
> e.g. a database query or some kind of hash, so it doesn't make sense to
> compute the whole key in advance if the first part is sufficient to
> establish an ordering most of the time. This is what I
[EMAIL PROTECTED] wrote:
> If this is the list.
>
> values = [ 0, 72, 0, 4, 9, 2, 0, 0, 42, 26, 0, 282,
> 23, 0, 101, 0, 0, 0, 0, 0]
>
> as we can see there are peaks in the list.that is 0,72,0 is a
> group(triangle) with peak 72.then 0, 4, 9, 2, 0, 0 with pe
[EMAIL PROTECTED] wrote:
> Thanks for that. My version of python does'nt find "groupby". I am
> using python 2.3.2. Is there a way I could do it with out using groupby
itertools.groupby is in Python 2.4. The docs[1] give a Python
equivalent, so if for some reason you can't upgrade to the current
mrstephengross wrote:
> So how can I get the kind of information I want then?
>
> For example:
>
> 0.103 --> 3
> 0.0103 --> 4
> 0.00103 --> 5
> 0.000103 --> 6
> 0.103 --> 7
Beware that this is probably only relevant if you have your numbers as
strings, not as floats:
py> 0.103
0.102
mrstephengross wrote:
> First of all, str() is not a function.
Yes it is.
> float f = 1.004;
> ostringstream s;
> s << f;
> cout << s.str();
This doesn't look like Python to me. Are you sure you're on the right
newsgroup?
STeVe
--
http://mail.python.org/mailman/listinfo/python-list
mrstephengross wrote:
> Well, the numbers are in fact stored as numbers, so string processing
> won't work.
What kind of numbers? Python floats?
STeVe
--
http://mail.python.org/mailman/listinfo/python-list
mrstephengross wrote:
>>But, assuming you have your numbers as strings, I would suggest
>
> looking
> at str.split() and len().
>
> Well, the numbers are in fact stored as numbers, so string processing
> won't work.
How about:
py> def digits(f):
... return len(str(f).split('.')[1].rstrip('0
[EMAIL PROTECTED] wrote:
> Hi Steve!
> I am not sure if I was clear with my previous post .Ok let me rephrase
> it .
>
> Assume the values list is the
> content of a histogram. Then we see that
> values = [ 0, 72, 2, 4, 9, 2, 0, 0, 42, 26, 0, 282,
> 23, 0, 101, 0, 0, 0, 0
Peter Hansen wrote:
> [EMAIL PROTECTED] wrote:
>
>> I get a syntax error in :
>>
>> py> [(min((abs(p - v), v) for v in valleys + [0] if v < p)[1],
>> ... p,
>> ... min((abs(p - v), v) for v in valleys if v > p)[1])
>> ... for p in peaks]
>
>
> I think we already covered the part where you
[EMAIL PROTECTED] wrote:
> Hello I have a question about inheritance in Python. I'd like to do
> something like this:
>
> class cl1:
> def __init__(self):
>self.a = 1
>
> class cl2(cl1):
> def __init__(self):
>self.b = 2
>
> But in such a way that cl2 instances have atributes 'b' A
[EMAIL PROTECTED] wrote:
> I am a C++ developer with only a little experience using Python. I
> want to create a Python class where by I can construct an instance from
> that class based on one of two different object types.
>
> For example, if I were programming in C++, I would do the something
James Stroud wrote:
> If you know what type of object "object" is
> (BTW, a keyword in 2.3 and later, I believe)
Not a keyword, but a builtin as of 2.2.
STeVe
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] wrote:
> Is there an easy way to grab the Unique elements from a list?
> For Example:
> data = [0.1,0.5,0.6,0.4,0.1,0.5,0.6,0.9]
>
> what I am looking for is the unique elements 0.4 and 0.9 with their
> index from the list.
This is basically the same as Fredrik Lundh's solution,
[EMAIL PROTECTED] wrote:
> If I simplify the problem, suppose I have 2 lists like:
>
> a = range(10)
> b = range(20,30)
>
> What I would like to have, is a "union" of the 2 list in a single tuple. In
> other words (Python words...):
>
> c = (0, 20, 1, 21, 2, 22, 3, 23, 4, 24, 5, 25, .
py> a
[EMAIL PROTECTED] wrote:
> The linear method:
>
> You create an array - one bool per minute. For one day 24 * 60 entries
> is enough. Spans (Start, End) are in minutes from midnight. Set array
> slots in range(Start, End) to True for each input span.
>
> Scan the array and find metaspans - contig
Christopher J. Bottaro wrote:
> After we were done, we talked about the pros and cons of the languages.
> Funny, the con of Python (documentation) is PHP's strong point. The PHP
> manual is extremely easy to navigate and its search feature works great.
> Contrast that with Python, where you have
Christopher J. Bottaro wrote:
> I think it should evolve into a manual that is more comprehensive
> and organized more like other programming manuals (chapter on control
> structures,
http://docs.python.org/tut/node6.html
or
http://docs.python.org/ref/compound.html
> functions,
http://docs.pyt
Sébastien Boisgérault wrote:
> Any idea why the 'options' object in
>
> # optparse stuff
> (options, args) = parser.parse_args()
>
> is not/couldn't be a real dict ? Or why at least it
> does not support dict's usual methods ?
Well, it's not a real dict because the original API intends it to be
Sébastien Boisgérault wrote:
> Steven Bethard wrote:
>
>>Sébastien Boisgérault wrote:
>>
>>>Any idea why the 'options' object in
>>>
>>># optparse stuff
>>>(options, args) = parser.parse_args()
>>>
>>>is not/cou
Ivan Van Laningham wrote:
> The Python docs are not ideal. I can never remember, for instance,
> where to find string methods (not methods in the string module, but
> methods with '')
Hmmm... Well going to http://docs.python.org/ and typing "string
methods" into the search box gives, as the firs
Christopher J. Bottaro wrote:
> Contrast that with Python. First off there is no "search" mechanism built
> into the documentation page (yes I know you can google it, but that just
> doesn't feel right).
Um, are you looking at the current documentation page?
http://docs.python.org/
In the upper
Bruno Desthuilliers wrote:
> Ivan Van Laningham a écrit :
>
>> Hi All--
>> The Python docs are not ideal. I can never remember, for instance,
>> where to find string methods (not methods in the string module, but
>> methods with ''),
>
>
> >>> dir('')
> ['__add__', '__class__', '__contains__',
Shi, Jue wrote:
> I agree. The PHP manual is really good, especially the examples and user
> contributed notes.
Dunno if anyone's spent much time editing this, but a while a go AMK posted:
http://www.amk.ca/diary/archives/cat_python.html#003336
which puts a wiki side-by-side with the Python docs
Ivan Van Laningham wrote:
> I should be able to type "string methods" into the text box,
> push submit, and IT SHOULD HAND ME THE PAGE. Not "Results 1 - 20 of
> about 9,800 from www.python.org for string methods. (0.78 seconds)"
Hmm... I typed in "string methods" at http://docs.python.org/ and g
Andrew Dalke wrote:
> Steven Bethard wrote:
>
>>Well one reason might be that it's easy to convert from an object's
>>attributes to a dict, while it's hard to go the other direction:
>
> ...
>
>>py> options['x'], options['
Ivan Van Laningham wrote:
> I get that. My question, cleverly concealed in a rant, was, "Why does
> clicking on the Documentation link at python.org NOT take me to
> docs.python.org?"
I believe the issue here is that docs.python.org is only the *current*
documentation. www.python.org/doc lists
Skip Montanaro wrote:
> Mike> Given that Python hides the difference between user-defined
> Mike> objects and built-in objects, it's not clear to me that anything
> Mike> other than the current system, with all the classes/types in one
> Mike> place, makes sense.
>
> Maybe the Modu
Ron Adam wrote:
> What I would like to see is something like the following for each item:
>
> 0. reference @ sequence code
> 2. "Builtin" | "import "
> 3. Type/class: Name/Syntax
> 4. Description with examples
> 6. Links to other references of this item in docs
> 7. Links to related functions or o
Christopher J. Bottaro wrote:
> Bengt Richter wrote:
>
>
>> >>> type(obj)
>>
>> >>> type(obj).mro()
>> [, , ,
>> [, ]
>> >>> tuple(x.__name__ for x in type(obj).mro())
>> ('A', 'B1', 'B2', 'C', 'object')
>
> Wow awesome, thats exactly what I was looking for. I hate to bring up the
> documentat
Jp Calderone wrote:
> Probably not. For example:
>
>>>> (1).__class__.__bases__[0].__subclasses__()[-1]('/dev/null')
>
However:
py> eval("(1).__class__.__bases__[0]"
... ".__subclasses__()[16]('/dev/null')",
... dict(__builtins__={}))
Traceback (most recent call last):
Fil
Robert Kern wrote:
> I find that using the "key" argument to sort is much nicer than "cmp"
> for these tasks.
>
> In [5]:L = [datetime.date(2005,5,2), datetime.date(1984,12,15),
> datetime.date(1954,1,1)]
>
> In [7]:L.sort(key=lambda x: (x.month, x.day))
>
> In [8]:L
> Out[8]:
> [datetime.date
M.E.Farmer wrote:
> (x,y,dotp,sumx,maxv) = abc(x,y,dotp,sumx,maxv)
> This will only create a tuple in memory that has no name to reference
> it by!
Huh? This binds the names "x", "y", "dotp", "sumx" and "maxv" to the
values returned by abc:
py> def abc(*args):
... return args
...
py> (x,y,d
M.E.Farmer wrote:
> I said exactly what I meant, the parentheses around the values creates
> a tuple that you have no reference to! It also has a side effect of
> binding the names inside the tuple to a value and placing them in the
> local namespace( implicit tuple unpacking ). It might be the "sa
1001 - 1100 of 1538 matches
Mail list logo