[issue18642] enhancement for operator 'assert'

2013-08-04 Thread Mark Dickinson
Mark Dickinson added the comment: Okay, I'm closing this for now. Al Korgun and mrDoctorWho0 .: if you think this idea deserves wider discussion, you should feel free to bring it up again on the python-ideas mailing list; that's a better forum to discuss these sorts of language changes anywa

[issue18642] enhancement for operator 'assert'

2013-08-03 Thread R. David Murray
R. David Murray added the comment: If your code is catching an exception generated by an assert statement, your code is using assert incorrectly. There is never any reason, as far as I can see, to catch an assert outside of a testing framework, and in a testing framework you definitely want t

[issue18642] enhancement for operator 'assert'

2013-08-03 Thread mrDoctorWho0 .
mrDoctorWho0 . added the comment: Assert with this feature will make code simplest. Simplification isn't python way? Why don't add it in python? It's must be really useful. Sometimes its necessary, when need to catch specified exception. Its easier to search errors by type, not by error body

[issue18642] enhancement for operator 'assert'

2013-08-03 Thread Al Korgun
Al Korgun added the comment: Mark Dickinson, sorry, didn't answer the first questiuon. >> In your original message, is it your intention that the assert raises >> TypeError, or that it raises AssertionError? I suggest to add the ability to raise relevant (for specific part of code) exception

[issue18642] enhancement for operator 'assert'

2013-08-03 Thread Al Korgun
Al Korgun added the comment: Mark Dickinson, #1 if dedug (and type check, respectively, as in this example, and 'raise') isn't needed we just need pyo >> Python won't execute those asserts at all that is convenient. if not isinstance(data, basestring): raise TypeError(...) - here we need a

[issue18642] enhancement for operator 'assert'

2013-08-03 Thread R. David Murray
R. David Murray added the comment: I think it would be confusing for assert to raise anything other than an AssertionError, so I also think this should be rejected. It might be interesting for there to be a way to call unittest's assert methods in a debug context (that is, without having to ha

[issue18642] enhancement for operator 'assert'

2013-08-03 Thread Mark Dickinson
Mark Dickinson added the comment: Ah, so I think I don't understand the proposal. In your original message, is it your intention that the assert raises TypeError, or that it raises AssertionError? Again: what's the benefit over existing solutions? Either: if not isinstance(data, bases

[issue18642] enhancement for operator 'assert'

2013-08-03 Thread Al Korgun
Al Korgun added the comment: Mark Dickinson, and I just think it might be useful in debug. PYO is another story. -- ___ Python tracker ___ __

[issue18642] enhancement for operator 'assert'

2013-08-03 Thread Mark Dickinson
Mark Dickinson added the comment: What's wrong with: if not isinstance(data, basestring): raise TypeError(...) ? In any case, you appear to be wanting to use assert to check user input. That's not its intended use; instead, it's there for making debugging assertions. Bear in mind that

[issue18642] enhancement for operator 'assert'

2013-08-03 Thread Al Korgun
New submission from Al Korgun: It would be pretty good, if 'assert' could raise specified exception, like that: >>> data = None >>> assert isinstance(data, basestring), TypeError("'data' must be a string") AssertionErrorTypeError: 'data' must be a string -- components: Interpreter Core