On 2006-12-14, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Neil Cerutti wrote:
>> On 2006-12-14, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>> >
>> > Neil Cerutti wrote:
>> >> On 2006-12-13, [EMAIL PROTECTED]
>> >> <[EMAIL
adipiscing [...]'''
> prefix = '>'
>
> import textwrap
> lines = ["%s %s" % (prefix, line) for line in textwrap.wrap(text,
> width=75)]
The solution will need to be instrumented in case of text that is
already quotes to one level. All
oes. It makes perfect sense.
> I did say that I thought it would be a rarely used feature :-)
Though the full rationale no longer applies to strings, which now
have plenty of methods.
--
Neil Cerutti
Weight Watchers will meet at 7 p.m. Please use large double door at the side
entrance. --Church Bulletin Blooper
--
http://mail.python.org/mailman/listinfo/python-list
I like using pattern matching in these simple cases:
last_line, _ = subprocess.Popen([r"tail","-n 1", "x.txt"],
stdout=subprocess.PIPE).communicate()
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
u *really* think
> that the Lisp savings are not worth it, then you would begin
> with my suggestion today.
I don't know how to build a house. It doesn't make me want to
live in a cave. ;-)
--
Neil Cerutti
The third verse of Blessed Assurance will be sung without musical
accomplishment. --Church Bulletin Blooper
--
http://mail.python.org/mailman/listinfo/python-list
ot;, "hello")
>
> But it seems such capability isn't shared with the append:
>
>>>> a.extend("hello")
> Traceback (most recent call last):
> File "", line 1, in
> TypeError: an integer is required
Try:
>>> a.fromstring(&qu
my code.
I first came accross it in Stroustrup's _The C++ Programming
Language_. I liked the look and the idea immediately, but my
editor of choice (by historical accident) Vim, doesn't yet
support it.
--
Neil Cerutti
I've had a wonderful evening, but this wasn't it. --Groucho Marx
--
http://mail.python.org/mailman/listinfo/python-list
efinition S, say, rename it to be xyz.cpp
> and feed it to a C++ compiler, the S sure remains a struct and
> the C++ compiler has no difficulty in handling it as a struct,
> so ?!?
That's true.
But it's also true that
struct foo {
int x, y;
};
is exactly equivalent to:
tory that's not stored in a format
that's easy to sort.
>>> a = [("Neil Cerutti", "8025552954"), ("Ted Smith", "8025552281"), ("Barny
>>> Fife", "8025551105")]
>>> b = [(" ".join(reversed(x.
On 2007-01-04, Peter Otten <[EMAIL PROTECTED]> wrote:
> Neil Cerutti wrote:
>> Another trick is to factor the key application out of the
>> sort. This may be a good idea if when you want to minimize the
>> number of times your key function is called.
>>
_x = 'mod2'
>
> And the test is:
>
> from mod1 import B as B1
> from mod2 import B as B2
>
> class A(B1, B2): pass
>
> a = A()
> a.foo()
> print a._B__x
> a.bar()
> print a._B__x
>
> Sure enough, mod2 messes up mod1's pr
gh if only I knew the
> number of keys/lists beforehand
len(dict.keys()).
--
Neil Cerutti
Next Sunday Mrs. Vinson will be soloist for the morning service. The pastor
will then speak on "It's a Terrible Experience." --Church Bulletin Blooper
--
http://mail.python.org/mailman/listinfo/python-list
static int i;
> }
>
>
> Do you agree that i is "private" to test ?
In C one uses the pointer to opaque struct idiom to hide data.
For example, the standard FILE pointer.
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
On 2007-01-08, Jussi Salmela <[EMAIL PROTECTED]> wrote:
> Neil Cerutti kirjoitti:
>> In C one uses the pointer to opaque struct idiom to hide data.
>> For example, the standard FILE pointer.
>
> To Neil Cerutti: If a programmer in C has got a pointer to some
> piece o
foo:
> print "Foo!"
> if bar:
> print "Bar!"
That's the key issue. The colon gives the editor an easy clue
where a block starts, but the there's no simply way to determine
where the block is supposed to end.
--
Neil Cerutti
Remember in prayer the many who are sick of our church and community. --Church
Bulletin Blooper
--
http://mail.python.org/mailman/listinfo/python-list
n doesn't
even try to make educated guesses.
class Thing:
pass
class Animal(Thing):
pass
class Dog(Animal):
pass
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
x27;)
o_bracket = re.compile('\\[')
c_bracket = re.compile('\\]')
colon = re.compile(':')
ix = 0
lexed_line = []
m = lambda regex, ix: match(regex, proto, ix, lexed_line)
while ix < len(proto):
old = ix
ix = m(arg_count, i
=re.compile('>|<'), end='---')
> BlockReader(f, start=lambda x: x.startswith('>'))
>
> Maybe make variations for character-based readers and
> line-based readers.
I would prefer, "f.readlines(delim='>')" etc., a la C++
str::getline.
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
> I agree with Bruno that i and j should be used only for
> indices, but I'm usually less terse than that.
I find i and j preferable to overly generic terms like "item."
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
ntly,
and with similar data inputs and outputs.
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
On 2007-06-06, Bruno Desthuilliers
<[EMAIL PROTECTED]> wrote:
> Neil Cerutti a écrit :
>> On 2007-06-04, Michael Hoffman <[EMAIL PROTECTED]> wrote:
>>> Wildemar Wildenburger wrote:
>>> I agree with Bruno that i and j should be used only for
>>&g
ria?
Consult the Python Docs about the heapq module.
--
Neil Cerutti
Beethoven wrote fewer symphonies than Haydn and Mozart because he wrote
longer, and besides he went death. --Music Lit Essay
--
http://mail.python.org/mailman/listinfo/python-list
On 2007-06-06, Josiah Carlson <[EMAIL PROTECTED]> wrote:
> Neil Cerutti wrote:
>> On 2007-06-06, rhXX <[EMAIL PROTECTED]> wrote:
>>> and/or
>>>
>>> - SORTED - INSERT in the correct place using some criteria?
>>
>> Consult the Python
that list.
The 'other' program is called 'new.py'. Is that what's causing
my problem?
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
On 2007-06-07, Robin Becker <[EMAIL PROTECTED]> wrote:
> BartlebyScrivener wrote:
>> On Jun 7, 8:17 am, Neil Cerutti <[EMAIL PROTECTED]> wrote:
>
>> A good habit for naming your scripts: If you have a script and you
>> want to name it text.py, or list.p
On 2007-06-07, Stebanoid <[EMAIL PROTECTED]> wrote:
> if you have a list of functions you can try this:
>
> import random
> import math
> m[int(math.floor(len(m)*random.random()))]() # seems like Lisp
Or rather m[random.randint(0, len(m))]()
--
Neil Cerutti
Caution: Cape
On 2007-06-07, Dustan <[EMAIL PROTECTED]> wrote:
> On Jun 7, 1:30 pm, Neil Cerutti <[EMAIL PROTECTED]> wrote:
>> On 2007-06-07, Stebanoid <[EMAIL PROTECTED]> wrote:
>>
>> > if you have a list of functions you can try this:
>>
>> > i
On 2007-06-08, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote:
> Neil Cerutti a écrit :
>> On 2007-06-06, Bruno Desthuilliers
>> <[EMAIL PROTECTED]> wrote:
>>> Neil Cerutti a écrit :
>>>> On 2007-06-04, Michael Hoffman <[EMAIL PROTECTED]> wrote:
On 2007-06-08, Stebanoid <[EMAIL PROTECTED]> wrote:
> On 8, 00:07, Dustan <[EMAIL PROTECTED]> wrote:
>> On Jun 7, 1:30 pm, Neil Cerutti <[EMAIL PROTECTED]> wrote:
>>
>> > On 2007-06-07, Stebanoid <[EMAIL PROTECTED]> wrote:
>>
&
ily, the output format has not changed yet, so issues with
maintaining the above haven't arisen.
However, I'd like something better.
Is there already a good module for working with fixed format
records available? I couldn't find one.
If not, please suggest how I might improve the above co
On 2007-06-08, Jeremy C B Nicoll <[EMAIL PROTECTED]> wrote:
> Neil Cerutti <[EMAIL PROTECTED]> wrote:
>> Luckily, the output format has not changed yet, so issues with
>> maintaining the above haven't arisen.
>
> The problem surely is that when you want to ch
On 2007-06-08, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
> In <[EMAIL PROTECTED]>, Neil Cerutti wrote:
>
>> new = file("new.dat", "w")
>> if not new:
>> print "Error. Could not open file new.dat for writing
On 2007-06-11, Marius Gedminas <[EMAIL PROTECTED]> wrote:
> On Jun 6, 3:18 pm, Neil Cerutti <[EMAIL PROTECTED]> wrote:
>> > Since 'i' and 'j' are canonically loop indices, I find it
>> > totally confusing to use them to name the iteration var
igned not by piling feature
on top of feature, but by removing the weaknesses and
restrictions that make additional features appear necessary.
Of course, that was written well before Scheme had most of its
current features.
--
Neil Cerutti
These people haven't seen the last of my fa
and non-recursive tail-calls. You
can't reasonably hand-optimize away the stack frame for all
tail-calls.
def foo(x)
bar(x)
The only way to hand-optimize the call to bar is to inline it
yourself.
--
Neil Cerutti
Will the highways on the Internet become more few? --George W. Bush
--
http://mail.python.org/mailman/listinfo/python-list
her behavior would be absurd,
> anyhow.
There's a reason it's generally refered to as "tail-call"
optimization and not "tail-recursive" optimization. The former is
more general, and, I believe, easier to implement than the
latter.
--
Neil Cerutti
The peace-making
ot;, line 525, in bar
raise ValueError
ValueError
shell returned 1
What makes the latter harder to work with?
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
On 2007-06-13, Neil Cerutti <[EMAIL PROTECTED]> wrote:
> On 2007-06-13, Anders J. Munch <[EMAIL PROTECTED]> wrote:
>> General tail-call optimisation is of course completely
>> out-of-bounds for Python, because it ruins tracebacks. Unlike
>> tail recursion, w
slowing it down in comparison to the non-method version.
Try the following simple optimization, using a local variable
instead of an attribute to build up the result.
# The method in a class
class bar:
def readgenome(self, filehandle):
s = ''
for line in filehandle.xre
On 2007-06-14, Bruno Desthuilliers
<[EMAIL PROTECTED]> wrote:
> Neil Cerutti a écrit :
> (snip)
>> class bar:
>> def readgenome(self, filehandle):
>> self.s = ''.join(line.strip() for line in filehandle)
>
>=>
>self.s
t provides to deal with
multiple inheritance, or generic, type-safe code. I don't think
it's inconsistent, though. The complexity of a feature *tends* to
mirror the *real* complexity.
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
On 2007-06-16, Paul Rubin wrote:
> Neil Cerutti <[EMAIL PROTECTED]> writes:
>> I vote for C++ as being astoundingly complex. But it provides
>> complex features, e.g.,the machanisms it provides to deal with
>> multiple inheritance, or generic, type-safe code.
>
&
ns long before I learned
about functions in Programming 101.
100 NAME$="TED"
110 AGE=40
120 GOSUB 1000
1000 PRINT NAME$, " IS ", AGE, " YEAR(S) OLD."
1010 RETURN
Named functions are so much nicer than numbered ones.
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
On 2007-06-17, Paul Rubin wrote:
> Neil Cerutti <[EMAIL PROTECTED]> writes:
>> I don't know that much about ML. I know is does a really nice job
>> of generic containers, as does C++. But can it 'foo' any type as
>> easily as C++?
>>
>&
s and what technique I should use.
You could get good results, and save yourself some effort, using
links or lynx with the command line options to dump page text to
a file. Python would still be needed to automate calling links or
lynx on all your documents.
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
directory and
read python.vim. Unfortunately, the current version contains no
documention, so it's harder to figure out what you get than it
ought to be.
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
impractical discussions of Scheme's dark
corners. Python is either much more free of dark corners, or else
simply doesn't attract that kind of aficionado.
--
Neil Cerutti
Let us join David and Lisa in the celebration of their wedding and bring their
happiness to a conclusion. --Church Bulletin Blooper
--
http://mail.python.org/mailman/listinfo/python-list
an instance of the class:
foo f;
f.bar();
}
In C++ they are used most often for factory functions, since they
conveniently have access to the class's private members, and
don't want or need an existing instance. Python seems to have
adopted this use-case (ConfigParser, for example)
On 2007-06-20, Alex Martelli <[EMAIL PROTECTED]> wrote:
> Neil Cerutti <[EMAIL PROTECTED]> wrote:
>
>> In C++ they are used most often for factory functions, since they
>> conveniently have access to the class's private members, and
>> don't want or n
On 2007-06-20, Neil Cerutti <[EMAIL PROTECTED]> wrote:
> On 2007-06-20, Alex Martelli <[EMAIL PROTECTED]> wrote:
>> Neil Cerutti <[EMAIL PROTECTED]> wrote:
>>> In C++ they are used most often for factory functions, since
>>> they conveniently have a
s
implementation of your Python curses program.
It doesn't actually use the windows console, however.
You could write your own little console interface, tailored to
your needs, which is implemented using curses on Unix, and the
effbot's 'console' on Windows.
--
Neil Cerutti
Symphonies of the Romantic era were a lot longer in length.
--Music Lit Essay
--
http://mail.python.org/mailman/listinfo/python-list
>
> And so on. Many thanks,
I think I'd put together a simple grammar and then write a
recursive descent parser that spit out my output files. But
that's just because I find that kind of thing fun. ;)
--
Neil Cerutti
I'm tired of hearing about money, money, money, money
open('in.txt', 'r')
>
> for line in f1:
> print line.rsplit(':')[4].strip("'"),
>
> Output:
>
> Afghanistan'
> Albania'
> Algeria'
> American Samoa'
>
> Why is there a apostrophe still at the end?
Most likely it's the newline at the end of each record that's
getting in your way.
You can double-strip it.
for line in f1:
print line.strip().rsplit(':')[4].strip("'")
--
Neil Cerutti
The world is more like it is now than it ever has been before. --Dwight
Eisenhower
--
http://mail.python.org/mailman/listinfo/python-list
t the intended effect.
def f():
a = [12]
def g():
if a[0] < 14:
a[0] = 13
g()
return a[0]
You'll get better results, in Python, by using a class instances
instead of closures. Not that there's anything wrong with Python
closures, but the scoping rules make some fun tricks too tricky.
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
ge prior to the adoption of CLOS.
Is there a second example? ;)
Seriously, maybe Python looks like 'blub' (thanks, Paul Graham),
to the skilled Lisp user, but it makes a lot of other languages
look like 'blub', too, including, sometimes, Lisp: Lisp has to
'blub' generators.
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
27;]
>
> what I need to do is compare l1 against l2 and return the "position"
> of where each object in l1 is in l2
>
> ie: pos = 0, 2, 4
>
> Thanks in advance, -h
Come, come! You can try harder than that.
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
On 2007-06-21, Douglas Alan <[EMAIL PROTECTED]> wrote:
> Neil Cerutti <[EMAIL PROTECTED]> writes:
>> Seriously, maybe Python looks like 'blub' (thanks, Paul
>> Graham), to the skilled Lisp user, but it makes a lot of other
>> languages look like 'blu
On 2007-06-22, Douglas Alan <[EMAIL PROTECTED]> wrote:
> Neil Cerutti <[EMAIL PROTECTED]> writes:
>> That said, I wouldn't give up the summer I spent studying _Simply
>> Scheme_.
>
> Sounds like fun. Is this like a kinder, gentler version of SICP?
No, it i
's see if I get this right.
>
> You create a website for a subject that you know nothing about. Then you
> try to solicit content in a bunch of programming language newsgroups.
>
> Wow, that's pretty pathetic, even for a google-groups poster!
Maybe they lost the business
for the .split method.
x = 'Smith, Ted, 15 Smedly Rd."
last, first, street = x / ', '
Tongue-in-cheekily-yours,
--
Neil Cerutti
Strangely, in slow motion replay, the ball seemed to hang in the air for even
longer. --David Acfield
--
http://mail.python.org/mailman/listinfo/python-list
only those variables?
This is off the cuff. There's likely a better way.
for k, v in MyClass.__dict__.iteritems():
if isinstance(v, property):
print k, v.__doc__
--
Neil Cerutti
22 members were present at the church meeting held at the home of Mrs. Marsha
Crutchfield last evening.
how to make
> the interpreter find instance name space first? Or any way to
> make programmer's life easier?
Try thinking of "self." as a notation that provides vital
information to you, the programmer.
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
iliar
> with generators yet so don't laugh) which changed my code just
> a slight bit:
Experimentation with stuff you don't fully understand is a great
way to learn, but not that useful for solving exercises. ;)
--
Neil Cerutti
This team is one execution away from being a very good basketball team. --Doc
Rivers
--
http://mail.python.org/mailman/listinfo/python-list
ation...
> This should be:
>
> class Led(Device):
> #...
Using a naming convention for class objects, e.g., camel-case, is
a practice very similar to hungarian notation.
I would've said something like: start learning the Python
community's naming conventions, and use t
SyntaxError("Ill-formed expression")
return parse_ast(sexp.read(expr))
The sexp parser I wrote returns a tuple that represents the parse
tree of an s-expression, and recognizes only s-expressions,
strings and integers.
How can I make the Python more idiomatic Python?
How can I make it more "beautiful"? A type hierarchy seems
over-engineered in comparison to Scheme's type-case, but I
liked a cascade of isinstance calls (as in parse) even less.
The type hierarchy did allow me to factor out the code
duplication in the (sub ...) and (add ...) types of Scheme, and
seems like a nice benefit over type-case.
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
On 2007-07-02, Laurent Pointal <[EMAIL PROTECTED]> wrote:
> Neil Cerutti wrote:
>> How can I make the Python more idiomatic Python?
>
> Have you taken a look at pyparsing ?
Yes, I have it. PyParsing has, well, so many convenience features
they seem to shout down whatever
On 2007-07-02, Paul McGuire <[EMAIL PROTECTED]> wrote:
> On Jul 2, 3:56 pm, Neil Cerutti <[EMAIL PROTECTED]> wrote:
> from pyparsing import *
It's always good when your messages start like that. ;)
> """
> Ok, here is the step-by-step, beginning with
uble quote; r"\" is not a valid string
literal (even a raw string cannot end in an odd number of
backslashes). Specifically, a raw string cannot end in a
single backslash (since the backslash would escape the
following quote character). Note also that a single backslash
followed by
, line 810, in _
parseNoCache
tokens = fn( instring, tokensStart, retTokens )
File "C:\edconn32\Python25\Lib\site-packages\pyparsing.py", line 658, in t
mp
return f(t)
File "wae.py", line 118, in
binop.setParseAction(lambda t: BinOp(t.op, t.lhs,
out the Python version is the cruft
required by the class hierarchy.
--
Neil Cerutti
I pulled into a lay-by with smoke coming from under the bonnet. I realized the
car was on fire so took my dog and smothered it with a blanket. --Insurance
Claim Blooper
--
http://mail.python.org/mailman/listinfo/python-list
On 2007-07-03, Méta-MCI <[EMAIL PROTECTED]> wrote:
> Hi!
>
>> Python 3000 doesn't include many significant changes to the language
>
> One exemple : non-Ascii characters in identifiers (= no significatif
> change?)
It is one of not many?
--
Neil Cerutti
--
n we could remove b) also and r"" strings
> would work as everyone expects.
>
> Does anyone know the justification for a)? Maybe we should
> remove it in py3k?
If the escaped quotes didn't function in raw strings, I'd be
unable to construct (with a single notat
On 2007-07-04, Neil Cerutti <[EMAIL PROTECTED]> wrote:
> On 2007-07-04, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
>> On Wed, 04 Jul 2007 11:21:14 +, Neil Cerutti wrote:
>>
>>> If the escaped quotes didn't function in raw strings, I
On 2007-07-04, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
> On Wed, 04 Jul 2007 11:21:14 +, Neil Cerutti wrote:
>
>> If the escaped quotes didn't function in raw strings, I'd be
>> unable to construct (with a single notation) a regex t
in Library Reference 2.2 Non-essential
Built-in Functions.
Apparently it is no longer needed or useful, but only kept for
backward compatibility.
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
f something like the following would help:
>>> def foo():
... try:
... 12/0
... except ZeroDivisionError, e:
... e.my_info = "Oops!"
... raise
...
>>> try:
... foo()
... except ZeroDivisionError, e:
... print e.my_info
...
Oops!
Users could get at the e
t;
> Then tell us, pray, who was willing to pay for the epitome of useless
> features in MS Word, that Useless Features' Useless Feature, the
> ability to format text with the animated effect "Marching Red Ants"?
> I'm sure I paid for it, but it wasn't willingly...
You should count your blessings. At least it doesn't play
pinball any more. At least, I hope not.
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
gt;
> import csv
>
> dictZipZones = {}
>
> reader = csv.reader(open("some.csv", "rb"))
> for row in reader:
> # Add the row to the dictionary
In addition to Chris's answer, the csv module can read and write
dictionaries directly. Look up csv.DictReader an
On 2007-07-05, Christoph Zwerschke <[EMAIL PROTECTED]> wrote:
> Neil Cerutti wrote:
>> The documentation for BaseException contains something that might
>> be relevant:
>>
>>[...] If more data needs to be attached to the exception,
>>attach it throu
?
It's a string to start with, since it comes from a text file.
Besides, a string is an excellent epresentation for a zip code,
since arithmetic upon them is unthinkable.
I shared your frustration with the csv module docs when I first
read them. But happily you can skip them and just read
the easily adapted examples (9.1.5 Examples).
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
On 2007-07-05, Christoph Zwerschke <[EMAIL PROTECTED]> wrote:
> Neil Cerutti wrote:
>> You may need the traceback module to get at the error message, if
>> trying to read e.message can fail.
>>
>> Something like this mess here: ;)
>>
>>...
>
guy, but I am a newbie. I would really
> appreciate if you can show in this thread how this can be done
> in Python.
Chech out the docs for sys.exc_info(), and for the raise
statement.
When handling an exception, you can rethrow a different
exception, but with the same traceback, by using the three-arg
version of raise.
See one of my earlier posts in this thread for a working example
(although it didn't solve Chris's problem).
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
er category make up the whole (one
> half plus the other half) and so that WE DON'T EXIST!!! A
> ridiculous claim to be sure, but we'd better let Herr Schluehr
> know that in no uncertain terms...
Wow! That explains why I had so much trouble eating me Wheaties
On 2007-07-05, John Machin <[EMAIL PROTECTED]> wrote:
> On Jul 6, 5:31 am, Neil Cerutti <[EMAIL PROTECTED]> wrote:
>>
>> Mostly you can use the default 'excel' dialect and be quite
>> happy, since Excel is the main reason anybody still cares about
>
On 2007-07-06, Neil Cerutti <[EMAIL PROTECTED]> wrote:
> On 2007-07-05, John Machin <[EMAIL PROTECTED]> wrote:
>> On Jul 6, 5:31 am, Neil Cerutti <[EMAIL PROTECTED]> wrote:
>>>
>>> Mostly you can use the default 'excel' dialect and be quite
private'' attributes of base and derived classes.
Further, from the _Python Tutorial (9.6) Private Variables_:
(Buglet: derivation of a class with the same name as the base
class makes use of private variables of the base class
possible.)
In other words, it's a mis
procedural language.
Going back to the stack machine question, and using it as an
example: Assume you design your program as a state machine.
Wouldn't it be easier to implement in a (hypothetical)
state-machine-based programming language than in a procedural
one? I think John was insinuating th
tand it--so they invented Smalltalk and now don't
> understand _it_!"
Heh, heh. Thanks for the intersting info.
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
ttributes that should not be
overrided or accessed by derived classes.
the weasel words from the documentation (which I put in quotes)
are there because the feature doesn't work (in all cases).
--
Neil Cerutti
The doctors X-rayed my head and found nothing. --Dizzy Dean
--
http://mail.python.org/mailman/listinfo/python-list
her
than base 10, but conversions to integer is the only support.
You can do:
>>> d = int(s, base).
but not:
>>> s = str(d, base)
The % format operator can do hex and octal, I believe.
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
>> Wow, can you make a coffee in.. 57ms ?
>
> [snip demonstration of xrange raising an exception]
>
> Of course! Can't you?
>
> And if I use a microwave oven, the coffee is made so quickly
> that I actually go backwards in time...
But what happens if you use a microwave oven? ... What the!?!?
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
ion to the dictionary of
defaulted elements is what I really want.
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
like this I want to cry...
>
>
>>>> adict = {(1,2): "parrot"}
>
> Try replacing that tuple with a list. "Just optimization" my eye!
So the question becomes: Why do Python dictionaries require keys
to be of an immutable type?
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
On 2007-04-23, Chris Cioffi <[EMAIL PROTECTED]> wrote:
> On 23 Apr 2007 17:19:15 +0200, Neil Cerutti <[EMAIL PROTECTED]>
> wrote:
>> So the question becomes: Why do Python dictionaries require
>> keys to be of an immutable type?
>
> Dictionary keys are hashed
On 2007-04-23, Steve Holden <[EMAIL PROTECTED]> wrote:
> Neil Cerutti wrote:
>> So the question becomes: Why do Python dictionaries require
>> keys to be of an immutable type?
>
> Because otherwise people would expect to be able to use a list
> to select a dict
.
Python's dictionaries are a proven winner--I'm definitely not an
advocate for changing them. But the general requirement for a
mapping container *isn't* that keys be immutable, but that you
either don't mutate keys, or don't do so without also reording
(rehashing?) the mapping.
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
he divider-between-elements model presented in the tutorial
really the "best way" to understand half-open range notation?
I vote we change the word "best" to "possible" in the excerpt.
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
On 2007-04-25, Steve Holden <[EMAIL PROTECTED]> wrote:
> Neil Cerutti wrote:
>> That would be documented as undefined behavior, and users
>> exhorted not to do such things.
>>
>> Python's dictionaries are a proven winner--I'm definitely not an
>
f [2:4] as a half-open range
much easier.
I suppose the above model could avoid this notational problem if
you say that a[k] means the one element slice a[k:k+1]
(technically true for strings, but false for lists), rather than
ever thinking of item indexes as pointing directly at an item.
So
inition.
> And before someone get's all technical, I know everything in
> Python is an 'object' even None, which implies class, or is it
> the other way around?
Classes are just objects like everything else.
--
Neil Cerutti
Bach's death is attributed to the end of the Baroque era. --Music Lit Essay
--
http://mail.python.org/mailman/listinfo/python-list
601 - 700 of 1188 matches
Mail list logo