On Sat, May 12, 2012 at 2:11 PM, Devin Jeanpierre
wrote:
> I'm not talking about unexpected exceptions. I'm saying, if I expect
> invalid input for int, where should I go to find out how to deal with
> said invalid input properly? How do I know that int raises ValueError
> on failure, and not, for
On Fri, May 11, 2012 at 11:21 PM, Chris Angelico wrote:
> There are times when you want to catch all exceptions, though.
> Top-level code will often want to replace exception tracebacks with
> error messages appropriate to some external caller, or possibly log
> the exception and return to some pr
On Sat, May 12, 2012 at 5:34 AM, Devin Jeanpierre
wrote:
> On Fri, May 11, 2012 at 2:10 AM, Chris Angelico wrote:
>> Unlike in Java, a function's list of things it can throw isn't part of
>> its signature. Instead of trying to catch every possible exception,
>> it's generally best to simply let e
On 11May2012 15:40, Mark Lawrence wrote:
| On 11/05/2012 15:32, Andreas Tawn wrote:
| > It's also helpful to not have to display every attribute, of which there
may be dozens.
|
| Do I detect a code smell here?
Not necessarily. (Well, yeah, "dozens" may indicate time to partition
stuff.) My "O"
On Fri, May 11, 2012 at 2:10 AM, Chris Angelico wrote:
> Unlike in Java, a function's list of things it can throw isn't part of
> its signature. Instead of trying to catch every possible exception,
> it's generally best to simply let exceptions propagate unless you KNOW
> you're expecting them.
H
Thank you all for your help.
Greatly appreciated.
John
--
http://mail.python.org/mailman/listinfo/python-list
Emile van Sebille wrote:
On 5/11/2012 9:41 AM Ethan Furman said...
Style question:
Since __all__ (if defined) is the public API, if I am using that should
I also still use a leading underscore on my private data/functions/etc?
I would, even if only to alert any future maintainer of the intern
On Sat, May 12, 2012 at 3:36 AM, Devin Jeanpierre
wrote:
> On Fri, May 11, 2012 at 12:45 AM, Stefan Behnel wrote:
>> However, have you tried using a pipe for them instead of a real file? That
>> would allow you to retrieve the output without needing to pass through a
>> file in the file system. Y
On Fri, May 11, 2012 at 12:45 AM, Stefan Behnel wrote:
> However, have you tried using a pipe for them instead of a real file? That
> would allow you to retrieve the output without needing to pass through a
> file in the file system. You can also replace sys.stdout/err with arbitrary
> objects in
On Sat, May 12, 2012 at 3:12 AM, Ian Kelly wrote:
> I believe that a MemoryError instance is pre-allocated for just this
> scenario.
Ah, wise move. It's one of those largely-imponderables, like figuring
out how to alert the sysadmin to a router failure.
ChrisA
--
http://mail.python.org/mailman/
On Fri, May 11, 2012 at 10:23 AM, Chris Angelico wrote:
> Hmm. What happens if the interpreter can't construct a MemoryError exception?
I believe that a MemoryError instance is pre-allocated for just this
scenario. You can see it in the result of gc.get_objects().
>>> [x for x in gc.get_objects
On 5/11/2012 9:41 AM Ethan Furman said...
Style question:
Since __all__ (if defined) is the public API, if I am using that should
I also still use a leading underscore on my private data/functions/etc?
I would, even if only to alert any future maintainer of the internal vs
exposed nature of t
Style question:
Since __all__ (if defined) is the public API, if I am using that should
I also still use a leading underscore on my private data/functions/etc?
~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list
On Sat, May 12, 2012 at 2:15 AM, Christian Heimes wrote:
> Am 11.05.2012 17:51, schrieb Terry Reedy:
>> If the domain of a function is truly all Python objects, it cannot raise
>> an error. I believe id(x) is such an example.
>
> Even id() can raise an exception, for example MemoryError when you a
Am 11.05.2012 17:51, schrieb Terry Reedy:
> If the domain of a function is truly all Python objects, it cannot raise
> an error. I believe id(x) is such an example.
Even id() can raise an exception, for example MemoryError when you are
running out of memory.
Christian
--
http://mail.python.org/
On 5/11/2012 1:55 AM, John Terrak wrote:
I couldnt find anywhere in the documentation that int() can throw a ValueError.
I checked the "The Python Language Reference", and the "The Python
Standard Library " to no avail.
Did I missed something?
To add to Chris' answer:
If the domain of a funct
> >> It's also helpful to not have to display every attribute, of which
> >> there may be dozens.
> >
> > Do I detect a code smell here?
> >
> I think so, Murphy's law dictates that the attribute you're interested in
> will not be
> displayed anyway.
That's what __repr__'s for.
--
http://mail.py
> > It's also helpful to not have to display every attribute, of which there
> > may be
> dozens.
>
> Do I detect a code smell here?
Possibly. I'll often try to subdivide into several simpler types, but sometimes
that makes the code more complex than it needs to be.
--
http://mail.python.org/m
Mark Lawrence wrote:
On 11/05/2012 15:32, Andreas Tawn wrote:
It's also helpful to not have to display every attribute, of which
there may be dozens.
Do I detect a code smell here?
I think so, Murphy's law dictates that the attribute you're interested
in will not be displayed anyway.
JM
-
On 5/11/2012 12:35 AM, Michael Rene Armida wrote:
Given this source:
def do_something(val):
if val:
return 'a'
else:
return 'b'
How do I get the line number of the "else:" line, using the ast
module? The grammar only includes the 'orelse' list:
If(expr test, s
On 11/05/2012 15:32, Andreas Tawn wrote:
It's also helpful to not have to display every attribute, of which there may be
dozens.
Do I detect a code smell here?
--
Cheers.
Mark Lawrence.
--
http://mail.python.org/mailman/listinfo/python-list
> I have no idea why using __repr__ versus __str__ would make any difference in
> the
> order of the attributes. They're going to come out in the order you specify,
> regardless of what you name your method. If you don't like the arbitrary
> order you
> get from the dictionary, then either sort
On 05/11/2012 07:16 AM, Andreas Tawn wrote:
>>
>> This is a very interesting solution.
>>
>> I think it might be better suited (for my purpose) to __repr__ rather than
>> __str__, mostly because I still lose control of the order the attributes
>> appear.
I have no idea why using __repr__ versus
On 11/05/2012 12:13, Nikhil Verma wrote:
Hi All
I was going through this link
http://docs.python.org/library/datetime.html#strftime-strptime-behavior.
I practised strftime() and strptime() functions.
Finally i stuck into a situation where i want to get the datetime
object so that i can save it
> This issue bit me once too often a few months ago, and now I have a class
> called
> "O" from which I often subclass instead of from "object".
> Its main purpose is a friendly __str__ method, though it also has a friendly
> __init__.
>
> Code:
>
> class O(object):
> ''' A bare objec
Hi All
I was going through this link
http://docs.python.org/library/datetime.html#strftime-strptime-behavior.
I practised strftime() and strptime() functions.
Finally i stuck into a situation where i want to get the datetime object
so that i can save it in my db.
What i want is :-
I have a stri
On 11/05/2012 05:35, Michael Rene Armida wrote:
Given this source:
def do_something(val):
if val:
return 'a'
else:
return 'b'
How do I get the line number of the "else:" line, using the ast
module? The grammar only includes the 'orelse' list:
If(expr test, stm
On 11/05/2012 10:55, Nikhil Verma wrote:
Hi All
I have a list like this :-
[ ('7 May monday AM Neuropancreatic'), ('8 May tuesday PM Cardiovascular')]
how can i increment date in the above list for the next months on weekly
basis ?
[ ('7 May monday AM Neuropancreatic'),('14May monday AM
Neu
Hi All
I have a list like this :-
[ ('7 May monday AM Neuropancreatic'), ('8 May tuesday PM Cardiovascular')]
how can i increment date in the above list for the next months on weekly
basis ?
[ ('7 May monday AM Neuropancreatic'),('14May monday AM
Neuropancreatic')('21 May monday AM Neuropancr
29 matches
Mail list logo