I take it then that you believe that ints like 1 should be mutable like
lists? Because that is what the suggested behaviour implies.
Ah, what a grand thing that would be! We could say:
0 += 1
1 += 2
7 -= 1
and then have 0 + 1 == 7. Think of the obfuscated code we could write!
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
lass
>>> variable or the object variable but not both. So either it could raise
>>> an attribute error or add two to the class variable.
>>
>> It does exactly what you say. It adds 2 to the a *instance variable* of
>> the object instance in 'b'.
>
> There is no instance variable at that point. How can it add 2, to
> something that doesn't exist at the moment.
By the standard rules of inheritance.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
don't care that much on how it gets fixed.
It isn't broken, there is nothing to fix. The code does precisely what the
inheritance model promises to do.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
ints '\n\r'
# Scenario 3
# Python code with standard inheritance:
class Paragraph:
ls = '\n' # line separator
linux_para = Paragraph()
windows_para = Paragraph()
windows_para.ls = '\n\r'
linux_para.ls
=> prints '\n'
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
s not a name: b.a is an attribute reference. You wouldn't
call b["a"] a name, and you shouldn't call b.a a name either.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
8
Look at that: the object which is referred to depends on how many times
you've already been through the loop. How nuts is that?
I guess that brings us back to making ints mutable. I can't wait until I
can write 1 - 0 = 99 and still be correct!
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
Why would you want b.a =
to correspond to b.__class__.a = ?
I'm not saying that it couldn't, if that was the model for inheritance you
decided to use. I'm asking why would you want it? What is your usage case
that demonstrates that your preferred inheritance model is useful?
--
St
On Thu, 03 Nov 2005 13:29:26 +0100, Jerzy Karczmarczuk wrote:
> Now, tell me: is the polluting of a newsgroup with off-topic postings,
> a crime,
Not in any nation that values personal freedom over petty laws controlling
people's behaviour for no good purpose.
--
Steven
ts (e.g. lists) are shared among
> instances of a class and the class itself
> - simple values are not shared
No. it is all about the inheritance, and mutable/immutable objects.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
s? You don't recommend doing this?
def MyClass:
def __init__(self, x):
self.x = x
???
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
l poster did ask how to read every nth byte
of "the Internet stream", so I assumed he had something like that in mind.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
Ewald R. de Wit wrote:
> I'm running into a something unexpected for a new-style class
> that has both a class attribute and __slots__ defined. If the
> name of the class attribute also exists in __slots__, Python
> throws an AttributeError. Is this by design (if so, why)?
>
> class A( object ):
On Thu, 03 Nov 2005 10:01:04 -0800, Paul Rubin wrote:
> Steven D'Aprano <[EMAIL PROTECTED]> writes:
>> Then you don't approve of inheritance? That's fine, it is your choice, but
>> as far as I know, all OO languages include inheritance.
>
> Some OO langu
On Thu, 03 Nov 2005 20:19:03 +0100, bruno at modulix wrote:
> Steven D'Aprano wrote:
>> On Thu, 03 Nov 2005 10:14:23 +0100, bruno at modulix wrote:
>>
>>
>>>Tieche Bruce A MSgt USMTM/AFD wrote:
>>>
>>>>I am new to python,
>>>&g
On Thu, 03 Nov 2005 16:40:43 -0500, Peter Hansen wrote:
> Steven D'Aprano wrote:
>> On Thu, 03 Nov 2005 15:51:30 +, Grant Edwards wrote:
>>>
>>>I've never heard of anybody using the data as source of
>>>entropy.
>>
>> Me neither,
one):
self.size = size
def print(self):
if self.size is None:
papersize = self.__class__.default_size
else:
papersize = self.size
do_something(papersize)
The standard inheritance model used by Python and all
OO languages I kno
rd behaviour. Is your behaviour more useful? Does
it make code easier to write? Does it result in more compact code? What
usage cases?
Or is it just a subjective judgement on your part that it would be neater?
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, 04 Nov 2005 09:03:56 +, Antoon Pardon wrote:
> Op 2005-11-03, Steven D'Aprano schreef <[EMAIL PROTECTED]>:
>> On Thu, 03 Nov 2005 13:01:40 +, Antoon Pardon wrote:
>>
>>>> Seems perfectly sane to me.
>>>>
>>>> What
On Fri, 04 Nov 2005 10:48:54 +, Antoon Pardon wrote:
> Please explain why this is illegal.
>
> x = 1
> def f():
> x += 1
Because names in function namespaces don't have inheritance.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
w many times you already went through the loop",
I'm supposed to magically read your mind and know that you don't actually
object to what you say you object to, but to something completely
different?
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
efers to two different namespaces at the same time.
> That is IMO madness. You may argue that the madness is of little
> importance, you can argue that because of the current implementation
> little can be done about it. But I don't see how one can defend
> it as sane behaviour.
Because inheritance is useful, sensible, rational behaviour for OO
programming.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
ame.advance()
py> print steve_game.level
3
py> print antoon_game.level
What will it print?
Hint: your scheme means that class attributes mask instance attributes.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, 04 Nov 2005 04:42:54 -0800, Paul Rubin wrote:
> Steven D'Aprano <[EMAIL PROTECTED]> writes:
>> There are good usage cases for the current inheritance behaviour.
>
> Can you name one? Any code that relies on it seems extremely dangerous to me.
Dangerous? In
On Fri, 04 Nov 2005 18:20:56 -0500, Mike Meyer wrote:
> Steven D'Aprano <[EMAIL PROTECTED]> writes:
>> equal? Some things are a matter of objective fact: should CPython use a
>> byte-code compiler and virtual machine, or a 1970s style interpreter that
>> int
On Fri, 04 Nov 2005 16:06:45 -0800, Paul Rubin wrote:
> Steven D'Aprano <[EMAIL PROTECTED]> writes:
>> A basic usage case:
>>
>> class Paper:
>> size = A4
>> def __init__(self, contents):
>> # it makes no sense to have class conte
On Sat, 05 Nov 2005 00:25:34 +, Bengt Richter wrote:
> On Fri, 04 Nov 2005 02:59:35 +1100, Steven D'Aprano <[EMAIL PROTECTED]> wrote:
>
>>On Thu, 03 Nov 2005 14:13:13 +, Antoon Pardon wrote:
>>
>>> Fine, we have the code:
>>>
>>>
On Fri, 04 Nov 2005 20:55:48 -0500, Chris F.A. Johnson wrote:
So that people reading your reply know what you are commenting about.
(Now, imagine that you're reading from a newsgroup where Chris' post has
disappeared off the server, or perhaps never showed up at all.)
--
Steven.
On Fri, 04 Nov 2005 13:52:22 -0800, Paul Rubin wrote:
> Steven D'Aprano <[EMAIL PROTECTED]> writes:
>> Follow the logical implications of this proposed behaviour.
>>
>> class Game:
>> current_level = 1
>> # by default, games start at level one
esult in more
>> compact code? What usage cases?
>
> What my behaviour? I don't need to specify alternative behaviour in
> order to judge specific behaviour.
If you are serious about wanting the behaviour changed, and not just
whining, then somebody has to come up with an alternative behaviour that
is better. If not you, then who? Most of the folks who have commented on
this thread seem to like the existing behaviour.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, 04 Nov 2005 20:41:31 -0800, Paul Rubin wrote:
> Steven D'Aprano <[EMAIL PROTECTED]> writes:
>> It also allows you to do something like this:
>>
>> class ExpertGame(Game):
>> current_level = 100
>
>> and then use ExpertGame any
On Sat, 05 Nov 2005 04:12:38 -0500, Chris F.A. Johnson wrote:
> On 2005-11-05, Steven D'Aprano wrote:
>> On Fri, 04 Nov 2005 20:55:48 -0500, Chris F.A. Johnson wrote:
>>
>>
>>
>> So that people reading your reply know what you are commenting about.
>>
lly horrible German industrial industrial punk themed
desktops, you could do a lot worse than play around with the Knoppix
LiveCD. That would be the quickest way to get started: no installation
necessary.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
980...
> It also has nice, beginner-friendly FAQs to help you
> get started.
Just so you understand what Jeffrey is talking about, by
"beginner-friendly" he means the FAQs walk you through the process of
compiling your own kernel. (Okay, okay, so that's a *tiny* bi
e are jumping through to modify the
language so that b.a += 2 assigns b.a in the same scope as it was
accessed, I'm still rather perplexed as to why you would want that
behaviour. It seems to me like spending many hours building a wonderfully
polished, ornate, exquisite device for build
On Fri, 04 Nov 2005 22:19:39 -0800, Paul Rubin wrote:
> Steven D'Aprano <[EMAIL PROTECTED]> writes:
>> > Next you get some performance gain by using gmpy to handle the long int
>> > arithmetic,
>>
>> Then whatever happens next will be my own stup
On Sat, 05 Nov 2005 16:27:00 -0800, Paul Rubin wrote:
> Steven D'Aprano <[EMAIL PROTECTED]> writes:
>> But do you want x += y to work for immutable objects as well? Then
>> __iadd__ cannot be a statement, because x can't be modified in place.
>
> It never
ot;)
L.sort() # throws the sorted list away
print L # prints the unsorted list
The only way the Liskov substitution principle works is if everything
works the same way, which means that all subclasses, all *possible*
subclasses, must have no more functionality than the subclass that does
the absolute
x in range(2000):
> if x % 100 == 0:
> do_something()
Another way is, if you aren't doing anything *except* counting for the
other 99 values of x, just skip them completely:
fox x in range(20):
do_something(x*100)
Ivan, what are you trying to do?
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
erent from the dual referencing that happens in Scenario 4.
Okay, perhaps wart is not quite the right word... but it is certainly
unexpected if you haven't come across it before, or thought *deeply* about
what is going on. A gotcha perhaps.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
t; the same search today, you'll still find examples, but 5 of the top 10
> hits are references to Xah's problems with the library reference. A
> few more rounds, and people will have to start adding -xah to their
> Python searches to get quality results.)
People are link
On Sun, 06 Nov 2005 04:28:35 -0800, jmdeschamps wrote:
> This actually brings us back to the jest of F. previous post,
I didn't think it was very funny...
Unless you meant the *gist* of Fredrik's post.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
ield.value
locals().update({sectionname: obj})
If you are likely to be changing the constants (either
names, field names, or values) an hour or three
developing this code will save you a lot of heart-ache
later.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
ncerned about malicious users, or just
incompetent users?
I suspect your best bet might be to write a
mini-language using Python, and get your users to use
that. You will take a small performance hit, but
security will be very much improved.
What do others think?
--
Steven.
--
http://
;transversePlanes = [
> Plane(type=3, z=4),
> Plane(type=5, z=6),
> Plane(type=3, z=8)
> ]
> )
That's a little trickier, but not much. You effectively
are just creating a struct where some attributes are
themselves structs.
> which I'm not sure the
ers to create new
innovative solutions, when they can just use Google to
search teh Interweb for source code which Google has
stolen from the rightful owners???
*wink*
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
y = 1
is the same as the two liner
x = 1
y = x
Both create two names, x and y, and sets them both to the same int 1.
Because ints are immutable, if you rebind one name, the other one will
NOT change:
py> x += 1
py> print x, y
2, 1
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
> obj = lst[-3]
py> obj
4
py> obj = obj + 1 # rebinds the name obj, doesn't change the underlying
object the name points to
py> print lst
['Now is the time', 4, 'all good men', {'foo': 42}]
You will quickly learn what are mutable and what are immutable. Ints,
floats, longs, strs and tuples are immutable. Lists and dicts are mutable.
Custom classes could be either, in principle, but are generally mutable.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
the objects in place, you are rebinding the name to another
object:
py> spam = "a tasty meat-like food"
py> alias = spam # both names point to the same str object
py> spam = "spam spam spam spam" # rebinds name to new str object
py> print spam, alias
'spam spam spam spam' 'a tasty meat-like food'
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
James Stroud wrote:
> Hello All,
>
> I'm running 2.3.4
>
> I was reading the documentation for classes & types
>http://www.python.org/2.2.3/descrintro.html
> And stumbled on this paragraph:
>
> """
> __new__ must return an object. There's nothing that requires that it return a
> new obj
print "Now calling RList append"
something.append("hello world") # call append on a non-existent object
What should Python do? Should "something" be a RList, QList, PList or
ordinary list?
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
i want to do these steps
> using python , how can i do it??
Type ctrl-d to exit Python, then at the command prompt, type su ,
then type your root password.
Then, as root, type python at the command prompt.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
ou are coding in too, or only English?
[snip]
>> there are several applications that can do this.
>> in fact, the free version of the visual studio 2005, which is free, have
>> this ability.
Just out of curiosity, how much is the free version of Visual Studio 2005?
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
several applications that can do this.
>>>>in fact, the free version of the visual studio 2005, which is free, have
>>>>this ability.
>>
>>
>> Just out of curiosity, how much is the free version of Visual Studio 2005?
>>
>>
> I'm not positive, b
el
> inclied to "rip off the code", or in this case, rip out the code.
Which leads to the important counter-question. Since there is a Python
obfuscator, is there a Python un-obfuscator? I am aware that not all
obfuscations can be reversed, but some can.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
27;t want
the memory containing the plaintext to be swapped to your swap
partition, where raw disk tools can recover it.
But as a general rule, you're right. If you, the developer, don't have to
think of your users as the enemy, you'd be amazed the amount of make-work
you don't have to do.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
ans = raw_input("Is it %d? y/n " % guess)
if ans in ('y', 'yes'):
break
ans = raw_input("Too high? y/n ")
if ans in ("y", "yes"):
hi = guess-1
else:
lo = guess+1
This should run, and it will *almost* do what you want.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
On Thu, 10 Nov 2005 06:47:41 +, Donn Cave wrote:
> Quoth Steven D'Aprano <[EMAIL PROTECTED]>:
> ...
> | So when working with ints, strs or other immutable objects, you aren't
> | modifying the objects in place, you are rebinding the name to another
> | object:
&
On Wed, 09 Nov 2005 20:45:52 +0100, bruno at modulix wrote:
>> If the array does not exist yet, it's created.
>
> Which is what I don't like. It should crash.
Perhaps not *crash* as such. Raise an exception perhaps.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
Some objects can change their
value, and some objects can't.
But the best way to get an intuitive feel for how Python operates is to
start up an interactive session and just experiment!
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
itself has
costs, costs of time, space, complexity, bugs, lost opportunities,
customer dissatisfaction, and even legality.
Sony has just found that out: having been caught installing root-kits on
peoples computers, they are now being sued.
--
Steven.
--
http://mail.python.org/mailman/list
f course x += 1 can't change the int in place, it has to rebind x to a
new int.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
log2(100) > 5 your five guesses won't always be enough (though seven
> should be).
Dude, that's what my code does, although I admit I took zero care to get
the awkward boundary conditions right, nor did I put code in to stop the
game after five attempts.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
f you tell us what sort
of information you are after, we can suggest where you should be looking,
rather than just assume it is hidden in "internal variables".
BTW, since Python is open source software, you can download and read
through the entire code base if you wish.
--
Steven.
--
everse lexicographic order, which is the result you get.
I'm not running Python 2.4 so I can't test this, but to get the result you
want I guess you want this:
py> x.sort(key=len, reverse=True)
py> x
['aardvark', 'abalone', 'aerate', 'acme', 'add']
or:
py> x.sort(key=len)
py> x.reverse()
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
ically, a method) which will return x converted to upper case when
called.
So the list comprehension you want is:
# note all the brackets
py> L = [(lambda x: x.upper)(x) for x in ['a', 'b', 'c']]
py> L
[, , ]
py> L[0](); L[1](); L[2]()
'A'
laws are good for either innovation or the economy, and given
the absolute artificiality of treating ideas as if they were scarce goods,
I don't understand why the artificial monopoly rights of copyright holders
are allowed to trump the natural rights of copyright users.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
is to force a system of artificial
government-granted monopolies, together with all the proven economic
inefficiencies of such monopolies, on the developing world.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
, keep in mind
firstly that the source code is obfuscated, and secondly that I am not an
idiot, I will recognise my own code if you try to pass it off as yours."
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
, well, if you think you can a commercial advantage by annoying
your customers, knock yourselves out.
[1] By "everyone" I mean "lots of people who should know better".
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
product
away for free? Promotions, network effects, "the first sample is free",
driving your competitors out of business, try before you buy, software
which is paid for by advertising... there are many reasons why companies
might not just turn a blind eye to piracy but welcome it. The mistake is
to only think of piracy as lost revenue.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
whatever namespace you define
them in.
Personally, I think rather than adding a new language feature (...slim to
none...) there is more hope of getting something like this added to the
standard library:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/413486
--
Steven.
--
http://mail.p
t() returns a value: it returns None:
who_cares = L.sort()
# who_cares is now None; L is now sorted
Languages such as Pascal have procedures, which don't return a value, and
functions, which do. Python does not have procedures.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
you suggesting that the Python language designers should somehow
predict every possible symbol that anyone in the world might ever need,
and build them into the language as predefined things?
If that is not what you mean, can you explain please, because I'm confused.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
On Sun, 13 Nov 2005 12:33:48 +0100, Pierre Barbier de Reuille wrote:
> Steven D'Aprano a écrit :
>> On Sun, 13 Nov 2005 10:11:04 +0100, Pierre Barbier de Reuille wrote:
>>
>>
>>>The problem, IMHO, is that way you need to declare "symbols"
>>
On Mon, 14 Nov 2005 00:48:46 +1100, Ben Finney wrote:
> Steven D'Aprano <[EMAIL PROTECTED]> wrote:
>> On Sun, 13 Nov 2005 10:11:04 +0100, Pierre Barbier de Reuille wrote:
>> > The problem, IMHO, is that way you need to declare "symbols"
>> > b
n owned the copyright.
See http://www.cdbaby.net/articles/courtney_love.html for details of how
the major record labels, through their enforcement arm the RIAA, stole
rights from the creative artists that they claim to represent.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
so here's the implementation I
> decided upon.
[snip]
Seems good to me.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
f simple tests, then ran it again.
Same result. Unless I've made some stupid mistake, I
think this is the way to go.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
Replying to myself... the first sign of madness *wink*
Steven D'Aprano wrote:
> size = 1024*1024*20 # 20 MB
> original = "A" * size
> copy = [None] * size
> for i in range(size):
> copy[i] = original[i].lower()
> copy = ''.join(copy)
Do you not
quot;Create a new polygon with n sides."""
self.state = n
def grow_side(self):
self.state += 1
def lose_side(self):
self.state -= 1
Compare that with something like this:
class MutablePolygon:
"""Define a polygon object that
cos}
# easy to modify
table["sin"] = my_better_sine_function
result = table["sin"](0)
If I have missed a usage case, perhaps you should give
at specific example.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
gh, in fairness, if
you could cut the time to 0.04s for 20MB then it would
be worth the extra work to use the array module.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
izeof(obj)
(obviously there is no built-in function sizeof...
wait, let me check... nope, not a built-in)
I've read the docs for gc and pdb and nothing stands
out to me as doing anything like this.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
2
CM_TO_METRES = 100
# ...
myObject.value = RIGHT_THING
#... 100 lines of code elided...
if myObject.value = RIGHT_THING:
do_right_thing()
else:
do_wrong_thing()
It isn't always appropriate or necessary to define "constants" (and I
sometimes wish that Python would enforce assign-once names), but they can
help avoid some silly mistakes.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
le compares prefixes with "O" and then "Q", the second
looks to see if prefixes is a substring of "OQ". In this case, they will
both have the same effect.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
, you refer to a plain
_marker, but in the method code block, you need to qualify it.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
code in a
try...except block and catch the exception raised when a non-iterator is
passed as an argument.
Which exception is that? I leave that as an exercise for the reader.
(Hint: Just Do It and read the traceback Python prints.)
Actually, I think "Just Do It" might make a good motto for Python.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, 15 Nov 2005 11:26:23 -0800, py wrote:
> Dan Sommers wrote:
>> Just do it. If one of foo's callers passes in a non-iterable, foo will
>> raise an exception, and you'll catch it during testing
>
> That's exactly what I don't want. I don't want an exception, instead I
> want to check to se
software.
Very few professional (i.e. they get paid to program)
developers actually own the copyright on the programs
they write, and of those that do own the copyright,
even fewer make money directly from that copyright.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
; print i + 1
> except TypeError:
> print "can't add string and integer"
try:
for item in obj:
do_stuff(item)
except TypeError, msg:
if msg == "iteration over non-sequence":
handle_non_iterator()
else:
# re-raise the exception
raise
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
_getitem__(), classes that implement
next(), and probably more things that I have forgotten.
Your code doesn't check for any of those.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, 15 Nov 2005 21:54:07 -0500, Dan Sommers wrote:
> On Wed, 16 Nov 2005 13:12:38 +1100,
> Steven D'Aprano <[EMAIL PROTECTED]> wrote:
>
>> try:
>> for item in obj:
>> do_stuff(item)
>> except TypeError, msg:
&g
bject that has a magic meaning
(e.g. as a sentinel), don't tempt your users to try to use it as if it
were an ordinary object.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, 16 Nov 2005 09:48:47 +, Duncan Booth wrote:
> Steven D'Aprano wrote:
>> I would like to see _marker put inside the class' scope. That prevents
>> somebody from the outside scope easily passing _marker as an argument
>> to instance.f. It also neatly
On Tue, 15 Nov 2005 21:59:44 -0500, Roy Smith wrote:
> In article <[EMAIL PROTECTED]>,
> Steven D'Aprano <[EMAIL PROTECTED]> wrote:
>
>> try:
>> for item in obj:
>> do_stuff(item)
>> except TypeError, m
[EMAIL PROTECTED] wrote:
> so the following would not result in any conflicts
>
> class A:
>def __init__(self):
> self.__i= 0
>
> class B(A):
>def __init__(self):
> A.__init__(self)
> self.__i= 1
>
Be careful here. The above won't result in any conflicts, but related
ery
simple idioms being made even shorter in Python.
So perhaps there should be a list method that takes an integer argument
and appends that many empty lists:
d = []
d.append_empties(5)
Or even a function that does this:
def nested(numcopies, base=None, *args):
if base is None:
base = []
for i in range(numcopies):
base.append(args[:])
return base
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, 16 Nov 2005 13:51:35 +, Ed Jensen wrote:
> Steven D'Aprano <[EMAIL PROTECTED]> wrote:
>> I'm not sure if that is meant to be a rhetorical
>> question or not, but something of the order of 95% of
>> all software written is never distributed to oth
ver
non-sequence" to something else, the code should continue to work
correctly.
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
children are lost generations with respect to ethics, manners,
> and respect for authority, perhaps we can train our grandchildren to
> behave more proprely.
There is too much respect for so-called "authority", not too little.
Respect for authority is just another way of saying "Don't think for
yourself, do as you're told."
--
Steven.
--
http://mail.python.org/mailman/listinfo/python-list
4001 - 4100 of 15563 matches
Mail list logo