Looking for pointers/suggestion - how to make a webbrowser with these restriction?

2012-09-26 Thread Anthony Kong
Hi, all,

It is kind of a MacGyver question. I am just looking for some general 
suggestions/pointer.

First let me first describe the development environment I am in: it is a locked 
down WinXP PC with limited development tools and libraries. At my disposal I 
have python 2.6 , webkit 5.33 dll, wx 2.8 and probably a V8 dll. No visual 
studio or any C/C++ compiler. Do not have admin right.

So given these existing ingredients, is it possible to build a rudimentary web 
browser using python as a glue language?  What will be the main 
challenge/bottleneck in this sort of project? In particular how can I hook up 
V8 and Webkit?

I have some working experience with Win32 APIs, so you may throw some low level 
stuff at me if needed. :-)

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


Re: Looking for pointers/suggestion - how to make a webbrowser with these restriction?

2012-09-26 Thread Anthony Kong
Hi, Chris,

Thanks for your reply. I really do not have any requirement. It is more a 
curiosity question (not work related). I'd like to find out how python can be 
used to 'glue' all these moving parts together. Performance and security are 
definitely not a concern as it is just a toy idea/project.

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


An interesting beginner question: why we need colon at all in the python language?

2011-07-11 Thread Anthony Kong
Hi, all,

Lately I am giving some presentations to my colleagues about the python
language. A new internal project is coming up which will require the use of
python.

One of my colleague asked an interesting:

*If Python use indentation to denote scope, why it still needs semi-colon at
the end of function declaration and for/while/if loop?*

My immediate response is: it allows us to fit statements into one line. e.g.
if a == 1: print a

However I do not find it to be a particularly strong argument. I think PEP8
does not recommend this kind of coding style anyway, so one-liner should not
be used in the first place!

Is there any other reasons for use of semi-colon in python?


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


Re: An interesting beginner question: why we need colon at all in the python language?

2011-07-11 Thread Anthony Kong
Awesome! Thanks for blog post link

Cheers

On Tue, Jul 12, 2011 at 12:16 AM, Thomas Jollans  wrote:

> On 07/11/2011 03:51 PM, Anthony Kong wrote:
> > Hi, all,
> >
> > Lately I am giving some presentations to my colleagues about the python
> > language. A new internal project is coming up which will require the use
> > of python.
> >
> > One of my colleague asked an interesting:
> >
> > /If Python use indentation to denote scope, why it still needs
> > semi-colon at the end of function declaration and for/while/if loop?/
> >
> > My immediate response is: it allows us to fit statements into one line.
> > e.g. if a == 1: print a
> >
> > However I do not find it to be a particularly strong argument. I think
> > PEP8 does not recommend this kind of coding style anyway, so one-liner
> > should not be used in the first place!
>
> Basically, it looks better, and is more readable. A colon, in English
> like in Python, means that something follows that is related to what was
> before the colon. So the colon makes it abundantly clear to the human
> reader that a block follows, and that that block is to be considered in
> relation to what was just said, before the colon.
>
> Coincidentally, Guido wrote this blog post just last week, without which
> I'd be just as much at a loss as you:
>
>
> http://python-history.blogspot.com/2011/07/karin-dewar-indentation-and-colon.html
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
/*--*/
Don’t EVER make the mistake that you can design something better than what
you get from ruthless massively parallel trial-and-error with a feedback
cycle. That’s giving your intelligence _much_ too much credit.

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


My take on 'Python Productivity tip for Java Programmer'. Could you give me more feedback?

2011-07-11 Thread Anthony Kong
Hi, all,

Lately I am giving some presentations to my colleagues about the python
language. A new internal project is coming up which will require the use of
python.

One of the goals of the presentations, as told by the 'sponsor' of the
presentation, is to help the existing Java/Excel VBA programming team to
become productive in python asap.

I have a feeling that they are asking it based on their Java/Eclipse
experience. By productive they are actually looking for some GUI tools that
are as helpful as Eclipse.

Having done Java programming before, I am thinking of answering the question
this way:

1) For many of us, vi/emacs are sufficient for python development. (I used
vim + ctags as my primary IDE for a very long time)

2) For a feature-rich GUI environment, we can consider pyCharm. (I was
totally 'wowed' by it, and has convinced my last employer to purchased a
few enterprise licenses)

3) The Python language itself is actually small and concise. The need for a
full-blown IDE is less. The language itself could be counted as a part of
the productive tool.

4) The functional aspect of the language (e.g. map, reduce, partial) helps
to make program shorter and easier to understand

5) The 'battery included' standard library helps to avoid the need of
complicated build tool.

6) The interactive shell helps to test out solutions in smaller units.

It is probably not the team is expecting. Do you have more to add? What do
you think about this 'answer'?

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


Re: An interesting beginner question: why we need colon at all in the python language?

2011-07-11 Thread Anthony Kong
Sorry, typo in my original question. I do mean 'colon'. It should have read

*If Python use indentation to denote scope, why it still needs colon at the
end of function declaration and for/while/if loop?*

Thanks


On Tue, Jul 12, 2011 at 12:36 AM, Dave Angel  wrote:

> On 01/-10/-28163 02:59 PM, Anthony Kong wrote:
>
>> Hi, all,
>>
>> Lately I am giving some presentations to my colleagues about the python
>> language. A new internal project is coming up which will require the use
>> of
>> python.
>>
>> One of my colleague asked an interesting:
>>
>> *If Python use indentation to denote scope, why it still needs semi-colon
>> at
>> the end of function declaration and for/while/if loop?*
>>
>> My immediate response is: it allows us to fit statements into one line.
>> e.g.
>> if a == 1: print a
>>
>> However I do not find it to be a particularly strong argument. I think
>> PEP8
>> does not recommend this kind of coding style anyway, so one-liner should
>> not
>> be used in the first place!
>>
>> Is there any other reasons for use of semi-colon in python?
>>
>>
>> Cheers
>>
>>  You're confusing the colon with the semi-colon.  If you want two
> statements on the same line, you use a semi-colon.
>
> The character you're asking about is the colon.  It goes at the end of an
> if, else, for, with, while statement.  I doubt it's absolutely essential,
> but it helps readability, since a conditional expression might span multiple
> lines.
>if someexpression ==
>  someotherexpression:
>body_of_the_conditional
>
> DaveA
>
>


-- 
/*--*/
Don’t EVER make the mistake that you can design something better than what
you get from ruthless massively parallel trial-and-error with a feedback
cycle. That’s giving your intelligence _much_ too much credit.

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


Property setter and lambda question

2011-07-11 Thread Anthony Kong
Hi, all,

This question is in the same context of my two earlier questions. This
question was raised by some python beginners, and I would like to check with
the list to ensure I provide a correct answer.

Here is a code snippet I used to demonstrate the keyword *property*:


class A(object):

def __init__(self):
self.__not_here = 1

def __get_not_here(self):
return self.__not_here

def __set_not_here(self, v):
print "I am called"
self.__not_here = v

not_here = property(lambda self: self.__get_not_here(), lambda self, v:
self.__set_not_here(v))
# not_here = property(lambda self: self.__not_here, lambda self, v:
self.__not_here = v)

So the question: is it possible to use lambda expression at all for the
setter? (As in the last, commented-out line)

Python interpreter will throw an exception right there if I use the last
line ('SyntaxError: lambda cannot contain assignment'). I'd use pass a
setter method anyway.

What is your preferred solution?

-- 

Tony Kong
*blog:* www.ahwkong.com

/*--*/
Don’t EVER make the mistake that you can design something better than what
you get from ruthless massively parallel trial-and-error with a feedback
cycle. That’s giving your intelligence _much_ too much credit.

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


Re: My take on 'Python Productivity tip for Java Programmer'. Could you give me more feedback?

2011-07-11 Thread Anthony Kong
Thomas,

Thanks for the excellent suggestions.

Generator is certainly an interesting subject.

>From what i understand, the advantage of generator is mainly about saving
memory, right? (i.e. no need to create a list in memory before iterate thru
it)

Duck typing... Although it can be easily demonstrated, I find it hard to
explain its advantages to Java developers who are so used to Interfaces. (Is
it about the certainty of type info... I am not sure about their concern
actually)

Jython is not a possibility, but I will show them an example anyway. We can
use it to write some support script, I suppose.

(Off topic) Monkey patching - It is a term used by Ruby developer a lot. If
it means to change a function's implementation in run-time, i think python
can achieve the same, right? Is it equivalent to Mixin?

Cheers



On Tue, Jul 12, 2011 at 2:00 AM, Thomas Jollans  wrote:

> On 07/11/2011 05:07 PM, Anthony Kong wrote:
> > Hi, all,
> >
> > Lately I am giving some presentations to my colleagues about the python
> > language. A new internal project is coming up which will require the use
> > of python.
> >
> > One of the goals of the presentations, as told by the 'sponsor' of the
> > presentation, is to help the existing Java/Excel VBA programming team to
> > become productive in python asap.
> >
> > I have a feeling that they are asking it based on their Java/Eclipse
> > experience. By productive they are actually looking for some GUI tools
> > that are as helpful as Eclipse.
> >
> > Having done Java programming before, I am thinking of answering the
> > question this way:
> >
> > 1) For many of us, vi/emacs are sufficient for python development. (I
> > used vim + ctags as my primary IDE for a very long time)
> >
> > 2) For a feature-rich GUI environment, we can consider pyCharm. (I was
> > totally 'wowed' by it, and has convinced my last employer to purchased a
> > few enterprise licenses)
> >
> > 3) The Python language itself is actually small and concise. The need
> > for a full-blown IDE is less. The language itself could be counted as a
> > part of the productive tool.
>
> If your colleagues are used to Eclipse, it's almost certainly best to
> continue using Eclipse, with PyDev. Don't make a big deal of the tools,
> just say that many Pythonista don't use a heavy IDE, mention PyDev, and,
> if you want to, recommend pyCharm.
>
> > 4) The functional aspect of the language (e.g. map, reduce, partial)
> > helps to make program shorter and easier to understand
>
> Don't overemphasize this. Those functions can be very useful, and using
> them can lead to very concise and simple code, but (big BUT) more often
> than not, they're overly cryptic when compared to list comprehension and
> generator expressions.
>
> Do make a huge case for generator expressions/list comprehension, and
> generators.
>
> > 5) The 'battery included' standard library helps to avoid the need of
> > complicated build tool.
> >
> > 6) The interactive shell helps to test out solutions in smaller units.
>
> Speaking of testing: introduce them to the doctest module.
>
> > It is probably not the team is expecting. Do you have more to add? What
> > do you think about this 'answer'?
>
> If using Jython is an option, present it! Jython will allow Java
> programmers to use their existing knowledge of the Java standard library.
>
> Explain, and make the case for, duck typing.
>
> While actual functional programming is, as I said, a bit "out there"
> from a Java/VBA standpoint, do show off function objects.
>
> If you know what they're going to do with Python, you should point them
> to relevant libraries/modules.
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 

Tony Kong
*blog:* www.ahwkong.com

Don’t EVER make the mistake that you can design something better than what
> you get from ruthless massively parallel trial-and-error with a feedback
> cycle. That’s giving your intelligence *much* too much credit.


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


Re: Property setter and lambda question

2011-07-11 Thread Anthony Kong
Thanks again for your input, Thomas.

I normally prefer

not_here = property(lambda self: self.__get_not_here(), lambda self, v:
self.__set_not_here(v))

than

not_here = property(__get_not_here, __set_not_here)

Because it allows me to have a pair getter/setter (when there is a need for
it). Use of lambda there is ensure derived class of A can provide their
custom version of getter/setter.


But decorator! Of course! Thanks for reminding me this.

In your example, where does '@not_here' come from? (Sorry, this syntax is
new to me)

Cheers

On Tue, Jul 12, 2011 at 2:23 AM, Thomas Jollans  wrote:

> On 07/11/2011 05:54 PM, Anthony Kong wrote:
> > Hi, all,
> >
> > This question is in the same context of my two earlier questions. This
> > question was raised by some python beginners, and I would like to check
> > with the list to ensure I provide a correct answer.
> >
> > Here is a code snippet I used to demonstrate the keyword *property*:
> >
> >
> > class A(object):
> >
> > def __init__(self):
> > self.__not_here = 1
> >
> > def __get_not_here(self):
> > return self.__not_here
> >
> > def __set_not_here(self, v):
> > print "I am called"
> > self.__not_here = v
> >
> > not_here = property(lambda self: self.__get_not_here(), lambda self,
> > v: self.__set_not_here(v))
> > # not_here = property(lambda self: self.__not_here, lambda self, v:
> > self.__not_here = v)
> >
> > So the question: is it possible to use lambda expression at all for the
> > setter? (As in the last, commented-out line)
> >
> > Python interpreter will throw an exception right there if I use the last
> > line ('SyntaxError: lambda cannot contain assignment'). I'd use pass a
> > setter method anyway.
> >
> > What is your preferred solution?
>
> No, a lambda can only contain an expression, not a statement. This is
> not C, assignments are not expressions.
>
> As to what I would do:
> There's really no need to use lambdas at all here:
>
> class A(object):
>def __init__(self):
>self.not_here = 1
>def __get_not_here(self):
>return self.__not_here
> def __set_not_here(self, val):
>self.__not_here = val
>not_here = property(__get_not_here, __set_not_here)
>
> My favourite way to create properties is of course with decorators:
>
> class A(object):
>def __init__(self):
>self.not_here = 1
>
> @property
>def not_here(self):
>return self.__not_here
>
>@not_here.setter
>def not_here(self, val):
>self.__not_here = val
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 

Tony Kong
*blog:* www.ahwkong.com

Don’t EVER make the mistake that you can design something better than what
> you get from ruthless massively parallel trial-and-error with a feedback
> cycle. That’s giving your intelligence *much* too much credit.


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


Re: Property setter and lambda question

2011-07-11 Thread Anthony Kong
Good point! Need to get my terminology right. Thanks

On Tue, Jul 12, 2011 at 2:43 AM, Ian Kelly  wrote:

> On Mon, Jul 11, 2011 at 9:54 AM, Anthony Kong 
> wrote:
> > Hi, all,
> > This question is in the same context of my two earlier questions. This
> > question was raised by some python beginners, and I would like to check
> with
> > the list to ensure I provide a correct answer.
> > Here is a code snippet I used to demonstrate the keyword property:
>
> What Thomas said.  But also, please note that "property" is a builtin,
> not a keyword.
>
> 
>
> Cheers,
> Ian
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 

Tony Kong
*blog:* www.ahwkong.com

Don’t EVER make the mistake that you can design something better than what
> you get from ruthless massively parallel trial-and-error with a feedback
> cycle. That’s giving your intelligence *much* too much credit.


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


Re: Property setter and lambda question

2011-07-11 Thread Anthony Kong
>
> PS: are you sure the lambda self: self.__foo() trick works, with
> subclasses or otherwise? I haven't tested it, and I'm not saying it
> doesn't, but I have a feeling double-underscore name mangling might be a
> problem somewhere down the line?
>
>
Awesome, Thomas. The trick only works if there is only *one* leading
underscore in the *method* names.

The following example works as I expected for the derived class B.

class A(object):

def __init__(self):
self.__not_here = 1

def _get_not_here(self):
return self.__not_here

def _set_not_here(self, v):
print "I am called"
self.__not_here = v

not_here = property(lambda self: self._get_not_here(), lambda self, v:
self._set_not_here(v))

class B(A):
def _set_not_here(self, v):
print "version B"
self.__not_here = v


a = A()
# print a.__not_here
print a.not_here
# a.set_not_here(10)
a.not_here = 10
print a.not_here


b = B()
print b.not_here
b.not_here = 70  # print version B
print b.not_here




-- 

Tony Kong
*blog:* www.ahwkong.com

Don’t EVER make the mistake that you can design something better than what
> you get from ruthless massively parallel trial-and-error with a feedback
> cycle. That’s giving your intelligence *much* too much credit.


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


Re: Property setter and lambda question

2011-07-11 Thread Anthony Kong
So subclass B has no access to __not_here in A after all...

OK, in one of legacy Python I supported there are a lot of code floating
around like this. It works OK (in term of business logic and unit test).
That's probably due to luck :-)

It also uses a lot of __slot__ = ['attr_a', 'attr_b'...] in class
definitions to prevent accidental creation of new variables (due to typo for
example).

Needless to say it was first written up by programmers of static lang
background who want to enforce the java/.net behavior... (private variables,
variable declaration)


Cheers


On Tue, Jul 12, 2011 at 3:41 AM, Ian Kelly  wrote:

> On Mon, Jul 11, 2011 at 11:21 AM, Anthony Kong
>  wrote:
> > Awesome, Thomas. The trick only works if there is only one leading
> > underscore in the method names.
> > The following example works as I expected for the derived class B.
> > class A(object):
> > def __init__(self):
> > self.__not_here = 1
> > def _get_not_here(self):
> > return self.__not_here
> > def _set_not_here(self, v):
> > print "I am called"
> > self.__not_here = v
> > not_here = property(lambda self: self._get_not_here(), lambda self,
> v:
> > self._set_not_here(v))
> > class B(A):
> > def _set_not_here(self, v):
> > print "version B"
> > self.__not_here = v
>
> It shouldn't.  You've still got the name __not_here used in both A and
> B, so that the B version is setting a different attribute than the A
> version (_B__not_here vs. _A__not_here).
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 

Tony Kong
*blog:* www.ahwkong.com

Don’t EVER make the mistake that you can design something better than what
> you get from ruthless massively parallel trial-and-error with a feedback
> cycle. That’s giving your intelligence *much* too much credit.


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


Re: An interesting beginner question: why we need colon at all in the python language?

2011-07-13 Thread Anthony Kong
Thanks, mate! I was writing that up really late at night. Somehow I changed
term to semi-colon half way through,

Cheers

On Wed, Jul 13, 2011 at 5:36 PM, Thorsten Kampe
wrote:

> * Dave Angel (Mon, 11 Jul 2011 10:36:48 -0400)
> > On 01/-10/-28163 02:59 PM, Anthony Kong wrote:
> > > My immediate response is: it allows us to fit statements into one
> > > line. e.g.
> > > if a == 1: print a
> > >
> > You're confusing the colon with the semi-colon. If you want two
> > statements on the same line, you use a semi-colon.
>
> He's not confusing anything at all. His example made it pretty clear
> that he didn't mean "two statements" but "multiline statemements".
>
> Thorsten
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 

Tony Kong
*blog:* www.ahwkong.com

Don’t EVER make the mistake that you can design something better than what
you get from ruthless massively parallel trial-and-error with a feedback
cycle. That’s giving your intelligence *much* too much credit.


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


Functional style programming in python: what will you talk about if you have an hour on this topic?

2011-07-13 Thread Anthony Kong
Hi, all,

If you have read my previous posts to the group, you probably have some idea
why I asked this question.

I am giving a few presentations on python to my colleagues who are mainly
java developers and starting to pick up python at work.


So I have picked this topic for one of my presentation. It is because
functional programming technique is one of my favorite in my bag  of python
trick. It also takes me to the rabbit hole of the functional programming
world, which is vastly more interesting than the conventional procedural/OO
languages.


I think I will go through the following items:


   - itertools module
   - functools module
   - concept of currying ('partial')



I would therefore want to ask your input e.g.


   - Is there any good example to illustrate the concept?
   - What is the most important features you think I should cover?
   - What will happen if you overdo it?



Cheers

-- 

Tony Kong
*blog:* www.ahwkong.com

Don’t EVER make the mistake that you can design something better than what
you get from ruthless massively parallel trial-and-error with a feedback
cycle. That’s giving your intelligence *much* too much credit.


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


Functional style programming in python: what will you talk about if you have an hour on this topic?

2011-07-13 Thread Anthony Kong
(My post did not appear in the mailing list, so this is my second try. Apology 
if it ends up posted twice)

Hi, all,

If you have read my previous posts to the group, you probably have some idea 
why I asked this question.

I am giving a few presentations on python to my colleagues who are mainly java 
developers and starting to pick up python at work.


So I have picked this topic for one of my presentation. It is because 
functional programming technique is one of my favorite in my bag  of python 
trick. It also takes me to the rabbit hole of the functional programming world, 
which is vastly more interesting than the conventional procedural/OO languages.


I think I will go through the following items:

itertools module
functools module
concept of currying ('partial')


I would therefore want to ask your input e.g.

Is there any good example to illustrate the concept? 
What is the most important features you think I should cover?
What will happen if you overdo it?


Cheers

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


Re: Functional style programming in python: what will you talk about if you have an hour on this topic?

2011-07-13 Thread Anthony Kong
Hi, James,


>
> You might also want to cover gotchas like Python's references.
>

Not sure what it means in the context of functional programming. If you can
give some code to demonstrate, it will be great.

Cheers
-- 

Tony Kong
*blog:* www.ahwkong.com

Don’t EVER make the mistake that you can design something better than what
you get from ruthless massively parallel trial-and-error with a feedback
cycle. That’s giving your intelligence *much* too much credit.


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


Re: What is the difference between PyPy and Python? are there lot of differences?

2011-07-13 Thread Anthony Kong
One of the main difference is that pypy supports only R-Python, which stands
for 'Restricted Python".

It is a subset of C-python language.

See here for more info:
http://codespeak.net/pypy/dist/pypy/doc/coding-guide.html#rpython-definition-not

Cheers

On Thu, Jul 14, 2011 at 12:06 AM, ArrC  wrote:

> Hey guys,i am a python newbie,
> i just read a qustion on quora where it said that quora quys used pypy (and
> pylon) to develop quora.
>
> So, i want to know what are the core diff btw PyPy and Python ?
>
> And they also talked about the lack of type check in python.
>
> So, how does it help (strongly typed) in debugging?
>
> Thanks
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 

Tony Kong
*blog:* www.ahwkong.com

Don’t EVER make the mistake that you can design something better than what
you get from ruthless massively parallel trial-and-error with a feedback
cycle. That’s giving your intelligence *much* too much credit.


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


Re: What is the difference between PyPy and Python? are there lot of differences?

2011-07-13 Thread Anthony Kong
I stand corrected.  Thanks Ian

Cheers

On Thu, Jul 14, 2011 at 1:18 AM, Ian Kelly  wrote:

> On Wed, Jul 13, 2011 at 8:19 AM, Anthony Kong 
> wrote:
> > One of the main difference is that pypy supports only R-Python, which
> stands
> > for 'Restricted Python".
> > It is a subset of C-python language.
>
> This is wrong.  The PyPy *interpreter* is written in RPython.  At the
> application level, PyPy supports the full syntax and semantics of
> Python (with a few minor differences of the same sort that you find in
> Jython or IronPython).
>



-- 

Tony Kong
*blog:* www.ahwkong.com

Don’t EVER make the mistake that you can design something better than what
you get from ruthless massively parallel trial-and-error with a feedback
cycle. That’s giving your intelligence *much* too much credit.


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


Re: Aw: Re: Aw: Functional style programming in python: what will you talk about if you have an hour on this topic?

2011-07-18 Thread Anthony Kong
Thanks for all the great suggestion. 

First of all, Carl is right that it does not take much to impress a java 
programmer about the expressiveness of functional programming.

Covered map, reduce and filter as Rainer suggested.

Emphasized the advantages of functional style as summarised by Steve D'Aprano. 

I showcased the use of groupby() in itertools. Think about what it takes to 
implement similar logic in Java. Also introduced the gotcha of using groupby(): 
you must first sort the list in the same way you want to group them by.


Then I got ambitious and tried to introduce partial(). I basically lost 
everyone right there. They can understand what partial does but do not know why 
it can be useful. My example was too trivial and it did not help.


What is the best way to introduce partial/currying? 



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


Question about compiling python 30 from subversion repository on OSX

2011-04-23 Thread Anthony Kong
Hi, all,

I have checked out source code from this url 
http://svn.python.org/projects/python/branches/py3k, then run

./configure  --with-universal-archs=64-bit
make

First of all, I got this message:

---
Modules/Setup.dist is newer than Modules/Setup;
check to make sure you have all the updates you
need in your Modules/Setup file.
Usually, copying Modules/Setup.dist to Modules/Setup will work.
---

Then the build failed with these messages

/usr/bin/ranlib: file: libpython3.3m.a(dynamic_annotations.o) has no symbols
/usr/bin/ranlib: file: libpython3.3m.a(pymath.o) has no symbols
ranlib libpython3.3m.a
ranlib: file: libpython3.3m.a(dynamic_annotations.o) has no symbols
ranlib: file: libpython3.3m.a(pymath.o) has no symbols
gcc   -framework CoreFoundation -o python.exe Modules/python.o libpython3.3m.a 
-ldl  -framework CoreFoundation
Could not find platform dependent libraries 
Consider setting $PYTHONHOME to [:]
Fatal Python error: Py_Initialize: can't initialize sys standard streams
Traceback (most recent call last):
  File "/Users/antkong/wd/python/python3/Lib/io.py", line 60, in 
/bin/sh: line 1: 55310 Abort trap  CC='gcc' LDSHARED='gcc -bundle 
-undefined dynamic_lookup  ' OPT='-DNDEBUG -g -fwrapv -O3 -Wall 
-Wstrict-prototypes' ./python.exe -E ./setup.py build
make: *** [sharedmods] Error 134


I wonder what caused these error messages. Is it possible that I am checking 
out the wrong branch?

The 3.2 branch (http://svn.python.org/projects/python/branches/release32-maint) 
can be compiled without much issue.


Cheers



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


Design Pattern and Python: Any book recommendation? Your view?

2011-11-03 Thread Anthony Kong
Sorry to resurrect this topic. By google search the last discussion was in 2003.

I would like to find out what is the current prevailing view or consensus (if 
any) on the use of Design Pattern in python? 

I am doing some 'fact-finding' in this area on request of my colleagues. Some 
of them want to buy a book or two in this subject area. Hopefully the newsgroup 
can give me some book recommendation and insight in this topic.

I myself pretty much subscribe to the view that the nature of python language 
actually do away much of the need of the use of DP, but it is just a personal 
view. It comes form my experience of migrating from webware4py (webframework 
based on J2EE/servlet idea) to cherrypy



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