PEAK is the "Python Enterprise Application Kit". If you develop "enterprise" applications with Python, or indeed almost any sort of application with Python, PEAK may help you do it faster, easier, on a larger scale, and with fewer defects than ever before. The key is component-based development, on a reliable infrastructure.
>>4
Yes, let's see if it's "fucking ugly" or not, Javafag. I've used common Python conventions for a full Pythonic effect.
errors = []
if not LuhnCheck(ccard.number) and ValidateCCNum(ccard.type, ccard.number):
errors += ['Invalid credit card number']
if not ValidExpDate(ccard.date):
errors += ['Invalid expiry date']
return ', '.join(errors)
As for you, lol @ Javafag, lol @ Hungarian, lol @ stupid getters, lol @ unnecessary and completely pointless parens such as the first pair (not sure about the language?), lol @ hackish logic, lol @ readability (or lach thereof), lol @ maintainability (what if you want to add 4 more possible errors?), lol @ ENTERPRISE.
Name:
Anonymous2007-09-28 9:03 ID:vGk48urQ
Alternate option if you want to do it in such a hackish way, but a single expression to return and no extra variables required:
return ','.join(
['Invalid credit card number'] if LuhnCheck(ccard.number) and ValidateCCNum(ccard.type, ccard.number) else []
+ ['Invalid expiry date'] if ValidExpDate(ccard.date) else []
)
This version is beautifully maintainable as well.
Name:
Anonymous2007-09-28 9:06 ID:370per+r
>>4
This is probably not ENTERPRISE enough, for I haven't tried out PEAK yet.
>>7
return ', '.join(err for val, err in [
(luhn_check(card.number) and validate_ccnum(card.type, card.number), 'Invalid Credit Card Number'),
(validate_exp_date(card.date), 'Invalid Expiry Date')
] if not val)
Name:
Anonymous2007-09-28 13:23 ID:65u+6JmJ
# Trust user input was correct
return ''
Name:
Anonymous2007-09-28 13:32 ID:370per+r
>>9 Let's stuff everything in one expression because we can. Who cares about readability anyway?
Fix'd.
That was the exact form I started with. >>7 is the second iteration.