Duncan Booth [EMAIL PROTECTED] wrote:
I may have made some blindingly obvious beginners mistake
I made the blindingly stupid beginners mistake of cleaning up the code
before posting it and breaking it in the process. The 'if' should of
course say:
if len(sys.argv) 1:
However my original
as though it just embeds the entire font.
--
Duncan Booth http://kupuguy.blogspot.com
--
http://mail.python.org/mailman/listinfo/python-list
this may not do what you wanted.
--
Duncan Booth http://kupuguy.blogspot.com
--
http://mail.python.org/mailman/listinfo/python-list
)
Is this correct approach? How can avoid call to Base.A(...)?
Decorators are just syntactic sugar for calling a function, so for this
situation you probably want to ignore the sugar and use the decorator
directly:
class Derived(Base):
A = decorator(Base.A)
--
Duncan Booth http
else:
raise RuntimeError(We connected without doing the net use!)
NetUseAdd(None, sharename, password, username=username)
with open(os.path.join(sharename, default.tag), r) as f:
print f.read()
NetUseDel(sharename)
---
--
Duncan Booth http
Steven D'Aprano [EMAIL PROTECTED] wrote:
dict1.update(dict2) is of course equivalent to this code:
for key, value in dict2.iteritems():
dict1[key] = value
Note that it replaces values in dict1 with the value taken from dict2. I
don't know about other people, but I more often want to
Christoph Zwerschke [EMAIL PROTECTED] wrote:
That would be possible. But I still think it makes sense to separate
them, like so:
def foo(a: a info, b: b info) - ret info raise exc info:
return hello world
And then the annotation dictionary would contain another key raise
Christoph Zwerschke [EMAIL PROTECTED] wrote:
But maybe the PEP should then at least mention what's the currently
recommended way to make annotations about thrown exceptions.
There is no currently recommended way to make such annotations, so how
could the PEP mention it?
I think the problem
easily
fail:
lst = [1, 2, 3]
lst[1] = lst
eval(repr(lst))
Traceback (most recent call last):
File pyshell#6, line 1, in module
eval(repr(lst))
File string, line 1
[1, [...], 3]
^
SyntaxError: invalid syntax
--
Duncan Booth http://kupuguy.blogspot.com
--
http
)
if code in name2codepoint:
return unichr(name2codepoint[code])
return match.group(0)
if isinstance(s, str):
s = s.decode(encoding)
return EntityPattern.sub(unescape, s)
--
Duncan Booth http://kupuguy.blogspot.com
--
http://mail.python.org
this for you. What parser
are you using?
--
Duncan Booth http://kupuguy.blogspot.com
--
http://mail.python.org/mailman/listinfo/python-list
or Mac, I have no idea.
One way on windows:
import win32pdhutil
def howmanycores():
for i in range():
try: win32pdhutil.GetPerformanceAttributes(Processor(%d) % i,%
Processor Time)
except: break
return i
print howmanycores()
2
--
Duncan Booth http
MIPS Linux
HPPA Linux
(from http://www.mono-project.com/Supported_Platforms)
So I'd say .Net scores pretty highly on the portability stakes. (Although
of course code written for .Net might not do so well).
--
Duncan Booth http://kupuguy.blogspot.com
--
http://mail.python.org/mailman/listinfo
thing.
--
Duncan Booth http://kupuguy.blogspot.com
--
http://mail.python.org/mailman/listinfo/python-list
topics are covered. The tutorial explains both modules and
packages: http://docs.python.org/tut/node8.html
What it doesn't cover is that you can import modules or packages directly
from a zip file.
Then read about eggs.
--
Duncan Booth http://kupuguy.blogspot.com
--
http://mail.python.org
Robert Rawlins [EMAIL PROTECTED] wrote:
I've just recently (in the past week) started using the __del__ method
to log class instance destruction so I can keep a track of when
objects are created and destroyed, in order to help me trace and fix
memory leaks.
That sounds like an appropriate
Robert Rawlins [EMAIL PROTECTED] wrote:
I like this idea, I can definitely see the benefits to working with
this concept. One things I will take this quick opportunity to ask,
even though it's a little OT:
What is the benefit of extending the base 'object' class? What does
that give me that
Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote:
On Sat, 19 Jul 2008 11:02:51 -0500, Grant Edwards wrote:
On 2008-07-19, Dennis Lee Bieber [EMAIL PROTECTED] wrote:
Which term applied to the TRS-80, the Apple II, Altair even...
Not that I remember. I had a homebrew S-100 bus system,
Berco Beute [EMAIL PROTECTED] wrote:
I remember reading somewhere how to create an instance attribute for
every method argument, but although Google is my friend, I can't seem
to find it. This could likely be done way more elegant:
=
class Test(object):
def
mk [EMAIL PROTECTED] wrote:
Iterating over a copy may _probably_ work:
t=['a', 'c', 'b', 'd']
for el in t[:]:
del t[t.index(el)]
t
[]
However, is it really safe? Defining safe as works reliably in every
corner case for every indexable data type?
No, because you
[EMAIL PROTECTED] wrote:
I wish to decorate all of the CX.func() in the same way. One way to
do this is to add a decorator to each of the derived classes. But
this is tedious and involves modifying multiple files.
Is there a way to modify the parent class and have the same effect?
Or
kj [EMAIL PROTECTED] wrote:
I still don't get it. If we write
y = 'Y'
x, = y
what's the difference now between x and y? And if there's no
difference, what's the point of performing such unpacking?
None whatsoever when the string has only one character, but with 2
characters it
Giampaolo Rodola' [EMAIL PROTECTED] wrote:
Having said that I'd like to understand if there are cases where
deleting or moving an element of the heap, causes heappop() to return
an element which is not the smallest one.
Yes, of course there are: any time you delete element 0 of the heap you
Giampaolo Rodola' [EMAIL PROTECTED] wrote:
Thanks, that's what I wanted to know.
I understand that heapq is not that efficient to implement timeouts as
I thought at first.
It would have been perfect if there were functions to remove arbitrary
elements withouth needing to re-heapify() the
Christoph Zwerschke [EMAIL PROTECTED] wrote:
Duncan Booth schrieb:
if url.startswith('http://'):
url = url[7:]
If I came across this code I'd want to know why they weren't using
urlparse.urlsplit()...
Right, such code can have a smell since in the case of urls, file names
ssecorp [EMAIL PROTECTED] wrote:
1. Why do I have to pass self into every method in a class? Since I am
always doing why cant this be automated or abstracted away?
Are the instances where I won't pass self?
I imagine there is some tradeoff involved otherwise it would have been
done away
Giampaolo Rodola' [EMAIL PROTECTED] wrote:
My question is the following: is it safe to avoid to re-heapify() a
heap when I remove or move an element which is not the first one?
Example:
from heapq import *
heap = [2,4,6,7,1,2,3]
heapify(heap)
del heap[4]
# Am I forced to heapify() the
Christoph Zwerschke [EMAIL PROTECTED] wrote:
In Python programs, you will quite frequently find code like the
following for removing a certain prefix from a string:
if url.startswith('http://'):
url = url[7:]
If I came across this code I'd want to know why they weren't using
Michiel Overtoom [EMAIL PROTECTED] wrote:
I occasionally have a need for printing lists of items too, but in the
form: Butter, Cheese, Nuts and Bolts. The last separator is the
word 'and' instead of the comma. The clearest I could come up with in
Python is below. I wonder if there is a more
Julien [EMAIL PROTECTED] wrote:
In Windows, when a path has been normalized with os.path.normpath, you
get something like this:
C:/temp/my_dir/bla.txt # With forward slashes instead or backward
slashes.
Is it possible to revert that?
magic_function('C:/temp/my_dir/bla.txt')
Ampedesign [EMAIL PROTECTED] wrote:
I'm trying to build a try/except case, and I want to have the except
function like such:
try:
# Do some code here
var = 1 # For example
except:
#Do nothing here
The only problem is if I leave a comment only in the except
zowtar [EMAIL PROTECTED] wrote:
urlencode({'page': i, 'order': 'desc', 'style': 'flex power'})
return:
page=1order=descstyle=flex+power
but I want:
page=1order=descstyle=flex%20power
and url.quote don't put the 's and ='s
any idea guys?
Why does it matter to you? The + means exactly
Alex G [EMAIL PROTECTED] wrote:
Does anyone know how I would go about conditionally raising an
exception in a decorator (or any returned function for that matter)?
For example:
def decorator(arg):
def raise_exception(fn):
raise Exception
return raise_exception
class
Alex G [EMAIL PROTECTED] wrote:
class classA(object):
@decorator('argument')
def some_method(self):
print An exception should be raised when I'm called, but not
when I'm defined
Will result in an exception on definition.
Well, yes it would. That's because what you defined
allowing debugging in context.
http://github.com/tablatom/rubydoctest/wikis/special-directives
Whereas Python has the more wordy version which works anywhere in ordinary
code or in doctests:
import pdb; pdb.set_trace()
--
Duncan Booth http://kupuguy.blogspot.com
--
http://mail.python.org
-0.5
C:\python25\python -Qwarn -c print -1/2
-c:1: DeprecationWarning: classic int division
-1
--
Duncan Booth http://kupuguy.blogspot.com
--
http://mail.python.org/mailman/listinfo/python-list
with that really neat pow() call. If runtime came into it then one of the
previous solutions or (as Mark already said) a straightforward sometable[i%
15] is going beat something like this hands-down.
This is coding for fun not profit.
--
Duncan Booth http://kupuguy.blogspot.com
--
http://mail.python.org
used utf-8, so string.decode('utf-8') should
give you a unicode string to work with.
--
Duncan Booth http://kupuguy.blogspot.com
--
http://mail.python.org/mailman/listinfo/python-list
).
If you wish to do something special when an import fails then you simply
put try:..except: around the import at the top level in a module and
handle it there: you don't need to put either the import or the handler
inside a function.
--
Duncan Booth http://kupuguy.blogspot.com
--
http
into a
script rather than running it interactively (the string '--' will be re-
used within a single compilation unit). So even if you understand all of
the choices made in your particular release of Python (and they do vary
between releases) it would be very unwise to rely on this behaviour.
--
Duncan
have 4 elements:
[[str(i), 'FizzBuzz', 'Fizz', 'Buzz'][25/(pow(i, 4, 15) + 1)%4] for i in
xrange(1, 101)]
I feel it is even more elegant with the lookup table in its natural order:
[['Fizz', 'Buzz', 'FizzBuzz', str(i)][62/(pow(i, 4, 15) + 1)%4] for i in
xrange(1, 101)]
:)
--
Duncan Booth
):
keys = range(N)
m1 = memory()
print m1
d = {}
for i in keys:
d[i] = None
m2 = memory()
print m2
print float((m2 - m1) * 1024) / N
main(2000)
--
Duncan Booth http://kupuguy.blogspot.com
--
http://mail.python.org/mailman/listinfo/python-list
\u000d\u000aWorld
print s
Hello\u000d\u000aWorld
s.decode('iso-8859-1').decode('unicode-escape')
u'Hello\r\nWorld'
--
Duncan Booth http://kupuguy.blogspot.com
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] wrote:
I downloaded BeautifulSoup.py from
http://www.crummy.com/software/BeautifulSoup/ and being a n00bie, I
just placed it in my Windows c:\python25\lib\ file. When I type
import beautifulsoup from the interactive prompt it works like a
charm. This seemed too easy in
Leo Jay [EMAIL PROTECTED] wrote:
same objects are equal, but equal don't have to be the same object.
same objects are often equal, but not always:
inf = 2e200*2e200
ind = inf/inf
ind==ind
False
ind is ind
True
--
Duncan Booth http://kupuguy.blogspot.com
--
http://mail.python.org/mailman
'
type.__class__
type 'type'
Old style classes don't have a class attribute, but you shouldn't be using
old style classes anyway and so long as you use
type(x)
to access its class rather than accessing the __class__ attribute directly
that doesn't particularly matter.
--
Duncan Booth http
cannot subclass
'object'.
--
Duncan Booth http://kupuguy.blogspot.com
--
http://mail.python.org/mailman/listinfo/python-list
):
print k, list(v)
1 ['a', 'e']
2 ['c']
3 ['b', 'd']
4 ['f']
or if you want a dictionary:
dict((k,list(v)) for (k,v) in
itertools.groupby(sorted(d, key=get), key=get))
{1: ['a', 'e'], 2: ['c'], 3: ['b', 'd'], 4: ['f']}
--
Duncan Booth http://kupuguy.blogspot.com
--
http
the \\ will prevent any of them being interpreted as
special so if you aren't wanting to substitute any groups into the string
just try repl.replace('\\', r'\\')
--
Duncan Booth http://kupuguy.blogspot.com
--
http://mail.python.org/mailman/listinfo/python-list
all and then fix up the result:
text = r'frob this avoid this \, OK?'
text.replace('', r'\').replace(r'\\', r'\')
'frob this \\ avoid this \\, OK?'
--
Duncan Booth http://kupuguy.blogspot.com
--
http://mail.python.org/mailman/listinfo/python-list
this in linux or how to reduce
Python programs memory usage.
Perhaps http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/303339
--
Duncan Booth http://kupuguy.blogspot.com
--
http://mail.python.org/mailman/listinfo/python-list
Alexnb [EMAIL PROTECTED] wrote:
path = self.e.get()
path = \ + path + \
os.startfile(path)
Why are you adding spurious quote marks round the filename? os.startfile()
will strip them off, but you don't need them. The help for os.startfile()
does say though that the
[EMAIL PROTECTED] wrote:
In xp when I try os.path.getmtime(%userprofile/dir/file%) Python
bites back with cannot find the path specified Since my script has
to run on machines where the username is unspecified I need a fix.
Thanks in advance.
os.path.expanduser(~/dir/file)
'C:\\Documents
')
['', 'frodo', 'foo', 'bar']
With your code you just get two empty strings as the leadin:
normpath(abspath(r'\\frodo\foo\bar')).split(os.sep)
['', '', 'frodo', 'foo', 'bar']
--
Duncan Booth http://kupuguy.blogspot.com
--
http://mail.python.org/mailman/listinfo/python-list
Lie [EMAIL PROTECTED] wrote:
On Jun 8, 7:27 am, Terry Reedy [EMAIL PROTECTED] wrote:
Karlo Lozovina [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
| I figured that out few minutes ago, such a newbie mistake :). The
| fix I came up with is:
|
| result = ['something'] +
the design of the code. I felt the room go cold:
they said the customer has to sign off the design before we start coding,
and once they've signed it off we can't change anything.
I wish I'd had your words then.
--
Duncan Booth http://kupuguy.blogspot.com
--
http://mail.python.org/mailman
Arnaud Delobelle [EMAIL PROTECTED] wrote:
I find that eloquent Python speakers often tend to write a for loop
when mere good ones will try to stick a list comprehension in!
+1 QOTW
--
Duncan Booth http://kupuguy.blogspot.com
--
http://mail.python.org/mailman/listinfo/python-list
for 'hiding' then just use two
leading underscores.
--
Duncan Booth http://kupuguy.blogspot.com
--
http://mail.python.org/mailman/listinfo/python-list
general case, you could just use the functions/methods directly
instead of using their names:
actions = (cp.Print, cp.sum, cp.divide, cp.myfunction)
for nn in actions:
nn(parameters)
--
Duncan Booth http://kupuguy.blogspot.com
--
http://mail.python.org/mailman/listinfo/python-list
understand your problem: it's just a single thread so killfile or
skip it.
--
Duncan Booth http://kupuguy.blogspot.com
--
http://mail.python.org/mailman/listinfo/python-list
Poppy [EMAIL PROTECTED] wrote:
a = ',P,'
b = ',I,G,AQ,ET,K,BF,'
c = ',DZ,'
for ea in (a,b,c):
print lst_codes(ea.strip(,))
Why not just use:
ea.strip(',').split(',')
?
--
Duncan Booth http://kupuguy.blogspot.com
--
http://mail.python.org/mailman/listinfo/python-list
to get caught by some other handler that was installed
just because someone was too lazy to write a set statement followed by a
writeline.
--
Duncan Booth http://kupuguy.blogspot.com
--
http://mail.python.org/mailman/listinfo/python-list
Dan Upton [EMAIL PROTECTED] wrote:
On Thu, May 29, 2008 at 3:36 AM, Duncan Booth
[EMAIL PROTECTED] wrote:
Dave Parker [EMAIL PROTECTED] wrote:
Catch doesn't return just error types or numbers, it can return any
object returned by the statements that are being caught; catch
doesn't care what
. That
means a bare except in Python no longer catches either of those: if you
want to handle either of these exceptions you have to be explicit about it.
--
Duncan Booth http://kupuguy.blogspot.com
--
http://mail.python.org/mailman/listinfo/python-list
Gabriel Genellina [EMAIL PROTECTED] wrote:
En Thu, 22 May 2008 07:55:44 -0300, Duncan Booth
[EMAIL PROTECTED] escribió:
Bruno Desthuilliers [EMAIL PROTECTED]
wrote:
Not to say that your concerns are pointless, and that things cannot
be improved somehow, but this is not that trivial
[EMAIL PROTECTED] wrote:
Ben Finney:
In Python, the philosophy we're all consenting adults here applies.
Michael Foord:
They will use whatever they find, whether it is the best way to
achieve a goal or not. Once they start using it they will expect us to
maintain it - and us telling them
David [EMAIL PROTECTED] wrote:
Problem 2: Slows down prototyping
In order to get a new system working, it's nice to be able to throw
together a set of modules quickly, and if that doesn't work, scrap it
and try something else. There's a rule (forget where) that your first
system will
David [EMAIL PROTECTED] wrote:
So, at what point do you start writing unit tests? Do you decide:
Version 1 I am going to definitely throw away and not put it into
production, but version 2 will definitely go into production, so I
will start it with TDD?.
If you are going to prototype
, rationals, intervals and strings (and real
numbers if you pay real money for them).
Maybe I'm missing something though, because I don't see how you can do
anything useful with out at least some sort of arrays (unless you are
supposed to store numbers in long strings).
--
Duncan Booth http
-php.html
--
Duncan Booth http://kupuguy.blogspot.com
--
http://mail.python.org/mailman/listinfo/python-list
Michael Fesser [EMAIL PROTECTED] wrote:
.oO(Duncan Booth)
On those rare occasions when I've helped someone who wanted advice
I've found that my Python oriented viewpoint can be quite hard to
translate to PHP. For example I'd suggest 'oh you just encode that as
utf8' only to be told
bukzor [EMAIL PROTECTED] wrote:
On May 21, 4:33 pm, Karlo Lozovina [EMAIL PROTECTED] wrote:
André [EMAIL PROTECTED] wrote
innews:a9913f2d-0c1a-4492-bf58-5c7
[EMAIL PROTECTED]:
How about something like the following (untested)
done = False
while not done:
try:
of the read. That implies that any unchecked
errors will go undetected. Ick.
--
Duncan Booth http://kupuguy.blogspot.com
--
http://mail.python.org/mailman/listinfo/python-list
numbers for each class.
That way any classname displayed would be based on the actual source
nesting and even static methods or functions injected from another class
would work 'correctly' (at some level).
--
Duncan Booth http://kupuguy.blogspot.com
--
http://mail.python.org/mailman/listinfo/python
is broken. If you want to be
able to test identity on strings safely then use the 'intern()' builtin to
get repeatable behaviour.
--
Duncan Booth http://kupuguy.blogspot.com
--
http://mail.python.org/mailman/listinfo/python-list
to make sure that page requests are as
efficient as possible.
In return you get an application which should scale well. There is nothing
Python specific about the techniques, it is just that Python is the first
(and so far only) language supported on the platform.
--
Duncan Booth http
is targetted at .Net. That compiles to a
bytecode known as MSIL which is then interpreted and/or JIT compiled to
machine code.
--
Duncan Booth http://kupuguy.blogspot.com
--
http://mail.python.org/mailman/listinfo/python-list
and the caller would need to be careful to call the correct one. So we end
up with functions from_keys_Foo_or_Baz(cls) and from_keys_Bar() which is an
unmaintainable mess.
--
Duncan Booth http://kupuguy.blogspot.com
--
http://mail.python.org/mailman/listinfo/python-list
Sanoski [EMAIL PROTECTED] wrote:
What would you guys says about this secret code? The key was
apparently lost. The guy never sent it, and he was never seen again.
It must stand for letters in the alphabet, but it almost looks like
trajectory tables. I don't know. What do you guys think?
_winreg.QueryValue(_winreg.HKEY_CLASSES_ROOT,
'FirefoxURL\shell\open\command')
and of course it throws an exception if firefox isn't installed.
Then just replace %1 with the url to get the actual command you need.
--
Duncan Booth http://kupuguy.blogspot.com
--
http://mail.python.org/mailman
be done. I guess it is achievable.
Thank you.
vars()[foo]
but if you are doing this you are almost certainly making your life harder
than it needs to be. Usually you really just want to keep the values in a
dict.
--
Duncan Booth http://kupuguy.blogspot.com
--
http://mail.python.org
hdante [EMAIL PROTECTED] wrote:
How can I access Usenet without using Google Groups ? (my ISP doesn't
have a NNTP server). Do you recommend doing so ?
Yes, even those ISP's who do have a news server often seem to make a mess
of maintaining it. I use news.individual.net which seems to do a
Nikhil [EMAIL PROTECTED] wrote:
Then why to have __len__() internal method at all when the built-in
len() is faster?
Because the internal method is used internally.
The idea is that you define __len__() on your objects when appropriate. You
are not expected to ever call it.
--
bc90021 [EMAIL PROTECTED] wrote:
On Sun, 11 May 2008 19:55:31 +, Duncan Booth wrote:
7stud [EMAIL PROTECTED] wrote:
              tempfileName =
\proctemp\\ Â Â Â Â Â Â Â Â Â Â Â Â Â Â +
self.matrix[c][0] + _other.txt\
It wouldn't
Dennis Lee Bieber [EMAIL PROTECTED] wrote:
The sloppy use of single quote for the apostrophe is unfortunate
G
True, but that problem is outside of the Python community's control. Given
that people do often refer to single quote when they mean apostrophe the
error message should be written
Ivan Illarionov [EMAIL PROTECTED] wrote:
is there a better way than my solution? is mine ok?
['%s%s' % (not i%3 and 'Fizz' or '', not i%5 and 'Buzz' or '')
or str(i) for i in xrange(1, 101)]
-- Ivan
or, more correctly, if you actually need to print:
[EMAIL PROTECTED] wrote:
There's a thing that bugs me in Python. Look at this...
print Testing\
SyntaxError: EOL while scanning single-quoted string
Please focus on the part of the error message that states while
scanning single-quoted string. How can Python claim it scanned a
bc90021 [EMAIL PROTECTED] wrote:
The error message was at the top of the thread (am I incapable of
posting it, or are you incapable of following a thread?), but here it
is again:
IOError: [Errno 2] no such file u'tempfileName'
So which was it? At the top of the thread you said it was:
7stud [EMAIL PROTECTED] wrote:
tempfileName = \proctemp\\ +
self.matrix[c][0] + _other.txt\
It wouldn't exactly result in either of the error messages you posted, but
I expect the spurious quote marks round the filename will
[EMAIL PROTECTED] wrote:
Indeed, there are many ways this could be done. Some are more
concise, some are more efficient. As I said, I did it the way I did
it to try out lambdas. Your way achieves the result, rather elegantly
I think, but teaches me nothing about using lambdas.
Lucas Prado Melo [EMAIL PROTECTED] wrote:
Hello,
How could I prove to someone that python accepts this syntax using
the documentation (I couldn't find it anywhere):
classname.functionname(objectname)
Language reference, mostly section 5.3 Primaries
call ::=
primary (
dmitrey [EMAIL PROTECTED] wrote:
On 9 ôÒÁ, 13:17, Paul Hankin [EMAIL PROTECTED] wrote:
On May 9, 11:04am, dmitrey [EMAIL PROTECTED] wrote:
list1 = ['elem0', 'elem1', 'elem2', 'elem3', 'elem4', 'elem5']
and
list2 = [0, 2, 4] # integer elements
howto (I mean most simple recipe, of
Viktor [EMAIL PROTECTED] wrote:
Can somebody give me an explanation what happened here (or point me to
some docs)?
Code:
HMMM = None
def w(fn):
print 'fn:', id(fn)
HMMM = fn
print 'HMMM:', id(HMMM)
def wrapper(*v, **kw):
fn(*v, **kw)
wrapper.i = fn
Terry Reedy [EMAIL PROTECTED] wrote:
Szabolcs Horvát [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
| Gabriel Genellina wrote:
|
| Python doesn't require __add__ to be associative, so this should
| not be
used as a general sum replacement.
|
| It does not _require_ this, but
Arnaud Delobelle [EMAIL PROTECTED] wrote:
George Sakkis wrote:
One of the few Python constructs that feels less elegant than
necessary to me is the del statement. For one thing, it is overloaded
to mean three different things:
(1) del x: Remove x from the current namespace
(2) del x[i]:
[EMAIL PROTECTED] wrote:
Here is a simple lambda that implements an exclusive or:
def XOR(x,y) :
return lambda : ( ( x ) and not ( y ) ) or ( not ( x ) and ( y )
)
(Because of the resemblance to C macros, I have been cautious and
written the lambda with lots of parentheses.)
To use
Arnaud Delobelle [EMAIL PROTECTED] wrote:
Duncan Booth wrote:
Arnaud Delobelle [EMAIL PROTECTED] wrote:
George Sakkis wrote:
One of the few Python constructs that feels less elegant than
necessary to me is the del statement. For one thing, it is
overloaded
to mean three
Martin Sand Christensen [EMAIL PROTECTED] wrote:
Now to the main point. When a generator function is run, it
immediately
returns a generator, and it does not run any code inside the
generator.
Not until generator.next() is called is any code inside the generator
executed, giving it
Martin Sand Christensen [EMAIL PROTECTED] wrote:
Duncan == Duncan Booth [EMAIL PROTECTED] writes:
[...]
Duncan Now try:
Duncan
Duncanfor command in getCommandsFromUser():
Duncanprint the result of that command was,
execute(command) Duncan
Duncan where getCommandsFromUser
Marco Mariani [EMAIL PROTECTED] wrote:
Duncan Booth wrote:
It does this:
@greedy
def getCommandsFromUser():
while True:
yield raw_input('Command?')
for cmd in getCommandsFromUser():
print that was command, cmd
Command?hello
Command?goodbye
501 - 600 of 1755 matches
Mail list logo