Re: module confusion

2007-10-05 Thread Marc 'BlackJack' Rintsch
On Sat, 06 Oct 2007 19:16:47 +1300, Lawrence D'Oliveiro wrote:

> In message <[EMAIL PROTECTED]>, Marc 'BlackJack' Rintsch
> wrote:
> 
>> To me a `variable` is made of a name, a memory address, a data type, and
>> a value.  In languages like C the address and type are attached to the
>> name while in Python both are attached to the value.
> 
> How does C++ with RTTI fit into your picture, then?

I'm no C++ expert but I'd say the type is attached to the value too there.
Same is true for Java.

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


Re: module confusion

2007-10-05 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Marc 'BlackJack' Rintsch
wrote:

> To me a `variable` is made of a name, a memory address, a data type, and
> a value.  In languages like C the address and type are attached to the
> name while in Python both are attached to the value.

How does C++ with RTTI fit into your picture, then?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: WebBased Vector 2D Graphics

2007-10-05 Thread Bjoern Schliessmann
 [EMAIL PROTECTED] wrote:
> On Oct 5, 11:43 am, Bjoern Schliessmann > The above approaches allow you to directly print to the web page.
> 
> Would this mean I wouldn't be able to have any fancy graphics
> outputed such as the rectangles I mentioned before with different
> filled in colours?

No, it wouldn't. I suggest you followed Diez' recommendation.

Regards,


Björn

-- 
BOFH excuse #437:

crop circles in the corn shell

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


Re: Test doubles (stubs and mocks) for unit testing (was: unit testing)

2007-10-05 Thread 7stud
On Oct 5, 4:51 pm, Ben Finney <[EMAIL PROTECTED]>
wrote:
>

Thanks.

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


Re: unit testing

2007-10-05 Thread Paul Rubin
Ben Finney <[EMAIL PROTECTED]> writes:
> Or even better:
> 
> def test_raises_good_exception():
> try:
> thingy()

Well if we're grading on style, maybe you really want to name the
function 'test_thingy' instead of 'test_raises_good_exception'.
-- 
http://mail.python.org/mailman/listinfo/python-list


pypar error

2007-10-05 Thread smalltalk
I want to install pypar,but it always show following errors:
D:\pypar_1.9.3>python setup.py build -c mingw32

running build
running build_py
running build_ext
building 'pypar.mpiext' extension
D:\MinGWStudio\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -I
$MPICH_DIR\SDK.gcc
\include -ID:\Python25\include -ID:\Python25\PC -c mpiext.c -o build
\temp.win32-
2.5\Release\mpiext.o
gcc: mpiext.c: No such file or directory
gcc: no input files
error: command 'gcc' failed with exit status 1

can you give me a help ?

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


Re: Python + Shoutpy + Twisted Locks

2007-10-05 Thread Gabriel Genellina
En Fri, 05 Oct 2007 04:55:55 -0300, exhuma.twn <[EMAIL PROTECTED]> escribi�:

> [...] What I found
> is that "libshout" is blocking, which should be fine as the whole
> thing runs in it's separate thread. But the application hangs
> nevertheless while streaming. This effectively blocks out the other
> thread that checks the player status, which then fails to append new
> songs to the queue. So only one song is played when streaming.
>
> The other threads in my application run fine and don't block the rest
> of the app. So I guess, that the main problem is that blocking occurs
> "outside" the python world and "inside" the libshout world.

Only one thread at a time may be executing Python code; the Global  
Interpreter Lock (GIL) ensures the mutual exclusion. Extension modules  
(written in C) may use the macros  
Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS to release/acquire the GIL  
before/after an external blocking call.
I don't know libshout, or how you are doing the binding python-libshout,  
but if your analysis is correct it means that the code is not releasing  
the GIL at the appropiate points.

-- 
Gabriel Genellina

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

Re: unit testing

2007-10-05 Thread Ben Finney
Ben Finney <[EMAIL PROTECTED]> writes:

> Paul Rubin  writes:
> 
> > Giampaolo Rodolà <[EMAIL PROTECTED]> writes:
> > > What's the equivalent of unittest's "assertRaises"?
> > 
> > def test_raises():
> > try:
> >thingy()
> >assert 42 == 43
> 
> Clearer would be:
> 
> assert False

Or even better:

def test_raises_good_exception():
try:
thingy()
except GoodException:
pass
else:
raise AssertionError("Did not raise expected GoodException")

-- 
 \ "Dad always thought laughter was the best medicine, which I |
  `\guess is why several of us died of tuberculosis."  -- Jack |
_o__)   Handey |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list

Need a minimal, easily-modifiable HTTP proxy

2007-10-05 Thread __BMR__
I'm looking for a simple HTTP proxy that I can modify to fix the 
"brokenness" of a website that I use often. One aspect of the 
"brokenness" is that if I visit the site from two different tabs in my 
browser, what I do in one tab will interfere with what happens in the 
other. There are a few other minor issues I want to tweak to my liking. 
I thought a simple local proxy would give me maximum flexibility when it 
comes to the tweaking part.

http://www.xhaus.com/alan/python/proxies.html contains a list of 
potential candidates but it's difficult to get a feel of the ease of 
modification.

I'd like to hear your experience/recommendation if you have solved a 
similar problem before.

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


Re: unit testing

2007-10-05 Thread Ben Finney
Paul Rubin  writes:

> Giampaolo Rodolà <[EMAIL PROTECTED]> writes:
> > def test_answer():
> > assert 42 == 43
> > 
> > What's the equivalent of unittest's "assertRaises"?
> 
> def test_raises():
> try:
>thingy()
>assert 42 == 43

Clearer would be:

assert False

> except GoodException:
>pass

-- 
 \"Some people, when confronted with a problem, think 'I know, |
  `\   I'll use regular expressions'. Now they have two problems." |
_o__)   —Jamie Zawinski, in alt.religion.emacs |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: anyone know howto IRC to freenode over port 80?

2007-10-05 Thread Gabriel Genellina
En Fri, 05 Oct 2007 20:18:30 -0300, gavino <[EMAIL PROTECTED]> escribi�:

> anyone?

http://ircatwork.com/

-- 
Gabriel Genellina

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

Re: Python Magazine: Issue 1 Free!

2007-10-05 Thread Terry Reedy

"Steve Holden" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
| I've just been told by the editors at Python Magazine that the first
| issue is out. It's all-electronic so anyone can download and read it.
| Let them know what you think:
|
|   http://www.pythonmagazine.com/c/issue/2007/10

OK.  Given that my (widescreen) monitor, like most current monitors, does 
not rotate into the portrait mode that would display a whole page, double 
column pdf files are painful to read on a screen.  Up and down, up and 
down.  And the color pages cannot be sensibly printed  on a b/w printer, 
even if I wanted to go to paper (which is what pdf was meant for), which I 
do not.  Mismatching electronic documents to the screens they are most 
commonly read on is to me at least shortsighted.  So I suggest that you 
also produce a readable html version. 



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


embedding python..

2007-10-05 Thread [EMAIL PROTECTED]
 I compiled the c program that is supposed to allow you to call a
procedure from the command line promt..  (it is from the embeding
example)..  I am a little confused as to what all I am supposed to
distribute to make it work..  Do I just need the python .dll for the
version I compiled or is it working with the installed version of
python.. (I don't want to start deleting stuff to find out)..  Any
help on this question would be apreaceated..





tagger what tagline

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


Re: howto kill a windows process by name ?

2007-10-05 Thread stef mientki
Adam Pletcher wrote:
> Take a look at "killProcName.py", in the win32 extension package.
>
> - Adam
>
>   
>> -Original Message-
>> From: [EMAIL PROTECTED]
>> [mailto:[EMAIL PROTECTED] On
>> 
> Behalf
>   
>> Of stef mientki
>> Sent: Friday, October 05, 2007 4:40 PM
>> To: python-list@python.org
>> Subject: howto kill a windows process by name ?
>>
>> hello,
>>
>> is there a library to kill a windows process by name ?
>>
>> thanks,
>> Stef Mientki
>> --
>> http://mail.python.org/mailman/listinfo/python-list
>> 
thanks Adam,
that indeed it works,
but googling for killProcName.py I found messages about it being slow,
and indeed it's slow,
and that same google search turned up a faster method, see below.

thanks again,
Stef Mientki



import time
import win32api, win32pdhutil, win32con
import win32pdh, string


# ***
# ***
def GetAllProcesses():
  object = "Process"
  items, instances = win32pdh.EnumObjectItems(None,None,object, 
win32pdh.PERF_DETAIL_WIZARD)
  return instances
# ***


# ***
# ***
def GetProcessID ( name ) :
  object = "Process"
  items, instances = win32pdh.EnumObjectItems(None,None,object, 
win32pdh.PERF_DETAIL_WIZARD)

  val = None
  if name in instances :
hq = win32pdh.OpenQuery()
hcs = []
item = "ID Process"
path = win32pdh.MakeCounterPath( (None,object,name, None, 0, item) )
hcs.append(win32pdh.AddCounter(hq, path))
win32pdh.CollectQueryData(hq)
time.sleep(0.01)
win32pdh.CollectQueryData(hq)

for hc in hcs:
  type, val = win32pdh.GetFormattedCounterValue(hc, 
win32pdh.PDH_FMT_LONG)
  win32pdh.RemoveCounter(hc)
win32pdh.CloseQuery(hq)
return val
# ***


"""
THIS IS SLOW !!
def Kill_Process ( process ) :
  #get process id's for the given process name
  pids = win32pdhutil.FindPerformanceAttributesByName ( process )
  for p in pids:
handle = win32api.OpenProcess(win32con.PROCESS_TERMINATE, 0, p) #get 
process handle
win32api.TerminateProcess(handle,0) #kill by handle
win32api.CloseHandle(handle)#close api
"""

# ***
# ***
def Kill_Process_pid ( pid ) :
  handle = win32api.OpenProcess(win32con.PROCESS_TERMINATE, 0, pid) #get 
process handle
  win32api.TerminateProcess(handle,0) #kill by handle
  win32api.CloseHandle(handle)#close api
# ***


# ***
# ***
def Kill_Process ( name ) :
  pid = GetProcessID ( name)
  if pid:
Kill_Process_pid ( pid )
# ***


# ***
# ***
if __name__ == "__main__":
  a = GetAllProcesses()
  print a

  process = 'UPD'
  Kill_Process ( process )

# ***



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


Re: TwistedMatrix missing OpenSSL?

2007-10-05 Thread Heikki Toivonen
>> Lamonte Harris wrote:
>>> Where can I get it?  Anyone got any idea?

Btw, M2Crypto and TLS Lite can also provide SSL for applications using
Twisted, by wrapping Twisted'd ProtocolWrapper and doing SSL in memory.

Here's the code for M2Crypto for example:

http://viewcvs.osafoundation.org/m2crypto/trunk/M2Crypto/SSL/TwistedProtocolWrapper.py?view=markup

And you can find the said projects here:

http://chandlerproject.org/Projects/MeTooCrypto
http://trevp.net/tlslite/

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


anyone know howto IRC to freenode over port 80?

2007-10-05 Thread gavino
anyone?

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


Re: TwistedMatrix missing OpenSSL?

2007-10-05 Thread Heikki Toivonen
Mike C. Fletcher wrote:
> Lamonte Harris wrote:
>> Where can I get it?  Anyone got any idea?
> http://www.voidspace.org.uk/python/modules.shtml#pycrypto

Last I checked Twisted actually required pyOpenSSL (maybe
pyOpenSSL-extended would also work but I haven't checked).

http://pyopenssl.sourceforge.net/
http://www.keyphrene.com/products/pyOpenSSL-extended/index.php?lng=en

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


Test doubles (stubs and mocks) for unit testing (was: unit testing)

2007-10-05 Thread Ben Finney
7stud <[EMAIL PROTECTED]> writes:

> What are some strategies for unit testing a function that obtains
> user input?

This is just one example of "how do I unit test a code unit that
interacts with something complex outside itself?" You want to test
*only* the code unit under test, not the external object with which it
interacts.

The answer is: Replace the external object irrelevant to your test
with a "test double" — a stub or mock object — that exhibits the
expected behaviour to the code unit, but doesn't perform the complex
behaviour that's irrelevant to your unit test.

If it's a matter of something simple and deterministic like "the input
for this test should be 'foo'", then the test double needs to do
nothing but respond to the expected method calls by producing the test
data. This is a "stub object", and you replace the real one with this
during the setup for your test case.

In more complex cases (e.g. "the code unit should write specific data
to this file", or "the code unit should make this change to the
database"), the test double needs to respond to method calls and
produce test data as needed, but also needs to be able to assert that
the right method calls were made. An instrumented test double like
this is called a "mock object", and you can query its state during the
test to assert that it has been manipulated as expected.

More about the difference between mock objects and stub objects:

http://martinfowler.com/articles/mocksArentStubs.html>

My favourite mock objects are created with Ian Bicking's "minimock",
which uses the doctest functionality for the instrumentation, and
keeps it really simple:

http://blog.ianbicking.org/minimock.html>

Set up any required test doubles at the start of each test case (so
you start with a known state each time), and switch back the real one
at the end of the test case. The test double thus becomes part of the
"test fixtures" for that specific test case.

More about test doubles (stub and mock objects) with Python:

http://pycheesecake.org/wiki/PythonTestingToolsTaxonomy>
http://www.mockobjects.com/>

Note that this works best when the external interface is a replaceable
object, or a small number of them. If the number of things that need
to be replaced with test doubles just to perform a single test case is
high, that's a warning sign: your code unit is too tightly coupled to
too many things, and you need to refactor it soon to have a looser
interface to the rest of the system.

http://www.c2.com/cgi/wiki?CouplingAndCohesion>

-- 
 \"I'd take the awe of understanding over the awe of ignorance |
  `\   any day."  -- Douglas Adams |
_o__)  |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: unit testing

2007-10-05 Thread Eduardo O. Padoan
> What's the equivalent of unittest's "assertRaises"?
> In certain situations it is also useful to test wether an exception
> (along its type) is raised or not.
> Does py.test support such thing?

import py.test

py.test.raises(NameError, "blablabla")

-- 
http://www.advogato.org/person/eopadoan/
Bookmarks: http://del.icio.us/edcrypt
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: howto kill a windows process by name ?

2007-10-05 Thread Adam Pletcher
Take a look at "killProcName.py", in the win32 extension package.

- Adam

> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On
Behalf
> Of stef mientki
> Sent: Friday, October 05, 2007 4:40 PM
> To: python-list@python.org
> Subject: howto kill a windows process by name ?
> 
> hello,
> 
> is there a library to kill a windows process by name ?
> 
> thanks,
> Stef Mientki
> --
> http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: unit testing

2007-10-05 Thread Paul Rubin
Giampaolo Rodolà <[EMAIL PROTECTED]> writes:
> def test_answer():
> assert 42 == 43
> 
> What's the equivalent of unittest's "assertRaises"?

def test_raises():
try:
   thingy()
   assert 42 == 43
except GoodException:
   pass
-- 
http://mail.python.org/mailman/listinfo/python-list


csv module and Unicode

2007-10-05 Thread Robert Dailey
Hi,

According to the Python 2.5 documentation, Unicode is not supported through
the CSV module. Is there some third-party CSV module I can use that has
Unicode support? Thanks.
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Python Magazine: Issue 1 Free!

2007-10-05 Thread Tool69
Thanks for it, what tools did you use to build the mag : Scribus ?

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


Re: Program with wx in Linux and Windows

2007-10-05 Thread brad
Grant Edwards wrote:

> I've been using wxPython for cross platofrm stuff on Linux and
> Windows for 5+ years now for at least a dozen programs. I never
> had any problems like the one you describe (though "appears
> disordered" isn't much of a problem description).  I write/test
> on Linux, and the programs pretty much "just work" on Windows.

That sums up my experience with wxPython as well. I've never had any 
problems. I develop on Linux and run on Linux, Mac and Windows.

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


Re: unit testing

2007-10-05 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit :
(snip)
> 
> Thanks to all for the opinions. Just to clarify, I have nothing
> against testing. I like doing it. I catch a lot of bugs! I dislike the
> formality of the unittest module. It's unyielding. It makes testing
> difficult unless your code is written with testing in mind from the
> start.

Indeed. But that's not specific to the unittest module - you'd have the 
same problem with any unit test framework.
-- 
http://mail.python.org/mailman/listinfo/python-list


howto kill a windows process by name ?

2007-10-05 Thread stef mientki
hello,

is there a library to kill a windows process by name ?

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


Re: Python Magazine: Issue 1 Free!

2007-10-05 Thread Bruno Desthuilliers
Wayne Brehaut a écrit :
> On Thu, 04 Oct 2007 04:52:13 +0200, Bruno Desthuilliers
> <[EMAIL PROTECTED]> wrote:
> 
> 
>>Wayne Brehaut a écrit :
>>
>>>On Thu, 04 Oct 2007 04:12:04 +0200, Bruno Desthuilliers
>>><[EMAIL PROTECTED]> wrote:
>>>
>>>
>>>
J. Clifford Dyer a écrit :
>>
>>(snip)
>>
>Well, it's also unpythonic to start numbering a sequence at 1, but
>it's clearly the right thing to do in this case.

As far as I'm concerned, if I had to number a magazine about 
programming, I'd obviously start with 0.
>>>
>>>And since the "first" issue is free that would be best here too.
>>>
>>>
Then it would be n°1, n°10, 
n°11, n°100 etc !-)
>>>
>>>But probably with enough leading zeros to last the expected lifetime
>>>(8 bits should about do it?)  so they'd sort properly:
>>>
>>> 
>>> 0001
>>>etc.
>>
>>Mmm... sort of reminds me of y2k.
> 
> 
> Funny, I was thinking IPv4.

Lol. At the exact moment I hit the 'send' button, I thought of some 
(in)famous quote about 640k for everyone !-)

And to answer your first point, 0, 1, 10, 11, 100 etc *does* sort 
properly...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Boolean parser..

2007-10-05 Thread Bruno Desthuilliers
Paul McGuire a écrit :
(snip)


May I suggest a couple cleanifications for our newbie friends around ?

> from searchparser import SearchQueryParser
> 
> products = [ "grape juice", "grape jelly", "orange juice", "orange
> jujubees",
> "strawberry jam", "prune juice", "prune butter", "orange
> marmalade",
> "grapefruit juice" ]

# round 1 : extracting constants from iterations

> class FruitSearchParser(SearchQueryParser):
> def GetWord(self, word):
> return set( p for p in products if p.startswith(word + " ") )

  def GetWord(self, word):
  target = word + " "
  return set(p for p in products if p.startswith(target) )


> def GetWordWildcard(self, word):
> return set( p for p in products if p.startswith(word[:-1]) )

   def GetWordWildcard(self, word):
   target = word[:-1]
   return set( p for p in products if p.startswith(target) )


# round 2 : factoring out common code

class FruitSearchParser(SearchQueryParser):
 def _find_products_starting_with(self, target):
 return set(p for p in products if p.startswith(target))

  def GetWord(self, word):
  return self._find_products_starting_with(word + " ")

   def GetWordWildcard(self, word):
  return self._find_products_starting_with(word[:-1])

# round 3: doing proper encapsulation:

class FruitSearchParser(SearchQueryParser):
 def __init__(self, products):
 self._products = products

 def _find_products_starting_with(self, target):
 return set(p for p in self._products if p.startswith(target))

  def GetWord(self, word):
  return self._find_products_starting_with(word + " ")

   def GetWordWildcard(self, word):
  return self._find_products_starting_with(word[:-1])


# round 4 : respecting pep08 (naming conventions):
# heck ! I guess that this would need a rewrite of SearchQueryParser


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


Re: Python Magazine: Issue 1 Free!

2007-10-05 Thread Wayne Brehaut
On Thu, 04 Oct 2007 04:52:13 +0200, Bruno Desthuilliers
<[EMAIL PROTECTED]> wrote:

>Wayne Brehaut a écrit :
>> On Thu, 04 Oct 2007 04:12:04 +0200, Bruno Desthuilliers
>> <[EMAIL PROTECTED]> wrote:
>> 
>> 
>>>J. Clifford Dyer a écrit :
>(snip)
Well, it's also unpythonic to start numbering a sequence at 1, but
it's clearly the right thing to do in this case.
>>>
>>>As far as I'm concerned, if I had to number a magazine about 
>>>programming, I'd obviously start with 0.
>> 
>> And since the "first" issue is free that would be best here too.
>> 
>>>Then it would be n°1, n°10, 
>>>n°11, n°100 etc !-)
>> 
>> But probably with enough leading zeros to last the expected lifetime
>> (8 bits should about do it?)  so they'd sort properly:
>> 
>>  
>>  0001
>> etc.
>
>Mmm... sort of reminds me of y2k.

Funny, I was thinking IPv4.

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


Re: Python Magazine: Issue 1 Free!

2007-10-05 Thread Bruno Desthuilliers
Wayne Brehaut a écrit :
> On Thu, 04 Oct 2007 04:12:04 +0200, Bruno Desthuilliers
> <[EMAIL PROTECTED]> wrote:
> 
> 
>>J. Clifford Dyer a écrit :
(snip)
>>>Well, it's also unpythonic to start numbering a sequence at 1, but
>>>it's clearly the right thing to do in this case.
>>
>>As far as I'm concerned, if I had to number a magazine about 
>>programming, I'd obviously start with 0.
> 
> And since the "first" issue is free that would be best here too.
> 
>>Then it would be n°1, n°10, 
>>n°11, n°100 etc !-)
> 
> But probably with enough leading zeros to last the expected lifetime
> (8 bits should about do it?)  so they'd sort properly:
> 
>  
>  0001
> etc.

Mmm... sort of reminds me of y2k.

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


Re: Python Magazine: Issue 1 Free!

2007-10-05 Thread Wayne Brehaut
On Thu, 04 Oct 2007 04:12:04 +0200, Bruno Desthuilliers
<[EMAIL PROTECTED]> wrote:

>J. Clifford Dyer a écrit :
>> On Fri, Oct 05, 2007 at 04:11:07PM -, Grant Edwards wrote
>> regarding Re: Python Magazine: Issue 1 Free!:
>> 
>>> On 2007-10-05, Steve Holden <[EMAIL PROTECTED]> wrote:
>>> 
>> I've just been told by the editors at Python Magazine that
>> the first issue is out.
> 
> The first issue is issue number 10?
> 
> That's a bit silly.
 
 It's the October edition. They obviously decided to make sure the
 month numbering was consistent across the volumes.
>>> 
>>> I presumed that was the reasoning. It just seems counter-intuitive
>>> (and sort of un-Pythonic) to start numbering a sequence of objects
>>> at 10. ;)
>>> 
>> 
>> 
>> Well, it's also unpythonic to start numbering a sequence at 1, but
>> it's clearly the right thing to do in this case.
>
>As far as I'm concerned, if I had to number a magazine about 
>programming, I'd obviously start with 0.

And since the "first" issue is free that would be best here too.

>Then it would be n°1, n°10, 
>n°11, n°100 etc !-)

But probably with enough leading zeros to last the expected lifetime
(8 bits should about do it?)  so they'd sort properly:

 
 0001
etc.

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


Re: Python "implements " equivalent?

2007-10-05 Thread Bruno Desthuilliers
Lawrence D'Oliveiro a écrit :
> In message <[EMAIL PROTECTED]>, Wojciech
> Gryc wrote:
> 
> 
>>I'm a seasoned Java programmer and quite a big fan of interfaces...
>>i.e. The idea that if I make a number of distinct classes that
>>implement interface X, I can pass them all as parameters to functions
>>or whatnot that require an X object.
> 
> 
> Why?
> 
> Interfaces are just a euphemism for multiple inheritance,

Java's 'interface' mechanism is mostly a (somewhat weak & dumb IMHO) 
mean to decouple (sub)typing from implementation. Given a declarative 
static type system and the restriction to single implementation 
inheritance, of course. IIRC, vb6 had *no* implementation inheritance at 
all - you had to do 'implement' it by yourself, using (manual of course) 
delegation...

Now multiple inheritence is clearly not the answer to the OP's question 
in a dynamically typed language, where subtyping is not bound to 
inheritance.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Magazine: Issue 1 Free!

2007-10-05 Thread John Masters
On 04:12 Thu 04 Oct , Bruno Desthuilliers wrote:
> J. Clifford Dyer a écrit :
> > On Fri, Oct 05, 2007 at 04:11:07PM -, Grant Edwards wrote
> > regarding Re: Python Magazine: Issue 1 Free!:
> > 
> >> On 2007-10-05, Steve Holden <[EMAIL PROTECTED]> wrote:
> >> 
> > I've just been told by the editors at Python Magazine that
> > the first issue is out.
>  
>  The first issue is issue number 10?
>  
>  That's a bit silly.
> >>> 

The first issue is actually 2007-10 which makes a lot of sense

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


Re: migrating to packages

2007-10-05 Thread Bruno Desthuilliers
Gerardo Herzig a écrit :
> Bruno Desthuilliers wrote:
> 
>> Gerardo Herzig a écrit :
>>  
>>
>>> Carl Bank a écrit :
>>>   
>>>
 Add these lines in __init__.py:

 from MYCLASSES.A import A
 from MYCLASSES.B import B


 
>>>
>>> Ummm, that works indeed, but forces me to import all (more than A and 
>>> B) classes, rigth?
>>>   
>>
>>
>> Why so ?
>>
>>  
>>
> If the original MYCLASSES.py has 5 different classes ,say A,B,C,D,E , 
> each one has to be imported 

where ? In the __init__.py or in the client code ?

> (as A and B) in order to be used for the 
> client code.

 From the client code POV, it doesn't change anything.

> The thing is, there are more than 5 classes,

Here again : where ?

You know, it's pretty common in Python to have more than one single 
symbol publicly available from a given module, and you don't *have* to 
do the java one-class-per-file dance. The main reason for splitting an 
existing module into multiple submodules of a package is to keep 
module's size manageable. If each of your classes is so big it need a 
whole module, then you possibly have another problem...

> and looks like 
> a lot of unnecesary work to me, since a particular program can use 1,2, 
> or 3 classes at the time

Then either it import the package and use fqn, or it only imports the 
needed classes.

> Thats why im watching the way to override 
> the `import statement'...

IMHO, chances are you're going for the wrong solution.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: unit testing

2007-10-05 Thread Giampaolo Rodolà
On 3 Ott, 14:37, Bruno Desthuilliers
<[EMAIL PROTECTED]> wrote:
> Paul Rubin a écrit :
>
> > brad <[EMAIL PROTECTED]> writes:
>
> >>Does anyone else feel that unittesting is too much work? Not in
> >>general, just the official unittest module for small to medium sized
> >>projects?
>
> > Yeah, unittest is sort of a Java-ism.  You might try the newer doctest
> > module instead.
>
> Or py.test or nose, which are both more complete than doctest and more
> pythonics than the unittest module.

Very interesting, thank you.
This is the first time I heard about py.test so I took a look at what
it is:
http://codespeak.net/py/dist/test.html
http://ianbicking.org/docs/pytest-presentation/pytest-slides.html

At a first look it seems very comfortable to me but I noticed that all
usage examples shown uses nothing but the assert statement:

def test_answer():
assert 42 == 43

What's the equivalent of unittest's "assertRaises"?
In certain situations it is also useful to test wether an exception
(along its type) is raised or not.
Does py.test support such thing?

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

Re: Python Magazine: Issue 1 Free!

2007-10-05 Thread Bruno Desthuilliers
J. Clifford Dyer a écrit :
> On Fri, Oct 05, 2007 at 04:11:07PM -, Grant Edwards wrote
> regarding Re: Python Magazine: Issue 1 Free!:
> 
>> On 2007-10-05, Steve Holden <[EMAIL PROTECTED]> wrote:
>> 
> I've just been told by the editors at Python Magazine that
> the first issue is out.
 
 The first issue is issue number 10?
 
 That's a bit silly.
>>> 
>>> It's the October edition. They obviously decided to make sure the
>>> month numbering was consistent across the volumes.
>> 
>> I presumed that was the reasoning. It just seems counter-intuitive
>> (and sort of un-Pythonic) to start numbering a sequence of objects
>> at 10. ;)
>> 
> 
> 
> Well, it's also unpythonic to start numbering a sequence at 1, but
> it's clearly the right thing to do in this case.

As far as I'm concerned, if I had to number a magazine about 
programming, I'd obviously start with 0. Then it would be n°1, n°10, 
n°11, n°100 etc !-)

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


Re: PYTHONPATH, opensuse10.2, gtk not working

2007-10-05 Thread Silfheed
On Oct 5, 1:04 pm, Silfheed <[EMAIL PROTECTED]> wrote:
> On Oct 4, 8:31 pm, Silfheed <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Oct 4, 7:39 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
>
> > > Silfheed wrote:
> > > > Heyas
>
> > > > So I'm trying to do two things, install a little gnome taskbar applet
> > > > (timer-applet) that was written in python and experiment with writing
> > > > python gtk apps.  I've installed (through yast) gtk, gtk2, gtk2-devel,
> > > > python-gtk, python-gtk-devl, python-gtk-doc but I still cant get
> > > > python to import gtk.  I set PYTHONPATH = /usr/lib/python2.5/site-
> > > > packages/ and that got importing pygtk to work, but the little app I
> > > > downloaded wants to import gtk and I just cant figure out what I'm
> > > > supposed to set PYTHONPATH to in order to get `import gtk` to work.
> > > > Anyone know what I'm doing wrong or missing?
>
> > > > Thanks
>
> > > set PYTHONPATH to /usr/lib/python2.5/lib/site-packages:gtk-root-dir
>
> > > By the way, do you really think that it's necessary to put site-packages
> > > on the path? You might find it's already on there as Python starts up.
>
> > > You can tell by printing sys.path from Python.
>
> > Yes, it actually requires adding the site-packages to the PYTHONPATH
> > to get pygtk to work.  So far I've managed to get gtk to give a
> > different error when I added the site-packages/gtk-2.0/ directory (the
> > only gtk-like thing in the site-packages) to the PYTHONPATH
> > `ImportError: gobject/_gobject.so: undefined symbol:
> > PyUnicodeUCS4_FromObject`.   I'll have to check the path when I get
> > home to see what it actually has within it and work from there.
>
> > Thanks.
>
> So after checking sys.path and snooping around a bit more, it turns
> out that I have two python site-package directories... one in /usr/lib
> and one in /usr/local/lib.. One is automatically stuck into sys.path
> (but allowed root access only) while the other is not.
>
> I dunno why this is, but is there a way to get python to see both of
> these automatically (without PYTHONPATH?)  Not that this solves my
> problem since after changing the permissions to world readable on the
> sys.path listed /usr/lib/python2.5/site-packages, it still wont let me
> import gtk.  This is all after installing everything with yast (which
> says that I have gtk)..

Well.. I suppose a logical explanation would be two different installs
of python.. sorry for the noise.

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


Re: unit testing

2007-10-05 Thread Paul Rubin
7stud <[EMAIL PROTECTED]> writes:
> What are some strategies for unit testing a function that obtains user
> input?

For example: http://en.wikipedia.org/wiki/Expect
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Starting a thread before wxPython bootup ... interesting.

2007-10-05 Thread Diez B. Roggisch
> 
> The real goal is to start the gui in a different thread, and have the
> main thread regain control. That seems like a feasible thing to be
> able to do, though I have been unsuccessful ... if anyone would like
> to suggest something without being covertly insulting, I'm all ears.

AFAIK some toolkits take it personally if they don't run in THE thread, 
meaning the main-thread. No idea if that applies to your situation, but 
as you continue to being vague, so are the answers.

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


Re: PYTHONPATH, opensuse10.2, gtk not working

2007-10-05 Thread Silfheed
On Oct 4, 8:31 pm, Silfheed <[EMAIL PROTECTED]> wrote:
> On Oct 4, 7:39 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
>
>
>
> > Silfheed wrote:
> > > Heyas
>
> > > So I'm trying to do two things, install a little gnome taskbar applet
> > > (timer-applet) that was written in python and experiment with writing
> > > python gtk apps.  I've installed (through yast) gtk, gtk2, gtk2-devel,
> > > python-gtk, python-gtk-devl, python-gtk-doc but I still cant get
> > > python to import gtk.  I set PYTHONPATH = /usr/lib/python2.5/site-
> > > packages/ and that got importing pygtk to work, but the little app I
> > > downloaded wants to import gtk and I just cant figure out what I'm
> > > supposed to set PYTHONPATH to in order to get `import gtk` to work.
> > > Anyone know what I'm doing wrong or missing?
>
> > > Thanks
>
> > set PYTHONPATH to /usr/lib/python2.5/lib/site-packages:gtk-root-dir
>
> > By the way, do you really think that it's necessary to put site-packages
> > on the path? You might find it's already on there as Python starts up.
>
> > You can tell by printing sys.path from Python.
>
> Yes, it actually requires adding the site-packages to the PYTHONPATH
> to get pygtk to work.  So far I've managed to get gtk to give a
> different error when I added the site-packages/gtk-2.0/ directory (the
> only gtk-like thing in the site-packages) to the PYTHONPATH
> `ImportError: gobject/_gobject.so: undefined symbol:
> PyUnicodeUCS4_FromObject`.   I'll have to check the path when I get
> home to see what it actually has within it and work from there.
>
> Thanks.

So after checking sys.path and snooping around a bit more, it turns
out that I have two python site-package directories... one in /usr/lib
and one in /usr/local/lib.. One is automatically stuck into sys.path
(but allowed root access only) while the other is not.

I dunno why this is, but is there a way to get python to see both of
these automatically (without PYTHONPATH?)  Not that this solves my
problem since after changing the permissions to world readable on the
sys.path listed /usr/lib/python2.5/site-packages, it still wont let me
import gtk.  This is all after installing everything with yast (which
says that I have gtk)..

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


Re: Howto Launch a windows application ?

2007-10-05 Thread stef mientki
Nicholas Bastin wrote:
> On 10/3/07, stef mientki <[EMAIL PROTECTED]> wrote:
>   
>> hello,
>>
>> I'm trying to launch a windows application,
>> but as many others on this list, I've some trouble.
>> I read some other threads about this topic,
>> but sorry, I still don't understand all this (never heard of pipes).
>>
>> When I use a batch file, I can launch the bat-file from python,
>> and the windows application launched from the batchfile is run perfectly.
>>
>> Now when I try to run the same windows application from Popen or call,
>> nothing happens (or at least it's very fast and produces not the
>> expected output).
>>
>> Please enlighten me, preferable in "windows-terminology"  ;-)
>>
>> thanks,
>> Stef Mientki
>>
>> from subprocess import *
>>
>> cmd =[]
>> cmd.append ( 'D:\\PIC-tools\\JALxxx\\jalv2_3.exe' )
>> cmd.append ( '-long-start' )
>> cmd.append ( '-d')
>> cmd.append ( '-clear' )
>> cmd.append ( '-sD:\\PIC-tools\\JAL\\libs2' )
>> cmd.append ( 'd:\\pic-tools\\jal\\programs\\test_rs232\\test_rs232_hw.jal' )
>> cmd.append ( '>d:\\data_actueel\\d7_test_browser\\temp.log' )
>>
>> # DOESN'T WORK
>> result = call ( cmd )
>>
>> # Both Popen and call work
>> cmd = [ 'd:\\data_actueel\\d7_test_browser\\JALcc.bat' ]
>> #output = Popen ( cmd )
>> result = call ( cmd )
>> print result
>> 
>
> First, call is a convenience function, but in your case, it's probably
> not that convenient.  Use the actual Popen constructor so you can get
> at the output directly.  Also, ditch the output redirector and use a
> pipe:
>
> p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
> (out, err) = p.stdout, p.stderr
> rcode = p.wait()
> print out, err, rcode
>
> Try that and see what happens.  When it doesn't work, look carefully
> in out and err and see if anything interesting is in there.  I was
> able to open notepad.exe in this way with no problems so my guess is
> you're having some other problem, but avoiding the use of the
> convenience function will give you stdout and stderr to look at.
>
>   
Thanks Nick,

replacing
#print out, err, rcode
with
for line in out:
  print line
for line in err:
  print line
points me to the problem issue, which is the "-s" option,
although I don't understand it yet

> --
> Nick
>
>   

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


Re: A question about subprocess

2007-10-05 Thread JD
Thanks very much for all the answers.

JD

On Oct 3, 6:24 pm, Dan Stromberg <[EMAIL PROTECTED]> wrote:
> You don't necessarily need thesubprocessmodule to do this, though you
> could use it.
>
> I've done this sort of thing in the past with fork and exec.
>
> To serialize the jobs on the machines, the easiest thing is to just send
> the commands all at once to a given machine, like "command1; command2;
> command3".
>
> You can use waitpid or similar to check if a series of jobs has finished
> on a particular machine.
>
> An example of something similar can be found 
> athttp://stromberg.dnsalias.org/~strombrg/loop.html
>
> (If you look at the code, be kind.  I wrote it long ago :)
>
> There's a benefit to saving the output from each machine into a single
> file for that machine.  If you think some machines will produce the same
> output, and you don't want to see it over and over, you can analyze the
> files with something 
> likehttp://stromberg.dnsalias.org/~strombrg/equivalence-classes.html.
>
>  On Wed, 03 Oct 2007 16:46:20 +, JD wrote:
>
> > Hi,
>
> > I want send my jobs over a whole bunch of machines (using ssh). The
> > jobs will need to be run in the following pattern:
>
> > (Machine A)   (Machine B)  (Machine C)
>
> > Job A1 Job B1Job C1
>
> >  Job A2   Job B2etc
>
> >  Job A3  etc
>
> >  etc
>
> > Jobs runing on machine A, B, C should be in parallel, however, for
> > each machine, jobs should run one after another.
>
> > How can I do it with thesubprocess?
>
> > Thanks,
>
> > JD


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


Re: TwistedMatrix missing OpenSSL?

2007-10-05 Thread Mike C. Fletcher
Lamonte Harris wrote:
> Where can I get it?  Anyone got any idea?
http://www.voidspace.org.uk/python/modules.shtml#pycrypto

Might help.
Mike
>
> Where do I get it?  I'm currently running python 2.5
>
> On 10/4/07, *Lamonte Harris* <[EMAIL PROTECTED] 
> > wrote:
-- 

  Mike C. Fletcher
  Designer, VR Plumber, Coder
  http://www.vrplumber.com
  http://blog.vrplumber.com

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


Re: Starting a thread before wxPython bootup ... interesting.

2007-10-05 Thread Chris Mellon
On 10/5/07, Shafik <[EMAIL PROTECTED]> wrote:
> My apologies for not supplying more info, I am at work and I am
> technically not allowed to surf the web for anything.
>
> I am using Python 2.5.1,  the latest wx version (2.8.xx, I dont recall
> exactly). This is running under windows XP under the latest version of
> cygwin (that could be the source of the issues too).
>
> I was just looking for a general way to approach wx and
> multithreading, not a detailed solution to my problem. There are lots
> of tutorials online that describe how to perform a time-consuming task
> in a separate thread in a wx-gui, but nothing that describes any other
> use cases.
>

The general way to approach wx and multithreading is to just do it. In
the general case, the only caveat you need to be aware of is that wx
is not threadsafe and all GUI calls need to called from the main
thread.

> The real goal is to start the gui in a different thread, and have the
> main thread regain control. That seems like a feasible thing to be
> able to do, though I have been unsuccessful ... if anyone would like
> to suggest something without being covertly insulting, I'm all ears.
>

If you're not going to say what you did and how it didn't work, I
don't know how you expect anyone to help you.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: novice list

2007-10-05 Thread Peter Otten
István wrote:

> Could somebody suggest me a novice Python list, please?

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

Re: novice list

2007-10-05 Thread [EMAIL PROTECTED]
On Oct 5, 10:42 am, [EMAIL PROTECTED] wrote:
> On Oct 5, 10:22 am, Paul Rudin <[EMAIL PROTECTED]> wrote:
>
> > István <[EMAIL PROTECTED]> writes:
> > > Could somebody suggest me a novice Python list, please?
>
> > Here you go:
>
> > ['novice']
>
> > (Sorry, couldn't resist.)
>
> No no... I think he meant a "simple" list. Like, you know, a list
> novices can handle.
>
> I suggest the empty list []!

Actually, that's a very hard concept. Think about the behavior
of NULL in a database.

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

Re: Starting a thread before wxPython bootup ... interesting.

2007-10-05 Thread Shafik
My apologies for not supplying more info, I am at work and I am
technically not allowed to surf the web for anything.

I am using Python 2.5.1,  the latest wx version (2.8.xx, I dont recall
exactly). This is running under windows XP under the latest version of
cygwin (that could be the source of the issues too).

I was just looking for a general way to approach wx and
multithreading, not a detailed solution to my problem. There are lots
of tutorials online that describe how to perform a time-consuming task
in a separate thread in a wx-gui, but nothing that describes any other
use cases.

The real goal is to start the gui in a different thread, and have the
main thread regain control. That seems like a feasible thing to be
able to do, though I have been unsuccessful ... if anyone would like
to suggest something without being covertly insulting, I'm all ears.


Thanks,
--Shafik

On Oct 4, 5:58 pm, "[david]" <[EMAIL PROTECTED]> wrote:
> Since the observed behaviour is clearly undefined,
> I forgive you for the poorly specified behaviour
> description: asking for a close description of random
> behaviour is just ridiculous.
>
> The most obvious point is that wx is not re-entrant
> or thread safe: you have to make it so by using
> wx.CallAfter()
>
> Since you are talking about a bug in your screen
> display while using a screen library, it would
> also be interesting it you described the environment:
> Which operating system? Which windowing system?
> Which wx library? Which Python? Which IDE? What code?
>
> [david]
>
> Shafik wrote:
> > Hello folks,
>
> > I'm having an issue with mixing wxPython and threading ... I realize
> > multi-threading always introduces subtle bugs, but the following
> > scenario is just odd:
>
> > I start a dummy thread, that does nothing but increment a counter and
> > print its value to the screen, then afterwards, I start the wxPython
> > application. I get nothing but weird behavior: sometimes the gui just
> > crashes, sometimes I get an exception, sometimes it runs for a little
> > but very slowly ...
>
> > Anyone know whats going on? I have a dual-core T5500, so multi
> > threading is piece of cake for it hardware -wise.
>
> > Cheers,
> > --Shafik


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


Re: TwistedMatrix missing OpenSSL?

2007-10-05 Thread Lamonte Harris
Where can I get it?  Anyone got any idea?

On 10/4/07, Lamonte Harris <[EMAIL PROTECTED]> wrote:
>
> Where do I get it?  I'm currently running python 2.5
>
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: unit testing

2007-10-05 Thread 7stud
What are some strategies for unit testing a function that obtains user
input?

Thanks.

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


Re: picture filter

2007-10-05 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb:
> hii my friends
> ı want to a filter for porn picture
> if you know , please help me :S:S
> how  do ı separate porn form not porn
> I don't want my web site porn;)
> (my english bad I hope understant it. very very thans )

If anybody know how to do that, he or she would immediatly become 
incredibly rich, selling this magic filter to concerned parents as well 
as eager porn enthusiasts, to help them filter away the noise or dirt, 
from their respective viewpoints that is of course...

So - you're out of luck buddy. Nobody will be able to help you.


Diez

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


Re: "SyntaxError: Non-ASCII character '\xc2'...", was Re: Is there a nicer way to do this?

2007-10-05 Thread Victor B. Gonzalez
On Friday 05 October 2007 3:33:43 am Peter Otten wrote:
> Victor B. Gonzalez wrote:
> > anyhow, I keep getting "SyntaxError: Non-ASCII character '\xc2'..." on
> > line 5. anyone know what this is?
>
> I too had that problem with KNode. Leading space consists of NO-BREAK SPACE
> (unichr(160)) which translates to '\xc2\xa0' in UTF-8. As I don't see this
> problem here (using pan) I suspect it may be specific to KMail/KNode.
>
> Peter

You're right, thank you for pointing that out. I am bad with almost anything 
like \this but stripping off the leading whitespace solved the issue. thank 
you for the heads up!

-- 
Best Regards
Victor B. Gonzalez
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: supplying password to subprocess.call('rsync ...'), os.system('rsync ...')

2007-10-05 Thread Stargaming
On Fri, 05 Oct 2007 08:37:05 -0700, timw.google wrote:

> On Oct 5, 10:33 am, "timw.google" <[EMAIL PROTECTED]> wrote:
>> Hi
>>
>> I want to write a python script that runs rsync on a given directory
>> and host. I build the command line string, but when I try to run
>> subprocess.call(cmd), or p=subprocess.Popen(cmd, shell=True),or
>> os.system(cmd), I get prompted for my login password. I expected this,
>> but when I try to give my password, it's echoed back to the terminal
>> and the special characters in the password is (I think) getting
>> interpreted by the shell (zsh)
>>
>> I can't ssh w/o supplying a password. That's the way the security is
>> set up here.
>>
>> How do I use python to do this, or do I just have to write a zsh
>> script?
>>
>> Thanks.
> 
> I wrote a zsh script to do what I wanted, but I'd still like to know how
> to do it in Python.

`subprocess.Popen` has a keyword argument called `stdin` -- what takes 
the password, I guess. Assigning `subprocess.PIPE` to it and using 
`Popen.communicate` should do the trick. 

Check the documentation at http://docs.python.org/lib/module-
subprocess.html for details.

Cheers,
Stargaming
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Magazine: Issue 1 Free!

2007-10-05 Thread J. Clifford Dyer
On Fri, Oct 05, 2007 at 04:11:07PM -, Grant Edwards wrote regarding Re: 
Python Magazine: Issue 1 Free!:
> 
> On 2007-10-05, Steve Holden <[EMAIL PROTECTED]> wrote:
> >>
> >>> I've just been told by the editors at Python Magazine that the
> >>> first issue is out.
> >> 
> >> The first issue is issue number 10?
> >> 
> >> That's a bit silly.
> >
> > It's the October edition. They obviously decided to make sure
> > the month numbering was consistent across the volumes.
> 
> I presumed that was the reasoning. It just seems
> counter-intuitive (and sort of un-Pythonic) to start numbering
> a sequence of objects at 10. ;)
> 

Well, it's also unpythonic to start numbering a sequence at 1, but it's clearly 
the right thing to do in this case.

Cheers,
Cliff
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Magazine: Issue 1 Free!

2007-10-05 Thread Grant Edwards
On 2007-10-05, Steve Holden <[EMAIL PROTECTED]> wrote:
>>
>>> I've just been told by the editors at Python Magazine that the
>>> first issue is out.
>> 
>> The first issue is issue number 10?
>> 
>> That's a bit silly.
>
> It's the October edition. They obviously decided to make sure
> the month numbering was consistent across the volumes.

I presumed that was the reasoning. It just seems
counter-intuitive (and sort of un-Pythonic) to start numbering
a sequence of objects at 10. ;)

-- 
Grant Edwards   grante Yow! Hmmm ... a CRIPPLED
  at   ACCOUNTANT with a FALAFEL
   visi.comsandwich is HIT by a
   TROLLEY-CAR ...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: unit testing

2007-10-05 Thread Kay Schluehr
On Oct 5, 4:12 pm, [EMAIL PROTECTED] wrote:
> On Oct 5, 5:38 am, Craig Howard <[EMAIL PROTECTED]> wrote:
>
> > Brad:
>
> > If the program is more than 100 lines or is a critical system, I
> > write a unit test. I hate asking myself, "Did I break something?"
> > every time I decide to refactor a small section of code. For
> > instance, I wrote an alarm system in Python for a water treatment
> > plant. If the chlorine, pH, or turbidity are out of spec, an email
> > message is sent to the plant operator's pager. Because of the nature
> > of the alarm system, extensive field testing was out of the question.
> > Unit testing was the only way to ensure it worked without disrupting
> > the plant operation.
>
> > Craig
>
> Thanks to all for the opinions. Just to clarify, I have nothing
> against testing. I like doing it. I catch a lot of bugs! I dislike the
> formality of the unittest module. It's unyielding. It makes testing
> difficult unless your code is written with testing in mind from the
> start.
>
> I maintain old code... code written a long time ago, before unittest
> was popular. Getting unittest to work on that is difficult at best. So
> we do informal testing ourselfs. The end result is the same... bugs
> are squashed before the code is placed into production. Many times, we
> find bugs as soon as we write a test!
>
> Thanks again for the advice.
>
> Brad

Just one recommendation. I don't know your project and remote
diagnostics is usually more funny than usefull, but there is a body of
literature about dealing with legacy code, for example:

http://www.amazon.com/Working-Effectively-Legacy-Robert-Martin/dp/0131177052

Of course Micheal Feathers talks constantly about putting systems
under test, exposing code for testability and lots more that goes
beyond code & fix.

Here is some article of the same author:

http://www.objectmentor.com/resources/articles/WorkingEffectivelyWithLegacyCode.pdf

Kay

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


picture filter

2007-10-05 Thread [EMAIL PROTECTED]
hii my friends
ı want to a filter for porn picture
if you know , please help me :S:S
how  do ı separate porn form not porn
I don't want my web site porn;)
(my english bad I hope understant it. very very thans )

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


Re: module confusion

2007-10-05 Thread Steve Holden
Steven D'Aprano wrote:
> On Fri, 05 Oct 2007 07:37:34 -0400, Steve Holden wrote:
> 
>> Steven D'Aprano wrote:
>>> On Fri, 05 Oct 2007 00:12:33 -0500, Robert Kern wrote:
>>>
 This is somewhat odd, because most modules aren't exposed that way.
 They are either in their own file and accessed by importing them
 directly, or they are inside a package.
>>> Any time you say:
>>>
>>> import parrot
>>>
>>>
>>> in one of your modules, you export parrot to anything that
>> subsequently
> 
> Well obviously you have to write the module before people import it. I 
> didn't really think "you must obey the laws of time and space" needed to 
> be explained.
> 
But a module needn't be fully executed before it's imported.
> 
>>> imports your
>>> module. (Unless you take specific steps to prevent it, for instance
>>> with del parrot.)
>> or the creation of an __all__ containing an exclusive list of names for
>> export.
> 
> No.
> 
> __all__ only effects names imported with "from module import *", it has 
> no effect on "import module".
> 
> What was that again about avoiding "writing anything that will be 
> misconstrued by newless cloobs unfortunate enough to reach this thread as 
> a result of a search for meaningful information on Python imports"?
> 
> 
> 
Well, precisely.

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden

Sorry, the dog ate my .sigline so I couldn't cat it

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


Re: remove list elements..

2007-10-05 Thread Marc 'BlackJack' Rintsch
On Fri, 05 Oct 2007 11:45:07 -0400, Steve Holden wrote:

> [EMAIL PROTECTED] wrote:
>> On Oct 5, 10:27 am, Abandoned <[EMAIL PROTECTED]> wrote:
>>> Hi..
>>> I have a problem..
>>> list1=[11, 223, 334, 4223...] 1 million element
>>> list2=[22,223,4223,2355...] 500.000 element
>>>
>>> I want to difference list1 to list2 but order very importent..
>>>
>>> My result must be:
>>> list3=[11,334,...]
>>>
>>> I do this use FOR easly but the speed very imported for me. I want to
>>> the fastest method please help me.
>> 
>> Research the "set" data type. :)
>> 
> Probably not a very helpful suggestion given that ordering is stated to 
> be very important.

A `set()` can be part of such a solution.

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


Re: module confusion

2007-10-05 Thread Steven D'Aprano
On Fri, 05 Oct 2007 07:37:34 -0400, Steve Holden wrote:

> Steven D'Aprano wrote:
>> On Fri, 05 Oct 2007 00:12:33 -0500, Robert Kern wrote:
>> 
>>> This is somewhat odd, because most modules aren't exposed that way.
>>> They are either in their own file and accessed by importing them
>>> directly, or they are inside a package.
>> 
>> Any time you say:
>> 
>> import parrot
>> 
>> 
>> in one of your modules, you export parrot to anything that
> 
> subsequently

Well obviously you have to write the module before people import it. I 
didn't really think "you must obey the laws of time and space" needed to 
be explained.


>> imports your
>> module. (Unless you take specific steps to prevent it, for instance
>> with del parrot.)
> 
> or the creation of an __all__ containing an exclusive list of names for
> export.

No.

__all__ only effects names imported with "from module import *", it has 
no effect on "import module".

What was that again about avoiding "writing anything that will be 
misconstrued by newless cloobs unfortunate enough to reach this thread as 
a result of a search for meaningful information on Python imports"?



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


Re: unit testing

2007-10-05 Thread Roy Smith
[EMAIL PROTECTED] wrote:
> Thanks to all for the opinions. Just to clarify, I have nothing
> against testing. I like doing it. I catch a lot of bugs! I dislike the
> formality of the unittest module. It's unyielding. It makes testing
> difficult unless your code is written with testing in mind from the
> start.

There is some advantage in forcing you to write code with testing in mind.  
It often works out that the same things which make code easy to test (clean 
interfaces, little cross-class dependency, etc), also make the code easy to 
maintain and modify later.

Compared to some other testing frameworks I've used, unittest is pretty 
lightweight.  That's not to say that for small projects, even the small 
amount of baggage it brings with it may feel heavy.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: remove list elements..

2007-10-05 Thread Steve Holden
[EMAIL PROTECTED] wrote:
> On Oct 5, 10:27 am, Abandoned <[EMAIL PROTECTED]> wrote:
>> Hi..
>> I have a problem..
>> list1=[11, 223, 334, 4223...] 1 million element
>> list2=[22,223,4223,2355...] 500.000 element
>>
>> I want to difference list1 to list2 but order very importent..
>>
>> My result must be:
>> list3=[11,334,...]
>>
>> I do this use FOR easly but the speed very imported for me. I want to
>> the fastest method please help me.
>>
>> I'm sorry my bad english.
>>
>> King regards..
> 
> Research the "set" data type. :)
> 
Probably not a very helpful suggestion given that ordering is stated to 
be very important.

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden

Sorry, the dog ate my .sigline so I couldn't cat it

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


Re: novice list

2007-10-05 Thread chris . monsanto
On Oct 5, 10:22 am, Paul Rudin <[EMAIL PROTECTED]> wrote:
> István <[EMAIL PROTECTED]> writes:
> > Could somebody suggest me a novice Python list, please?
>
> Here you go:
>
> ['novice']
>
> (Sorry, couldn't resist.)

No no... I think he meant a "simple" list. Like, you know, a list
novices can handle.

I suggest the empty list []!

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

Re: supplying password to subprocess.call('rsync ...'), os.system('rsync ...')

2007-10-05 Thread timw.google
On Oct 5, 10:33 am, "timw.google" <[EMAIL PROTECTED]> wrote:
> Hi
>
> I want to write a python script that runs rsync on a given directory
> and host. I build the command line string, but when I try to run
> subprocess.call(cmd), or p=subprocess.Popen(cmd, shell=True),or
> os.system(cmd), I get prompted for my login password. I expected this,
> but when I try to give my password, it's echoed back to the terminal
> and the special characters in the password is (I think) getting
> interpreted by the shell (zsh)
>
> I can't ssh w/o supplying a password. That's the way the security is
> set up here.
>
> How do I use python to do this, or do I just have to write a zsh
> script?
>
> Thanks.

I wrote a zsh script to do what I wanted, but I'd still like to know
how to do it in Python.

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


Re: Boolean parser..

2007-10-05 Thread Paul McGuire
On Oct 5, 7:00 am, Abandoned <[EMAIL PROTECTED]> wrote:
> http://pyparsing.wikispaces.com/space/showimage/searchparser.pythis
> is searchparser but i can't understant to use this.
> Can anybody explain this how to use ?

The code demonstrates a testing example, named TestParser, which
inherits from SearchQueryParser.  As mentioned in the docstrings at
the top, to use this code, import the module and define your own class
to inherit from SearchQueryParser.  Then override the Get... methods,
as is done in TestParser.  Each Get method returns a set, and all sets
are then ANDed and ORed according to the input search string.

Here's a simple example, a database of fruit-based products.  To keep
things simple, each product will come from a single fruit, and the
name of the fruit will be at the beginning of the product's name, for
instance "grape juice" is made from the fruit named "grape".

from searchparser import SearchQueryParser

products = [ "grape juice", "grape jelly", "orange juice", "orange
jujubees",
"strawberry jam", "prune juice", "prune butter", "orange
marmalade",
"grapefruit juice" ]

class FruitSearchParser(SearchQueryParser):
def GetWord(self, word):
return set( p for p in products if p.startswith(word + " ") )

def GetWordWildcard(self, word):
return set( p for p in products if p.startswith(word[:-1]) )

def GetQuotes(self, search_string, tmp_result):
result = Set()
# I have no idea how to use this feature...
return result

def GetNot(self, not_set):
return set( products ) - not_set


parser = FruitSearchParser()

tests = """\
grape or orange
grape*
not(grape*)
prune and grape""".splitlines()

for t in tests:
print t.strip()
print parser.Parse(t)
print


Prints:

grape or orange
set(['orange juice', 'grape juice', 'orange marmalade', 'orange
jujubees', 'grape jelly'])

grape*
set(['grapefruit juice', 'grape juice', 'grape jelly'])

not(grape*)
set(['orange jujubees', 'orange juice', 'prune butter', 'orange
marmalade', 'strawberry jam', 'prune juice'])

prune and grape
set([])



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


Re: Where's the Starship's crew?

2007-10-05 Thread Aahz
In article <[EMAIL PROTECTED]>,
Dick Moores  <[EMAIL PROTECTED]> wrote:
>
>
>
>I didn't check on all of them, but the only one I found was Mark 
>Hammond .

This is the unfortunate remnant of a system hack; many people who used
to have active Starship accounts never bothered bringing them back after
Starship was cleaned up.  Starship was recently moved to another machine
and we're having discussions about the future.
-- 
Aahz ([EMAIL PROTECTED])   <*> http://www.pythoncraft.com/

The best way to get information on Usenet is not to ask a question, but
to post the wrong information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: unit testing

2007-10-05 Thread Steven Bethard
[EMAIL PROTECTED] wrote:
> On Oct 5, 5:38 am, Craig Howard <[EMAIL PROTECTED]> wrote:
>> Brad:
>>
>> If the program is more than 100 lines or is a critical system, I
>> write a unit test. I hate asking myself, "Did I break something?"
>> every time I decide to refactor a small section of code. For
>> instance, I wrote an alarm system in Python for a water treatment
>> plant. If the chlorine, pH, or turbidity are out of spec, an email
>> message is sent to the plant operator's pager. Because of the nature
>> of the alarm system, extensive field testing was out of the question.
>> Unit testing was the only way to ensure it worked without disrupting
>> the plant operation.
> 
> Thanks to all for the opinions. Just to clarify, I have nothing
> against testing. I like doing it. I catch a lot of bugs! I dislike the
> formality of the unittest module. It's unyielding. It makes testing
> difficult unless your code is written with testing in mind from the
> start.

There's been talk in the past about trying to bring some of the features 
of py.test to the unittest module.  However, I think there hasn't been 
anyone with enough free time to start tackling this problem.

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


Re: remove list elements..

2007-10-05 Thread J. Clifford Dyer
On Fri, Oct 05, 2007 at 07:27:39AM -0700, Abandoned wrote regarding remove list 
elements..:
> 
> Hi..
> I have a problem..
> list1=[11, 223, 334, 4223...] 1 million element
> list2=[22,223,4223,2355...] 500.000 element
> 
> I want to difference list1 to list2 but order very importent..
> 
> My result must be:
> list3=[11,334,...]
> 
> I do this use FOR easly but the speed very imported for me. I want to
> the fastest method please help me.
> 
> I'm sorry my bad english.
> 
> King regards..
> 
> -- 
> http://mail.python.org/mailman/listinfo/python-list

If you're using a recent python, you can create a set from list2, and preserve 
order with list1 like so:

set2 = set(list2)
list3 = [ x for x in list1 if x not in set2 ]

That will speed up your access to list2 (for 500,000 scans) at the low cost of 
reading through the whole thing once.

You say order is very important, but if your order is known to be strictly 
increasing (as it appears from your sample code), you can speed up further by 
doing:

set1 = set(list1)
set2 = set(list2)
list3 = sorted(set1 - set2)


Though to tell the truth, I'm not sure this actually would be faster, since you 
access each element of list1 just once in the list comprehension version.  And 
I can't be bothered to try it out with timeit.

Cheers,
Cliff

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


Re: remove list elements..

2007-10-05 Thread Hrvoje Niksic
Abandoned <[EMAIL PROTECTED]> writes:

> I do this use FOR easly but the speed very imported for me. I want
> to the fastest method please help me.

Can you post the code snippet that was too slow for you?  Are the
lists sorted?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Magazine: Issue 1 Free!

2007-10-05 Thread Brian Jones
On 10/5/07, Paul McGuire <[EMAIL PROTECTED]> wrote:
>
> On Oct 5, 9:44 am, Grant Edwards <[EMAIL PROTECTED]> wrote:
> > On 2007-10-05, Steve Holden <[EMAIL PROTECTED]> wrote:
> >
> > > I've just been told by the editors at Python Magazine that the first
> > > issue is out.
> >
> > The first issue is issue number 10?
> >
> > That's a bit silly.
> >
> > --
> > Grant Edwards   grante Yow! I can't decide
> which
> >   at   WRONG TURN to make
> first!!
> >visi.comI wonder if BOB
> GUCCIONE
> >has these problems!
>
> Probably Issue 10 as in "issued in October, being the 10th month", so
> this is more of an id than it is a sequential index number.  Just like
> a social security number of 123-45-6789 does not mean you are the
> 123,456,789th human born since the beginning of the SS system.
>
> But I grant that Issue number does have some connotation of sequence
> to it, and if the next issue is something like 2 or 8, or really
> anything other than 11, now THAT would be silly.  And I'm sure that in
> the future, when people are trying to amass the complete set of Python
> Magazines, they'll wonder why those issues 1-9 of the first volume are
> so hard to come by.
>
> But I suspect that, come January, we will see the release of Vol 2,
> Issue 1.  Just an artifact of having the first issue come out in some
> month other than January.
>
> -- Paul
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>

It's "Volume 1, Issue 10". A volume is a year. When January '08 is released,
it will be "Volume 2, Issue 1".

Keep the feedback coming!
brian.

-- 
Brian K. Jones
Python Magazine  http://www.pythonmagazine.com
My Blog  http://m0j0.wordpress.com
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Boolean parser..

2007-10-05 Thread Paul McGuire
On Oct 4, 3:00 pm, [EMAIL PROTECTED] wrote:
> On Oct 5, 7:29 am, Abandoned <[EMAIL PROTECTED]> wrote:
>
> > Hi..
> > I try a boolean parser in python since 1 weak.. But i can't do this
> > because this is very complicated :(
> > Do you know any blooean parser script in python or how do i write a
> > boolean parser ?
> > example query: ((google or yahoo) or (live msn)) not web
> > I'm sorry my bad english.
> > King Regards..
>
> Try the pyparsing module (google it)
> They have several examples.

The pyparsing wiki has this online example:
http://pyparsing.wikispaces.com/space/showimage/searchparser.py.

-- Paul

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


Re: Python Magazine: Issue 1 Free!

2007-10-05 Thread Steve Holden
Grant Edwards wrote:
> On 2007-10-05, Steve Holden <[EMAIL PROTECTED]> wrote:
> 
>> I've just been told by the editors at Python Magazine that the first 
>> issue is out.
> 
> The first issue is issue number 10?
> 
> That's a bit silly.
> 
It's the October edition. They obviously decided to make sure the month 
numbering was consistent across the volumes.

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden

Sorry, the dog ate my .sigline so I couldn't cat it

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


Re: Python Magazine: Issue 1 Free!

2007-10-05 Thread Paul McGuire
On Oct 5, 9:44 am, Grant Edwards <[EMAIL PROTECTED]> wrote:
> On 2007-10-05, Steve Holden <[EMAIL PROTECTED]> wrote:
>
> > I've just been told by the editors at Python Magazine that the first
> > issue is out.
>
> The first issue is issue number 10?
>
> That's a bit silly.
>
> --
> Grant Edwards   grante Yow! I can't decide which
>   at   WRONG TURN to make first!!
>visi.comI wonder if BOB GUCCIONE
>has these problems!

Probably Issue 10 as in "issued in October, being the 10th month", so
this is more of an id than it is a sequential index number.  Just like
a social security number of 123-45-6789 does not mean you are the
123,456,789th human born since the beginning of the SS system.

But I grant that Issue number does have some connotation of sequence
to it, and if the next issue is something like 2 or 8, or really
anything other than 11, now THAT would be silly.  And I'm sure that in
the future, when people are trying to amass the complete set of Python
Magazines, they'll wonder why those issues 1-9 of the first volume are
so hard to come by.

But I suspect that, come January, we will see the release of Vol 2,
Issue 1.  Just an artifact of having the first issue come out in some
month other than January.

-- Paul

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


Re: remove list elements..

2007-10-05 Thread Carsten Haese
On Fri, 2007-10-05 at 07:27 -0700, Abandoned wrote:
> Hi..
> I have a problem..
> list1=[11, 223, 334, 4223...] 1 million element
> list2=[22,223,4223,2355...] 500.000 element
> 
> I want to difference list1 to list2 but order very importent..
> 
> My result must be:
> list3=[11,334,...]
> 
> I do this use FOR easly but the speed very imported for me. I want to
> the fastest method please help me.

If you can write this as a for/append loop, then you can easily rewrite
it into a list comprehension:

 = []
for  in :
  if :
 .append()

becomes

 = [ for  in  if ]

Now all you need to do is fill in the blanks.

As a hint for what exactly to fill in for blank4, remember (or be
advised) that Python has sets.

HTH,

-- 
Carsten Haese
http://informixdb.sourceforge.net


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


Re: remove list elements..

2007-10-05 Thread chris . monsanto
On Oct 5, 10:27 am, Abandoned <[EMAIL PROTECTED]> wrote:
> Hi..
> I have a problem..
> list1=[11, 223, 334, 4223...] 1 million element
> list2=[22,223,4223,2355...] 500.000 element
>
> I want to difference list1 to list2 but order very importent..
>
> My result must be:
> list3=[11,334,...]
>
> I do this use FOR easly but the speed very imported for me. I want to
> the fastest method please help me.
>
> I'm sorry my bad english.
>
> King regards..

Research the "set" data type. :)

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


Version 0.3.7 of the config module has been released

2007-10-05 Thread Vinay Sajip
Version 0.3.7 of the Python config module has been released.

What Does It Do?

The config module allows you to implement a hierarchical configuration
scheme with support for mappings and sequences, cross-references
between one part of the configuration and another, the ability to
flexibly access real Python objects, facilities for configurations to
include and cross-reference one another, simple expression evaluation
and the ability to change, save, cascade and merge configurations. You
can easily integrate with command line options using optparse.

This module has been developed on python 2.3 but should work on
version 2.2 or greater. A test suite using unittest is included in the
distribution.

A very simple configuration file (simple.cfg):

# starts here
message: Hello, world!
#ends here

a very simple program to use it:

from config import Config

cfg = Config(file('simple.cfg'))
print cfg.message

results in:

Hello, world!

Configuration files are key-value pairs, but the values can be
containers that contain further values.

A simple example - with the example configuration file:

messages:
[
  {
stream : `sys.stderr`
message: 'Welcome'
name: 'Harry'
  }
  {
stream : `sys.stdout`
message: 'Welkom'
name: 'Ruud'
  }
  {
stream : $messages[0].stream
message: 'Bienvenue'
name: Yves
  }
]

a program to read the configuration would be:

from config import Config

f = file('simple.cfg')
cfg = Config(f)
for m in cfg.messages:
s = '%s, %s' % (m.message, m.name)
try:
print >> m.stream, s
except IOError, e:
print e

which, when run, would yield the console output:

Welcome, Harry
Welkom, Ruud
Bienvenue, Yves

The above example just scratches the surface. There's more information
about this module available at

http://www.red-dove.com/python_config.html

Comprehensive API documentation is available at

http://www.red-dove.com/config/index.html

As always, your feedback is most welcome (especially bug reports,
patches and suggestions for improvement). Enjoy!

Cheers

Vinay Sajip
Red Dove Consultants Ltd.

Changes since the last release posted on comp.lang.python[.announce]:
=
Added Mapping.__delitem__ (patch by John Drummond).
Mapping.__getattribute__ no longer returns "" when asked
for "__class__" - doing so causes pickle to crash
(reported by Jamila Gunawardena).
Allow negative numbers (reported by Gary Schoep; had
already been fixed but not yet released).

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


Re: Python Magazine: Issue 1 Free!

2007-10-05 Thread Grant Edwards
On 2007-10-05, Steve Holden <[EMAIL PROTECTED]> wrote:

> I've just been told by the editors at Python Magazine that the first 
> issue is out.

The first issue is issue number 10?

That's a bit silly.

-- 
Grant Edwards   grante Yow! I can't decide which
  at   WRONG TURN to make first!!
   visi.comI wonder if BOB GUCCIONE
   has these problems!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Program with wx in Linux and Windows

2007-10-05 Thread Grant Edwards
On 2007-10-04, marcpp <[EMAIL PROTECTED]> wrote:

> Hi I've developed a program (WXpython GUI). In Linux the GUI is correct 
> (various distributions), but in Windows all appears disordered.
> Any recomendations?

I've been using wxPython for cross platofrm stuff on Linux and
Windows for 5+ years now for at least a dozen programs. I never
had any problems like the one you describe (though "appears
disordered" isn't much of a problem description).  I write/test
on Linux, and the programs pretty much "just work" on Windows.

I would guess your code is wrong it a way that happens to be
tolerated better under Linux than Windows for some reason.  If
you can come up with a minimal example program that
demonstrates the problem, the people on the wxPython mailing
list will almost certainly be able to tell you what you've done
wrong.

-- 
Grant Edwards   grante Yow! Spreading peanut
  at   butter reminds me of
   visi.comopera!!  I wonder why?
-- 
http://mail.python.org/mailman/listinfo/python-list


supplying password to subprocess.call('rsync ...'), os.system('rsync ...')

2007-10-05 Thread timw.google
Hi

I want to write a python script that runs rsync on a given directory
and host. I build the command line string, but when I try to run
subprocess.call(cmd), or p=subprocess.Popen(cmd, shell=True),or
os.system(cmd), I get prompted for my login password. I expected this,
but when I try to give my password, it's echoed back to the terminal
and the special characters in the password is (I think) getting
interpreted by the shell (zsh)

I can't ssh w/o supplying a password. That's the way the security is
set up here.

How do I use python to do this, or do I just have to write a zsh
script?

Thanks.

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


remove list elements..

2007-10-05 Thread Abandoned
Hi..
I have a problem..
list1=[11, 223, 334, 4223...] 1 million element
list2=[22,223,4223,2355...] 500.000 element

I want to difference list1 to list2 but order very importent..

My result must be:
list3=[11,334,...]

I do this use FOR easly but the speed very imported for me. I want to
the fastest method please help me.

I'm sorry my bad english.

King regards..

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


Re: novice list

2007-10-05 Thread Paul Rudin
István <[EMAIL PROTECTED]> writes:

> Could somebody suggest me a novice Python list, please?

Here you go:

['novice']


(Sorry, couldn't resist.)

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

Re: Python Magazine: Issue 1 Free!

2007-10-05 Thread Adrian Cherry
Paul McGuire <[EMAIL PROTECTED]> wrote in
news:[EMAIL PROTECTED]: 

> I thought Steve Holden's Random Hits column was the "back
> page commentry".

after re-reading it then yes I can see your point, I suppose I 
was just hoping for some pythonesque humour to close the show!

Regards

Adrian

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


Re: unit testing

2007-10-05 Thread byte8bits
On Oct 5, 5:38 am, Craig Howard <[EMAIL PROTECTED]> wrote:
> Brad:
>
> If the program is more than 100 lines or is a critical system, I
> write a unit test. I hate asking myself, "Did I break something?"
> every time I decide to refactor a small section of code. For
> instance, I wrote an alarm system in Python for a water treatment
> plant. If the chlorine, pH, or turbidity are out of spec, an email
> message is sent to the plant operator's pager. Because of the nature
> of the alarm system, extensive field testing was out of the question.
> Unit testing was the only way to ensure it worked without disrupting
> the plant operation.
>
> Craig

Thanks to all for the opinions. Just to clarify, I have nothing
against testing. I like doing it. I catch a lot of bugs! I dislike the
formality of the unittest module. It's unyielding. It makes testing
difficult unless your code is written with testing in mind from the
start.

I maintain old code... code written a long time ago, before unittest
was popular. Getting unittest to work on that is difficult at best. So
we do informal testing ourselfs. The end result is the same... bugs
are squashed before the code is placed into production. Many times, we
find bugs as soon as we write a test!

Thanks again for the advice.

Brad


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


Re: migrating to packages

2007-10-05 Thread Hrvoje Niksic
Gerardo Herzig <[EMAIL PROTECTED]> writes:

> If the original MYCLASSES.py has 5 different classes ,say A,B,C,D,E
> , each one has to be imported (as A and B) in order to be used for
> the client code. The thing is, there are more than 5 classes, and
> looks like a lot of unnecesary work to me, since a particular
> program can use 1,2, or 3 classes at the timeThats why im
> watching the way to override the `import statement'...
>
> Damn client code!!!

You can create both a package and a compatibility module.  The package
would be broken into modules for modularity, while the compatibility
module would import what old code needs from the package, like this:

# old.py:
from new.submodule1 import A, B
from new.submodule2 import C, D
...

Now, old code can keep using "from old import A" and such, while new
code would import new.submodule1, new.submodule2, etc., as necessary.

Old code is no worse off because, although it uses the compatibility
module that just imports everything, that is in essence what the
previous module did as well.  On the other hand, new code can make use
of the modularity and reduce load times by only importing what it
really needs.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Magazine: Issue 1 Free!

2007-10-05 Thread Paul McGuire
On Oct 5, 7:52 am, "Adrian Cherry" <[EMAIL PROTECTED]> wrote:
> Steve Holden <[EMAIL PROTECTED]> wrote innews:[EMAIL PROTECTED]:
>
> > I've just been told by the editors at Python Magazine that
> > the first issue is out. It's all-electronic so anyone can
> > download and read it. Let them know what you think:
>
> >http://www.pythonmagazine.com/c/issue/2007/10
>
> > regards
> >   Steve
>
> Thanks for that, initial impression looks good, I peruse it later
> when the boss isn't watching. Unfortunately there seems to be a
> few horror pictures crept in on page 4!.
>
> One initial comment is the end of the magazine. It just seems to
> stop abruptly. No back page commentry, cartoon or teaser for the
> next issue.
>
> Regards
>
> Adrian

I thought Steve Holden's Random Hits column was the "back page
commentry".  Maybe this column needs to start on the last page, and
continue on the previous one, so that it qualifies as truly "back
page".

Nice launch, good luck PyMag!

-- Paul

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


Re: migrating to packages

2007-10-05 Thread Gerardo Herzig
Bruno Desthuilliers wrote:

>Gerardo Herzig a écrit :
>  
>
>>Carl Bank a écrit :
>>
>>
>>>Add these lines in __init__.py:
>>>
>>>from MYCLASSES.A import A
>>>from MYCLASSES.B import B
>>> 
>>>
>>>  
>>>
>>Ummm, that works indeed, but forces me to import all (more than A and B) 
>>classes, rigth?
>>
>>
>
>Why so ?
>
>  
>
If the original MYCLASSES.py has 5 different classes ,say A,B,C,D,E , 
each one has to be imported (as A and B) in order to be used for the 
client code. The thing is, there are more than 5 classes, and looks like 
a lot of unnecesary work to me, since a particular program can use 1,2, 
or 3 classes at the timeThats why im watching the way to override 
the `import statement'...

Damn client code!!!

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


Re: tkinter question

2007-10-05 Thread Kevin Walzer
Eric Brunel wrote:
> On Fri, 05 Oct 2007 14:10:57 +0200, Kevin Walzer <[EMAIL PROTECTED]> 
> wrote:
>> "expand = 1" ==  "expand=TRUE"--that means the widget resizes itself 
>> when the window is re-sized.
> 
> That's the theory... But what does fill=BOTH means then? And why does 
> expand=1 (or TRUE, or True) is only needed in some cases and not others? 
> And I'm quite sure that sometimes, I use expand=1 and it does exactly 
> what I don't want, and removing it gives the behaviour I want. I've been 
> doing tk/Tkinter stuff for quite a few years now, and I still haven't 
> understood exactly when I should use this option... Quite 
> counter-intuitive, IMHO.
> 
> But then, since I almost never use pack for this kind of layout, I guess 
> it's not really important...

"Fill" refers to the dimension/space that is filled when you expand the 
widget (assuming "expand" is set to true). "fill=x" means the widget 
will expand horizontally (along the x axis). "fill=y" means that the 
widget will expand vertically (along the y axis). "fill=both" means the 
widget will expand in both direction.

Frederick Lundh has a good introduction to the packer here: 
http://effbot.org/tkinterbook/pack.htm

I find "pack" to be more flexible than "grid," so I prefer it for 
complex layouts. "grid" is better for simple layouts.

HTH,
Kevin

-- 
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Magazine: Issue 1 Free!

2007-10-05 Thread Adrian Cherry
Steve Holden <[EMAIL PROTECTED]> wrote in
news:[EMAIL PROTECTED]: 

> I've just been told by the editors at Python Magazine that
> the first issue is out. It's all-electronic so anyone can
> download and read it. Let them know what you think:
> 
>http://www.pythonmagazine.com/c/issue/2007/10
> 
> regards
>   Steve

Thanks for that, initial impression looks good, I peruse it later 
when the boss isn't watching. Unfortunately there seems to be a 
few horror pictures crept in on page 4!.

One initial comment is the end of the magazine. It just seems to 
stop abruptly. No back page commentry, cartoon or teaser for the 
next issue.

Regards

Adrian




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


Re: module confusion

2007-10-05 Thread Neil Cerutti
On 2007-10-05, Lawrence D'Oliveiro <[EMAIL PROTECTED]> wrote:
> In message <[EMAIL PROTECTED]>, Neil Cerutti wrote:
>
>> On 2007-10-03, Lawrence D'Oliveiro <[EMAIL PROTECTED]>
>> wrote:
>>> In Python, all names _are_ variables. They are not "bound" to
>>> objects. The value of os.path is a pointer. It's implemented
>>> as a pointer, it has all the semantics of a pointer.
>> 
>> No. A pointer is also an iterator.
>> 
>> void duplicate(char *d, const char *s)
>> {
>>   while (*d++ = *s++)
>> ;
>> }
>
> So if you can't do pointer arithmetic, then it's not a pointer?
> Trying this:
>
> void duplicate(void *d, const void *s)
> {
>   while (*d++ = *s++)
> ;
> }
>
> I get:
>
> test.c: In function 'duplicate':
> test.c:3: warning: dereferencing 'void *' pointer
> test.c:3: warning: dereferencing 'void *' pointer
> test.c:3: error: invalid use of void expression
>
> So you can't do arithmetic or iterate with a void * pointer.

...or dereference.

> Does that mean it's not really a pointer?

That's an interesting taxonimical conundrum. If a pointer were
defined by it's semantics, then yes, a void pointer wouldn't be a
pointer. But pointers are defined not by behavior, but by an
ANSI/ISO standard. The term "pointer to void" makes sense if you
think of it as a pointer in an altered, intermediate state.

I suppose you might score a Pyrrhic victory by claiming that
Python identifiers are pointers that don't behave like pointers.
But you claimed the opposite.

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


Re: Boolean parser..

2007-10-05 Thread David
On 10/4/07, Abandoned <[EMAIL PROTECTED]> wrote:
> Hi..
> I try a boolean parser in python since 1 weak.. But i can't do this
> because this is very complicated :(
> Do you know any blooean parser script in python or how do i write a
> boolean parser ?
> example query: ((google or yahoo) or (live msn)) not web
> I'm sorry my bad english.
> King Regards..
>
> --

http://mail.python.org/pipermail/python-list/2006-August/399804.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: tkinter question

2007-10-05 Thread Eric Brunel
On Fri, 05 Oct 2007 14:10:57 +0200, Kevin Walzer <[EMAIL PROTECTED]>  
wrote:
> "expand = 1" ==  "expand=TRUE"--that means the widget resizes itself  
> when the window is re-sized.

That's the theory... But what does fill=BOTH means then? And why does  
expand=1 (or TRUE, or True) is only needed in some cases and not others?  
And I'm quite sure that sometimes, I use expand=1 and it does exactly what  
I don't want, and removing it gives the behaviour I want. I've been doing  
tk/Tkinter stuff for quite a few years now, and I still haven't understood  
exactly when I should use this option... Quite counter-intuitive, IMHO.

But then, since I almost never use pack for this kind of layout, I guess  
it's not really important...
-- 
python -c "print ''.join([chr(154 - ord(c)) for c in  
'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Where's the Starship's crew?

2007-10-05 Thread Dick Moores
At 04:54 AM 10/5/2007, Thomas Heller wrote:
>Dick Moores schrieb:
> > 
> >
> > I didn't check on all of them, but the only one I found was Mark
> > Hammond .
> >
> > Dick Moores
> >
>
>There are more. Think of it as a game you have to solve.

Yeah, a mind numbing game!

http://starship.python.net/crew/ewalstad/ Eric Walstad
http://starship.python.net/crew/piers/ Piers Lauder
http://starship.python.net/crew/jae/ --> http://zhar.net/  John Eikenberry
http://starship.python.net/crew/mwh/
http://starship.python.net/crew/manus/ Manus Hand
http://starship.python.net/crew/bhoel/ Berthold Höllmann
http://starship.python.net/crew/marduk/ ("Server Error")
http://starship.python.net/crew/schorsch/
http://starship.python.net/crew/dni/ David Niergarth
http://starship.python.net/crew/jcooley/ James Cooley
http://starship.python.net/crew/sdrees/ Stefan Drees
http://starship.python.net/crew/jwt/ Jim Tittsler
http://starship.python.net/crew/theller/ Thomas Heller
http://starship.python.net/crew/gherman/ Dinu Gherman
http://starship.python.net/crew/mhammond/ Mark Hammond
http://starship.python.net/crew/atuining/
http://starship.python.net/crew/hooft/ Rob W.W. Hooft
http://starship.python.net/crew/lemburg/ --> http://www.egenix.com/
http://starship.python.net/crew/goodger/ David Goodger
http://starship.python.net/crew/mmuller/ Mike Muller
http://starship.python.net/crew/skippy/ same as 
http://starship.python.net/crew/mhammond/ Mark Hammond

BTW How could I have done this with Python script?

Dick Moores

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


Re: Python and SSL

2007-10-05 Thread [EMAIL PROTECTED]
On Oct 5, 2:50 am, John Nagle <[EMAIL PROTECTED]> wrote:
> Johny wrote:
> > Martin and John,
> > Thank you both for your replies
> >  Must I  have OpenSSL imported in my Python program?
> > So far I have been using only SSL  support.
> > Built-in SSL support works OK if I connect from my Python program
> > directly to SSL server ( but not via proxy).
> > L.
>
>  SSL isn't SUPPOSED to work through proxies.  That's the whole point of
> SSL - to prevent somebody in the middle from tapping into the connection.
> Look up "man in the middle attack".

I'm afraid this is complete rubbish - using a proxy with SSL is fine.
The only
issue is that the built in python SSL support doesn't work with
proxies. There
are a number of ways of adding support though eg.
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/456195
One thing to note is that python's built in SSL support does not
validate the
server certicate and is therefore vulnerable to MITM attacks
irrespective
of whether a proxy is in use or not. If you want real security then
you need
to use something like PyOpenSSL or M2Crypto and a certificate store
with your
root CAs.

Rich.

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


Re: tkinter question

2007-10-05 Thread goldtech

>
> try to change listbox.pack() to listbox.pack(expand=True, fill=BOTH)
> .. is it that you want ?

Yes.

>
>  -mykhal

Worked with TRUE all uppercase.

Exactly what I needed. Thank you.

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


Re: tkinter question

2007-10-05 Thread Kevin Walzer
Eric Brunel wrote:

> 
> BTW, even for something that simple, using the grid geometry manager may 
> be easier... It is at least easier to explain: don't ask me what the 
> expand=1 option means, I never understood it... I just add or remove it 
> when the pack doesn't do what I want. The sticky option with grid is 
> easier to handle.
> 

"expand = 1" ==  "expand=TRUE"--that means the widget resizes itself 
when the window is re-sized.


-- 
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Boolean parser..

2007-10-05 Thread Abandoned
http://pyparsing.wikispaces.com/space/showimage/searchparser.py this
is searchparser but i can't understant to use this.
Can anybody explain this how to use ?

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


Re: Python "implements " equivalent?

2007-10-05 Thread David
> I'm a seasoned Java programmer and quite a big fan of interfaces...
> i.e. The idea that if I make a number of distinct classes that
> implement interface X, I can pass them all as parameters to functions
> or whatnot that require an X object.
>
> Is there something similar in Python?
>

Python will probably be getting Abstract Base Classes at some point.

http://www.python.org/dev/peps/pep-3119/

For ABC in current versions of Python, see the "Can you implement
abstract classes in Python in 0 lines of code? Or 4?" question on this
page: http://norvig.com/python-iaq.html

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


Re: Where's the Starship's crew?

2007-10-05 Thread Thomas Heller
Dick Moores schrieb:
> 
> 
> I didn't check on all of them, but the only one I found was Mark 
> Hammond .
> 
> Dick Moores
> 

There are more.  Think of it as a game you have to solve.

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


Python Magazine: Issue 1 Free!

2007-10-05 Thread Steve Holden
I've just been told by the editors at Python Magazine that the first 
issue is out. It's all-electronic so anyone can download and read it. 
Let them know what you think:

   http://www.pythonmagazine.com/c/issue/2007/10

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden

Sorry, the dog ate my .sigline so I couldn't cat it

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


Re: WebBased Vector 2D Graphics

2007-10-05 Thread Robin Becker
Diez B. Roggisch wrote:
>  [EMAIL PROTECTED] wrote:
> 
...
> 
> You certainly need to get on speed with webdevelopment. Otherwise you will
> fail miserably.
> 
> There are several options here:
> 
>  - rendering a server-side image, deliver that embedded in a html-page
> 
>  - render using html tags like DIV and the like, which allow for positioned
> colored rectangles and text, in pixel coordinates
> 
>  - canvas tag, to render 2D-drawing-commands
> 
>  - embedded SVG
> 
> All that can be enriched with AJAX to have that fancy
> realtime-update-thingy.
> 
> Diez

simple rectangles are pretty easy though. I did a progress bar here
http://www.jessikat.plus.com/pbar.html with a bit of javascript.

The other side of the information usually involves ajax call backs to determine 
how much of the job has been done etc etc. I seem to remember doing that for a 
project a while back. As I recall we had a cgi script that did

action "start" start off a long running job that detached itself from the web 
server so the response could be made short

action "query" find out from an output file how much of the job has been done.

A javascript timeout periodically performed the query request and used the 
response to update the ticker.
-- 
Robin Becker

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


Re: module confusion

2007-10-05 Thread Steve Holden
Steven D'Aprano wrote:
> On Fri, 05 Oct 2007 00:12:33 -0500, Robert Kern wrote:
> 
>> This is somewhat odd, because most modules aren't exposed that way. They
>> are either in their own file and accessed by importing them directly, or
>> they are inside a package.
> 
> Any time you say:
> 
> import parrot
> 
> 
> in one of your modules, you export parrot to anything that 

subsequently

>  imports your 
> module. (Unless you take specific steps to prevent it, for instance with 
> del parrot.)

or the creation of an __all__ containing an exclusive list of names for 
export.
> 
> 
> Just to pick some random examples:
> 
 import ConfigParser, base64, fileinput
 ConfigParser.re
> 
 base64.struct
> 
 base64.binascii
> 
 fileinput.sys
> 
 fileinput.os
> 
> 
> 
> It's quite common.
> 
> 
OK, I am sort of getting used to the idea that you guys are going to 
beat this one to death with a stick, and will still be tossing emails 
back and forth to each other while the rest of us are admiring the heat 
death of the universe.

So please try and avoid writing anything that will be misconstrued by 
newless cloobs unfortunate enough to reach this thread as a result of a 
search for meaningful information on Python imports.

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden

Sorry, the dog ate my .sigline so I couldn't cat it

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


  1   2   >