Am 11.11.2012 23:24, schrieb Cantabile:
I'm writing a small mail library for my own use, and at the time I'm
testing parameters like this:
Let's ignore the facts that there is an existing mail library, that you
should use real parameters if they are required and that exit() is
completely
Just a few tricks you may have missed:
On 12 November 2012 10:48, Ulrich Eckhardt
ulrich.eckha...@dominolaser.comwrote:
Am 11.11.2012 23:24, schrieb Cantabile:
if required.intersection(params.**keys()) != required:
if required.issubset(params):
missing = required -
On 12 November 2012 13:23, Joshua Landau joshua.landau...@gmail.com wrote:
Just a few tricks you may have missed:
On 12 November 2012 10:48, Ulrich Eckhardt
ulrich.eckha...@dominolaser.com wrote:
Am 11.11.2012 23:24, schrieb Cantabile:
if required.intersection(params.**keys()) !=
Wow, lots of things I had never heard of in your posts.
I guess I need to do some homework...
Cantabile
--
http://mail.python.org/mailman/listinfo/python-list
Hi,
I'm writing a small mail library for my own use, and at the time I'm
testing parameters like this:
class Mail(object):
def __init__(self, smtp, login, **params)
blah
blah
required = ['Subject', 'From', 'To', 'msg']
for i in required:
if not i
On Sun, Nov 11, 2012 at 3:24 PM, Cantabile cantabile...@wanadoo.fr wrote:
I'd like to do something like that instead of the 'for' loop in __init__:
assert[key for key in required if key in params.keys()]
A list evaluates as true if it is not empty. As long as at least one
of the required
assert[key for key in required if key in params.keys()]
...
Could you explain why it doesn't work and do you have any idea of how it
could work ?
Well, here, if any of the items are found, you get a list that is
non-False'ish, so the assert passes.
It sounds like you want all() (available as
On Sun, 11 Nov 2012 23:24:14 +0100, Cantabile wrote:
Hi,
I'm writing a small mail library for my own use, and at the time I'm
testing parameters like this:
class Mail(object):
def __init__(self, smtp, login, **params)
blah
blah
required = ['Subject',
On 11/11/2012 5:56 PM, Ian Kelly wrote:
On Sun, Nov 11, 2012 at 3:24 PM, Cantabile cantabile...@wanadoo.fr wrote:
I'd like to do something like that instead of the 'for' loop in __init__:
assert[key for key in required if key in params.keys()]
A list evaluates as true if it is not empty. As
On Sun, 11 Nov 2012 18:37:05 -0500, Terry Reedy wrote:
or if you want them to be identified by keyword only (since 7 positional
args is a bit much)
def __init__(self, smtp, login, *, subject, from, to, msg):
(I forget when this feature was added)
It's a Python 3 feature.
--
Steven
--
Thanks everyone for your answers. That's much clearer now.
I see that I was somehow fighting python instead of using it. Lesson
learned (for the time being at least) :)
I'll probably get back with more questions...
Cheers,
Cantabile
--
http://mail.python.org/mailman/listinfo/python-list
On 11/11/12 17:18, Steven D'Aprano wrote:
but that leaves you with the next two problems:
2) Fixing the assert still leaves you with the wrong exception. You
wouldn't raise a ZeroDivisionError, or a UnicodeDecodeError, or an IOError
would you? No of course not. So why are you suggesting
On Sun, 11 Nov 2012 18:21:32 -0600, Tim Chase wrote:
On 11/11/12 17:18, Steven D'Aprano wrote:
but that leaves you with the next two problems:
2) Fixing the assert still leaves you with the wrong exception. You
wouldn't raise a ZeroDivisionError, or a UnicodeDecodeError, or an
IOError
13 matches
Mail list logo