On Tue, Feb 5, 2013 at 5:51 PM, Laxmikant Chitare
wrote:
> One more thing, apart from what Albert mentioned.
> Exceptions must be classes or instances. In effect you cannot just do
> 'raise'. 'raise' statement must be followed by a class or an instance.
You can inside an except clause.
>>> try:
On 2/4/2013 6:16 PM, Steven D'Aprano wrote:
The eternal conflict between "Look Before You Leap" and "Easier to Ask for
Forgiveness than Permission" (LBYL vs EAFP) continues...
A somewhat different answer is that it depends on what you want the
function to do, as documented and *tested*. And th
One more thing, apart from what Albert mentioned.
Exceptions must be classes or instances. In effect you cannot just do
'raise'. 'raise' statement must be followed by a class or an instance.
On Tue, Feb 5, 2013 at 6:28 AM, Albert Hopkins wrote:
>
>
> On Mon, Feb 4, 2013, at 04:49 PM, Rodrick Br
Terry Reedy writes:
> It looks like you should perhaps just forget about reopening and just
> use sys.stdout.flush(). This works fine even on IDLE.
As an alternative, can't you just use sys.stderr for printing such
feedback? sys.stderr is unbuffered by default...
ciao, lele.
--
nickname: Lele
The original message was received at Tue, 5 Feb 2013 09:14:21 +0200
from python.org [28.133.101.57]
- The following addresses had permanent fatal errors -
- Transcript of session follows -
while talking to python.org.:
>>> MAIL From:"Automatic Email Delivery Software"
<<< 501
On 2/4/2013 7:09 PM, Jabba Laci wrote:
Hi,
Thanks for the answers. I like the context manager idea but setting
the sys.stdout back to the original value doesn't work.
Example:
class Unbuff(object):
def __init__(self):
self.stdout_bak = sys.stdout
This could/should go in the __e
On Tue, 05 Feb 2013 16:20:19 +1100, Chris Angelico wrote:
> On Tue, Feb 5, 2013 at 3:52 PM, Steven D'Aprano
> wrote:
>> There's also the principle that it is best to raise an exception as
>> early as possible. It's easier to track down errors at the point they
>> are introduced than long afterwar
On 02/04/2013 09:14 PM, Anthony Correia wrote:
> I need to pick up a language that would cover the Linux platform. I
use Powershell for a scripting language on the Windows side of things.
Very simple copy files script. Is this the best way to do it?
>
> import os
>
> objdir = ("C:\\temp2")
>
Secure your position during Pre-Launch!
http://www.TheAppThatPays.ca
One of a kind, mobile application that makes it possible for the
average, every day person, to profit.
Check it out!
--
http://mail.python.org/mailman/listinfo/python-list
On Mon, Feb 4, 2013 at 9:52 PM, Steven D'Aprano
wrote:
> You seem to be making the
> classic mistake of thinking that exceptions are something to avoid:
Far from it. You've extrapolated a lot more than what I actually
said, and I completely agree with everything you wrote. I was
explaining EAFP
On Tue, Feb 5, 2013 at 3:52 PM, Steven D'Aprano
wrote:
> There's also the principle that it is best to raise an exception as early
> as possible. It's easier to track down errors at the point they are
> introduced than long afterwards.
Yes, definitely, especially (as was mentioned) if you're work
On Tue, Feb 5, 2013 at 2:52 PM, Steven D'Aprano
wrote:
> On Tue, 05 Feb 2013 10:38:41 +1100, Chris Angelico wrote:
>
>> On Tue, Feb 5, 2013 at 10:16 AM, Steven D'Aprano
>> wrote:
>>> A third option is not to check x at all, and hope that it will blow up
>>> at some arbitrary place in the middle o
On Mon, 04 Feb 2013 16:46:11 -0700, Ian Kelly wrote:
> Presumably if the operation requires
> a number, then it will at some point perform some kind of numerical
> manipulation that will raise a TypeError if one is not passed. If the
> operation succeeds, then the object supported all the operatio
Just started learning Python. I just wrote a simple copy files script. I use
Powershell now as my main scripting language but I wanted to extend into the
linux platform as well. Is this the best way to do it?
import os
objdir = ("C:\\temp2")
colDir = os.listdir(objdir)
for f in
I need to pick up a language that would cover the Linux platform. I use
Powershell for a scripting language on the Windows side of things. Very simple
copy files script. Is this the best way to do it?
import os
objdir = ("C:\\temp2")
colDir = os.listdir(objdir)
for f in colDir:
On Tue, 05 Feb 2013 10:38:41 +1100, Chris Angelico wrote:
> On Tue, Feb 5, 2013 at 10:16 AM, Steven D'Aprano
> wrote:
>> A third option is not to check x at all, and hope that it will blow up
>> at some arbitrary place in the middle of my code rather than silently
>> do the wrong thing. I don't l
On Tue, Feb 5, 2013 at 4:29 AM, Saul Spatz wrote:
> class Adder(): # python 2.7, classic class
>
> Why does this work for __add__ and not for __getattr__?
Is this a case of "why bother trying to understand it, just use
new-style classes"? They do make more sense in many ways.
ChrisA
On 4 February 2013 23:16, Steven D'Aprano
wrote:
>
> I want to check that a value is a number. Let's say I don't care what sort
> of number -- float, int, complex, Fraction, Decimal, something else -- just
> that it is a number. Should I:
>
> Look Before I Leap:
>
> from numbers import Number
On Mon, Feb 4, 2013, at 04:49 PM, Rodrick Brown wrote:
> For the life of me I cant figure out why this exception is being thrown.
> How could I use pdb to debug this?
>
> $ python udp_local2.py server
> File "udp_local2.py", line 36
> except:
> ^
> SyntaxError: invalid syntax
>
>
On 02/04/2013 03:16 PM, Steven D'Aprano wrote:
The eternal conflict between "Look Before You Leap" and "Easier to Ask for
Forgiveness than Permission" (LBYL vs EAFP) continues...
I want to check that a value is a number. Let's say I don't care what sort
of number -- float, int, complex, Fraction
On Tue, Feb 5, 2013 at 10:16 AM, Steven D'Aprano
wrote:
> from numbers import Number
> if isinstance(x, Number):
> ...
> else:
> raise TypeError
>
>
> or Ask Forgiveness:
>
> x + 0
> ...
>
>
> where in both cases the ellipsis ... is the code I actually care abou
Hi,
Thanks for the answers. I like the context manager idea but setting
the sys.stdout back to the original value doesn't work.
Example:
class Unbuff(object):
def __init__(self):
self.stdout_bak = sys.stdout
def __enter__(self):
sys.stdout.flush()
sys.stdout = os
On 02/04/2013 06:38 PM, Chris Angelico wrote:
On Tue, Feb 5, 2013 at 10:16 AM, Steven D'Aprano
wrote:
A third option is not to check x at all, and hope that it will blow up at
some arbitrary place in the middle of my code rather than silently do the
wrong thing. I don't like this idea because,
On Feb 4, 2013 4:24 PM, "Steven D'Aprano" <
steve+comp.lang.pyt...@pearwood.info> wrote:
>
> The eternal conflict between "Look Before You Leap" and "Easier to Ask for
> Forgiveness than Permission" (LBYL vs EAFP) continues...
>
> I want to check that a value is a number. Let's say I don't care wha
On Tue, Feb 5, 2013 at 10:16 AM, Steven D'Aprano
wrote:
> A third option is not to check x at all, and hope that it will blow up at
> some arbitrary place in the middle of my code rather than silently do the
> wrong thing. I don't like this idea because, even if it fails, it is better
> to fail ea
The eternal conflict between "Look Before You Leap" and "Easier to Ask for
Forgiveness than Permission" (LBYL vs EAFP) continues...
I want to check that a value is a number. Let's say I don't care what sort
of number -- float, int, complex, Fraction, Decimal, something else -- just
that it is a n
Should it not be "try-except-else' instead of 'if-except-else'?
try:
if delay > 2.0:
raise RuntimeError('I think the server is down')
except:
raise
else:
break
On Mon, Feb 4, 2013 at 5:21 PM,
Rodrick Brown wrote:
> For the life of me I cant figure out why this exception is being thrown.
> How could I use pdb to debug this?
>
> $ python udp_local2.py server
> File "udp_local2.py", line 36
> except:
> ^
> SyntaxError: invalid syntax
You can't use pdb to debug it, because
Dennis Lee Bieber wrote:
> I suspect you have a poorly normalized database (what does that
> trailing number identify? Heck, are the leading initials unique to the
> subsequent name?). The trailing number should probably be something
> stored as a separate field. If the initials are unique,
On Tue, Feb 5, 2013 at 8:49 AM, Rodrick Brown wrote:
> if delay > 2.0:
> raise RuntimeError('I think the server is down')
> except:
> raise
> else:
> break
I think you have an indentation error here. Backtab the e
For the life of me I cant figure out why this exception is being thrown.
How could I use pdb to debug this?
$ python udp_local2.py server
File "udp_local2.py", line 36
except:
^
SyntaxError: invalid syntax
#!/usr/bin/env python
import random, socket, sys
s = socket.socket(socket.
On 2/4/2013 12:12 PM, Jabba Laci wrote:
Hi,
I'd like to set autoflush on/off in my script. I have a loop that is
checking something and every 5 second I want to print a '.' (dot). I
do it with sys.stdout.write and since there is no newline, it is
buffered and not visible immediately. I have this
On Tue, Feb 5, 2013 at 7:50 AM, Terry Reedy wrote:
> I have mostly followed pydev since it began, and as far as I know, it is
> Barry's private joke, perhaps developed in private conversations.
Thanks Terry, Simon. I'll listen to that tonight when I get a chance
(no way I can listen to nearly an
On 2/4/2013 10:10 AM, Chris Angelico wrote:
This isn't particularly related to the post I'm quoting, it's more a
point of curiosity.
On Mon, Feb 4, 2013 at 10:53 AM, João Bernardo wrote:
Re: [Python-ideas] constant/enum type in stdlib
I have my own implementation with a basic api somewhat borr
Am 04.02.2013 18:12, schrieb Jabba Laci:
autoflush_on = False
def unbuffered():
"""Switch autoflush on."""
global autoflush_on
# reopen stdout file descriptor with write mode
# and 0 as the buffer size (unbuffered)
if not autoflush_on:
sys.stdout = os.fdopen(sys
Jabba Laci wrote:
> Hi,
>
> I'd like to set autoflush on/off in my script. I have a loop that is
> checking something and every 5 second I want to print a '.' (dot). I
> do it with sys.stdout.write and since there is no newline, it is
> buffered and not visible immediately.
My solution is sys.st
Saul Spatz wrote:
> Thanks, Peter. I realize this is getting sort of academic now, as I know
> how to do exactly what I want, but I'm still confused. Is __getattr__ a
> special case then, even for classic classes?
Well, it never occured to me to try a per-instance __getattr__(), but you
are ab
Looking for a new Pelican theme? Look no further than
https://github.com/demianbrecht/pelican-bold
Still a little rough around the edges, feel free to fork and contribute.
(Using it for my personal blog, and yes, I'm very much aware that the
content needs some lovin' :))
Demian Brecht
http://dem
Thanks, Peter. I realize this is getting sort of academic now, as I know how
to do exactly what I want, but I'm still confused. Is __getattr__ a special
case then, even for classic classes?
class Adder(): # python 2.7, classic class
def __init__(self, x):
self.x = x
self.
On Feb 4, 2013 4:27 PM, "nn" wrote:
>
> On Feb 4, 10:10 am, Chris Angelico wrote:
> > This isn't particularly related to the post I'm quoting, it's more a
> > point of curiosity.
> >
> > On Mon, Feb 4, 2013 at 10:53 AM, João Bernardo wrote:
> >
> > Re: [Python-ideas] constant/enum type in stdlib
Steffen Mutter wrote:
> Dennis Lee Bieber wrote:
>> Untested:
>>
>> SELECT DISTINCT * from
>> (select homenr as nr, home as club FROM Runde20122013
>> WHERE place="karlsruhe"
>> UNION SELECT guestnr as nr, guest as club FROM 20122013
>> WHERE place="karlsruhe")
>> limit 10
>
> Hi Dennis,
>
> her
On Feb 4, 10:10 am, Chris Angelico wrote:
> This isn't particularly related to the post I'm quoting, it's more a
> point of curiosity.
>
> On Mon, Feb 4, 2013 at 10:53 AM, João Bernardo wrote:
>
> Re: [Python-ideas] constant/enum type in stdlib
>
> > I have my own implementation with a basic api
On 02/04/2013 09:30 AM, Steffen Mutter wrote:
359|TV Calmbach
21101|SG Heidel/Helm
21236|JSG Neuth/Büch
23108|TG Eggenstein
23108|TGEggenstein 2 <-
23109|TV Ettlingenw
23109|TV Ettlingenw 2 <-
23112|TSV Jöhlingen
23112|TSV Jöhlingen 2 <-
23112|TSV Jöhlingen 3 <-
Still not like what I'm looking
This isn't particularly related to the post I'm quoting, it's more a
point of curiosity.
On Mon, Feb 4, 2013 at 10:53 AM, João Bernardo wrote:
Re: [Python-ideas] constant/enum type in stdlib
> I have my own implementation with a basic api somewhat borrowed from
> flufl.enum (plus a lot of other s
Peter Otten wrote:
> Saul Spatz wrote:
>
>> Now I have another question. If dunder methods are looked up only in the
>> class, not the instance, why did defining __nonzero__ the way I did work?
>> Shouldn't I have had to define it with a def? Is __nonzero__ a special
>> case?
>
> Unfortunately
Dennis Lee Bieber wrote:
> Untested:
>
> SELECT DISTINCT * from
> (select homenr as nr, home as club FROM Runde20122013
> WHERE place="karlsruhe"
> UNION SELECT guestnr as nr, guest as club FROM 20122013
> WHERE place="karlsruhe")
> l
Saul Spatz wrote:
> Now I have another question. If dunder methods are looked up only in the
> class, not the instance, why did defining __nonzero__ the way I did work?
> Shouldn't I have had to define it with a def? Is __nonzero__ a special
> case?
Unfortunately the situation is a bit more co
Hi,
experimenting with zmq. I like to start/stop/restart
n independent subscriber with one deamon service in Python.
How I should adapt a common daemon class in python?
Thanks for a starting point
Christian
--
http://mail.python.org/mailman/listinfo/python-list
On Sunday, February 3, 2013 10:35:30 PM UTC-6, Steven D'Aprano wrote:
> On Sun, 03 Feb 2013 17:08:47 -0800, Saul Spatz wrote:
>
>
>
> > I don't understand what's going on at all. Can't I dynamically define
>
> > __getattr__? How should I go about it?
>
>
>
> Special "dunder" methods (Dou
It Is Not Just A Religion
This brief video shows the truth about religion Islam, it clarifies
the doubts that were put forward by people of other faiths and
religions
http://youtube.googleapis.com/v/Bj5kozRnxPw?rel=0
thank you
--
http://mail.python.org/mailman/listinfo/python-list
Dave Angel wrote:
> The decorator function will execute while *compiling* the class A, and
> the one in class B is unreferenced.
No, the decorator function is called when *executing* the class body of A.
Compilation could have happened weeks earlier.
It really does make it a lot easier to und
Ibad Kureshi U0850037 writes:
> I am bit new to python and am struggling to install NumPy and SciPy on to
> Python 2.7. Based on my understanding I believe that the problem is with my
> Python install rather than the way I am installing NumPy. I have seen only
> two other threads that deal wit
52 matches
Mail list logo