[ANN] Portable SciPy v0.1 released

2007-04-28 Thread Stef Mientki
Portable SciPy, is an easy installer of SciPy for M$ windows users.

For this moment, you can find the description page, with all links here
  
http://oase.uci.kun.nl/~mientki/data_www/pic/jalcc/python/portable_scipy.html

For future use, it's advised to always use my redirector page
  http://pic.flappie.nl/

The simple method described here,
can be used to create any set of Python packages + other programs,
with just a few lines of code (example available).

have fun,
and let me hear what you think of it.

Stef Mientki

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

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


Re: Cgi File Upload without Form

2007-04-28 Thread Gabriel Genellina
En Fri, 27 Apr 2007 18:10:42 -0300, [EMAIL PROTECTED]  
escribió:

 what is the simplest way to upload a file (or a long string) to a
 server using cgi/python?

 Since I want to upload the data programmatically, a form based
 solution is not good. I am not experienced with SOAP/WSDL and I
 believe that would be more difficult than necessary. The client
 program I have to use does not support FTP.

I don't understand your question. Do you control the server, the client,  
or both? Which one is in Python?

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


Re: SPE

2007-04-28 Thread SPE - Stani's Python Editor
On Apr 26, 9:06 pm, Glich [EMAIL PROTECTED] wrote:
 After posting this message I realized the stupid mistake I had made!
 But it was too late to change! I think patching it with py2exe would
 be a good idea.

 Greetings also,
 Glich

Yes, it would. Please subscribe to the spe-dev list and I'll guide you
there. There is done some work already which might be useful. Probably
a new version of SPE will come out in May but is now already available
in subversion.
http://pythonide.blogspot.com/2007/02/how-to-download-latest-spe-from_26.html

Stani
--
http://pythonide.stani.be

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


Crystal Concepts offering PHP-MYSQL JAVA/J2EE

2007-04-28 Thread Rajesh
Crystal Concepts offering PHP-MYSQL  JAVA/J2EE
courses on short term basis.
For details contact,
19/2 New No 182 Kaliamman Koil Street,
Virugambakkam
Chennai 600 092
mail: [EMAIL PROTECTED]
Mobile: 98407-28150

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


Re: Beginner Ping program

2007-04-28 Thread Marc 'BlackJack' Rintsch
In [EMAIL PROTECTED], Linus Cohen
wrote:

 I'm a newbie to python and programming in general, so I wanted a
 simple project to start off. What I'm trying to do here is write a
 python command-line ping program, much like the Unix and Windows ping
 programs. I've got this much worked out already:
 
 class ping
 def PING(IP, pings, size):

Why is it a class?  I would have expected a `ping()` function.

And you might have a look at `PEP 8 -- Style Guide for Python Code`_ for
spelling conventions for class and function names.

.. _PEP 8 -- Style Guide for Python Code:
   http://www.python.org/dev/peps/pep-0008/

Ciao,
Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: My newbie annoyances so far

2007-04-28 Thread Marc 'BlackJack' Rintsch
In [EMAIL PROTECTED], Bjoern Schliessmann wrote:

 Dennis Lee Bieber wrote:
 
 HP RPL made more sense: b if c [else d] end
 
 Please explain.
 
 HP RPL: b if c [else d] end
 Python: b if c else d
 
 What's the more sense here?

The HP RPL leaves even more questions.  If the square brackets mean the
``else`` part is optional, what would be the result of the expression if
`c` is `False`?

Hypothetical HP RPL syntax construct in Python::

  x = 42 if False end
  print x   # - ???

Ciao,
Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Which are your favorite UML tools?

2007-04-28 Thread Marc 'BlackJack' Rintsch
In [EMAIL PROTECTED], Russell E. Owen
wrote:

 Some problems are intrinsic to UML (for instance it has no concept of 
 linking use case information to other elements). And I don't know of any 
 way to model functions (only classes).

Just model modules as classes and functions as static methods of the
module's class. Modules are objects too and can be seen as singletons.

Ciao,
Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Portable SciPy v0.1 released

2007-04-28 Thread Stef Mientki
Beliavsky wrote:
 On Apr 27, 6:17 pm, Stef Mientki [EMAIL PROTECTED]
 wrote:
 Portable SciPy, is an easy installer of SciPy for M$ windows users.
 
 If you have an announcement for Windows users, I suggest that you not
 needlessly turn them off by abbreviating Microsoft as M$ . You don't
 like Windows, but many of us Windows users don't like the anti-Windows
 snobs. There is nothing wrong with making money by selling software.
 
Of course I've totally no objection with earning money in a fair way.
But do hard drug dealers earn their money in a fair way ?
The European Committee has taken several measures over the past 10 years,
to make the competition in the software market more fair,
but AFAIK there is only one country that succeeded in this goal.
So if politician can't achieve the goal, wanted by almost all their residents,
I feel it as my duty to make people aware of this faulty situation, whenever I 
can.

But let us use this list for more constructive tasks,
after all, Python might be an important step
on the road to a more fair competition.

cheers,
Stef Mientki
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Dedicated CPU core for Python?

2007-04-28 Thread Gabriel Genellina
Joshua J. Kugler ha escrito:

 On Thursday 26 April 2007 14:07, Gabriel Genellina wrote:

  En Thu, 26 Apr 2007 15:54:38 -0300, Joshua J. Kugler
  [EMAIL PROTECTED] escribió:

  CPython only
  uses one
  CPU core right now because it's threads are all internal, and do not
  spawn system threads (IIRC).
 
  Python threads are OS threads:
  http://docs.python.org/lib/module-thread.html
  [The thread module] is supported on Windows, Linux, SGI IRIX, Solaris
  2.x, as well as on systems that have a POSIX thread (a.k.a. ``pthread'')
  implementation.

 Yes, that may be, but they are not true system threads, or at least do not
 appear to be.  Threads on linux each show up as a separate process.  I can
 have several threads in my Python program, but no additional processes show
 up in ps -A.  I don't see how Python threads can be system threads with the
 GIL.  But, I've been wrong before, and threads are something I have very
 light knowledge of.

Try with ps -L

[EMAIL PROTECTED] ps -L -C python
  PID   LWP TTY  TIME CMD
 3952  3952 pts/100:00:03 python
 3952  3956 pts/100:00:00 python
 3952  3957 pts/100:00:00 python
 3952  3958 pts/100:00:00 python
 3952  3959 pts/100:00:00 python
 3952  3960 pts/100:00:00 python
 3952  3961 pts/100:00:00 python
 3952  3962 pts/100:00:00 python

Or ps --help depending on your system.

--
Gabriel Genellina

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


Re: getting rid of EOL character ?

2007-04-28 Thread Stef Mientki
hi John,

 In the previous language I used,
 when reading a line by readline, the EOL character was removed.
 
 Very interesting; how did you distinguish between EOF and an empty line? 
 Did you need to call an isEOF() method before each read?
Yes indeed, and I admit it needs some more coding ;-)
 

 Now I'm reading a text-file with CR+LF at the end of each line,
Datafile = open(filename,'r')line = Datafile.readline()

 now this gives an extra empty line
print line

 and what I expect that should be correct, remove CR+LF,
 gives me one character too much removed
print line[,-2]
 
 Stef, that would give you a syntax error. I presume that you meant to 
 type line[:-2]
Yes, sorry.
 

 while this gives what I need ???
print line[,-1]

 Is it correct that the 2 characters CR+LF are converted to 1 character ?
 
 In text mode (the default), whatever is the line ending on your platform 
 is converted to a single newline '\n' which is the same as LF.
Aha, that was the answer I was looking for.

snip

thanks for the splendid explanation John,

cheers,
Stef Mientki
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Memory addressing

2007-04-28 Thread Steven D'Aprano
On Fri, 27 Apr 2007 16:07:57 -0700, castironpi wrote:

 That's what we need: a CopyMemory() routine.

What we _really_ need are Poke() and Peek() routines.


-- 
Steven.

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


Re: if __name__ == 'main': passing an arg to a class object

2007-04-28 Thread Bjoern Schliessmann
alisonken1 wrote:

[if __name__ == __main__]
 These are samples to give the programmer an idea of how the code
 is supposed to work. 

No, this belongs into comments or docs. The contents of this block
are often used for testing or debugging, or for normally executable
code if it makes sense to call the module directly.

Regards,


Björn

-- 
BOFH excuse #224:

Jan  9 16:41:27 huber su: 'su root' succeeded for  on /dev/pts/1

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


Re: My newbie annoyances so far

2007-04-28 Thread Steven D'Aprano
On Sat, 28 Apr 2007 06:57:54 +, Dennis Lee Bieber wrote:

 On Fri, 27 Apr 2007 22:39:25 +0200, Bjoern Schliessmann
 [EMAIL PROTECTED] declaimed the following
 in comp.lang.python:
 
 Dennis Lee Bieber wrote:
 
  And I'll probably ignore those expressions whenever I do get
  around to 2.5+... That syntax, in my mind, just... stinks...
  
  HP RPL made more sense: b if c [else d] end
 
 Please explain.
 
 HP RPL: b if c [else d] end
 Python: b if c else d
 
 What's the more sense here?

   You didn't take account of what b, c, and d were...
 
 RPL:  condition if truth else false end
 Python:   truth if condition else false
 
 (RPL is a somewhat common reference to the stack based language of the
 later calculators -- HP48, for instance)

I believe RPL is the official name of the language used for the HP-28 and
-48 series calculators, although it doesn't appear to be in their
reference manuals.

The syntax as given above is actually incorrect. That appears more like
Forth -- an easy mistake to make. In RPL, it is:

IF test-clause THEN true-clause END
IF test-clause THEN true-clause ELSE false-clause END

Note that despite being a stack-based language, the Reverse Polish
notation of RPL is loosened slightly for conditional and looping commands.
The syntax above is a little misleading... in fact, IF doesn't actually do
anything (but is required!), as it is the THEN that pops a flag off the
stack. So long as there is a value on the stack for the THEN to pop off,
it doesn't matter if it gets there before or after the IF. Hence many
people preferred to write:

test-clause IF THEN true-clause ELSE false-clause END

instead. Note also that each *-clause can be a block of code, and is
only executed if needed. Either true-clause or false-clause can be empty.



-- 
Steven.

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


Re: My newbie annoyances so far

2007-04-28 Thread Bjoern Schliessmann
Dennis Lee Bieber wrote:

 You didn't take account of what b, c, and d were...
 
 RPL:  condition if truth else false end
 Python:   truth if condition else false
 
 (RPL is a somewhat common reference to the stack based language of
 the later calculators -- HP48, for instance)

I still don't see the more sense. Python's variant seems logical
to me -- fetch out garbage if garbage can full else don't.

The HP equivalent will be, if I understand correctly:

garbage can full if fetch out garbage [else don't]

I see two problems here:

- Also from my error in the last posting it's quite clear that the
RPL statement doesn't do what one would suppose. Isn't this what
Python always tries to avoid: Doing something different from what
is obvious. RP order doesn't fit in Python, IMHO.

- What should the expression's value be if the else is omitted?
None? What's it in the original? I can't imagine a use case here
since I always have two alternatives when I use a if b else c.

Regards,


Björn

-- 
BOFH excuse #110:

The rolling stones concert down the road caused a brown out

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


Re: Cgi File Upload without Form

2007-04-28 Thread Max M
[EMAIL PROTECTED] skrev:
 Hello,
 
 what is the simplest way to upload a file (or a long string) to a
 server using cgi/python?
 
 Since I want to upload the data programmatically, a form based
 solution is not good. I am not experienced with SOAP/WSDL and I
 believe that would be more difficult than necessary. The client
 program I have to use does not support FTP.

Try out urllib2

-- 

hilsen/regards Max M, Denmark

http://www.mxm.dk/
IT's Mad Science
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: getting rid of EOL character ?

2007-04-28 Thread Michael Hoffman
John Machin wrote:
 On 27/04/2007 11:19 PM, Michael Hoffman wrote:
 stef wrote:
 hello,

 In the previous language I used,
 when reading a line by readline, the EOL character was removed.
 
 Very interesting; how did you distinguish between EOF and an empty line? 
 Did you need to call an isEOF() method before each read?
 

 Now I'm reading a text-file with CR+LF at the end of each line,
Datafile = open(filename,'r')line = Datafile.readline()

 now this gives an extra empty line
print line

 and what I expect that should be correct, remove CR+LF,
 gives me one character too much removed
print line[,-2]
 
 Stef, that would give you a syntax error. I presume that you meant to 
 type line[:-2]
 

 while this gives what I need ???
print line[,-1]

 Is it correct that the 2 characters CR+LF are converted to 1 character ?
 
 In text mode (the default), whatever is the line ending on your platform 
 is converted to a single newline '\n' which is the same as LF.
 
 Using line[:-1] is NOT recommended, as the last line in your file may 
 not be terminated, and in that case you would lose the last data character.
 
 Is there a more automatic way to remove the EOL from the string ?

 line = line.rstrip(\r\n) should take care of it. If you leave out 
 the parameter, it will strip out all whitespace at the end of the 
 line, which is what I do in most cases.
 
 If you want *exactly* what is in the line, use line.rstrip('\n') -- this 
 will remove only the trailing newline (if it exists).
 
 If you want to strip all trailing whitespace, use line.rstrip() as 
 Michael suggested.
 
 Michael, note carefully that line.rstrip('\r\n') removes instances of 
 '\r' OR '\n' -- the arg is a set of characters to be removed, not a 
 suffix to be removed. In Stef's situation, it works only by accident. 
 Using that would not always give you the correct answer -- e.g. if your 
 (Windows) file had a line ending in CR CR LF [I've seen stranger].

I knew that about line.rstrip, but didn't consider the possibility of 
\r\r\n, while still wanting the first \r. Yuck.

Honestly, I almost always use line.rstrip()--it is seldom that I care 
about closing whitespace.
-- 
Michael Hoffman
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: My newbie annoyances so far

2007-04-28 Thread Gary Duzan
In article [EMAIL PROTECTED],
John Nagle  [EMAIL PROTECTED] wrote:

(P.S. PEP 3117 is a joke, right?)

   I expect so, especially given its creation date.

Gary Duzan
Motorola CHS


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


Re: My newbie annoyances so far

2007-04-28 Thread Steven D'Aprano
On Sat, 28 Apr 2007 10:58:25 +0200, Bjoern Schliessmann wrote:

 Dennis Lee Bieber wrote:
 
 You didn't take account of what b, c, and d were...
 
 RPL:  condition if truth else false end
 Python:   truth if condition else false
 
 (RPL is a somewhat common reference to the stack based language of
 the later calculators -- HP48, for instance)
 
 I still don't see the more sense. Python's variant seems logical
 to me -- fetch out garbage if garbage can full else don't.
 
 The HP equivalent will be, if I understand correctly:
 
 garbage can full if fetch out garbage [else don't]

As I explained in another post, the syntax given is wrong for RPL, but if
it were right, then that description would be correct: the if would pop a
flag off the stack, in this case garbage can full, and then branch to
either the code after the if fetch out garbage or after the else don't.


 I see two problems here:
 
 - Also from my error in the last posting it's quite clear that the
 RPL statement doesn't do what one would suppose.

There are bad programmers in every language, but RPL conditional blocks
aren't the cause of them. Once you learn how RPL works, if statements work
consistently and obviously (although maybe not to programmers who don't
get RP notation).


 Isn't this what
 Python always tries to avoid: Doing something different from what
 is obvious. RP order doesn't fit in Python, IMHO.

I agree that blindly trying to copy RP notation into Python wouldn't work.


 - What should the expression's value be if the else is omitted?
 None? What's it in the original? I can't imagine a use case here
 since I always have two alternatives when I use a if b else c.

In RPL, there are no expressions. RPL programs are constructed from data
and commands, not expressions. So you shouldn't think of 

garbage can full if fetch out garbage [else don't]

as an expression. Think of it as a block, equivalent to the Python:

if garbage_can_full:
fetch 
out
garbage
else:
don't

except that you can write it as a single line. Newlines in RPL are just
another sort of whitespace, with no special significance.

If the else clause is missing, then nothing is executed and processing
simply continues past the end of the block.

I agree with you that in the case of Python _expressions_, it doesn't make
sense to have a missing else part. But in the case of RPL, it is perfectly
natural for the else block to be missing.


-- 
Steven.

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


Re: Beginner Ping program

2007-04-28 Thread Linus Cohen
Actually the class ping bit is a placeholder. I'm actually developing
a module with python implementations of most standard network/internet
tools such as telnet, tracert, whois etc. It will be called inettools,
and the ping function is what I'm working on first. It should be a
simple enough job to code in the features the Unix and DOS ping
programs have(never stop, change size, change timeout).
As I am typing this, I'm looking through ping.c to see what I can
glean. It probably won't be much. My experience with C is very little.
As in, microscopic. Pretty much all the coding I've done up till now
has been shell scripting.

Cheers,
Linus



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


Re: getting rid of EOL character ?

2007-04-28 Thread John Machin
On Apr 28, 7:25 pm, Michael Hoffman [EMAIL PROTECTED] wrote:
 John Machin wrote:
  On 27/04/2007 11:19 PM, Michael Hoffman wrote:
  stef wrote:
  hello,

  In the previous language I used,
  when reading a line by readline, the EOL character was removed.

  Very interesting; how did you distinguish between EOF and an empty line?
  Did you need to call an isEOF() method before each read?

  Now I'm reading a text-file with CR+LF at the end of each line,
 Datafile = open(filename,'r')line = Datafile.readline()

  now this gives an extra empty line
 print line

  and what I expect that should be correct, remove CR+LF,
  gives me one character too much removed
 print line[,-2]

  Stef, that would give you a syntax error. I presume that you meant to
  type line[:-2]

  while this gives what I need ???
 print line[,-1]

  Is it correct that the 2 characters CR+LF are converted to 1 character ?

  In text mode (the default), whatever is the line ending on your platform
  is converted to a single newline '\n' which is the same as LF.

  Using line[:-1] is NOT recommended, as the last line in your file may
  not be terminated, and in that case you would lose the last data character.

  Is there a more automatic way to remove the EOL from the string ?

  line = line.rstrip(\r\n) should take care of it. If you leave out
  the parameter, it will strip out all whitespace at the end of the
  line, which is what I do in most cases.

  If you want *exactly* what is in the line, use line.rstrip('\n') -- this
  will remove only the trailing newline (if it exists).

  If you want to strip all trailing whitespace, use line.rstrip() as
  Michael suggested.

  Michael, note carefully that line.rstrip('\r\n') removes instances of
  '\r' OR '\n' -- the arg is a set of characters to be removed, not a
  suffix to be removed. In Stef's situation, it works only by accident.
  Using that would not always give you the correct answer -- e.g. if your
  (Windows) file had a line ending in CR CR LF [I've seen stranger].

 I knew that about line.rstrip, but didn't consider the possibility of
 \r\r\n, while still wanting the first \r. Yuck.

It would be unusual to want that first \r -- a possibly more likely
scenario might be where your text file contains an extract from a
database, and you need to check that there are no unwanted (e.g.
unprintable) characters in the data (whether at the end of the line,
the middle, or the start).

In any case I think that you are missing the point that when reading a
normal text file on Windows with readline, while the line in the file
may be 'foo bar\r\n', what you get from readline is 'foo bar\n' -- so
in normal usage, the \r in your line.rstrip('\r\n') is pointless.


 Honestly, I almost always use line.rstrip()--it is seldom that I care
 about closing whitespace.

Honestly, I almost always split a line into fields and then for each
field, strip leading and trailing whitespace, and change runs of 1 or
more whitespace characters to a single space -- where whitespace
includes the pesky U+00A0 aka nbsp; which doesn't qualify as
whitespace in a str instance.

Cheers,
John

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


Re: Numeric + wxPython, can't understand a bug...

2007-04-28 Thread John Ladasky
On Apr 27, 9:40 pm, Robert Kern [EMAIL PROTECTED] wrote:

 wx.Point objects are being recognized as sequences by array(). Consequently,
 reshape() thinks you are trying to reshape a (height*width, 2) array into a
 (height, width) array. You might want to create an empty (height, width)
 PyObject array first, and simply assign wx.Point values into it. That bypasses
 array()'s attempt at intuiting the structure of the list.

Thanks for the heads-up, Robert.  I did as you suggested, and it works
fine.  I'll need to read more about Numeric's array init procedure --
what it does it not immediately obvious to a newcomer.

+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+
|   Ladasky Home Solar, Inc.:  blowing sunshine up your   |
|   power grid since March 24, 2005.  Fiat lux!   |
+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+
|   UptimeDowntimekWh generated kWh consumed  |
|   744 days  13 hours1288614321  |
+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+

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


Re: Beginner Ping program

2007-04-28 Thread Marc 'BlackJack' Rintsch
In [EMAIL PROTECTED], Linus Cohen
wrote:

 Actually the class ping bit is a placeholder. I'm actually developing
 a module with python implementations of most standard network/internet
 tools such as telnet, tracert, whois etc. It will be called inettools,
 and the ping function is what I'm working on first.

Still doesn't explain why it is a class.

Ciao,
Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list


Program runs in all directories, except one..

2007-04-28 Thread Theo v. Werkhoven

Goodday,

Something strange going on here.
A piece of code I wrote bombs out in one of de directories under $HOME,
but not in others.
Here's a snipped:

#v+
def bin2asc(c):
s=''
for i in range(0,8):
  if c  1(7-i):
  s+='1'
  else:
  s+='0'
return 'b'+s

def shiftout(numoctets):
os.system('clear')
ser = serial.Serial(0)
from array import array
octarray = [0]
for i in range(0,numoctets-1):
octarray.append(0)

for octet in range(numoctets,0,-1):
octarray[octet-1]=1
for shift in range(0,8):
strg = array(B,octarray).tostring()
for oct in range(len(strg)):
  print 'octet%-11s' % oct,
print
for byte in array(B,octarray):
print '%-2s' % bin2asc(int(byte)),
print '%-6s' % hex(int(byte)),
print; print
try:
dummy = raw_input(Druk op een toets om de bytes te verzenden )
except KeyboardInterrupt, msg:
print; usage(Exiting..)
sys.exit()
ser.write(strg)
octarray[octet-1] = octarray[octet-1]  1
os.system('clear')
octarray[octet-1]=0
print done..
#v-

Here's the output from the directory it bombs out in:
#v+
theo:/home/theo/Devel/Python $ python serialLEDtest-cli.py
Hoeveel chips van het type HC595 zitten er op het LED board? 2
0
7865
8162
8220
17307
251430
5886084
5886182
5891527
5892283
5901048
5901062
Traceback (most recent call last):
  File serialLEDtest-cli.py, line 96, in module
main()
  File serialLEDtest-cli.py, line 93, in main
shiftout(numoctets)
  File serialLEDtest-cli.py, line 62, in shiftout
strg = array(B,octarray).tostring()
TypeError: 'list' object is not callable
#v-
Where the numbers come from I don't know, python internal?
#v+
theo:/home/theo/Devel/Python$ stat serialLEDtest-cli.py
  File: `serialLEDtest-cli.py'
  Size: 2641Blocks: 8  IO Block: 4096   regular file
Device: fd00h/64768dInode: 69113   Links: 4
Access: (0644/-rw-r--r--)  Uid: ( 1000/theo)   Gid: (  100/   users)
Access: 2007-04-28 13:28:23.0 +0200
Modify: 2007-04-28 13:00:33.0 +0200
Change: 2007-04-28 13:22:38.0 +0200
#v-

Now i've made hard links to other directories, like $HOME and $HOME/bin
#v+
theo:/home/theo $ stat serialLEDtest-cli.py
  File: `serialLEDtest-cli.py'
  Size: 2641Blocks: 8  IO Block: 4096   regular file
Device: fd00h/64768dInode: 69113   Links: 4
Access: (0644/-rw-r--r--)  Uid: ( 1000/theo)   Gid: (  100/   users)
Access: 2007-04-28 13:30:02.0 +0200
Modify: 2007-04-28 13:00:33.0 +0200
Change: 2007-04-28 13:22:38.0 +0200
#v-

And when I run (the same script) from that location:
#v+
theo:/home/theo $ python serialLEDtest-cli.py
Hoeveel chips van het type HC595 zitten er op het LED board? 2
octet0   octet1  
b 0x0b0001 0x1   

Druk op een toets om de bytes te verzenden
#v-

Not a problem there, and neither in other directories I  made links in,
or copied the file to, only in that one directory..

Anyone have ideas?
Tnx.

Theo
-- 
theo at van-werkhoven.nlICQ:277217131  SuSE Linux
linuxcounter.org: 99872  Jabber:muadib at jabber.xs4all.nl  AMD XP3000+ 1024MB
ik _heb_ niets tegen Microsoft, ik heb iets tegen
 de uitwassen *van* Microsoft
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Which are your favorite UML tools?

2007-04-28 Thread Anastasios Hatzis
On Friday 27 April 2007 23:48, Bruno Desthuilliers wrote:
 Anastasios Hatzis a écrit :
  Hello,
 
  I'm working on the light-weight MDA tool pyswarm,
  http://pyswarm.sourceforge.net/ (it is about a code-generator for
  Python/PostgreSQL-based software. I plan to add support of UML CASE tools
  other than the one supported currently.
 
  I would like to learn which UML tools you use (if any),

 Any piece of paper and anything that can be used to write on it.

Maybe importing paper-based UML into a MDA tool would be easier than the XMI 
interoperability nightmare I'm facing ;)

  preferrably if it
  comes to modeling a Python application.

 I stll wait for UML to be able to describe common hi-level dynamic
 languages idioms and patterns without requiring more space and time than
   source code.

Do you have an example for what you mean? As I understand Python itself is 
already pretty abstract compared to other languages and platforms where UML 
and also MDA are -for good reasons- popular. I think it depends on the 
complexity of a Python software if it would be worth to add another 
abstraction layer. UML and especially MDA are adding their own complexity 
which has to be compensated by the benefits of the additional abstraction.

BTW, I don't know if UML is the appropriate notation (or model level) to 
describe high level dynamic languages' idioms and patterns. Two days ago I 
learned of a research project that uses Essential Meta Object Facility (MOF 
is the meta-meta model of UML) to model their own Python language with 
extensions or modifications of regular Python to build domain specific 
languages. Modules in these special Python dialects can be compiled and 
executed by a normal Python interpreter. I was pretty impressed although I 
didn't understand all the details how it works. These things are beyound my 
current skills. :)

Best regards,
Anastasios
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Which are your favorite UML tools?

2007-04-28 Thread Anastasios Hatzis
On Saturday 28 April 2007 00:26, Russell E. Owen wrote:
 In article [EMAIL PROTECTED],

  Bruno Desthuilliers [EMAIL PROTECTED] wrote:
  Anastasios Hatzis a écrit :
   Hello,
  
   I'm working on the light-weight MDA tool pyswarm,
   http://pyswarm.sourceforge.net/ (it is about a code-generator for
   Python/PostgreSQL-based software. I plan to add support of UML CASE
   tools other than the one supported currently.
  
   I would like to learn which UML tools you use (if any),
 
  Any piece of paper and anything that can be used to write on it.
 
   preferrably if it
   comes to modeling a Python application.
 
  I stll wait for UML to be able to describe common hi-level dynamic
  languages idioms and patterns without requiring more space and time than
source code.

 I am inclined to agree, though my experience is limited. I work on a
 project that is trying to model all its software using Enterprise
 Architect. EA has some nice features, but overall I find it clumsy and
 frustrating.

 Some problems are intrinsic to UML (for instance it has no concept of
 linking use case information to other elements). And I don't know of any
 way to model functions (only classes).

 Others are EA's fault. For instance it is very slow and clumsy to add or
 edit lists of items (such as class methods or database fields). Also,
 shared development is a pain because there is no concurrent version
 control (it uses CVS to keep track of revisions, but not in a concurrent
 way; checking out a package locks out everybody else).

Version control of UML models is a tough issue, given the dependencies between 
models and thinking of visualization of differences between two models. So 
far my tool only uses one model in one single XMI file, but I have to change 
this especially since I want to ease the re-use of components between 
projects.


 I tried using a competing product but the interporability was terrible.
 Which brings up another point: it is likely the original poster would
 need to do a lot of work for each CASE tool supported.

Unfortunetaly you are too right! :)) Interoperability via XMI is a nightmare I 
don't want to dream anymore. For example, in the recent years it would have 
been much easier to use MagicDraw's OpenAPI with Jython to access models 
instead of importing its XMI files. The one thing is that MOF, UML and XMI 
are developing way too fast, so there are many tools but chance is little 
that they are based on the same standard versions. Additionally I don't know 
one tool which fully implements the corresponding standard specifications. 
Not a big surprise since the specifications are really complex and extensive. 
So, supporting one specific XMI format of one UML tool is not that 
complicated (especially since not all features are needed). But I have still 
a hard time thinking about an appropriate mapping between all these different 
standard versions and the differences how they are implemented in the tools. 
Especially since I want to keep these differences away from the normal tool 
user. Maybe it will be possible, at least as some compromise. The future will 
show.

Best regards,
Anastasios
-- 
http://mail.python.org/mailman/listinfo/python-list

Numbers and truth values

2007-04-28 Thread Szabolcs
Newbie question:

Why is 1 == True and 2 == True (even though 1 != 2),
but 'x' != True (even though  if 'x':  works)?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Numbers and truth values

2007-04-28 Thread Michael Hoffman
Szabolcs wrote:

 Why is 1 == True and 2 == True (even though 1 != 2),

Not what I get.

Python 2.5 (r25:51908, Mar 13 2007, 08:13:14)
[GCC 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)] on cygwin
Type help, copyright, credits or license for more information.
  2 == True
False
-- 
Michael Hoffman
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Numbers and truth values

2007-04-28 Thread Irmen de Jong
Szabolcs wrote:
 Newbie question:
 
 Why is 1 == True and 2 == True (even though 1 != 2),
 but 'x' != True (even though  if 'x':  works)?

Please check before you post:

[E:\Projects]python
Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on 
win32
Type help, copyright, credits or license for more information.
  2==True
False
 

Anyway,
it helps to think about value domains (in your examples, numbers and strings)
as having a single null value, and non-null values.
The null value is considered False.
The non-null values are considered True.

The null value for numbers is 0 obviously, and for strings it is ''
(the empty string).
Non-zero numbers and non-empty strings are considered True when used
in a boolean expression.

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


Re: Numbers and truth values

2007-04-28 Thread Steven D'Aprano
On Sat, 28 Apr 2007 14:33:23 +0200, Szabolcs wrote:

 Newbie question:
 
 Why is 1 == True and 2 == True (even though 1 != 2),
 but 'x' != True (even though  if 'x':  works)?

Everything in Python has a truth-value. So you can always do this:

if some_object:
print if clause is true
else:
print else clause

no matter what some_object is.

The constants True and False are a pair of values of a special type bool.
The bool type is in fact a sub-class of int:

 issubclass(bool, int)
True
 7 + False
7
 7 + True
8

Can you guess what values True and False are under the hood?

 1 == True
True
 0 == False
True
 2 == True
False
 if 2:
... print 2 is considered true
...
2 is considered true


If you are getting different results, the chances are that you have
accidentally reassigned that names True or False:

 True = 2  # DON'T DO THIS!!!
 2 == True
True



-- 
Steven.

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


Re: Program runs in all directories, except one..

2007-04-28 Thread John Machin
On Apr 28, 9:50 pm, Theo v. Werkhoven [EMAIL PROTECTED]
werkhoven.nl.invalid wrote:
 Goodday,

 Something strange going on here.
 A piece of code I wrote bombs out in one of de directories under $HOME,
 but not in others.
[snip]
 def shiftout(numoctets):
 os.system('clear')
 ser = serial.Serial(0)
 from array import array
 octarray = [0]
 for i in range(0,numoctets-1):
 octarray.append(0)

 for octet in range(numoctets,0,-1):
 octarray[octet-1]=1
 for shift in range(0,8):
 strg = array(B,octarray).tostring()

The above statement appears to be where the error manifests itself.
Possibilities: (1) array is bound to a list (2) the result of
array(B, octarray) has an attribute tostring which is bound to a
list. Option (1) seems less implausible. I'd be replacing that line
by:

print octet %r, shift %r, array %r % (octet, shift, array)
array_b = array(B, octarray)
print array_b %r % array_b
print array_b.tostring %r % array_b.tostring
strg = array_b.tostring()

You haven't shown us all of your code -- is array mentioned elsewhere?
What other imports are you doing? Do you have a file called array.py
in the offending directory? [I believe that this wouldn't matter,
because builtin modules like array can't be overridden by a file-based
module of the same name, but I could be wrong]

What platform and what version of Python?

HTH,
John

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


Re: Numbers and truth values

2007-04-28 Thread Szabolcs
Steven D'Aprano wrote:
 
 1 == True
 True
 0 == False
 True
 2 == True
 False

Oh my goodness! Now I also get 2 != True. I really don't know what 
happened. Most probably this (as a result of mistyping):

 
 True = 2  # DON'T DO THIS!!!
 2 == True
 True
 

But shouldn't Python forbid this? Is it possible to get a warning when 
unintentionally redefining built-in thing?
-- 
http://mail.python.org/mailman/listinfo/python-list


python function in pipe

2007-04-28 Thread Bart
Hi everyone!

Im using module that gives errors to stderr/stdout  (generated by SWIG)
Problem is that I need to parse this errors/information from module.

os.popen3 looks nice but this executes  command  not  function.

Is there any solution?

Best regards
Bart.

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


tkinter undo

2007-04-28 Thread Gigs_
Hi


I dont have idea how to write tkinter undo/redo function form my text editor 
and 
my paint program.
Could someone help? I'm not asking for code, just for some guidelines to get me 
in the right way.


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


Re: Multiple select in wx.GenericDirCrtl

2007-04-28 Thread Soren
On Apr 27, 3:13 pm, [EMAIL PROTECTED] wrote:
 On Apr 27, 7:31 am, Soren [EMAIL PROTECTED] wrote:

  Hi!

  Is it possible to do multiple file selections in a wx.GenericDirCtrl??

  Thanks,
  Soren

 I'm not finding anything. I do know you can select multiple files
 using the FileDialog. You should email the wxPython users group
 though. They may have a custom control or they will likely be able to
 point you in the right direction.

 http://www.wxpython.org/maillist.php

 Mike

I'll try that, thanks Mike!

Soren

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


Re: Python CGI and Browser timeout

2007-04-28 Thread Steve Holden
Sebastian Bassi wrote:
 On 26 Apr 2007 14:48:29 -0700, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 In order to work around this problem, I started printing empty strings
 (i.e. print ) so that the browser does not timeout.
 
 How do you print something while doing the query and waiting for the results?
 I saw some pages that display something like: This page will be
 updated in X seconds to show the results (X is an estimated time
 depending of server load), after a JS countdown, it refresh itself and
 show the result or another This page will be updated in X seconds to
 show the results.

The usual way is by client pull: send the content you want the user to 
see, and include a Refresh: header - the easiest way is to include a 
META tag in the html content head section like

   meta http-equiv=refresh content=N; URL=other-web-address

So the page can continually check whether the user's job is finished, if 
it isn't just sending out the same content and then when it is printing 
the details.

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden
-- Asciimercial -
Get Python in your .sig and on the web. Blog and lens
holdenweb.blogspot.comsquidoo.com/pythonology
tag items:del.icio.us/steve.holden/python
All these services currently offer free registration!
-- Thank You for Reading 

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


Re: Program runs in all directories, except one..

2007-04-28 Thread Carsten Haese
On Sat, 2007-04-28 at 13:50 +0200, Theo v. Werkhoven wrote:
 Goodday,
 
 Something strange going on here.
 A piece of code I wrote bombs out in one of de directories under $HOME,
 but not in others.

This usually means that the directory where your script doesn't work
contains some .py file that has the same name as a standard library
module that you need. Since the only import in your code snippet is
from array import array, and calling array() raises the exception that
a list object is not callable, I am guessing that the culprit is a file
named array.py that defines a list called array. Rename that file.

-Carsten


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


Re: *** Dr G Polya BRILLIANTLY analyses the Virgina Shooting Incident ***

2007-04-28 Thread Quadibloc
[EMAIL PROTECTED] wrote:
 On Apr 24, 2:09 pm, Quadibloc [EMAIL PROTECTED] wrote:

  I never thought that I would feel the urge to call someone an
  edelweiss-eating Tanzanian devil, but Dr. Polya proved that I lacked
  imagination.
.
 The effect is - in fact - more severely damaged by your confusion
 between Tasmania - where Dr. Polya actually lives - and Tanzania which
 is a country in Africa with a name similar enough to confuse semi-
 literate Americans.
.
Had you read his essay, as I did, you would have known that even if I
had had the two countries confused previously, Dr. Polya would have
disabused me of any such confusion before I finished his essay.

Rather, the point of my remark, as ought to be clear, was that such an
epithet - by displaying conspicuous disregard for the distinction
between Tasmania and Tanzania, and the distinction between Australia
and Austria, *both at the same time* - is intended to be insulting,
and the author's vituperative attack on the United States makes him
deserving of insult.

Australia - Tasmania included - would today be under the iron heel of
Imperial Japan had it not been for the armed might of the United
States of America!

John Savard

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


Re: Python CGI and Browser timeout

2007-04-28 Thread Steve Holden
Steve Holden wrote:
 Sebastian Bassi wrote:
 On 26 Apr 2007 14:48:29 -0700, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 In order to work around this problem, I started printing empty strings
 (i.e. print ) so that the browser does not timeout.
 How do you print something while doing the query and waiting for the results?
 I saw some pages that display something like: This page will be
 updated in X seconds to show the results (X is an estimated time
 depending of server load), after a JS countdown, it refresh itself and
 show the result or another This page will be updated in X seconds to
 show the results.
 
 The usual way is by client pull: send the content you want the user to 
 see, and include a Refresh: header - the easiest way is to include a 
 META tag in the html content head section like
 
meta http-equiv=refresh content=N; URL=other-web-address
 
 So the page can continually check whether the user's job is finished, if 
 it isn't just sending out the same content and then when it is printing 
 the details.
 
I should have pointed out that N is the number of seconds to wait before 
refreshing.

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden
-- Asciimercial -
Get Python in your .sig and on the web. Blog and lens
holdenweb.blogspot.comsquidoo.com/pythonology
tag items:del.icio.us/steve.holden/python
All these services currently offer free registration!
-- Thank You for Reading 

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


Re: EuroPython vs PyconUK

2007-04-28 Thread Steve Holden
EuGeNe Van den Bulke wrote:
 Steve Holden wrote:
So by this reasoning there should have been no Python UK conference
 for the last four years (in case you didn't know it ran as a track of 
 the C/C++ conference, but ths track has now broadened to include all 
 scripting languages). And what about the people who can't get the time 
 and/or money to attend EuroPython?
 
 I am afraid there is a misunderstanding. I have no problem with PyCon UK 
 but would like to have elements to help me choose (the official language 
 of PyCon Uno Italy is Italian so that fixes it :P).
 
 Diversity is good, so it isn't one vs. the other. And the UK really *is* 
 part of Europe (no matter how its politicians behave) :P
 
 I agree that diversity is good (you won't hear me say that there are too 
 many web frameworks in Python :D) but isn't dilution a danger?
 
 If Guido was a rock star and I was a groupie, I would want to know which 
 festival to attend to see him on stage. I guess there is always Google 
 Video ;)
 
 More seriously in Geneva there were people from all over the place, 
 speakers and attendees, which is one of the reason why such conferences 
 are interesting (or am I deluded?). It is harder for someone from 
 Australia to come twice to Europe in the space of 2 months than for a 
 pythoneer lambda to spend a couple of days studying another web 
 framework to see if it fits how his brain works and the problem he's got 
 to solve.
 
 Looking at the reactions to my post, I must be wrong. I didn't mean to 
 offend anyone if I did. I'll go to Vilnius because I have never seen the 
 city and try to go to Birmingham if the program looks interesting (not 
 very rational or is it?).
 
If you're traveling from Australia or similarly distant locations then 
I'd have to say EuroPython would be the one where you'd see most 
Pythonistas from most places.

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden
-- Asciimercial -
Get Python in your .sig and on the web. Blog and lens
holdenweb.blogspot.comsquidoo.com/pythonology
tag items:del.icio.us/steve.holden/python
All these services currently offer free registration!
-- Thank You for Reading 

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


Re: Tutorial creates confusion about slices

2007-04-28 Thread Steve Holden
Antoon Pardon wrote:
 On 2007-04-26, Steve Holden [EMAIL PROTECTED] wrote:
[...]
 
 Warning: this is an explicit test to see whether you can sit on your 
 hands and refrain from replying. It's hard to find a thread where you 
 don't make the last comment on every branch you get involved in.
 
 Well I guess I failed.
 
Yes, that just about says it all.

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden
-- Asciimercial -
Get Python in your .sig and on the web. Blog and lens
holdenweb.blogspot.comsquidoo.com/pythonology
tag items:del.icio.us/steve.holden/python
All these services currently offer free registration!
-- Thank You for Reading 

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


Re: More urllib timeout issues.

2007-04-28 Thread Steve Holden
John Nagle wrote:
I thought I had all the timeout problems with urllib worked around,
 but no.
 
socket.setdefaulttimeout is useful, but not always effective.
 I'm setting that to 15 seconds.
 If the host end won't open the connection within 15 seconds,
 urllib times out.  But if the host end opens the connection,
 then never sends anything, urllib waits for many minutes before
 timing out.  Any idea how to deal with this?  And don't just
 say use urllib2 unless you KNOW it works better there and
 can explain why.  I finally have M2Crypto and urllib playing
 well together, and don't want to mess with that.
 
For some wierd reason, several UK academic sites have this
 behavior, including soton.ac.uk.  If you try to open that
 in a browser, the browser just sits there, and eventually,
 after several minutes, displays The site is taking too
 long to respond.
 
What's the current status in this area?  Some patches to sockets
 were proposed a while back.  There's a long history of trouble
 in this area, and some fixes, but nothing that just works.
 The sockets module has two timeout settings (socket.setdefaulttimeout and
 sock.settimeout, the M2Crypto module has two (sock.set_socket_read_timeout 
 and 
 sock.set_socket_write_timeout), and none of them play well together
 or with the urllib/urllib2/httplib level and the blocking/non blocking
 socket distinction.
 
What we really should have is something like this:
 
 Sockets should have
   set_socket_connect_timeout
   set_socket_read_timeout
   set_socket_write_timeout
 
 which set an upper limit on how long a socket can go with a request for
 a connect, read or write pending but without progress on the connection.
 This needs to be independent of select poll timeouts, and these timeouts
 should work on blocking sockets.
 
 The existing socket function
 
   settimeout
 
 should set all of the above, and
 
   socket.setdefaulttimeout
 
 should set the default value for settimeout to be used on new sockets.
 
 SSL and M2Crypto, which wrap socket functionality,
 should understand all the above functions.
 
 HTTPlib, urllib, and urllib2 objects should understand
 
   settimeout
 
 Making the connect/read/write timeout distinction at that level
 probably isn't worth the trouble.
   
 Then we'd have a reasonable network timeout system.
 We have about half of the above now, but it's not consistent.
 
 Comments?
 
The only comments I'll make for now are

1) There is work afoot to build timeout arguments into network libraries 
for 2.6, and I know Facundo Batista has been involved, you might want to 
Google or email Facundo about that.

2) The main reason why socket.setdefaulttimeout is unsuitable for many 
purposes is its thread-unsafe property, so all threads must use the same 
default timeout or have it randomly change according to the whim of hte 
last thread to alter it.

3) This is important and sensible work and if properly followed through 
will likely lead to serious quality improvements in the network libraries.

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden
-- Asciimercial -
Get Python in your .sig and on the web. Blog and lens
holdenweb.blogspot.comsquidoo.com/pythonology
tag items:del.icio.us/steve.holden/python
All these services currently offer free registration!
-- Thank You for Reading 

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


Re: webbrowser.open works in IDLE and cmd shell but not from cygwin prompt

2007-04-28 Thread Steve Holden
Gregory Bloom wrote:
 On Apr 27, 3:12 am, Michael Hoffman [EMAIL PROTECTED] wrote:
 And, more to the point, how can I use webbrowser from scripts launched under
   cygwin?

 If you're using native Windows Python as you seem to be, try
 webbrowser.get(windows-default).open_new(url)

 If you want to use Cygwin Python instead, I submitted a patch more than
 1.5 years ago to allow it, but it hasn't been reviewed:

 http://python.org/sf/1244861
 --
 Michael Hoffman
 
 
 Awesome!  That works perfectly.  Thanks.
 
 
Interestingly when I tried this under Cygwin I got the links browser 
displaying the material from the given URL.

That's different enough that I might keep it like that.:-)

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden
-- Asciimercial -
Get Python in your .sig and on the web. Blog and lens
holdenweb.blogspot.comsquidoo.com/pythonology
tag items:del.icio.us/steve.holden/python
All these services currently offer free registration!
-- Thank You for Reading 

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


Re: creating an object from base class

2007-04-28 Thread Steve Holden
Ian Clark wrote:
 Quote iogilvy:
 i wish to have some extended functionality added to sockets

 i can create my own socket class   class mysocket(socket.socket):

 and all should be fine. Except, the sockets are created for me by the
 accept method, listening on port. So how can i take the standard
 socket created for me and create a 'mysocket'. I need a method that
 will initialise any new properties i have added in my class, but how
 can i change the class of the socket created?

 
 Someone correct me if I'm wrong, but I don't believe it's possible to
 change the type of objects made from builtin classes. Though if it's a
 custom class you can, for example:
 
 class Foo: pass
 class Bar: pass
 obj = Foo()
 obj.__class__ = Bar
 
 
Yes, assuming you weren't asking a rhetorical question you will 
eventually run up against

   class myClass1(object): pass
  ...
   class myClass2(object): pass
  ...
   mc1 = myClass1()
   type(mc1)
class '__main__.myClass1'
   mc1.__class__ = myClass2
   type(mc1)
class '__main__.myClass2'
   2 . __class__ = myClass1
Traceback (most recent call last):
   File stdin, line 1, in module
TypeError: __class__ assignment: only for heap types
  

This doesn't qualify as error message of the year, but it clearly tells 
you you aren't going to get around the prohibition. We also see

   o = object
   o.__class__ = myClass2
Traceback (most recent call last):
   File stdin, line 1, in module
TypeError: can't set attributes of built-in/extension type 'object'
  

which gives a much better error message. Of course it'll probably only 
take Alex Martelli a few minutes to find a workaround or counter-example.

 One option is to make your custom socket a wrapper around
 socket.socket and then pass through the calls you don't want to handle
 to socket.socket. The downside to this is there are quite a lot of
 methods that need to be accounted for. For example:
 
 class CustomSocket:
 def __init__(self, socket):
 self.socket = socket
 def connect(self, address):
 self.socket.connect( address + '.some.tld' )
 [etc]

 ...

 s = server_socket.accept()
 s = CustomSocket(s)
 
This technique is formally called delegation if you want to Google it.
 
 Another approach you might want to look at is populating your object
 at runtime through a function. This won't give it the type you want,
 but it will give it any methods and attributes it would have gotten
 from your class with the added benefit of it still being of type
 socket.socket. Example:
 
 def modify_socket( socket ):
 socket.cabbages = 'Yuk'
 socket.apples = 'Yum'

 def info():
 print 'Cabbages? %s\nApples? %s' % (socket.cabbages, socket.apples)
 obj.show_info = info

 ...

 s = server_socket.accept()
 modify_socket( s )
 s.show_info()
 Cabbages? Yuk
 Apples? Yum
 s.apples = 'Yummie'
 s.show_info()
 Cabbages? Yuk
 Apples? Yummie
 type(s)
 class 'socket._socketobject'
 
Of course that approach sucks if sockets happen to have an organes or 
apples attribute that's used in the inner workings of the class. This is 
when the C++ devotees start screaming about protected and private 
variables. Just ignore them :-)

[Note: these remarks are more for the OP than Ian]

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden
-- Asciimercial -
Get Python in your .sig and on the web. Blog and lens
holdenweb.blogspot.comsquidoo.com/pythonology
tag items:del.icio.us/steve.holden/python
All these services currently offer free registration!
-- Thank You for Reading 

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


I have a chance to do somting diffrent way not Python ?!

2007-04-28 Thread anders
Hi!
On my work we have a lot off diffrent server to make software for
diffrent os
from Windows, OS/X to Linux Solaris

Everyting is scripted with shell, but Windows  has batchfiles witch is
very
limited, compared to cshell etc.

So my boss has told me that it okej if i want to make somting better
och smooter,
for the windows machine.

First i looked a Ruby but didn't like it to interacting with the os,
nothinh wrong
but my eyes moved to Python becurse syntax is clean and every server
(not windows) has Python as base installed, and in the future i could
then move
the script to run on all servers.

So basicly i like advice about interac with os, compiler etc.
Nice webblinks to read more
and do/don't things.

best regards
Anders

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


Re: Video: Professor of Physics Phd at Cal Tech says: 911 Inside Job

2007-04-28 Thread War Office
On 25 abr, 21:33, Bill Habr [EMAIL PROTECTED] wrote:
 [EMAIL PROTECTED] wrote in message

 news:[EMAIL PROTECTED]

  Cal Tech is the ELITE of ELITE in physics.

  If Feynman were alive, he would point his finger straight at the 911
  criminal operators, the yank bastards themselves ...

 http://www.911blogger.com/node/8101

  No self-respecting scientist should keep his mouth shut. Its a
  fundamental challenge to the method of science, a detective work most
  demanding of INTELLECTUAL HONESTY.

 Isn't this the guy who has more conspiracy theories than Carter has pills?

 Whitewater, Vince Foster, moon landing hoax one week - we found a UFO on the 
 moon the
 next, Oklahoma City bombing, a new conspiracy every day ad nauseum?

Why can't any of you just discuss the fact that free-fall collapse of
this building contradicts the laws of physics (God's law whom gave you
and God's children whom's mass murder in Iraq you have allowed)?

Why do you all have to avoid the topic and rather go on a chracter
assassination which is totally abhorent to scientific method?

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


Re: Video: Professor of Physics Phd at Cal Tech says: 911 Inside Job

2007-04-28 Thread War Office
On 25 abr, 21:33, Bill Habr [EMAIL PROTECTED] wrote:
 [EMAIL PROTECTED] wrote in message

 news:[EMAIL PROTECTED]

  Cal Tech is the ELITE of ELITE in physics.

  If Feynman were alive, he would point his finger straight at the 911
  criminal operators, the yank bastards themselves ...

 http://www.911blogger.com/node/8101

  No self-respecting scientist should keep his mouth shut. Its a
  fundamental challenge to the method of science, a detective work most
  demanding of INTELLECTUAL HONESTY.

 Isn't this the guy who has more conspiracy theories than Carter has pills?

 Whitewater, Vince Foster, moon landing hoax one week - we found a UFO on the 
 moon the
 next, Oklahoma City bombing, a new conspiracy every day ad nauseum?

Why can't any of you just discuss the fact that free-fall collapse of
this building contradicts the laws of physics?

Why do you all have to avoid the topic and rather go on a character
assassination which is totally abhorent to scientific method?

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


If you Got Questions? I bet We got Answers

2007-04-28 Thread Leisure . 201
http://ugotquestions.blogspot.com/ - Find out anything !

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


Re: Video: Professor of Physics Phd at Cal Tech says: 911 Inside Job

2007-04-28 Thread Eric Gisse
On Apr 28, 8:44 am, War Office [EMAIL PROTECTED] wrote:
 On 25 abr, 21:33, Bill Habr [EMAIL PROTECTED] wrote:



  [EMAIL PROTECTED] wrote in message

 news:[EMAIL PROTECTED]

   Cal Tech is the ELITE of ELITE in physics.

   If Feynman were alive, he would point his finger straight at the 911
   criminal operators, the yank bastards themselves ...

  http://www.911blogger.com/node/8101

   No self-respecting scientist should keep his mouth shut. Its a
   fundamental challenge to the method of science, a detective work most
   demanding of INTELLECTUAL HONESTY.

  Isn't this the guy who has more conspiracy theories than Carter has pills?

  Whitewater, Vince Foster, moon landing hoax one week - we found a UFO on 
  the moon the
  next, Oklahoma City bombing, a new conspiracy every day ad nauseum?

 Why can't any of you just discuss the fact that free-fall collapse of
 this building contradicts the laws of physics?

 Why do you all have to avoid the topic and rather go on a character
 assassination which is totally abhorent to scientific method?

...because that's all that is left.

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


Re: python function in pipe

2007-04-28 Thread attn . steven . kuo
On Apr 28, 6:37 am, Bart [EMAIL PROTECTED] wrote:
 Hi everyone!

 Im using module that gives errors to stderr/stdout  (generated by SWIG)
 Problem is that I need to parse this errors/information from module.

 os.popen3 looks nice but this executes  command  not  function.

 Is there any solution?



Perhaps you're looking for the unittest module?

You can use assertRaises if an exception is raised
by the function.

You can also redirect sys.stderr and sys.stdout as needed
and test the captured strings with assertEquals.



Else you can wrap the module under test in another
module:

# mytest.py

import module_under_test

if __name__ == __main__:
module_under_test.foo()

Then, using os.popen3 (or subprocess),
run python mytest.py as your command.

--
Hope this helps,
Steven

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


Re: Video: Professor of Physics Phd at Cal Tech says: 911 Inside Job

2007-04-28 Thread Ben newsam
On 28 Apr 2007 09:35:59 -0700, War Office [EMAIL PROTECTED]
wrote:

(God's law whom gave you
and God's children whom's mass murder in Iraq you have allowed)?

Hi Dennis! waves
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Video: Professor of Physics Phd at Cal Tech says: 911 Inside Job

2007-04-28 Thread Eric Gisse
On Apr 24, 6:13 pm, [EMAIL PROTECTED] wrote:
 Cal Tech is the ELITE of ELITE in physics.

INN World Report interviewed Dr. Crockett Grabbe - professor of
physics at the University of Iowa - regarding his thoughts on the
'collapses' of WTC1, WTC2,  WTC7. In this interview he lists numerous
reasons to suspect controlled demolition and expresses support for
alternative theories.

A common mistake - I frequently confuse CalTech and U of Iowa.

http://scholar.google.com/scholar?hl=enlr=safe=offclient=firefox-aq=crockett+grabbe+author%3Ac-grabbe+iowabtnG=Search

That's interesting, no publications on any engineering topic. A
professor of physics, not engineering, who claims that explosives were
planted in not only WTC7, but WTC 1 and 2 which were trigged by the
planes impacting the building.

Why is anyone listening to this loon?


 If Feynman were alive, he would point his finger straight at the 911
 criminal operators, the yank bastards themselves ...

I don't recall Feynman ever advocating nutcase positions.


 http://www.911blogger.com/node/8101

 No self-respecting scientist should keep his mouth shut. Its a
 fundamental challenge to the method of science, a detective work most
 demanding of INTELLECTUAL HONESTY.

I love how folks like you ask for intellectual honesty when every
effort is made to ignore evidence that doesn't agree with your
presupposed findings.

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


Re: Video: Professor of Physics Phd at Cal Tech says: 911 Inside Job

2007-04-28 Thread Michael A. Terrell
Eric Gisse wrote:
 
 On Apr 24, 6:13 pm, [EMAIL PROTECTED] wrote:
  Cal Tech is the ELITE of ELITE in physics.
 
 INN World Report interviewed Dr. Crockett Grabbe - professor of
 physics at the University of Iowa - regarding his thoughts on the
 'collapses' of WTC1, WTC2,  WTC7. In this interview he lists numerous
 reasons to suspect controlled demolition and expresses support for
 alternative theories.
 
 A common mistake - I frequently confuse CalTech and U of Iowa.
 
 http://scholar.google.com/scholar?hl=enlr=safe=offclient=firefox-aq=crockett+grabbe+author%3Ac-grabbe+iowabtnG=Search
 
 That's interesting, no publications on any engineering topic. A
 professor of physics, not engineering, who claims that explosives were
 planted in not only WTC7, but WTC 1 and 2 which were trigged by the
 planes impacting the building.
 
 Why is anyone listening to this loon?


   The same reason they listen to the even loonier Rosie O'donell?

   http://www.popularmechanics.com/blogs/911myths/4213805.html


-- 
Service to my country? Been there, Done that, and I've got my DD214 to
prove it.
Member of DAV #85.

Michael A. Terrell
Central Florida
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python function in pipe

2007-04-28 Thread 7stud
On Apr 28, 7:37 am, Bart [EMAIL PROTECTED] wrote:
 Hi everyone!

 Im using module that gives errors to stderr/stdout  (generated by SWIG)
 Problem is that I need to parse this errors/information from module.

 os.popen3 looks nice but this executes  command  not  function.

 Is there any solution?

 Best regards
 Bart.

Maybe something like this:

moduleA.py:
---
def someFunc():
print hello
raise ValueError

someFunc()
--

import subprocess

print Main executing
try:
p  = subprocess.Popen([python, 6test.py],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)

result = p.wait()
if result == 0:
print output:, p.stdout.read()
else:
print output before error:, p.stdout.read()
print error:, p.stderr.read()

except (OSError, TypeError, ValueError), e:
print subprocess was never started
print e


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


Re: python function in pipe

2007-04-28 Thread 7stud
 p  = subprocess.Popen([python, 6test.py],
 stdout=subprocess.PIPE,
 stderr=subprocess.PIPE)

The file name is wrong there; it should be:

p  = subprocess.Popen([python, moduleA.py],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)

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


Re: Numbers and truth values

2007-04-28 Thread Steven D'Aprano
On Sat, 28 Apr 2007 15:36:19 +0200, Szabolcs wrote:

 True = 2  # DON'T DO THIS!!!
 2 == True
 True
 
 
 But shouldn't Python forbid this? Is it possible to get a warning when 
 unintentionally redefining built-in thing?

Python forbids very few things in comparison to other languages. The
attitude is We're all adults here. Because Python is such a dynamic
language, it is often hard for the compiler to tell the difference between
something you are doing deliberately and a mistake.

If you're worried about that, google for PyChecker.


-- 
Steven.

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


Re: Beginner Ping program

2007-04-28 Thread [EMAIL PROTECTED]
On Apr 27, 10:54 pm, Linus Cohen [EMAIL PROTECTED] wrote:
 Hi all,
 I'm a newbie to python and programming in general, so I wanted a
 simple project to start off. What I'm trying to do here is write a
 python command-line ping program, much like the Unix and Windows ping
 programs. I've got this much worked out already:

 class ping
 def PING(IP, pings, size):

I agree with Marc here, probably no reason for a class here. As well,
if you are creating classes, generally class names should be
capitalized, methods should be lower case, i.e.

class Ping(object):
def ping(self, ip, pings, size):


But, there really is no need for a class here, placeholder or
otherwise.


 and that's where I stop, because I realize I have no idea how to make
 python send ICMP request packets. My previous project(an email reader
 using poplib)used the stuff in section 18 of the modules
 index(internet protocols) but I can't seem to find an equivalent for
 ICMP packets. If anyone has help on this, I would really appreciate
 it.

There is no (that I am aware of) ICMP module in the standard library.
See http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/409689 for
an example of a Python implementation of ping.


 Cheers,
 Linus

HTH,

Pete

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


Re: how to create/ref globals in an alternate namespace?

2007-04-28 Thread Steve Holden
Steven W. Orr wrote:
 On Friday, Apr 27th 2007 at 14:07 -0700, quoth James Stroud:
 
 =Steven W. Orr wrote:
 = I have two seperate modules doing factory stuff which each have the 
 = similar function2:
 = 
 = In the ds101 module, def DS101CLASS(mname,data):
 = cname = mname+'DS101'
 = msg_class = globals()[cname]
 = msg = msg_class(data)
 = return msg
 = 
 = and in the fdu module,
 = 
 = def FDUCLASS(mname,data):
 = cname = mname+'FDU'
 = msg_class = globals()[cname]
 = msg = msg_class(data)
 = return msg
 = 
 = I was thinking I'd be clever and create a common function:
 = def procCLASS(mname, objname, data):
 = cname = mname+objname
 = msg_class = globals()[cname]
 = msg = msg_class(data)
 = return msg
 = 
 = but the call to globals fouls it all up. Is there a way to write it so 
 = that the call to globals can be parameterized to be in the context of a 
 = specific module?
 = 
 = Also, I need to go the other way, a la,
 = globals()[name] = nclass
 = 
 = Is this doable?
 = 
 = TIA
 = 
 =
 =Why do you need all of the msg_class(es) global? Why not put them into a 
 =module and import the module where you need them? This would be the 
 =conventional way to avoid such problems.
 
 The idea is that DS101 is being called in a loop in the ds101 module to 
 create a lot of msg_classes. The same is true for the FDUCLASS function; 
 it creates a lot of classes in a loop.
 
 In addition, I have two other functions, almost alike, in two seperate 
 modules (mdefs is a structure with all of the stuff needed to drive the 
 loops)
 
 def __InitDS101Classes():
 for m in mdefs:
 mdef = mdefs[m]
 name = mdefs[m]['name']+'DS101'
 nclass = new.classobj(name,(DS101,),{})
 nclass.mdef = mdef
 nclass.mid = m
 globals()[name] = nclass
 
 
 def __InitFDUClasses():
 for m in mdefs:
 mdef = mdefs[m]
 name = mdefs[m]['name']+'FDU'
 nclass = new.classobj(name,(FDU,),{})
 nclass.mdef = mdef
 nclass.mid = m
 globals()[name] = nclass
 
 I'm trying to see if by being clever, I can factor out the common code of 
 the four different functions and still end up with what they create ending 
 up in the namespaces where they are intended to reside in. Does this make 
 sense or am I way off base?
 
 
Even if you *can* factor out the common code there's no reason why that 
shouldn't go in a fifth module that the other four import ...

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden
-- Asciimercial -
Get Python in your .sig and on the web. Blog and lens
holdenweb.blogspot.comsquidoo.com/pythonology
tag items:del.icio.us/steve.holden/python
All these services currently offer free registration!
-- Thank You for Reading 

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


Re: Video: Professor of Physics Phd at Cal Tech says: 911 Inside Job

2007-04-28 Thread Eric Gisse
On Apr 28, 9:30 am, Michael A. Terrell [EMAIL PROTECTED]
wrote:
 Eric Gisse wrote:

  On Apr 24, 6:13 pm, [EMAIL PROTECTED] wrote:
   Cal Tech is the ELITE of ELITE in physics.

  INN World Report interviewed Dr. Crockett Grabbe - professor of
  physics at the University of Iowa - regarding his thoughts on the
  'collapses' of WTC1, WTC2,  WTC7. In this interview he lists numerous
  reasons to suspect controlled demolition and expresses support for
  alternative theories.

  A common mistake - I frequently confuse CalTech and U of Iowa.

 http://scholar.google.com/scholar?hl=enlr=safe=offclient=firefox-a...

  That's interesting, no publications on any engineering topic. A
  professor of physics, not engineering, who claims that explosives were
  planted in not only WTC7, but WTC 1 and 2 which were trigged by the
  planes impacting the building.

  Why is anyone listening to this loon?

The same reason they listen to the even loonier Rosie O'donell?

wait...WHAT?


http://www.popularmechanics.com/blogs/911myths/4213805.html

 --
 Service to my country? Been there, Done that, and I've got my DD214 to
 prove it.
 Member of DAV #85.

 Michael A. Terrell
 Central Florida


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


ImportError: No module named QtOpenGL

2007-04-28 Thread Pradnyesh Sawant
Hello,
I've written a small pyqt4 code, which on running on an ubuntu 6.10
system gives me the foll error:
$ python2.4 updLbl.py
Traceback (most recent call last):
  File updLbl.py, line 1, in ?
import PyQt4.Qt as qt
  File /usr/lib/python2.4/site-packages/PyQt4/Qt.py, line 4, in ?
from PyQt4.QtOpenGL import *
ImportError: No module named QtOpenGL

I've tried installing python-opengl, and also qt4-dev-tools, but the
error persists.
What pkg do i need to install to get rid of the error message?

Thanks!
-- 
warm regards,
Pradnyesh Sawant
--
Be yourself, everyone else is taken. --Anon
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: More urllib timeout issues.

2007-04-28 Thread John Nagle
Steve Holden wrote:
 John Nagle wrote:

 Then we'd have a reasonable network timeout system.
 We have about half of the above now, but it's not consistent.

 Comments?

 The only comments I'll make for now are
 
 1) There is work afoot to build timeout arguments into network libraries 
 for 2.6, and I know Facundo Batista has been involved, you might want to 
 Google or email Facundo about that.

 2) The main reason why socket.setdefaulttimeout is unsuitable for many 
 purposes is its thread-unsafe property, so all threads must use the same 
 default timeout or have it randomly change according to the whim of hte 
 last thread to alter it.

It has other problems.  If you set that value, it affects
socket blocking/non blocking modes.  It can mess up M2Crypto, causing
it to report Peer did not return certificate.

 3) This is important and sensible work and if properly followed through 
 will likely lead to serious quality improvements in the network libraries.

Agreed.

 regards
  Steve

 I took a look at Facundo Batista's work in the tracker, and he
currently seems to be trying to work out a good way to test the
existing SSL module.  It has to connect to something to be tested,
of course.  Testing network functionality is tough; to do it right,
you need a little test network to talk to, one that forces some of
the error cases.  And network testing doesn't have the repeatability
upon which the Python test system/buildbot depends.

 It's really tough to test this stuff properly.  The best I've
been able to do so far is to run the 11,000 site list from the
Webspam Challenge through our web spider.

 Here's a list of URLs from our error log which
have given us connection trouble of one kind or another.
Most of these open an HTTP transaction, but for some reason,
don't carry it through to completion properly, resulting in
a long stall in urllib.


blaby.gov.uk
boys-brigade.org.uk
cam.ac.uk
essex.ac.uk
gla.ac.uk 

open.ac.uk
soton.ac.uk
uea.ac.uk
ulster.ac.uk


So that's a short, but useful, set of timeout test cases.  Those are the ones
that timed out after, not during, TCP connection opening.

It's interesting that this problem appears for the root domains of many
English universities.  They must all run the same server software.

Some of these fail because robotparser, which uses urllib, hangs
for minutes trying to read the robots.txt file associated with the
domain.

This isn't something that requires a major redesign.  These are bugs. 


John Nagle


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


Re: Numbers and truth values

2007-04-28 Thread Alex Martelli
Szabolcs [EMAIL PROTECTED] wrote:
   ...
  True = 2  # DON'T DO THIS!!!
  2 == True
  True
 
 But shouldn't Python forbid this? Is it possible to get a warning when
 unintentionally redefining built-in thing?

Python can be changed to make some non-reserved builtin identifiers into
reserved words, going through a stage where this is allowed but gives a
warning.  This happened in recent years for assignments to None, which
were legal back in 2.2 and earlier:

$ python2.3 -c'None=23'   
string:1: SyntaxWarning: assignment to None
$ python2.4 -c'None=23'
  File string, line 1
SyntaxError: assignment to None

...and, as you can see, gave syntax warnings in 2.3, becoming syntax
errors in 2.4 and later versions.

However, Python has a somewhat large and growing number of builtin
identifiers:

$ python2.3 -c'print len(__builtins__.__dict__)'
124
$ python2.4 -c'print len(__builtins__.__dict__)'
128
$ python2.5 -c'print len(__builtins__.__dict__)'
133

while keywords (reserved words) are far fewer, and more constrained in
their growth:

$ python2.3 -c'import keyword; print len(keyword.kwlist)'
29
$ python2.4 -c'import keyword; print len(keyword.kwlist)'
29
$ python2.5 -c'import keyword; print len(keyword.kwlist)'
31

so, making all builtins into keywords is unlikely to happen: it would
break a lot of existing code in exchange for a minor benefit.

It _would_ surely be possible to make Python behave this way only when a
certain commandline flag or environment variable is present, e.g. by
tweaking the implementation of the relevant bytecodes:

 def f():
...   global aglobal
...   aglobal = 23
...   alocal = 45
... 
 dis.dis(f)
  3   0 LOAD_CONST   1 (23)
  3 STORE_GLOBAL 0 (aglobal)

  4   6 LOAD_CONST   2 (45)
  9 STORE_FAST   0 (alocal)
 12 LOAD_CONST   0 (None)
 15 RETURN_VALUE

STORE_GLOBAL and STORE_FAST.  However, this might slow down normal
operation (by needing to check some flag at each STORE_...).

Perhaps a better approach is to perform your checking with a tool that
is _separate_ from Python proper.  Wouldn't it be great to have a tool
to check Python sources, one which we could name, for example,
pychecker, that we could run as follows...:

$ cat ba.py
False = 23

$ pychecker ba.py 
Processing ba...

Warnings...

ba.py:1: (False) shadows builtin
ba.py:1: Should not assign to False, it is (or will be) a builtin


Rejoyce!  http://pychecker.sourceforge.net/ ...

There are other tools to perform such checks, such as pylint,
http://www.logilab.org/857, which is quite a bit more complicated but
can perform many more checks (and can be integrated into PyDev, an
Eclipse add-on which some people like to use as a Python IDE), and, I
believe, a few other with slightly different slants (such as pyflakes,
http://www.divmod.org/projects/pyflakes, which does fewer checks but
does them faster and in a way that's safe against potentially-evil
code).

By the way, both of these tools (and many other tools, and a lot of
other useful tips) are mentioned at
http://www.python.org/doc/faq/programming/ , the Python Programming
FAQ (it's a bit dated, but if you find any problem with it, just like
with any other piece of official Python docs, bugs and suggested patches
are welcome at the usual location,
http://sourceforge.net/projects/python ).

Perhaps one day some variant of pychecker and/or pylint can be
integrated in Python itself, and executed (for example at each import)
if that's indicated by some appropriate flag or environment variable;
however, for us command-line dinosaurs, the people who prefer running
python at a shell prompt (rather than more advanced things such as
ipython, or IDEs such as PyDev, IDLE, etc, etc) this doesn't really tend
to be that high a priority, as we're quite used to not necessarily
auto-integrated tools; it's probably a higher priority to get pychecker
or something like that integrated with other IDEs such as IDLE (I don't
know, besides PyDev's ability to use pylint, which other such
integrations currently exist -- anybody?).


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


Re: Cgi File Upload without Form

2007-04-28 Thread Steve Holden
[EMAIL PROTECTED] wrote:
 Hello,
 
 what is the simplest way to upload a file (or a long string) to a
 server using cgi/python?
 
 Since I want to upload the data programmatically, a form based
 solution is not good. I am not experienced with SOAP/WSDL and I
 believe that would be more difficult than necessary. The client
 program I have to use does not support FTP.
 
A form-based solution is actually just what you want - you write a 
Python program that does just what the user's browser would do after 
they filled in a form.

You can do this with urllib fairly easily. If you get stuck then look 
for a library called mechanise.

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden
-- Asciimercial -
Get Python in your .sig and on the web. Blog and lens
holdenweb.blogspot.comsquidoo.com/pythonology
tag items:del.icio.us/steve.holden/python
All these services currently offer free registration!
-- Thank You for Reading 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Memory addressing

2007-04-28 Thread Alex Martelli
Steven D'Aprano [EMAIL PROTECTED] wrote:

 On Fri, 27 Apr 2007 16:07:57 -0700, castironpi wrote:
 
  That's what we need: a CopyMemory() routine.
 
 What we _really_ need are Poke() and Peek() routines.

You can easily write them with ctypes (it's part of the standard library
now, too) -- at least on systems where you can easily access the C
runtime library as a dynamic library, such as Windows, Linux, and
MacOSX, but I imagine it wouldn't be that much harder on others (I
haven't really looked in depth at the lowest-level functionality offered
by ctype, as the higher-level stuff is plenty sufficient to get a lot of
core dumps:-).


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


Re: Numbers and truth values

2007-04-28 Thread John Nagle
Steven D'Aprano wrote:
 On Sat, 28 Apr 2007 15:36:19 +0200, Szabolcs wrote:
 
 
True = 2  # DON'T DO THIS!!!
2 == True

True


But shouldn't Python forbid this? Is it possible to get a warning when 
unintentionally redefining built-in thing?
 
 
 Python forbids very few things in comparison to other languages. The
 attitude is We're all adults here. Because Python is such a dynamic
 language, it is often hard for the compiler to tell the difference between
 something you are doing deliberately and a mistake.

 I'd have to consider that a bug.

 Some very early FORTRAN compilers allowed you to redefine
integer constants:


CALL SET(25,99)
WRITE (6,100) 25
 100 FORMAT(I6)

SUBROUTINE SET(IVAR, INEWVAL)
IVAR = INEWVAL

would print

 99

 It was generally agreed by 1970 or so that this was a bad idea,
and was taken out of the language.

 C originally didn't have a Boolean type, and it took years to
get that in and uniformly defined.  But in the end, true and
false were reserved words.

 True, False, and None should be reserved words in Python.
None already is.

John Nagle



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


How to pass in argument to timeit.Timer

2007-04-28 Thread [EMAIL PROTECTED]
Hi,

I have a function in my python like this:
def callFunc(line, no):
  # some code

And I want to do a performance test like this:
 for line in f:
for i in range(int(count)):
t1 = timeit.Timer(callFunc(line, i),from __main__
import callFunc)
r1 = t1.timeit();
print r1;

but when I run it, it can't recognize the parameter 'line' and 'i',
can you please tell me how to fix it? i get this error:

 File /usr/lib/python2.4/timeit.py, line 161, in timeit
timing = self.inner(it, self.timer)
  File timeit-src, line 6, in inner
NameError: global name 'line' is not defined

Thank you.

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


how can I put an Exception as the key of a hash table

2007-04-28 Thread [EMAIL PROTECTED]
I want to keep track of the number of different exception happens in
my python program:

ErrorHash = {}

try:

 # come code ...

 except Exception, e:
print e
errcode = e

if (ErrorHash.has_key(errcode)):
ErrorFailNo = ErrorHash[errcode]

ErrorHash[errcode] = ErrorFailNo + 1

else:
ErrorHash[errcode] = 1


But when i print out the ErrorHash like this:

print ErrorHash

i get an empty string.  Can you please tell me how can I put an
Exception as the key of a hash table ? Or how can i dump out all the
content of the hashtable.

Thank you.

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


relative import broken?

2007-04-28 Thread Alan Isaac
Are relative imports broken in 2.5?
Directory ``temp`` contains::

__init__.py
test1.py
test2.py

File contents:
__init__.py and test2.py are empty
test1.py contains a single line::

from . import test2

Python 2.5.1 under Win2000, cmd line execution,
produces as output::

Traceback (most recent call last):
  File F:\temp\test1.py, line 1, in module
from . import test2
ValueError: Attempted relative import in non-package

Why?

Thanks,
Alan Isaac


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


Re: Program runs in all directories, except one..

2007-04-28 Thread Theo v. Werkhoven
The carbonbased lifeform John Machin inspired comp.lang.python with:
 On Apr 28, 9:50 pm, Theo v. Werkhoven [EMAIL PROTECTED]
 werkhoven.nl.invalid wrote:
 Goodday,

 strg = array(B,octarray).tostring()

 The above statement appears to be where the error manifests itself.
 Possibilities: (1) array is bound to a list (2) the result of
 array(B, octarray) has an attribute tostring which is bound to a
 list. Option (1) seems less implausible. I'd be replacing that line
 by:

 print octet %r, shift %r, array %r % (octet, shift, array)
 array_b = array(B, octarray)
 print array_b %r % array_b
 print array_b.tostring %r % array_b.tostring
 strg = array_b.tostring()

 You haven't shown us all of your code -- is array mentioned elsewhere?
 What other imports are you doing? Do you have a file called array.py
 in the offending directory? [I believe that this wouldn't matter,
 because builtin modules like array can't be overridden by a file-based
 module of the same name, but I could be wrong]

Bingo!
#v+
theo:/home/theo/Devel/Python $ ls array*  
array.py  array.pyc

theo:/home/theo/Devel/Python $ cat array.py
#!/usr/bin/python

import sys, os

array = [14, 8765, 756, 5345, 98, 5634654, 234123, 9087, 58, 297, 7865]
num = 0

while 1:
try:
print num
num = num + array.pop()
except:
 break
#v-
And that code produces the numbers I was seeing..

 What platform and what version of Python?

$ python --version
Python 2.5

$ uname -srv
Linux 2.6.18.8-0.1-default #1 SMP Fri Mar 2 13:51:59 UTC 2007
$ uname -mip
i686 athlon i386

 HTH,
 John

Thank you very much John. Nice catch.

Theo
-- 
theo at van-werkhoven.nlICQ:277217131  SuSE Linux
linuxcounter.org: 99872  Jabber:muadib at jabber.xs4all.nl  AMD XP3000+ 1024MB
ik _heb_ niets tegen Microsoft, ik heb iets tegen
 de uitwassen *van* Microsoft
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Program runs in all directories, except one..

2007-04-28 Thread Theo v. Werkhoven
The carbonbased lifeform Carsten Haese inspired comp.lang.python with:
 On Sat, 2007-04-28 at 13:50 +0200, Theo v. Werkhoven wrote:
 Goodday,
 
 Something strange going on here.
 A piece of code I wrote bombs out in one of de directories under $HOME,
 but not in others.

 This usually means that the directory where your script doesn't work
 contains some .py file that has the same name as a standard library
 module that you need. Since the only import in your code snippet is
 from array import array, and calling array() raises the exception that
 a list object is not callable, I am guessing that the culprit is a file
 named array.py that defines a list called array. Rename that file.

And you were right on the spot too, Cartsen, see my reply to John.
Thank you too.

Cheers,
Theo
-- 
theo at van-werkhoven.nlICQ:277217131  SuSE Linux
linuxcounter.org: 99872  Jabber:muadib at jabber.xs4all.nl  AMD XP3000+ 1024MB
ik _heb_ niets tegen Microsoft, ik heb iets tegen
 de uitwassen *van* Microsoft
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Video: Professor of Physics Phd at Cal Tech says: 911 Inside Job

2007-04-28 Thread Salmon Egg
On 4/28/07 9:44 AM, in article
[EMAIL PROTECTED], War Office
[EMAIL PROTECTED] wrote:

 Why can't any of you just discuss the fact that free-fall collapse of
 this building contradicts the laws of physics?
 
 Why do you all have to avoid the topic and rather go on a character
 assassination which is totally abhorent to scientific method?

Sometimes, when I pee into the toilet, a few droplets rise to heights that
defy god's laws. Do I have magic urine?

-- If there is such a thing as intelligent design, please explain
hemorrhoids.


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


Re: Video: Professor of Physics Phd at Cal Tech says: 911 Inside Job

2007-04-28 Thread War Office
On 28 abr, 13:56, Eric Gisse [EMAIL PROTECTED] wrote:
 On Apr 28, 8:44 am, War Office [EMAIL PROTECTED] wrote:



  On 25 abr, 21:33, Bill Habr [EMAIL PROTECTED] wrote:

   [EMAIL PROTECTED] wrote in message

  news:[EMAIL PROTECTED]

Cal Tech is the ELITE of ELITE in physics.

If Feynman were alive, he would point his finger straight at the 911
criminal operators, the yank bastards themselves ...

   http://www.911blogger.com/node/8101

No self-respecting scientist should keep his mouth shut. Its a
fundamental challenge to the method of science, a detective work most
demanding of INTELLECTUAL HONESTY.

   Isn't this the guy who has more conspiracy theories than Carter has pills?

   Whitewater, Vince Foster, moon landing hoax one week - we found a UFO on 
   the moon the
   next, Oklahoma City bombing, a new conspiracy every day ad nauseum?

  Why can't any of you just discuss the fact that free-fall collapse of
  this building contradicts the laws of physics?

  Why do you all have to avoid the topic and rather go on a character
  assassination which is totally abhorent to scientific method?

 ...because that's all that is left.

But no-one has critiqued Steven Jones' thesis. And this guy Professor
Emeritus of Physics concurs with Jones' thesis.

I challenge you to find any tenured or emirtus professor who has
written a counter thesis to Jones'

You realise everyone is still waiting for NIST to publish their final
report and that in Dec 2006 they announced that they would investigate
the explosives hypothesis as well as thermite to explain the molten
steel?

So as you can appreciate then this is still a current issue even
Officially.

Thus your feigned answer ...because that's all that is left is a
lie.

Can you show me past threads of your own where you have argued about
this Jones' thesis to any detail?

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


Re: Video: Professor of Physics Phd at Cal Tech says: 911 Inside Job

2007-04-28 Thread War Office
On 28 abr, 14:15, Eric Gisse [EMAIL PROTECTED] wrote:
 On Apr 24, 6:13 pm, [EMAIL PROTECTED] wrote:

  Cal Tech is the ELITE of ELITE in physics.

 INN World Report interviewed Dr. Crockett Grabbe - professor of
 physics at the University of Iowa - regarding his thoughts on the
 'collapses' of WTC1, WTC2,  WTC7. In this interview he lists numerous
 reasons to suspect controlled demolition and expresses support for
 alternative theories.

 A common mistake - I frequently confuse CalTech and U of Iowa.

 http://scholar.google.com/scholar?hl=enlr=safe=offclient=firefox-a...

 That's interesting, no publications on any engineering topic. A
 professor of physics, not engineering, who claims that explosives were
 planted in not only WTC7, but WTC 1 and 2 which were trigged by the
 planes impacting the building.

 Why is anyone listening to this loon?

There is no engineering professor or less who has written a counter-
thesis to Jones' thesis Why Indeed Did The Twin Towers Completely
Collapse
http://www.journalof911studies.com/volume/200609/Why_Indeed_Did_the_WTC_Buildings_Completely_Collapse_Jones_Thermite_World_Trade_Center.pdf

Have you even read it?

Can you find me a counter-thesis, a direct respons to that thesis
which rejects it in detail beyond a cursory I don't agree?

Don't you find it interesting that this thesis which is held up by 90%
of the Truth Movement as the smoking gun that WTC7 was controlled
demolition has had no formal or professional response from defenders
of the Official story? That the academic world remains silent?

And yet Jones' career has published over 50 academic papers in
esteemed journals.





  If Feynman were alive, he would point his finger straight at the 911
  criminal operators, the yank bastards themselves ...

 I don't recall Feynman ever advocating nutcase positions.

You havn't even demonstrated as much and already you're on an ad
hominem assassination?

Are you lying and misrepresenting this issue deliberately?





 http://www.911blogger.com/node/8101

  No self-respecting scientist should keep his mouth shut. Its a
  fundamental challenge to the method of science, a detective work most
  demanding of INTELLECTUAL HONESTY.

 I love how folks like you ask for intellectual honesty when every
 effort is made to ignore evidence that doesn't agree with your
 presupposed findings.

Which evidence would that be? Please cite twhich evidence contradicts
the controlled demolition hypothesis of WTC7 posited in  this paper:
http://www.journalof911studies.com/volume/200609/Why_Indeed_Did_the_WTC_Buildings_Completely_Collapse_Jones_Thermite_World_Trade_Center.pdf


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


Re: Video: Professor of Physics Phd at Cal Tech says: 911 Inside Job

2007-04-28 Thread War Office
On 28 abr, 16:06, Salmon Egg [EMAIL PROTECTED] wrote:
 On 4/28/07 9:44 AM, in article
 [EMAIL PROTECTED], War Office

 [EMAIL PROTECTED] wrote:
  Why can't any of you just discuss the fact that free-fall collapse of
  this building contradicts the laws of physics?

  Why do you all have to avoid the topic and rather go on a character
  assassination which is totally abhorent to scientific method?

 Sometimes, when I pee into the toilet, a few droplets rise to heights that
 defy god's laws. Do I have magic urine?

Was it recorded on video by three different television netoworks? How
can we believe you when you have no evidence other than your own
testimony to go by?
How do you know that you're not mistaken?

Have you tested this inquiry scientifically? Is there any way that an
independent investigation could repeat and varify the experiemental
results you are claiming to have observed?

Have you written this down in a careful academically structured thesis
such as this one:
http://www.journalof911studies.com/volume/200609/Why_Indeed_Did_the_WTC_Buildings_Completely_Collapse_Jones_Thermite_World_Trade_Center.pdf




 -- If there is such a thing as intelligent design, please explain
 hemorrhoids.


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


Re: Video: Professor of Physics Phd at Cal Tech says: 911 Inside Job

2007-04-28 Thread War Office
On 28 abr, 14:30, Michael A. Terrell [EMAIL PROTECTED]
wrote:
 Eric Gisse wrote:

  On Apr 24, 6:13 pm, [EMAIL PROTECTED] wrote:
   Cal Tech is the ELITE of ELITE in physics.

  INN World Report interviewed Dr. Crockett Grabbe - professor of
  physics at the University of Iowa - regarding his thoughts on the
  'collapses' of WTC1, WTC2,  WTC7. In this interview he lists numerous
  reasons to suspect controlled demolition and expresses support for
  alternative theories.

  A common mistake - I frequently confuse CalTech and U of Iowa.

 http://scholar.google.com/scholar?hl=enlr=safe=offclient=firefox-a...

  That's interesting, no publications on any engineering topic. A
  professor of physics, not engineering, who claims that explosives were
  planted in not only WTC7, but WTC 1 and 2 which were trigged by the
  planes impacting the building.

  Why is anyone listening to this loon?

The same reason they listen to the even loonier Rosie O'donell?

http://www.popularmechanics.com/blogs/911myths/4213805.html


That is not a scientific paper. It makes unsubstantiated claims and
asks the reader to trust their advice that they have inquired with
'experts'.

Please compare that popular mechanics article of unsubstantiated
claims with this
varifiable substantiated and falsifiable theis by Professor Steven
Jones:
http://www.journalof911studies.com/volume/200609/Why_Indeed_Did_the_WTC_Buildings_Completely_Collapse_Jones_Thermite_World_Trade_Center.pdf

It would be great if PM were willing to take on a critique of Jones'
thesis and I want to add that it is no suprise that they refuse.
Notice that they don't even mention Jones' in the article? And yet
Jones is the most famous 9/11 controlled demolition  theory academic
second only perhaps to David Ray Griffin.

If PM really intended to dispel the 'myth' that Rosie espoused then
would they go for the heart of it?, namely:
http://www.journalof911studies.com/volume/200609/Why_Indeed_Did_the_WTC_Buildings_Completely_Collapse_Jones_Thermite_World_Trade_Center.pdf





 --
 Service to my country? Been there, Done that, and I've got my DD214 to
 prove it.
 Member of DAV #85.

 Michael A. Terrell
 Central Florida


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


Re: Video: Professor of Physics Phd at Cal Tech says: 911 Inside Job

2007-04-28 Thread War Office
On 28 abr, 14:30, Michael A. Terrell [EMAIL PROTECTED]
wrote:
 Eric Gisse wrote:

  On Apr 24, 6:13 pm, [EMAIL PROTECTED] wrote:
   Cal Tech is the ELITE of ELITE in physics.

  INN World Report interviewed Dr. Crockett Grabbe - professor of
  physics at the University of Iowa - regarding his thoughts on the
  'collapses' of WTC1, WTC2,  WTC7. In this interview he lists numerous
  reasons to suspect controlled demolition and expresses support for
  alternative theories.

  A common mistake - I frequently confuse CalTech and U of Iowa.

 http://scholar.google.com/scholar?hl=enlr=safe=offclient=firefox-a...

  That's interesting, no publications on any engineering topic. A
  professor of physics, not engineering, who claims that explosives were
  planted in not only WTC7, but WTC 1 and 2 which were trigged by the
  planes impacting the building.

  Why is anyone listening to this loon?

The same reason they listen to the even loonier Rosie O'donell?

http://www.popularmechanics.com/blogs/911myths/4213805.html


That is not a scientific paper. It makes unsubstantiated claims and
asks the reader to trust their advice that they have inquired with
'experts'.

Please compare that Popular Mechanics article of unsubstantiated
claims with this
varifiable substantiated and falsifiable thesis by Professor Steven
Jones:
http://www.journalof911studies.com/volume/200609/Why_Indeed_Did_the_WTC_Buildings_Completely_Collapse_Jones_Thermite_World_Trade_Center.pdf

It would be great if PM were willing to take on a critique of Jones'
thesis and I want to add that it is no suprise that they neglected to.
Notice that they don't even mention StevenJones in the article? And
yet Jones is the most famous 9/11 controlled demolition  theory
academic second only perhaps to David Ray Griffin.

If PM really intended to dispel the 'myth' that Rosie espoused then
wouldn't  they go for the heart of it?, namely:
http://www.journalof911studies.com/volume/200609/Why_Indeed_Did_the_WTC_Buildings_Completely_Collapse_Jones_Thermite_World_Trade_Center.pdf





 --
 Service to my country? Been there, Done that, and I've got my DD214 to
 prove it.
 Member of DAV #85.

 Michael A. Terrell
 Central Florida

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


Re: python function in pipe

2007-04-28 Thread Gabriel Genellina
En Sat, 28 Apr 2007 13:58:59 -0300, [EMAIL PROTECTED] escribió:

 On Apr 28, 6:37 am, Bart [EMAIL PROTECTED] wrote:
 Im using module that gives errors to stderr/stdout  (generated by SWIG)
 Problem is that I need to parse this errors/information from module.
 os.popen3 looks nice but this executes  command  not  function.

 Perhaps you're looking for the unittest module?

 You can use assertRaises if an exception is raised
 by the function.
 You can also redirect sys.stderr and sys.stdout as needed
 and test the captured strings with assertEquals.

Maybe I'm wrong, but I think this won't help the OP with his problem.
As I understand it, he has a C function that uses stdout and stderr to  
report errors (perhaps using printf, fprintf, perror and similar  
functions) and he wants to call it from Python. Reassigning  
sys.stdout/stderr in Python won't help.

One way would be to make an executable from the C code, and call it using  
the subprocess module or some popen variant. How to pass arguments depends  
on the application, and may not be efficient.

Another way would be to change the C code, adding a FILE parameter (let's  
call it logfile) and replacing every printf(..., xxx) with  
fprintf(logfile, ..., xxx); the same for related functions.

Yet another way, and perhaps the easiest and less intrusive on the C code,  
would be to use freopen to replace stdout and stderr with another file  
(and going back again at the end!).

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


My Python annoyances

2007-04-28 Thread André
I'm really annoyed at Python - and not for the reasons already
mentioned on this list.

Everyone know that programming is supposed to be a dark art, nearly
impossible to learn.  Computer code is supposed to be something
impossible to read to the common person and yet reveal their secrets
to the initiated - just remember the code displayed in the Matrix...

Python takes all of that away.  It is just too readable.  Even
beginners can quickly learn to read code written by experts.

To make it even friendlier to beginners, Python uses ugly double
underscores both as prefix and suffix on magic methods to be invoked
only by more advanced programmers.   What's the fun in hiding the
complexity so that beginners can stay away from potential problems.

And why, oh why, does raw_input() have to go?  Here was at least one
good example of something that gave a hint (what does raw mean?) at
the underlying complexity.  Combined with the evil of the hidden eval
in the more obvious input(), there was at least a chance to trip
beginners into doing something dangerous.  Alas, that will no longer
be the case...

Python does not even make good use of weird symbols like $ and @ and %
to define variable types like Perl does.  Now, that's a language to
learn if you want to be respected.  I think that Georg Brandl had it
right in his recent proposal:
http://mail.python.org/pipermail/python-dev/2007-April/072419.html

If not Perl, perhaps Python should be inspired by a language like C++,
full of arcane stuff and, thankfully, requiring typing declaration.
This dynamic typing thing makes it just too easy to write working
programs quickly, especially combined with the ease of use of the
interpreter.  And this other thing called duck typing is just too
flexible to use.

No, Python should be more difficult.  It should take a full two
minutes to compile a Hello World program on a modern computer.

Also, this docstring business has to go.  Any programmer should, as
a rite of passage, have to spend countless hours reading obscure
documentation to learn other people's code before finding out what
methods can be used and how they should be used.  Having to use things
like dir and help just makes it too easy.

And don't get me started about the absence of curly braces to define
blocks of code.  What's the fun in making it so darn visually easy to
define such blocks of code, removing the possibility of creating
subtle bugs due to the misplacement of a curly bracket.  No sir, with
Python, the structure has to be obvious at a glance - newbies can see
it just as well as experts, thereby decreasing the aura surrounding
the latter.  This is not fair for people that have spent dozens of
hours in learning to program using Python!

And don't talk to me about functions, classes and methods, not to
mention modules. Python makes it too easy to write code in many
different styles, trying to please people who like to write only
object-oriented code as well as those that follow the more traditional
procedural approach.  Even functional type people find their way to
write code in their preferred method using Python.  This is not right.

Fortunately, Python has incorporated some newbie-unfriendly features,
like metaclasses and, to a lesser extent, decorators which, at last,
make use of a special character.  There should be more of these, to
make Python something more challenging to learn.

Programming should be more difficult than this - otherwise, how can
programmers be respected by the common folks?
---
André

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


Re: how can I put an Exception as the key of a hash table

2007-04-28 Thread James Stroud
[EMAIL PROTECTED] wrote:
 I want to keep track of the number of different exception happens in
 my python program:
 
 ErrorHash = {}
 
 try:
 
  # come code ...
 
  except Exception, e:
 print e
 errcode = e
 
 if (ErrorHash.has_key(errcode)):
 ErrorFailNo = ErrorHash[errcode]
 
 ErrorHash[errcode] = ErrorFailNo + 1
 
 else:
 ErrorHash[errcode] = 1
 
 
 But when i print out the ErrorHash like this:
 
 print ErrorHash
 
 i get an empty string.  Can you please tell me how can I put an
 Exception as the key of a hash table ? Or how can i dump out all the
 content of the hashtable.
 
 Thank you.
 

First, you may want

   errcode = str(e)

instead of

   errcode = e


Second, the empty string is probably because the Exception is 
instantiated without a string. E.g.:

  str(Exception())
''

Third, you must not be showing us everything, because an Exception can 
be used as a key, but does not give an empty string upon printing. You 
are definitely not showing us what it looks like when you print 
ErrorHash, which would be helpful.

Fourth, that you are creating a table of error codes means that you are 
attempting to transmogrify the way python handles exceptions into some 
paradigm you have used in a language like FORTRAN and thus are not using 
exceptions in their intended way. You might describe the reason you are 
generating error codes and gather suggestions about a more pythonic 
(i.e. reasonable) approach.

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


Re: how can I put an Exception as the key of a hash table

2007-04-28 Thread 7stud

[EMAIL PROTECTED] wrote:
 I want to keep track of the number of different exception happens in
 my python program:

 ErrorHash = {}

 try:

  # come code ...

  except Exception, e:
 print e
 errcode = e

 if (ErrorHash.has_key(errcode)):
 ErrorFailNo = ErrorHash[errcode]

 ErrorHash[errcode] = ErrorFailNo + 1

 else:
 ErrorHash[errcode] = 1


 But when i print out the ErrorHash like this:

 print ErrorHash

 i get an empty string.  Can you please tell me how can I put an
 Exception as the key of a hash table ? Or how can i dump out all the
 content of the hashtable.

 Thank you.

Apparently, the Exception class's __str__() method doesn't print
anything about the exception.  That doesn't mean the exception is an
empty string though:


ErrorHash = {}

try:

raise ValueError

except Exception, e:
print the exception is:, e, 

if (ErrorHash.has_key(e)):
ErrorFailNo = ErrorHash[e]
ErrorHash[e] = ErrorFailNo + 1
else:
ErrorHash[e] = 1

print ErrorHash

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


Re: My Python annoyances

2007-04-28 Thread Stef Mientki

 Programming should be more difficult than this - otherwise, how can
 programmers be respected by the common folks?

the answer is very simple (even more simple than Python ;-) ...
... create what common folks ask for !!

cheers,
Stef Mientki
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to serialize a COM object ?

2007-04-28 Thread vml
On 24 avr, 23:53, Neil Hodgson [EMAIL PROTECTED] wrote:
 vmlwrote:
  I have a COM object.

  I would like to pass this com object from a server to a client through
  a socket.

 As Diez mentioned, this may be possible through Distributed COM
 (DCOM). Its not very popular any more with techniques such as SOAP being
 more widely implemented. DCOM is fiddly to set up particularly the
 security aspects. IIRC I did get it to work with Python but that was
 maybe 8 years ago. Here's an overview of DCOM:

 http://msdn2.microsoft.com/en-us/library/ms809311.aspx

 Neil

Thank you for your answers, I think that a DCOM application ...

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


Re: My Python annoyances

2007-04-28 Thread Basilisk96
 Everyone know that programming is supposed to be a dark art, nearly
 impossible to learn.  Computer code is supposed to be something
 impossible to read to the common person and yet reveal their secrets
 to the initiated - just remember the code displayed in the Matrix...

Hmm, on my PyCon mug there are words Python: so easy...even your BOSS
can use it!
Thankfully, my boss doesn't know the difference between directories
and files, so I can easily succeed in making him think that Python
really IS a black art :)

Cheers
-Basilisk96

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


python and activeX control

2007-04-28 Thread vml
I have an application that I want to automatised trough a COM layer or
(DCOM)...

I can access to all the method of the COM objects with python and
win32com when this application is running

If the application is not running, I can not access to all the method
of the object.

Usually to overcome this problem , One can use an activeX control
which is just a bitmap in a form in VB(6)... and then the code is :

Dim module As Automation.IModule

Dim myBlock as Automation.IBlock2

Dim myDatabase As Automation.IDatabase

Set module = ActiveXModuleLoader1.module

myDatabase = module.Database(C:/Data/myproj)

I can have active X  ModuleLoader._DActiveXModuleLoader running under
python without a GUI but when you call the .module method of this
object it crashes :

Traceback (most recent call last):

  File interactive input, line 1, in module

  File D:\soft\python25\lib\site-packages\win32com\client
\__init__.py, line 458, in __getattr__

return self._ApplyTypes_(*args)

  File D:\soft\python25\lib\site-packages\win32com\client
\__init__.py, line 451, in _ApplyTypes_

dispid, 0, wFlags, retType, argTypes, *args),

com_error: (-2147418113, 'Catastrophic failure', None, None)


my questions :

- Do you have ideas to do translate the vb code into python ?


-In a module genrated by makepy : what can I call as object : coclass
or Dipatch base class ?\


-Do you know how to integrate an activeX control in a python GUI
( wxpython ) ? WOuld it solve my problems ?


- Why I can not access all the method of an object when the
application is not running ? Is there a way to do it ?

-  can I create a Ghost of such an application to be able to have all
the method on all the objects ?

- Can I create a vb code which contains all the code for the com
objects and then try to use python with scipy to do some mathematical
operations on the data?

I would like to do every thing in python but I am a newbie 

Thanks in advance !

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


Re: How to pass in argument to timeit.Timer

2007-04-28 Thread Gabriel Genellina
En Sat, 28 Apr 2007 15:48:11 -0300, [EMAIL PROTECTED]  
[EMAIL PROTECTED] escribió:

 I have a function in my python like this:
 def callFunc(line, no):
   # some code

 And I want to do a performance test like this:
  for line in f:
 for i in range(int(count)):
 t1 = timeit.Timer(callFunc(line, i),from __main__
 import callFunc)
 r1 = t1.timeit();
 print r1;

 but when I run it, it can't recognize the parameter 'line' and 'i',
 can you please tell me how to fix it? i get this error:

They go in the setup parameter, like this:

 t1 = timeit.Timer(callFunc(line, i),from __main__ import callFunc;  
line=%r; i=%d % (line, i))

If it gets much longer, try this:

setup = 
 from __main__ import callFunc
line = %r
i = %d % (line, i)
stmt = callFunc(line, i)
t1 = timeit.Timer(stmt, setup)

-- 
Gabriel Genellina

PS: Please leave out the final ; - this is Python, not C nor ...
PS2: Perhaps the only place where I've used ; is with timeit. And even  
then you can avoid them as in the last example.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: My Python annoyances

2007-04-28 Thread James Stroud
André wrote:
 I'm really annoyed at Python - and not for the reasons already
 mentioned on this list.
 
 Everyone know that programming is supposed to be a dark art, nearly
 impossible to learn.  Computer code is supposed to be something
 impossible to read to the common person and yet reveal their secrets
 to the initiated - just remember the code displayed in the Matrix...
 
 Python takes all of that away.  It is just too readable.  Even
 beginners can quickly learn to read code written by experts.
 
 To make it even friendlier to beginners, Python uses ugly double
 underscores both as prefix and suffix on magic methods to be invoked
 only by more advanced programmers.   What's the fun in hiding the
 complexity so that beginners can stay away from potential problems.
 
 And why, oh why, does raw_input() have to go?  Here was at least one
 good example of something that gave a hint (what does raw mean?) at
 the underlying complexity.  Combined with the evil of the hidden eval
 in the more obvious input(), there was at least a chance to trip
 beginners into doing something dangerous.  Alas, that will no longer
 be the case...
 
 Python does not even make good use of weird symbols like $ and @ and %
 to define variable types like Perl does.  Now, that's a language to
 learn if you want to be respected.  I think that Georg Brandl had it
 right in his recent proposal:
 http://mail.python.org/pipermail/python-dev/2007-April/072419.html
 
 If not Perl, perhaps Python should be inspired by a language like C++,
 full of arcane stuff and, thankfully, requiring typing declaration.
 This dynamic typing thing makes it just too easy to write working
 programs quickly, especially combined with the ease of use of the
 interpreter.  And this other thing called duck typing is just too
 flexible to use.
 
 No, Python should be more difficult.  It should take a full two
 minutes to compile a Hello World program on a modern computer.
 
 Also, this docstring business has to go.  Any programmer should, as
 a rite of passage, have to spend countless hours reading obscure
 documentation to learn other people's code before finding out what
 methods can be used and how they should be used.  Having to use things
 like dir and help just makes it too easy.
 
 And don't get me started about the absence of curly braces to define
 blocks of code.  What's the fun in making it so darn visually easy to
 define such blocks of code, removing the possibility of creating
 subtle bugs due to the misplacement of a curly bracket.  No sir, with
 Python, the structure has to be obvious at a glance - newbies can see
 it just as well as experts, thereby decreasing the aura surrounding
 the latter.  This is not fair for people that have spent dozens of
 hours in learning to program using Python!
 
 And don't talk to me about functions, classes and methods, not to
 mention modules. Python makes it too easy to write code in many
 different styles, trying to please people who like to write only
 object-oriented code as well as those that follow the more traditional
 procedural approach.  Even functional type people find their way to
 write code in their preferred method using Python.  This is not right.
 
 Fortunately, Python has incorporated some newbie-unfriendly features,
 like metaclasses and, to a lesser extent, decorators which, at last,
 make use of a special character.  There should be more of these, to
 make Python something more challenging to learn.
 
 Programming should be more difficult than this - otherwise, how can
 programmers be respected by the common folks?
 ---
 André
 

I want to complain about the fact that I wrote 200 lines the other day 
and it worked first time. Problem was, I spent 20 minutes before I 
realized that the lack of errors was a result of the lack of bugs.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Video: Professor of Physics Phd at Cal Tech says: 911 Inside Job

2007-04-28 Thread War Office
On 28 abr, 14:15, Eric Gisse [EMAIL PROTECTED] wrote:
 On Apr 24, 6:13 pm, [EMAIL PROTECTED] wrote:

  Cal Tech is the ELITE of ELITE in physics.

 INN World Report interviewed Dr. Crockett Grabbe - professor of
 physics at the University of Iowa - regarding his thoughts on the
 'collapses' of WTC1, WTC2,  WTC7. In this interview he lists numerous
 reasons to suspect controlled demolition and expresses support for
 alternative theories.

 A common mistake - I frequently confuse CalTech and U of Iowa.

 http://scholar.google.com/scholar?hl=enlr=safe=offclient=firefox-a...

 That's interesting, no publications on any engineering topic.

None the less a phyics professor and able to write academic thesis as
proven in his physics publications:
http://www.physics.uiowa.edu/~cgrabbe/writing/research.html

Further from your insult, NIST refuse to give out any of the critical
specifications; such as blueprints and Protec photograph and video of
the debris field. So even if he was  Professor of Engineering he would
not be able to comment as a Professional Engineer  becuase he wouldn't
have access to the necessary information. Yes thats right, Guliani
order the expediant clean up of WTC7 and none of the assigned forensic
engineers even got to analyse the debris as per normal due process.
Don't believe me? Why don't you see the forensic engineers themselves
testify in this History Channel piece on WTC7:
http://www.youtube.com/watch?v=TVSxeJH_RCY



 A
 professor of physics, not engineering, who claims that explosives were
 planted in not only WTC7, but WTC 1 and 2 which were trigged by the
 planes impacting the building.

 Why is anyone listening to this loon?



  If Feynman were alive, he would point his finger straight at the 911
  criminal operators, the yank bastards themselves ...

 I don't recall Feynman ever advocating nutcase positions.



 http://www.911blogger.com/node/8101

  No self-respecting scientist should keep his mouth shut. Its a
  fundamental challenge to the method of science, a detective work most
  demanding of INTELLECTUAL HONESTY.

 I love how folks like you ask for intellectual honesty when every
 effort is made to ignore evidence that doesn't agree with your
 presupposed findings.


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


Re: Interop between C# and Python

2007-04-28 Thread Ravi Teja
On Apr 27, 8:25 pm, urielka [EMAIL PROTECTED] wrote:
 thx i will try this.

 i am also trying XML-RPC,i wrote a basic generator(in python) that
 genrate a Interface from the XML-RPC service module,but maybe with
 soaplib i don`t need this if i use wsdl as Visual Studio can generate
 the code from the wsdl

Typed remoting mechanisms (SOAP, CORBA, ICE etc) tend to be less work
with statically typed languages like C#. Untyped remoting mechanisms
are more convenient to work with dynamic languages (XML-RPC, JSON-RPC
etc). When combining them, typed one are more convenient because
working with typed systems is more convenient in dynamic languages
than it is to work with untyped systems in typed languages. Of course,
if the project is really small, none of this really matters. Pick your
poison.

Ravi Teja.

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


Re: how can I put an Exception as the key of a hash table

2007-04-28 Thread Alex Martelli
[EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

 I want to keep track of the number of different exception happens in
 my python program:
 
 ErrorHash = {}
 
 try:
 
  # come code ...
 
  except Exception, e:
 print e
 errcode = e
 
 if (ErrorHash.has_key(errcode)):
 ErrorFailNo = ErrorHash[errcode]
 
 ErrorHash[errcode] = ErrorFailNo + 1
 
 else:
 ErrorHash[errcode] = 1
 
 
 But when i print out the ErrorHash like this:
 
 print ErrorHash
 
 i get an empty string.  Can you please tell me how can I put an
 Exception as the key of a hash table ? Or how can i dump out all the
 content of the hashtable.

I can't reproduce your problem (using simpler code of course, yours is
wildly redundant and needlessly complicated, though it should be
semantically equivalent):

 errdic = {}
 def f(whatever):
...   try:
... exec(whatever, {})
...   except Exception, e:
... errdic[e] = 1 + errdic.get(e, 0)
... 
 f('(syntax err')
 errdic
{SyntaxError('unexpected EOF while parsing', ('string', 1, 11,
'(syntax err')): 1}
 f('23/0')   
 errdic
{SyntaxError('unexpected EOF while parsing', ('string', 1, 11,
'(syntax err')): 1, ZeroDivisionError('integer division or modulo by
zero',): 1}
 f('23/0')
 errdic
{SyntaxError('unexpected EOF while parsing', ('string', 1, 11,
'(syntax err')): 1, ZeroDivisionError('integer division or modulo by
zero',): 1, ZeroDivisionError('integer division or modulo by zero',): 1}
 

As you can see, the only problem is that two occurrences of the same
error ar kept distinct -- they're distinct instances of the same class
without special hashing or comparison methods, and so are distinct when
considered as keys into a dict.  There are of course ways to collapse
them (e.g, use (type(e), str(e)) as the dict key, or, many others), but
at any rate this does not appear to have anything to do with the problem
you report.

Could you perhaps post a complete, self-sufficient short script or
interactive interpreter session, such as the few lines I've just copied
and pasted above, to help us understand your problem?  (More generally,
http://www.catb.org/~esr/faqs/smart-questions.html has pretty good
advice about how to ask questions the smart way).


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


Re: Video: Professor of Physics Phd at Cal Tech says: 911 Inside Job

2007-04-28 Thread Major Quaternion Dirt Quantum
here's a question that came-up recently,
in battling with the controlled-demo advocates
at teh Promenade:

how is it that the metal was still molten,
after weeks?

it seems taht an additional hypothesis is required,
to explain that. because I doubt that
there was sufficient nukular material
left-over from a hypothetical suitcase-device.

there are similar question,
from what I recall of Jones' report
(I just stopped at the first thing
that seemed funny, today .-)

publications:http://www.physics.uiowa.edu/~cgrabbe/writing/
research.html

   demanding of INTELLECTUAL HONESTY.

thus:
this was basically assuming that
floor 50 of a 100-floor building started the collapse?...
interesting analysis; I hope to look at it, again, later.

have you seen the old analysis by the MIT Head Welder,
that I only saw a couple of weeks ago?

 At time t=0, the top 50 floors begin to fall, independently of each
 other. The first actual impact is when floor 50 hits floor 49. On
 impact, those 2 floors fall together with an initial velocity that is
 less than that of higher floors due to conservation of momentum. Thus
 the next impact will not be floors 50,49 with floor 48 but rather it
 will be floor 51 hitting the slower moving 50,49 combo. The 3 floors
 51,50,49 then become a unit. The initial velocity of the new 51,50,49
 combo will be greater than the velocity of the 50-49 combo just before
 impact, but still less than that of the floors above (which are still
 in free fall).

http://www.rwgrayprojects.com/synergetics/plates/figs/plate01.html

thus:
Global Warning,
an *anonymous* article in an old issue of *National Review*,
the so-called conservative mag of the grotesque Establishment
creature,
William Buckley, was a sort of benignly-spun expose
of the Mont Pelerin Society, the vehicle of British imperialist free
trade,
free beer  free dumb, whose many rightwing affiliate foundations
are always in the news.  the universally-newspaper-lauded-when-
he-died founding president, Mitlon Friedman,
used Sir Henry of Kiss.Ass. to conduct their first experiment
in Chile, with the help of Augusto Pinochet  Dick Nixon.

(the fact that it was an awful failure, with the privatization
of Chile's social security, was only recently mention, but
only before Uncly Milty died.)

I realized, much later, since it was anonymous, that
it was probably taken from The Holy Spook Economist, but
I haven't checked that hypothesis.

yes, Warning was meant to evoke warming, although
nowhere mentioned in the article, as I recall; can you say,
emmissions trading schemes, Boys and Girl?...
can you say, hedge funds on out-of-the-way desert islands?...
Just Desserts Island?

thus:
why do Dick, Borat, Osama, Harry P., Rumsfeld and Tony B. want us
to underwrite the 3rd British Invasion of Sudan,
so badly?

anyway, Bertrand Russel published a jeremyad in the Bulletin
of the Atomic Scientists, while the USA was the only thermonukey
power,
that we should bomb them into the Stone Age;
that's your British pacifist, whether before or after he went nuts
because of Godel's proof.

thus:
if you can't prove that all Fermat numbers are pairwise coprime,
again!

Darfur 'Mini-Summit'
http://www.larouchepub.com/other/1998/rice_2546.html

thus:
uh yeah; Borat wants you in Sudan,
why, Baby?...  Harry Potter wants you in Iran --
yeah, Baby; shag'US with a spoon?

--DARFURIA CONSISTS OF ARABs  nonARABs; NEWS-ITEM:
  we are marching to Darfuria, Darfuria, Darfuria!
Harry Potter IIX, ?Ordeal @ Oxford//Sudan ^ Aircraft Carrier!
http://larouchepub.com/other/2007/3410caymans_hedges.html
ALgoreTHEmovieFORpresident.COM:
http://larouchepub.com/eirtoc/site_packages/2007/al_gore.html

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


Re: My Python annoyances

2007-04-28 Thread Aahz
In article [EMAIL PROTECTED],
=?iso-8859-1?B?QW5kcuk=?=  [EMAIL PROTECTED] wrote:

Programming should be more difficult than this - otherwise, how can
programmers be respected by the common folks?

http://www.netfunny.com/rhf/jokes/98/May/stroustrup.html
-- 
Aahz ([EMAIL PROTECTED])   * http://www.pythoncraft.com/

...string iteration isn't about treating strings as sequences of strings, 
it's about treating strings as sequences of characters.  The fact that
characters are also strings is the reason we have problems, but characters 
are strings for other good reasons.  --Aahz
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: My Python annoyances

2007-04-28 Thread Alex Martelli
James Stroud [EMAIL PROTECTED] wrote:
 André wrote:
   [snipping total repost of André's post]



  I'm really annoyed at Python - and not for the reasons already
  mentioned on this list.
  
  Everyone know that programming is supposed to be a dark art, nearly
  impossible to learn.  Computer code is supposed to be something
  impossible to read to the common person and yet reveal their secrets
  to the initiated - just remember the code displayed in the Matrix...
  
  Python takes all of that away.  It is just too readable.  Even
  beginners can quickly learn to read code written by experts.
  
  To make it even friendlier to beginners, Python uses ugly double
  underscores both as prefix and suffix on magic methods to be invoked
  only by more advanced programmers.   What's the fun in hiding the
  complexity so that beginners can stay away from potential problems.
  
  And why, oh why, does raw_input() have to go?  Here was at least one
  good example of something that gave a hint (what does raw mean?) at
  the underlying complexity.  Combined with the evil of the hidden eval
  in the more obvious input(), there was at least a chance to trip
  beginners into doing something dangerous.  Alas, that will no longer
  be the case...
  
  Python does not even make good use of weird symbols like $ and @ and %
  to define variable types like Perl does.  Now, that's a language to
  learn if you want to be respected.  I think that Georg Brandl had it
  right in his recent proposal:
  http://mail.python.org/pipermail/python-dev/2007-April/072419.html
  
  If not Perl, perhaps Python should be inspired by a language like C++,
  full of arcane stuff and, thankfully, requiring typing declaration.
  This dynamic typing thing makes it just too easy to write working
  programs quickly, especially combined with the ease of use of the
  interpreter.  And this other thing called duck typing is just too
  flexible to use.
  
  No, Python should be more difficult.  It should take a full two
  minutes to compile a Hello World program on a modern computer.
  
  Also, this docstring business has to go.  Any programmer should, as
  a rite of passage, have to spend countless hours reading obscure
  documentation to learn other people's code before finding out what
  methods can be used and how they should be used.  Having to use things
  like dir and help just makes it too easy.
  
  And don't get me started about the absence of curly braces to define
  blocks of code.  What's the fun in making it so darn visually easy to
  define such blocks of code, removing the possibility of creating
  subtle bugs due to the misplacement of a curly bracket.  No sir, with
  Python, the structure has to be obvious at a glance - newbies can see
  it just as well as experts, thereby decreasing the aura surrounding
  the latter.  This is not fair for people that have spent dozens of
  hours in learning to program using Python!
  
  And don't talk to me about functions, classes and methods, not to
  mention modules. Python makes it too easy to write code in many
  different styles, trying to please people who like to write only
  object-oriented code as well as those that follow the more traditional
  procedural approach.  Even functional type people find their way to
  write code in their preferred method using Python.  This is not right.
  
  Fortunately, Python has incorporated some newbie-unfriendly features,
  like metaclasses and, to a lesser extent, decorators which, at last,
  make use of a special character.  There should be more of these, to
  make Python something more challenging to learn.
  
  Programming should be more difficult than this - otherwise, how can
  programmers be respected by the common folks?
  ---
  André
  
 
 I want to complain about the fact that I wrote 200 lines the other day
 and it worked first time. Problem was, I spent 20 minutes before I 
 realized that the lack of errors was a result of the lack of bugs.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Numbers and truth values

2007-04-28 Thread Alex Martelli
John Nagle [EMAIL PROTECTED] wrote:
   ...
  I'd have to consider that a bug.
 
  Some very early FORTRAN compilers allowed you to redefine
 integer constants:
 
   
   CALL SET(25,99)
   WRITE (6,100) 25
  100 FORMAT(I6)
 
   SUBROUTINE SET(IVAR, INEWVAL)
   IVAR = INEWVAL
 
 would print
 
  99
 
  It was generally agreed by 1970 or so that this was a bad idea,
 and was taken out of the language.

It was still perfectly legal in the Fortran 1977 standard for a compiler
to cause this effect, because the Fortran source you quote has
*undefined behavior* -- the compiler doesn't have to diagnose this error
and can cause any effects as a consequence.

The point of Fortran is to let the compiler generate the fastest code it
can, NOT to tenderly hold your hand lest scary bugs disturb your
blessed and dreamy innocence.

If this has changed in the Fortran 1990 standard or later, then I can
only say I'm happy I stopped using Fortran heavily before such standards
became widespread in commonly available compilers -- by the late '90s,
when I was still using _some_ Fortran, it was Fortran '77, as that was
the version that was widely available and well optimized.

Python is not particularly focused on coddling the programmer lest he or
she (horrors!) make a mistake, either; rather, it embodies well 4 of the
5 principles that make up the Spirit of C according to the Preface to
C's ISO Standard -- trust the programmer, don't stop the programmer
from doing what needs to be done, keep the language small and simple
(the 4th one, offer only one way to perform an operation, is not
germane here).  Making the language more complicated (e.g., with more
reserved words) because you _don't_ trust the programmer and badly wants
to stop him/her from doing something is not well consistent with these
principles.  Maybe somebody assigning a value to True or False is a
common error, but much of my livelihood over the last 10 years has been
about mentoring/coaching programmers in Python, and that's one error I
have *NEVER* observed, so I'd need a lot of empirical evidence to
convince me it's worth adding two more reserved words to Python's
reasonably short list (I feel much the same way about None, by the way).
pychecker, pylint, and friends, are a much better way to detect and warn
about all sort of anomalies of this kind.


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


Re: relative import broken?

2007-04-28 Thread Alex Martelli
Alan Isaac [EMAIL PROTECTED] wrote:

 Are relative imports broken in 2.5?
 Directory ``temp`` contains::
 
 __init__.py
 test1.py
 test2.py
 
 File contents:
 __init__.py and test2.py are empty
 test1.py contains a single line::
 
 from . import test2
 
 Python 2.5.1 under Win2000, cmd line execution,
 produces as output::
 
 Traceback (most recent call last):
   File F:\temp\test1.py, line 1, in module
 from . import test2
 ValueError: Attempted relative import in non-package
 
 Why?

If you're running test1.py as your main module, then it's not part of a
package, so the relative import should indeed fail as you mention.
OTOH, something like:

$ python -c'from temp import test1'

from the parent directory of temp should work fine.  Since you don't
give us the exact command line you're trying to execute, it's impossible
to guess exactly what you're doing.


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


Re: python and activeX control

2007-04-28 Thread M�ta-MCI
Bonsoir !

Flagrant délit de manque de confiance dans les newsgroups français en vue...

Ha ! Ha ! Ha !   Bonne chance avec les US...








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


Re: python and activeX control

2007-04-28 Thread vml
On 28 avr, 23:09, Méta-MCI [EMAIL PROTECTED] wrote:
 Bonsoir !

 Flagrant délit de manque de confiance dans les newsgroups français en vue...

 Ha ! Ha ! Ha !   Bonne chance avec les US...

c'est vrai j'avoue ;)

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


Re: Portable SciPy v0.1 released

2007-04-28 Thread Alex Martelli
Beliavsky [EMAIL PROTECTED] wrote:

 On Apr 27, 6:17 pm, Stef Mientki [EMAIL PROTECTED]
 wrote:
  Portable SciPy, is an easy installer of SciPy for M$ windows users.
 
 If you have an announcement for Windows users, I suggest that you not
 needlessly turn them off by abbreviating Microsoft as M$ . You don't
 like Windows, but many of us Windows users don't like the anti-Windows
 snobs. There is nothing wrong with making money by selling software.

Speaking as a Microsoft stockholder, and having recently broken out the
champagne because MSFT is finally back over $30 again [1] (and hoping
this time is STAYS that way, as opposed to the flash-in-the-pan at the
end of January) I'm perfectly happy with seeing $ associated to
Microsoft, for a change.  I entirely agree about making money by selling
software, and indeed that's why I'm a stockholder -- now if you could
just convince Ballmer and friends that making money by selling SW is
better than losing money by failing to sell online ads and music players
(and just about breaking even with videogame HW, thanks be for Sony's
incredible mistakes in the field that allowed Microsoft to stay above
water) then I won't be the only MSFT stockholder to want to offer you a
steak dinner (warning: excess of steak dinners might raise your LDL
cholesterol!-).

Microsoft can still make kick-ass software, if need be by hiring the
right people, and they proved it well with IronPython, IMHO.  They
obviously _can't_ do as well in HW and online services; if they stopped
throwing good money after bad, and instead raised the dividend and
renewed and increased the stock-repurchase program, that would be great
for the economy of Western France (and Catalunya, for those who prefer
cava, etc -- basically, all regions that export champagne!-).


Alex

[1] yah, I do remember MSFT flirting with $60 [considering the early'03
split] at the end of '99 -- that was just Wall Street being crazy, and
the fall from THOSE heights is NOT any fault of Microsoft's management.
The interminable last 5+ years below $30, OTOH...

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


Re: editing scripts on a mac

2007-04-28 Thread Alex Martelli
Michael Bentley [EMAIL PROTECTED] wrote:
   ...
 highlighting for Python (and most everything else).  But both Text  
 Edit and nano are dead easy for noobs.

TextMate, a shareware program, is also widely appreciated -- it has
pretty good support for many languages, including Python.

Personally, I swear by VIM (the full downloaded version with GUI support
and everything, see http://macvim.org/OSX/index.php) but unless you
like the general approach of vi I guess you're more likely to swear AT
it than BY it:-).


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


Re: Numbers and truth values

2007-04-28 Thread Szabolcs
Alex Martelli wrote:
 Maybe somebody assigning a value to True or False is a
 common error, but much of my livelihood over the last 10 years has been
 about mentoring/coaching programmers in Python, and that's one error I
 have *NEVER* observed, so I'd need a lot of empirical evidence to
 convince me it's worth adding two more reserved words to Python's
 reasonably short list (I feel much the same way about None, by the way).
 pychecker, pylint, and friends, are a much better way to detect and warn
 about all sort of anomalies of this kind.

Yes, I admit that it was a very stupid mistake. (Though I'm not even 
sure that this is what happened. Next time I should probably sleep on 
it, and try it again the next day, to avoid posting such a stupid 
question again.) But note that I was using Python interactively (just 
experimenting with it). It is very unlikely that someone would write 
things like True == 2 without any additional context in a real program. 
(Actually it is unlikely that someone would write this in any 
circumstance in a real program.)

But I still think that it is an inconsistency to allow to redefine a 
_value_ like True or False (not a built-in function that may have been 
missing in earlier versions). Saying True = 2 is just like saying 3 = 2.

Learning about pylint was very useful (thanks for the advice!) -- it 
helps in catching those kinds of errors that surface only at runtime in 
Python programs, but are easily caught at compile time in compiled 
languages.
-- 
http://mail.python.org/mailman/listinfo/python-list


Platform-dependent module search order?

2007-04-28 Thread John Machin
On Apr 29, 5:04 am, Theo v. Werkhoven [EMAIL PROTECTED]
werkhoven.nl.invalid wrote:
 The carbonbased lifeform John Machin inspired comp.lang.python with:



  On Apr 28, 9:50 pm, Theo v. Werkhoven [EMAIL PROTECTED]
  werkhoven.nl.invalid wrote:
  Goodday,

  strg = array(B,octarray).tostring()

  The above statement appears to be where the error manifests itself.
  Possibilities: (1) array is bound to a list (2) the result of
  array(B, octarray) has an attribute tostring which is bound to a
  list. Option (1) seems less implausible. I'd be replacing that line
  by:

  print octet %r, shift %r, array %r % (octet, shift, array)
  array_b = array(B, octarray)
  print array_b %r % array_b
  print array_b.tostring %r % array_b.tostring
  strg = array_b.tostring()

  You haven't shown us all of your code -- is array mentioned elsewhere?
  What other imports are you doing? Do you have a file called array.py
  in the offending directory? [I believe that this wouldn't matter,
  because builtin modules like array can't be overridden by a file-based
  module of the same name, but I could be wrong]

 Bingo!
 #v+
 theo:/home/theo/Devel/Python $ ls array*
 array.py  array.pyc

 theo:/home/theo/Devel/Python $ cat array.py
 #!/usr/bin/python

 import sys, os

 array = [14, 8765, 756, 5345, 98, 5634654, 234123, 9087, 58, 297, 7865]
 num = 0

 while 1:
 try:
 print num
 num = num + array.pop()
 except:
  break
 #v-
 And that code produces the numbers I was seeing..

  What platform and what version of Python?

 $ python --version
 Python 2.5

 $ uname -srv
 Linux 2.6.18.8-0.1-default #1 SMP Fri Mar 2 13:51:59 UTC 2007

Very interesting. My first reaction to Theo's posting was to make a
confident declaration like Carsten did, but I couldn't simulate this
behaviour on Windows with Python 2.5.1 (or 2.1.3 for that matter) and
moreover the docs say:

Details of the module searching and loading process are implementation
and platform specific. It generally involves searching for a ``built-
in'' module with the given name and then searching a list of locations
given as sys.path.

(from http://docs.python.org/ref/import.html)

I'm now curious about the rationale for having/permitting such a
difference.

Here's what I get on Windows XP Pro SP2 with Python 2.5.1:
8---
C:\junktype array.py
print Gotcha!

C:\junktype arrayimport.py
import sys, pprint
print 'sys.path:'
pprint.pprint(sys.path)
import array
print 'array: %r' % array
C:\junk\python25\python arrayimport.py
sys.path:
['C:\\junk',
 'C:\\python25\\lib\\site-packages\\cheesecake-0.6.1-py2.5.egg',
 'C:\\python25\\lib\\site-packages\\setuptools-0.6c5-py2.5.egg',
 'C:\\python25\\python25.zip',
 'C:\\python25\\DLLs',
 'C:\\python25\\lib',
 'C:\\python25\\lib\\plat-win',
 'C:\\python25\\lib\\lib-tk',
 'C:\\python25',
 'C:\\python25\\lib\\site-packages']
array: module 'array' (built-in)
8--

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


CPython vs. Jython/JPython

2007-04-28 Thread Sean McCallister
Is this stephen coursen, once married to michelle coursen from linden NJ?
-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   >