Re: How to test that an exception is raised ?

2005-01-31 Thread Antoon Pardon
Op 2005-01-28, StepH schreef <[EMAIL PROTECTED]>:
> Antoon Pardon a écrit :
>> Op 2005-01-28, StepH schreef <[EMAIL PROTECTED]>:
>> 
>>>Thanks for you answer.
>>>I'm new to Python (coming from C/C++).
>>>
>>>Do you say that it's not possible to test (using unittest) if an exception
>>>is well raised if the tested code catch it ?
>>>How to solve this paradoxe ?  How to automaticaly test such code ?
>> 
>> 
>> IMO you want something unittest are not designed for.
>
> So why the assertRaises function in unittest?

To see if an exception is propagated to the caller.

> My goal is to test if an 
> exception is well raised when a bad filename is passed to the mps2xml 
> function.

>> Unittest are supposed to test for particular results, not for particular
>> behaviour within. If the expected behaviour is that calling code doesn't
>> see an exception raised, then the test passed if no exception was seen.
>> 
>
> No (unless i don't well understand you), the expected behavior is to 
> launch an exception if a bad filename is passed.  If no exception is 
> raised, this is not normal.

What do you mean with launch an exception? Should the exception
propagate to the caller or not? If it should your code was wrong
to catch it.

>> You equally can't test which branch of an if statement was taken or
>> which parameter was given to a helper function in order to get to
>> the desired result.
>
> I'm agree with out on this point, but not for the exception part...

Why not? Exceptions are nothing special. Either you want to propagated
them to the caller, in which case they can be seen as somekind of result
and this can be tested for with a unittest or you don't want them to
be propagted and then they are just an implementation detail of your
unit.

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


Re: variable declaration

2005-01-31 Thread Peter Otten
Alexander Zatvornitskiy wrote:

> epsilon=0
> S=0
> while epsilon<10:
>   S=S+epsilon
>   epselon=epsilon+1
> print S
> 
> It will print zero, and it is not easy to find such a bug!

pychecker may help you find misspelled variable names. You have to move the
code into a function, though:

$ cat epsilon.py
def loop():
epsilon=0
S=0
while epsilon<10:
S=S+epsilon
epselon=epsilon+1
print S

$ pychecker epsilon.py
Processing epsilon...

Warnings...

epsilon.py:6: Local variable (epselon) not used

Peter

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


COM on a network drive can't find pywintypes23.dll

2005-01-31 Thread Marco Aschwanden
Hi
I have installed Python (2.3.4) on a shared network drive. I use it to run  
a bunch of application on the workstations (Win2K).

Now I am running into the first problem ever. I try to use COM to generate  
a word-file. It runs fine on my machine (Python installed locally). When I  
deploy it and start the app on another workstation from the fileserver -  
it runs but as soon as it comes to the COM part it exits saying:

The procedure entry point  
?PyWinObject_AsDEVMODE@@YAHPAU_object@@PAPAU_devicemodeA@@[EMAIL PROTECTED] could not be  
located in the dynamic link library pywintypes23.dll

Heck... I copied the files:
pythoncom23.dll
pywintypes23.dll
to about "1000" locations to make it run (Application's dir, Workstation's  
System Dirs, Fileserver's Python main and bin dir, ...). I tried setting  
the path on the workstations. But nothing seems to solve the problem.

Do you have any proposals how to solve this problem?
Thanks in advance,
Marco
--
http://mail.python.org/mailman/listinfo/python-list


Re: Nested scopes and class variables

2005-01-31 Thread [EMAIL PROTECTED]
To me it seems you should do it something like this:
-def f(x):
-class C(object):
-def __init__(self, x):
-self.x = x # here you set the attribute for class C
-c = C(x) # instantiate a C object
-print c.x

-f(5)

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


Re: Nested scopes and class variables

2005-01-31 Thread Nick Coghlan
Dave Benjamin wrote:
I ran into an odd little edge case while experimenting with functions that
create classes on the fly (don't ask me why):
It gets even kookier:
Py> x = 5
Py> def f(y):
...   class C(object):
... x = x
...   print C.x
...
Py> f(5) # OK with x bound at global
5
Py> def f(x):
...   class C(object):
... x = x
...   print C.x
...
Py> f(6) # Oops, ignores the argument!
5
Py> def f(y):
...   class C(object):
... x = y
...   print C.x
...
Py> f(6) # OK with a different name
6
Py> y = 5
Py> def f(y):
...   class C(object):
... x = y
...   print C.x
...
Py> f(6) # Correctly use the nearest scope
6
That second case is the disturbing one - the class definition has silently 
picked up the *global* binding of x, whereas the programmer presumably meant the 
function argument.

With a nested function definition (instead of a class definition), notice that 
*both* of the first two cases will generate an UnboundLocalError.

Anyway, the Python builtin disassembler is very handy when looking at behaviour 
like this (I've truncated the dis output below after the interesting section):

Py> import dis
Py> def f1(x):
...   class C(object):
... x = x
...   print C.x
...
Py> def f2(y):
...   class C(object):
... x = y
...   print C.x
...
Py> dis.dis(f1)
  2   0 LOAD_CONST   1 ('C')
  3 LOAD_GLOBAL  0 (object)
  6 BUILD_TUPLE  1
  9 LOAD_CONST   2 (", line 2>)
[...]
Py> dis.dis(f2)
  2   0 LOAD_CONST   1 ('C')
  3 LOAD_GLOBAL  0 (object)
  6 BUILD_TUPLE  1
  9 LOAD_CLOSURE 0 (y)
 12 LOAD_CONST   2 (", line 2>)
[...]
Notice the extra LOAD_CLOSURE call in the second version of the code. What if we 
define a function instead of a class?:

Py> def f3(x):
...   def f():
... x = x
... print x
...   f()
...
Py> def f4(y):
...   def f():
... x = y
... print x
...   f()
...
Py> dis.dis(f3)
  2   0 LOAD_CONST   1 (", line 2>)
[...]
Py> dis.dis(f4)
  2   0 LOAD_CLOSURE 0 (y)
  3 LOAD_CONST   1 (", line 2>)
[...]
Again, we have the extra load closure call. So why does the function version 
give us an unbound local error, while the class version doesn't?. Again, we look 
at the bytecode - this time of the corresponding internal code objects:

Py> dis.dis(f1.func_code.co_consts[2])
  2   0 LOAD_GLOBAL  0 (__name__)
  3 STORE_NAME   1 (__module__)
  3   6 LOAD_NAME2 (x)
  9 STORE_NAME   2 (x)
 12 LOAD_LOCALS
 13 RETURN_VALUE
Py> dis.dis(f3.func_code.co_consts[1])
  3   0 LOAD_FAST0 (x)
  3 STORE_FAST   0 (x)
  4   6 LOAD_FAST0 (x)
  9 PRINT_ITEM
 10 PRINT_NEWLINE
 11 LOAD_CONST   0 (None)
 14 RETURN_VALUE
In this case, it's the LOAD_FAST opcode that blows up, while the LOAD_NAME falls 
back on the globals and then the builtins. Looking at the class based version 
that works also lets us see why:

Py> dis.dis(f2.func_code.co_consts[2])
  2   0 LOAD_GLOBAL  0 (__name__)
  3 STORE_NAME   1 (__module__)
  3   6 LOAD_DEREF   0 (y)
  9 STORE_NAME   3 (x)
 12 LOAD_LOCALS
 13 RETURN_VALUE
Here we can see the "LOAD_DEREF" instead of the "LOAD_NAME" that was present in 
the version where the same name is reused. The dereference presumably picks up 
the closure noted earlier.

I vote bug. If the assignment is going to be allowed, it should respect the 
nested scopes.

Cheers,
Nick.
--
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---
http://boredomandlaziness.skystorm.net
--
http://mail.python.org/mailman/listinfo/python-list


Re: Dynamic class methods misunderstanding

2005-01-31 Thread TZOTZIOY
On Sat, 29 Jan 2005 10:24:27 +0100, rumours say that [EMAIL PROTECTED]
(Alex Martelli) might have written:

>Bill Mill <[EMAIL PROTECTED]> wrote:
>   ...
>> > class Test:
>> > def __init__(self, method):
>> > self.m = new.instancemethod(method, self, Test)
>> 
>> Beautiful! thank you very much. Looking into the "new" module in
>> python 2.4, that's equivalent to:
>> 
>> self.m = type(self.__init__)(method, self, Test)

>Another approach with the same result is to exploit the fact that a
>function is a descriptor:
>
>self.m = method.__get__(self, Test)

Almost true; not all builtin functions are descriptors though.

.>> import new
.>> f= new.instancemethod(divmod, 7, object)
.>> map(f, range(1,10,2))
[(7, 0), (2, 1), (1, 2), (1, 0), (0, 7)]
.>> f= divmod.__get__(7)

Traceback (most recent call last):
  File "", line 1, in -toplevel-
f= divmod.__get__(7)
AttributeError: 'builtin_function_or_method' object has no attribute
'__get__'

I didn't run an extensive test, but it's possible that all builtin
functions are not descriptors.
-- 
TZOTZIOY, I speak England very best.
"Be strict when sending and tolerant when receiving." (from RFC1958)
I really should keep that in mind when talking with people, actually...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: COM on a network drive can't find pywintypes23.dll

2005-01-31 Thread Roger Upole
This means the machine is finding an older verion
of pywintypes23.dll first, rather than not finding it at all.
You may have an old version hanging around in the
\system32 directory on that machine.  (or anywhere else
that it would be found first).  You might also want to
verify that the dll's you're copying around both come
from the same distribution.

 Roger

"Marco Aschwanden" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Hi
>
> I have installed Python (2.3.4) on a shared network drive. I use it to run 
> a bunch of application on the workstations (Win2K).
>
> Now I am running into the first problem ever. I try to use COM to generate 
> a word-file. It runs fine on my machine (Python installed locally). When I 
> deploy it and start the app on another workstation from the fileserver - 
> it runs but as soon as it comes to the COM part it exits saying:
>
> The procedure entry point 
> ?PyWinObject_AsDEVMODE@@YAHPAU_object@@PAPAU_devicemodeA@@[EMAIL PROTECTED] 
> could not be 
> located in the dynamic link library pywintypes23.dll
>
>
> Heck... I copied the files:
>
> pythoncom23.dll
> pywintypes23.dll
>
> to about "1000" locations to make it run (Application's dir, Workstation's 
> System Dirs, Fileserver's Python main and bin dir, ...). I tried setting 
> the path on the workstations. But nothing seems to solve the problem.
>
> Do you have any proposals how to solve this problem?
>
> Thanks in advance,
>
> Marco
> 




== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 
Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Nested scopes and class variables

2005-01-31 Thread Nick Coghlan
[EMAIL PROTECTED] wrote:
To me it seems you should do it something like this:
-def f(x):
-class C(object):
-def __init__(self, x):
-self.x = x # here you set the attribute for class C
-c = C(x) # instantiate a C object
-print c.x
-f(5)
That does something different - in this case, x is an instance variable, not a 
class variable.

You do raise an interesting questions though:
Py> def f(x):
...   class C(object):
... x = None
... def __init__(self):
...   if C.x is None:
... C.x = x
...   C()
...   print C.x
...
Py> x = 5
Py> f(6)
6
So, the real problem here is the interaction between the ability to write 
" = " in a class definition with the reference on the RHS being 
resolved in the global namespace and nested scopes (since that first lookup does 
NOT respect nested scopes).

Functions don't have the problem, since they don't allow that initial lookup to 
be made from the outer scope.

Cheers,
Nick.
--
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---
http://boredomandlaziness.skystorm.net
--
http://mail.python.org/mailman/listinfo/python-list


Re: Dynamic class methods misunderstanding

2005-01-31 Thread Alex Martelli
Christos TZOTZIOY Georgiou <[EMAIL PROTECTED]> wrote:
   ...
> >> > class Test:
> >> > def __init__(self, method):
> >> > self.m = new.instancemethod(method, self, Test)
   ...
> >self.m = method.__get__(self, Test)
> 
> Almost true; not all builtin functions are descriptors though.
   ...
> AttributeError: 'builtin_function_or_method' object has no attribute
> '__get__'
> 
> I didn't run an extensive test, but it's possible that all builtin
> functions are not descriptors.

Indeed, many callables (builtin-functions, types, ...) are not
descriptors, so you can't call __get__ on them.  But then, many
descriptors (statimethods, classmethods, ...) are not callable, so you
can't pass them as the first argument to instancemethod.  Not having any
indication of what the author of class Test means to pass in as
"method", it's not clear whether Test(divmod) or Test(staticmethod(foo))
is more likely to be of interest to them as a use case.  If ``method''
is a function, which is both a descriptor AND callable, either approach
works; otherwise, one has to pick an approach, or try both approaches
with a try/except.


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


Re: test_socket.py failure

2005-01-31 Thread Nick Coghlan
[EMAIL PROTECTED] wrote:
 hi all,
 Linux 2.4.28
 Glibc 2.2.5
 gcc   2.95.3
 I'm new to Python.
 I've compiled Python 2.4 from tar file.
 When running 'make test' i'm getting a failure
 in test_socket.
Two questions. First, what does the following code give when you run it at the 
interactive prompt?:

Py> import socket
Py> socket.getservbyname('daytime')
13
Second, is there an entry for 'daytime' in /etc/services?
Cheers,
Nick.
--
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---
http://boredomandlaziness.skystorm.net
--
http://mail.python.org/mailman/listinfo/python-list


Re: Nested scopes and class variables

2005-01-31 Thread Alex Martelli
Dave Benjamin <[EMAIL PROTECTED]> wrote:

> I ran into an odd little edge case while experimenting with functions that
> create classes on the fly (don't ask me why):

"Why not?".  But classes have little to do with it, in my view.


>   >>> def f(x):
>   ...   class C(object):
>   ... x = x

You bind x, so x is local (to the class), not free.  Videat, classless:

>>> def f(x):
...   def g():
... x=x
... return x
...   return g
... 
>>> z=f(23)
>>> z()
Traceback (most recent call last):
  File "", line 1, in ?
  File "", line 3, in g
UnboundLocalError: local variable 'x' referenced before assignment

In this example the error is discovered when the body of g executes; in
your case, the body of C executes as part of the class statement, i.e.
when f is called, so the error is discovered earlier.

> "x" clearly is defined, but apparently Python is not looking at the nested
> variable scope to find it. What's stranger is that if I rename the parameter
> "x" to "y", the error goes away:

Why is this strange?  There's no name conflict then.

> So, it's not like nested scopes aren't supported in the class block. Rather,
> when it sees "x = x", it seems like Python is determining at that point that
> "x" is a class variable, and refuses to search any further.

That's like saying that nested scopes aren't supported in a function...
when Python sees "x = x", etc etc.

> At the top-level, it works as expected:
> 
>   >>> x = 5
>   >>> class C(object):
>   ...   x = x
>   ...
>   >>> C.x
>   5
> 
> Any implementation gurus have some insight into what's going on here?

Class bodies and function bodies are compiled slightly differently,
leading to a "handy specialcasing" of globals in the latter example
which is probably what's confusing you.  OK, let's try digging into more
detail:

>>> def f(x):
...   class C:
... x = x
...   return C
... 
>>> dis.dis(f)
  2   0 LOAD_CONST   1 ('C')
  3 BUILD_TUPLE  0
  6 LOAD_CONST   2 (", line 2>)
  9 MAKE_FUNCTION0
 12 CALL_FUNCTION0
 15 BUILD_CLASS 
 16 STORE_FAST   1 (C)

  4  19 LOAD_FAST1 (C)
 22 RETURN_VALUE

this shows you where the codeobject for C's body is kept -- constant
number two among f's constants.  OK then:

>>> dis.dis(f.func_code.co_consts[2])
  2   0 LOAD_GLOBAL  0 (__name__)
  3 STORE_NAME   1 (__module__)

  3   6 LOAD_NAME2 (x)
  9 STORE_NAME   2 (x)
 12 LOAD_LOCALS 
 13 RETURN_VALUE

Compare with:

>>> def f(x):
...   def g():
... x = x
... return x
...   return g
... 
>>> dis.dis(f)
  2   0 LOAD_CONST   1 (", line 2>)
  3 MAKE_FUNCTION0
  6 STORE_FAST   1 (g)

  5   9 LOAD_FAST1 (g)
 12 RETURN_VALUE
>>> 

and:

>>> dis.dis(f.func_code.co_consts[1])
  3   0 LOAD_FAST0 (x)
  3 STORE_FAST   0 (x)

  4   6 LOAD_FAST0 (x)
  9 RETURN_VALUE


See the difference?  In a function, the 'x = x' compiles into LOAD_FAST,
STORE_FAST, which only looks at locals and nowhere else.  In a
classbody, it compiles to LOAD_NAME, STORE_NAME, which looks at locals
AND globals -- but still not at closure cells...


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


Re: The next Xah-lee post contest

2005-01-31 Thread Steve Holden
[EMAIL PROTECTED] wrote:
Tragi-comic.  really.  BTW you forgot cross-post to c.l.scheme, C,
smalltalk and C++
Would there, I wonder, be any enthusiasm for a "Best Xah Lee impression" 
prize at PyCon?

regards
 Steve
--
Steve Holden   http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
Holden Web LLC  +1 703 861 4237  +1 800 494 3119
--
http://mail.python.org/mailman/listinfo/python-list


Re: variable declaration

2005-01-31 Thread Alex Martelli
Alexander Zatvornitskiy
<[EMAIL PROTECTED]> wrote:

> Hello All!
> 
> I'am novice in python, and I find one very bad thing (from my point of
> view) in language. There is no keyword or syntax to declare variable, like
> 'var' in

Since the lack of declarations is such a crucial design choice for
Python, then, given that you're convinced it's a very bad thing, I
suggest you give up Python in favor of other languages that give you
what you crave.  The suggestions about using pychecker, IMHO, amount to
"band-aids" -- the right way to deal with minor annoying scratches, but
surely not with seriously bleeding wounds, and your language ("very bad
thing", "very ugly errors") indicates this is a wound-level issue for
you.  Therefore, using Python, for you, would mean you'd be fighting the
language and detesting its most fundamental design choice: and why
should you do that?  There are zillions of languages -- use another one.

> Pascal, or special syntax in C. It can cause very ugly errors,like this:
> 
> epsilon=0
> S=0
> while epsilon<10:
>   S=S+epsilon
>   epselon=epsilon+1
> print S
> 
> It will print zero, and it is not easy to find such a bug!

Actually, this while loop never terminates and never prints anything, so
that's gonna be pretty hard to ignore;-).  But, assume the code is
slightly changed so that the loop does terminate.  In that case...:

It's absolutely trivial to find this bug, if you write even the tiniest
and most trivial kinds of unit tests.  If you don't even have enough
unit tests to make it trivial to find this bug, I shudder to think at
the quality of the programs you code.  Even just focusing on typos,
think of how many other typos you could have, besides the misspelling of
'epsilon', that unit tests would catch trivially AND would be caught in
no other way whatsoever -- there might be a <= where you meant a <, a
1.0 where you meant 10, a - where you meant a +, etc, etc.

You can't live without unit tests.  And once you have unit tests, the
added value of declarations is tiny, and their cost remains.

A classic reflection on the subject by Robert Martin, a guru of C++ and
other languages requiring declarations, is at:
.

 
> Even Visual Basic have 'Option Explicit' keyword! May be, python also have
> such a feature, I just don't know about it?

Python has no declarations whatsoever.  If you prefer Visual Basic, I
strongly suggest you use Visual Basic, rather than pining for Visual
Basic features in Python.  If and when your programming practices ever
grow to include extensive unit-testing and other aspects of agile
programing, THEN you will be best advised to have a second look at
Python, and in such a case you will probably find Python's strengths,
including the lack of declarations, quite compelling.

Some people claim a language should change the way you think -- a
frequent poster, excellent Python contributor, and friend, even has that
claim in his signature.  That may be alright in the groves of academia.
If you program to solve problems, rather than for personal growth, on
the other hand, changing "the way you think" with each programming
language is a rather steep price to pay.  As a pragmatist, I prefer a
motto that I've also seen about Python: "it fits your brain".  I find
it's true: Python gets out of my way and let me solve problems much
faster, because it fits my brain, rather than changing the way I think.

If Python doesn't fit YOUR brain, for example because your brain is
ossified around a craving for the declaration of variables, then, unless
you're specifically studying a new language just for personal growth
purposes, I think you might well be better off with a language that
DOES, at least until and unless your brain changes by other means.


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


½Ã°£¿¡ ´ëÇÑ ¸í¾ð

2005-01-31 Thread °Ç°­ÇÑ»ç¶÷

  
  
¾È³çÇϼ¼¿ä ^^; ¹Ý°©½À´Ï´Ù..
¿ì¸® Ŭ·´À» ¼Ò°³ÇÕ´Ï´Ù. [¿ÏÀüºñ¿µ¸®¿î¿µ][¼ø¼öÇÏ°Ô À£ºùÁ·¸¸ ¿À¼Å¿ä]
wonkiup.cyworld.com
1ºÐÀ̸é 10³âÀ» Àþ°í °Ç°­ÇÏ°Ô »ìºñ°áÀ» µå¸³´Ï´Ù.
¿À¼Å¼­ Á¤º¸ ¸¶´Ï ¸¶´Ï ¾ò¾î°¡¼¼¿ä.
 
¾î·Á¿ï¶§ Àϼö·Ï ¿ìÁÖ¿¡³ÊÁö(Ѩ)¸¦ ¹ÞÀ¸½Ã¸é ¿îÀÌ ¿­¸³´Ï´Ù.Ѩ°¡ ¾øÀ¸¸é ¿îµµ¾ø´Ù.
Ѩ°¡ ÀÖÀ¸¸é ¿îµµ¿Â´Ù.
ê¡ÀÌ ÀÖÀ¸¸é °Ç°­µµ¿Â´Ù.
À£ºùÀ» ÁöÇâÇÏ´Â »ç¶÷µéÀÇ ¸ðÀÓ 
 
[À£ºù]°Ç°­»îÀÇ ¸ð½Àµé [À£ºù]°Ç°­ÇÑ»îÀÇ »ó½Äµé [À£ºù]°Ç°­ÇÑ»îÀÇ Áö¸§±æ [À£ºù]¸í¾ðÀ» ³ª´¯½Ã´Ù!! 
[À£ºù]¾Ë½ö´Þ½ö ÄûÁî~ [ÀÚ·á½Ç]±×¸² 
[ÀÚ·á½Ç]¸¸È­¸¸Æò~*^^*  [³»À£¼Ò]³» À£ºù Àü·«? 
³ª¸¸ÀÇ Á¤½Å¼¼°è¸¦ ±×·Á¿ä 
ÀÚÀ¯°Ô½ÃÆÇ 
°°ÀÌ °øÀ¯ÇØ¿ä~~ 
¿ì¸® ÀÏÃÌÇØ¿ä~ 
Ŭ·´»ç¿ëÈı⸦ ½áÁÖ¼¼¿ä 
 
[°Ç°­]¹æÁß¼úÀÇ 7°¡Áö ºñ¹Ð   2  120 [°Ç°­]È÷¶õ¾ß¶õ?   5
 119 [Á¤º¸]È÷¶õ¾ß ÀÛµµ¹ý   4  118 [Á¤º¸]È÷¶õ¾ßÀÇ ÀÌ»óÇÑ
È¿°ú   2  117 [Á¤º¸]ÇǶó¹Ô¾È¿¡¼­ ¼Ò¿øÀ̳ª ±âµµ´Â ÀÌ·ç¾îÁø´Ù.   2
 116 [Á¤º¸]ÇǶó¹ÌµåÀ°°¢¼ö Á¦Á¶¿Í À°°¢¼ö°Ç°­¹ý    2  115 [Á¤º¸]ÁöÀü·ùÀÇ
Á¤ÀÇ¿Í Â÷´Ü¹æ¹ý   3  114 [Á¤º¸]½Åºñ½º·± ¼öÁ¤À̾߱⠠ 3  113
[½Åºñ] Çö´ëÀÇ ÃÊ´É·ÂÀڵ頠 3  112 [Àھưè¹ß]¿ì³ú°è¹ßÀº ÃÊ´É·ÂÀ» ¸¸µé¾î ³½´Ù.  
3  111 [Á¤º¸]ÇÚµåÆù ÀüÀÚÆÄ Á¤¸» ¹®Á¦Àε¥...   3  110
[°Ç°­/ÀáÀÚ¸®]¾î¶²»ç¶÷µéÀº ²ÞÀ» ÀÚÁÖ²Û´Ù°í ÇÏ´øµ¥...   3  109 [½Åºñ]ûÁÖº´¿ø¿¡¼­
ÀÖ¾ú´øÀÏ...   2  108 [Á¤º¸]´ëÇѹα¹Àº ¾î¶² ÅÍÀΰ¡?   2
 107 [Á¤º¸]ŸÀ̰ſìÁîÀÇ ¼º°øºñ°áÀº... 
 [Á¤º¸]¿ì¸® Áý(¹æ) ¼ö¸Æ ÀÚ°¡Áø´Ü¹ý   1  105 [°Ç°­Á¤º¸]¼ö¸Æ
¿¹¹æ¹ýÀº?   2  104 [°Ç°­]¼ö¸Æ°ú »ýȰ   2  103 [°Ç°­]¼ö¸Æ
°ú ÀáÀÚ¸®   3  102 [Á¤º¸]´ë±â¾÷¿¡ Ãë¾÷ÇÏ´Â ±æ?   3  101
Ѩ¿Í °Ç°­ ±×¸®°í Çູµ¿È£È¸   3  100 [ÇнÀ]Àΰ£ÀÇ ´É·ÂÀ» 200¹è ¹ßÈÖÇÏ´Â ¹ý  
3  98 [½Åºñ]ÇǶó¹Ìµå¶õ?   2  97 [¼ö¸ÆÀÚ°¡Áø´Ü]±è´ëÁß Àü´ëÅë·É°ú
¼ö¸Æ...   2  96 ±â(Ѩ)ÃøÁ¤ÆäÀÌÆÛ¸¦ ¹«·á·Î ÁÖ´Â °÷ÀÔ´Ï´Ù!! [1]   
6  94 ¼ö¸ÆÆÄ ¿¹¹æ¹ý   3  93 [±Ý¿¬Á¤º¸]ÇǶó¹Ô¾È¿¡ ÇÏ·çµÎ¾ú´Ù°¡ ÇÇ¸é ¾ÆÁÖ
¼øÇØÁ®..   2  92 [»îÀÇÁöÇý]°øÇØ.ÇÇ·Î.½ºÆ®·¹½º¿¡ ¸Ûµç Çö´ëÀÎÀÇ
°Ç°­¹ý.    2  91 [°Ç°­]¼ö¸ÆÀÌ...   2  90 [³»¸öÀº
³»°¡ÁöŲ´Ù]ų¸®¾È »çÁøÀ̶õ? Ѩ¿¡³ÊÁö Áõ¸íÇÏ´Ù.    
 
 88 Ű½ºÀÇ Á¾·ù~ [1]    5  87 ¹æ±Í³¿»õ·Î °Ç°­À»
üũÇÑ´Ù??   3  86 [°øÁö]°°ÀÌ °øÀ¯ÇØ¿ä´Â?   6  85
[¸í»ó/¼ö·Ã]À±È¸´Â ¾ø´Ù.!!   3  84 [°Ç°­/Ä¡À¯]Ƽºª Àǻ翡°Ô ¸ÆÀ» ÀâÈ÷°í
½Í´Ù...   3  83 [ÀÚ±â°è¹ß/Àھƹ߰ß]°¨Á¤ ÀÇ»ç¼ÒÅëÀÇ 6°¡Áö Á¢±Ù¹ý   5
 82 [»îÀÇ ÁöÇý]ÇູÇÑ ¹Ùº¸ ¹°¶ó ³ª¸£·çµò,öÇÐÀÚ¿Í ³íÀïÇÏ´Ù.   3  81
[¿µ¼º/»ýÅÂ/½Å¹®¸í]ÇÁ¶õü½ºÄÚÀÇ [žçÀÇ Âù°¡]   3  80 [°øÁö]ÀÌ °Ô½ÃÆÇÀº?   7
 79 [°Ç°­º¸°¨]À߸ÔÀ¸¸é ºñ¾Æ±×¶ó?! û±¹Àå~   5  78 [½Ç¹Ù ¸¶Àεå ÄÁÆ®·ÑÀÇ '²Þ
Á¶Àý¹ý']²ÞÀ» Á¶ÀýÇÏ¸é »õ·Î¿î »îÀÌ ¿­¸°´Ù.   3  77 [Áúº´°ü¸®]¸¸º´ÅëÄ¡ÀÇ ¹¦¾à   3
 76 [dz¼ö ÀÎÅ׸®¾î]Á¶±Ý¸¸ ½Å°æ¾²¸é ¿ì¸® Áýµµ ¸í´çÀÌ µÈ´Ù.   3  75 [°Ç°­ÇÑ]´ç½ÅÀÌ
¿øÇÏ´Â »îÀ» ¼³°èÇϱâ:12´Ü°è   74 [°Ç°­ÇÑ]À̹ÌÁö°¡ ¹Ù²î¸é »õ»óµµ º¯ÇÑ´Ù~!   3 
 73 [°Ç°­ÇÑ]ÀáÀç Àǽļӿ¡ »õ·Î¿î ¹ÏÀ½ »õ±â±â...!   3  72
[°Ç°­ÇÑ]MIND POWER!!³»¸éÀÇ ¼¼°è¸¦ ´Ù½º·Á¶ó~   3  71 [°Ç°­ÇÑ]´ç½ÅÀÌ ¿øÇÏ´Â »îÀ»
°áÁ¤Ç϶ó...!   2  70 [°Ç°­ÇÑ]Á¤¸» ¿øÇÏ´Â °ÍÀº °á±¹ ¾ò°Ô µÉ°ÍÀÌ´Ù.   2
 68 [°Ç°­ÇÑ]ä½Ä ½Ä´ÜÇ¥~   4  67 [°Ç°­ÇÑ]¾ÆÁ÷µµ °í±â ¸ÀÀ» ÀØÀ»¼ö°¡
¾ø´Ù...   2  66 [°Ç°­ÇÑ]¹«¾ùÀ» ¸ÔÀ»°ÍÀΰ¡?   3  65
[°Ç°­ÇÑ]°í±â¸¦ ¾È¸Ô¾îµµ ¿µ¾çÀº ÃæºÐÇѰ¡?   3  64 [°Ç°­ÇÑ]ä½Ä°¡°¡ À°½Ä°¡ º¸´Ù ´õ
°Ç°­ÇÏ´Ù.   3  63 [°Ç°­ÇÑ]À°½Ä ¹«¾ùÀÌ ¹®Á¦Àΰ¡?   3  62
[°Ç°­ÇÑ]¸í»ó   2  61 [°Ç°­ÇÑ]¿ä°¡ÀÇ È£Èí¹ý...   3  60
[°Ç°­ÇÑ]¸ö¿¡´ëÇÑ ÀǽÄÀ» ÀÏ ±ú¿ì´Â ¾Æ»ç³ª...   2  59 [°Ç°­ÇÑ]¿ä°¡ ¿Í °Ç°­... 

 [°Ç°­ÇÑÁ¤½Å¼¼°è]´©±¸µçÁö ÇÒ¼öÀÖ´Â ¿ä°¡ ÀÇ ±æ...   2  57 [°øÁö]¿©±â
¸ðÀÓÀº¿ä   10  56 [°øÁö]ÀÌ °Ô½ÃÆÇÀº?  2004.07.14 5  55
[°øÁö]ÀÌ °Ô½ÃÆÇÀº?   3  54 [°øÁö]ÀÌ °Ô½ÃÆÇÀº?   5  53 
[°øÁö]°Ç°­ÇÑ ¸ð½ÀµéÀº?   8  52 [»ýȰ/¿¹¼ú]¸»ÇÒ ¼ö ¾ø´Â »ç¶ûÀ̾߱â, ±îºñ¸£(Kabir)ÀÇ
½Ã   3  51 [°øÁö]°Ç°­ÇÑ »îÀÇ Áö¸§±æÀº?   4  49 ¾Æ¹öÁö¿Í
¾ÆµéÀº ¾î¶»°Ô ¼­ ÀÖÀ»±î?   4  48 ³ª´Â ¸îµîÀϱî¿ä?   3  47
102=99+1ÀÇ ºñ¹Ð   3  46 ºÒÀ» Äѱâ À§ÇØ ÇØ¾ß ÇÒ ÀÏ   2
 45 ¾Þ¹«»õÀÇ ºñ¹Ð   2  44 7¸íÀÇ »ç¶÷µéÀÌ...   2
 43 ¾Æ´Ï ¾î¶»°Ô ÀÌ·± ÀÏÀÌ??  42 ¼¼µð°¡ ÅÃÇÑ ¹æ¹ýÀº?   2 
 41 ¿µ¼ö¿Í Çб¸, ±ú²ýÀÌ »ìÀÚ!   3  40 ¸î°³ÀÇ ¹®¿¡ 9¶ó´Â ¼ýÀÚ°¡
Æ÷ÇԵɱî?   2  39 ¼¼ ¸¶¸®ÀÇ °í¾çÀ̰¡ 3ºÐ¿¡ ¼¼¸¶¸®ÀÇ Á㸦 Àâ´Â´Ù¸é...   2
 38 Àº½ÄÀº ¹«¾óÇÏ´Â »ç¶÷Àϱî??   4  37 Æë±Ï°ú ¿øÁÖ¹ÎÀÇ
ºñ¹Ð°ü°è?   2  36 µÎ¸íÀÇ ¾î¸Ó´Ï¿Í µÎ¸íÀÇ µþ?   2  35 ¾î¶»°Ô
Ưº°ÇÑ Àåºñµµ ¾øÀÌ ÇѰ­À» °Ç³Î ¼ö ÀÖ¾úÀ»±î?   2  34 ¹ÙÄû»çÀÌÀÇ °ø°£Àº ¸î°³??  
2  33 ±×³àÀÇ ³ªÀÌ´Â??   2  32 ¿¡º£·¹½ºÆ®»êÀÌ ¹ß°ßµÇ±â Àü¿¡ Áö±¸»ó¿¡¼­ °¡Àå ³ôÀº
»êÀº ¹«¾ùÀ̾ú½À´Ï±î?   2  31 11¿¡ 1À» ´õÇßÀ» ¶§ Á¤´äÀÌ 1ÀÌ µÇ´Â °æ¿ì´Â ¾î¶²
°ÍÀϱî¿ä?   2  30 ºñ¹ÐÀÇ Èû(The power of Secrecy)¿¡ °üÇÏ¿©   3
 29 ¹«À§(ÙíêÓ)..   3  28 ¾î¸Ó´Ï ´ëÁö¿¡°Ô °¨»çµå¸³´Ï´Ù   2
    ±× ³²Àڴ   2  26 »îÀº ±«·Î¿î °Í¸¸Àº
¾Æ´Ï´Ù   3  25 ¾ðÁ¦³ª ³»°¡ ´©±¸¸¦ ¸¸³ªµç...   2  24 ¿©ÇàÀÇ
ÁøÁ¤ÇÑ ¸ñÀû   2  23 ¿ôÀ½ÀÌ °¡Àå ÁÁÀº ¾àÀÌ´Ù   2  22
[°Ç°­ÇÑ]Ææµâ·³ ´Ù¿ì¡ÀÇ ½ÇÀü¿¬½À!   3  21 [°Ç°­ÇÑ]Ææµâ·³ ´Ù¿ì¡ µû¶óÇØº¸±â...  
3  20 [°Ç°­ÇÑ]Á÷°üÀÇ ÈûÀ¸·Î ÇØ¼®ÇÏ´Â ÆæµÑ·³´Ù¿ì¡   3  19
[°Ç°­ÇÑ]Ææµâ·³À̶õ?   3  16 [°Ç°­ÇÑ]¿ÀÀÏÀÇ Á¾·ù?   2  15
[°Ç°­ÇÑ]¾Æ·Î¸¶Å×¶óÇǶõ?   3  14 [°Ç°­ÇÑ]ó±(Â÷)ÀÇ Á¾·ù   2
 13 [°Ç°­ÇÑ]ó±(Â÷)ÀÇ ¸í»ó¹ý   2  12 [°Ç°­ÇÑ]¼öÁ¤º¸°üÇϱ⠠ 2
 11 [°£±ëÈù]¼öÁ¤ Á¤È­Çϱâ 
10 [°Ç°­ÇÑ]¼öÁ¤ÀÇ Ä¡À¯   3  9 [°Ç°­ÇÑ]¼öÁ¤ ¸í»ó¹ýÀº?   3
 8 [°Ç°­ÇÑ]¼öÁ¤ÀÇ È¿°ú   4  7 [°Ç°­ÇÑ]¼öÁ¤À̶õ? 
 
Æò½É¼­±âøÁãýà¢Ñ¨_¼øÈ­·Ó°Ô ÇѸ¶À½1
´ç½Å²² ¹¯½À´Ï´Ù. Á·ðë ÇϽÿÀ?
 
Æò½É¼­±âøÁãýà¢Ñ¨_¼øÈ­·Ó°Ô 

implicit conversion

2005-01-31 Thread Benjamin Schmeling
Hi,
I am working on exposing a bigint class to python.  Now I've got the 
problem that methods which take an bigint as
an parameter do not accept Python longs.

For example:
import _PythonLiDIA
x=123L;
c=_PythonLiDIA.bigint();
_PythonLiDIA.gcd(c,x);
Traceback (most recent call last):
File "test.py", line 132, in ?
 _PythonLiDIA.gcd(a,x);
Boost.Python.ArgumentError: Python argument types in
 _PythonLiDIA.gcd(bigint, long)
did not match C++ signature:
 gcd(LiDIA::bigint, LiDIA::bigint)
I don't know how to achieve implicit conversion at this point, turning an
long automatically into an bigint. The other way round, turning an bigint
into long can be realized by defining __long__.
Can someone help me please?
Benjamin
--
http://mail.python.org/mailman/listinfo/python-list


Re: The next Xah-lee post contest

2005-01-31 Thread Arthur
On Mon, 31 Jan 2005 07:40:40 -0500, Steve Holden <[EMAIL PROTECTED]>
wrote:

>[EMAIL PROTECTED] wrote:
>
>> Tragi-comic.  really.  BTW you forgot cross-post to c.l.scheme, C,
>> smalltalk and C++
>> 
>Would there, I wonder, be any enthusiasm for a "Best Xah Lee impression" 
>prize at PyCon?

And the rules of the game, if he shows?  

I guess "no ringers", would have to be the rule.


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


Re: variable declaration

2005-01-31 Thread Steve Holden
Alex Martelli wrote:
Alexander Zatvornitskiy
<[EMAIL PROTECTED]> wrote:

Hello All!
I'am novice in python, and I find one very bad thing (from my point of
view) in language. There is no keyword or syntax to declare variable, like
'var' in

[...]
There are zillions of languages -- use another one.
[...]
If Python doesn't fit YOUR brain, for example because your brain is
ossified around a craving for the declaration of variables, then, unless
you're specifically studying a new language just for personal growth
purposes, I think you might well be better off with a language that
DOES, at least until and unless your brain changes by other means.
Alex
I think we should all remember that Python isn't for everyone, and least 
of all for those with little knowledge of Python and preconceptions 
about what Python *should* be like.

regards
 Steve
--
Steve Holden   http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
Holden Web LLC  +1 703 861 4237  +1 800 494 3119
--
http://mail.python.org/mailman/listinfo/python-list


Re: Where can I find sample "beginner" programs to study?

2005-01-31 Thread Franz Steinhaeusler
On Fri, 28 Jan 2005 21:41:05 +0100, moma <[EMAIL PROTECTED]> wrote:

>Eggs are here. Bring some bacon.
>http://www.python-eggs.org/links.html

Hi,

interesting site, but who is maintaining this
page. I'd like to add some new links.
-- 
Franz Steinhaeusler
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how do i create such a thing?

2005-01-31 Thread Alex Martelli
Steven Bethard <[EMAIL PROTECTED]> wrote:

> Of if you only want to deal with the case where the attribute doesn't
> exist, you can use getattr, which gets called when the attribute can't
> be found anywhere else:
> 
> py> class DefaultAttr(object):
> ...   def __init__(self, default):
> ...   self.default = default
> ...   def __getattr__(self, name):
> ...   return self.default
> ...   
> py> x = DefaultAttr(99)
> py> x.a
> 99
> py> x.a = 10
> py> x.a
> 10

This is a good approach, but it's fragile regarding specialnames.

>>> class DefaultAttr(object):
...   def __init__(self, default): self.default = default
...   def __getattr__(self, name): return self.default
... 
>>> import copy
>>> copy.copy(DefaultAttr(99))
Traceback (most recent call last):
  File "", line 1, in ?
  File "/usr/local/lib/python2.4/copy.py", line 87, in copy
rv = reductor(2)
TypeError: 'int' object is not callable

There are many more, worse example for classic classes, but even in
newstyle classes you must consider that once in a while a system routine
will try a getattr(someinst, '__aspecialname__', None) or the like --
and your class is making its instances claim to have ANY special name
that may be introspected for in this way.  This can be a pernicious lie,
since your class in fact has no idea whatsoever what that specialname
and the corresponding value might be for.

It's HIGHLY advisable to have your __getattr__ methods raise
AttributeError for any requested name that starts and ends with double
underscores, possibly with some specific and specifically designed
exceptions.


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


Re: implicit conversion

2005-01-31 Thread Alex Martelli
Benjamin Schmeling <[EMAIL PROTECTED]> wrote:
   ...
> I don't know how to achieve implicit conversion at this point, turning an
> long automatically into an bigint. The other way round, turning an bigint
> into long can be realized by defining __long__.

Perhaps adding to your bigint class a constructor (not declared as
``explicit'', if you're coding C++) which accepts as its argument a
python long might help...?


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


Re: What's so funny? WAS Re: rotor replacement

2005-01-31 Thread Nick Craig-Wood
Paul Rubin  wrote:
>  Actually and surprisingly, that's not really true.  Crypto algorithms
>  are pretty straightforward, so if you examine the code and check that
>  it passes a bunch of test vectors, you can be pretty sure it's
>  correct.

I was going to write pretty much the same thing.

If a security flaw is found in a block cipher (say) it won't be
because it has a buffer overflow etc, it will be because the algorithm
is flawed.  You can't patch up crypto algorithms, you have to throw
them away and start again (you can't have two incompatible versions of
DES for instance).

-- 
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
-- 
http://mail.python.org/mailman/listinfo/python-list


Report

2005-01-31 Thread decoder-x-mac-gujarati
The original message was received at Mon, 31 Jan 2005 19:08:12 +0500 from 
[140.253.248.170]

- The following addresses had permanent fatal errors -
python-list@python.org



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

re module - cannot make expression

2005-01-31 Thread Laszlo Zsolt Nagy
Hi All!
I would like to match strings not beginning with '/webalizer'. How can I 
do this?
The only one negation command is ^ inside [] but it cannot be used here. 
I looked
over "re" examples on the net but I could not find an example about how 
to match
"not beginning with" type expressions.

Thanks,
  Laci 2.0
--
http://mail.python.org/mailman/listinfo/python-list


Want to meet any of these people? They are registered for PyCon

2005-01-31 Thread Steve Holden
In accordance with PyCon's privacy policy, there are currently 29 PyCon 
registrants who have asked that their names not be published. The 
remainder, however, are listed here just in case you've ever wanted to 
meet any of them, and could do so by registering for PyCon at

  http://www.python.org/pycon/2005/register.html
Note that the sort order isn't perfect - I just sorted on the second 
"word" in each name. PyCon is a *great* place to meet people and discuss 
ideas. Hope to see you there.

regards
 Steve
Chris Akre
Brad Allen
Kevin Altis
Ummesalma Amil
Stephen Apiki
Dan Arico
Larry Austin
Suresh Babu Eddala
Jim Baker
Amir Bakhtiar
Greg Barr
Facundo Batista
Anton Benard
Thomas Bennett
Bill Bergmann
Ian Bicking
Brian Bilbrey
David Binger
Zachery Bir
Matthew Blecker
Chris Blunck
Ben Bodner
Jonah Bossewitch
Ivo Busko
Theodore C. Pollari
Matthew Cahn
JP Calderone
Brett Cannon
Katie Capps Parlante
Vern Ceder
Michael Chermside
Martin Chilvers
Anders Chrigstrom
Daniel Chudnov
Tom Cocagne
Eric Coffman
Kevin Cole
Tim Couper
Matt Croydon
Kevin Cully
Andrew Dalke
R. David Murray
Zoltan Deak
Stephan Deibel
Catherine Devlin
Cory Dodt
Bruce Donald Campbell
Brian Dorsey
Scott Downie
Fred Drake
Matt Drew
Michael Droettboom
Reggie Dugard
Donovan Eastman
Bruce Eckel
John Ehresman
Alan Elkner
Jeffrey Elkner
Richard Emslie
Mathieu Fenniak
Robert Ferguson
Abe Fettig
Russell Finn
Timothy Fitz
Mike Fletcher
Alec Flett
Paul Flint
Mitchell Foral
Doug Fort
Robin Friedrich
Phil Frost
Jim Fulton
Patrick Garrett
Philip Gaudette
David Geller
Grig Gheorghiu
Christopher Gillett
John Goebel
Matthew Good
David Goodger
Nat Goodspeed
Perry Greenfield
Joe Grossberg
David Grumm
Walter H. Rauser
Warren Hack
Walker Hale IV
Jacob Hallen
David Hancock
Andrew Harrington
Travis Hartwell
Randy Heiland
Mark Hertel
Raymond Hettinger
Rob Hill
Tom Hoffman
Steve Holden
Jim Hugunin
John Hunter
Jeremy Hylton
Bob Ippolito
Joseph J. Pamer
Kevin Jacobs
Vineet Jain
Michael Johnson
Eric Jones
Evan Jones
Ian Jones
Richard Jones
Francisco Juarez
Patrick K. O'Brien
Jacob Kaplan-Moss
Don Kauffman
David Keeney
Peter Kessler
Shahthureen Khan
Brian Kirsch
Sally Kleinfeldt
Josheph Kocherhans
Jeff Kowalczyk
Daniel Krech
Kartic Krishnamurthy
Peter Kropf
Andrew Kuchling
Bob Kuehne
Jeff Kunce
Lloyd Kvam
Jason L  Asbahr
MAN-YONG LEE
Cameron Laird
LD Landis
Jukka Laurila
Aaron Lav
Phil Lawrence
Edward Leafe
Charles Leake
Glyph Lefkowitz
Ted Leung
Michelle Levesque
Bailing Li
Greg Lindstrom
Yihsiang Liow
Peter Lyons
John M. Camara
Matthew MacInnes
Andrew MacKeith
Bryan MacRae
Brian Mahoney
Alex Martelli
Andrej Masiar
Peter Masiar
Roger Masse
Mark McClain
Alan McIntyre
Michael McLay
Paul McNett
Simon Michael
Charles Moad
Andrew Moore
David Morrill
David Muffley
Edward Muller
Robin Munn
Eric Newton
Edward Ng
Rob Nichols
Nestor Nissen
Greg Noble
Neal Norwitz
Peter Olsen
Mike Orr
Brad Palmquist
Guy Pardoe
Bob Parks
Thomas Parsli
Anders Pearson
Joel Pearson
Samuele Pedroni
Dave Perkins
Tim Peters
Carl Phillips
Charles Phillips
John Pinner
Mike Pirnat
Patrick Power
Mark Pratt
Kashif Qureshi
James R Hall-Morrison
Michael R. Bernstein
Douglas R. Caldwell
Andrew R. Gross
Robert R. Knight
Christian R. Simms
Anna Ravenscroft
Jimmy Retzlaff
John Rhodes
Anthony Rhudd
Armin Rigo
Nicholas Riley
Arnaldo Riquelme
Tracy Ruggles
Jeff Rush
Ollie Rutherfurd
Dr. S. Candelaria de Ram
Mike Salib
Prasan Samtani
Michel Sanner
Phil Schumm
Bill Sconce
Chris Shenton
Allen Short
Jim Sizelove
Brian Skahan
Erik Smartt
Garrett Smith
Jason Smith
Jacob Smullyan
Jeff Sprandel
David Stanek
William Stein
Yusei TAHARA
Geoff Talvola
Lee Taylor
Mike Taylor
Christian Theune
Rick Thomas
Andy Trice
George Trojan
Jamie Turner
Karl Ulbrich
Kirby Urner
Eric V. Smith
Andi Vajda
Hernando Vera
Thomas Verghese
Martin Walsh
Barry Warsaw
Steve Waterbury
Michael Weigend
Chad Whitacre
Kendall Whitesell
Frank Wilder
Derek Willis
Simon Willison
Mark Wittner
Russ Woodman
Andy Wright
Linden Wright
Peter Wu
Yahong Wu
James Y Knight
Ka-Ping Yee

Re: re module - cannot make expression

2005-01-31 Thread Steve Holden
Laszlo Zsolt Nagy wrote:
Hi All!
I would like to match strings not beginning with '/webalizer'. How can I 
do this?
The only one negation command is ^ inside [] but it cannot be used here. 
I looked
over "re" examples on the net but I could not find an example about how 
to match
"not beginning with" type expressions.

Thanks,
  Laci 2.0
You can do taht with Python re's. Look in the re documentation for 
"negative lookahead assertion".

regards
 Steve
--
Steve Holden   http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
Holden Web LLC  +1 703 861 4237  +1 800 494 3119
--
http://mail.python.org/mailman/listinfo/python-list


import directory error

2005-01-31 Thread Olivier Noblanc ATOUSOFT
Hello,


When i want to import a .py fire from another subdirectory i make

import inc/setupxml


but that make me an error message.

A man tell me to put a dot but that doesn't work.

Can you help me ?

Thanks.



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


Re: PyGame not working(?) (was: trouble installing numeric)

2005-01-31 Thread Kamilche
Are you using Python 2.3? Pygame doesn't work with 2.4, unfortunately.
It's the reason I removed 2.4 from my machine. I'll upgrade once PyGame
upgrades.

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


Re: import directory error

2005-01-31 Thread Ola Natvig
Olivier Noblanc ATOUSOFT wrote:
Hello,
When i want to import a .py fire from another subdirectory i make
import inc/setupxml
but that make me an error message.
A man tell me to put a dot but that doesn't work.
Can you help me ?
Thanks.

You should write
import inc.setupxml
this imports the module located at inc/setupxml.py
It's said that it imports the setupxml *module* from the inc *package*
All packages should include a __init__.py file. The import may not work 
unless. You will get the __init__.py file if you type

import inc

--
--
 Ola Natvig <[EMAIL PROTECTED]>
 infoSense AS / development
--
http://mail.python.org/mailman/listinfo/python-list


Re: import directory error

2005-01-31 Thread Steve Holden
Olivier Noblanc ATOUSOFT wrote:
Hello,
When i want to import a .py fire from another subdirectory i make
import inc/setupxml
but that make me an error message.
A man tell me to put a dot but that doesn't work.
Can you help me ?
Thanks.

If you want to import a single .py (a Python module) then the ONLY way 
to achieve that is to make sure it appears in a directory that is a 
member of the sys.path list. (This is a slight simplification, but it 
will do as long as you are only importing from the file store).

There are various ways to affect the contents of sys.path, the best 
known of which include

   1. Setting the PYTHONPATH environment variable
   2. Creating *.pth files
   3. Altering sys.path inside site-customize.py in
  your standard library
Python does allow you to implement PACKAGES, which are directories 
containing

   a) a file called __init__.py and (optionally)
   b) other modules (.py files) and packages (directories
  containing __init__.py files).
The Python interpreter looks for packages in all the same places it 
looks for modules, but it imports packages by running the __init__.py 
file (as usual, this happens on the *first* time the package is imported).

So, for example, under Cygwin or Linux/Unix, I can define a package 
(with no Python in it, but still obeying the rules) as follows:

[EMAIL PROTECTED] ~
$ mkdir mp1
[EMAIL PROTECTED] ~
$ touch mp1/__init__.py
[EMAIL PROTECTED] ~
$ touch mp1/rhubarb.py
[EMAIL PROTECTED] ~
$ mkdir mp1/p2
[EMAIL PROTECTED] ~
$ touch mp1/p2/__init__.py
[EMAIL PROTECTED] ~
$ python
Python 2.4 (#1, Dec  4 2004, 20:10:33)
[GCC 3.3.3 (cygwin special)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
 >>> import sys
 >>> "" in sys.path
True
 >>> import mp1
 >>> import mp1.rhubarb
 >>> import mp1.p2
 >>>
[EMAIL PROTECTED] ~
$ find mp1
mp1
mp1/p2
mp1/p2/__init__.py
mp1/p2/__init__.pyc
mp1/rhubarb.py
mp1/rhubarb.pyc
mp1/__init__.py
mp1/__init__.pyc
In this case mp1.rhubarb is a module from the mp1 package, mp1.p2 is a 
sub-package of mp1. You can see what's been compiled by the interpreter 
on import and when by looking at the .pyc files.

Does this help any?
regards
 Steve
--
Steve Holden   http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
Holden Web LLC  +1 703 861 4237  +1 800 494 3119
--
http://mail.python.org/mailman/listinfo/python-list


Re: import directory error

2005-01-31 Thread Olivier Noblanc ATOUSOFT
Problem solved thanks a lot


"Steve Holden" <[EMAIL PROTECTED]> a écrit dans le message de news: 
[EMAIL PROTECTED]
> Olivier Noblanc ATOUSOFT wrote:
>
>> Hello,
>>
>>
>> When i want to import a .py fire from another subdirectory i make
>>
>> import inc/setupxml
>>
>>
>> but that make me an error message.
>>
>> A man tell me to put a dot but that doesn't work.
>>
>> Can you help me ?
>>
>> Thanks.
>>
>>
>>
> If you want to import a single .py (a Python module) then the ONLY way to 
> achieve that is to make sure it appears in a directory that is a member of 
> the sys.path list. (This is a slight simplification, but it will do as 
> long as you are only importing from the file store).
>
> There are various ways to affect the contents of sys.path, the best known 
> of which include
>
>1. Setting the PYTHONPATH environment variable
>2. Creating *.pth files
>3. Altering sys.path inside site-customize.py in
>   your standard library
>
> Python does allow you to implement PACKAGES, which are directories 
> containing
>
>a) a file called __init__.py and (optionally)
>b) other modules (.py files) and packages (directories
>   containing __init__.py files).
>
> The Python interpreter looks for packages in all the same places it looks 
> for modules, but it imports packages by running the __init__.py file (as 
> usual, this happens on the *first* time the package is imported).
>
> So, for example, under Cygwin or Linux/Unix, I can define a package (with 
> no Python in it, but still obeying the rules) as follows:
>
> [EMAIL PROTECTED] ~
> $ mkdir mp1
>
> [EMAIL PROTECTED] ~
> $ touch mp1/__init__.py
>
> [EMAIL PROTECTED] ~
> $ touch mp1/rhubarb.py
>
> [EMAIL PROTECTED] ~
> $ mkdir mp1/p2
>
> [EMAIL PROTECTED] ~
> $ touch mp1/p2/__init__.py
>
> [EMAIL PROTECTED] ~
> $ python
> Python 2.4 (#1, Dec  4 2004, 20:10:33)
> [GCC 3.3.3 (cygwin special)] on cygwin
> Type "help", "copyright", "credits" or "license" for more information.
>  >>> import sys
>  >>> "" in sys.path
> True
>  >>> import mp1
>  >>> import mp1.rhubarb
>  >>> import mp1.p2
>  >>>
>
> [EMAIL PROTECTED] ~
> $ find mp1
> mp1
> mp1/p2
> mp1/p2/__init__.py
> mp1/p2/__init__.pyc
> mp1/rhubarb.py
> mp1/rhubarb.pyc
> mp1/__init__.py
> mp1/__init__.pyc
>
> In this case mp1.rhubarb is a module from the mp1 package, mp1.p2 is a 
> sub-package of mp1. You can see what's been compiled by the interpreter on 
> import and when by looking at the .pyc files.
>
> Does this help any?
>
> regards
>  Steve
> -- 
> Steve Holden   http://www.holdenweb.com/
> Python Web Programming  http://pydish.holdenweb.com/
> Holden Web LLC  +1 703 861 4237  +1 800 494 3119 


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


Re: how to find number of processors in python

2005-01-31 Thread Christopher De Vries
"/usr/sbin/psrinfo -p" will print the number of physical processors on the
system, though it does not indocate if they are on- or off-line. You could also
write an extension which gets processor information using the sys/processor
library. Example code is available in the "p_online" man page. 

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


Using HTTPSConnection and verifying server's CRT

2005-01-31 Thread Marc Poulhiès
Hi,

I'm trying to build a system using HTTPS with python clients that have
to verify the server's identity. From the Python document, it seems that
the server's certificate is not veryfied, and authentication can only be
in the other way (client authentication).
I know usually users only click on 'yes I trust this certificate', but
what if you really care (this is my case)?

I tried to see if the M2Crypto has this possibility, but from my tests
and from what I can find on the website, it seems not :/

Can someone confirm me this is not possible or point me to something
that could help me?

 Thanks,
   Marc
-- 
http://mail.python.org/mailman/listinfo/python-list


import doesn't work as i want

2005-01-31 Thread Olivier Noblanc ATOUSOFT
Hello,

In the botom of this post you will see my source code.

The problem is when i launch main.py that doesn't make anything why ?

Thanks
olivier noblanc
Atousoft
http://www.logiciel-erp.fr



I have main.py :

-
import wx
import inc.importlist
--

inc/importlist.py

import wx.grid
import getdata
import time
import sys
---

inc/wxgrid.py
-
# -*- coding: cp1252 -*-


#starta = time.time()
import wx
import getdata

class MyFrame(wx.Frame):
def __init__(self, *args, **kwds):
# begin wxGlade: MyFrame.__init__
kwds["style"] = wx.DEFAULT_FRAME_STYLE
wx.Frame.__init__(self, *args, **kwds)
self.grid_1 = wx.grid.Grid(self, -1, size=(1, 1))

self.__set_properties()
self.__do_layout()
# end wxGlade

def __set_properties(self):
# begin wxGlade: MyFrame.__set_properties
self.SetTitle("frame_1")
self.SetSize((400, 400))
# end wxGlade

self.grid_1.CreateGrid(len(db.data), len(db.fields))

# met les labels des colonnes
index = 0
for item in db.fields:
self.grid_1.SetColLabelValue(index, item[0])
index += 1

# remplissage des données.
for row in range(len(db.data)):
for col in range(len(db.data[row])):
values = db.data[row][col]
self.grid_1.SetCellValue(row,col,str(values))

# mise en forme et affichage
def __do_layout(self):
# begin wxGlade: MyFrame.__do_layout
sizer_1 = wx.BoxSizer(wx.VERTICAL)
sizer_1.Add(self.grid_1, 1, wx.EXPAND, 0)
self.SetAutoLayout(True)
self.SetSizer(sizer_1)
self.Layout()
# end wxGlade

# end of class MyFrame


if __name__ == "__main__":
app = wx.PySimpleApp(0)
wx.InitAllImageHandlers()
frame_1 = MyFrame(None, -1, "")
app.SetTopWindow(frame_1)
frame_1.Show()
#startb = time.time() - starta
#print startb
app.MainLoop()


---

inc/getdata.py
--
import MySQLdb


class Eb_db:
def __init__(self):
try:
connection = MySQLdb.connect(host="dellced", user="ats", 
passwd="",db="atsmedicdatabase" )
cursor = connection.cursor()
cursor.execute( "SELECT * FROM PATIENT " )
except MySQLdb.OperationalError, message:
errorMessage = "Error %d:\n%s" % ( message[ 0 ], message[ 1 ] )
return
else:
 self.data = cursor.fetchall()
 self.fields = cursor.description
 cursor.close()
 connection.close()


-




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


barchart for webpage needed

2005-01-31 Thread dimitri pater
Hello,

I am looking for a Python tool to create graphs and charts on a
webpage. Chartdirector is too expensive for me. A simple script for
creating a barchart should be sufficient as a starting point.

Thanks!
Dimitri
-- 
Please visit dimitri's website: www.serpia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Best python postgres module?

2005-01-31 Thread Frank Miles
In article <[EMAIL PROTECTED]>,
Robert Brewer <[EMAIL PROTECTED]> wrote:
>Roland Heiber wrote:
>> i recently migrated from mysql to postgresql and did use 
>> severel python 
>> postgres-modules. All do what they are designed for, so 
>> which one would 
>> you use? psycopg, pygresql, pypgsql? psycopg seems to be the best 
>> solution for heavy traffic/multiple connections  i have no real 
>> testing environment, so any advice which one to use for different 
>> usecases would be nice.
>
>If your "use cases" involve cross-platform development (i.e. Linux and
>Windows), pypgsql seems to fit the bill nicely.

psycopg is available for WinXX as well, though I'm not sure how long it
takes for bleeding-edge (development versions) to get to WinXX.

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


Re: import doesn't work as i want

2005-01-31 Thread Fredrik Lundh
Olivier Noblanc wrote:

> In the botom of this post you will see my source code.
>
> The problem is when i launch main.py that doesn't make anything why ?

the "if __name__" statement checks the name of the module.  if you run
Python file as a script, by passing a filename to the python interpreter, the
__name__ variable is set to  "__main__".  if you import a file as a module,
the __name__ is the name of the module, not "__main__".

if you want main.py to do something, move that code to main.py (or move
it into a function, and call it from main.py)

 



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


Re: barchart for webpage needed

2005-01-31 Thread John Hunter
> "dimitri" == dimitri pater <[EMAIL PROTECTED]> writes:

dimitri> Hello, I am looking for a Python tool to create graphs
dimitri> and charts on a webpage. Chartdirector is too expensive
dimitri> for me. A simple script for creating a barchart should be
dimitri> sufficient as a starting point.

matplotlib does barcharts, errorbars, stacked bars, and more (and its
free).  See the following links

# matplotlib with web app servers: 
http://matplotlib.sourceforge.net/faq.html#APPSERVER

# a barchart screenshot with example code
http://matplotlib.sourceforge.net/screenshots.html#barchart_demo


# the bar command for making bar charts
http://matplotlib.sourceforge.net/matplotlib.pylab.html#-bar

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


RE: variable declaration

2005-01-31 Thread Robert Brewer
Alex Martelli wrote:
> If Python doesn't fit YOUR brain, for example because your brain is
> ossified around a craving for the declaration of variables, 
> then, unless
> you're specifically studying a new language just for personal growth
> purposes, I think you might well be better off with a language that
> DOES, at least until and unless your brain changes by other means.

*shudder* Once a VB coder, always a VB coder? Whatever your first shop
uses, you're stuck with for life? Again, I say *shudder*.

Bah. Nothing teaches you a new language like having your job depend upon
it. People who study languages merely for "personal growth" learn 50% of
the syntax and 1% of the concepts, and then fritter that learning away
on inconsequential newsgroups the world over.

Alex Z, keep using and learning Python. Let it change your brain.


Robert Brewer
MIS
Amor Ministries
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list


Re: variable declaration

2005-01-31 Thread Michael Tobis
With all due respect, I think "so go away if you don't like it" is
excessive, and "so go away if you don't like it and you obviously don't
like it so definitely go away" is more so. The writer is obviously
neither a native speaker of English nor an accomplished user of Python,
so there are two language issues here. Try expressing your reply in
Russian before deciding that "very ugly" means exactly what you think
it does. I think just saying that "experienced Python users have not
found the lack of declarations to be a major hindrance" would have been
more appropriate.

Also, the assertion that "Python has no declarations whatsoever" is no
longer obviously true. In the 2.4 decorator syntax, a decorator line is
not executable, but rather a modifier to a subsequent symbol binding. I
call it a declaration. I found this disappointing in that it seems to
me a violation of "Special cases aren't special enough to break the
rules" but on further reflection it enables consideration of what a
whole slew of declarative constructs could achieve.

To begin with, now that the design constraint of "no declarations" has
been shown to be less than absolute, why not allow for perl-style ('use
strict') declarations? It actually is very useful in the small-script
space (up to a few hundred lines) where the best Perl codes live.

Let me add that I remain unconvinced that a language cannot combine the
best features of Python with very high performance, which is ultimately
what I want. It seems to me that such a language (possibly Python,
possibly a Python fork, possibly something else) will need substantial
programmer control over references as well as referents.

It seems to me that Python has a weaker case for purity in this regard
now that the dam has been breached with decorator syntax, which is, I
think, a declaration.

Let me conclude with the confession that I'm still on the steep part of
the learning curve (if it ever flattens out at all...). Python has
definitely significantly modified how I think about things, and I
deeply appreciate all the efforts of you veterans. So I say this all
with some trepidation, because I don't want to join Alexander in
inadvertently offending you. And since I presumably missed some intense
flame wars about decorators by only a couple of months,  this may be a
real hornet's nest I am poking.

In summary, again with all due respect and gratitude for the
spectacularly excellent product that Python is today, I wonder  *why*
this strong aversion to declarative statements, and *whether* decorator
syntax constitutes a violation of it. I'd appreciate any responses or
links.

--
mt

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


Re: Nested scopes and class variables

2005-01-31 Thread Steven Bethard
Alex Martelli wrote:
def f(x):
...   class C:
... x = x
...   return C
... 

[snip]

def f(x):
...   def g():
... x = x
... return x
...   return g
... 

[snip]
See the difference?  In a function, the 'x = x' compiles into LOAD_FAST,
STORE_FAST, which only looks at locals and nowhere else.  In a
classbody, it compiles to LOAD_NAME, STORE_NAME, which looks at locals
AND globals -- but still not at closure cells...
Is there a reason why the class body doesn't look at closure cells? 
That is, are there cases where this lookup scheme is preferred to one 
that checks locals, closure cells and globals?

Steve
P.S. Question disclaimer:
My questions here are founded in a curiosity about language design, and 
are not intended as an attack on Python. =)
--
http://mail.python.org/mailman/listinfo/python-list


Re: Microsoft Visual C++ and pyton

2005-01-31 Thread Christopher De Vries
On Sun, Jan 30, 2005 at 03:12:06PM -0800, mike wrote:
> I am new with python.  Is it possible to have an MFC application and
> develop some module using python? what are the steps in doing this? can
> anybody give me a url or some documentation for this.. thanks..

It is possible to embed python in a C or C++ application, enabling you to call
python functions from C. I would recommend reading "Extending and Embedding the
Python Interpreter" at http://docs.python.org/ext/ext.html for more
information. If you are currently using Visual C++ 6.0, either stick with
Python 2.3 or read this: http://www.vrplumber.com/programming/mstoolkit/ to
learn how to build extensions for python 2.4 with the free VC++ toolkit
compiler. If you are already using version 7 of the Microsoft C++ compiler then
you should have no problems with Python 2.4. 

I usually do not embed the interpreter, but I have written some extension
modules... well, I should say I have used SWIG (http://www.swig.org/) to create
wrappers around some C libraries. For information (read: rants) on extending
versus embedding see http://twistedmatrix.com/users/glyph/rant/extendit.html
and http://c2.com/cgi/wiki?EmbedVsExtend . 

You can also use win32 python extensions to make your module available through
COM, but I don't know anything about that.

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


Re: variable declaration

2005-01-31 Thread Fredrik Lundh
Michael Tobis wrote:

> Also, the assertion that "Python has no declarations whatsoever" is no
> longer obviously true. In the 2.4 decorator syntax, a decorator line is
> not executable

that's a nice theory, but since the decorator line is executed by the inter-
preter, it's a little weak.

 



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


Re: import doesn't work as i want

2005-01-31 Thread Olivier Noblanc ATOUSOFT
how to move in function ?

"Fredrik Lundh" <[EMAIL PROTECTED]> a écrit dans le message de news: 
[EMAIL PROTECTED]
> Olivier Noblanc wrote:
>
>> In the botom of this post you will see my source code.
>>
>> The problem is when i launch main.py that doesn't make anything why ?
>
> the "if __name__" statement checks the name of the module.  if you run
> Python file as a script, by passing a filename to the python interpreter, 
> the
> __name__ variable is set to  "__main__".  if you import a file as a 
> module,
> the __name__ is the name of the module, not "__main__".
>
> if you want main.py to do something, move that code to main.py (or move
> it into a function, and call it from main.py)
>
> 
>
> 


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


Re: Using HTTPSConnection and verifying server's CRT

2005-01-31 Thread Ng Pheng Siong
According to Marc Poulhiès  <[EMAIL PROTECTED]>:
> I tried to see if the M2Crypto has this possibility, but from my tests
> and from what I can find on the website, it seems not :/

How did you test and where on the website does it say not?

> Can someone confirm me this is not possible or point me to something
> that could help me?

M2Crypto does server cert verification. With M2Crypto's httpslib, you pass
in an SSL.Context instance to the HTTPSConnection constructor to configure
the SSL; one of the config knobs is cert verification. So, redo your test,
satisfy yourself that this is doable, and send me your code to include as
an example in the distribution. ;-)

M2Crypto even does client certs. Since Apr 2000, according to the very last
blog entry on the ZServerSSL page.


-- 
Ng Pheng Siong <[EMAIL PROTECTED]> 

http://sandbox.rulemaker.net/ngps -+- M2Crypto, ZServerSSL for Zope, Blog
http://www.sqlcrypt.com -+- Database Engine with Transparent AES Encryption
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: re module - cannot make expression

2005-01-31 Thread Steven Bethard
Laszlo Zsolt Nagy wrote:
I would like to match strings not beginning with '/webalizer'. How can I 
do this?
Are you sure you need a regular expression?  The str.startswith method 
is what I would normally use to solve this kind of problem:

py> lst = ['aax', 'abx', 'acx', 'aay', 'aby', 'acy']
py> [s for s in lst if not s.startswith('ab')]
['aax', 'acx', 'aay', 'acy']
If you do need a regular expression, Steve Holden's suggestion about 
negative lookahead assertions is the right way to go:

py> s = 'aaxabxacxaayabyacy'
py> re.compile(r'(?!ab).{2}[xy]+').findall(s)
['aax', 'acx', 'aay', 'acy']
Steve
--
http://mail.python.org/mailman/listinfo/python-list


Re: import doesn't work as i want

2005-01-31 Thread Fredrik Lundh
Olivier Noblanc wrote:

> how to move in function ?

how to put code in a function?  the same way you put code in a method.

change

if __name__ == "__main__":
app = wx.PySimpleApp(0)
wx.InitAllImageHandlers()
frame_1 = MyFrame(None, -1, "")
app.SetTopWindow(frame_1)
frame_1.Show()
#startb = time.time() - starta
#print startb
app.MainLoop()

to

def main():
app = wx.PySimpleApp(0)
wx.InitAllImageHandlers()
frame_1 = MyFrame(None, -1, "")
app.SetTopWindow(frame_1)
frame_1.Show()
#startb = time.time() - starta
#print startb
app.MainLoop()

and call it from your main program:

import inc.wxgrid
inc.wxgrid.main()

if you have trouble sorting out the imports, this might help:

http://docs.python.org/ref/import.html
http://www.python.org/doc/essays/packages.html
http://effbot.org/zone/import-confusion.htm

 



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


Re: Using HTTPSConnection and verifying server's CRT

2005-01-31 Thread Marc Poulhiès
[EMAIL PROTECTED] (Ng Pheng Siong) writes:

Hi,

> According to Marc Poulhiès  <[EMAIL PROTECTED]>:
>> I tried to see if the M2Crypto has this possibility, but from my tests
>> and from what I can find on the website, it seems not :/
>
> How did you test and where on the website does it say not?

I did things like this:
con = M2Crypto.httpslib.HTTPSConnection("some_secure_server")
con.request("GET" , "/")
 
I tried to play with optional parameters (strict, debuglevel, etc) to
see if it was saying that it will not check server's CRT or some other
debug message dealing with server's certificate, but it is always
returning the webpage without saying anything :)

I did not say that M2C's doc stated clearly that this was not possible
(that's why I wrote "seems"), but I couldn't find something stating it
was possible (I tried google, API docs).

>> Can someone confirm me this is not possible or point me to something
>> that could help me?
>
> M2Crypto does server cert verification. With M2Crypto's httpslib, you pass
> in an SSL.Context instance to the HTTPSConnection constructor to configure
> the SSL; one of the config knobs is cert verification. So, redo your test,
> satisfy yourself that this is doable, and send me your code to include as
> an example in the distribution. ;-)

Ok, sorry for that. Maybe that with more readings I could have spotted
this. I'll try that tomorrow and give my code if I have something
working!


> M2Crypto even does client certs. Since Apr 2000, according to the very last
> blog entry on the ZServerSSL page.

Yes, I did try this and have my client authenticated to the server.

Thanks for this quick and clear answer ;)

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


Crude statistics on the standard library

2005-01-31 Thread F. Petitjean
I have written a script to find the modules which export the largest
number of names. The gc.getreferrers(*objs) function gives also an idea
of the dependencies between the modules.

The code (statsmod.py) :

#!/usr/bin/env python
# -*- coding: latin-1 -*-

"""
statsmod.py   module rudimentaire de statistiques des noms exportés
par les modules de la bibliothèque standard
"""

import sys
import gc

from glob import glob
import os, os.path
from os.path import basename

def browse_stdlib():
"""browse the standard library
returns list of names of modules
"""
pyver = 'python%s' % (sys.version[:3],)
pyglob = os.path.join(sys.prefix, 'lib', pyver, '*.py')
# lpys = glob(pyglob)
if os.path.exists(os.path.join(sys.prefix, 'Lib', 'os.pyc')):
pyglob = os.path.join(sys.prefix, 'Lib', '*.py')
lpys = map(basename, glob(pyglob))
names = [ name[:-3] for name in lpys ]
# remove some obsolete modules ('this' + DeprecationWarning)
for dontparse in ("this", "tzparse", 'FCNTL', 'posixfile', 'pre', 'regsub',
'statcache', 'TERMIOS', 'xmllib'):
try:
names.remove(dontparse)
except ValueError:
continue
return names

def exports(names, with_modules=False):
"""imports all the modules in names
returns a 2-tuple :
- list of tuples : NumberOfExternalNames len(dir(module)) nodname
- list of modules (if with_modules is true)
"""
res = []
add = res.append
_all = []
modules = []
# this simple minded method (__import__) doesn't include sys ?
for name in names:
print name, " ",
try:
module = __import__(name, globals(), locals(), _all)
ldir = len(dir(module))
if hasattr(module, '__all__'):
nexports = len(module.__all__)
else:
nexports = ldir
add((nexports, ldir, name))
if with_modules:
modules.append(module)
# del sys.modules[name]
except ImportError, msg:
print "cannot import module", name, msg
return res, modules

def pm_histo(values, nbins=20):
"""a poor man histogram
Return a list of nbins tuples (left, right) such that
the union of the consecutive ranges(left, right) is range(len(values)+1)
values[k]
"""
vlo, vhi = values[0], values[-1]+1
nbins = min(nbins, vhi-vlo)
deltax = int((vhi - vlo)/nbins)
assert deltax > 0
ranges = []
add = ranges.append
left = 0 # left index  first bin
val = vlo + deltax
while val < vhi:
for right in range(left, len(values)):
if values[right] > val:
break
add((left, right))
left = right
val = val + deltax
return ranges

def basic_stat(seq):
"""basic statistics on the values in seq
Returns NumberOfItems, MeanValue, StandardDeviation, variance
"""
s0, s1, s2 = 0, 0, 0
for indx, item in enumerate(seq):
s0 = s0 + 1 # seq may be an iterable without len
Xi = float(item)
if not indx:
Xmin = Xi
s1 = s1 + Xi
s2 = s2 + Xi*Xi
# s0 = len(seq)  # sum of 0 order
Xm = s1/s0  # mean value
Xmax = Xi
median = (Xmin + Xmax)*0.5
variance = (s2 - s0*Xm*Xm)/s0  # ecart-type ** 2
import math
stddev = math.sqrt(variance)  # ecart-type
return s0, Xmin, Xmax, median, Xm, stddev  # , variance

if __name__ == '__main__':
names = ['cStringIO', 'sys', 'gc' ]
names.extend(browse_stdlib())
freqs, modules = exports(names, True)
print#  exports() prints without new line
print "%d imported modules and %d in sys.modules" % (
len(freqs), len(sys.modules))

print "number of unreachable objects", gc.collect()
simples = []
while modules:
module = modules.pop()
# print module.__name__, sys.getrefcount(module)
items = gc.get_referrers(module)
litems = len(items)
if litems <= 2:
simples.append(module.__name__)
del sys.modules[module.__name__], module, items
else:
print "referrers of %s" % (module.__name__,)
for item in items[2:]:
name = item.get('__file__', 'unknown')
if name.endswith('__init__.pyc'):
pslash = name.rfind(os.sep)
pslash = name[:pslash].rfind(os.sep)
name = name[pslash+1:][:-4] # strip .pyc
elif name.endswith('__init__.py'):
pslash = name.rfind(os.sep)
pslash = name[:pslash].rfind(os.sep)
name = name[pslash+1:][:-3] # strip .py
elif name.endswith('.pyc'):
pslash = name.rfind(os.sep)
name = name[pslash+1:][:-4] # strip .pyc
elif name.endswith('.py'):
pslash = name.rfind(os.sep)
name = name[pslash

Re: variable declaration

2005-01-31 Thread Michael Tobis
> that's a nice theory, but since the decorator line is executed by the
inter-
> preter, it's a little weak.

Well, uh, who else would process it?

"use strict' and 'my epsilon' in perl are executed by the perl
interpreter as well, but they have a declarative flavor.

A decorator is a modifier to a subsequent binding, and it modifies the
reference and not the referent. So how is it anythng but declarative?
--
mt

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


Twain problems

2005-01-31 Thread Mikael Olofsson
Hi all!
Sorry for this rather lengthy post. It's a long preamble followed by a few 
questions based on that.

Here's my situation: I am trying to write a specialized scanner utility for 
my own needs, and I want to use the module twain to control my scanner. I 
haven't used the twain module before, which is most certainly why I'm facing 
problems. My problem is to interprete some of the information I get from the 
scanner. The scanner, by the way, is an HP LaserJet 3020, which is a 
multi-toy (printer/scanner/copyer), and I use Python 2.3 on Windows XP.

I set up communication with the scanner as follows (modulo a few ifs to take 
care of unsuccessful connections). Here self is an instance of a class with 
Tkinter.Tk as its base class.

   self.SM = twain.SourceManager(self.winfo_id(),ProductName='foo')
   self.SD = self.SM.OpenSource()
The TWAIN dialog pops up nicely, and I get two options: "hp LaserJet 3020 
TWAIN 1.0 (32-32)" and "WIA-hp LaserJet 3020 1.0 (32-32)". The first choice 
is HPs interface to the scanner, while the second seems to be a scanner 
interface that comes with Windows.

One issue arises if I choose "WIA-hp LaserJet 3020 1.0 (32-32)" and then do 
the following:

   capVal=self.SD.GetCapability(twain.ICAP_CONTRAST)
After that capVal is
   {'StepSize': 1,
   'DefaultValue': 0,
   'CurrentValue': 0,
   'MaxValue': 1000,
   'MinValue': 64536}
My educated guess is that 64536 should be interpreted as -1000, since 64536 
is -1000 modulo 2**16. One problem is that the twain type is not specified. 
So, perhaps I can find the twain type in some other way. The check

   capDef=self.SD.GetCapabilityDefault(twain.ICAP_CONTRAST)
gives me capDef==( 7, 0.0 ). According to my introspection of the twain 
module, the type 7 is twain.TWTY_FIX32. Googling around gives me the 
impression that this corresponds to 32 bits of which the first 16 bits 
correspond to the integer part, and the last 16 bits correspond to the 
fraction part. I thought that the twain module would take care of sign 
issues for me, but it does not seem to do so. OK, I can probably live with 
that. In any case, I guess I'll have to.

OK, that's perhaps not so tough.
Another issue arises if I choose "hp LaserJet 3020 TWAIN 1.0 (32-32)" and 
then do the following:

   capVal=self.SD.GetCapability(twain.ICAP_XSCALING)
After that capVal is
   {'StepSize': 429457408,
   'DefaultValue': 1,
   'CurrentValue': 1,
   'MaxValue': 6,
   'MinValue': 429457408}
Now I'm in trouble. The problem is to interprete capVal['StepSize'] and 
capVal['MinValue']. Both should correspond to some small positive value. 
Here the check

   capDef=self.SD.GetCapabilityDefault(twain.ICAP_XSCALING)
gives me capDef==( 4, 100 ). More introspection says that type 4 is 
twain.TWTY_UINT16. So, again googling around, and I find that this 
corresponds to an unsigned 16bit integer, but that doesn't help me much 
since 429457408 > 2**16. I also notice that capDef[1]==100, while 
capVal['DefaultValue']==1, so there must be a scaling factor of 100 
(percents, yes I know). But that doesn't change the fact that I'm completely 
lost here.

Finally, here are my questions:
Can anyone enlighten me? From the above, I get the impression that the 
dictionary returned by self.SD.GetCapability in these cases give me integer 
approximations of the current and default values. Is that a correct 
interpretation? How should I deal with 429457408 in the example above? Are 
there other twain-type related issues that I haven't seen yet, that I should 
be aware of? Is there some web-resource out there that answers my questions? 
Am I simply missing some information that I might already have? At least I 
haven't been able to find any enlightment in the documentation of the twain 
module or in the TWAIN specification. It seems to me that I need to be very 
careful with the type of the capabilities. How careful should I be?

Googling for things like TWTY_UINT16 typically results in what I interprete 
as C or C++ code, which does not help me much. I'm less fluent in C or C++ 
than I am in Italian (I can order a beer and buy postcards or stamps, that's 
more or less it).

I-cannot-order-a-beer-in-C-but-I-can-in-Python-ly yours
/Mikael Olofsson
Universitetslektor (Senior Lecturer [BrE], Associate Professor [AmE])
Linköpings universitet
---
E-Mail:  [EMAIL PROTECTED]
WWW: http://www.dtr.isy.liu.se/en/staff/mikael
Phone:   +46 - (0)13 - 28 1343
Telefax: +46 - (0)13 - 28 1339
---
Linköpings kammarkör: www.kammarkoren.com   Vi söker tenorer och basar! 

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


Re: variable declaration

2005-01-31 Thread Fredrik Lundh
Michael Tobis wrote:

>> that's a nice theory, but since the decorator line is executed by the
>> interpreter, it's a little weak.
>
> Well, uh, who else would process it?

the compiler.

from __future__ is a declaration.  @expression is an executable statement.

 



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


Re: variable declaration

2005-01-31 Thread Alex Martelli
Robert Brewer <[EMAIL PROTECTED]> wrote:

> Bah. Nothing teaches you a new language like having your job depend upon
> it. People who study languages merely for "personal growth" learn 50% of
> the syntax and 1% of the concepts, and then fritter that learning away
> on inconsequential newsgroups the world over.

I disagree.  I studied Python, even though it had nothing to do with my
job, just with the idea of using it on hobby projects; yet I believe I
can reasonably claim to have learned more than 50% of the syntax and 1%
of the concepts, even though you might claim that, whatever percentage
it may be, it's "frittered away on inconsequential newsgroups".


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


re: variable declaration

2005-01-31 Thread ajsiegel
MT writes - 

>In summary, again with all due respect and gratitude for the
>spectacularly excellent product that Python is today, I wonder  *why*
>this strong aversion to declarative statements, and *whether* decorator
>syntax constitutes a violation of it. I'd appreciate any responses or
>links

First be warned that I fit fairly well the profile Robert paints in the 
previous 
post on this thread - my life and livelihood do not depend on being 
a Python programmer.  Though I would claim that my efforts to wrap 
my mind around it have enhanced both.

Personal growth kind of thing.

And I clutter this news group from time to time with 
observations which I admit are light on technical savy.

I *can* tell you that some very bright, respected and technical 
members of the community argued *for* decorators on 
the exact grounds that Python needed to break away from
its aversion to declarative statements.

Someone like myself without a full grasp of the 
technical terminology and little grasp of the underlying structures, 
cannot tell you whether decorators are or are not declarative. 
I can observe that folks tend to get to where they want
to get in these kinds of discussions by playing with the 
ambiguities in these kinds of words.

>From an outside observer point of view, I seem to notice 
that in the world of programming, there seems
to be more ambiguity in technical words than 
one would expect (or ideally like to see) in words 
that purport to be technical words.

In short, I suspect there is a lot of semantics to be played
with in answering your question.

My own sense is that decorators do break a dam in Python,
for better or for worse, and that it is OK to let folks provoke
you into concluding for yourself what words best describe
the specifics.  But don't let the old hands convince you
they represent business as usual.

Though the authorative tone of your post indicates, I
suspect, that this post was quite unnecessary.

Art 




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


Re: variable declaration

2005-01-31 Thread DogWalker
"EP" <[EMAIL PROTECTED]> said:

>> Original Message
>> From: [EMAIL PROTECTED] (Alexander Zatvornitskiy)
>
>>
>> Hello All!
>> 
>> I'am novice in python, and I find one very bad thing (from my point of 
>> view) in
>> language. There is no keyword or syntax to declare variable, like 'var' 
>> in
>> Pascal, or special syntax in C. It can cause very ugly errors,like 
>> this:
>> 
>> epsilon=0
>> S=0
>> while epsilon<10:
>>   S=S+epsilon
>>   epselon=epsilon+1
>> print S
>> 
>> It will print zero, and it is not easy to find such a bug!
>
>
>Hmmm.  I am surely an expert in writing buggy code, but I can not say I make 
>this error in Python.  Why is that?
>
>I'm not sure, but a couple things that may help me miss making this mistake in 
>practice may be (somewhat informal in my case) unit testing - I test for 
>correct results for at least a few cases.
>
>It may also help that with Python I can code at a somewhat higher conceptual 
>level, or maybe it is just the syntax that helps avoid these problems:
>
  for epsilon in range (0,10):
> S=S+epsilon
>  
 for epsilon in range (0,10):
>   S=S+epselon
>   
>Traceback (most recent call last):
>  File "", line 2, in ?
>S=S+epselon
>NameError: name 'epselon' is not defined
>
>
>It may seem like jumping off a cliff, but the improvement in readability (the 
>variable declarations being visual clutter) makes it much easier for me to see 
>my code, and any typos in it.
>
>It seems it would be simple enough to have one's code, or another script, 
>automatically print out a sorted list of the variables - which would make the 
>error you note obvious.  But I haven't needed this, yet at least.
>
>You might like Python and find the lack of variable declaration checking not a 
>problem.  It's worth a shot.
>
>
class MyVars(object):
__slots__ = ['epsilon', 'thud', 'foo']

mv = MyVars()

mv.epselon = 42
Traceback (most recent call last)

/home/dw/KirbyBase-1.7/
  
AttributeError: 'MyVars' object has no attribute 'epselon'
  
mv.epsilon = 42
-- 
http://mail.python.org/mailman/listinfo/python-list

RE: variable declaration

2005-01-31 Thread Robert Brewer
Alex Martelli wrote:
> 
> Robert Brewer <[EMAIL PROTECTED]> wrote:
> 
> > Bah. Nothing teaches you a new language like having your 
> job depend upon
> > it. People who study languages merely for "personal growth" 
> learn 50% of
> > the syntax and 1% of the concepts, and then fritter that 
> learning away
> > on inconsequential newsgroups the world over.
> 
> I disagree.  I studied Python, even though it had nothing to 
> do with my
> job, just with the idea of using it on hobby projects; yet I believe I
> can reasonably claim to have learned more than 50% of the 
> syntax and 1%
> of the concepts, even though you might claim that, whatever percentage
> it may be, it's "frittered away on inconsequential newsgroups".

You are an exceptional person, Alex. ;)


Robert Brewer
MIS
Amor Ministries
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list


Re: variable declaration

2005-01-31 Thread Diez B. Roggisch
> A decorator is a modifier to a subsequent binding, and it modifies the
> reference and not the referent. So how is it anythng but declarative?

I learned the hard way that it still is simply interpreted - its a pretty
straight forward syntactic sugaring, as this shows:

foo = classmethod(foo)

becomes:

@classmethod

Now @classmethod has to return a callable that gets passed foo, and the
result is assigned to foo - not more, not less, so it becomes equivalent to
the older type of creating a class method.

Is this a declaration? I'd personally say and think "practically, yes", as I
also view

class Bar:
   

as a declaration. But obviously some people like Alex Martelli have
different views on this (and are right), because you can do this in python:

if condition:
class Foo:
def bar(self):
pass

else:
class Foo:
def schnarz(self):
pass

So that makes class statements not as declarative as they are in languages
like java.

So to sum it up (for me at least): things like metaclasses, decorators and
so on make me write code more declarative - if they are a declaration in
the strict sense, I don't bother.

-- 
Regards,

Diez B. Roggisch
-- 
http://mail.python.org/mailman/listinfo/python-list


how to access class methods via their name-as-string

2005-01-31 Thread phil_nospam_schmidt
I'd like to be able to look up a method name by passing a string with
the method name. I thought I could use self.__dict__ to get at the
method names, but as my example shows, this is obviously not working.
I've also tried self.__class__.__dict__ without success.

Can anyone point me in the right direction to make this work?

Thanks,
Phil

>>> class a:
def m1(self):
print 'm1'
def __getitem__(self, k):
return self.__dict__[k]

>>> class b(a):
def m2(self):
print 'm2'


>>> z=b()
>>> dir(z)
['__doc__', '__getitem__', '__module__', 'm1', 'm2']
>>> z['m1']
Traceback (most recent call last):
File "", line 1, in ?
z['m1']
File "", line 5, in __getitem__
return self.__dict__[k]
KeyError: 'm1'
>>>

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


Re: variable declaration

2005-01-31 Thread Alex Martelli
Michael Tobis <[EMAIL PROTECTED]> wrote:

> With all due respect, I think "so go away if you don't like it" is
> excessive, and "so go away if you don't like it and you obviously don't
> like it so definitely go away" is more so. The writer is obviously

I disagree: I believe that, if the poster really meant what he wrote, he
may well be happier using other languages and all the declarations he
cherishes, so recommending that course of action to him is quite proper
on my part.  Nobody forces him to follow my advice, in particular if, as
you suggest, he's mis-expressed himself.

> neither a native speaker of English nor an accomplished user of Python,
> so there are two language issues here. Try expressing your reply in
> Russian before deciding that "very ugly" means exactly what you think
> it does.

I don't know any Russian, and I don't see how that's relevant.  If the
poster said "it's very ugly" meaning "I'm not fully comfortable with it"
or "it's the best thing I've ever seen in my life", he can perfectly
well correct his misexpression if he cares to -- not my job to try to
read his mind and perform exegesis on his words.

> I think just saying that "experienced Python users have not
> found the lack of declarations to be a major hindrance" would have been
> more appropriate.

I think it would have been true, but weak and insufficient.  Not only
experienced Python users have that opinion: lack of declarations didn't
faze me even I was a total newbie (other things did, and I learned that
most of them were good only gradually; but if I'd blocked on something
as obviously *fundamental* to Python, I'd never have gone deeper, of
course).  Plus, I did offer a URL for a classic post by Robert Martin,
who's not even talking about Python yet came to exactly the same
conclusion *while using statically typed languages*, just on the basis
of unit-testing experience.


> Also, the assertion that "Python has no declarations whatsoever" is no
> longer obviously true. In the 2.4 decorator syntax, a decorator line is
> not executable, but rather a modifier to a subsequent symbol binding. I
> call it a declaration.

You may call it a strawberry, if you wish, but that doesn't mean it will
taste good with fresh cream.  It's nothing more and nothing less than an
arguably weird syntax for a perfectly executable statement:

@
def functionname 

means EXACTLY the same thing as

def functionname 
functionname = (functionname)

Nothing more, nothing less.  The splat-syntax isn't a "declaration" in
any sense of the word, just a not-so-short shortcut for an assignment
statement.  Proof by disassembly:

>>> def f():
...   @foo
...   def g(): pass
... 
>>> dis.dis(f)
  2   0 LOAD_GLOBAL  0 (foo)
  3 LOAD_CONST   1 (", line 2>)
  6 MAKE_FUNCTION0
  9 CALL_FUNCTION1
 12 STORE_FAST   0 (g)
 15 LOAD_CONST   0 (None)
 18 RETURN_VALUE
>>> def f():
...   def g(): pass
...   g = foo(g)
... 
>>> dis.dis(f)
  2   0 LOAD_CONST   1 (", line 2>)
  3 MAKE_FUNCTION0
  6 STORE_FAST   0 (g)

  3   9 LOAD_GLOBAL  1 (foo)
 12 LOAD_FAST0 (g)
 15 CALL_FUNCTION1
 18 STORE_FAST   0 (g)
 21 LOAD_CONST   0 (None)
 24 RETURN_VALUE

the splat-syntax optimizes away one STORE_FAST of g and the
corresponding LOAD_FAST, by having the LOAD_GLOBAL of foo earlier; nice,
but not earth-shaking, and definitely no "declaration" whatsoever.


> Let me add that I remain unconvinced that a language cannot combine the
> best features of Python with very high performance, which is ultimately

I'm also unconvinced.  Fortunately, so is the EU, so they have approved
very substantial financing for the pypy project, which aims in good part
exactly at probing this issue.  If any single individual can be called
the ideator of pypy, I think it's Armin Rigo, well-known for his
excellent psyco specializing-compiler for Python: the key research
thesis behind both projects is that a higher-level, dynamic language
need not have performance inferior to a lower-level one and indeed may
well beat it.

> what I want. It seems to me that such a language (possibly Python,
> possibly a Python fork, possibly something else) will need substantial
> programmer control over references as well as referents.

pypy is dedicated to proving you're wrong.  With at least half a dozen
great people now finally having started working full-time on the
project, and due to continue so doing for the next couple of years, I
like our chances.


> It seems to me that Python has a weaker case for purity in this regard
> now that the dam has been breached with decorator syntax, which is, I
> think, a declaration.

I entirely disagree that a minor syntax 

Re: how to access class methods via their name-as-string

2005-01-31 Thread Steven Bethard
[EMAIL PROTECTED] wrote:
I'd like to be able to look up a method name by passing a string with
the method name.
Use getattr:
py> class A(object):
... def f(self):
... pass
... def g(self):
... pass
...
py> class B(A):
... def h(self):
... pass
...
py> getattr(B(), 'f')
>
py> getattr(B(), 'g')
>
py> getattr(B(), 'h')
>
Steve
--
http://mail.python.org/mailman/listinfo/python-list


stop program in komodo

2005-01-31 Thread [EMAIL PROTECTED]
Hello,
How can we stop this peace of code in KOMODO:
while 1:
 print "helo"

I can't stop it, even using Ctrl+C

pujo

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


Re: implicit conversion

2005-01-31 Thread Benjamin Schmeling
Alex Martelli wrote:
Benjamin Schmeling <[EMAIL PROTECTED]> wrote:
  ...
 

I don't know how to achieve implicit conversion at this point, 
turning an
long automatically into an bigint. The other way round, turning an 
bigint
into long can be realized by defining __long__.
  

Perhaps adding to your bigint class a constructor (not declared as
``explicit'', if you're coding C++) which accepts as its argument a
python long might help...?
Alex
 

I have got such an constructor now (my_type(long_)), but nevertheless 
implicit conversion from long to my_type isn't supported. Any other ideas?

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


Re: variable declaration

2005-01-31 Thread Steve Holden
Alex Martelli wrote:
Michael Tobis <[EMAIL PROTECTED]> wrote:
[...]
Let me add that I remain unconvinced that a language cannot combine the
best features of Python with very high performance, which is ultimately

I'm also unconvinced.  Fortunately, so is the EU, so they have approved
very substantial financing for the pypy project, which aims in good part
exactly at probing this issue.  If any single individual can be called
the ideator of pypy, I think it's Armin Rigo, well-known for his
excellent psyco specializing-compiler for Python: the key research
thesis behind both projects is that a higher-level, dynamic language
need not have performance inferior to a lower-level one and indeed may
well beat it.
I should be failing in my duty as Chairman if I didn't remind readers at 
this point that they can hear Armin Rigo's talk "PyPy and Type 
Inference" at PyCon at 5:30 on Wednesday March 23.

  http://www.python.org/pycon/dc2005/register.html
While Alex is not necessarily too modest to mention it he might forget 
that he is also giving three talks to PyCon. I believe this is the first 
year he has been able to attend PyCon, so delegates are definitely in 
for a treat this year.

regards
 Steve
--
Steve Holden   http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
Holden Web LLC  +1 703 861 4237  +1 800 494 3119
--
http://mail.python.org/mailman/listinfo/python-list


Re: stop program in komodo

2005-01-31 Thread Will McGugan
[EMAIL PROTECTED] wrote:
Hello,
How can we stop this peace of code in KOMODO:
while 1:
 print "helo"
I can't stop it, even using Ctrl+C
Are you sure that is what is happening? When I tried it, it appeared as 
though nothing had happened after pressing the break button. But it was 
just that the buffer had filled up with a squillion "helo"'s and was 
busy scrolling away..

Regards,
Will McGugan
--
http://mail.python.org/mailman/listinfo/python-list


Relocatable binary installs....

2005-01-31 Thread [EMAIL PROTECTED]
Hello all,

I'm currently working on a software package that is going to be
distributed in binary form (with accompanying source) for lot of
different unixes (Linux, AIX, HP-UX and others).  Parts of the package
are written in Python... so we are going to want to distribute our own
version of python.

Right now we are just distributing the Python tarball and building it
at install time.  This works ok, but we are running into some problems
on some machines with weird default installs (DEC Alphas in
particular) some of them won't build all the python modules we want
(although our in house machines will).

What I want to do is compile python statically into binaries and then
plop them wherever our customers choose to do an install (we will
provide the source tarballs on a cd as well).  The problem we are
running into is that when we do this python continues to think it's
still installed where it was initially compiled and not where it has
been placed (which causes some problems with traceback and some other
functions).

Is there a way to make a relocateable python binary... that is... a
python installation that won't care where it is on the machine... and
won't care if it gets put somewhere else besides /  ?

Sorry for the long winded post... just want to make sure you understand
my problem.

Thanks in advance for any help!

Derek

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


Re: Relocatable binary installs....

2005-01-31 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote:

> Is there a way to make a relocateable python binary... that is... a
> python installation that won't care where it is on the machine... and
> won't care if it gets put somewhere else besides /  ?

the standard CPython interpreter is 100% "relocatable".  If you think
it isn't, you have to be a bit more specific.

 



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


Re: stop program in komodo

2005-01-31 Thread [EMAIL PROTECTED]
Hello Will,

I have received information from [EMAIL PROTECTED]
That he has already added this problem as bug.

"I've added a bug for this:
http://bugs.activestate.com/show_bug.cgi?id=36443
Regards,
Shane"

So stay tune.

Pujo

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


Re: The next Xah-lee post contest

2005-01-31 Thread Erik Max Francis
Steve Holden wrote:
Would there, I wonder, be any enthusiasm for a "Best Xah Lee impression" 
prize at PyCon?
I imagine standing in a corner, facing the wall, and screaming 
incoherently at the top of your lungs would be guaranteed at least 
second place.

--
Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
  You've got me wondering / If you know that I am wondering about you
  -- India Arie
--
http://mail.python.org/mailman/listinfo/python-list


Re: ANNOUNCE: KirbyBase 1.7

2005-01-31 Thread Paul McGuire
"Jamey Cribbs" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Paul Rubin wrote:
> > That's cute, especially the part about using Python expressions
> > instead of SQL to express queries.  I don't see anything in the info
> > page about what happens when you have multiple clients updating the db
> > concurrently.  Do you make any attempt to handle that?
>
> Yep.  There are two server scripts included with the distribution.  One
> (kbsimpleserver.py) does serial, blocking requests, so there are no
> concurrent-access issues.  The second server script
> (kbthreadedserver.py) is threaded and non-blocking.  I have code in the
> script that manages read and write locks for each table.  I'm no rocket
> scientist, but I have been using kbthreadedserver.py at work for several
> months with no issues so far, so I am beginning to trust the code.  :)
>
> Jamey

Before you get too confident, you might try your code on a multiprocessor
machine, under some heavy stress test (or ask one of your collaborators if
you don't have access to such a thing).  Threaded code that runs on
uniprocessors can do very different/unexpected/unwanted things on
multiprocessors.

-- Paul


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


[ANN] Spike Asset Manager release 0.13

2005-01-31 Thread mh
Spike Asset Manager (SAM) is an open-source cross-platform framework
written in python for probing a system for components and reporting
them. It includes a driver file that probes for components commonly
found in a LAMPJ stack (Apache, MySQL, PHP, Tomcat, etc).  Note that
the L in LAMP could be Linux, Solaris, Windows or Mac.  SAM can find
multiple versions that are installed, query the rpm database and
indicate whether components are running.

Release 0.13 changes:
- Migrate to ElementTree from minidom
- Migrate to Cheetah from xsl
- Preliminary MacOSX support

thanks

Matt

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


Re: Relocatable binary installs....

2005-01-31 Thread Steve Holden
Fredrik Lundh wrote:
[EMAIL PROTECTED] wrote:

Is there a way to make a relocateable python binary... that is... a
python installation that won't care where it is on the machine... and
won't care if it gets put somewhere else besides /  ?

the standard CPython interpreter is 100% "relocatable".  If you think
it isn't, you have to be a bit more specific.
Is it possible that you are using "relocatable" in the standard sense of 
"code can be located anywhere in physical memory", where the OP is using 
the same term to mean "can live anywhere in the filestore"?

I suspect the problem the OP is seeing is because the --prefix 
configuration parameter will cause an interpreter to look in a specific 
place for standard libraries. Clearly if you "relocate" the libraries to 
another directory entirely then an interpreter without any further nouse 
(and no symbolic links to help it) is going to crap out badly.

But I could be wrong.
always-prepared-to-at-least-admit-the-possibility-ly y'rs  - steve
--
Steve Holden   http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
Holden Web LLC  +1 703 861 4237  +1 800 494 3119
--
http://mail.python.org/mailman/listinfo/python-list


Q: quoting string without escapes

2005-01-31 Thread Xah Lee
in Python, is there a way to quote a string as to avoid escaping ' or "
inside the string?

i.e. like Perl's q or qq.
thanks.

 Xah
 [EMAIL PROTECTED]
 http://xahlee.org/PageTwo_dir/more.html

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


Re: Q: quoting string without escapes

2005-01-31 Thread Steve Holden
Xah Lee wrote:
in Python, is there a way to quote a string as to avoid escaping ' or "
inside the string?
i.e. like Perl's q or qq.
thanks.
 Xah
 [EMAIL PROTECTED]
 http://xahlee.org/PageTwo_dir/more.html
Aren't you the guy who's telling the whole world how to write Python and 
Perl? Unusual to find arrogance and humility in such close proximity.

Please stop cross-posting your ill-informed and inflammatory stuff to 
c.l.py and c.l.perl.m. And now I have your attention, the answer to your 
question is ...

Use triple-quoting.
followups-set'ly y'rs  - steve
--
Steve Holden   http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
Holden Web LLC  +1 703 861 4237  +1 800 494 3119
--
http://mail.python.org/mailman/listinfo/python-list


Re: Relocatable binary installs....

2005-01-31 Thread Fredrik Lundh
Steve Holden wrote:

>>>Is there a way to make a relocateable python binary... that is... a
>>>python installation that won't care where it is on the machine... and
>>>won't care if it gets put somewhere else besides /  ?
>>
>>
>> the standard CPython interpreter is 100% "relocatable".  If you think
>> it isn't, you have to be a bit more specific.
>>
> Is it possible that you are using "relocatable" in the standard sense of 
> "code can be located 
> anywhere in physical memory", where the OP is using the same term to mean 
> "can live anywhere in 
> the filestore"?

nope.

> I suspect the problem the OP is seeing is because the --prefix configuration 
> parameter will cause 
> an interpreter to look in a specific place for standard libraries. Clearly if 
> you "relocate" the 
> libraries to another directory entirely then an interpreter without any 
> further nouse (and no 
> symbolic links to help it) is going to crap out badly.

clearly?

[EMAIL PROTECTED] build] mv python2.3 /tmp
[EMAIL PROTECTED] build] mkdir /tmp/lib
[EMAIL PROTECTED] build] mv lib /tmp/lib/python2.3
[EMAIL PROTECTED] build] cd /tmp
[EMAIL PROTECTED] tmp]$ ./python2.3
>>> import sys
>>> sys.prefix
'/tmp'
>>> sys.path
['', '/tmp/lib/python23.zip', '/tmp/lib/python2.3', ...]
>>>
[EMAIL PROTECTED] tmp]$ mkdir spam
[EMAIL PROTECTED] tmp]$ mv python2.3 spam
[EMAIL PROTECTED] tmp]$ mv lib spam
[EMAIL PROTECTED] tmp]$ cd spam/
[EMAIL PROTECTED] spam]$ ./python2.3
>>> import sys
>>> sys.prefix
'/tmp/spam'
>>> sys.path
['', '/tmp/spam/lib/python23.zip', '/tmp/spam/lib/python2.3', ...]
>>>

[EMAIL PROTECTED] spam]$ mkdir bin
[EMAIL PROTECTED] spam]$ mv python2.3 bin
[EMAIL PROTECTED] spam]$ bin/python2.3
>>> import sys
>>> sys.prefix
'/tmp/spam'
>>>

[EMAIL PROTECTED] spam]$ cd bin
[EMAIL PROTECTED] bin]$ ./python2.3
>>> import sys
>>> sys.prefix
'/tmp/spam'

[EMAIL PROTECTED] fredrik]$ export PATH=/tmp/spam/bin:$PATH
[EMAIL PROTECTED] bin]$ cd
[EMAIL PROTECTED] fredrik]$ python2.3
>>> import sys
>>> sys.prefix
'/tmp/spam'
>>>

and so on...

 



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


Re: Relocatable binary installs....

2005-01-31 Thread Steve Holden
Fredrik Lundh wrote:
Steve Holden wrote:

Is there a way to make a relocateable python binary... that is... a
python installation that won't care where it is on the machine... and
won't care if it gets put somewhere else besides /  ?

the standard CPython interpreter is 100% "relocatable".  If you think
it isn't, you have to be a bit more specific.
Is it possible that you are using "relocatable" in the standard sense of "code can be located 
anywhere in physical memory", where the OP is using the same term to mean "can live anywhere in 
the filestore"?

nope.

I suspect the problem the OP is seeing is because the --prefix configuration parameter will cause 
an interpreter to look in a specific place for standard libraries. Clearly if you "relocate" the 
libraries to another directory entirely then an interpreter without any further nouse (and no 
symbolic links to help it) is going to crap out badly.

clearly?
[EMAIL PROTECTED] build] mv python2.3 /tmp
[EMAIL PROTECTED] build] mkdir /tmp/lib
[EMAIL PROTECTED] build] mv lib /tmp/lib/python2.3
[EMAIL PROTECTED] build] cd /tmp
[EMAIL PROTECTED] tmp]$ ./python2.3
import sys
sys.prefix
'/tmp'
sys.path
['', '/tmp/lib/python23.zip', '/tmp/lib/python2.3', ...]
[EMAIL PROTECTED] tmp]$ mkdir spam
[EMAIL PROTECTED] tmp]$ mv python2.3 spam
[EMAIL PROTECTED] tmp]$ mv lib spam
[EMAIL PROTECTED] tmp]$ cd spam/
[EMAIL PROTECTED] spam]$ ./python2.3
import sys
sys.prefix
'/tmp/spam'
sys.path
['', '/tmp/spam/lib/python23.zip', '/tmp/spam/lib/python2.3', ...]
[EMAIL PROTECTED] spam]$ mkdir bin
[EMAIL PROTECTED] spam]$ mv python2.3 bin
[EMAIL PROTECTED] spam]$ bin/python2.3
import sys
sys.prefix
'/tmp/spam'
[EMAIL PROTECTED] spam]$ cd bin
[EMAIL PROTECTED] bin]$ ./python2.3
import sys
sys.prefix
'/tmp/spam'
[EMAIL PROTECTED] fredrik]$ export PATH=/tmp/spam/bin:$PATH
[EMAIL PROTECTED] bin]$ cd
[EMAIL PROTECTED] fredrik]$ python2.3
import sys
sys.prefix
'/tmp/spam'
and so on...
Well, OK, maybe it's not quite as clear as I thought :-)
regards
 Steve
--
Steve Holden   http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
Holden Web LLC  +1 703 861 4237  +1 800 494 3119
--
http://mail.python.org/mailman/listinfo/python-list


Re: variable declaration

2005-01-31 Thread Thomas Bartkus
"Alexander Zatvornitskiy"
<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hello All!
>
> I'am novice in python, and I find one very bad thing (from my point of
view) in
> language. There is no keyword or syntax to declare variable, like 'var' in
> Pascal, or special syntax in C. It can cause very ugly errors,like this:
>
> epsilon=0
> S=0
> while epsilon<10:
>   S=S+epsilon
>   epselon=epsilon+1
> print S
>
> It will print zero, and it is not easy to find such a bug!
>
> Even Visual Basic have 'Option Explicit' keyword! May be, python also have
such
> a feature, I just don't know about it?

Exactly so!
Python *does* require that your variables be declared and initialized before
you use them. You did that with epsilon=0 and S=0 at the top.  It is
unfortunate, however, that the statement epselon=epsilon+1 also declares a
new variable in the wrong place at the wrong time. Such mispellings are a
*common* error caught instantly in languages that require a more formal
declaration procedure.

Another irksome sitiuation is that while Python does enforce strict type
checking, you can re-declare variables and morph them in the middle of
nowhere.
 S = 0   # It's an Integer!
 S = S + 'Hello' # No can do! Strong type checking forbids this.
 S = 'GoodBye' # Whoops - Now it's a string! Unfortunately
legal!
This seemingly demolishes all the good reasons one has for wanting strict
type checking.

That second example is just bad programming practice and easy to avoid.  The
problem you point out in your code, however, hurts! Was that an I, an l or a
1 in the variable name?

Hey! - I like Python a lot.
But nothings perfect
Thomas Bartkus


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


Re: [ANN] Spike Asset Manager release 0.13

2005-01-31 Thread Skip Montanaro

Matt> Spike Asset Manager (SAM) is an open-source cross-platform
Matt> framework written in python for probing a system for components
Matt> and reporting them.

Matt,

That's a pretty generic description.  Pardon my ignorance, but what's the
advantage over, for example, "rpm -aq | grep httpd"?

-- 
Skip Montanaro
[EMAIL PROTECTED]
http://www.mojam.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


msvcp71.dll and Python 2.4 C++ extensions

2005-01-31 Thread Matthias Baas
Hi,

are there any guidelines about what to do if a Windows extension for
Python 2.4  requires the C++ runtime (msvcp71.dll)? If I want to
distribute a binary installer of an extension that contains C++ code,
should I really include the msvcp71.dll in the package? It doesn't
sound like a good idea to me if every package places another copy of
this dll somewhere in the Python directory.
Python 2.4 does install the C runtime (msvcr71.dll) in the Windows
system32 directory, doesn't it? (btw, shouldn't this be installed in
the Python directory instead?) So would it be possible that future
Python releases would also install the C++ runtime? I think it's
better if the dll would only be installed once by Python instead of
several times by every extension that uses C++.

Currently, I do not package the C++ runtime and leave it up to the
user to install the dll if it isn't already somewhere on his system.
But this really is not a satisfying solution...

- Matthias -

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


py-xmlrpc postpone question

2005-01-31 Thread elbertlev
Hi!
I'm trying to use py-xmlrpc. All works fine (and very fast) in
one-threaded case, but I really have to serve many clients.

As advertised, py-xmlrpc supports non-blocking calls (via select).

When request is received the handler is called with proper parameters.
As I understood from reading the source, if rpc call can't be executed
immediately (or takes long time) respond can be postponed by raising
postpone exception and when respond is ready, calling queueResponse() .


I wanted to have a pool of worker threads listening on a queue. In the
"lengthy command handlers", post data on the queue and raise postpone.
Threads from the pool respond by calling queueResponse() when rpc is
done.

Server trace tells me that postpone was received, but client reacts as
if socket was closed (got EOS while reading). I tryed to supress
default error handling on the client side by returning from OnErr()
xmlrpc.ONERR_KEEP_WORK, but this kills the interpreter!
What am I doing wrong?

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


Re: [ANN] Spike Asset Manager release 0.13

2005-01-31 Thread Fredrik Lundh
Skip Montanaro wrote:

>Matt> Spike Asset Manager (SAM) is an open-source cross-platform
>Matt> framework written in python for probing a system for components
>Matt> and reporting them.
>
> That's a pretty generic description.  Pardon my ignorance, but what's the
> advantage over, for example, "rpm -aq | grep httpd"?

C:\>rpm -aq | grep httpd
'rpm' is not recognized as an internal or external command,
operable program or batch file.

(on the other hand, it doesn't find any Python installation on my machine, which
I do find a bit strange...)

 



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


Handling MySQL connection

2005-01-31 Thread Josh
Hi,

First off, I am a newbie to Python and so far I must say that we're
getting along pretty well. My schooling was is C/C++, but have been
writing code in, dare I say it, VB, for the past 4 years.

Here is the problem I have run across. I am using SPE w/WXGlade to
setup the GUI, so it handled the initial formatting of my python code
as two seperate classes, one for the APP and one for the Frame. I'll be
the first to admit I haven't gotten a good grasp on how things should
flow within a python program. Anyway, what I have done is created a few
functions using the DEF statement to handle the action of the widgets.
Part of the program is accessing a MySQL database. Once a button is
pushed, part of it's function is to open the database, check to see if
a value exists, and then close the connection. Running this locally on
my PC, which is also where MySQL resides, returns results instantly.
The flow is
a) Open a connection to the database
b) Execute a simple Select statement to verify the field
c) Close the connection.
All done within a single DEF

This works fine and dandy on my Windows 2000 PC that is also acting as
the MySQL server, but when I transfer the program to a Linux box
running Fedora, there is a very noticable lag when this action takes
place. So my thought is rather than connecting to the database,
fetching the data, then closing out the connection every time, it may
be a better idea to connect to the database upon starting the program,
leaving the connection open, making the transactions as needed, and
then closing the connection upon leaving the program. Doing this,
however, has proved to be a little more difficult than I thought, and
I'm sure it's just because of my lack of knowledge of Python.

So I put the question out, how do I accomplish this?

Do I need some sort of Global(such an evil word) object to work off of?

In the Def __init__ I would like to open the connection
eg: connection = MySQLdb.connect(host="localhost", user="root",
passwd="blah", db="data")

In a Sepeate Function I would like to make the transactions on it.
eg: cursor = connection.cursor()
cursor.execute( "SELECT * FROM tags WHERE tags.tag_no = %s"
%temp_tag )
self.data = cursor.fetchall()
cursor.close()

Finally in another Function I would like to be able to close the
connection
eg: connection.close()

All of these Def's would fall under the same Frame class. Am I going
about this incorrectly? 

Thanks for your help and patience. 

Josh

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


Re: python and gpl

2005-01-31 Thread Scott Robinson
On 30 Jan 2005 21:59:25 -0800, Paul Rubin
 wrote:

>John Hunter <[EMAIL PROTECTED]> writes:
>> The question is: does shipping a backend which imports a module that
>> links with GPL code make some or all of the library GPL.
>
>Literally speaking, no, not automatically, any more than driving a car
>makes you into a licensed driver if you weren't one already.  But if
>you weren't licensed, then you've broken the law by driving the car.
>So your question should be: 1) is shipping that backend one of the
>things you need the GPL to license you to legally do, and 2) if so,
>does the GPL in fact give you that license?
>
>If you're asking in terms of legal enforcement, the answer is 1) maybe
>and 2) almost certainly not.  I think it's better to ask in terms of
>the GPL's spirit.  I would say that it's not in the GPL's spirit and
>that GPL die-hards would consider that use objectionable, though they
>might make exceptions for specific cases (so it doesn't hurt to ask).
>Some authors who use the GPL are less strict about how they interpret
>it, so again, the friendly thing to do is ask the author.
>
>  * If a backend module somebackend does
>
> import somelib
>
>where somelib is a python wrapper of GPL code, is somebackend GPLd?
>
>It's GPL'd if you GPL it.  If you don't GPL it, then distributing it
>it may be a GPL violation that could get you taken to court.  I
>believe the FSF's view is that it is fact a violation; however, the
>courts have not yet established this.  The law doesn't have a
>black-and-white boundary.  It's more like a fractal.  The only way to
>find out what a court will decide is to actually try a case there.
>
>Rather than try to probe how closely you can dance around the
>boundaries of the GPL, you might just ask the author of the GPL'd
>library whether what you want to do is ok with him or her.  If s/he
>says no and you do it anyway, you're both inviting trouble over the
>possible infringement, and also inviting people to try to use your
>code in ways you don't like.  Since the free software movement depends
>on a spirit of cooperation, I think it's best to avoid trying to press
>too hard against the boundaries of anyone's licenses.
>
>http://www.gnu.org/licenses/gpl-faq.html

If you read the GPL, it claims everything it can (any "work" created
using GPLed "work").  My guess is that anything that calls the code in
a way not specifically allowed by the author is going to get you into
trouble.  IANAL, but from what I can remember about earlier licensing
issues, any code specific for a GPLed library (especially "import")
will get you into to trouble.  Having a non-free library with an
identical API and issuing 
exec("import "+sys.argv[1])
where the user can supply sys.argv as the name of the gpl'ed library
will work (I think there is a free/non-free library out there that is
never run, but exists for exactly this condition).

Scott Robinson

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


Re: Description Field in WinXP Services

2005-01-31 Thread Larry Bates
Roger,
I wrote an extension to Mark Hammond's win32serviceutil.ServiceFramework class
(that I submitted to him also) that extends the class to provide you with this 
functionality (along with the ability to support py2exe frozen services better).

Here it is:
import _winreg
import os
import win32evtlogutil
class NTserviceBase:
'''
Written by: Larry A. Bates - Syscon, Inc.  March 2004
This is a base class for creating new NTservices with Python.
It should be included when you are defining your class as follows:
class newNTservice(win32serviceutil.ServiceFramework, NTserviceBase):
#
# Required attributes for a service
#
_svc_name_="newNTservice"
_svc_display_name_="newNTservice"
_svc_description_='newNTservice is a service that can be installed ' \
  'and 'run on any Windows NT, 2000, XP, 2003 ' \ 

  'computer.  It can be controlled by services applet' \
  'in the Control Panel and will run unattended ' \
  'after being started.'
def __init__(self, args):
NTserviceBase.__init__(self)
win32serviceutil.ServiceFramework.__init__(self, args)
#
# Create an event which we will use to wait on.
# The "service stop" request will set this event.
#
self.hWaitStop=win32event.CreateEvent(None, 0, 0, None)
return
Note: the __init__ method of the created class should call the __init__
method of NTserviceBase AND win32serviceutil.ServiceFramework to get
everything initialized properly
'''
def __init__(self):
#---
# Call function to set self.PythonService (0=binary, 1=Python)
#---
self.getSERVICEtype()
self.installpath=self.getSERVICEpath()
#---
# Call function to set Service's long description string.  Can't
# seem to find a way to do this that works for both PythonServices
# and binary (py2exe) services.  So I will set the description
# every time the service is started.
#---
self.setSERVICEdescription()
#---
# Call function to register eventlog message handler which is
# different if I'm a binary vs. PythonService.
#---
self.getPythonServicePath()
#---
# If this is a PythonService, point to installed PythonService.exe
# if not, point to a copy of PythonService.exe that gets installed
# along with the binary.  Note: on binary distributions you must
# include a copy of PythonService.exe along with your other files
# to provide EventLog message decoding.
#---
if self.PythonService: sourcepath=self.PythonServicePath
else: sourcepath=os.path.join(self.installpath, "PythonService.exe ")
self.setSERVICEeventlogSource(sourcepath)
return
def getSERVICEtype(self):
'''
Function to determine if this is a Python service or a binary service
created by py2exe.  Sets self.PythonService=1 if it is a Python service
or PythonService=0 if it is a binary service.
'''
#-
# This service can run as a PythonService or it can run as a binary
# .EXE service (created by py2exe).  We can sense this by looking
# to see if
# HKLM\SYSTEM\CurrentControlSet\Services\_svc_name_\PythonClass
# key exists in the registry.  If it doesn't, then I'm a binary
# install.
#-
# Open registry and search for PythonService install
#-
regkey='SYSTEM\CurrentControlSet\Services\%s' % self._svc_name_
key=_winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, regkey)
nsubkeys, nvalues, lastmodified=_winreg.QueryInfoKey(key)
#-
# Begin by assuming I'm a binary (non-Python) service created by py2exe
#-
self.PythonService=0
#-
# Loop over the keys in this branch looking for "PythonService" key
#---

Re: barchart for webpage needed

2005-01-31 Thread Larry Bates
dimitri pater wrote:
Hello,
I am looking for a Python tool to create graphs and charts on a
webpage. Chartdirector is too expensive for me. A simple script for
creating a barchart should be sufficient as a starting point.
Thanks!
Dimitri
ReportLab's Graphics module is free and works quite well for me.
www.reportlab.org
Larry Bates
--
http://mail.python.org/mailman/listinfo/python-list


[perl-python] find & replace strings for all files in a dir

2005-01-31 Thread Xah Lee
suppose you want to do find & replace of string of all files in a
directory.
here's the code:

©# -*- coding: utf-8 -*-
©# Python
©
©import os,sys
©
©mydir= '/Users/t/web'
©
©findStr=''
©repStr=''
©
©def replaceStringInFile(findStr,repStr,filePath):
©"replaces all findStr by repStr in file filePath"
©tempName=filePath+'~~~'
©input = open(filePath)
©output = open(tempName,'w')
©
©for s in input:
©output.write(s.replace(findStr,repStr))
©output.close()
©input.close()
©os.rename(tempName,filePath)
©print filePath
©
©def myfun(dummy, dirr, filess):
© for child in filess:
© if '.html' == os.path.splitext(child)[1] and
©os.path.isfile(dirr+'/'+child):
© replaceStringInFile(findStr,repStr,dirr+'/'+child)
©os.path.walk(mydir, myfun, 3)


note that files will be overwritten.
be sure to backup the folder before you run it.

try to edit the code to suite your needs.

previous tips can be found at:
http://xahlee.org/perl-python/python.html

---
the following is a Perl version i wrote few years ago.
Note: if regex is turned on, correctness is not guranteed.
it is very difficult if not impossible in Perl to move regex pattern
around and preserve their meanings.


#!/usr/local/bin/perl

=pod

Description:
This script does find and replace on a given foler recursively.

Features:
* multiple Find and Replace string pairs can be given.
* The find/replace strings can be set to regex or literal.
* Files can be filtered according to file name suffix matching or other

criterions.
* Backup copies of original files will be made at a user specified
folder that preserves all folder structures of original folder.
* A report will be generated that indicates which files has been
changed, how many changes, and total number of files changed.
* files will retain their own/group/permissions settings.

usage:
1. edit the parts under the section '#-- arguments --'.
2. edit the subroutine fileFilterQ to set which file will be checked or

skipped.

to do:
* in the report, print the strings that are changed, possibly with
surrounding lines.
* allow just find without replace.
* add the GNU syntax for unix command prompt.
* Report if backup directory exists already, or provide toggle to
overwrite, or some other smarties.

Date created: 2000/02
Author: Xah

=cut

#-- modules --

use strict;
use File::Find;
use File::Path;
use File::Copy;
use Data::Dumper;

#-- arguments --

# the folder to be search on.
my $folderPath = q[/Users/t/web/UnixResource_dir];

# this is the backup folder path.
my $backupFolderPath = q[/Users/t/xxxb];

my %findReplaceH = (
q[back to Unix
Pestilence]=>q[? Back to Unix
Pestilence],
);

# $useRegexQ has values 1 or 0. If 1, inteprets the pairs in
%findReplaceH
# to be regex.
my $useRegexQ = 0;

# in bytes. larger files will be skipped
my $fileSizeLimit = 500 * 1000;


#-- globals --

$folderPath =~ s[/$][]; # e.g. '/home/joe/public_html'
$backupFolderPath =~ s[/$][]; # e.g. '/tmp/joe_back';

$folderPath =~ m[/(\w+)$];
my $previousDir = $`;   # e.g. '/home/joe'
my $lastDir = $1;   # e.g. 'public_html'
my $backupRoot = $backupFolderPath . '/' . $1; # e.g.
'/tmp/joe_back/public_html'

my $refLargeFiles = [];
my $totalFileChangedCount = 0;

#-- subroutines --

# fileFilterQ($fullFilePath) return true if file is desired.
sub fileFilterQ ($) {
my $fileName = $_[0];

if ((-s $fileName) > $fileSizeLimit) {
push (@$refLargeFiles, $fileName);
return 0;
};
if ($fileName =~ m{\.html$}) {
print "processing: $fileName\n";
return 1;};

##if (-d $fileName) {return 0;}; # directory
##if (not (-T $fileName)) {return 0;}; # not text file

return 0;
};

# go through each file, accumulate a hash.
sub processFile {
my $currentFile = $File::Find::name; # full path spect
my $currentDir = $File::Find::dir;
my $currentFileName = $_;

if (not fileFilterQ($currentFile)) {
return 1;
}

# open file. Read in the whole file.
if (not(open FILE, "<$currentFile")) {die("Error opening file:
$!");};
my $wholeFileString;
{local $/ = undef; $wholeFileString = ;};
if (not(close(FILE))) {die("Error closing file: $!");};

# do the replacement.
my $replaceCount = 0;

foreach my $key1 (keys %findReplaceH) {
my $pattern = ($useRegexQ ? $key1 : quotemeta($key1));
$replaceCount = $replaceCount + ($wholeFileString =~
s/$pattern/$findReplaceH{$key1}/g);
};

if ($replaceCount > 0) { # replacement has happened
$totalFileChangedCount++;
# do backup
# make a directory in the backup path, make a backup
copy.
my $pathAdd = $currentDir; $pathAdd =~
s[$folderPath][];
mkpath("$backupRoot/$pathAdd", 0, 0777);
copy($currentFile,
"$backupRoot/$pathAdd/$currentFileName") or
die "error: file copying file failed on
$currentFile\n$!";

# write to the original
# get the file mode.
my ($mode, $uid, $gid) = (stat($currentFile))[2,4,5];

# write out a new file.
if (not(open OUTFILE, ">$currentFile")) {die("Error
opening file: $!");};
print OUTFILE $wholeFileString;
if

Re: python and gpl

2005-01-31 Thread Steve Holden
Scott Robinson wrote:
On 30 Jan 2005 21:59:25 -0800, Paul Rubin
 wrote:

John Hunter <[EMAIL PROTECTED]> writes:
The question is: does shipping a backend which imports a module that
links with GPL code make some or all of the library GPL.
Literally speaking, no, not automatically, any more than driving a car
makes you into a licensed driver if you weren't one already.  But if
you weren't licensed, then you've broken the law by driving the car.
So your question should be: 1) is shipping that backend one of the
things you need the GPL to license you to legally do, and 2) if so,
does the GPL in fact give you that license?
If you're asking in terms of legal enforcement, the answer is 1) maybe
and 2) almost certainly not.  I think it's better to ask in terms of
the GPL's spirit.  I would say that it's not in the GPL's spirit and
that GPL die-hards would consider that use objectionable, though they
might make exceptions for specific cases (so it doesn't hurt to ask).
Some authors who use the GPL are less strict about how they interpret
it, so again, the friendly thing to do is ask the author.
* If a backend module somebackend does
   import somelib
  where somelib is a python wrapper of GPL code, is somebackend GPLd?
It's GPL'd if you GPL it.  If you don't GPL it, then distributing it
it may be a GPL violation that could get you taken to court.  I
believe the FSF's view is that it is fact a violation; however, the
courts have not yet established this.  The law doesn't have a
black-and-white boundary.  It's more like a fractal.  The only way to
find out what a court will decide is to actually try a case there.
Rather than try to probe how closely you can dance around the
boundaries of the GPL, you might just ask the author of the GPL'd
library whether what you want to do is ok with him or her.  If s/he
says no and you do it anyway, you're both inviting trouble over the
possible infringement, and also inviting people to try to use your
code in ways you don't like.  Since the free software movement depends
on a spirit of cooperation, I think it's best to avoid trying to press
too hard against the boundaries of anyone's licenses.
http://www.gnu.org/licenses/gpl-faq.html

If you read the GPL, it claims everything it can (any "work" created
using GPLed "work").  My guess is that anything that calls the code in
a way not specifically allowed by the author is going to get you into
trouble.  IANAL, but from what I can remember about earlier licensing
issues, any code specific for a GPLed library (especially "import")
will get you into to trouble.  Having a non-free library with an
identical API and issuing 
	exec("import "+sys.argv[1])
where the user can supply sys.argv as the name of the gpl'ed library
will work (I think there is a free/non-free library out there that is
never run, but exists for exactly this condition).

Scott Robinson
I presume the appropriate way to answer this question is to ask the Gnu, 
since under these circumstances the Python zen would advise "refuse the 
temptation to guess". So I am Cc'ing [EMAIL PROTECTED] with a request for an 
answer to the (apparently relatively simple) question:

If a Python program imports a module licensed under the GPL, in your 
opinion does the Python program become a derivative work of the GPL'd 
software?

regards
 Steve
--
Steve Holden   http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
Holden Web LLC  +1 703 861 4237  +1 800 494 3119
--
http://mail.python.org/mailman/listinfo/python-list


Anyone else experience Thread.join() returning early?

2005-01-31 Thread Michael Hobbs
I just wanted to see if anyone else experienced a problem with the
Thread.join() method in Python 2.4. Unfortunately, I did not debug this
problem fully before re-writing my code to avoid Thread.join(). 

My specific situation was that I called subprocess.Popen() to spawn a
separate process with the stdout redirected to a pipe. I then created
a Thread to process the data coming through the pipe. The thread would
terminate when it encountered EOF on the pipe.

When I used Thread.join(), I would encounter symptoms that lead me to
believe that join() was returning before the subprocess actually
terminated. After I rewrote the code to manually manipulate a lock
instead of using Thread.join(), the symptoms went away.

I guess that I'm just curious to see if anyone else has encountered a
problem here, so that a bug can be filed if necessary. I did a quick
Google search, but didn't see any other reports.

Thanks,
- Mike
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: variable declaration

2005-01-31 Thread Carl Banks

Thomas Bartkus wrote:
> Python *does* require that your variables be declared and initialized
before
> you use them. You did that with epsilon=0 and S=0 at the top.  It is
> unfortunate, however, that the statement epselon=epsilon+1 also
declares a
> new variable in the wrong place at the wrong time. Such mispellings
are a
> *common* error caught instantly in languages that require a more
formal
> declaration procedure.


I have no interest in arguing this right now, but it does raise a
question for me:  How common is it for a local variable to be bound in
more than one place within a function?  It seems that it isn't (or
shouldn't be) too common.

Certainly the most common case where this occurs is for temporary
variables and counters and stuff.  These typically have short names and
thus are not as likely to be misspelled.

Another common place is for variables that get bound before and inside
a loop.  I would guess that's not as common in Python as it is in other
languages, seeing that Python has features like iterators that obviate
the need to do this.  (The OP's original example should have been "for
epsilon in range(10)"; epsilon only needed bound in one place.)

I guess this might be why, in practice, I don't seem to encounter the
misspelling-a-rebinding error too often, even though I'm prone to
spelling errors.  Perhaps, if someone runs into this error a lot, the
problem is not with Python, but with their tendency to rebind variables
too much?  Just a thought.


-- 
CARL BANKS

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


Re: [ANN] Spike Asset Manager release 0.13

2005-01-31 Thread mh
The idea is to have a framework to do this in a semi-crossplatform
manner.  The framework could be updated to know about apt, portage
repositories as well as talk to to the windows registry.
Not everyone is running redhat ;)

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


Request for Feedback; a module making it easier to use regular expressions.

2005-01-31 Thread Kenneth McDonald
I'm working on the 0.8 release of my 'rex' module, and would appreciate
feedback, suggestions, and criticism as I work towards finalizing the
API and feature sets. rex is a module intended to make regular expressions
easier to create and use (and in my experience as a regular expression
user, it makes them MUCH easier to create and use.) 

I'm still working on formal documentation, and in any case, such 
documentation isn't necessarily the easiest way to learn rex. So, I've
appended below a rex interactive session which was then annotated
with explanations of the features being used. I believe it presents a
reasonably good view of what rex can do. If you have time, please
read it, and then send your feedback via email. Unfortunately, I do not
currently have time to keep track of everything on comp.lang.python.

Thanks,
Ken McDonald

=

 What follows is an illustration by example of how the 'rex' module works, for 
those already knowledgable of regular expressions as used in Python's 're' (or 
similar) regular expressions package. It consists of a quick explanation of a 
rex feature, followed by an interactive demo of that feature. You need to 
understand a couple of quick points to understand rex and the demo.
 
 1) To distinguish between standard regular expressions as constructed by hand 
and used with the 're' package, and regular expressions constructed by and used 
in 'rex', I'll call the former 'regexps', and the latter 'rexps'.
 
 2) The Rexp class, of which every rexp is an instance, is simply a subclass of 
Python's regular string class, with some modified functionality (for example, 
the __add__ method has been changed to modify the action of the '+' operation), 
and many more operators and methods. I'm not sure this was the wisest thing to 
do, but it sure helps when trying to relate rexps to regexps; just construct a 
rexp interactively or in a program and print it, and in either case you'll see 
the underlying string that is passed to the 're' module functions and methods.
 
 On to the tutorial.
  
 'rex' is designed have few public names, so the easiest way to use
 it is to import all the names:
>>> from rex import *

The most basic rex function is PATTERN, which simply takes a string or strings, 
and produces a rexp which will match exactly the argument strings when used to 
match or search text. As mentioned above, what you see printed as the result of 
executing PATTERN is the string that will be (invisibly) passed to 're' as a 
regexp string.
>>> PATTERN("abc")
'abc'

If given more than one argument, PATTERN will concatenate them into a single 
rexp.
>>> PATTERN("abc", "d")
'abcd'

The other rex function which converts standard strings to rexps is CHARSET, 
which produces patterns which match a single character in searched text if that 
character is in a set of characters defined by the CHARSET operation. This is 
the equivalent of the regexp [...] notation. Every character in a string passed 
to CHARSET will end up in the resulting set of characters.
>>> CHARSET("ab")
'[ab]'

If CHARSET is passed more than one string, all characters in all arguments are 
included in the result rexp.
>>> CHARSET("ab", "cd")
'[abcd]'

If an argument to CHARSET is a two-tuple of characters, it is taken as 
indicating the range of characters between and including those two characters. 
This is the same as the regexp [a-z] type notation. For example, this defines a 
rexp matching any single consonant.
>>> CHARSET('bcd', 'fgh', ('j', 'n'), ('p', 't'), 'vwxz')
'[bcdfghj-np-tvwxz]'
 
When using CHARSET (or any other rexp operation), you do _not_ need to worry 
about escaping any characters which have special meanings in regexps; that is 
handled automatically. For example, in the follwing character set containing 
square brackets, a - sign, and a backslash, we have to escape the backslash 
only because it has a special meaning in normal Python strings. This could be 
avoided by using raw strings. The other three characters, which have special 
meaning in regexps, would have to be escaped if building this character set by 
hand.
>>> CHARSET('[]-\\')
'[\\[\\]\\-]'
The result above is what you'd need to type using re and regexps to directly 
define this character set. Think you can get it right the first time?

CHARSET provides a number of useful attributes defining commonly used character 
sets. Some of these are defined using special sequences defined in regexp 
syntax, others are defined as standard character sets. In all cases, the common 
factor is that CHARSET attributes all define patterns matching a _single_ 
character. Here are a few examples:
>>> CHARSET.digit
'\\d'
>>> CHARSET.alphanum
'\\w'
>>> CHARSET.uspunctuation
'[EMAIL PROTECTED]&*()_\\-+={\\[}\\]|:;"\'<,>.?/

Re: python and gpl

2005-01-31 Thread Tim Churches
John Hunter wrote:
I have a question about what it takes to trigger GPL restrictions in
python code which conditionally uses a GPL library.
Here is the context of my question.  matplotlib, which I develop, is a
plotting module which is distributed under a PSF compatible license,
and hence we avoid using GPLd code so as to not trigger the GPL
requirements.  matplotlib has rigid segregation between the front end
(plotting commands, figure objects, etc) and backends (gtk, wx, ps,
svg, etc).  The backend is chosen dynamically at runtime -- eg the
same python script could trigger the import gtk, wx, or ps, depending
an some rc settings or command line opts.
The question is: does shipping a backend which imports a module that
links with GPL code make some or all of the library GPL. 

We sought formal legal advice on this issue from a lawyer with expertise 
in open source licensing - in our case, our application which is 
licensed under a (very slightly) modifided version of the Mozilla Public 
License v1.1 imports a GPLed Python module (RPy) which wraps a GPLed 
library (R).

The answer was that the GPL does not apply to combination of code at 
run-time. Specifically, Section 0., Para 1 (assuming zero-based 
paragraph numbering...) says:

"Activities other than copying, distribution and modification are not 
covered by this License; they are outside its scope. The act of running 
the Program is not restricted,..."

Furthermore, Section 2 para 1 says:
"These requirements apply to the modified work as a whole. If 
identifiable sections of that work are not derived from the Program, and 
can be reasonably considered independent and separate works in 
themselves, then this License, and its terms, do not apply to those 
sections when you distribute them as separate works. ..."

and Section 2 para 3 says:
"In addition, mere aggregation of another work not based on the Program 
with the Program (or with a work based on the Program) on a volume of a 
storage or distribution medium does not bring the other work under the 
scope of this License."

On the basis of these clauses, the legal advice to us was that merely 
including "import rpy" and making calls to RPy-wrapped R functions does 
not invoke the provisions of the GPL because these calls only relate to 
run-time linking, which is not covered by the GPL. However, combining 
GPLed source code or static linking would invoke the GPL provisions. 
Additionally, we were advised to (re-)distribute any GPLed components 
required by our application in clearly separate packages i.e as separate 
tarballs or zip files, and not to bind them together in an omnibus 
distribution or installation file. However, putting them on the same 
CD-ROM or other media is fine.

Note that the formal advice was specific to Australian law, and did 
mention some Australian case law regarding fair use under the Copyright 
Act with respect to making API calls - that relates to our application 
making API calls to the GPLed library which is imported at runtime. The 
opinion was that we were on safe ground here, but you might want to 
investigate this aspect wrt copyright laws in other countries. My 
understanding is that most copyright law provides for "fair use" which 
may cover use of parts of an API to a GPLed library (as distinct from 
complete incorporation of the entire API into another application - 
which would invoke the GPL).

IANAL, and the above constitutes mangled paraphrasing of carefully 
worded formal legal advice, the scope of which was restricted to 
Australian law. However, the sections of the GPL quoted above are pretty 
unambiguous.

The other, informal advice, was to ignore the FAQs and other opinions on 
the FSF web site regarding intepretation of the GPL - it's only the 
license text which counts.

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


Re: [ANN] Spike Asset Manager release 0.13

2005-01-31 Thread mh
Fredrik-

This is a known issue.  The tool currently only looks in certain
locations or hints rather then spidering the whole hard drive (which
could take a bit of time).  If you have installed in a non-standard
location (or are using a platform or version of software that hasn't
been tested against) the tool won't find the component.

One way around this is manually enter more "hints" but this doesn't
scale.  I'm open to suggestions for handling this in a better way.

matt

ps-I assume you are running on windows.  Where is python installed on
your machine?

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


Re: variable declaration

2005-01-31 Thread Aahz
In article <[EMAIL PROTECTED]>,
Alex Martelli <[EMAIL PROTECTED]> wrote:
>
>Some people claim a language should change the way you think -- a
>frequent poster, excellent Python contributor, and friend, even has that
>claim in his signature.  

Generally speaking, I change my .sig either when I get bored or when
someone references it.  So here's the new one.
-- 
Aahz ([EMAIL PROTECTED])   <*> http://www.pythoncraft.com/

"Given that C++ has pointers and typecasts, it's really hard to have a serious 
conversation about type safety with a C++ programmer and keep a straight face.
It's kind of like having a guy who juggles chainsaws wearing body armor 
arguing with a guy who juggles rubber chickens wearing a T-shirt about who's 
in more danger."  --Roy Smith, c.l.py, 2004.05.23
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Want to meet any of these people? They are registered for PyCon

2005-01-31 Thread Aahz
In article <[EMAIL PROTECTED]>,
Steve Holden  <[EMAIL PROTECTED]> wrote:
>
>Note that the sort order isn't perfect - I just sorted on the second 
>"word" in each name. PyCon is a *great* place to meet people and discuss 
>ideas. Hope to see you there.

Good thing I'm not coming this year, eh?  ;-)
-- 
Aahz ([EMAIL PROTECTED])   <*> http://www.pythoncraft.com/

"Given that C++ has pointers and typecasts, it's really hard to have a serious 
conversation about type safety with a C++ programmer and keep a straight face.
It's kind of like having a guy who juggles chainsaws wearing body armor 
arguing with a guy who juggles rubber chickens wearing a T-shirt about who's 
in more danger."  --Roy Smith, c.l.py, 2004.05.23
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Q: quoting string without escapes

2005-01-31 Thread Daniel Bickett
On Mon, 31 Jan 2005 14:09:10 -0500, Steve Holden <[EMAIL PROTECTED]> wrote:
>  Use triple-quoting.

An example, for the sake of examples:

Python 2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> string = """ " ' " ' " ' " ' \""" """
>>> string
' " \' " \' " \' " \' """ '
>>> string = """
... "
... "
... "
... '
... '
... '
... \"""
... "\""
... ""\"
... """
>>> string
'\n"\n"\n"\n\'\n\'\n\'\n"""\n"""\n"""\n'

-- 
Daniel Bickett
dbickett at gmail.com
http://heureusement.org/
-- 
http://mail.python.org/mailman/listinfo/python-list


Spawning, and Killing, a Process

2005-01-31 Thread brolewis
I am writing a program on Windows (XP Pro) that as part of the
application takes advantage of rsync's ability to synchronize a client
and server computer. However, because of the nature of our company's
policies and our proxy, I must connect using SSH and use it as a tunnel
to get to the location I need on the inside.

My delimma is that I need to be able to spawn a process that uses the
SSH, runs rsync, and then I need to be able to kill the SSH process and
do not know a way to do that in Windows. I also would prefer to have
SSH run invisible to the end user (no new window) which I get when
using spawnl

The commands I am running are as follows:

SSH Tunnel:
ssh [EMAIL PROTECTED] -i file_name -L
873:200.200.60.60:7000 -N

Rsync Command:
rsync -azv [EMAIL PROTECTED]::package .

I am aware that you should be able to run ssh inside of rsync but there
seems to be a problem with the port of rsync that prevents me from
accomplishing this.
I thank you in advance for any assistance you are able to give.

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


"Mail receiver server"

2005-01-31 Thread manatlan
In an intranet/lan, i'd like to put a "python server script" (which run 
forever) on a computer A...

On another computer B, I'd like to send smtp-email to the computer A ... 
(send to "[EMAIL PROTECTED]", for example ...126.52.12.12 is the ip 
address of "B")

in fact, i'd like to control "computer A" by sending smtp email from 
"computer B".

What kind of server should i write on computer "B", a smtp server ? a 
pop server ?
(i think i have to make a script which listen on a port, and execute 
some handlers ... but i don't know how to start)

i know python very well, but i dont know anything about smtp/lan
if you have a recipe to build this kind of server, it could be good
but i'm pretty sure it can be easy to do ...
--
http://mail.python.org/mailman/listinfo/python-list


serializing data structures

2005-01-31 Thread Philippe C. Martin
Hi,

I am trying to figure out the traps/issues about sending data structures
through a TCP/IP socket under the following circumstances:

1) there could be a different O/S on both side of the socket
2) there could be a difference CPU architecure on both side of the
socket
3) there could be a different major release of python (ex 2.3 and 2.4)
on both side of the socket.


I once wrote something in C to do that, but since python usually has a
solution for me 


Any clue ?

Regards,


Philippe





-- 
***
Philippe C. Martin
SnakeCard LLC
www.snakecard.com
***

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


Re: "Mail receiver server"

2005-01-31 Thread Mitja
On Mon, 31 Jan 2005 23:23:46 +0100, manatlan <[EMAIL PROTECTED]>  
wrote:

in fact, i'd like to control "computer A" by sending smtp email from  
"computer B".

What kind of server should i write on computer "B", a smtp server ? a  
pop server ?
It would be easier if you used an existing mail server (which OS are you  
running on comp B?), then use its redirecting features to pipe the  
incoming mail to your python script. AFAIK most servers support that. Less  
hassle, though probably a wee bit more intensive for the computer.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Microsoft Visual C++ and pyton

2005-01-31 Thread mike
Thanks Chris..
I was also advised to build the python core (pythoncore.vcproj) with my
C++ program. By that way I would not have to load the python core
anymore during runtime. Is this a good approach?
I am currently using VC++ 7 and python 2.4.
- mike

Christopher De Vries wrote:
> On Sun, Jan 30, 2005 at 03:12:06PM -0800, mike wrote:
> > I am new with python.  Is it possible to have an MFC application
and
> > develop some module using python? what are the steps in doing this?
can
> > anybody give me a url or some documentation for this.. thanks..
>
> It is possible to embed python in a C or C++ application, enabling
you to call
> python functions from C. I would recommend reading "Extending and
Embedding the
> Python Interpreter" at http://docs.python.org/ext/ext.html for more
> information. If you are currently using Visual C++ 6.0, either stick
with
> Python 2.3 or read this:
http://www.vrplumber.com/programming/mstoolkit/ to
> learn how to build extensions for python 2.4 with the free VC++
toolkit
> compiler. If you are already using version 7 of the Microsoft C++
compiler then
> you should have no problems with Python 2.4.
>
> I usually do not embed the interpreter, but I have written some
extension
> modules... well, I should say I have used SWIG (http://www.swig.org/)
to create
> wrappers around some C libraries. For information (read: rants) on
extending
> versus embedding see
http://twistedmatrix.com/users/glyph/rant/extendit.html
> and http://c2.com/cgi/wiki?EmbedVsExtend .
>
> You can also use win32 python extensions to make your module
available through
> COM, but I don't know anything about that.
> 
> Chris

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


Re: Request for Feedback; a module making it easier to use regular expressions.

2005-01-31 Thread Skip Montanaro

Ken> rex is a module intended to make regular expressions easier to
Ken> create and use...

Have you checked out Ping's rxb module?

http://lfw.org/python/

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


  1   2   >