RE: goto statement

2005-04-20 Thread Sander Steffann
On 4/20/05, praba kar <[EMAIL PROTECTED]> wrote:
>In Python what is equivalent to goto statement

An old user-friendly cartoon that might be relevant:
http://ars.userfriendly.org/cartoons/?id=2506

Have fun :-)
Sander

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: time.clock() going backwards??

2006-08-25 Thread Sander Steffann
Hi,

>>>I experimented something very strange, a few days ago. I was debugging an
>>>application at a customer's site, and the problem turned out to be that
>>>time.clock() was going "backwards", that is it was sometimes
>>>(randomically)
>>>returning a floating point value which was "less than" the value returned
>>>by the previous invokation.
>
> If I remember it right, the cause of such a problem is updating the
> clock by accessing a time server over a network. Just any such access
> results in adjusting the time a bit and leads eventually to such problems.

Usualy time is synchronized by making the clock run a little faster or a 
little slower until it is in sync with the timeserver. It shouldn't go 
backwards... A bad time-sync-program might ofcourse do this, but with a 
decent NTP client this shouldn't happen.

- Sander


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ntp in python

2006-08-29 Thread Sander Steffann
Hi,

> I want to measure the packet delivery delays over various network
> links. For this I need to synchronise the times of the sender and
> receiver, either against NTP or eachother.

Maybe you can contact RIPE. They have test-boxes for exactly these kind of 
tests. I know AMS-IX uses them to measure the quality of their switch 
platform.

See http://www.ripe.net/projects/ttm/index.html

- Sander



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: unicode

2007-07-01 Thread Sander Steffann
Hi,

"Erik Max Francis" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> 7stud wrote:
>
>> Based on this example and the error:
>>
>> -
>> u_str = u"abc\u"
>> print u_str
>>
>> UnicodeEncodeError: 'ascii' codec can't encode character u'\u' in
>> position 3: ordinal not in range(128)
>> --
>>
>> it looks like when I try to display the string, the ascii decoder
>> parses each character in the string and fails when it can't convert a
>> numerical code that is higher than 127 to a character, i.e. the
>> character \u.
>
> If you try to print a Unicode string, then Python will attempt to first 
> encode it using the default encoding for that file.  Here, it's apparent 
> the default encoding is 'ascii', so it attempts to encode it into ASCII, 
> which it can't do, hence the exception.

If you want to change the default encoding of your stdout and stderr, you 
can do something like this:

import codecs, sys
sys.stdout = codecs.getwriter('utf-8')(sys.stdout)
sys.stderr = codecs.getwriter('utf-8')(sys.stderr)

After doing this, print u_str will work as expected (when using an utf-8 
terminal)

- Sander



-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Restart Linux System

2007-05-23 Thread Sander Steffann
Hi,

> > Probably not.  You need to just spawn the "reboot" command, or run
> > "init 6."  This requires root, though.  Without root there's no way
> > to reboot a linux system.
> 
> ...unless you run shutdown(8) or reboot(8) setuid root (reboot is
> kinda harsh though, btw).

It's not that bad. Reboot takes care of unintended consequences itself:

from 'man 8 reboot':
> If halt or reboot is called when the system is not in runlevel 0 or 6,
> in other words when it's  running  normally, shutdown will be invoked
> instead (with the -h or -r flag).

Since version 2.74 :)
- Sander



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: #!/usr/bin/env python > 2.4?

2007-03-21 Thread Sander Steffann
Hi,

Op 21-mrt-2007, om 20:41 heeft [EMAIL PROTECTED] het volgende  
geschreven:

> On Mar 21, 11:07 am, Jon Ribbens <[EMAIL PROTECTED]> wrote:
>> In article <[EMAIL PROTECTED]>, Stargaming wrote:
>>> from sys import version_info
>>> if version_info[0] < 2 or version_info[1] < 4:
>>>  raise RuntimeError("You need at least python2.4 to run this  
>>> script")
>>
>> That'll fail when the major version number is increased (i.e.  
>> Python 3.0).
>>
>> You want:
>>
>>   if sys.hexversion < 0x020400f0:
>> ... error ...
>
> Yes, it was intended to be and 'and' instead of an 'or'.

If you make it an 'and' it will not raise the exception on version  
like 1.5 or 2.3... If you realy want to use version_info, you'll have  
to do something like:

if version_info[0] < 2 or (version_info[0] == 2 and version_info[1] <  
4):
raise RuntimeError

- Sander

-- 
http://mail.python.org/mailman/listinfo/python-list


RE: John Bokma harassment

2006-05-26 Thread Sander Steffann
From: John Bokma
> dreamhost has made a decission, a right one IMO. And now you 
> ask people to harass them more?
> 
> You really are just a pathetic little shit now aren't you?
> Not even the balls nor the guts to fix the issue that you are.

Using language like this clearly shows who has a communication problem...

Please use decent language or shut up
- Sander

-- 
http://mail.python.org/mailman/listinfo/python-list