Re: Fastest way to calculate leading whitespace

2010-05-10 Thread Stefan Behnel

Stefan Behnel, 10.05.2010 08:54:

dasacc22, 08.05.2010 19:19:

This is a simple question. I'm looking for the fastest way to
calculate the leading whitespace (as a string, ie ' ').


Here is an (untested) Cython 0.13 solution:

from cpython.unicode cimport Py_UNICODE_ISSPACE

def leading_whitespace(unicode ustring):
cdef Py_ssize_t i
cdef Py_UNICODE uchar

for i, uchar in enumerate(ustring):
if not Py_UNICODE_ISSPACE(uchar):
return ustring[:i]
return ustring

Cython compiles this to the obvious C code, so this should be impossible
to beat in plain Python code.


... and it is. For a simple string like

u = u"   abcdefg" + u"fsdf"*20

timeit gives me this for "s=u.lstrip(); u[:-len(s)]":

100 loops, best of 3: 0.404 usec per loop

and this for "leading_whitespace(u)":

1000 loops, best of 3: 0.0901 usec per loop

It's closer for the extreme case of an all whitespace string like " "*60, 
where I get this for the lstrip variant:


100 loops, best of 3: 0.277 usec per loop

and this for the Cython code:

1000 loops, best of 3: 0.177 usec per loop

But I doubt that this is the main use case of the OP.

Stefan

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


Re: solve a newspaper quiz

2010-05-10 Thread Francesco Bochicchio
On 9 Mag, 11:20, superpollo  wrote:
> "if a b c are digits, solve ab:c=a*c+b"
>
> solved in one minute with no thought:
>
> for a in range(10):
>      for b in range(10):
>          for c in range(10):
>              try:
>                  if (10.*a+b)/c==a*c+b:
>                      print "%i%i:%i=%i*%i+%i" % (a,b,c,a,c,b)
>              except:
>                  pass
>
> any suggestion for improvement?
>
> bye

The obvious one-liner. Maybe not an improvement, but more compact (I
included the solutions for the really lazy ones).
But you need to think just one second to exclude 0 from the values of
c and avoid a divide by zero exception.


>>> [(a,b,c) for a in range(10) for b in range(10) for c in range(1,10) if 
>>> (a*10+b)/c == a*c+b ]
[(0, 0, 1), (0, 0, 2), (0, 0, 3), (0, 0, 4), (0, 0, 5), (0, 0, 6), (0,
0, 7), (0, 0, 8), (0, 0, 9), (0, 1, 1), (0, 2, 1), (0, 3, 1), (0, 4,
1), (0, 5, 1), (0, 6, 1), (0, 7, 1), (0, 8, 1), (0, 9, 1), (1, 0, 3),
(1, 5, 2), (1, 6, 2), (2, 0, 3), (2, 1, 3), (3, 1, 3), (4, 1, 3), (4,
2, 3), (5, 2, 3), (6, 2, 3), (6, 3, 3), (7, 3, 3), (8, 3, 3), (8, 4,
3), (9, 4, 3)]


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


Extract all words that begin with x

2010-05-10 Thread Jimbo
Hello

I am trying to find if there is a string OR list function that will
search a list of strings for all the strings that start with 'a' &
return a new list containing all the strings that started with 'a'.

I have had a search of Python site & I could not find what I am
looking for, does a function like this exist?

The only one that I think could work is, use the string
function .count()

algorithm: to exract all the words inside a list that start with 'a'
 - make sure the list is arranged in alphabetical order
 - convert the list to a big string
 - use list_string.count(',a') to obtain the index where the last 'a'
word occurs
 - convert back into string (yes this is a REAL hack :P)
 - and then create a new list, ie, new_list = list[0:32]
 - & return new_list

Ok that algorithm is terrible, I know, & I just realise that it wont
work for letters after 'a'. So if anyone could suggest a function or
algorithm it would be extremely helpful
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Extract all words that begin with x

2010-05-10 Thread Xavier Ho
Have I missed something, or wouldn't this work just as well:

>>> list_of_strings = ['2', 'awes', '3465sdg', 'dbsdf', 'asdgas']
>>> [word for word in list_of_strings if word[0] == 'a']
['awes', 'asdgas']

Cheers,
Xav


On Mon, May 10, 2010 at 6:40 PM, Jimbo  wrote:

> Hello
>
> I am trying to find if there is a string OR list function that will
> search a list of strings for all the strings that start with 'a' &
> return a new list containing all the strings that started with 'a'.
>
> I have had a search of Python site & I could not find what I am
> looking for, does a function like this exist?
>
> The only one that I think could work is, use the string
> function .count()
>
> algorithm: to exract all the words inside a list that start with 'a'
>  - make sure the list is arranged in alphabetical order
>  - convert the list to a big string
>  - use list_string.count(',a') to obtain the index where the last 'a'
> word occurs
>  - convert back into string (yes this is a REAL hack :P)
>  - and then create a new list, ie, new_list = list[0:32]
>  - & return new_list
>
> Ok that algorithm is terrible, I know, & I just realise that it wont
> work for letters after 'a'. So if anyone could suggest a function or
> algorithm it would be extremely helpful
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Extract all words that begin with x

2010-05-10 Thread superpollo

Jimbo ha scritto:

Hello

I am trying to find if there is a string OR list function that will
search a list of strings for all the strings that start with 'a' &
return a new list containing all the strings that started with 'a'.

I have had a search of Python site & I could not find what I am
looking for, does a function like this exist?


>>> sw = lambda s: lambda t: t.startswith(s)
>>> list = ["a string","another one","this is a string","and so is this 
one"]

>>> filter(sw("a"),list)
['a string', 'another one', 'and so is this one']
>>>

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


Re: unable to get Hudson to run unit tests

2010-05-10 Thread Jean-Michel Pichavant

Stefan Behnel wrote:

j vickroy, 07.05.2010 20:44:

I apologize if this is not the appropriate forum for a question about
Hudson (http://hudson-ci.org/), but I did not know where else to ask and
my web searches have not been fruitful.


Certainly nice to read something about Hudson in this forum, which is 
rare enough. It's seriously the greatest CI tool I've ever used, and 
it works great with Python apps.


We use it, but this is a python list that's why there's few topics about 
it. :)
Speaking for myself,  I use it to execute the linter (pylint) on the 
code and run unitary tests. Great tool for sure.


JM

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


NFL NBA MLB NHL jersey

2010-05-10 Thread world-trade
AAA quality clothes cheap wholesale . (http://
www.jordanonline06.com/)
NFL jersey wholesale (http://www.jordanonline06.com/)
NFL NBA MLB NHL soccer  soccer jerseys (http://
www.jordanonline06.com/)
nike brand,MLB jerseys china supplier (http://
www.jordanonline06.com/)
MLB jerseys china wholesaler.(http://www.jordanonline06.com/)
wholesale MLB jerseys.(http://www.jordanonline06.com/)
NFL shop,,NFL NBA MLB NHL jerser wholesale,NFL NBA MLB NHL
(http://www.jordanonline06.com/)
jersey supplier(http://www.jordanonline06.com/)
NFL NBA MLB NHL jersey korea supplier (http://
www.jordanonline06.com/)
NFL NBA jersey stock (http://www.jordanonline06.com/)
alibaba,wholesale NFL NBA MLB NHL jerseys.(http://
www.jordanonline06.com/)
soccer jersey china supplier (http://www.jordanonline06.com/)
soccer jerseys china wholesale.(http://www.jordanonline06.com/)
wholesale soccer jersey,supply soccer jerseys (http://
www.jordanonline06.com/)
NFL NBA MLB NHL copy jersey (http://www.jordanonline06.com/)
copy www.guoshitrade.com paypal paymentjerseys from china
(http://www.jordanonline06.com/)
NFL jerseys from china.(http://www.jordanonline06.com/)
NBA www.guoshitrade.com paypal payment shop (http://
www.jordanonline06.com/)
NFL jersey wholesale womens NBA jersey  (http://
www.jordanonline06.com/)
NBA jersey sale  (http://www.jordanonline06.com/)
cheap authentic NBA jersey
(http://www.jordanonline06.com/)  
07 jersey NBA star
(http://www.jordanonline06.com/)
NBA jersey numbers
(http://www.jordanonline06.com/)  
NBA vintage jersey NBA throw back jersey
(http://www.jordanonline06.com/)
NBA jersey dress for woman
(http://www.jordanonline06.com/)
reebok NBA jersey  (http://www.jordanonline06.com/)  
NBA jersey for toddler  (http://www.jordanonline06.com/)
old NBA jersey  (http://www.jordanonline06.com/)  
youth NBA swingman jersey
(http://www.jordanonline06.com/)
NBA authentic basketball jersey  (http://www.jordanonline06.com/)
basketball jersey NBA new style (http://www.jordanonline06.com/)
NBA all star game jersey (http://www.jordanonline06.com/)
NBA new jersey (http://www.jordanonline06.com/)  
adidas NBA jersey  (http://www.jordanonline06.com/)
official NBA jersey (http://www.jordanonline06.com/)
classics hardwood jersey NBA (http://www.jordanonline06.com/)
old school NBA jersey (http://www.jordanonline06.com/)  
NBA jersey for woman  (http://www.jordanonline06.com/)
classic NBA jersey (http://www.jordanonline06.com/)  
NFL jersey korea supplier(http://www.jordanonline06.com/)
mitchell and ness NBA jersey (http://www.jordanonline06.com/)
2009 game jersey NBA star  (http://www.jordanonline06.com/)
alternate jersey NBA  (http://www.jordanonline06.com/)
best selling NBA jersey (http://www.jordanonline06.com/)
NBA jersey card  (http://www.jordanonline06.com/)  
authenic NBA jersey  (http://www.jordanonline06.com/)
discount NBA jersey  (http://www.jordanonline06.com/)
Wholesale MLB jerseys,paypal,cheap MLB jersey(http://
www.jordanonline06.com/)
wholesale football jerseys,(http://www.jordanonline06.com/)
reebok MLB player jerseys,(http://www.jordanonline06.com/)  
authentic MLB jerseys,discount MLB  
jerseys,mitchell ness jerseys,throwback (http://
www.jordanonline06.com/)
Nice jerseys,replica MLB jerseys,(http://www.jordanonline06.com/)
women MLB jerseys,youth MLB (http://www.jordanonline06.com/)
jerseys,official MLB jerseys,(http://www.jordanonline06.com/)  
pro Bowl jerseys,super bowl jerseys,(http://www.jordanonline06.com/)
nhljerseys,hockey jerseys,nba jerseys,(http://
www.jordanonline06.com/)
all star jersey,mlb baseball jerseys (http://www.jordanonline06.com/)
(http://www.jordanonline06.com/)  


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


Re: Extract all words that begin with x

2010-05-10 Thread James Mills
On Mon, May 10, 2010 at 6:50 PM, Xavier Ho  wrote:
> Have I missed something, or wouldn't this work just as well:
>
 list_of_strings = ['2', 'awes', '3465sdg', 'dbsdf', 'asdgas']
 [word for word in list_of_strings if word[0] == 'a']
> ['awes', 'asdgas']

I would do this for completeness (just in case):

 [word for word in list_of_strings if word and word[0] == 'a']

Just guards against empty strings which may or may not be in the list.

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


Re: Extract all words that begin with x

2010-05-10 Thread superpollo

superpollo ha scritto:

Jimbo ha scritto:

Hello

I am trying to find if there is a string OR list function that will
search a list of strings for all the strings that start with 'a' &
return a new list containing all the strings that started with 'a'.

I have had a search of Python site & I could not find what I am
looking for, does a function like this exist?


 >>> sw = lambda s: lambda t: t.startswith(s)
 >>> list = ["a string","another one","this is a string","and so is this 
one"]

 >>> filter(sw("a"),list)
['a string', 'another one', 'and so is this one']
 >>>

bye


of course there is a simpler way:

>>> [string for string in list if string.startswith("a")]
['a string', 'another one', 'and so is this one']
>>>

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


Re: idiomatic way to collect and report multiple exceptions?

2010-05-10 Thread Jean-Michel Pichavant

Ben Cohen wrote:

Apologies for the TABs -- I wrote that example for demonstration purposes in my 
mail client -- I'll copy and paste from a real code editor in the future.
Ben
  


There's nothing to apologies for. Be wary of those trying to get you out 
of the right path, they will lie to you stating python does not support 
Tabs while it surely does. Did you know that before generating bytecode, 
python replace all 4 spaces by a tabulations ? If that is not a proof 
that TABS is the all mighty indentation, I'm Mickey Mouse.


Feel free to join our group for promoting TABS (monthly fee 50$). You an 
also purchase the book 'TABS Are Beautiful' (12 pages, 380$).


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


Re: Picking a license

2010-05-10 Thread Paul Boddie
On 10 Mai, 03:09, Patrick Maupin  wrote:
> On May 9, 6:39 pm, Paul Boddie  wrote:
> > but if they aren't pitching it directly at you, why would you believe
> > that they are trying to change your behaviour?
>
> Because I've seen people specifically state that their purpose in
> GPLing small libraries is to encourage other people to change their
> behavior.  I take those statements at face value.  Certainly RMS
> carefully lays out that the LGPL should be used sparingly in his "Why
> you shouldn't use the Lesser GPL for your next library" post.  (Hint:
> he's not suggesting a permissive license instead.)

Sure, but all he's asking you to do is to make the software available
under a GPL-compatible licence.

[...]

> rst2pdf was licensed under the MIT license before I started
> contributing to it, and there is no way I was going to even consider
> adding patches for a GPLed package (which would certainly have to be
> GPLed) into the rst2pdf repository.  (Say what you will about how
> sometimes differently licensed code can be combined, but RMS has to
> share quite a bit of the blame/credit for the whole combining licenses
> FUD.)

I think the FSF are quite clear about combining licences - they even
go to the trouble of telling you which ones are compatible with the
GPL - so I don't see where "FUD" comes into it, apart from possible
corner cases where people are trying to circumvent the terms of a
licence and probably know themselves that what they're trying to do is
at the very least against the spirit of the licence. Even then,
warning people about their little project to make proprietary plugins,
or whatever, is not really "FUD".

As for rst2pdf, what your modifications would mean is that the
software would need to be redistributed under a GPL-compatible
licence. I'll accept that this does affect what people can then do
with the project, but once again, you've mentioned at least one LGPL-
licensed project which was previously in this very situation, and it
was never actually GPL-licensed itself. Here's the relevant FAQ entry:

http://www.gnu.org/licenses/gpl-faq.html#LinkingWithGPL

[...]

> This is exactly the same situation that Carl was describing, only with
> two different open source packages rather than with a proprietary
> package and a GPL package.  The whole reason people use words like
> "force" and "viral" with the GPL is that this issue would not have
> come up if svglib were MIT and rst2pdf were GPL.  (Note that the LGPL
> forces you to give back changes, but not in a way that makes it
> incompatible with software under other licenses.  That's why you see
> very few complaints about the LGPL.)

Actually, the copyleft licences don't "force" anyone to "give back
changes": they oblige people to pass on changes.

[...]

> But I have definitely seen cases where people are offering something
> that is not of nearly as much value as they seem to think it is, where
> one of the goals is obviously to try to spread the GPL.

Well, even the FSF doesn't approve of trivial projects using the GPL:

http://www.gnu.org/licenses/gpl-faq.html#WhatIfWorkIsShort

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


Re: accessing superclass methods from subclass

2010-05-10 Thread Jean-Michel Pichavant

ben wrote:

Ok, thanks for the info.

What would be a better way to do this?  What I'm trying to do is treat
things in a reasonable OOP manner (all fairly new to me, esp. in
Python).  Here's a made-up example with a little more context.  Let's
say you're making a drawing program that can draw various shapes.  So
in the interest of not repeating oneself, I want a class Shape that
handles everything that shapes have, such as a color, and a location.
Then I can subclass Shape to create Square, which has code specific to
drawing a square (e.g. 4 equal sides).  So, like this:

class Shape:

x = 0
y = 0

def setColor(self,color):
self.color = color

def setLocation(self,x,y):
self.x = x
self.y = y

def getLocation(self):
return [self.x,self.y]

class Square(Shape):

size = 0

def __init__(self,size):
self.size = size

def draw(self):
location = getLocation()
# code to draw shape from location[0],location[1] at size size
# etc...

It seems to me that you would want the location code handled in the
Shape class so that I'm not rewriting it for Circle, Triangle, etc.,
but I'm not allowed to call any of those methods from the subclass.  I
must be thinking of this in the wrong way.  Help?

thanks!



  


Hi Ben,

Please do not top post.
You already been given good advices, especially the one suggesting to go 
through the tutorial. You're making basic mistakes here.


Here is a very simple version of your code.

class Shape:

   def __init__(self, x=0, y=0):
   self.x = 0
   self.y = 0
   self.color = None

   def draw(self):
   print 'drawing %s' % self


class Square(Shape):

   def __init__(self,size):
   self.size = size

   def draw(self):
   Shape.draw(self) # this is one way to call the base class method
   location = (self.x, self.y)
   # code to draw shape from self.x, self.y at size self.size
   # etc...


mySquare = Square(5,2)
mySquare.color = 'red'
print mySquare.x
>>> 5

Since your attributes are flagged as public, you don't really need 
setters & getters.



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


Re: Kindly show me a better way to do it

2010-05-10 Thread Jean-Michel Pichavant

Oltmans wrote:

On May 9, 1:53 am, superpollo  wrote:

  

add = lambda a,b: a+b
for i in reduce(add,a):
 print i



This is very neat. Thank you. Sounds like magic to me. Can you please
explain how does that work? Many thanks again.

  

shorter <> nicer IMO.
Those alternatives are interesting from a tech point of view, but 
nothing can beat the purity of a vintage 'for' loop with *meaningful names*.



salads = [['apple', 'banana'], ['apple', 'lemon', 'kiwi']]

ingredients = []

for salad in salads:
   for fruit in salad:
  ingredients.append(fruit)

print 'Remember to buy %s' % ingredients

Lame & effective (1st adjective is irrelevant outside a geek contest)

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


Re: Python is cool!!

2010-05-10 Thread lkcl
On Mar 23, 4:55 pm, Jose Manuel  wrote:
> I have been learning Python, and it is amazing  I am using the
> tutorial that comes with the official distribution.
>
> At the end my goal is to develop applied mathematic in engineering
> applications to be published on the Web, specially on app. oriented to
> simulations and control systems, I was about to start learning Java
> but I found Python which seems easier to learn that Java.
>
> Would it be easy to integrate Python in Web pages with HTML? I have
> read many info on Internet saying it is, and I hope so 

 jose, hi,

 perhaps it should be pointed out that there are four completely
different types of answers, as outlined here:
http://www.advogato.org/article/993.html

 python can be involved in absolutely every single one of those four
separate types of answers.

 you should ideally read that article to determine which of the four
approaches is most appropriate for you, and let people here know; and
then people here will be able to respond accordingly and advise you
accurately and with less time spent on their part, in guessing what it
is that you want to do.

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


Is Python a functional programming language?

2010-05-10 Thread Samuel Williams
Dear Friends,

Is Python a functional programming language?

Is this a paradigm that is well supported by both the language syntax and the 
general programming APIs?

I heard that lambdas were limited to a single expression, and that other 
functional features were slated for removal in Python 3... is this the case or 
have I been misinformed?

Finally, even if Python supports functional features, is this a model that is 
used often in client/application code?

Kind regards,
Samuel

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


unittest not being run

2010-05-10 Thread John Maclean

hi,

can some one explain why the __first__ test is not being run?

#!/usr/bin/env python
import unittest # {{{
class T1TestCase(unittest.TestCase):

def setUp(self):
pass  # can we use global variables here?

def tearDown(self):
pass  # garbage collection

def test_T1(self):
'''this test aint loading'''
self.assertEquals(1, 0)

def test_T2(self):  ## test method names begin 'test*'
self.assertEquals((1 + 2), 3)
self.assertEquals(0 + 1, 1)

def test_T3(self):
self.assertEquals((0 * 10), 0)
self.assertEquals((5 * 8), 40)

# the output is better. prints each test and ok or fail
suite = unittest.TestLoader().loadTestsFromTestCase(T1TestCase)
unittest.TextTestRunner(verbosity=2).run(suite) # }}}


''' halp!

the first test ain't loading...

python blaht.py
test_T2 (__main__.T1TestCase) ... ok
test_T3 (__main__.T1TestCase) ... ok

--
Ran 2 tests in 0.000s

OK

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


Re: Picking a license

2010-05-10 Thread Paul Boddie
On 10 Mai, 08:31, Carl Banks  wrote:
> On May 9, 10:08 am, Paul Boddie  wrote:
> > Oh sure: the GPL hurts everyone, like all the companies who have made
> > quite a lot of money out of effectively making Linux the new
> > enterprise successor to Unix, plus all the companies and individuals
> > who have taken the sources and rolled their own distributions.
>
> Relative to what they could have done with a more permissive license?

Well, yes. Some people would have it that the only reason why BSD
variants never became as popular as Linux (or rather, GNU/Linux, but
lets keep this focused) is because the litigation around the BSD code
base "scared people away". Yet I remember rather well back in the
mid-1990s when people using the same proprietary-and-doomed platform
as myself started looking into Unix-flavoured operating systems, and a
group of people deliberately chose NetBSD because of the favourable
licensing conditions and because there was a portability headstart
over Linux, which at the time people seriously believed was rather non-
portable. So, that "scary AT&T" myth can be sunk, at least when
considering its impact on what people were doing in 1994. Although the
NetBSD port in question lives on, and maybe the people responsible all
took jobs in large companies, its success on that platform and its
derivatives has been dwarfed by that of the corresponding Linux port.

> Yes.  GPL hurts everyone relative to licenses that don't drive wedges
> and prevent interoperability between software.

I can think of another case, actually connected to the above
proprietary platform and its practitioners, where software licensing
stood in the way of "just getting on with business" which is what you
seem to be advocating: a company released their application under the
GPL, except for one critical library which remained proprietary
software. Now, although you can argue that everyone's life would be
richer had the GPL not prohibited "interoperability" (although I
imagine that the application's licensing actually employed an
exception to glue everything together in that particular case), a
community never formed because people probably assumed that their role
would only ever be about tidying up someone else's code so that the
original authors could profit from it.

All the GPL is designed to do in such cases is to encourage people to
seek control (in terms of the "four freedoms") of all the technology,
rather than be placated by the occasional airdrop of proprietary
software and to be convinced never to explore the possibility of
developing something similar for themselves. The beneficiary of the
refusal to work on the above application was the GPL-licensed
Inkscape, which might not be as well-liked by many people, but it does
demonstrate, firstly, that permissive licences do not have the
monopoly on encouraging people to work on stuff, and secondly, that
actually going and improving something else is the answer if you don't
like the licensing of something.

> You might argue that GPL is sometimes better than proprietary closed
> source, and I won't disagree, but it's nearly always worse than other
> open source licenses.

For me, I would argue that the GPL is always better than "proprietary
closed source", recalling that the consideration is that of licensing
and not mixing in other concerns like whether a particular program is
technically better. In ensuring that an end-user gets some code and
can break out those "four freedoms" on it, it is clearly not "worse
than other open source licenses", and I don't accept that this is some
rare thing that only happens outside a theoretical setting on an
occasional basis.

> > P.S. And the GPL isn't meant to further the cause of open source: it's
> > meant to further the Free Software cause, which is not at all the same
> > thing.
>
> It doesn't matter what the GPL "meant" to do, it matters what it does,
> which is hurt everyone (relative to almost all other licenses).

This is your opinion, not objectively established fact.

> > Before you ridicule other people's positions, at least get your
> > terminology right.
>
> I don't agree with FSF's defintion of free software and refuse to
> abide by it.  GPL isn't free software; any software that tells me I
> can't compile it in with a closed source API isn't free.  Period.

Well, if you can't (or can't be bothered) to distinguish between what
is known as Free Software and "open source", then I'm hardly surprised
that you take offence at people releasing software for one set of
reasons while you only consider another set of reasons to be valid
ones. Throughout this discussion I've been accused of not being able
to put myself in the position of the other side, but I completely
understand that people just want as much publicly available software
as possible to be permissively licensed, frequently for the reason
that it will "grease the wheels of commerce", that it reduces (but,
contrary to popular belief, does *not* eliminate) the amoun

Upgrade Python 2.6.4 to 2.6.5

2010-05-10 Thread Werner F. Bruhin

Just upgraded on my Windows 7 machine my copy of 2.6.4 to 2.6.5.

However doing sys.version still shows 2.6.4 even so python.exe is dated 
19. March 2010 with a size of 26.624 bytes.


Is this a known issue?  Or did I do something wrong?

If I install to a new folder all is well, but I would have to install 
all my other stuff again (kinterbasdb, matplotlib, sphinx etc etc).


Werner

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


Re: unittest not being run

2010-05-10 Thread Joe Riopel
On Mon, May 10, 2010 at 8:38 AM, John Maclean  wrote:
> hi,
>
> can some one explain why the __first__ test is not being run?

It looks like you defined test_T1 inside of  the tearDown method.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is Python a functional programming language?

2010-05-10 Thread Stefan Behnel

Samuel Williams, 10.05.2010 14:24:

Is Python a functional programming language?


No. Python is a multi-paradigm language. But it does have functions (and 
methods) as first-class objects.




Is this a paradigm that is well supported by both the language syntax
and the general programming APIs?


I'd say so, but it certainly depends on what functional language features 
you desire.




I heard that lambdas were limited to a single expression


... which is a good thing. An expression in Python can do pretty complex 
things already. Not allowing more puts a limit to code readability degradation.




and that other
functional features were slated for removal in Python 3... is this the
case or have I been misinformed?


No such functionality has been removed in Py3, and in fact, several core 
language features were adapted to make functional programming easier and 
more efficient.




Finally, even if Python supports functional features, is this a model
that is used often in client/application code?


From my point of view, yes. But the beauty is that Python is 
multi-paradigm, so you're not restricted to functional language features.


Stefan

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


Re: Is Python a functional programming language?

2010-05-10 Thread Bruno Desthuilliers

Samuel Williams a écrit :

Dear Friends,

Is Python a functional programming language?


Depends on your definition of "functional programming language", but 
well, not really. It's mostly an imperative, object-oriented (but not 
pure-object) language. It has some restricted support for some 
functional idioms but trying to use it a true FPL would be a waste of 
time (both developper's and computer's).



Is this a paradigm that is well supported by both the language syntax and the 
general programming APIs?


No.


I heard that lambdas were limited to a single expression,


True.


and that other functional features were slated for removal in Python 3...


False.

Some FP-inspired functions and types are moving from builtins to a 
dedicated module, but they are still available.



is this the case or have I been misinformed?

Finally, even if Python supports functional features, is this a model that is 
used often in client/application code?


Once again, depends on your definitions of what's "functional". Some 
FP-inspired idioms and features are definitly idiomatic, but that 
doesn't make for true functional programming. Once again, trying to do 
pure FP in Python would be fighting against the language.




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


Re: unable to get Hudson to run unit tests

2010-05-10 Thread j vickroy

Stefan Behnel wrote:

j vickroy, 07.05.2010 20:44:

I apologize if this is not the appropriate forum for a question about
Hudson (http://hudson-ci.org/), but I did not know where else to ask and
my web searches have not been fruitful.


Certainly nice to read something about Hudson in this forum, which is 
rare enough. It's seriously the greatest CI tool I've ever used, and it 
works great with Python apps.




"C:\Python26\Scripts\nosetests.exe --with-xunit --verbose"

in the *Execute Python Script* subsection.


The problem is that this isn't a "Python Script". I's a an executable, 
native program. Use the "execute shell" build step instead.


Stefan


Thanks for your reply, Stefan.

When the above command

"C:\Python26\Scripts\nosetests.exe --with-xunit --verbose"

is moved to the "Execute shell" section of the job configuration page 
along with the following "tracer" command:


#!python.exe
print 'FOOO'

their is still no indication the unit tests are run.

Here is the output from the Hudson Console Output page

---
Started by user anonymous
Updating svn://vm-svn/GOES data processing/trunk/GOES/13,14,15/SXI/level-1
At revision 3401
no change for svn://vm-svn/GOES data 
processing/trunk/GOES/13,14,15/SXI/level-1 since the previous build
[workspace] $ python.exe 
C:\DOCUME~1\JIM~1.VIC\LOCALS~1\Temp\hudson2011616575490005324.sh

FOOO
[workspace] $ cmd.exe -xe 
C:\DOCUME~1\JIM~1.VIC\LOCALS~1\Temp\hudson902246697107326581.sh

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\jim.vickroy\.hudson\jobs\GOES 13-15 SXI 
Level-1 Products Generation\workspace>Recording test results

Test reports were found but none of them are new. Did tests run?
For example, C:\Documents and Settings\jim.vickroy\.hudson\jobs\GOES 
13-15 SXI Level-1 Products Generation\workspace\level-1\nosetests.xml is 
2 days 19 hr old


Finished: FAILURE
---

As a side note, my Hudson "global" configuration page contains:

cmd.exe

in the "Shell executable" section and

NOSEDIR
C:\Python26\Scripts

in the "Global properties" section.

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


Re: unable to get Hudson to run unit tests

2010-05-10 Thread j vickroy

Jean-Michel Pichavant wrote:

Stefan Behnel wrote:

j vickroy, 07.05.2010 20:44:

I apologize if this is not the appropriate forum for a question about
Hudson (http://hudson-ci.org/), but I did not know where else to ask and
my web searches have not been fruitful.


Certainly nice to read something about Hudson in this forum, which is 
rare enough. It's seriously the greatest CI tool I've ever used, and 
it works great with Python apps.


We use it, but this is a python list that's why there's few topics about 
it. :)
Speaking for myself,  I use it to execute the linter (pylint) on the 
code and run unitary tests. Great tool for sure.


JM



Is there a more appropriate forum to ass about Python and Hudson?  -- jv
--
http://mail.python.org/mailman/listinfo/python-list


Re: unittest not being run

2010-05-10 Thread J. Cliff Dyer
My guess is you mixed tabs and spaces.  One tab is always treated by the
python interpreter as being equal to eight spaces, which is two
indentation levels in your code.

Though if it were exactly as you show it, you'd be getting a syntax
error, because even there, it looks like the indentation of your `def
test_T1(self):` line is off by one column, relative to pass, and by
three columns relative to the other methods.

Cheers,
Cliff
 

On Mon, 2010-05-10 at 13:38 +0100, John Maclean wrote:
> hi,
> 
> can some one explain why the __first__ test is not being run?
> 
> #!/usr/bin/env python
> import unittest # {{{
> class T1TestCase(unittest.TestCase):
> 
>  def setUp(self):
>  pass  # can we use global variables here?
> 
>  def tearDown(self):
>  pass  # garbage collection
> 
>   def test_T1(self):
>   '''this test aint loading'''
>   self.assertEquals(1, 0)
> 
>  def test_T2(self):  ## test method names begin 'test*'
>  self.assertEquals((1 + 2), 3)
>  self.assertEquals(0 + 1, 1)
> 
>  def test_T3(self):
>  self.assertEquals((0 * 10), 0)
>  self.assertEquals((5 * 8), 40)
> 
> # the output is better. prints each test and ok or fail
> suite = unittest.TestLoader().loadTestsFromTestCase(T1TestCase)
> unittest.TextTestRunner(verbosity=2).run(suite) # }}}
> 
> 
> ''' halp!
> 
> the first test ain't loading...
> 
> python blaht.py
> test_T2 (__main__.T1TestCase) ... ok
> test_T3 (__main__.T1TestCase) ... ok
> 
> --
> Ran 2 tests in 0.000s
> 
> OK
> 
> '''



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


HTTP Post Request

2010-05-10 Thread [email protected]
Hi to all, i want to ask you a question, concerning the best way to do
the following as a POST request:
There is server-servlet that accepts xml commands
It had the following HTTP request headers:

Host: somehost.com
User-Agent: Jakarta Commons-HttpClient
Content-Type: text/xml
Content-Length: 415

and the following request body (reformatted here for clarity):



  search

How can i send the above to the Listener Servlet?
Thanks in advance
-- 
http://mail.python.org/mailman/listinfo/python-list


INCREF DECREF manually

2010-05-10 Thread moerchendiser2k3
Hi,

just a small question. Is it possible to change the refcount of a
reference manually? For debugging / ...

Thanks!

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


Re: INCREF DECREF manually

2010-05-10 Thread Jean-Michel Pichavant

moerchendiser2k3 wrote:

Hi,

just a small question. Is it possible to change the refcount of a
reference manually? For debugging / ...

Thanks!

moerchendiser2k3
  
Why don't you just create a global reference to the object ? Unless this 
one is removed, the object will be kept in memory.


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


Re: unittest not being run

2010-05-10 Thread John Maclean

On 10/05/2010 14:38, J. Cliff Dyer wrote:

My guess is you mixed tabs and spaces.  One tab is always treated by the
python interpreter as being equal to eight spaces, which is two
indentation levels in your code.

Though if it were exactly as you show it, you'd be getting a syntax
error, because even there, it looks like the indentation of your `def
test_T1(self):` line is off by one column, relative to pass, and by
three columns relative to the other methods.

Cheers,
Cliff


'twas a spaces/indent issue. thanks!



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


Re: HTTP Post Request

2010-05-10 Thread Kushal Kumaran
On Mon, May 10, 2010 at 7:30 PM, [email protected]  wrote:
> Hi to all, i want to ask you a question, concerning the best way to do
> the following as a POST request:
> There is server-servlet that accepts xml commands
> It had the following HTTP request headers:
>
>            Host: somehost.com
>            User-Agent: Jakarta Commons-HttpClient
>            Content-Type: text/xml
>            Content-Length: 415
>
> and the following request body (reformatted here for clarity):
>
>            
>            
>              search
>            
> How can i send the above to the Listener Servlet?
> Thanks in advance

Use the xmlrpclib module.

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


Re: unable to get Hudson to run unit tests

2010-05-10 Thread Jean-Michel Pichavant

j vickroy wrote:

Stefan Behnel wrote:

j vickroy, 07.05.2010 20:44:

I apologize if this is not the appropriate forum for a question about
Hudson (http://hudson-ci.org/), but I did not know where else to ask 
and

my web searches have not been fruitful.


Certainly nice to read something about Hudson in this forum, which is 
rare enough. It's seriously the greatest CI tool I've ever used, and 
it works great with Python apps.




"C:\Python26\Scripts\nosetests.exe --with-xunit --verbose"

in the *Execute Python Script* subsection.


The problem is that this isn't a "Python Script". I's a an 
executable, native program. Use the "execute shell" build step instead.


Stefan


Thanks for your reply, Stefan.

When the above command

"C:\Python26\Scripts\nosetests.exe --with-xunit --verbose"

is moved to the "Execute shell" section of the job configuration page 
along with the following "tracer" command:


#!python.exe
print 'FOOO'

their is still no indication the unit tests are run.

Here is the output from the Hudson Console Output page

---
Started by user anonymous
Updating svn://vm-svn/GOES data 
processing/trunk/GOES/13,14,15/SXI/level-1

At revision 3401
no change for svn://vm-svn/GOES data 
processing/trunk/GOES/13,14,15/SXI/level-1 since the previous build
[workspace] $ python.exe 
C:\DOCUME~1\JIM~1.VIC\LOCALS~1\Temp\hudson2011616575490005324.sh

FOOO
[workspace] $ cmd.exe -xe 
C:\DOCUME~1\JIM~1.VIC\LOCALS~1\Temp\hudson902246697107326581.sh

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\jim.vickroy\.hudson\jobs\GOES 13-15 SXI 
Level-1 Products Generation\workspace>Recording test results

Test reports were found but none of them are new. Did tests run?
For example, C:\Documents and Settings\jim.vickroy\.hudson\jobs\GOES 
13-15 SXI Level-1 Products Generation\workspace\level-1\nosetests.xml 
is 2 days 19 hr old


Finished: FAILURE
---

As a side note, my Hudson "global" configuration page contains:

cmd.exe

in the "Shell executable" section and

NOSEDIR
C:\Python26\Scripts

in the "Global properties" section.

-- jv
Maybe something is missing on the machine hosting hudson, did you try to 
execute nosetests.exe on that machine ?
I'm also confused with something, you do not provide nosetests with the 
location of your package, assuming the current directory contains that 
package (my guess).
Instead of printing 'FOOO', try "import os ; print os.getcwd(); print 
os.listdir(os.getcwd())" to know where you are exactly and if this dir 
contains your python package.


JM


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


Re: INCREF DECREF manually

2010-05-10 Thread moerchendiser2k3

Do to some debugging if a version contains a bug and needs to be fixed
there manually.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: HTTP Post Request

2010-05-10 Thread [email protected]
On May 10, 10:22 am, Kushal Kumaran 
wrote:
> On Mon, May 10, 2010 at 7:30 PM, [email protected]  wrote:
> > Hi to all, i want to ask you a question, concerning the best way to do
> > the following as a POST request:
> > There is server-servlet that accepts xml commands
> > It had the following HTTP request headers:
>
> >            Host: somehost.com
> >            User-Agent: Jakarta Commons-HttpClient
> >            Content-Type: text/xml
> >            Content-Length: 415
>
> > and the following request body (reformatted here for clarity):
>
> >            
> >            
> >              search
> >            
> > How can i send the above to the Listener Servlet?
> > Thanks in advance
>
> Use the xmlrpclib module.
>
> --
> regards,
> kushal

OK, sending headers with xmlrpclib,
but how do i send the XML message?

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


Re: Picking a license

2010-05-10 Thread Patrick Maupin
On May 10, 6:01 am, Paul Boddie  wrote:
> On 10 Mai, 03:09, Patrick Maupin  wrote:
>
> > On May 9, 6:39 pm, Paul Boddie  wrote:
> > > but if they aren't pitching it directly at you, why would you believe
> > > that they are trying to change your behaviour?
>
> > Because I've seen people specifically state that their purpose in
> > GPLing small libraries is to encourage other people to change their
> > behavior.  I take those statements at face value.  Certainly RMS
> > carefully lays out that the LGPL should be used sparingly in his "Why
> > you shouldn't use the Lesser GPL for your next library" post.  (Hint:
> > he's not suggesting a permissive license instead.)
>
> Sure, but all he's asking you to do is to make the software available
> under a GPL-compatible licence.

I'll be charitable and assume the fact that you can make that
statement without apparent guile merely means that you haven't read
the post I was referring to:

http://www.gnu.org/philosophy/why-not-lgpl.html

> [...]
>
> > rst2pdf was licensed under the MIT license before I started
> > contributing to it, and there is no way I was going to even consider
> > adding patches for a GPLed package (which would certainly have to be
> > GPLed) into the rst2pdf repository.  (Say what you will about how
> > sometimes differently licensed code can be combined, but RMS has to
> > share quite a bit of the blame/credit for the whole combining licenses
> > FUD.)
>
> I think the FSF are quite clear about combining licences - they even
> go to the trouble of telling you which ones are compatible with the
> GPL

Yes, but one of the things they are quite clear on is that the overall
work must be licensed as GPL, if any of the components are licensed as
GPL.  They claim this is true, even if a non-GPL work dynamically
links to a GPL work.

 - so I don't see where "FUD" comes into it, apart from possible
> corner cases where people are trying to circumvent the terms of a
> licence and probably know themselves that what they're trying to do is
> at the very least against the spirit of the licence.

Legally, I don't think they can dictate the license terms of, e.g.
clisp just because it can link to readline.  But practically, they DID
manage to do this, simply because Bruno Haible, the clisp author, was
more concerned about writing software than spending too much time
sparring with Stallman over the license, so he finally licensed clisp
under the gpl.  clisp *could* use readline, but didn't require it;
nonetheless Stallman argued that clisp was a "derivative" of
readline.  That case of the tail wagging the dog would be laughable if
it hadn't worked.  In any case, Stallman's success at that tactic is
probably one of the things that led him to write the paper on why you
should use GPL for your library.  (As an aside, since rst2pdf *can*
use GPL-licensed svglib, it could possibly be subject to the same kind
of political pressure as clisp.  But the fact that more people are
better informed now and that the internet would publicize the dispute
more widely more quickly means that this is a battle Stallman is
unlikely to wage at this point, because if the leader of any such
targeted project has enough cojones, the FSF's inevitable loss would
reduce some of the FUD dramatically.)

> Even then,
> warning people about their little project to make proprietary plugins,
> or whatever, is not really "FUD".

I think that, legally, they probably don't have a leg to stand on for
some of their overarching claims (e.g. about shipping proprietary
software that could link to readline, without even shipping
readline).  But morally -- well, they've made their position
reasonably clear and I try to abide by it.  That still doesn't make it
"not really FUD."  I'd call this sort of badgering "copyright misuse"
myself.

> As for rst2pdf, what your modifications would mean is that the
> software would need to be redistributed under a GPL-compatible
> licence.

That's parsing semantics rather finely.  In practice, what it really
means is that the combination (e.g. the whole program) would
effectively be GPL-licensed.  This then means that downstream users
would have to double-check that they are not combining the whole work
with licenses which are GPL-incompatible, even if they are not using
the svg feature.  Hence, the term "viral."

> I'll accept that this does affect what people can then do
> with the project, but once again, you've mentioned at least one LGPL-
> licensed project which was previously in this very situation, and it
> was never actually GPL-licensed itself. Here's the relevant FAQ entry:
>
> http://www.gnu.org/licenses/gpl-faq.html#LinkingWithGPL

Yes, I've read that, but this is much more informative:

http://www.gnu.org/licenses/gpl-faq.html#GPLInProprietarySystem

"A system incorporating a GPL-covered program is an extended version
of that program. The GPL says that any extended version of the program
must be released under the GPL if it is released at all."

This makes 

Re: Picking a license

2010-05-10 Thread Aahz
In article <074b412a-c2f4-4090-a52c-4d69edb29...@d39g2000yqa.googlegroups.com>,
Paul Boddie   wrote:
>
>Actually, the copyleft licences don't "force" anyone to "give back
>changes": they oblige people to pass on changes.

IMO, that's a distinction without a difference, particularly if you
define "give back" as referring to the community rather than the original
project.  With the FSF itself using "pressure" in the FAQ entry you
linked to, I have no clue why you and Ben Finney object to my use of
"force".
-- 
Aahz ([email protected])   <*> http://www.pythoncraft.com/

f u cn rd ths, u cn gt a gd jb n nx prgrmmng.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: INCREF DECREF manually

2010-05-10 Thread Antoine Pitrou
On Mon, 10 May 2010 07:26:42 -0700 (PDT)
moerchendiser2k3  wrote:
> 
> Do to some debugging if a version contains a bug and needs to be fixed
> there manually.

This is certainly the wrong approach.
To know if your Python code is leaking references, use either
sys.getrefcount(), or (better) a weakref -- and don't forget to
call gc.collect().
To know if some C extension is buggy, use your C debugger (or your
favourite alternative debugging method, such as printf()).

Changing reference counts from Python will lead to two possible
consequences:
- if you increment a reference count, you will have a permanent memory
  leak
- if you decrement a reference count, you will eventually crash the
  interpreter


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


Wholesale Sports Shoes Clear Air Force One AAA++quality(www.cnnshoe.com)

2010-05-10 Thread xiao wu


supply sports shoes. The brand Sports shoes basketball shoes, Boot,
walling shoes, Athletic shoes, Jogging shoes, running shoes, leather
shoes, football, shoe sports shoe Footwear Sneaker, Shox Max Rift T-
shirts, womens t-shirts, Clothing womens clothing, wear hats Caps
Jersey jeans Sock Jacks, Watches, wallet, handbags, and Jeans Lady
Clothing and so on. Please contact us by email to get more
information. please kindly visite our website: http://www.cnnshoe.com
msn: [email protected]
email: [email protected]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Picking a license

2010-05-10 Thread Aahz
[we have previously been using "MIT-style" and "BSD-style" licensing in
this thread for the most part -- given the poster who suggested that
Apache makes more sense these days, I'm switching to that terminology]

In article <[email protected]>,
Carl Banks   wrote:
>
>You might argue that GPL is sometimes better than proprietary closed
>source, and I won't disagree, but it's nearly always worse than other
>open source licenses.

That I completely disagree with.  I'm not going to bother making
arguments (Paul Boddie et al has done a much better job than I could),
but I wanted to register my disagreement as someone who generally prefers
Apache-style licenses.  I will just add that I believe that Apache-style
licensing could not work in the absence of GPL software.  IOW, I believe
that GPL confers a form of herd immunity to Open Source in general, and
Stallman gets full credit for creating the idea of GPL to protect Open
Source.

I believe that Stallman understands this perfectly well and it in part
represents why he is so opposed to non-GPL licensing; it makes sense that
he feels some resentment toward the "freeloading" from the rest of the
Open Source community.  OTOH, I also believe that having only GPL would
destroy Open Source as a viable development environment and community;
it's too restrictive for some very valuable projects (including Python in
specific, to bring this back on topic).

Each project needs to think carefully about its relationship to the Open
Source ecosystem and community before deciding on a license.  But for
small projects trying to get users, defaulting to Apache makes sense.
-- 
Aahz ([email protected])   <*> http://www.pythoncraft.com/

f u cn rd ths, u cn gt a gd jb n nx prgrmmng.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: unable to get Hudson to run unit tests

2010-05-10 Thread j vickroy

Jean-Michel Pichavant wrote:

j vickroy wrote:

Stefan Behnel wrote:

j vickroy, 07.05.2010 20:44:

I apologize if this is not the appropriate forum for a question about
Hudson (http://hudson-ci.org/), but I did not know where else to ask 
and

my web searches have not been fruitful.


Certainly nice to read something about Hudson in this forum, which is 
rare enough. It's seriously the greatest CI tool I've ever used, and 
it works great with Python apps.




"C:\Python26\Scripts\nosetests.exe --with-xunit --verbose"

in the *Execute Python Script* subsection.


The problem is that this isn't a "Python Script". I's a an 
executable, native program. Use the "execute shell" build step instead.


Stefan


Thanks for your reply, Stefan.

When the above command

"C:\Python26\Scripts\nosetests.exe --with-xunit --verbose"

is moved to the "Execute shell" section of the job configuration page 
along with the following "tracer" command:


#!python.exe
print 'FOOO'

their is still no indication the unit tests are run.

Here is the output from the Hudson Console Output page

---
Started by user anonymous
Updating svn://vm-svn/GOES data 
processing/trunk/GOES/13,14,15/SXI/level-1

At revision 3401
no change for svn://vm-svn/GOES data 
processing/trunk/GOES/13,14,15/SXI/level-1 since the previous build
[workspace] $ python.exe 
C:\DOCUME~1\JIM~1.VIC\LOCALS~1\Temp\hudson2011616575490005324.sh

FOOO
[workspace] $ cmd.exe -xe 
C:\DOCUME~1\JIM~1.VIC\LOCALS~1\Temp\hudson902246697107326581.sh

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\jim.vickroy\.hudson\jobs\GOES 13-15 SXI 
Level-1 Products Generation\workspace>Recording test results

Test reports were found but none of them are new. Did tests run?
For example, C:\Documents and Settings\jim.vickroy\.hudson\jobs\GOES 
13-15 SXI Level-1 Products Generation\workspace\level-1\nosetests.xml 
is 2 days 19 hr old


Finished: FAILURE
---

As a side note, my Hudson "global" configuration page contains:

cmd.exe

in the "Shell executable" section and

NOSEDIR
C:\Python26\Scripts

in the "Global properties" section.

-- jv
Maybe something is missing on the machine hosting hudson, did you try to 
execute nosetests.exe on that machine ?


Hudson is running on my workstation (which also has python and nose 
installed).


I'm also confused with something, you do not provide nosetests with the 
location of your package, assuming the current directory contains that 
package (my guess).


That is correct but see below ...

Instead of printing 'FOOO', try "import os ; print os.getcwd(); print 
os.listdir(os.getcwd())" to know where you are exactly and if this dir 
contains your python package.


great suggestion !

This showed the current working directory to be one level above where I 
expected so that was definitely a problem so I changed my nose command, 
in the Hudson Job configuration Execute shell box, to be


nosetests.exe --where=level-1 --with-xunit --verbose

and saved the configuration change.

This works as expected when run from a command shell in the Hudson 
current working directory for this Hudson job.


Unfortunately, when "Hudson Build now" is performed, the Hudson Console 
output, for this job, is:



Started by user anonymous
Updating svn://vm-svn/GOES data processing/trunk/GOES/13,14,15/SXI/level-1
At revision 3403
no change for svn://vm-svn/GOES data 
processing/trunk/GOES/13,14,15/SXI/level-1 since the previous build
[workspace] $ python.exe 
C:\DOCUME~1\JIM~1.VIC\LOCALS~1\Temp\hudson5273111667332806239.sh
os.getcwd(): C:\Documents and Settings\jim.vickroy\.hudson\jobs\GOES 
13-15 SXI Level-1 Products Generation\workspace

os.listdir(os.getcwd()): ['level-1']
[workspace] $ cmd.exe -xe 
C:\DOCUME~1\JIM~1.VIC\LOCALS~1\Temp\hudson991194264891924641.sh

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\jim.vickroy\.hudson\jobs\GOES 13-15 SXI 
Level-1 Products Generation\workspace>Recording test results

No test report files were found. Configuration error?
Finished: FAILURE


The second [workspace] section output (above) looks like cmd.exe is 
being executed with no parameters (i.e., without the

"nosetests.exe --where=level-1 --with-xunit --verbose") parameter.

Thanks for thinking about this; I realize how difficult it is to 
remotely troubleshoot a problem like this.


-- jv



JM




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


Re: Sphinx hosting

2010-05-10 Thread Michele Simionato
On May 5, 8:00 am, James Mills  wrote:
> On Wed, May 5, 2010 at 3:35 PM, Michele Simionato
>
>  wrote:
> > I am sure it has, but I was talking about just putting in the
> > repository an index.html file and have it published, the wayI hear  it
> > works in BitBucket and GitHub.
>
> I'm pretty sure Google Code Hosting doesn't support
> rendering text/html mime-type files in the repository (like Trac can).

At the end I discovered that if you put HTML files into a Googlecode
repository and you click on "display raw file" it just works (TM). So
my problem was already solved and I my worries were unjustified. I
have just committed my talk at the Italian PyCon and all the
stylesheets are recognized just fine: 
http://micheles.googlecode.com/hg/pypers/pycon10/talk.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Extract all words that begin with x

2010-05-10 Thread Aahz
In article ,
James Mills   wrote:
>On Mon, May 10, 2010 at 6:50 PM, Xavier Ho  wrote:
>> Have I missed something, or wouldn't this work just as well:
>>
> list_of_strings = ['2', 'awes', '3465sdg', 'dbsdf', 'asdgas']
> [word for word in list_of_strings if word[0] == 'a']
>> ['awes', 'asdgas']
>
>I would do this for completeness (just in case):
>
> [word for word in list_of_strings if word and word[0] == 'a']
>
>Just guards against empty strings which may or may not be in the list.

No need to do that with startswith():

>>> ''.startswith('x')
False

You would only need to use your code if you suspected that some elements
might be None.
-- 
Aahz ([email protected])   <*> http://www.pythoncraft.com/

f u cn rd ths, u cn gt a gd jb n nx prgrmmng.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Picking a license

2010-05-10 Thread Paul Boddie
On 10 Mai, 17:06, [email protected] (Aahz) wrote:
> In article 
> <074b412a-c2f4-4090-a52c-4d69edb29...@d39g2000yqa.googlegroups.com>,
> Paul Boddie   wrote:
> >Actually, the copyleft licences don't "force" anyone to "give back
> >changes": they oblige people to pass on changes.
>
> IMO, that's a distinction without a difference, particularly if you
> define "give back" as referring to the community rather than the original
> project.

There is a difference: I know of at least one vendor of GPL-licensed
solutions who received repeated requests that they make their sources
available to all-comers, even though the only obligation is to those
receiving the software in the first place. Yes, the code can then
become public - if Red Hat decided to only release sources to their
customers, and those customers shared the sources publicly, then
CentOS would still be around as a Red Hat "clone" - but there are
situations where recipients of GPL-licensed code may decide that it is
in their best interests not to just upload it to the public Internet.

>  With the FSF itself using "pressure" in the FAQ entry you
> linked to, I have no clue why you and Ben Finney object to my use of
> "force".

Because no-one is being forced to do anything. Claiming that "force"
is involved is like hearing a schoolboy saying, "I really wanted that
chocolate, but why is that man forcing me to pay for it?" Well, you
only have to pay for it if you decide you want to take it - that's the
only reasonable response.

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


Re: Is Python a functional programming language?

2010-05-10 Thread Paul Rubin
Samuel Williams  writes:
> Is Python a functional programming language?

It supports some aspects of functional programming but I wouldn't go as
far as to call it an FPL.  

> Is this a paradigm that is well supported by both the language syntax
> and the general programming APIs?

I'd say "somewhat supported" rather than "well supported".

> I heard that lambdas were limited to a single expression, and that
> other functional features were slated for removal in Python 3... is
> this the case or have I been misinformed?

I think, some features were slated for removal, but after some
discussion they were moved to libraries instead of eliminated
completely.

> Finally, even if Python supports functional features, is this a model
> that is used often in client/application code?

That's more a question of the programmers than the programs.  If you're
comfortable programming in functional style, that will tend to show
up in your python code.  There are some contortions you have to do though.

If your goal is to engage in functional programming, you're better off
using a language designed for that purpose.  Python is a pragmatic
language from an imperative tradition, that has some functional features
tacked on.  Python is pleasant for imperative programming while letting
you make some use of functional style.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is Python a functional programming language?

2010-05-10 Thread Aahz
In article <[email protected]>,
Paul Rubin   wrote:
>
>If your goal is to engage in functional programming, you're better off
>using a language designed for that purpose.  Python is a pragmatic
>language from an imperative tradition, that has some functional features
>tacked on.  

While your first sentence is spot-on, saying that functional features
are "tacked on" understates the case.  Consider how frequently people
reach for list comps and gen exps.  Function dispatch through dicts is
the standard replacement for a switch statement.  Lambda callbacks are
common.  Etc, etc, etc
-- 
Aahz ([email protected])   <*> http://www.pythoncraft.com/

f u cn rd ths, u cn gt a gd jb n nx prgrmmng.
-- 
http://mail.python.org/mailman/listinfo/python-list


Turbogears 2 training this weekend in Washington, DC USA

2010-05-10 Thread Alex Clark
Hi all,

Sorry for the short notice.

We (the Zope/Python Users Group of DC) are having a 
TurboGears 2 training class this weekend in Washington, DC USA
taught by core developer Chris Perkins.

Please consider attending! And, I would appreciate you spreading the
word to anyone you think may be interested as well.

Details are here:

http://www.meetup.com/python-meetup-dc/messages/10123013/

And here is a taste:

---

The DC Python Meetup is pleased to present Turbogears 2 training, 
delivered by Turbogears core developer Christopher Perkins. You can 
register now at http://tg2-class.eventbrite.com/

Turbogears is a modern python web framework with a powerful ORM 
(the one and only SQLAlchemy), designer friendly templates, and a 
widget system that simplifies Ajax development. If you're a web 
developer interested in expanding your toolkit or a python developer 
who wants to dabble in the web space, this training is an excellent 
opportunity to learn an agile and mature web framework.

The training itself will be wonderfully practical, taking you from 
basic setup to a real application over the course of a day. You're 
invited to bring your own data, so that you can work with Chris to 
start migrating that legacy PHP app you have sitting around to 
Python beauty. This hands-on training aims to bring students up to 
speed with TurboGears 2, its administration interface, and touch 
common deployment scenarios. Students will also get to customize 
auto generated forms and tables.

---

I hope to see you there!

Alex, http://zpugdc.org


-- 
Alex Clark · http://aclark.net
Author of Plone 3.3 Site Administration · http://aclark.net/plone-site-admin

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


Re: Picking a license

2010-05-10 Thread Patrick Maupin
On May 10, 12:37 pm, Paul Boddie  wrote:
> On 10 Mai, 17:06, [email protected] (Aahz) wrote:
>
> > In article 
> > <074b412a-c2f4-4090-a52c-4d69edb29...@d39g2000yqa.googlegroups.com>,
> > Paul Boddie   wrote:
> > >Actually, the copyleft licences don't "force" anyone to "give back
> > >changes": they oblige people to pass on changes.
>
> > IMO, that's a distinction without a difference, particularly if you
> > define "give back" as referring to the community rather than the original
> > project.
>
> There is a difference: I know of at least one vendor of GPL-licensed
> solutions who received repeated requests that they make their sources
> available to all-comers, even though the only obligation is to those
> receiving the software in the first place. Yes, the code can then
> become public - if Red Hat decided to only release sources to their
> customers, and those customers shared the sources publicly, then
> CentOS would still be around as a Red Hat "clone" - but there are
> situations where recipients of GPL-licensed code may decide that it is
> in their best interests not to just upload it to the public Internet.
>
> >  With the FSF itself using "pressure" in the FAQ entry you
> > linked to, I have no clue why you and Ben Finney object to my use of
> > "force".
>
> Because no-one is being forced to do anything. Claiming that "force"
> is involved is like hearing a schoolboy saying, "I really wanted that
> chocolate, but why is that man forcing me to pay for it?" Well, you
> only have to pay for it if you decide you want to take it - that's the
> only reasonable response.

I've addressed this before.  Aahz used a word in an accurate, but to
you, inflammatory, sense, but it's still accurate -- the man *would*
force you to pay for the chocolate if you took it.  You're making it
sound like whining, but Aahz was simply trying to state a fact.  The
fact is, I know the man would force me to pay for the chocolate, so in
some cases that enters into the equation and keeps me from wanting the
chocolate.  This isn't whining; just a common-sense description of
reality.  Personally, I think this use of the word "force" is much
less inflammatory than the deliberate act of co-opting the word
"freedom" to mean "if you think you can take this software and do
anything you want with it, you're going to find out differently when
we sue you."

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


Re: Is Python a functional programming language?

2010-05-10 Thread Nobody
On Tue, 11 May 2010 00:24:22 +1200, Samuel Williams wrote:

> Is Python a functional programming language?

Not in any meaningful sense of the term.

> Is this a paradigm that is well supported by both the language syntax and
> the general programming APIs?

No.

> I heard that lambdas were limited to a single expression,

Yes. In a functional language that wouldn't be a problem, as there's no
limit to the complexity of an expression. Python's expressions are far
more limited, which restricts what can be done with a lambda.

> and that other
> functional features were slated for removal in Python 3... is this the
> case or have I been misinformed?

I don't know about this.

> Finally, even if Python supports functional features, is this a model that
> is used often in client/application code?

Not really. List comprehensions are probably the most common example of
functional idioms, but again they're limited by Python's rather limited
concept of an expression.

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


Hex String

2010-05-10 Thread Anthony Cole
How can I concatenate 2 hex strings (e.g. '\x16' and '\xb9') then convert 
the answer to an integer?

When I try i always end up with the ASCII equivalent!

Thanks,
Anthony 


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


How to measure speed improvements across revisions over time?

2010-05-10 Thread Matthew Wilson
I know how to use timeit and/or profile to measure the current run-time
cost of some code.

I want to record the time used by some original implementation, then
after I rewrite it, I want to find out if I made stuff faster or slower,
and by how much.

Other than me writing down numbers on a piece of paper on my desk, does
some tool that does this already exist?

If it doesn't exist, how should I build it?

Matt

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


Re: Hex String

2010-05-10 Thread Chris Rebert
On Mon, May 10, 2010 at 12:55 PM, Anthony Cole  wrote:
> How can I concatenate 2 hex strings (e.g. '\x16' and '\xb9') then convert
> the answer to an integer?
>
> When I try i always end up with the ASCII equivalent!

I think you want the `struct` module:
struct — Interpret strings as packed binary data
http://docs.python.org/library/struct.html

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Hex String

2010-05-10 Thread MRAB

Anthony Cole wrote:
How can I concatenate 2 hex strings (e.g. '\x16' and '\xb9') then convert 
the answer to an integer?


When I try i always end up with the ASCII equivalent!


Those are just bytestrings (assuming you're using Python 2.x), ie
strings using 1 byte per character. You can convert a bytestring to an
integer using the functions in the 'struct' module.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Upgrade Python 2.6.4 to 2.6.5

2010-05-10 Thread Martin v. Loewis
Werner F. Bruhin wrote:
> Just upgraded on my Windows 7 machine my copy of 2.6.4 to 2.6.5.
> 
> However doing sys.version still shows 2.6.4 even so python.exe is dated
> 19. March 2010 with a size of 26.624 bytes.
> 
> Is this a known issue?  Or did I do something wrong?

Look at the copy of python26.dll. This should be the new one; perhaps
you have another copy in the system32 folder?

Did the upgrade inform you that it was an upgrade, or did it warn you
that you would overwrite the previous installation?

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


[Epydoc-devel] How to? epydoc --top=README

2010-05-10 Thread Phlip
Pythonistas:

I have a question to epydoc-devel, but it might be languishing:

http://sourceforge.net/mailarchive/forum.php?thread_name=l2n860c114f1005061707k1ccf68cdz277a3d875b99fe04%40mail.gmail.com&forum_name=epydoc-devel

How do you populate the index.html output with your (insanely clever)
contents of your README file?

When I try the obvious notations, such as --top=README or --
top=README.html, I get:

Warning: Identifier 'README' looks suspicious; using it anyway.
Warning: Could not find top page 'README'; using module-tree.html
instead

And, yes, the README is included in the input list, and yes I get a
script-README-module.html

8<--

The question for the rest of Python-Land: Should I be using a better
documentation extractor? (pydoc is too mundane so far.) Or should I be
using a better forum for epydoc users questions?

--
  yes-I-know-topicality-ly-yrs
  Phlip
  http://c2.com/cgi/wiki?ZeekLand
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Epydoc-devel] How to? epydoc --top=README

2010-05-10 Thread Chris Rebert
On Mon, May 10, 2010 at 1:29 PM, Phlip  wrote:
> Pythonistas:

> The question for the rest of Python-Land: Should I be using a better
> documentation extractor? (pydoc is too mundane so far.)

Sphinx is in vogue right now:
http://sphinx.pocoo.org/

It's used for the official docs and its results are quite pretty.

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to? epydoc --top=README

2010-05-10 Thread Phlip
On May 10, 1:39 pm, Chris Rebert  wrote:

> Sphinx is in vogue right now:http://sphinx.pocoo.org/
>
> It's used for the official docs and its results are quite pretty.

The manager said to hold off on Sphinx until the next phase - then ran
off to get married or something.

But yet I persevere...
-- 
http://mail.python.org/mailman/listinfo/python-list


Problem displaying jpgs in Tkinter via PIL

2010-05-10 Thread Armin

Hi everyone,

I'm new to Python and have been playing around with it using the 
Enthought Python distribution for Mac OS X 10.6.3 (EPD academic 
license, version 6.1 with python 2.6.4).


It's been great learning the basics, but I've started running into 
problems when I'm trying to use the PIL library with Tkinter. All I'm 
trying to do is display a JPG as a Tkinter label:


# code below:
from Tkinter import *
import Image, ImageTk

def main():
   filename = "images/testimg.jpg"
   imgPIL = Image.open(filename)

   root = Tk()
   imgTK = ImageTk.PhotoImage(imgPIL)
   label = Label(root, image=imgTK)
   label.pack()
   root.mainloop()

main()
# end of code

It all works fine when I'm just using GIF images through Tkinter's 
photoimage object, but as soon as I'm trying to convert an image 
through ImageTk, I get the following error:


ImportError: 
dlopen(/Library/Frameworks/Python.framework/Versions/6.1/lib/python2.6/site-packages/PIL/_imagingtk.so, 
2): Library not loaded: /sys...@rpath/Tcl Referenced from: 
/Library/Frameworks/Python.framework/Versions/6.1/lib/python2.6/site-packages/PIL/_imagingtk.so 
Reason: image not found


I have no idea what that means, but I've always assumed the EPD 
includes all the stuff that's needed to make Tkinter work with PIL.

Any advice would be greatly appreciated. Thanks!






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


lame sphinx questions [Was: lame epydoc questions]

2010-05-10 Thread Phlip
On May 10, 1:51 pm, Phlip  wrote:
> On May 10, 1:39 pm, Chris Rebert  wrote:
>
> > Sphinx is in vogue right now:http://sphinx.pocoo.org/

Okay, we have ten thousand classes to document. How to add them all to
index.rst?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: unittest not being run

2010-05-10 Thread cjw

On 10-May-10 10:21 AM, John Maclean wrote:

On 10/05/2010 14:38, J. Cliff Dyer wrote:

My guess is you mixed tabs and spaces. One tab is always treated by the
python interpreter as being equal to eight spaces, which is two
indentation levels in your code.

Though if it were exactly as you show it, you'd be getting a syntax
error, because even there, it looks like the indentation of your `def
test_T1(self):` line is off by one column, relative to pass, and by
three columns relative to the other methods.

Cheers,
Cliff


'twas a spaces/indent issue. thanks!



PyScripter and PythonWin permit the user to choose the equivalence of 
tabs and spaces.  I like two spaces = on tab, it's a matter of taste.  I 
feel that eight spaces is too much.


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


Difference between 'is not' and '!=' ?

2010-05-10 Thread AON LAZIO
As subject says, what is the differences of 'is not' and '!='. Confusing..

-- 
Passion is my style
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Difference between 'is not' and '!=' ?

2010-05-10 Thread Chris Rebert
On Mon, May 10, 2010 at 4:25 PM, AON LAZIO  wrote:
> As subject says, what is the differences of 'is not' and '!='. Confusing..

!= checks value inequality, `is not` checks object identity /
"pointer" inequality
Unless you're doing `foo is not None`, you almost always want !=.

By way of demonstration (using the non-negated versions to be less confusing):
>>> x = [1, 2]
>>> y = [1, 2]
>>> x == y
True
>>> x is y
False
>>> z = x
>>> x is z
True
>>> z is y
False
>>> x.append(3)
>>> x
[1, 2, 3]
>>> y
[1, 2]
>>> z
[1, 2, 3]
>>> x is z
True

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Difference between 'is not' and '!=' ?

2010-05-10 Thread Christian Heimes

AON LAZIO wrote:

As subject says, what is the differences of 'is not' and '!='. Confusing..


"is not" checks if two objects are not identical. "!=" checks if two 
objects are not equal.


Example:
Two apples may be equal in size, form and color but they can never be 
identical because they are made up from different atoms.


Christian

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


Re: unittest not being run

2010-05-10 Thread Joe Riopel
On Mon, May 10, 2010 at 5:17 PM, cjw  wrote:
> PyScripter and PythonWin permit the user to choose the equivalence of tabs
> and spaces.  I like two spaces = on tab, it's a matter of taste.  I feel
> that eight spaces is too much.

While it is a matter of taste,  PEP 8 recommends 4 spaces per indentation level.

http://www.python.org/dev/peps/pep-0008/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is Python a functional programming language?

2010-05-10 Thread Luis M . González
On 10 mayo, 09:24, Samuel Williams 
wrote:
> Dear Friends,
>
> Is Python a functional programming language?
>
> Is this a paradigm that is well supported by both the language syntax and the 
> general programming APIs?
>
> I heard that lambdas were limited to a single expression, and that other 
> functional features were slated for removal in Python 3... is this the case 
> or have I been misinformed?
>
> Finally, even if Python supports functional features, is this a model that is 
> used often in client/application code?
>
> Kind regards,
> Samuel

I'm no expert of functional programming at all, but I read many times
(from famous programmers) that Python is very lisp-like, but with a
more conventional syntax.
For example, Paul Graham and others have some interesting views on
this subject: http://www.prescod.net/python/IsPythonLisp.html

That doesn't mean python can compete with other purely functional
languages, but it's probably as functional as it can be for a more
conventional, multiparadigm language.

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


Re: Picking a license

2010-05-10 Thread Ben Finney
[email protected] (Aahz) writes:

> Paul Boddie   wrote:
> >Actually, the copyleft licences don't "force" anyone to "give back
> >changes": they oblige people to pass on changes.
>
> IMO, that's a distinction without a difference, particularly if you
> define "give back" as referring to the community rather than the
> original project. With the FSF itself using "pressure" in the FAQ
> entry you linked to, I have no clue why you and Ben Finney object to
> my use of "force".

Precisely because there *is* force involved: copyright law is enforced,
ultimately, by police with threats to put you in a box forcibly.

But that force, it must be recognised, comes from the force of law. The
GPL, and all free software licenses, do *not* force anyone to do
anything; exactly the opposite is the case.

Free software licenses grant specific exceptions to the enforcement of
copyright law. They grant freedom to do things that would otherwise be
prevented by force or the threat of force.

This is obvious when you consider what would be the case in the absence
of any free software license: everything that was prohibited is still
prohibited in the absence of the license, and indeed some more things
are now prohibited as well.

Conversely, in the absence of any copyright law (not that I advocate
that situation), copyright licenses would have no force in or behind
them.

So I object to muddying the issue by misrepresenting the source of that
force. Whatever force there is in copyright comes from law, not any free
software license.

-- 
 \   “Let others praise ancient times; I am glad I was born in |
  `\  these.” —Ovid (43 BCE–18 CE) |
_o__)  |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: HTTP Post Request

2010-05-10 Thread Kushal Kumaran
On Mon, May 10, 2010 at 8:26 PM, [email protected]  wrote:
> On May 10, 10:22 am, Kushal Kumaran 
> wrote:
>> On Mon, May 10, 2010 at 7:30 PM, [email protected]  wrote:
>> > Hi to all, i want to ask you a question, concerning the best way to do
>> > the following as a POST request:
>> > There is server-servlet that accepts xml commands
>> > It had the following HTTP request headers:
>>
>> >            Host: somehost.com
>> >            User-Agent: Jakarta Commons-HttpClient
>> >            Content-Type: text/xml
>> >            Content-Length: 415
>>
>> > and the following request body (reformatted here for clarity):
>>
>> >            
>> >            
>> >              search
>> >            
>> > How can i send the above to the Listener Servlet?
>> > Thanks in advance
>>
>> Use the xmlrpclib module.
>>
>
> OK, sending headers with xmlrpclib,
> but how do i send the XML message?
>

Your XML message is an XML RPC message.  You will use xmlrpclib like this:

server_proxy = xmlrpclib.ServerProxy(('somehost.com', 80))
result = server_proxy.search()

The call to server_proxy.search will result in an actual XML RPC
message being sent.

Read up on the xmlrpclib documentation here:
http://docs.python.org/library/xmlrpclib.html, and the XMLRPC spec
here: http://www.xmlrpc.com/spec

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


Re: How to measure speed improvements across revisions over time?

2010-05-10 Thread Steven D'Aprano
On Mon, 10 May 2010 20:13:44 +, Matthew Wilson wrote:

> I know how to use timeit and/or profile to measure the current run-time
> cost of some code.
> 
> I want to record the time used by some original implementation, then
> after I rewrite it, I want to find out if I made stuff faster or slower,
> and by how much.
> 
> Other than me writing down numbers on a piece of paper on my desk, does
> some tool that does this already exist?
> 
> If it doesn't exist, how should I build it?


from timeit import Timer
before = Timer(before_code, setup)
after = Timer(after_code, setup)
improvement = min(before.repeat()) - min(after.repeat())


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


Re: Is Python a functional programming language?

2010-05-10 Thread Samuel Williams
Thanks to everyone for their great feedback, it is highly appreciated.

Kind regards,
Samuel
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Extract all words that begin with x

2010-05-10 Thread Terry Reedy

On 5/10/2010 5:35 AM, James Mills wrote:

On Mon, May 10, 2010 at 6:50 PM, Xavier Ho  wrote:

Have I missed something, or wouldn't this work just as well:


list_of_strings = ['2', 'awes', '3465sdg', 'dbsdf', 'asdgas']
[word for word in list_of_strings if word[0] == 'a']

['awes', 'asdgas']


I would do this for completeness (just in case):


[word for word in list_of_strings if word and word[0] == 'a']


Just guards against empty strings which may or may not be in the list.


 ... word[0:1] does the same thing. All Python programmers should learn 
to use slicing to extract a  char from a string that might be empty.

The method call of .startswith() will be slower, I am sure.


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


Re: Extract all words that begin with x

2010-05-10 Thread Tycho Andersen
On Mon, May 10, 2010 at 10:23 PM, Terry Reedy  wrote:
> On 5/10/2010 5:35 AM, James Mills wrote:
>>
>> On Mon, May 10, 2010 at 6:50 PM, Xavier Ho  wrote:
>>>
>>> Have I missed something, or wouldn't this work just as well:
>>>
>> list_of_strings = ['2', 'awes', '3465sdg', 'dbsdf', 'asdgas']
>> [word for word in list_of_strings if word[0] == 'a']
>>>
>>> ['awes', 'asdgas']
>>
>> I would do this for completeness (just in case):
>>
>> [word for word in list_of_strings if word and word[0] == 'a']
>>
>> Just guards against empty strings which may or may not be in the list.
>
>  ... word[0:1] does the same thing. All Python programmers should learn to
> use slicing to extract a  char from a string that might be empty.
> The method call of .startswith() will be slower, I am sure.

Why? Isn't slicing just sugar for a method call?

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


Re: virtualenvwrapper for Windows (Powershell)

2010-05-10 Thread Lawrence D'Oliveiro
In message 
<22cf35af-44d1-43fe-8b90-07f2c6545...@i10g2000yqh.googlegroups.com>, 
Guillermo wrote:

> If you've ever missed it on Windows and you can use Powershell ...

I thought the whole point of Windows was to get away from this command-line 
stuff. Not such a good idea after all?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: shortcut for large amount of global var declarations?

2010-05-10 Thread Lawrence D'Oliveiro
In message , Alex Hall 
wrote:

> ... I have about fifteen vars in a function which have to be
> global.

Why not make them class variables, e.g.

class my_namespace :
var1 = ...
var2 = ...
#end my_namespace

def my_function(...) :
... can directly read/assign my_namespace.var1 etc here ...
#end my_function

Also has the benefit of minimizing pollution of the global namespace.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: fast regex

2010-05-10 Thread Lawrence D'Oliveiro
In message
, 
james_027 wrote:

> I was working with regex on a very large text, really large but I have
> time constrained.

“Fast regex” is a contradiction in terms. You use regexes when you want ease 
of definition and application, not speed.

For speed, consider hand-coding your own state machine. Preferably in a 
compiled language like C.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: unable to get Hudson to run unit tests

2010-05-10 Thread Stefan Behnel

j vickroy, 10.05.2010 17:39:

Unfortunately, when "Hudson Build now" is performed, the Hudson Console
output, for this job, is:


Started by user anonymous
Updating svn://vm-svn/GOES data processing/trunk/GOES/13,14,15/SXI/level-1
At revision 3403
no change for svn://vm-svn/GOES data
processing/trunk/GOES/13,14,15/SXI/level-1 since the previous build
[workspace] $ python.exe
C:\DOCUME~1\JIM~1.VIC\LOCALS~1\Temp\hudson5273111667332806239.sh
os.getcwd(): C:\Documents and Settings\jim.vickroy\.hudson\jobs\GOES
13-15 SXI Level-1 Products Generation\workspace
os.listdir(os.getcwd()): ['level-1']
[workspace] $ cmd.exe -xe
C:\DOCUME~1\JIM~1.VIC\LOCALS~1\Temp\hudson991194264891924641.sh
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\jim.vickroy\.hudson\jobs\GOES 13-15 SXI
Level-1 Products Generation\workspace>Recording test results
No test report files were found. Configuration error?
Finished: FAILURE


The second [workspace] section output (above) looks like cmd.exe is
being executed with no parameters (i.e., without the
"nosetests.exe --where=level-1 --with-xunit --verbose") parameter.


No, what Hudson actually does, is, it writes your command(s) into a text 
file and runs it with the system's shell interpreter (which, unless 
otherwise configured, is "cmd.exe" on Windows). This assures the highest 
possible compatibility with the executed script. You can even use the 
shebang in Hudson's scripts that way, so that you can execute scripts in 
basically any scripting language.


The likely reason why it doesn't find your test results is that you didn't 
tell it where to look. Put a wildcard path into the unit test config box 
that finds the XML files that nosetest writes. It's also best to tell 
nosetest where to put them explicitly using a command line option.


Stefan

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


Re: How to measure speed improvements across revisions over time?

2010-05-10 Thread Martin v. Loewis
Matthew Wilson wrote:
> I know how to use timeit and/or profile to measure the current run-time
> cost of some code.
> 
> I want to record the time used by some original implementation, then
> after I rewrite it, I want to find out if I made stuff faster or slower,
> and by how much.
> 
> Other than me writing down numbers on a piece of paper on my desk, does
> some tool that does this already exist?

I recommend to use rrd. This can record time series, and then generate
diagrams.

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


Re: win32com

2010-05-10 Thread mohamed issolah
hey,

I need help .

2010/5/9 mohamed issolah 

> hey,
> I wich to have an example please
>
> need help
>
>
>
> 2010/5/9 Chris Rebert 
>
> On Sun, May 9, 2010 at 1:15 AM, mohamed issolah 
>> wrote:
>> > hey,
>> >
>> > there is an alternative of win32com in linux?
>> >
>> > what i want to say : can communicate with application (ex: evolution or
>> > another) throught python like in windows with win32com
>>
>> The closest equivalent would probably be python-dbus. See the "Python"
>> section of http://www.freedesktop.org/wiki/Software/DBusBindings
>>
>> Information on D-Bus generally: http://en.wikipedia.org/wiki/D-Bus
>>
>> Cheers,
>> Chris
>> --
>> http://blog.rebertia.com
>>
>
>
>
> --
> issolah mohamed
>



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