Re: Naive idiom questions



On 2008-01-31, Terran Melconian <te_rem_ra_ove_an_forspam@xxxxxxxxxxxxxx> wrote:

* Why are there no real mutable strings available?

[...]

I want to be able to accumulate a string with +=, not by going
through an intermediate list and then doing ''.join(),

So what's stopping you?

s = "one"
s += " two"
s
'one two'


because I think the latter is ugly.

Then don't do it. :)

There are also times when I'd like to use the string as a
modifiable buffer.

That would be an array of characters or bytes:

http://docs.python.org/lib/module-array.html

Is the python idiom that this is actually the Right Thing for
reasons I'm not seeing?

I'm not sure what you're asking. AFAIK, the main reason that
strings are immutable is so they can be used as dict keys.

Is there a fundamental reason it would be hard to
implement a mutable string in cpython?

What problem would a mutable string solve that an array of
chars won't?

* What's the best way to initialize a list of lists?

Hmm. I guess I never need to do that.

* Is there a way to get headings in docstrings?

Docstrings? Real Men Don't Write Docstrings!

--
Grant Edwards grante Yow! Now, let's SEND OUT
at for QUICHE!!
visi.com
.



Relevant Pages

  • Re: g77 and DVF works fine but ifc causes a run-time error! Any ideas?
    ... Just because an array of size 1 has only one element, ... The standard does not allow you to pass a named scalar ... automatic code writing software isn't likely to special-case ... There are also a bunch of reasons that are a bit on the strage side ...
    (comp.lang.fortran)
  • Re: ReDimed Array size
    ... It also leads to possibilities of out-of-memory problems owing to memory fragmentation. ... to automatically redim the array instead of raising the error should not be an overhead. ... that has many reasons for being one or the other--there are historical reasons of compatibility as well as applications where one or the other makes common sense. ... I think it's a remain from the old days and also an inheritance from low level languages, but it's not good for a high level language. ...
    (microsoft.public.vb.general.discussion)
  • Re: dgemm subroutine in BLAS - I think Ive cracked the difference, please confirm
    ... > see what I'm talking about), so in the current state of memory allocation, ... padding for performance reasons - a memory subsystem might work much better ... so you would perform a 1024x1024 FFT on a 1025x1024 array ...
    (comp.lang.fortran)
  • Re: dgemm subroutine in BLAS - I think Ive cracked the difference, please confirm
    ... > if the stride is not a power of two, for instance (this is true on many ... > - there are algorithms, some recursive, that operate on smaller subarrays ... > of the whole array. ... > There are likely additional reasons... ...
    (comp.lang.fortran)
  • Re: Dynamic allocation of a triple indirection
    ... > I'm trying to dynamically allocate memory to an array of strings ... for reasons that have been discussed many times before. ... > The reason for building this array is to feed it to sscanfto parse ... > characters to my sscanfoutput strings. ...
    (comp.lang.c)