Samuel Karl Peterson wrote:
> Greetings Pythonistas. I have recently discovered a strange anomoly
> with string.replace. It seemingly, randomly does not deal with
> characters of ordinal value > 127. I ran into this problem while
> downloading auction web pages from ebay and trying to replace th
Schüle Daniel wrote:
> Hello,
>
> lst = list((1,2,3))
> lst = [1,2,3]
>
> t = tupel((1,2,3))
> t = (1,2,3)
>
> s = set((1,2,3))
> s = ...
>
> it would be nice feature to have builtin literal for set type
> maybe in P3 .. what about?
> s = <1,2,3>
In Python 3.0, this looks like::
s = {1,2
Schüle Daniel wrote:
> Steven Bethard schrieb:
>> Schüle Daniel wrote:
>>> it would be nice feature to have builtin literal for set type
>>> maybe in P3 .. what about?
>>> s = <1,2,3>
>>
>> In Python 3.0, this looks like::
>>
>>
Edward K Ream wrote:
> The pros and cons of making 'print' a function in Python 3.x are well
> discussed at:
>
> http://mail.python.org/pipermail/python-dev/2005-September/056154.html
>
> Alas, it appears that the effect of this pep would be to make it impossible
> to use the name 'print' in a ba
Edward K Ream wrote:
>> You could offer up a patch for Python 2.6 so that you can do::
>>from __future__ import print_function
>
> This would only work for Python 2.6. Developers might want to support Python
> 2.3 through 2.5 for awhile longer :-)
Python 3.0 is determined not to be hampered
Schüle Daniel wrote:
>> {:} for empty dict and {} for empty set don't look too much atrocious
>> to me.
>
> this looks consistent to me
Yes, a lot of people liked this approach, but it was rejected due to
gratuitous breakage. While Python 3.0 is not afraid to break backwards
compatibility, it t
[EMAIL PROTECTED] wrote:
> I am on WindowsXP. I have a dll that I can load in python 2.3 but
> when trying to load it into python 2.5 it complains that there is
> nothing by that name. Is there some aspect of the dll loading
> mechanism between python 2.3 and 2.5 that has changed preventing me
>
GiBo wrote:
> One more question - is it likely that StringIO will be turned into
> new-style class in the future? The reason I ask is whether I should try
> to deal with detection of new-/old-style classes or take the
> old-styleness for granted and set in stone instead.
In Python 3.0, everything
Steven Bethard:
> While Python 3.0 is not afraid to break backwards
> compatibility, it tries to do so only when there's a very substantial
> advantage.
[EMAIL PROTECTED] wrote:
> I understand, but this means starting already to put (tiny)
> inconsistencies into Python 3
Jay Tee wrote:
> Yo,
>
> On Feb 16, 6:07 am, Steven Bethard <[EMAIL PROTECTED]> wrote:
>> Python 3.0 is determined not to be hampered by backwards incompatibility
>> concerns. It's not even clear yet that your average 2.6 code will work
>
> Then Python is p
Jay Tee wrote:
> Let's see if I can scare up something I wrote about ten years ago on a
> now-dead language that I really wanted to use (wound up sticking with
> python instead because "it was supported" ;-)
>
> ===
> to figure out how to work things. The fact that there are t
Steven Bethard wrote:
> So as a Python programmer, the path is clear. As soon as possible, you
> should make your code compatible with Python 3.0.
John Nagle wrote:
> There's always the possiblity that Python 3 won't happen.
That's not really a possibility. Unlike P
[EMAIL PROTECTED] wrote:
> Steven Bethard:
>> take a look at the current state of tuples:
>>1, 2
>>1,
>>()
>
> That's not a good situation. I presume the situation/syntax of tuples
> in Python 2.x can't be improved. But can it be improve
Announcing argparse 0.6
---
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 rele
Luis M. González wrote:
> I've come across a code snippet in www.rubyclr.com where they show how
> easy it is to declare a class compared to equivalent code in c#.
> I wonder if there is any way to emulate this in Python.
>
> The code is as follows:
>
> Person = struct.new( :name, :birthday, :chi
Luis M. González wrote:
> On Feb 28, 6:21 pm, Steven Bethard <[EMAIL PROTECTED]> wrote:
>> How about something like::
>>
>> class Person(Record):
>> __slots__ = 'name', 'birthday', 'children'
>>
>> You
Arnaud Delobelle wrote:
> On Feb 28, 7:26 pm, "Luis M. González" <[EMAIL PROTECTED]> wrote:
>> I've come across a code snippet inwww.rubyclr.comwhere they show how
>> easy it is to declare a class compared to equivalent code in c#.
>> I wonder if there is any way to emulate this in Python.
>>
>> Th
Arnaud Delobelle wrote:
> On Mar 1, 4:01 pm, Steven Bethard <[EMAIL PROTECTED]> wrote:
>> Arnaud Delobelle wrote:
> [...]
>> This does pretty much the same thing as the recipe I posted:
>
> Not at all. My new_struct create returns a new class which is simil
Arnaud Delobelle wrote:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/502237
[snip]
> Although I don't see the necessity of a metaclass: you could have
>
> class Record(object):
> def __init__(self, *vals):
> for slot, val in zip(self.__slots__, vals):
>
Luis M. González wrote:
> This is the closest we got so far to the intended result.
> If there was a way to enter attributes without quotes, it would be
> almost identical.
Ok, below is the Python code so that the following works::
class Person(Struct): "name birthday children"
Note that
*
Tim Chase wrote:
>>> ASIDE: I've started refactoring this bit out in my local
>>> source...how would I go about contributing it back to the
>>> Python code-base? I didn't get any feedback from posting to
>>> the Optik site.
>>
>> You can post a patch to bugs.python.org, but it will probably
>> ju
Tim Chase wrote:
> ASIDE: I've started refactoring this bit out in my local source...how
> would I go about contributing it back to the Python code-base? I didn't
> get any feedback from posting to the Optik site.
You can post a patch to bugs.python.org, but it will probably just get
forwarde
braver wrote:
> Posted to the Optik list, but it seems defunct. Optik is now Python's
> optparse.
>
> I wonder how do you implement optional arguments to Optik.
You may want to check out argparse:
http://argparse.python-hosting.com/
It supports optional arguments like this::
parser
[EMAIL PROTECTED] wrote:
(1).__cmp__(10)
> -1
Integer object "(1)" followed by method call ".__cmp__(10)"
1.__cmp__(10)
> File "", line 1
> 1.__cmp__(10)
> ^
> SyntaxError: invalid syntax
Floating point number "1." followed by "__cmp__(10)".
STeVe
--
http://mail.pyt
braver wrote:
> Steve -- thanks for your pointer to argparse, awesome progress --
> optional arguments.
>
> However, I still wonder how I do reporting. The idea is that there
> should be a list with tuples of the form:
>
> (short, long, value, help)
>
> -- for all options, regardless of whether
gamename wrote:
> In TCL, you can do things like:
> set foobar "HI!"
> set x foo
> set y bar
> subst $$x$y
> HI!
>
> Is there a way to do this type of evaluation in python?
If this is at the outer-most scope, you can use globals()::
>>> foobar = 'HI!'
>>> x = 'foo'
>>> y = 'bar'
Boris Borcic wrote:
> davenet wrote:
>> Hi,
>>
>> I'm new to Python and working on a school assignment.
>>
>> I have setup a dictionary where the keys point to an object. Each
>> object has two member variables. I need to find the smallest value
>> contained in this group of objects.
>>
>> The obje
blaine wrote:
> Hey guys,
> For my Network Security class we are designing a project that will,
> among other things, implement a Diffie Hellman secret key exchange.
> The rest of the class is doing Java, while myself and a classmate are
> using Python (as proof of concept). I am having problems
Jeff wrote:
> On Nov 21, 6:25 am, Bruno Desthuilliers [EMAIL PROTECTED]> wrote:
>> joe jacob a écrit :
>> (snip)
>>
>>> Thanks everyone for the response. From the posts I understand that
>>> Django and pylons are the best. By searching the net earlier I got the
>>> same information that Django is
Fuzzyman wrote:
> On Nov 26, 11:56 pm, Carl Banks <[EMAIL PROTECTED]> wrote:
>> On Nov 20, 3:50 pm, [EMAIL PROTECTED] (John J. Lee) wrote:
>>> Not much to add to the subject line. I mean something like this:
>>> ProxyClass.__name__ = ProxiedClass.__name__
>>> I've been told that this is common pra
[EMAIL PROTECTED] wrote:
> First, it is absolutely horrible being a newbie. I'd forgot how bad it
> was. In addition to making a fool of yourself in public, you have to
> look up everything. I wanted to find a substring in a string. OK,
> Python's a serious computer language, so you know it's got a
Steven D'Aprano wrote:
> When you call a new-style class, the __new__ method is called with the
> user-supplied arguments, followed by the __init__ method with the same
> arguments.
>
> I would like to modify the arguments after the __new__ method is called
> but before the __init__ method, som
13 07:36:24 -0600 (Thu, 13 Apr 2006) $
Author: Steven Bethard <[EMAIL PROTECTED]>
Status: Draft
Type: Standards Track
Content-Type: text/x-rst
Created: 05-Apr-2006
Python-Version: 2.6
Post-History: 05-Apr-2006, 06-Apr-2006, 13-Apr-2006
Abstract
This PEP proposes a generalization of t
Steven Bethard wrote:
> I've updated PEP 359 with a bunch of the recent suggestions. The
> patch is available at:
> http://bugs.python.org/1472459
> and I've pasted the full text below.
>
> I've tried to be more explicit about the goals -- the make statemen
Tim Roberts wrote:
> Steven Bethard <[EMAIL PROTECTED]> wrote:
>
>> Steven Bethard wrote:
>>> I've updated PEP 359 with a bunch of the recent suggestions. ...
>> Guido has pronounced on this PEP:
>>http://mail.python.org/pipermail/python-300
Panos Laganakos wrote:
> we usually define private properties and provide public functions
> to access them, in the form of:
> get { ... } set { ... }
>
> Should we do the same in Python:
>
> self.__privateAttr = 'some val'
>
> def getPrivateAttr(self):
> return self.__privateAttr
>
> Or th
[Please don't top-post]
Steven Bethard wrote:
> Panos Laganakos wrote:
>> we usually define private properties and provide public functions
>> to access them, in the form of:
>> get { ... } set { ... }
>>
>> Should we do the same in Python:
Dennis Lee Bieber wrote:
> On Thu, 27 Apr 2006 14:32:15 -0500, Philippe Martin
> <[EMAIL PROTECTED]> declaimed the following in comp.lang.python:
>
>> What then is the point of the double underscore (if any) ?:
>
> To prevent masking/shadowing of inherited attributes...
Note that it can fa
John Salerno wrote:
> If I want to make a list of four items, e.g. L = ['C', 'A', 'D', 'B'],
> and then figure out if a certain element precedes another element, what
> would be the best way to do that?
>
> Looking at the built-in list functions, I thought I could do something
> like:
>
> if L
nikie wrote:
> Steven Bethard wrote:
>
>> John Salerno wrote:
>>> If I want to make a list of four items, e.g. L = ['C', 'A', 'D', 'B'],
>>> and then figure out if a certain element precedes another element, what
>>> w
Sorry the summaries are so late. We were late already, and it's taken
me a bit of time to get set up with the new python.org site. But I
should be all good now, and hopefully we'll get caught up with all the
summaries by the end of May. Hope you all weren't too depressed
without your bi-weekly p
python-dev Summary for 2006-02-01 through 2006-02-15
.. contents::
[The HTML version of this Summary is available at
http://www.python.org/dev/summary/2006-02-01_2006-02-15]
=
Announcements
=
python-dev Summary for 2006-02-16 through 2006-02-28
.. contents::
[The HTML version of this Summary is available at
http://www.python.org/dev/summary/2006-02-16_2006-02-28]
=
Announcements
=
---
python-dev Summary for 2006-03-01 through 2006-03-15
.. contents::
[The HTML version of this Summary is available at
http://www.python.org/dev/summary/2006-03-01_2006-03-15]
=
Announcements
=
---
nikie wrote:
> Steven Bethard wrote:
>
>> nikie wrote:
>>> Steven Bethard wrote:
>>>
>>>> John Salerno wrote:
>>>>> If I want to make a list of four items, e.g. L = ['C', 'A', 'D', 'B'],
>>>
John J. Lee wrote:
> Robin Becker <[EMAIL PROTECTED]> writes:
>
>> When young I was warned repeatedly by more knowledgeable folk that self
>> modifying code was dangerous.
>>
>> Is the following idiom dangerous or unpythonic?
>>
>> def func(a):
>> global func, data
>> data = somethingco
nikie wrote:
> That's what this thread was all about. Now, I don't really see what you
> are trying to say: Are you still trying to convince the OP that he
> should write a Python function like one of those you suggested, for
> performance reasons?
Sure, if it really matters. Code it in C, and yo
Steven Bethard wrote:
> John Salerno wrote:
>> If I want to make a list of four items, e.g. L = ['C', 'A', 'D', 'B'],
>> and then figure out if a certain element precedes another element,
>> what would be the best way to do that?
>&
Edward Elliott wrote:
> Remember kids:
> 1. Numbers can show anything
> 2. Know your data set
> 3. Premature optimizations are evil
Amen. =)
STeVe
--
http://mail.python.org/mailman/listinfo/python-list
John Salerno wrote:
> If I want to make a list of four items, e.g. L = ['C', 'A', 'D', 'B'],
> and then figure out if a certain element precedes another element, what
> would be the best way to do that?
>
> Looking at the built-in list functions, I thought I could do something
> like:
>
> if L
Kay Schluehr wrote:
>> * building a dict of indicies::
>>
>>positions = dict((item, i) for i, item in enumerate(L))
>>
>>if positions['A'] < positions['D']:
>># do some stuff
>>
>>You'll only get a gain from this version if you need to do several
>> comparisons inste
So I see that elementtidy doesn't like strings with \0 characters in them:
>>> import urllib
>>> from elementtidy import TidyHTMLTreeBuilder
>>> url = 'http://news.bbc.co.uk/1/hi/world/europe/492215.stm'
>>> url_file = urllib.urlopen(url)
>>> tree = TidyHTMLTreeBuilder.parse(url_file)
Traceba
I feel like I must be reinventing the wheel here, so I figured I'd post
to see what other people have been doing for this. In general, I love
the optparse interface, but it doesn't do any checks on the arguments.
I've coded something along the following lines a number of times:
class Opti
AndyL wrote:
> What would by a python equivalent of following shell program:
>
> #!/bin/sh
>
> prog1 > file1 &
> prog2 > file2 &
If you're just going for quick-and-dirty, Rob's suggestion of os.system
is probably a reasonable way to go. If you want better error reporting,
I sugges
Lorenzo Thurman wrote:
> This is what I have so far:
>
> //
> #!/usr/bin/python
>
> import os
>
> cmd = 'ntpq -p'
>
> output = os.popen(cmd).read()
> //
>
> The output is saved in the variable 'output'. What I need to do next is
> select the line from that output that starts with the '*'
[sni
Brian Cole wrote:
> I'm not sure if this is the proper place to post this...
>
> A lot of the essays at http://www.python.org/doc/essays/ have a messed
> up layout in Firefox and IE.
The proper place to post this is to follow the "Report website bug" link
at the bottom of the sidebar and post a
[EMAIL PROTECTED] wrote:
> I want to inherit fresh copies of some class variables. So I set up a
> metaclass and meddle with the class variables there.
>
> Now it would be convenient to run thru a dictionary rather than
> explicitly set each variable. However getattr() and setattr() are out
> beca
[EMAIL PROTECTED] wrote:
> OK no question. I'm only posting b/c it may be something another newbie
> will want to google in the future. Now that I've worked thru the
> process this turns out to be fairly easy.
>
> However, if there are better ways please let me know.
>
> Module = ClassVars.py
>
[EMAIL PROTECTED] wrote:
> Oops! This isn't working. As the sequence I'm trying for is
def set_classvars(**kwargs):
> ... def __metaclass__(name, bases, classdict):
> ... for name, value in kwargs.iteritems():
> ... if name not in classdict:
> ...
[EMAIL PROTECTED] wrote:
> Fresh copies of class vars so the first one is the correct: ('foo',
> 'bar', [], False)
Ahh, yeah, then you definitely need the copy.copy call.
import copy
class ClassVars(type):
> ... def __init__(cls, name, bases, dict):
> ... for name, valu
Steven D'Aprano wrote:
> On Tue, 01 Jan 2008 13:36:57 +0100, Diez B. Roggisch wrote:
>
>> And codemonkeys know that in python
>>
>> doc = et.parse(StringIO(string))
>>
>> is just one import away
>
> Yes, but to play devil's advocate for a moment,
>
> doc = et.parse(string_or_file)
>
> would be
Chris Leary wrote:
> As I understand it, the appeal of properties (and descriptors in
> general) in new-style classes is that they provide a way to
> "intercept" direct attribute accesses. This lets us write more clear
> and concise code that accesses members directly without fear of future
> API c
George Sakkis wrote:
> Unless I missed it, PEP 328 doesn't mention anything about this.
> What's the reason for not allowing "from .relative.module import *' ?
Generally, there's a move away from all "import *" versions these days.
For example, Python 3.0 removes the ability to use "import *" wit
Diez B. Roggisch wrote:
> Jean-Paul Calderone wrote:
>
>> On Tue, 22 Jan 2008 15:15:43 +0100, "Diez B. Roggisch"
>> <[EMAIL PROTECTED]> wrote:
>>> Jean-Paul Calderone wrote:
>>>
On Tue, 22 Jan 2008 14:20:35 +0100, "Diez B. Roggisch"
<[EMAIL PROTECTED]> wrote:
> For a simple greenlet/
I'm having trouble using the subprocess module on Windows when my
command line includes special characters like "&" (ampersand)::
>>> command = 'lynx.bat', '-dump', 'http://www.example.com/?x=1&y=2'
>>> kwargs = dict(stdin=subprocess.PIPE,
... stdout=subprocess.PIPE,
...
Steven D'Aprano wrote:
> On Tue, 22 Jan 2008 22:53:20 -0700, Steven Bethard wrote:
>
>> I'm having trouble using the subprocess module on Windows when my
>> command line includes special characters like "&" (ampersand)::
>>
>> >>>
Ross Ridge wrote:
> Tim Golden <[EMAIL PROTECTED]> wrote:
>> but this doesn't:
>>
>>
>> "c:\Program Files\Mozilla Firefox\firefox.exe" "%*"
>>
>>
>>
>> import subprocess
>>
>> cmd = [
>> r"c:\temp\firefox.bat",
>> "http://local.goodtoread.org/search?word=tim&cached=0";
>> ]
>> subprocess.Popen
Kristian Domke wrote:
> I am trying to learn python at the moment studying an example program
> (cftp.py from the twisted framework, if you want to know)
>
> There I found a line
>
> foo = (not f and 1) or 0
Equivalent to ``foo = int(not f)``
> In this case f may be None or a string.
>
> If I
Alan Isaac wrote:
> I have a small set of objects associated with a larger
> set of values, and I want to map each object to its
> minimum associated value. The solutions below work,
> but I would like to see prettier solutions...
>
[snip]
>
> # arbitrary setup
> keys = [Pass() for i in range(10)]
Steven Bethard wrote:
> rndblnch wrote:
>> my goal is to implement a kind of named tuple.
>> idealy, it should behave like this:
>> p = Point(x=12, y=13)
>> print p.x, p.y
>> but what requires to keep track of the order is the unpacking:
>> x, y = p
>>
rndblnch wrote:
> my goal is to implement a kind of named tuple.
> idealy, it should behave like this:
> p = Point(x=12, y=13)
> print p.x, p.y
> but what requires to keep track of the order is the unpacking:
> x, y = p
> i can't figure out how to produce an iterable that returns the values
> in th
Steven D'Aprano wrote:
> I have a problem which I think could be solved by using a dict as a
> namespace, in a similar way that exec and eval do.
>
> When using the timeit module, it is very inconvenient to have to define
> functions as strings. A good alternative is to create the function as
>
Arnaud Delobelle wrote:
> Sligthly improved (not for performance! but signature-preserving and
> looks for default values)
>
> from functools import wraps
> from inspect import getargspec
> from itertools import izip, chain
>
> def autoassign(*names):
> def decorator(f):
> fargnames,
Jeremy Sanders wrote:
> [EMAIL PROTECTED] wrote:
>
>> Any elegant way of breaking out of the outer for loop than below, I
>> seem to have come across something, but it escapes me
>>
>> for i in outerLoop:
>>for j in innerLoop:
>>if condition:
>> break
>>else:
>>co
Wildemar Wildenburger wrote:
> Arnaud Delobelle wrote:
>>> I believe both set and dict comprehensions will be in 3.0.
>>
>> Python 3.0a1+ (py3k:59330, Dec 4 2007, 18:44:39)
>> [GCC 4.0.1 (Apple Inc. build 5465)] on darwin
>> Type "help", "copyright", "credits" or "license" for more information.
>>
[EMAIL PROTECTED] wrote:
> 1. functools.partialpre: partialpre( f, x, y )( z )-> f( z, x, y )
> 2. functools.pare: pare( f, 1 )( x, y )-> f( y )
> 3. functools.parepre: parepre( f, 1 )( x, y )-> f( x )
> 4. functools.calling_default: calling_default( f, a, DefaultA, b )->
> f( a, , b )
There are l
Steven D'Aprano wrote:
> Double-underscore names and methods are special to Python. Developers are
> prohibited from creating their own (although the language doesn't enforce
> that prohibition). From PEP 0008, written by Guido himself:
>
> __double_leading_and_trailing_underscore__: "magi
Phoe6 wrote:
> beta.python.org evolved very nice and noticed today the new python.org
> website going live. There is a change in the look n feel, wherein it
> looks "more official" and maximum possible information about python is
> now directly accessible from the home page itself. Kudoes to the
John Salerno wrote:
> Given:
>
> numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
>
> can someone explain to me why
>
> numbers[10:0:-2] results in [10, 8, 6, 4, 2]?
I always have trouble with these. Given the docs[1]:
"""
The slice of s from i to j with step k is defined as the sequence of
items w
John Salerno wrote:
> Given:
>
> numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
>
> can someone explain to me why
>
> numbers[10:0:-2] results in [10, 8, 6, 4, 2]?
I've filed a bug report:
http://bugs.python.org/1446619
I suggest the following rewording for extended slices:
"""
To get the sli
Roy Smith wrote:
> I'm OK with bold for stuff like this, but the wording could be better. The
> last sentence:
>
> Many Python programmers report substantial productivity
> gains and feel the language encourages the development of
> higher quality, more maintainable code.
>
> r
Michal Kwiatkowski wrote:
> Code below shows that property() works only if you use it within a class.
Yes, descriptors are only applied at the class level (that is, only
class objects call the __get__ methods).
> Is there any method of making descriptors on per-object basis?
I'm still not convi
Martin P. Hellwig wrote:
> While I was reading PEP 8 I came across this part:
>
> """
> Function and method arguments
>Always use 'self' for the first argument to instance methods.
>Always use 'cls' for the first argument to class methods.
> """
>
> Now I'm rather new to programming and u
[EMAIL PROTECTED] wrote:
> I'm having a scoping problem. I have a module called SpecialFile,
> which defines:
>
> def open(fname, mode):
> return SpecialFile(fname, mode)
>
> class SpecialFile:
>
> def __init__(self, fname, mode):
> self.f = open(fname, mode)
> ...
>
[snip]
>
> Ho
A.M. Kuchling wrote:
> On Sun, 12 Mar 2006 10:25:19 +0100,
> Fredrik Lundh <[EMAIL PROTECTED]> wrote:
>> and while you're at it, change "python-dev" to "developers" and
>> "psf" to "foundation" (or use a title on that link).
>
> I've changed the PSF link, but am not sure what to do about th
I'm having trouble using elementtree with an XML file that has some
gbk-encoded text. (I can't read Chinese, so I'm taking their word for
it that it's gbk-encoded.) I always have trouble with encodings, so I'm
sure I'm just screwing something simple up. Can anyone help me?
Here's the interac
Diez B. Roggisch wrote:
> Steven Bethard schrieb:
>> I'm having trouble using elementtree with an XML file that has some
>> gbk-encoded text. (I can't read Chinese, so I'm taking their word for
>> it that it's gbk-encoded.) I always have trouble
Diez B. Roggisch wrote:
>> Here's what I get with the prepending hack:
>>
>> >>> et.fromstring('\n' +
>> open(filename).read())
>> Traceback (most recent call last):
>> File "", line 1, in ?
>> File "C:\Program
>> Files\Python\lib\site-packages\elementtree\ElementTree.py", line 960,
>> in X
the.theorist wrote:
> I was writing a small script the other day with the following CLI
> prog [options] [file]*
>
> I've used getopt to parse out the possible options, so we'll ignore
> that part, and assume for the rest of the discussion that args is a
> list of file names (if any provided).
>
Fredrik Lundh wrote:
> Steven Bethard wrote:
>
>> I'm having trouble using elementtree with an XML file that has some
>> gbk-encoded text. (I can't read Chinese, so I'm taking their word for
>> it that it's gbk-encoded.) I always have trouble with
Fredrik Lundh wrote:
> Steven Bethard wrote:
>
>> Hmm... I downloaded the newest cElementTree (and I already had the
>> newest ElementTree), and here's what I get:
>
>> >>> tree = myparser(filename, 'gbk')
>> Traceback (most recent call
Schüle Daniel wrote:
> however we lack the reverse functionality
> the logical
>
> >>> str(10,2)
> Traceback (most recent call last):
> File "", line 1, in ?
> TypeError: str() takes at most 1 argument (2 given)
> >>>
>
> fails
>
> it would not break anything if str interface would be change
Colin J. Williams wrote:
> Doc strings provide us with a great opportunity to illuminate our code.
>
> In the example below, __init__ refers us to the class's documentation,
> but the class doc doesn't help much.
It doesn't?
>>> print list.__doc__
list() -> new list
list(sequence) -> new list i
[EMAIL PROTECTED] wrote:
f(01)
> 43
f(02)
> 44
f(010)
> 50
42+010
> 50
>
> The first f(01) was a mistake. I accidentally forgot to delete the
> zero, but to my suprise, it yielded the result I expected. So, I tried
> it again, and viola, the right answer. So, I decided to re
Gregory Petrosyan wrote:
> 1) From 2.4.2 documentation:
> There are two new valid (semantic) forms for the raise statement:
> raise Class, instance
> raise instance
Check `PEP 8`_ -- the latter form is preferred:
"""
When raising an exception, use "raise ValueError('message')" instead of
the old
Anand wrote:
> Wouldn't it be nice to say
>
> id, *tokens = line.split(',')
id, tokens_str = line.split(',', 1)
STeVe
--
http://mail.python.org/mailman/listinfo/python-list
bruno at modulix wrote:
> Hi
>
> I'm currently playing with some (possibly weird...) code, and I'd have a
> use for per-instance descriptors, ie (dummy code):
>
> class DummyDescriptor(object):
> def __get__(self, obj, objtype=None):
> if obj is None:
> return self
> return getatt
Anand wrote:
>>> Wouldn't it be nice to say
>>> id, *tokens = line.split(',')
>>
>> id, tokens_str = line.split(',', 1)
>
> But then you have to split tokens_str again.
>
> id, tokens_str = line.split(',', 1)
> tokens = tokens_str.split(',')
Sorry, it wasn't clear that you needed the tokens from
bruno at modulix wrote:
> Steven Bethard wrote:
>> Could you explain again why you don't want baaz to be a class-level
>> attribute?
>
> Because the class is a decorator for many controller functions, and each
> controller function will need it's own set of desc
bruno at modulix wrote:
> Using a class as a
> decorator, I have of course only one instance of it per function - and
> for some attributes, I need an instance per function call.
Per function call? And you want the attributes on the function, not the
result of calling the function? If so, that
1401 - 1500 of 1538 matches
Mail list logo