Re: [BangPypers] How to model these entities?

2015-03-29 Thread Dhananjay Nene
One reason I am not fond of singletons is that they make unit testing a lot
harder

Dhananjay

On Wed, Mar 25, 2015 at 7:02 PM, Abhaya Agarwal 
wrote:

> Hi,
>
> I need to model four entities that share some attributes and behaviors and
> also have some unique attributes and behaviors. I need to be able to refer
> to them from other entities. And these entities are Singletons.
>
> Ex: online marketplaces. They share common attributes like website, contact
> person, commission rates which are best stored in DB. But they differ in
> how you upload data to them - one of them supports FTP, other Dropbox -
> best modeled as implementation of an interface. There may be unique data
> associated with these behaviors. FTP credentials, Dropbox credentials.
>
> Also a product may need to refer to these marketplaces (Ex: where all is it
> going to be listed), so they need to be enumerable.
>
> I have considered class hierarchy + a central registry + on disk config
> files. But since this is a part of a larger Django project, implementing it
> like this kind of sticks out and integrating it with admin etc requires lot
> more work. What are the other options to model something like this? I feel
> like I'm missing something obvious.
>
> Thanks a lot!
>
> Regards,
> Abhaya
>
> --
> -
> blog: http://abhaga.blogspot.com
> Twitter: http://twitter.com/abhaga
> -
> ___
> BangPypers mailing list
> BangPypers@python.org
> https://mail.python.org/mailman/listinfo/bangpypers
>
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Iterators

2014-04-02 Thread Dhananjay Nene
On Tue, Apr 1, 2014 at 11:19 PM, Anand Chitipothu wrote:

> On Tue, Apr 1, 2014 at 11:16 PM, Noufal Ibrahim KV
> wrote:
>
> > On Tue, Apr 01 2014, Pradip Caulagi wrote:
> >
> > > It is rather late in the day to bring this up but ...
> > >
> > > I heard they are removing iterators from Python to keep a small core.
> > > Anybody want to join efforts to write a generic library to fill this
> > > gap?
> >
> > Damn you. I googled for this. This happens to me *every* year. :(
> >
>
> Don't worry. You are not alone.
>

I go to sleep on the 31st reminding myself to not fall for anything the
next day. Incidentally, someone did try to pull another one off on my FB
stream - Windows to have full POSIX compliance :)
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] list question

2013-12-05 Thread Dhananjay Nene
from itertools import groupby
x = [['cat','NM123',12],['cat','NM234',12], ['dog', 'NM56',65]]
y = [['cat','NM123, NM234', 12], ['dog', 'NM56', 65]]

def grouper(t) : return (t[0],t[2])
assert y ==  list(list((keys[0],", ".join(val[1] for val in vals),keys[1]))
  for keys, vals in  groupby(sorted(x,key=grouper),grouper))



http://blog.dhananjaynene.com twitter: @dnene google+:
https://google.com/+DhananjayNene


On Thu, Dec 5, 2013 at 2:16 PM, L Radhakrishna Rao
wrote:

> One thing is here:
>
> The x[0] and x[1] are in union with each other.
>
> this needs to be solved by set operations on list of lists.
>
>
>
>
> On Thu, Dec 5, 2013 at 1:55 PM, Vikram K  wrote:
>
> > Any suggestions on what i have to do to go from x to y?
> >
> > >>> x = [['cat','NM123',12],['cat','NM234',12], ['dog', 'NM56',65]]
> > >>> x
> > [['cat', 'NM123', 12], ['cat', 'NM234', 12], ['dog', 'NM56', 65]]
> > >>> y = []
> > >>> y = [['cat','NM123, NM234', 12], ['dog', 'NM56', 65]]
> > >>>
> >
> > Regards
> > Vik
> > ___
> > BangPypers mailing list
> > BangPypers@python.org
> > https://mail.python.org/mailman/listinfo/bangpypers
> >
> ___
> BangPypers mailing list
> BangPypers@python.org
> https://mail.python.org/mailman/listinfo/bangpypers
>
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Issue with list comprehension

2013-10-30 Thread Dhananjay Nene
Thats surprising. The code runs just fine

http://ideone.com/06qjoM

(Ans: 986)

As an aside I renamed _sum to sum_

When avoiding naming conflicts, its recommended to postfix a underscore

Prefixing an underscore is to provide a hint that the value that gets
assigned to the variable is going to be ignore (ie. that variable
itself is going to be ignored)

Dhananjay


On Wed, Oct 30, 2013 at 5:42 PM, Anant   wrote:
> Hi folks,
>
> I am new to Python (have been on Java for 8 years), but I have quickly
> grasped its style.
>
> While working on a problem (as Python practice) to generate fibonacci
> numbers using generators and list comprehension, I ran into an issue.
>
> Here's my code:
>
> *import itertools*
> *
> *
> *def fibonacci():*
> *a, b = 0, 1*
> *while True:*
> * yield b*
> * a, b = b, a+b*
> *
> *
> *fib=fibonacci()
> *
> *_sum=sum([n for n in itertools.takewhile(lambda x: x < 400, fib)])*
> *print _sum*
>
> Basically, I wanted to sum up all the fib numbers till 400.
> *This code runs fine when run on REPL (shell). But when I run it*
> *as a script, i get following error:*
>
> Traceback (most recent call last):
>   File "2.py", line 10, in 
> _sum=sum([n for n in itertools.takewhile(lambda x: x < 400, fib)])
> TypeError: 'int' object is not callable
>
>
>  Python version: 2.7.3
>
> Is there a bug in Python or am I missing something? Why does this only work
> in REPL
> and not as shell script?
>
> Thanks for help.
>
> Cheers,
> Anant
> ___
> BangPypers mailing list
> BangPypers@python.org
> https://mail.python.org/mailman/listinfo/bangpypers
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] BangPypers Digest, Vol 74, Issue 3

2013-10-23 Thread Dhananjay Nene
On Thu, Oct 3, 2013 at 2:02 PM, Aditya Laghate  wrote:
> On Thu, Oct 03, 2013 at 01:18:24PM +0530, Dhananjay Nene wrote:
>> >
>> Its in the downloaded tar.gz. You'll find the jar in lib/src
>> Besides the community edition clearly mentions "Free, open-source,
>> Apache 2 license"
>
> I had downloaded the OS X version of PyCharm. Looked into the lib/src
> folder and found three files (OS X version), viz:
> - pycharm-openapi-src.zip
> - pycharm-pydev-src.zip
> - trove4j_src.jar
>
> None of them have the entire source code the PyCharm IDE.
>
> I don't know what is available in the linux package.
>
> btw, pycharm.jar is about 74 mb, as against the total of the above three
> files in the src folder is 897 kb.
>
> Did a google search for 'source code pycharm', found a link to a blog
> post[1]. One of the comments was asking for the link of the source code,
> which was answered by "The source code of PyCharm CE will be available
> in the intellij-community repo on GitHub under Apache 2 license in a few
> days."
>
> So, I guess that solves my question on the source code.

Topical update :
http://blog.jetbrains.com/pycharm/2013/10/pycharm-3-0-community-edition-source-code-now-available/
>
> Links:
> 1:
> http://blog.jetbrains.com/pycharm/2013/09/jetbrains-delights-the-python-community-with-a-free-edition-of-its-famous-ide-pycharm-3-0/
>
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Object Oriented Programming in python

2013-10-22 Thread Dhananjay Nene
Am going to sign out of this discussion. It would not be correct to
say it is reaching the point of diminishing returns. In fact for
myself it has turned more interesting. But its turned a bit esoteric.
Have been doing up some more reading and I drew a few conclusions for
myself

* Terms don't mean the same across languages. In fact they may not
even mean the same within programmers of the same language. (eg.
metaclasses and
http://stackoverflow.com/questions/2676007/what-is-rubys-analog-to-python-metaclasses
)
* I think the semantics need to be evaluated in the context of what
capabilities are imparted. Incidentally I got much more confused about
metaclasses in other langs, though I'm going to probably not continue
with seeking more there at the moment. But I think my comfort persists
that Python has the necessary constructs to support various usecases I
could think of, and thats good enough for the moment. Much of the
runtime capability enhancement is available via classes and
construction time via metaclasses (the point Saager was driving). I
think I got that. These are powerful tools at a programmers disposal.
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Object Oriented Programming in python

2013-10-22 Thread Dhananjay Nene
On Mon, Oct 21, 2013 at 11:40 PM, Saager Mhatre  wrote:
> On Mon, Oct 21, 2013 at 7:11 PM, Dhananjay Nene 
> wrote:
>
>> Since you suggested that "Superior constructs
>> implemented inferiorly." and did not respond to the line which
>> wondered if that was based on syntactic or stylistic differences,
>
>
> I believe I responded to that statement by saying that the difference I
> note is neither syntactic, nor stylistic; it is semantic in that
> metaclasses behave very differently in other platforms by interacting with
> objects at run-time as opposed to just at compile-time. That simple
> difference makes them significantly more powerful to me.

I don't understand the distinction you make between compile time and runtime.

Here's one example
class FooMeta(type):
def __new__(cls, name, bases, classdict):
print("I just constructed a {}".format(cls))
if(getattr(FooMeta,"fubar",None)) :
classdict["rockband"] = "zeezeetop"
else:
classdict["rockband"] = "men at work"
result = type.__new__(cls, name, bases, dict(classdict))
return result

class Foo(metaclass=FooMeta):
def __init__(self,val):
self.val = val
def __str__(self):
return "Foo({})".format(self.val)

f = Foo(5)
print(f)
print(f.rockband)
print(type(f))
print(type(type(f)))


def bar(self) :
print(self.val)

def buz(self):
print("Darn, I'm buzzed now")

Foo.bar = bar
Foo.class_level_constant = 99
FooMeta.fubar = 987
FooMeta.buz = buz
f.bar()

print(f.class_level_constant)
print(type(f).fubar)
print(type(f).buz())
try :
print(f.fubar)
except Exception as e :
print("Ignoring an exception {}".format(e))

f2 = Foo(9)
print(f2)
print(f2.rockband)

class Bar(metaclass=FooMeta):
def __init__(self,val):
self.val = val
def __str__(self):
return "Bar({})".format(self.val)

bar = Bar(23)
print(bar)
print(bar.rockband)

I added both a method and a attribute to a class at runtime and was
able to use it via the instance. Let me stress once again - this was
not compile time, this was runtime.

Again when you suggest semantic differences, it is very unclear what
you are specifically referring to.

To be clear in the above scenario, the type of "f" is "Foo", and any
modifcations to "Foo" percolate down to f as appropriate. There is a
fair degree of capabilities one has in being able to modify Foo at
runtime.

Are you getting confused between Foo and FooMeta ? FooMeta is really
the factory for Foo. To restate, the object is "f", the class is
"Foo", Foo is also an object whose class is FooMeta.

Note, I was not only able to add a attribute to Foo, I was also able
to do it to FooMeta

I was not just able to add an attribute to FooMeta, I was also able to
influence how it constructs classes next time a new one is declared
(eg. when Bar gets declared, fubar has been set, so the rockband
attribute gets set to "zeezeetop")

So frankly, when you say python does stuff at compile time, I don't
get it. Perhaps you are referring to the fact that the __new__ of the
metaclass gets called whenever a class is declared ? Maybe. But it is
hardly compile time.
>
>> I presumed that comment was based on one or two examples of scenarios
>> that you had run into where you found python metaprogramming /
>> metaclasses constraining in some particular way. Anyways it seems
>> there aren't any such examples I can elicit from a continuing
>> discussion.
>>
>
> Again, if we re-read the conversation so far (and I just did), I have been
> avoiding a discussion on metaprogramming as that has little to do with
> metaclasses in all the other platforms I mentioned. AFAICT, only Python
> conflates these two[*], YMMV. Any examples of metaprogramming in
> Ruby/Groovy I provide will provide no value in demonstrating the
> capabilities of metaclasses therein.

> As for metaclasses, I find Python's implementation constraining
> specifically for the point I mentioned above in this very note. For a
> whirlwind tour of what Groovy's MetaClass has to offer try the Dynamic
> Groovy <http://groovy.codehaus.org/Dynamic+Groovy> section of the Groovy
> User Guide <http://groovy.codehaus.org/User+Guide>. I could give you more
> contrived examples, but that would only lead to a pissing match where you
> show me how X can be achieved in Python with P + Q - R. But, to really get
> a hang of these features I'll give you the same advice that several
> pythonistas (including yourself) gave me when I started with it and found
> things out of place- give Ruby/Groovy a shot, take them out for a spin
> (preferably a long drive) and then you

Re: [BangPypers] Object Oriented Programming in python

2013-10-21 Thread Dhananjay Nene
On Mon, Oct 21, 2013 at 11:46 PM, Saager Mhatre  wrote:
> On Fri, Oct 18, 2013 at 11:33 AM, Dhananjay Nene
> wrote:
>
>> On Tue, Oct 15, 2013 at 2:33 PM, Dhruv Baldawa 
>> wrote:
>> > Also take a look at videos by Raymond Hettinger
>> > http://pyvideo.org/speaker/138/raymond-hettinger
>>
>> I have some serious reservations on how OO is packaged here. Wanted to
>> post a detailed and articulate opinion, but it is going to take a
>> while since I am not getting the time to do so, but will get there
>> eventually. In the meanwhile I do want to offer an as yet
>> unsubstantiated opinion that some of these are not necessarily the
>> best references on the topic.
>>
>
> Dammit, had meant to reply to this one earlier, but got completely
> side-tracked by our metaclasses discusison.
>
> I got a similar vibe when I sat through Raymond's talks at PyCon India
> 2011. A TWer friend and I were watching the talks together and our WTF
> counters turned quite a bit and usually at the same time.
>
> Like Dhananjay said, any response is going to have to be pretty detailed
> and I'm too tired and sleep now. :|

Since I had earlier stated that I would be responding on this thread,
should state that I did write out a response. Turned out to be a long
and detailed response. Given the tone of what I wrote, I decided to
not post it here (did mail it raymond though).

Dhananjay
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Object Oriented Programming in python

2013-10-21 Thread Dhananjay Nene
On Mon, Oct 21, 2013 at 6:42 PM, Saager Mhatre  wrote:
> On Oct 21, 2013 3:21 PM, "Dhananjay Nene"  wrote:
>>
>> On Mon, Oct 21, 2013 at 3:02 PM, Saager Mhatre 
> wrote:
>> > On Oct 21, 2013 12:09 PM, "Dhananjay Nene" 
> wrote:
>> >>
>> >> On Mon, Oct 21, 2013 at 11:53 AM, Saager Mhatre <
> saager.mha...@gmail.com>
>> > wrote:
>> >> > On Oct 21, 2013 11:39 AM, "Dhananjay Nene" 
>> > wrote:
>> >> >>
>> >> >> On Mon, Oct 21, 2013 at 10:55 AM, Saager Mhatre <
>> > saager.mha...@gmail.com>
>> >> > wrote:
>> >> >>
>> >> >> > Which generally lead to poor (or at least poorer) abstractions;
> but I
>> >> > digress.
>> >> >>
>> >> >> Leaky ??  :)
>> >> >
>> >> > For the most part, yes.
>> >> >
>> >> >> >
>> >> >> >> I think OOPs concepts across a number of languages are quite
>> > different.
>> >> >> >> You will find python having superior constructs eg. metaclasses
> etc.
>> >> > if you were comparing Python OOP to C++/Java.
>> >> >> >
>> >> >> > Superior constructs implemented inferiorly. Meteclasses are much^3
>> > more
>> >> > powerful in Groovy, Ruby and SmallTalk (where some would claim Python
>> >> > borrowed them from; but that's just not true.)
>> >> >>
>> >> >> I wonder if you meant syntactically/stylistically. Would be keen to
>> >> > learn, if there are examples where ruby / groovy (I don't know much
>> > about
>> >> > smalltalk) allow things that python does not.
>> >> >
>> >> > Semantically! MetaClasses are a much more powerful construct in those
>> >> > languages.
>> >>
>> >> I'm specifically looking for evidence to support that. And I suspect
>> >> it might be out there to be found , just that I haven't so far. One of
>> >> my early attempts was documented here
>> >>
>> >
> http://blog.dhananjaynene.com/2010/01/dynamically-adding-methods-with-metaprogramming-ruby-and-python/
>> >>
>> >
>> > Don't look for metaprogramming, you'll end up with a lot of ancillary
>> > stuff. Look for metaclasses or metaobject protocol.
>>
>> Is there an example or two which demonstrates ruby can do things via
>> metaprogramming / metaclasses / metaobject protocol that python cannot
>> ? Something more than syntactic or stylistic differences.
>>
>> It wouldn't be normally fair for me to ask for that and I should go
>> hunt it down myself, but given the earlier assertions made in this
>> thread, i believe it is reasonable in this case.
>
> Sorry, on GPRS, so hunting for videos will kill my phone & tablet. Add
> 'Yehuda Katz' or 'wykatz' in your queries; methinks he's done a bunch of
> talks about this. There was also one from the RuPy conference, but I don't
> remember if it dealt with metaprogramming per se. But you should be able to
> find some videos. That said, it might be hard to find comparisons as the
> Ruby folk usually just outright ignore Python, the Groovy folk are too busy
> embettering Groovy and the SmallTalk folk are in a cave somewhere that I
> know not of!

Still doesn't help me. Since you suggested that "Superior constructs
implemented inferiorly." and did not respond to the line which
wondered if that was based on syntactic or stylistic differences, I
presumed that comment was based on one or two examples of scenarios
that you had run into where you found python metaprogramming /
metaclasses constraining in some particular way. Anyways it seems
there aren't any such examples I can elicit from a continuing
discussion.
>
> Also, just to clarify, metaprogramming is distinct from metaclasses and
> presence of one in a platform is not essential to the presence of the
> other. Metaprogramming is more to do with code that writes, unwrites or
> modifies more code; while metaclasses are about some seriously dynamic
> dispatch.
>
> Incidentally, that is another place Python's implementation departs from
> metaclasses in other languages. Where Python provides metaclasses as a hook
> to rewrite class internals/implementation before it becomes available to
> other code, other platforms attach metaclasses to classes (or objects, in
> some cases) at runtime to control/alter the way messages 

Re: [BangPypers] Object Oriented Programming in python

2013-10-21 Thread Dhananjay Nene
On Mon, Oct 21, 2013 at 3:02 PM, Saager Mhatre  wrote:
> On Oct 21, 2013 12:09 PM, "Dhananjay Nene"  wrote:
>>
>> On Mon, Oct 21, 2013 at 11:53 AM, Saager Mhatre 
> wrote:
>> > On Oct 21, 2013 11:39 AM, "Dhananjay Nene" 
> wrote:
>> >>
>> >> On Mon, Oct 21, 2013 at 10:55 AM, Saager Mhatre <
> saager.mha...@gmail.com>
>> > wrote:
>> >>
>> >> > Which generally lead to poor (or at least poorer) abstractions; but I
>> > digress.
>> >>
>> >> Leaky ??  :)
>> >
>> > For the most part, yes.
>> >
>> >> >
>> >> >> I think OOPs concepts across a number of languages are quite
> different.
>> >> >> You will find python having superior constructs eg. metaclasses etc.
>> > if you were comparing Python OOP to C++/Java.
>> >> >
>> >> > Superior constructs implemented inferiorly. Meteclasses are much^3
> more
>> > powerful in Groovy, Ruby and SmallTalk (where some would claim Python
>> > borrowed them from; but that's just not true.)
>> >>
>> >> I wonder if you meant syntactically/stylistically. Would be keen to
>> > learn, if there are examples where ruby / groovy (I don't know much
> about
>> > smalltalk) allow things that python does not.
>> >
>> > Semantically! MetaClasses are a much more powerful construct in those
>> > languages.
>>
>> I'm specifically looking for evidence to support that. And I suspect
>> it might be out there to be found , just that I haven't so far. One of
>> my early attempts was documented here
>>
> http://blog.dhananjaynene.com/2010/01/dynamically-adding-methods-with-metaprogramming-ruby-and-python/
>>
>
> Don't look for metaprogramming, you'll end up with a lot of ancillary
> stuff. Look for metaclasses or metaobject protocol.

Is there an example or two which demonstrates ruby can do things via
metaprogramming / metaclasses / metaobject protocol that python cannot
? Something more than syntactic or stylistic differences.

It wouldn't be normally fair for me to ask for that and I should go
hunt it down myself, but given the earlier assertions made in this
thread, i believe it is reasonable in this case.
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Object Oriented Programming in python

2013-10-20 Thread Dhananjay Nene
On Mon, Oct 21, 2013 at 11:53 AM, Saager Mhatre  wrote:
> On Oct 21, 2013 11:39 AM, "Dhananjay Nene"  wrote:
>>
>> On Mon, Oct 21, 2013 at 10:55 AM, Saager Mhatre 
> wrote:
>>
>> > Which generally lead to poor (or at least poorer) abstractions; but I
> digress.
>>
>> Leaky ??  :)
>
> For the most part, yes.
>
>> >
>> >> I think OOPs concepts across a number of languages are quite different.
>> >> You will find python having superior constructs eg. metaclasses etc.
> if you were comparing Python OOP to C++/Java.
>> >
>> > Superior constructs implemented inferiorly. Meteclasses are much^3 more
> powerful in Groovy, Ruby and SmallTalk (where some would claim Python
> borrowed them from; but that's just not true.)
>>
>> I wonder if you meant syntactically/stylistically. Would be keen to
> learn, if there are examples where ruby / groovy (I don't know much about
> smalltalk) allow things that python does not.
>
> Semantically! MetaClasses are a much more powerful construct in those
> languages.

I'm specifically looking for evidence to support that. And I suspect
it might be out there to be found , just that I haven't so far. One of
my early attempts was documented here
http://blog.dhananjaynene.com/2010/01/dynamically-adding-methods-with-metaprogramming-ruby-and-python/

> They form the core of the MetaObjectProtocol which governs the
> dynamic dispatch of messages/methods. Modifications to MetaClasses
> percolate to Classes and objects they are associated with and such
> modifications as well as MetaClass associations can be dynamic as well as
> temporary; leading to some seriously powerful use cases.

The "temporary" is intriguing. I don't quite yet understand what it
means .. does it mean you could say temporarily add a method and then
take it out later (or some other similar capability) ?
>
> That's pretty much what always foiled my attempts at understanding Python
> MetaClasses, I was looking for power where there was none to find. The best
> comparison I could find was to Groovy's Compile time AST transforms, but
> even those are even more powerful as they drop down a level of abstraction
> and hand you the AST for the an rated element.

AST transforms are sort of feasible but rarely done, and not sure if I
would like to be a part of such an exercise. They kick in via the
import hook, thus you build the AST on your own, thankfully python
does provide AST helpers. Googling for python macros will show some
such valiant attempts - https://github.com/lihaoyi/macropy or
https://code.google.com/p/metapython/wiki/Tutorial
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Object Oriented Programming in python

2013-10-20 Thread Dhananjay Nene
On Mon, Oct 21, 2013 at 10:55 AM, Saager Mhatre  wrote:
> On Oct 15, 2013 4:10 AM, "Dhananjay Nene"  wrote:
>>
>> On Tue, Oct 15, 2013 at 1:46 AM, Pranav Raj 
> wrote:
>> > Hi fellow python lovers,
>> >
>> > I wanted to do OOPS programming in python, but i just found out that
> there are no private variables in python. Does anyone know why python
> classes have no private variables and why python's OOPS concept are a lot
> different from other programming languages?
>>
>> http://stackoverflow.com/a/1641236/12754
>>
>
> Meh! Weak arguments, strongly made.
>
>> I am not sure what the history or reasoning was. But encapsulation is not
> considered particularly desirable or useful.
>>
>
> Which generally lead to poor (or at least poorer) abstractions; but I
> digress.

Leaky ??  :)
>
>> I think OOPs concepts across a number of languages are quite different.
> You will find python having superior constructs eg. metaclasses etc. if you
> were comparing Python OOP to C++/Java.
>
> Superior constructs implemented inferiorly. Meteclasses are much^3 more
> powerful in Groovy, Ruby and SmallTalk (where some would claim Python
> borrowed them from; but that's just not true.)

I wonder if you meant syntactically/stylistically. Would be keen to
learn, if there are examples where ruby / groovy (I don't know much
about smalltalk) allow things that python does not.
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Object Oriented Programming in python

2013-10-20 Thread Dhananjay Nene
On Fri, Oct 18, 2013 at 5:58 PM, s|s  wrote:
> On Fri, Oct 18, 2013 at 11:31 AM, Dhananjay Nene
> wrote:
>
>> On Tue, Oct 15, 2013 at 4:44 PM, s|s  wrote:
>> > Hi Pranav,
>> >
>> > I would pose a counter question regarding object oriented programming.
>> How
>> > did you learn OOP concepts? I am assuming like most of us, probably
>> through
>> > a C++ or Java course. These courses ingrain a certain expectation of what
>> > OOP should "look like". Which to me seems to be a dis-service to
>> > underpinnings of Object Oriented Paradigm itself.
>>
>> How so ?
>>
>>
> To me, OO Paradigm is not about having a keyword **class** in a language
> but the sense of constructing an ensemble of programmed units which makes
> sense together. To illustrate, GObject in Gtk+ is as much a first rate OO
> implementation as any other. In fact some of the new breed of languages
> like Golang do not follow conventional structure of OOP popularized by C++
> and Java.

Not really sure what you mean by constructing an ensemble of
programmed units which makes sense together. In a lay reading that to
me is what module systems are for.

I haven't looked at GObject. So can't analyse the rest of what you
say. But an interesting definition for me always has been "OP to me
means only messaging, local retention and protection and hiding of
state-process, and extreme late-binding of all things." - Dr. Alan Kay
(http://userpage.fu-berlin.de/~ram/pub/pub_jf47ht81Ht/doc_kay_oop_en).
Some commentators believe open recursion is necessary (though I myself
haven't subscribed to that yet).

>> >
>> > Python implements OOP differently from imperative languages of C family
>> > like C++ and Java. The reason, I think is C++ and Java are very much
>> driven
>> > towards machine code efficiency whereas Python is very much about
>> > developers productive.
>>
>> Can you cite an example ?
>>
>>
> Lets look at integer as an example in Python (int)
>
> class int(object)
>int(x[, base]) -> integer
>
> which is unlike java where int is a "basic" non-class type. An explicit
> upgrade to **Integer** class is required to use OOP features. This is done
> with sole purpose of machine efficiency.

Ahh, the primitives. But in most cases primitives have their OO
counterparts, so you can pick and choose. Fair enough. Java in the
late 1990s and early 2000s was very very very slow. A lot of it had to
do with how it used memory, the garbage collections the late binding
as compared to C++, the JVM etc. etc. It was later that the JVM got
well tuned enough for the performance it shows off now. I don't think
I would ever imagine java itself was "ever" designed towards machine
code efficiency .. though it did work out that way eventually.

>
>
>> >  To this end Python developers must have thought of
>> > data hiding as not an important language goal.
>>
>> The traceability of the above "to this end" to "data hiding as not an
>> important language goal" is very unclear. Could you clarify
>>
>>
> Python, to me, seems to lean towards reducing development time. To "this
> end" simple implementation is used instead of grand frameworks. Data hiding
> with public, private, protected is just one of these frames. Yes again I am
> critiquing Java.

Hmm ... there's boiler plate and there's frames of additional
capabilities. I think Java and C++ suffered from more boilerplate,
which was co-incidental. I can't imagine how just prefixing with a
public / private / ... reduces developer productivity - in fact by
promoting information hiding it can help hunt down bugs faster. And
modern languages like Scala don't require you to do getX / setX - they
can give you that capability - even switching from attributes to
functions and back with a simple change of a word. So, as yet I remain
unconvinced about the link between data hiding and developer
productivity.

>> > Mind you Python does allow data hiding through slots but it is not as
>> > straight forward as C++ or Java.

How so ?

class Foo(object):
__slots__ = ["val"]
def __init__(self, val) :
self.val = val


f = Foo(5)
print(f.val)

Dhananjay
e
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Object Oriented Programming in python

2013-10-17 Thread Dhananjay Nene
On Tue, Oct 15, 2013 at 4:44 PM, s|s  wrote:
> Hi Pranav,
>
> I would pose a counter question regarding object oriented programming. How
> did you learn OOP concepts? I am assuming like most of us, probably through
> a C++ or Java course. These courses ingrain a certain expectation of what
> OOP should "look like". Which to me seems to be a dis-service to
> underpinnings of Object Oriented Paradigm itself.

How so ?

>
> Python implements OOP differently from imperative languages of C family
> like C++ and Java. The reason, I think is C++ and Java are very much driven
> towards machine code efficiency whereas Python is very much about
> developers productive.

Can you cite an example ?

>  To this end Python developers must have thought of
> data hiding as not an important language goal.

The traceability of the above "to this end" to "data hiding as not an
important language goal" is very unclear. Could you clarify

>
> Mind you Python does allow data hiding through slots but it is not as
> straight forward as C++ or Java.
>
> regards
>
>
>
>
>
> On Tue, Oct 15, 2013 at 2:33 PM, Dhruv Baldawa wrote:
>
>> Also take a look at videos by Raymond Hettinger
>> http://pyvideo.org/speaker/138/raymond-hettinger
>>
>> --
>> Dhruv Baldawa
>> (http://www.dhruvb.com)
>>
>>
>> On Tue, Oct 15, 2013 at 1:58 PM, T S KAMATH  wrote:
>>
>> > Dear Pranav,
>> >
>> > The following video would get you understand better
>> > http://www.sagemath.org/help-video.html check for Google I_O 2008 -
>> > Painless Python Part 1 & 2
>> >
>> > Srikanth
>> >
>> > On 14-Oct-2013, at 10:16 PM, Pranav Raj  wrote:
>> >
>> > Hi fellow python lovers,
>> >
>> > I wanted to do OOPS programming in python, but i just found out that
>> there
>> > are no private variables in python. Does anyone know why python classes
>> > have no private variables and why python's OOPS concept are a lot
>> different
>> > from other programming languages?
>> >
>> >
>> > thank you, Pranav Raj
>> >
>> > ___
>> > BangPypers mailing list
>> > BangPypers@python.org
>> > https://mail.python.org/mailman/listinfo/bangpypers
>> >
>> > ___
>> > BangPypers mailing list
>> > BangPypers@python.org
>> > https://mail.python.org/mailman/listinfo/bangpypers
>> >
>> ___
>> BangPypers mailing list
>> BangPypers@python.org
>> https://mail.python.org/mailman/listinfo/bangpypers
>>
>
>
>
> --
> Supreet Sethi
> Ph UK: +447859172473
> Ph IN: +919811143517
> Ph Skype: d_j_i_n_n
> Profile: http://www.google.com/profiles/supreet.sethi
> Twt: http://twitter.com/djinn
> ___
> BangPypers mailing list
> BangPypers@python.org
> https://mail.python.org/mailman/listinfo/bangpypers



-- 
--
http://blog.dhananjaynene.com twitter: @dnene google plus:
http://gplus.to/dhananjaynene
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Object Oriented Programming in python

2013-10-17 Thread Dhananjay Nene
On Tue, Oct 15, 2013 at 2:33 PM, Dhruv Baldawa  wrote:
> Also take a look at videos by Raymond Hettinger
> http://pyvideo.org/speaker/138/raymond-hettinger

I have some serious reservations on how OO is packaged here. Wanted to
post a detailed and articulate opinion, but it is going to take a
while since I am not getting the time to do so, but will get there
eventually. In the meanwhile I do want to offer an as yet
unsubstantiated opinion that some of these are not necessarily the
best references on the topic.

>
> --
> Dhruv Baldawa
> (http://www.dhruvb.com)
>
>
> On Tue, Oct 15, 2013 at 1:58 PM, T S KAMATH  wrote:
>
>> Dear Pranav,
>>
>> The following video would get you understand better
>> http://www.sagemath.org/help-video.html check for Google I_O 2008 -
>> Painless Python Part 1 & 2
>>
>> Srikanth
>>
>> On 14-Oct-2013, at 10:16 PM, Pranav Raj  wrote:
>>
>> Hi fellow python lovers,
>>
>> I wanted to do OOPS programming in python, but i just found out that there
>> are no private variables in python. Does anyone know why python classes
>> have no private variables and why python's OOPS concept are a lot different
>> from other programming languages?
>>
>>
>> thank you, Pranav Raj
>>
>> ___
>> BangPypers mailing list
>> BangPypers@python.org
>> https://mail.python.org/mailman/listinfo/bangpypers
>>
>> ___
>> BangPypers mailing list
>> BangPypers@python.org
>> https://mail.python.org/mailman/listinfo/bangpypers
>>
> ___
> BangPypers mailing list
> BangPypers@python.org
> https://mail.python.org/mailman/listinfo/bangpypers



-- 
--
http://blog.dhananjaynene.com twitter: @dnene google plus:
http://gplus.to/dhananjaynene
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] First python interview

2013-10-14 Thread Dhananjay Nene
On Tue, Oct 15, 2013 at 11:25 AM, Navin Kabra  wrote:
> If I were interviewing you, I would not really be checking your python
> knowledge (unless you claimed to be good in Python in your resume). I
> would really check how good you are in Java (your primary language), and
> your general programming and problem solving skills.

+1. I always prefer to ask someone what he is really good at and
assuming one of the interviewing team has good exposure to that go
really deep.

I know this is not an answer to your question, but is more an aside -
interviewing someone who claims limited knowledge or exposure to
something is more often than not a futile exercise unless the
candidate turns out really strong. If the candidate cannot answer the
questions well, it is very hard to reach any reasonable assessment.

So if I was the interviewer, I would really not worry about how much
python you knew, but instead go after your java skills because thats
what you've primarily worked on, and its your java knowledge that
would be the decisive factor.
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Object Oriented Programming in python

2013-10-14 Thread Dhananjay Nene
On Tue, Oct 15, 2013 at 1:46 AM, Pranav Raj  wrote:
> Hi fellow python lovers,
>
> I wanted to do OOPS programming in python, but i just found out that there 
> are no private variables in python. Does anyone know why python classes have 
> no private variables and why python's OOPS concept are a lot different from 
> other programming languages?

http://stackoverflow.com/a/1641236/12754

I am not sure what the history or reasoning was. But encapsulation is
not considered particularly desirable or useful.

I think OOPs concepts across a number of languages are quite
different. You will find python having superior constructs eg.
metaclasses etc. if you were comparing Python OOP to C++/Java. Just
start using the features and over a period of time you will gain a
reasonable understanding of the subtleties.
>
>
> thank you, Pranav Raj
>
> ___
> BangPypers mailing list
> BangPypers@python.org
> https://mail.python.org/mailman/listinfo/bangpypers



-- 
--
http://blog.dhananjaynene.com twitter: @dnene google plus:
http://gplus.to/dhananjaynene
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] the pyCharm from Jetbrains has been opensourced i.e. its free now!

2013-10-04 Thread Dhananjay Nene
On Fri, Oct 4, 2013 at 4:30 PM, Saager Mhatre  wrote:
> On Oct 3, 2013 9:40 AM, "Dhananjay Nene"  wrote:
>>
>> On Thu, Oct 3, 2013 at 8:19 AM, Mandar Vaze / मंदार वझे
>>  wrote:
>> > Downloaded it, bit not used it, yet. (still using vim)
>> > But I have heard so much praise about pycharm from everyone in every
>> > (python related) forum that I can't wait to use it
>>
>> Any links to the discussions?
>
> http://andrewbrookins.com/tech/one-year-later-an-epic-review-of-pycharm-2-7-from-a-vim-users-perspective/
>
> That's the most comprehensive one I've read.
Nice review. Thx.
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] BangPypers Digest, Vol 74, Issue 3

2013-10-03 Thread Dhananjay Nene
On Thu, Oct 3, 2013 at 1:01 PM, Aditya Laghate  wrote:
> On Thu, Oct 03, 2013 at 12:24:27PM +0530, Venu Murthy wrote:
>> As far as I know, this is permanent move Rahul, Pycharm is going to have
>> two versions, the basic one is opensourced for ever and then there one with
>> more bells and whistles which is licensed.
>
> It is opensourced or just given out free? I did not see any link to the
> source code.
>
Its in the downloaded tar.gz. You'll find the jar in lib/src

Besides the community edition clearly mentions "Free, open-source,
Apache 2 license"


> Cheers
> Aditya
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] the pyCharm from Jetbrains has been opensourced i.e. its free now!

2013-10-02 Thread Dhananjay Nene
On Thu, Oct 3, 2013 at 8:19 AM, Mandar Vaze / मंदार वझे
 wrote:
> Downloaded it, bit not used it, yet. (still using vim)
> But I have heard so much praise about pycharm from everyone in every
> (python related) forum that I can't wait to use it

Any links to the discussions?
>
> -Mandar
>
>
> On Tue, Oct 1, 2013 at 3:21 PM, Venu Murthy 
> wrote:
>
>> Hello Comrades!
>>
>> I am happy to share with the joyful news that my favourite language -
>> Python and it's one of the best IDE - pycharm has been opensourced and can
>> be downloaded from this link
>>
>> http://www.jetbrains.com/pycharm/
>>
>> Enjoy using it and writing code that is beautiful!
>>
>>
>> Best regards,
>> Venu
>>
>> ---
>> *"Excellence is never an accident. It is always the result of high
>> intention, sincere effort, and intelligent execution -- Aristotle*
>> ___
>> BangPypers mailing list
>> BangPypers@python.org
>> https://mail.python.org/mailman/listinfo/bangpypers
>>
> ___
> BangPypers mailing list
> BangPypers@python.org
> https://mail.python.org/mailman/listinfo/bangpypers



-- 
--
http://blog.dhananjaynene.com twitter: @dnene google plus:
http://gplus.to/dhananjaynene
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Fwd: How to do clustering in python.

2013-09-30 Thread Dhananjay Nene
On Mon, Sep 30, 2013 at 4:37 PM, uday sankar  wrote:
> Hi,
>
> I have a engine built in python. I implemented a webserver in python it
> will listen to the request sent and will responsed back with the necessary
> result. Now the problem is that I am able to run this engine in one node,
> if this node goes down engine will go down and we will not be able to run
> the application. Is there any way if one node goes down other node will
> process the request. How we can implement clustering and load balancing in
> python?. Please guide me how we can do this.

The most important question you need to answer is is your engine
stateful ? Does it store any information in global, module,
application level variables that a failover node will need in order to
successfully process a request. Note: storing valid session ids or
other information against a session or any such information within a
process memory or in a storage subsystem (eg. local file system) that
is not accessible to other engine classifies as stateful.

Clustering stateless services is easy. Stateful ones isn't. The
starting point would be to classify your system, and if feasible make
it stateless.
>
> Regards
>  Uday
> ___
> BangPypers mailing list
> BangPypers@python.org
> https://mail.python.org/mailman/listinfo/bangpypers



-- 
--
http://blog.dhananjaynene.com twitter: @dnene google plus:
http://gplus.to/dhananjaynene
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] What are you using for developing desktop GUIs?

2013-09-27 Thread Dhananjay Nene
On Fri, Sep 27, 2013 at 10:04 PM, Sriram Karra  wrote:
> On Fri, Sep 27, 2013 at 8:55 PM, Dhananjay Nene 
> wrote:
>
>
>>
>> In most cases I find users want a installer. Basically just point and
>> click. So if there is no installer where a user selects a install
>> directory and presses a button called install (and perhaps a couple of
>> app specific items), there's a huge support cost due to users being
>> not able to install apps successfully. I presume what you mean by a
>> standard python application, but if it means a user having to install
>> python if not installed, create a virtualenv, run pip install, create
>> desktop shortcuts to start / stop servers, in most cases it is very
>> very unlikely to work with lay end users. (Much of this applies to
>> desktop based apps as well).
>>
>
>
> None of that pip/virtualenv stuff is required. There are tools available
> that can convert a python application into a native executable - py2exe for
> windows, and py2app mac, for. e.g. Once you have the native, self contained
> executables, they can be wrapped into a msi or dmg package like any other
> native application.
>
Ok. I haven't tried them myself ever :( Though usually there's more
required during installation (eg. where does the program get installed
what directory should data go to etc. Not sure if these get addressed
by these. Perhaps there are standard python ways to deal with all such
issues that I am unaware of.

> When I said the embedded webapp is like any other python application I
> wanted to say that the above packaging options area available for a webapp
> as well - because all the code is pure python and is completely self
> contained. I hope that was clear.
>
It wasn't to me, but that could be my shortcoming.
>
>>
>> > I have not done this. The invocation is explicitly on demand. It is
>> trivial
>> > to protect against multiple invocations of the program, and to support a
>> > 'Exit Program' action on the front end that will shut down the web
>> server.
>>
>> Ok. I've never tried this. Perhaps it is trivial. But shutting down a
>> server even as the controller is processing a request may
>> "potentially" be hard. Perhaps one could set a timeout to allow the
>> request to complete and then trigger a shutdown.
>>
>
>
> You should definitely fire up the PRS program below, and look at how the
> shutdown action is triggered and handled in the controller. My guess is you
> will find it very straightforward.
>
Ok.
>
>
>> >
>> > It is as easy as any other program. To give you an example, take a look
>> at
>> > a sample: https://github.com/skarra/PRS
>>
>> Ok, I am not particularly familiar with how the windows integration
>> works so am not able to quickly figure it out.
>>
>
>
> There is no windows integration of any sort here. If you are using python
> on Windows already, just clone that repo and double click on the file
> called prs.pyw -> that is all you need to start the program.
>
Haven't used windows in ages :(
>
>
>> The difficulty is that the user may have multiple versions of python
>> installed and/or his default version may not be compatible with the
>> one you want. Plus virtualenv specific for your app will need to be
>> configured.
>>
>
>
> As explained above, the py2exe / py2app type programs are able to make
> completely self contained native executables.
>
>
>>
>> You did mention reusable code. Service integration, system tray
>> integration etc. are all cross platform issues that are introduced
>> when you install a web app on a desktop
>
>
>
> I do not know if there are any cross-platform python libraries that take
> care of issues such as this. I will only say that the webapp approach to
> cross-platform UI programming does not put you at any greater disadvantage
> than using a UI toolkit. Remember the original topic was discussion on UI
> toolkits!
>
My point was that service and system tray integration are usually not
required for desktop apps. But if your webapp is going to be
explicitly started and stopped by user, it may not be required by such
webapps as well.
>
> You also open yourself up to cross browser portability issues. Also
>> having to deal with older vs newer browsers (IE6??). Which if you were
>> using a standard widget library wouldn't have worried you.
>>
>
>
> That is definitely very true. But in this day and age of html5 boilerplate,
> twitter bootstrap, jquery, etc. this particular problem can be considered
> well under control.
>
>
>>
>>

Re: [BangPypers] What are you using for developing desktop GUIs?

2013-09-27 Thread Dhananjay Nene
On Fri, Sep 27, 2013 at 7:35 PM, Noufal Ibrahim  wrote:
> Sriram Karra  writes:
>
>
> [...]
>
>> Isn't that the case with any cross-platform toolkit - if the intent is
>> to be cross platform?
>
> Yes but going inside the browser is more of a sacrifice than other
> approaches. I mean, just launching the app will start a web server and
> then a browser and take you inside there to do a task that should be
> done locally. You don't get any of the native widgets (which you would
> if you something like wx) and none of the behaviour you've configured
> for local GUI apps.
>
> I guess YMMV but if a local app launches a web server and a browser to
> get things done, it's a deal breaker for me.
>
> [...]
>
>> Can you give some specific examples of what is possible in a Python
>> app using a cross platform GUI toolkit and NOT possible with a webapp
>> architecture when the web server and the browser are running on the
>> same machine?

Event loops and asynchronous updates on the UI are much easier to
handle within a desktop app than writing JS+AJAX imo.
Also Rich UIs where you have lots of panels and components and based
on data entered in one you want to enable / disable or modify other
panels is much easier handled in desktop UIs since they have a easier
event propagation and listener models. The same can be done in
Javascript, but can get a lot more painful.
On both the points, YMMV


> Hmmm. That's a good point. You're planning to use the HTML+CSS+JS purely
> for presentation (instead of a gui toolkit). I suppose most things can
> be done although perhaps using a combination of HTML/CSS/JS for UI and
> then sending messages to the backend and doing the work there. This
> sounds convoluted to me and I think it's overkill for a web app.
>
> As for things not possible with a web app that work fine with a GUI, I
> can think of games and other resource demanding applications but those
> are not particularly cross platform anyway so you're right.
>
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] What are you using for developing desktop GUIs?

2013-09-27 Thread Dhananjay Nene
On Fri, Sep 27, 2013 at 7:21 PM, Sriram Karra  wrote:
> On Fri, Sep 27, 2013 at 7:06 PM, Dhananjay Nene 
> wrote:
>
>>
Overall background: I write desktop apps but not in python, I do write
the backends in python. So my desktop awareness is more generic. I did
try wxPython years ago but never took it to reasonable stage and not
to production either.

>> a) What are sample installers one could use to install web based apps
>> on user's machine (users more often than not use simple wizards to
>> install apps)
>>
>
> It is a standard python application with a web server included - the server
> and client are on the same machine, that is all. So there are no special
> requirements, per se.

In most cases I find users want a installer. Basically just point and
click. So if there is no installer where a user selects a install
directory and presses a button called install (and perhaps a couple of
app specific items), there's a huge support cost due to users being
not able to install apps successfully. I presume what you mean by a
standard python application, but if it means a user having to install
python if not installed, create a virtualenv, run pip install, create
desktop shortcuts to start / stop servers, in most cases it is very
very unlikely to work with lay end users. (Much of this applies to
desktop based apps as well).
>
> b) Do you start up app by default ? If so can the installer integrate
>> into the native service system to start / stop the webapp?
>>
>
> I have not done this. The invocation is explicitly on demand. It is trivial
> to protect against multiple invocations of the program, and to support a
> 'Exit Program' action on the front end that will shut down the web server.

Ok. I've never tried this. Perhaps it is trivial. But shutting down a
server even as the controller is processing a request may
"potentially" be hard. Perhaps one could set a timeout to allow the
request to complete and then trigger a shutdown.
>
>
>> c) If you do not start app by default, how easy is it for users to
>> start and stop the webapp.
>>
>
> It is as easy as any other program. To give you an example, take a look at
> a sample: https://github.com/skarra/PRS

Ok, I am not particularly familiar with how the windows integration
works so am not able to quickly figure it out.
>
> Here I require that the user have python installed. The main python driver
> is called prs.pyw (for Windows) - the user has to double click on that
> file. For use on other systems I have a symlink the py file to the pyw.

The difficulty is that the user may have multiple versions of python
installed and/or his default version may not be compatible with the
one you want. Plus virtualenv specific for your app will need to be
configured.
>
>
>> d) Do you offer any integration in the system tray to shut down the
>> app if the user is in a memory hungry situation and would prefer to
>> shutdown your app to conserve memory
>>
>
> I have not tried this. But I am sure the answer to such question lies in
> platform specific libraries. For e.g. on Windows Pywin32 can do wonders.
> But again, these issues have to be solved regardless of what widget library
> you use, or you go the tornado route.

You did mention reusable code. Service integration, system tray
integration etc. are all cross platform issues that are introduced
when you install a web app on a desktop (desktop apps usually do not
have these issues since they exit when user presses exit, and usually
always keep an application window open for the user to find the exit
button from. So there's still a few skills you need to pick up and in
this case they are platform specific (at least I am not aware of
platform neutral solutions)

You also open yourself up to cross browser portability issues. Also
having to deal with older vs newer browsers (IE6??). Which if you were
using a standard widget library wouldn't have worried you.

>
>
>> e) Do you undergo security audits ? If so, what issues come up in the
>> discussions that wouldn't have come up in pure desktop apps ?
>>
>
> I do not do this stuff commercially. So have not had to deal with this. But
> *again* - no one needs to even bother that this is a 'webapp' - the entire
> thing runs on your desktop and will work even without an internet
> connection.

At the minimum you have an open port. You probably need to restrict
traffic only from localhost. In addition you need to worry about SQL
injection, XSS, XSRF, and a bunch of other alphabet soup combinations.
Desktop apps don't need to worry about many of these (though they can
fall prey to some of these as well, its much harder to write an
insecure desktop app than an insecure webapp).

I don't mean to sugges

Re: [BangPypers] What are you using for developing desktop GUIs?

2013-09-27 Thread Dhananjay Nene
On Fri, Sep 27, 2013 at 6:52 PM, Sriram Karra  wrote:
> On Fri, Sep 27, 2013 at 2:19 AM, Shabda Raaj  wrote:
>
>> I am building my first desktop app with Python and I would like to get
>> recommendation on what toolkit to use.
>>
>> I am planning to use either PyGTK or PyQT.
>> (Are there anything else I should consider.)
>>
>
> I always write them as webapps - and ship them with embedded tornado web
> server. You can strip it down to bare minimum, or choose lighter weight
> 'frameworks' if you wish. There are plenty of advantages to this general
> approach:

a) What are sample installers one could use to install web based apps
on user's machine (users more often than not use simple wizards to
install apps)
b) Do you start up app by default ? If so can the installer integrate
into the native service system to start / stop the webapp ?
c) If you do not start app by default, how easy is it for users to
start and stop the webapp.
d) Do you offer any integration in the system tray to shut down the
app if the user is in a memory hungry situation and would prefer to
shutdown your app to conserve memory
e) Do you undergo security audits ? If so, what issues come up in the
discussions that wouldn't have come up in pure desktop apps ?

> a) your app will look the same across all your platforms (at least the best
> it can be) as the front end is html/css/js
>
> b) you don't have to learn a new widget library
>
> c) your are building reusable code and skills that you can carry across
> even programming languages. If you use mustache templates, for e.g., you
> can even reuse the templates wholesale in other projects written in ruby,
> for e.g.
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] What are you using for developing desktop GUIs?

2013-09-27 Thread Dhananjay Nene
On Fri, Sep 27, 2013 at 2:49 AM, Amber Jain  wrote:
> On Fri, Sep 27, 2013 at 2:25 AM, Bibhas  wrote:
>
>> I used Kivy a year back. Not sure of it's state now. You could look into
>> it once.
>>
>>
> +1 for Kivy (under active development). The same code runs unmodified on
> Linux, OSX, Windows, Android and iOS (ofcourse, if device in question does
> not has for instance multi-touch support, then corresponding features won't
> work; or work in some kind of fallback mode).
>
> Guido himself recommended Kivy (though he recommended it specifically for
> developing mobile apps in Python):
> https://twitter.com/gvanrossum/status/342145797770604545

Is kivy comparably good enough for desktop based development as
desktop focused toolkits are?
>
>
>> Shabda Raaj  wrote:
>> >I am building my first desktop app with Python and I would like to get
>> >recommendation on what toolkit to use.
>> >
>> >I am planning to use either PyGTK or PyQT.
>> >(Are there anything else I should consider.)
>> >
>> >I see a lot of outdated, unmaintained tutorials about these. I am
>> >looking
>> >for modern, opinionated tutorials/books about GUI programming for
>> >Python.
>>
>
> --
> Amber Jain
> i.amber.j...@gmail.com
> http://amberj.devio.us/
> ___
> BangPypers mailing list
> BangPypers@python.org
> https://mail.python.org/mailman/listinfo/bangpypers
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] (no subject)

2013-09-25 Thread Dhananjay Nene
On Wed, Sep 25, 2013 at 7:09 PM, Vineet Naik  wrote:
> On Tue, Sep 24, 2013 at 6:19 PM, Dhananjay Nene 
> wrote:
>
>> On Tue, Sep 24, 2013 at 6:11 PM, Dhananjay Nene
>>  wrote:
[..]
>>
>> which just trashed the ordering of an and followed by a plus followed by
>> an and.
>>
>
> This is a more serious problem particularly if the dict is required to be
> serialized back to xml.
= = =
TL;DR. Use domain rather than use cases for exploring data structures
especially where they can cause a lot of change later. Semantic
Consistency is important, don't treat it lightly. Impedance mismatch
can be fragile. If feasible, stay away.
= = =

You probably did not mean this literally, but interpreting it to be so
helps unravel a couple of interesting issues, since it attempts to
reach a judgement based on a use case and doesn't reflect on the
semantics of that data.

a) Do you design a data structure based on a use case or a domain.
I've often preferred to use the underlying domain representation
rather than the minimalistic needed by use cases. eg. When designing
tables, I would choose to not add a column unless it is necessary for
the current use cases. However if the current use cases simplify a
one-to-many relationship to one-to-one, and a reasonable domain
assessment concludes that the relation in the wild is a one-to-many, I
prefer to model it as a one-to-many. That is because over a period of
time more aspects of the domain get implemented and some of these
early decisions need to be revisited. Adding columns to a table is
relatively less expensive than changing the cardinality of table
relationships. (YAGNI proponents may choose to disagree, and thats
fair - I am just stating my opinion here)

Why is it relevant here ? It doesn't matter whether the dict is
required to be serialized back to xml today. What matters more is
whether the domain suggests that ordering is important. I would use
that as deciding factor rather than what operations get done on the
data in the current use cases. If order is unimportant, round tripping
won't hurt, and if it does, just throw xmltodict away.

b) There is yet another issue here. The thread primarily began by
attempting a conversion assuming syntactic equivalence without
verifying semantic compatibility. While JSON / YAML are quite
compatible with each other, XML has a different set of semantics. (and
I don't even refer to some of the issues as discussed at
http://www.w3.org/DesignIssues/XML-Semantics.html and
http://www.balisage.net/Proceedings/vol6/html/Dombrowski01/BalisageVol6-Dombrowski01.html
). I refer to a simple difference. JSON / YAML have two types - a
sequence and a map. The sequence is ordered, the map isn't. Each of
the sequence or a map may contain other primitives or other sequences
or maps. There is no SequenceMap type. A type which has a name, has a
map having key value pairs, but also is a sequence of other
SequenceMaps with potentially not necessarily consecutively repeating
names. There simply isn't any similar pythonic structure (The way I
have worded it make it sound like a structural characteristic rather
than semantics, but I'll continue with that word for the moment).

Why is this relevant ? When one decides on a JSON / YAML file format,
one commits to one set of semantics and when one commits to a XML it
is a different set of semantics. The issue is as the software keeps on
growing a file that is in JSON will more likely continue to grow
differently in terms of its schema than an equivalent XML file. So if
you are the author of the file format just make it a JSON if you want
simple pythonic structures. But if you are choosing to deal with XML
because that format is not in your control, there is a good likelihood
that the maintainer of that file will continue to grow it with XML
semantics in mind, and even if under today's use cases you could find
a way to coerce a XML to primitive python structures like JSON, that
whole approach could break as you go along over the next few years of
maintenance.
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] (no subject)

2013-09-24 Thread Dhananjay Nene
On Tue, Sep 24, 2013 at 6:11 PM, Dhananjay Nene
 wrote:
> On Tue, Sep 24, 2013 at 6:04 PM, Dhananjay Nene
>  wrote:
>> On Tue, Sep 24, 2013 at 5:48 PM, Vineet Naik  wrote:
>>> Hi,
>>>
>>> On Tue, Sep 24, 2013 at 10:38 AM, bab mis  wrote:
>>>
>>>> Hi ,Any XML parser which gives the same kind of data structure as yaml
>>>> parser gives in python.  Tried with xmlmindom but ir's not of a proper
>>>> datastrucure ,every time i need to read by element and create the dict.
>>>>
>>>
>>> You can try xmltodict[1]. It also retains the node attributes and makes
>>> than accessible using the '@' prefix (See the example in README of the repo)
>>>
>>> [1]: https://github.com/martinblech/xmltodict
>>
>> Being curious I immediately took a look and tried the following :
>>
>> import xmltodict
>>
>> doc1 = xmltodict.parse("""
>> 
>>   
>> elements
>> more elements
>>   
>>   
>> element as well
>>   
>> 
>> """)
>>
>> doc2 = xmltodict.parse("""
>> 
>>   
>> more elements
>>   
>>   
>> element as well
>>   
>> 
>> """)
>> print(doc1['mydocument']['and'])
>> print(doc2['mydocument']['and'])
>>
>> The output was :
>> OrderedDict([(u'many', [u'elements', u'more elements'])])
>> OrderedDict([(u'many', u'more elements')])
>>
>> The only difference is there is only one "many" node inside the "and"
>> node in doc2. Do you see an issue here (at least I do). The output
>> structure is a function of the cardinality of the inner nodes. Since
>> it changes shape from a list of many to not a list of 1 but just 1
>> element (throwing away the list). Which can make things rather
>> unpredictable. Since you cannot predict upfront whether the existence
>> of just one node inside a parent node is consistent with the xml
>> schema or is just applicable in that particular instance.
>>
>> I do think the problem is tractable so long as one clearly documents
>> the specific constraints which the underlying XML will satisfy,
>> constraints which will allow transformations to lists or dicts safe.
>> Trying to make it easy without clearly documenting the constraints
>> could lead to violations of the principle of least surprise like
>> above.
>>
> It gets even more interesting, eg. below
>
> doc3 = xmltodict.parse("""
> 
>   
> elements
>   
>   
> element as well
>   
>   
> more elements
>   
> 
> """)
>
> print(doc3['mydocument']['and'])
>
> leads to the output :
>
> [OrderedDict([(u'many', u'elements')]), OrderedDict([(u'many', u'more
> elements')])]
>
> Definitely not what would be naively expected.

Correction:

print(doc3['mydocument'])

prints

OrderedDict([(u'@has', u'an attribute'), (u'and',
[OrderedDict([(u'many', u'elements')]), OrderedDict([(u'many', u'more
elements')])]), (u'plus', OrderedDict([(u'@a', u'complex'), ('#text',
u'element as well')]))])

which just trashed the ordering of an and followed by a plus followed by an and.

Dhananjay

-- 
--
http://blog.dhananjaynene.com twitter: @dnene google plus:
http://gplus.to/dhananjaynene
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] (no subject)

2013-09-24 Thread Dhananjay Nene
On Tue, Sep 24, 2013 at 6:04 PM, Dhananjay Nene
 wrote:
> On Tue, Sep 24, 2013 at 5:48 PM, Vineet Naik  wrote:
>> Hi,
>>
>> On Tue, Sep 24, 2013 at 10:38 AM, bab mis  wrote:
>>
>>> Hi ,Any XML parser which gives the same kind of data structure as yaml
>>> parser gives in python.  Tried with xmlmindom but ir's not of a proper
>>> datastrucure ,every time i need to read by element and create the dict.
>>>
>>
>> You can try xmltodict[1]. It also retains the node attributes and makes
>> than accessible using the '@' prefix (See the example in README of the repo)
>>
>> [1]: https://github.com/martinblech/xmltodict
>
> Being curious I immediately took a look and tried the following :
>
> import xmltodict
>
> doc1 = xmltodict.parse("""
> 
>   
> elements
> more elements
>   
>   
> element as well
>   
> 
> """)
>
> doc2 = xmltodict.parse("""
> 
>   
> more elements
>   
>   
> element as well
>   
> 
> """)
> print(doc1['mydocument']['and'])
> print(doc2['mydocument']['and'])
>
> The output was :
> OrderedDict([(u'many', [u'elements', u'more elements'])])
> OrderedDict([(u'many', u'more elements')])
>
> The only difference is there is only one "many" node inside the "and"
> node in doc2. Do you see an issue here (at least I do). The output
> structure is a function of the cardinality of the inner nodes. Since
> it changes shape from a list of many to not a list of 1 but just 1
> element (throwing away the list). Which can make things rather
> unpredictable. Since you cannot predict upfront whether the existence
> of just one node inside a parent node is consistent with the xml
> schema or is just applicable in that particular instance.
>
> I do think the problem is tractable so long as one clearly documents
> the specific constraints which the underlying XML will satisfy,
> constraints which will allow transformations to lists or dicts safe.
> Trying to make it easy without clearly documenting the constraints
> could lead to violations of the principle of least surprise like
> above.
>
It gets even more interesting, eg. below

doc3 = xmltodict.parse("""

  
elements
  
  
element as well
  
  
more elements
  

""")

print(doc3['mydocument']['and'])

leads to the output :

[OrderedDict([(u'many', u'elements')]), OrderedDict([(u'many', u'more
elements')])]

Definitely not what would be naively expected.
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] (no subject)

2013-09-24 Thread Dhananjay Nene
On Tue, Sep 24, 2013 at 5:48 PM, Vineet Naik  wrote:
> Hi,
>
> On Tue, Sep 24, 2013 at 10:38 AM, bab mis  wrote:
>
>> Hi ,Any XML parser which gives the same kind of data structure as yaml
>> parser gives in python.  Tried with xmlmindom but ir's not of a proper
>> datastrucure ,every time i need to read by element and create the dict.
>>
>
> You can try xmltodict[1]. It also retains the node attributes and makes
> than accessible using the '@' prefix (See the example in README of the repo)
>
> [1]: https://github.com/martinblech/xmltodict

Being curious I immediately took a look and tried the following :

import xmltodict

doc1 = xmltodict.parse("""

  
elements
more elements
  
  
element as well
  

""")

doc2 = xmltodict.parse("""

  
more elements
  
  
element as well
  

""")
print(doc1['mydocument']['and'])
print(doc2['mydocument']['and'])

The output was :
OrderedDict([(u'many', [u'elements', u'more elements'])])
OrderedDict([(u'many', u'more elements')])

The only difference is there is only one "many" node inside the "and"
node in doc2. Do you see an issue here (at least I do). The output
structure is a function of the cardinality of the inner nodes. Since
it changes shape from a list of many to not a list of 1 but just 1
element (throwing away the list). Which can make things rather
unpredictable. Since you cannot predict upfront whether the existence
of just one node inside a parent node is consistent with the xml
schema or is just applicable in that particular instance.

I do think the problem is tractable so long as one clearly documents
the specific constraints which the underlying XML will satisfy,
constraints which will allow transformations to lists or dicts safe.
Trying to make it easy without clearly documenting the constraints
could lead to violations of the principle of least surprise like
above.

>
>
>> ___
>> BangPypers mailing list
>> BangPypers@python.org
>> https://mail.python.org/mailman/listinfo/bangpypers
>>
>
>
>
> --
> Vineet Naik
> ___
> BangPypers mailing list
> BangPypers@python.org
> https://mail.python.org/mailman/listinfo/bangpypers



-- 
--
http://blog.dhananjaynene.com twitter: @dnene google plus:
http://gplus.to/dhananjaynene
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] (no subject)

2013-09-24 Thread Dhananjay Nene
On Tue, Sep 24, 2013 at 10:38 AM, bab mis  wrote:
> Hi ,Any XML parser which gives the same kind of data structure as yaml parser 
> gives in python.  Tried with xmlmindom but ir's not of a proper datastrucure 
> ,every time i need to read by element and create the dict.

Just think about it for a moment. yaml consists of dicts and lists.
xml on the other hand consists of ordered sequences of named nodes
each of which is simultaneously a dict of attributes and a collection
of additional ordered sequences of nodes. Its hard to stuff XML into
native python constructs like dicts and lists. They just don't map
well.

If you could make assumptions about the XML having specific
constraints which would allow it to be cast into dicts and lists, you
could with trivial effort write a transformer to transform a DOM into
a bunch of lists and dicts. In other words - the issue is not the tool
- it is the domain you are dealing with.
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Pyladies Bangalore in Times of India

2013-09-23 Thread Dhananjay Nene
On Mon, Sep 23, 2013 at 11:24 AM, Annapoornima Koppad
 wrote:
> Dear All,
>
> Pyladies Bangalore was recently featured in Times of India dated, 22nd sept
> and later on 23 sept as well. [1]. I am not able to find the link for the
> 23rd edition.
>
> I thank Anand Chitipothu for making Pycon India 2013 women inclusive. Since
> he has already made a comment that there was enough participation from
> women, there are a few facts that I want get them straight.
>
> Dear Mr. Anand Chitipothu, can you please provide the exact number of women
> participants in Pycon India 2013? How many women were key note speakers? I
> would like a list of their email ids and names if they were women. I need
> them because I want to increase the Pyladies visibility and also encourage
> ladies in other cities to start Pyladies chapter in their respective towns
> and cities.
>
> Also, Mr. Anand, can you please provide me an introduction to Shilpa
> Patankar the news reporter so that I can give her the status of Pyladies
> Bangalore, overview of goals, etc.
>
> [1].
> http://timesofindia.indiatimes.com/tech/personal-tech/computing/Women-programmers-learn-to-schmooze/articleshow/22877116.cms
>
> I wholeheartedly thank Anand Chitipothu ( and the other volunteers) for
> making Pycon India 2013 a women inclusive event.
>

A gentle reminder there are three mailing lists with their respective
agendas as follows :

bangpypers : This group is for discussions related to the
Python programming language. We welcome all kinds of
discussions related to Python.
inpycon: This mailing list is for discussions regarding organizing
Pycon India. Anyone who is interested to take an active role in
discussing and/or organizing PyCon India  is
welcome to join the list.
ipss: Discussions related to the Indian Python Software Society.
I believe there is another pyladies group which discusses associated
appropriate issues.

I am subscribed to this mailing list because I am interested in the
python programming language. Can someone please change the documented
objective of this mailing list to appropriately reflect the reality if
I my perception is stale or out of date.

Dhananjay
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] decorator help

2013-09-20 Thread Dhananjay Nene
On Fri, Sep 20, 2013 at 6:06 PM, babmis  wrote:
> I want to print entry and exit message for functions , i have bunch of such
> function . How can i do it in decorator.

>>> from functools import wraps
>>>
>>> def trace(f):
... @wraps(f)
... def wrap(*args, **kwargs):
... print("Entering {} with {} {}".format(f.__name__,args,kwargs))
... ret = f(*args,**kwargs)
... print("Leaving {} with {}".format(f.__name__, ret))
... return ret
... return wrap
...
>>> @trace
... def foo(arg1,arg2,arg3="bar",arg4="buz") :
... print("Into foo")
... return ("Zoo", False)
...
>>>
>>> foo("hello", "world", arg4="Boo!")
Entering foo with ('hello', 'world') {'arg4': 'Boo!'}
Into foo
Leaving foo with ('Zoo', False)
('Zoo', False)


> ___
> BangPypers mailing list
> BangPypers@python.org
> https://mail.python.org/mailman/listinfo/bangpypers
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Do you pin your requirements.txt ?

2013-09-16 Thread Dhananjay Nene
On Mon, Sep 16, 2013 at 4:18 PM, Saager Mhatre  wrote:
> On Sep 16, 2013 8:46 AM, "Dhananjay Nene"  wrote:
>> let me state that while I pin requirements.txt
>
> To be just a little pedantic here- you pin version of dependencies, not the
> entire requirements.txt.

Matching the pedantic spirit => Look at the topic of the thread. It
could've just ended with a No.

If you read other content here, I've talked about generating
requirements.txt using pip freeze just before "re-running a test
suite" and associating a requirements.txt with a commit (in a scenario
where one would want to use the latest and the greatest of
dependencies to reduce complacency).

> Just saying... 'cause, even though I may have
> myself used the phrase in previous responses on this thread, I personally
> prefer to specify dependencies in setup.py and avoid creating a separate
> requirements.txt file.

Fair enough. A alternative valid on its own merit.

> Either approach could very well be put down as a
> stylistic difference,

No. A stylistic difference implies no non-aesthetic differences.

The first level dependencies might have specified a dependency as
"foolib >= x.y". Guess what, now you can get foolib of x.z where z >=
y.

Both are reasonable roads to travel. They don't take you to the same place.

> but the specific compatibility of these approaches
> with different build tools (distutils, setuptools/easy_install,
> distribute/pip) makes it significant, IMHO.
>

That is something I would be keen to understand. (Should be a separate
thread imo).
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] need help w.r.t itertools

2013-09-16 Thread Dhananjay Nene
On Mon, Sep 16, 2013 at 12:27 PM, Suyash Bhatt  wrote:
> thanks for the response..
>
> what if i have another list
>
> *e = [*'*my1name1is1','**my2name2is1','xyz','abc']*
> *and in the list d, I want only the elements which are present in e..*
> *
Python 2.7.3 (default, Apr 10 2013, 05:13:16)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import itertools
>>>
>>> a = ['my1','my2']
>>> b = ['name1', 'name2']
>>> c = ['my1', 'my2']
>>> e = ['my1name1my1','my1name2my1','foobar']
>>> d = [y for y in (''.join(x) for x in itertools.product(a, b, c)) if y in e]
>>>
>>> d
['my1name1my1', 'my1name2my1']
>>>
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Do you pin your requirements.txt ?

2013-09-15 Thread Dhananjay Nene
On Mon, Sep 16, 2013 at 12:37 AM, Kiran Jonnalagadda  wrote:
>
>
> Pinned requirements == complacency == future breakage, when maintenance is
> much more expensive than it is today.

imo there are is two underlying independent issues here. Having said
that let me state that while I pin requirements.txt, and started
responding to this thread earlier with a bit of ambivalence on the
issue, I have moved closer to the pinning requirements.txt as an
appropriate solution for me as the thread has evolved.

1) Complacency :

This simply has to do with how frequently one does builds / creates
dists that are used for deployment. A scenario where one continuously
recreates a fresh virtualenv and regenerates requirements.txt "before"
everytime one re-runs a test-suite, should fix it. It is not tied to
whether a requirements.txt is being used or not. I am still working
through what is the implication for automation for dealing with this.
Clearly one would need to find a way of associating a version / tag /
commit with a last successfully tested requirement.txt. I am not yet
sure of how one would go around doing that. Though that is something I
intend to spend time on.

2) Repeatability : Was the software you tested, the software you
deployed. This could be fixed by one of multiple approaches
a) Bundled dependencies
b) Pinned requirements.txt

I acknowledge the implication in terms of potential rot. I think I
shall be working on fixing (1) without compromising on (2) rather than
treating them as mutually exclusive.

There are too many contextual variables here, so please don't assume I
am making a recommendation. The above seems to be the best I think I
should be doing. YMMV.
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Do you pin your requirements.txt ?

2013-09-14 Thread Dhananjay Nene
On Sun, Sep 15, 2013 at 3:43 AM, Kiran Jonnalagadda  wrote:

> Thanks to Travis, we test every commit, before deployment.
>

I was perhaps misunderstood. If you test (even with say travis) but without
a pinned requirements.txt, and then create a dist and later deploy the dist
onto the server using a pip install (w/o a requirements.txt) then you no
longer have a repeatability in terms of transient dependencies. Because
travis may have used a version x.y of a transient dependency but the actual
deployment may end up using version x.(y+1) if the dependency in setup.py
of a dist you directly used specified the transient dependency as >= x.0
say.

Or then perhaps I couldn't understand something.

>
> --
> Kiran Jonnalagadda
> http://jace.zaiki.in/
> http://hasgeek.com/
>
> (Sent from my phone)
> On Sep 14, 2013 11:58 PM, "Dhananjay Nene" 
> wrote:
>
> > On Sat, Sep 14, 2013 at 11:00 PM, Kiran Jonnalagadda 
> > wrote:
> >
> > > We almost never pin at HasGeek. If an external library breaks API, we
> > > upgrade our code ASAP (we discover breakage from Travis reports).
> > >
> > > I know I sound a little too particular, and frankly that is not my
> > intent,
> > but there still remains an issue in terms of repeatability. The tests
> have
> > to be run as a part of the deployment process if you want to ensure that
> > the distributions you test with are the distributions that you deploy
> with.
> >
> >
> > > Between the risk of breaking code and having the hot seat at any hint
> of
> > > bit rot, I find the latter preferable.
> > >
> > > A sentiment I empathise with. Only yesterday I found code breaking
> > against
> > python 3.3.1 (as opposed to 3.3.0) and hopefully should fix it in the
> next
> > couple of days. Its just that I've rarely found the luxury to hold back a
> > deployment should a piece of code break due to dependency version
> upgrades.
> > Thus dependency version upgrades almost work with a different time window
> > than just pure deployable distribution version upgrade cycle.
> >
> > > Kiran
> > >
> > > --
> > > Kiran Jonnalagadda
> > > http://jace.zaiki.in/
> > > http://hasgeek.com/
> > >
> > > (Sent from my phone)
> > > On Sep 14, 2013 10:50 PM, "Noufal Ibrahim" 
> > wrote:
> > >
> > > > Dhananjay Nene  writes:
> > > >
> > > >
> > > > [...]
> > > >
> > > > > The difficulty with that approach (I've never actually done it) is
> > > > > that it requires versioning these bundles, make them available to
> > your
> > > > > installation scripts and code to them (lately I've started using
> > > > > ansible to do this).
> > > >
> > > > I know. I don't think I'd do it again. This was a stop gap thing back
> > > > then.
> > > >
> > > >
> > > > [...]
> > > >
> > > > > After realising distributions eventually disappear pypi (central),
> > > > > makes sense to have your own pypi mirror which lacks the feature of
> > > > > disappearing dists.
> > > >
> > > > I actually had a script which would make a bundle and then wrap it up
> > in
> > > > a self extracting script (using makeself). If you ran it, it would
> > serve
> > > > the packages in that bundle as a local PyPI mirror which you could
> > > > install off of.
> > > > [...]
> > > >
> > > >
> > > > --
> > > > Cordially,
> > > > Noufal
> > > > http://nibrahim.net.in
> > > > ___
> > > > BangPypers mailing list
> > > > BangPypers@python.org
> > > > https://mail.python.org/mailman/listinfo/bangpypers
> > > >
> > > ___
> > > BangPypers mailing list
> > > BangPypers@python.org
> > > https://mail.python.org/mailman/listinfo/bangpypers
> > >
> >
> >
> >
> > --
> >
> >
> --
> > http://blog.dhananjaynene.com twitter: @dnene
> > <http://twitter.com/dnene>google plus:
> > http://gplus.to/dhananjaynene
> > ___
> > BangPypers mailing list
> > BangPypers@python.org
> > https://mail.python.org/mailman/listinfo/bangpypers
> >
> ___
> BangPypers mailing list
> BangPypers@python.org
> https://mail.python.org/mailman/listinfo/bangpypers
>
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Do you pin your requirements.txt ?

2013-09-14 Thread Dhananjay Nene
On Sat, Sep 14, 2013 at 11:00 PM, Kiran Jonnalagadda  wrote:

> We almost never pin at HasGeek. If an external library breaks API, we
> upgrade our code ASAP (we discover breakage from Travis reports).
>
> I know I sound a little too particular, and frankly that is not my intent,
but there still remains an issue in terms of repeatability. The tests have
to be run as a part of the deployment process if you want to ensure that
the distributions you test with are the distributions that you deploy with.


> Between the risk of breaking code and having the hot seat at any hint of
> bit rot, I find the latter preferable.
>
> A sentiment I empathise with. Only yesterday I found code breaking against
python 3.3.1 (as opposed to 3.3.0) and hopefully should fix it in the next
couple of days. Its just that I've rarely found the luxury to hold back a
deployment should a piece of code break due to dependency version upgrades.
Thus dependency version upgrades almost work with a different time window
than just pure deployable distribution version upgrade cycle.

> Kiran
>
> --
> Kiran Jonnalagadda
> http://jace.zaiki.in/
> http://hasgeek.com/
>
> (Sent from my phone)
> On Sep 14, 2013 10:50 PM, "Noufal Ibrahim"  wrote:
>
> > Dhananjay Nene  writes:
> >
> >
> > [...]
> >
> > > The difficulty with that approach (I've never actually done it) is
> > > that it requires versioning these bundles, make them available to your
> > > installation scripts and code to them (lately I've started using
> > > ansible to do this).
> >
> > I know. I don't think I'd do it again. This was a stop gap thing back
> > then.
> >
> >
> > [...]
> >
> > > After realising distributions eventually disappear pypi (central),
> > > makes sense to have your own pypi mirror which lacks the feature of
> > > disappearing dists.
> >
> > I actually had a script which would make a bundle and then wrap it up in
> > a self extracting script (using makeself). If you ran it, it would serve
> > the packages in that bundle as a local PyPI mirror which you could
> > install off of.
> > [...]
> >
> >
> > --
> > Cordially,
> > Noufal
> > http://nibrahim.net.in
> > ___
> > BangPypers mailing list
> > BangPypers@python.org
> > https://mail.python.org/mailman/listinfo/bangpypers
> >
> ___
> BangPypers mailing list
> BangPypers@python.org
> https://mail.python.org/mailman/listinfo/bangpypers
>



-- 
--
http://blog.dhananjaynene.com twitter: @dnene
<http://twitter.com/dnene>google plus:
http://gplus.to/dhananjaynene
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Do you pin your requirements.txt ?

2013-09-14 Thread Dhananjay Nene
On Sat, Sep 14, 2013 at 2:56 PM, Noufal Ibrahim wrote:

> Baishampayan Ghose  writes:
>
> > Oh! Is that a big deal? Of course we pin our requirements (in all
> > languages) and that's how it should be done. Otherwise you can't get
> > repeatable builds. ~BG
>
> I sometimes go futher and bundle the dependecies, and put them on
> dropbox or something. Then wget and install the bundle from there.
>
> The difficulty with that approach (I've never actually done it) is that it
requires versioning these bundles, make them available to your installation
scripts and code to them (lately I've started using ansible to do this).


> This was before PyPI was mirrored and became more reliable.
>

After realising distributions eventually disappear pypi (central), makes
sense to have your own pypi mirror which lacks the feature of disappearing
dists.
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Python packages and modules (was: Favorite tips/techniques)

2013-09-13 Thread Dhananjay Nene
On 13 Sep 2013 19:21, "Saager Mhatre"  wrote:
>
>
> Your result is not bad, but I still prefer my original approach. No
> offence. :)

None perceived :)
> Oh, and I'm still waiting on an answer for [3]. ;)

I have my theories :) Don't know the facts.
>
> - d
>
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Python packages and modules (was: Favorite tips/techniques)

2013-09-13 Thread Dhananjay Nene
On Fri, Sep 13, 2013 at 6:50 PM, Dhananjay Nene
 wrote:
> On Fri, Sep 13, 2013 at 3:58 PM, Saager Mhatre  
> wrote:
>> On Fri, Sep 13, 2013 at 1:10 PM, Saju M  wrote:
>>
>>> Saager,
>>>
>>> As per python module-import semantics, sub-modules don't end up as names
>>> in the
>>> package-module[*] unless explicitly added.
>>>
>>> I didn't get it, what you mean by package-module[*] ?.
>>>
>>
>> Ah, there it is... the sound of your head exploding! :P
>>
>> Buckle up, this is going to be a fast, but rough ride!
>>
>> Basically...
>> 
>> * A module is a dict-like object that binds names to values.
>> * A package is a namespace that can contain (only) other modules (which
>> could, in turn, be package-modules themselves).
>> * A package-module[1] would be a module that also serves as a package.
>>
>> I guess it'd be easier to explain with with an example.
>>
>> Semantically...
>> ---
>> * Lets stick to json.tool. In this case, json is a module and tool is a
>> sub-module of the json module.
>> * They are both modules in that each can contain bindings to names =>
>> json.dump and tool.main.
>> * But, json is also a package in that it contains the tool module =>
>> json.tool
>> * The sub-module relationship is mostly evident from the fact that the tool
>> module is referenced by prefixing 'json.' to it => import json.tool;
>> * Or providing 'json' as the package to look for the module => from json
>> import tool
>>
>> Physically...
>> ---
>> * Any .py file can be loaded as a module.
>> * Any directory with an __init__.py file can be treated as a package.
>> * The __init__.py file itself serves as the package-module, i.e., the
>> module with same name as the package
>> * Any .py files inside the directory (except __init__.py, of course) can be
>> loaded as sub-modules of the above package.
>> * Any sub-directories inside the directory (containing __init__.py, of
>> course) can be loaded as sub-packages of the above package.
>> * Turtles all the way...
>>
>> Funda-mentally...
>> ---
>> * The confusion basically stems from the fact that Python chose to conflate
>> physical storage and namespacing with just enough overlap to be
>> inconsistent.
>> * They are conflated in that package/module naming and their lookup
>> (finding the code for a module) is tied to the physical storage hierarchy.
>> * They are inconsistent that module loading is transitive only upwards in
>> the hierarchy, i.e., when you load a module, all packages above it in the
>> hierarchy are automatically loaded.[2]
>> * However, sub-modules are not loaded even though the physical hierarchy
>> evidences it.
>> * The conflation extends further as we look as modules as namespaces,
>> because sub-modules do not end up as names in package-modules until they
>> are loaded; see below
>> Python 2.7.4 (default, Apr 19 2013, 18:28:01)
>> [GCC 4.7.3] on linux2
>> Type "help", "copyright", "credits" or "license" for more information.
>> *>>> json*
>> Traceback (most recent call last):
>>   File "", line 1, in 
>> NameError: name 'json' is not defined
>> *>>> import json*
>> *>>> json*
>> 
>> *>>> json.tool*
>> Traceback (most recent call last):
>>   File "", line 1, in 
>> AttributeError: 'module' object has no attribute 'tool'
>> *>>> from json import tool*
>> *>>> json*
>> 
>> *>>> tool*
>> 
>> *>>> json.tool*
>> 
>> *>>> *
>>
>> Finally...
>> ---
>> On a closing note, it goes without saying that these packages are not to be
>> confused with packages as published on package indexes such as
>> https://pypi.python.org.[3]
>
> Nice. I reached out for the "Favourite" button but realised
> emails/mailing lists don't have it.
>
> I do think it can be a little easier to understand by doing
> s/package-module/namespace/g. Having done that I realised a few things
> needed to be reworded, and then noticed a few minor corrections were
> required.
>
> Here's the result (Have attempted to only make minor structural
> corrections without adjusting any of the opinions or rationale
> expressed herein)
> -
> Ah, there it is...

Re: [BangPypers] Python packages and modules (was: Favorite tips/techniques)

2013-09-13 Thread Dhananjay Nene
On Fri, Sep 13, 2013 at 3:58 PM, Saager Mhatre  wrote:
> On Fri, Sep 13, 2013 at 1:10 PM, Saju M  wrote:
>
>> Saager,
>>
>> As per python module-import semantics, sub-modules don't end up as names
>> in the
>> package-module[*] unless explicitly added.
>>
>> I didn't get it, what you mean by package-module[*] ?.
>>
>
> Ah, there it is... the sound of your head exploding! :P
>
> Buckle up, this is going to be a fast, but rough ride!
>
> Basically...
> 
> * A module is a dict-like object that binds names to values.
> * A package is a namespace that can contain (only) other modules (which
> could, in turn, be package-modules themselves).
> * A package-module[1] would be a module that also serves as a package.
>
> I guess it'd be easier to explain with with an example.
>
> Semantically...
> ---
> * Lets stick to json.tool. In this case, json is a module and tool is a
> sub-module of the json module.
> * They are both modules in that each can contain bindings to names =>
> json.dump and tool.main.
> * But, json is also a package in that it contains the tool module =>
> json.tool
> * The sub-module relationship is mostly evident from the fact that the tool
> module is referenced by prefixing 'json.' to it => import json.tool;
> * Or providing 'json' as the package to look for the module => from json
> import tool
>
> Physically...
> ---
> * Any .py file can be loaded as a module.
> * Any directory with an __init__.py file can be treated as a package.
> * The __init__.py file itself serves as the package-module, i.e., the
> module with same name as the package
> * Any .py files inside the directory (except __init__.py, of course) can be
> loaded as sub-modules of the above package.
> * Any sub-directories inside the directory (containing __init__.py, of
> course) can be loaded as sub-packages of the above package.
> * Turtles all the way...
>
> Funda-mentally...
> ---
> * The confusion basically stems from the fact that Python chose to conflate
> physical storage and namespacing with just enough overlap to be
> inconsistent.
> * They are conflated in that package/module naming and their lookup
> (finding the code for a module) is tied to the physical storage hierarchy.
> * They are inconsistent that module loading is transitive only upwards in
> the hierarchy, i.e., when you load a module, all packages above it in the
> hierarchy are automatically loaded.[2]
> * However, sub-modules are not loaded even though the physical hierarchy
> evidences it.
> * The conflation extends further as we look as modules as namespaces,
> because sub-modules do not end up as names in package-modules until they
> are loaded; see below
> Python 2.7.4 (default, Apr 19 2013, 18:28:01)
> [GCC 4.7.3] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> *>>> json*
> Traceback (most recent call last):
>   File "", line 1, in 
> NameError: name 'json' is not defined
> *>>> import json*
> *>>> json*
> 
> *>>> json.tool*
> Traceback (most recent call last):
>   File "", line 1, in 
> AttributeError: 'module' object has no attribute 'tool'
> *>>> from json import tool*
> *>>> json*
> 
> *>>> tool*
> 
> *>>> json.tool*
> 
> *>>> *
>
> Finally...
> ---
> On a closing note, it goes without saying that these packages are not to be
> confused with packages as published on package indexes such as
> https://pypi.python.org.[3]

Nice. I reached out for the "Favourite" button but realised
emails/mailing lists don't have it.

I do think it can be a little easier to understand by doing
s/package-module/namespace/g. Having done that I realised a few things
needed to be reworded, and then noticed a few minor corrections were
required.

Here's the result (Have attempted to only make minor structural
corrections without adjusting any of the opinions or rationale
expressed herein)
-
Ah, there it is... the sound of your head exploding! :P

Buckle up, this is going to be a fast, but rough ride!

Basically...

* A namespace is a dict-like object that binds names to values.
* A namespace is an abstract notion, which is implemented as packages or modules
  Thus a package is-a namespace and a module is-a namespace
* The package namespace includes the modules in it and the stuff in __init__.py

I guess it'd be easier to explain with with an example.

Semantically...
---
* Lets stick to json.tool. In this case, json is a package and tool is
a module
* They are both namespaces in that each can contain bindings to names
=> json.dump and tool.main.
* json is a package namespace in that it contains the tool module => json.tool
* The sub-module relationship is mostly evident from the fact that the
tool module is referenced by prefixing 'json.' to it => import
json.tool;
* Or providing 'json' as the package to look for the module => from
json import tool

Physically...
---
* Any .py file can be loaded as a module.
* Any directory w

Re: [BangPypers] Favorite tips/techniques

2013-09-13 Thread Dhananjay Nene
On Fri, Sep 13, 2013 at 12:49 PM, Saju M  wrote:
> Import sub-modules with alias.
> Is it a bug ?
>

 import json
 from json import tool

>
> 
>

 import json as sjson
 from sjson import tool
> Traceback (most recent call last):
>   File "", line 1, in 
> ImportError: No module named sjson


import and from serve to import packages using their canonical package
names into the appropriate module name spaces.

The alias is applied as a part of the importing process and the target
of this is the module name space.

Since from looks at the canonical names (in the virtualenv etc.) from
sjson means it should look up a package on the disk called sjson (not
locate sjson out of module namespace)

Dhananjay
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Do you pin your requirements.txt ?

2013-09-12 Thread Dhananjay Nene
On Fri, Sep 13, 2013 at 12:38 AM, Saager Mhatre  wrote:
> On Thu, Sep 12, 2013 at 6:30 PM, Abdul Muneer  wrote:
>
>> I also pin requirements. But when I do 'pip freeze', I remove the packages
>> that are installed as a dependency to main libraries which were explicitly
>> installed.
>>
>
> I tend to avoid using 'pip freeze' as part of my dev flow for just this
> reason.
> YMMV, but it just adds busywork; easier to hand maintain a list of pinned
> top-level packages.
> As for (optimistically or pessimistically) pinned dependencies, I usually
> pin them on a case-by-case basis.
>
> Packages from pypi may specify dependency as ">=" and it will fetch the
>> latest. But if you had pinned those too, it can cause conflicts especially
>> if you upgrade the main component. Had run into issues because of this
>> while working on a pylons project.
>>
>
> Ditto.
> Except I recall hitting this when we were moving to py3k and one of the
> 'newer' packages of a dependency of something we were depending on added
> code that was beyond 2to3's capability. :P

Its a tradeoff between convenience and repeatability. If one wants to
avoid surprises eg. the one Saager mentioned, and ensure repeatability
its better to pin. Given adequate test coverage to verify negative
side effects of any transitive dependency version upgrades, pinning
could be skipped imo.

Dhananjay
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Python "Wat"s

2013-09-12 Thread Dhananjay Nene
On Thu, Sep 12, 2013 at 11:22 PM, Shabda Raaj  wrote:
>> whole qx business than Python programmers are with os and subprocess.
>
> That because subprocess and os module have a very bad api. I prefer using
> envoy whenevr I can.
>
> https://github.com/kennethreitz/envoy

Interesting. Haven't worked with envoy, but have found sh
http://amoffat.github.io/sh/ as a useful alternative to subprocess.

Dhananjay
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Favorite tips/techniques

2013-09-10 Thread Dhananjay Nene
Ignoring classes for the moment, how likely do you think you would
have a dict like that :)

On a separate note if you are using primitive types, I cannot think of
any scenarios, where not coercing keys to be of the same type would be
considered inappropriate (except in case of reverse dicts)

On Tue, Sep 10, 2013 at 3:52 PM, Me@Bibhas  wrote:
> What would happen for a dictionary like this?
>
 d = {'1': 'foo', 1: 'bar'}
 d
> {'1': 'foo', 1: 'bar'}
>
>
> On Tuesday 10 September 2013 10:00 AM, Noufal Ibrahim wrote:
>> Shabda Raaj  writes:
>>
>>> http://code.activestate.com/recipes/52308-the-simple-but-handy-collector-of-a-bunch-of-named/
>>>
>>> With api responses after you have parsed the json, you start doing things
>>> like:
>>>
>>> api_response["attribute"]
>>>
>>> I would much prefer to do
>>>
>>> api_response.attribute
>> I generally like to use attributes instead of keys. One additional
>> advantage is that I can, if necessary, later convert the attribute into
>> a property that does more than just return a value.
>>
>> [...]
>>
>>
>
> ___
> BangPypers mailing list
> BangPypers@python.org
> https://mail.python.org/mailman/listinfo/bangpypers



-- 
--
http://blog.dhananjaynene.com twitter: @dnene google plus:
http://gplus.to/dhananjaynene
___
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers


[BangPypers] Appropriate list conduct (was Re: Fwd: Fw: Fwd: https://github.com/pythonhacker/ladies.py)

2013-09-08 Thread Dhananjay Nene
Top posting since am making some rather broad comments rather than to
specific lines in particular.


This is a thread which has been bothering me since morning. For a
number of reasons.

None of them have to do with the very essence of the thread, since I
never got to see the repository and the code to be able to make a
judgement. So I took an apology offered as a sign of matter closed and
hopefully things taking a turn for the better.

* Yet more comments continued about specific people. I've always
thought a good decorum is to attack issues, generally not people. Is
that a reasonable guideline to follow ? I really do not think it was
appropriate to continue with judgement about people once the
underlying issues had been addressed. I don't know if I hold a
minority position here.
* Further comments continued about how to appropriately bring the
matter to a closure. I thought the convergence and agreement on the
core issues should've closed it. I am frankly not sure why anyone
would've imagined why list readers would be remotely interested in
further tactical matters such as existence or deletion of github repos
and the necessity to close them out and the sequencing thereof.
* I was further happy to note that the thread died down, but no, there
was more drama to follow. It so seems a private message was forwarded
to the mailing list. I speak for myself, but to me and under my
individual code of conduct, this is outrageous behaviour. This
concerns me. There are some serious privacy issues here (imo).

eg: I was to respond to matters raised in this mailing list to someone
else privately, I am no longer sure whats the community stand - can it
be made public or will the community severely frown on such a
behaviour. I am in doubt because list admins are further being
encouraged stop "this" whatever this means in the context. This breaks
every known decorum I know of and I wonder if this list has a
different set of rules than what I think lists follow.

I think there are some meta-issues about the mailing list that do need
to be discussed. I don't know if this is the place to do it, so will
leave it at these set of open questions to be worked through. This
discussion could be moved to an appropriate forum if this is not the
place.

Dhananjay


On Mon, Sep 9, 2013 at 12:08 AM, svaksha  wrote:
>
> Chris, STOP emailing me offlist. I made it very clear earlier that I
> didnt want to have any private conversations and have said everything
> on the list.
> List admins, can you do something to stop this? Thanks.
> svaksha ॥ स्वक्ष
>
>
>
> -- Forwarded message --
> From: CsquaredinOmaha 
> Date: Sun, Sep 8, 2013 at 6:32 PM
> Subject: Fw: [BangPypers] Fwd:  https://github.com/pythonhacker/ladies.py
> To: "svak...@gmail.com" 
>
>
> Svaksah,
>
> This was intended to be sent to you directly, not to the group list.
> My rule is "praise in public, criticize in private".  But I made a
> mistake in replying using this yahoo email interface.
> My apologies.
>
>
> - Forwarded Message -
> From: CsquaredinOmaha 
> To: Bangalore Python Users Group - India 
> Sent: Sunday, September 8, 2013 1:18 PM
> Subject: Re: [BangPypers] Fwd: https://github.com/pythonhacker/ladies.py
>
> That is what I thought - you have no answers and are simply interested
> in forcing others by your bullying.
>
> I took it off topic, directly to you, because I was honestly
> interested in your reply
> and didn't want your reply to be compelled to be less than honest.
>
> So my asking you a question you don't want to answer  means you label
> it  "troll"
> and  wondering your position on equality of free speech is "ad hominem" .
>
>
> Your stance and attitude do  your cause disservice.
>  I don't believe you have even it any thought and perhaps don't even
> grasped my point.
> Which is unfortunate,  it seems as so many liberals, that you are
> being loud without being thoughtful.
>
>
> 
> From: svaksha 
> To: Bangalore Python Users Group - India 
> Sent: Sunday, September 8, 2013 12:49 PM
> Subject: [BangPypers] Fwd:  https://github.com/pythonhacker/ladies.py
>
>
> Chris, was it easier to troll in private than on the public Bangpypers
> mailing list? If you're reduced to ad hominem and that too in private
> off-list messages, you're pretty clearly out of anything remotely
> relevant to say.
> svaksha ॥ स्वक्ष
>
>
> -- Forwarded message --
> From: CsquaredinOmaha 
> Date: Sun, Sep 8, 2013 at 5:36 PM
> Subject: Re: [BangPypers] https://github.com/pythonhacker/ladies.py
> To: "svak...@gmail.com" 
>
>
> svaksha,
>
> Let me see if I can summarize your string of responses:
>
> You are offended by Anand making fun of a group that used ".com"
> instead of ".org"
> and he apparently was sarcastically bringing into question/criticism
> some parts of your stated mission.
>
> In the subsequent emails, you threatened to report him and announced
> you felt the need to shame him on this list.
>
> So 

Re: [BangPypers] Sad demise of our dear KG (Keneth Gonsalvas)

2012-08-03 Thread Dhananjay Nene
On Fri, Aug 3, 2012 at 3:25 PM, JAGANADH G  wrote:

> Hi All,
>
> Just now I got a message that our dear KG (Kenneth Gonsalvas) passed away.
> He was admitted in hospital due to Asthma attack and passed away today
> morning.
> Cremation will be held at ooty on 4th Aug 2012.
>
> Shocking and extremely tragic. His commitment and contribution to python
community will be missed. Fare well.

Dhananjay
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] python framework for android

2012-01-09 Thread Dhananjay Nene
On Wed, Jan 4, 2012 at 12:25 PM, Kenneth Gonsalves  wrote:

> On Wed, 2012-01-04 at 14:24 +0800, Senthil Kumaran wrote:
> > On Wed, Jan 4, 2012 at 2:18 PM, Kenneth Gonsalves 
> > wrote:
> > >
> > > am looking at kivy right now
> >
> > Looks neat. I would like to try that one too.
>
> there was a wonderful talk on it in the last pycon.
>

Some more activity on the topic :
http://www.h-online.com/open/news/item/Python-for-Android-launched-1406039.html

Dhananjay
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] google api and facebook api ?

2011-11-15 Thread Dhananjay Nene
On Sat, Nov 12, 2011 at 7:35 PM, vishnu prasad  wrote:

> Hi to all
>
> How google internally running the code my doubt is python ?
> i mean api means we need to learn the code for separately apart from
> andriod,python,php, ruby ?
> knowing the api code and how can i start that ? is it python api is
> available for embedding with google ?
> please help me and also tell facebook and google running which code at back
> side ?
>
>
> I'm going to be brave and attempt to infer what was it you really intended
to ask ?


   - How google is running their own code internally ? Frankly doesn't
   matter when you interact it using an API
   - We need to learn the code separately ...? If you are referring to the
   API, yes you need to learn it separately. Google publishes their APIs both
   as HTTP APIs, and also as client libraries which call those APIs. You need
   to learn one of these two and in most situations you will choose to use the
   client libraries since they are much more friendly towards programmers
   (rather than raw HTTP streams) and allow you to do your code productively.
   For various python client libraries for google APIs refer
   http://code.google.com/p/gdata-python-client/
   - Is Python API available for embedding with google. Python API is
   available for invoking google services. See the link above.
   - Which code is google and facebook running at the back ? There is a
   plethora of languages both use. The language used to implement the services
   is actually irrelevant if you are accessing their services.
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Timestamp error

2011-11-10 Thread Dhananjay Nene
On Thu, Nov 10, 2011 at 5:05 PM, Shashidhar Paragonda <
shashidha...@gmail.com> wrote:

> Dear Python hackers,
>
>   >>> I am facing *ValueError : **timestamp out of range for
> platform time_t
> *
> *   >>> *I am working on Zope v. 2.8.11 with Python v2.4.4 on
> Debian v6.0 Squeeze.
>   >>> I get this error when I extract some parameters and
> values from database.
>   >>> can one one help me, thank you in advance
>

It means you attempted to create a timestamp beyond what the underlying
platform supports (most likely a date too far out or far back). Perhaps if
you attached the specific line of code with the actual values being passed
to the constructor that we could replicate, it would help provide a more
elaborate answer.

>
> --
> ---
> Regards,
>
> Shashidhar N.Paragonda
> shashidha...@gmail.com
> +919449073835
> ___
> BangPypers mailing list
> BangPypers@python.org
> http://mail.python.org/mailman/listinfo/bangpypers
>



-- 
--
http://blog.dhananjaynene.com twitter: @dnene
google plus:
http://gplus.to/dhananjaynene
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Generate Dynamic lists

2011-11-06 Thread Dhananjay Nene
On Mon, Nov 7, 2011 at 5:11 AM, Dhananjay Nene wrote:

>
>
> On Fri, Oct 21, 2011 at 12:10 AM, Asif Jamadar 
> wrote:
>
>> So I'm trying to generate dynamic choices for  django form. Here i'm usig
>> formset concept (CODE is mentioned below)
>>
>>
>>
>> Suppose i have list called criteria_list = ['education', 'know how',
>> 'managerial', 'interpersonal', ]
>>
>>
>>
>> now i need to generate choices as follows
>>
>>
>>
>> list1 = [('education', 1), ('education', 2), ('education', 3),
>> (''education' , 4) , ('know how', 1) ('know ho', 2), ('know ho', 3), ('know
>> ho', 4)]
>>
>>
>>
>> list2 = [('education', 1), ('education', 2), ('education', 3),
>> (''education' , 4) , ('managerial', 1) ('managerial', 2), ('managerial',
>> 3), ('managerial', 4)]
>>
>>
>>
>> list3 = [('education', 1), ('education', 2), ('education', 3),
>> (''education' , 4) , ('interpersonal', 1) ('interpersonal', 2),
>> ('interpersonal', 3), ('interpersonal', 4)]
>>
>>
>>
>> list4 = [('know how', 1), ('know how', 2), ('know how ', 3), ('know how'
>> , 4) , ('managerial', 1) ('managerial', 2), ('managerial', 3),
>> ('managerial', 4)]
>>
>>
>>
>> list5 = [('know how', 1), ('know how', 2), ('know how ', 3), ('know how'
>> , 4) , ('interpersonal', 1) ('interpersonal', 2), ('interpersonal', 3),
>> ('interpersonal', 4)]
>>
>>
>>
>> list6= [('managerial', 1), ('managerial', 2), ('managerial ', 3),
>> ('managerial' , 4) , ('interpersonal', 1) ('interpersonal', 2),
>> ('interpersonal', 3), ('interpersonal', 4)]
>>
>>
>>
>>
>>
>> How can i achive this in python?
>>
>> You could just create a list of lists using either of the following
> approaches
>
> import itertools as it
>
>
> criteria_list = ['education', 'know how', 'managerial', 'interpersonal', ]
>
> pairs = list((first,second) for (first,second) in
> (it.combinations(criteria_list,2)))
> lists = list(list((elem,r+1) for elem in pair for r in range(4)) for pair
> in pairs)
> print lists
>
> lists2 = map(lambda (x,y): map(lambda (r,v): (v,r+1),
> it.chain(enumerate(it.repeat(x,4)),enumerate(it.repeat(y,4,
> it.combinations(criteria_list,2))
> print lists2
>
>
>
The first comprehension above (pairs) had redundant building of the
first,second tuple. You could just simplify it as follows :

import itertools as it

criteria_list = ['education', 'know how', 'managerial', 'interpersonal', ]
lists = list(list((elem,r+1) for elem in pair for r in range(4)) for pair
in (it.combinations(criteria_list,2)))
print lists

lists2 = map(lambda (x,y): map(lambda (r,v): (v,r+1),
it.chain(enumerate(it.repeat(x,4)),enumerate(it.repeat(y,4,
it.combinations(criteria_list,2))
print lists2
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Generate Dynamic lists

2011-11-06 Thread Dhananjay Nene
On Fri, Oct 21, 2011 at 12:10 AM, Asif Jamadar wrote:

> So I'm trying to generate dynamic choices for  django form. Here i'm usig
> formset concept (CODE is mentioned below)
>
>
>
> Suppose i have list called criteria_list = ['education', 'know how',
> 'managerial', 'interpersonal', ]
>
>
>
> now i need to generate choices as follows
>
>
>
> list1 = [('education', 1), ('education', 2), ('education', 3),
> (''education' , 4) , ('know how', 1) ('know ho', 2), ('know ho', 3), ('know
> ho', 4)]
>
>
>
> list2 = [('education', 1), ('education', 2), ('education', 3),
> (''education' , 4) , ('managerial', 1) ('managerial', 2), ('managerial',
> 3), ('managerial', 4)]
>
>
>
> list3 = [('education', 1), ('education', 2), ('education', 3),
> (''education' , 4) , ('interpersonal', 1) ('interpersonal', 2),
> ('interpersonal', 3), ('interpersonal', 4)]
>
>
>
> list4 = [('know how', 1), ('know how', 2), ('know how ', 3), ('know how' ,
> 4) , ('managerial', 1) ('managerial', 2), ('managerial', 3), ('managerial',
> 4)]
>
>
>
> list5 = [('know how', 1), ('know how', 2), ('know how ', 3), ('know how' ,
> 4) , ('interpersonal', 1) ('interpersonal', 2), ('interpersonal', 3),
> ('interpersonal', 4)]
>
>
>
> list6= [('managerial', 1), ('managerial', 2), ('managerial ', 3),
> ('managerial' , 4) , ('interpersonal', 1) ('interpersonal', 2),
> ('interpersonal', 3), ('interpersonal', 4)]
>
>
>
>
>
> How can i achive this in python?
>
> You could just create a list of lists using either of the following
approaches

import itertools as it

criteria_list = ['education', 'know how', 'managerial', 'interpersonal', ]

pairs = list((first,second) for (first,second) in
(it.combinations(criteria_list,2)))
lists = list(list((elem,r+1) for elem in pair for r in range(4)) for pair
in pairs)
print lists

lists2 = map(lambda (x,y): map(lambda (r,v): (v,r+1),
it.chain(enumerate(it.repeat(x,4)),enumerate(it.repeat(y,4,
it.combinations(criteria_list,2))
print lists2
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] parsing xml

2011-09-30 Thread Dhananjay Nene
On Fri, Jul 29, 2011 at 10:47 AM, Anand Chitipothu wrote:

> 2011/7/28 Venkatraman S :
> > parsing using minidom is one of the slowest. if you just want to extract
> the
> > distance and assuming that it(the tag) will always be consistent, then i
> > would always suggest regexp. xml parsing is a pain.
>
> regexp is a bad solution to parse xml.
>

Partly because the answer is loosely related and partly because of the
humour quotient, I thought this response to using regex's to parse HTMLs
(which is perhaps more challenging in general than XMLs) was quite an
interesting read. Note this response could be considered a bit OT so don't
take it too seriously in the context of this thread's discussion.

http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454

>
> minidom is the fastest solution if you consider the programmer time
> instead of developer time.  Minidom is available in standard library,
> you don't have to add another dependency and worry about PyPI
> downtimes and lxml compilations failures.
>
> I don't think there will be significant performance difference between
> regexp and minidom unless you are doing it a million times.
>
>
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


[BangPypers] [JOB] Vayana Services seeking curious and committed python programmers

2011-09-23 Thread Dhananjay Nene
Vayana Services helps Small and Medium Enterprises (SMEs), get working
capital loans from banks and helps bank expand their lending reach. We
keep the technology simple to the point of being invisible to end
customers. We work on Python, Scala and Erlang with our SAAS offerings
deployed on AWS and Rackspace. We have been in production for a year,
and have already processed Rs. 50 crores of financing just in the last
quarter, with 3 bank partners and over 50 corporates/ SME's in the
program. This is impressive considering the myriad objections banks
and corporates in India have to the cloud let alone their
exceptionally confidential data being handled by a third party. We
plan to launch in US by Q1 next year.

We have a small but highly committed team of engineers creating,
collapsing, testing, and supporting code. The current team includes
@dnene, @dexterous, @missingfaktor, @vineetmago, @nkhalasi, and
@vaishaliphadkar. We hope to add exceptionally smart, committed coders
who can span the length from problem definition to dev-ops. There is
no minimum experience, candidates being rated on attitude, passion and
skill. We do not recruit managers (preferring self managing teams),
pure thinkers, coders who dislike testing their dogfood or people who
expect to be told in detail what to do.

Location : Pune
Experience : No prerequisites, but capabilities should reflect
relevant experience.
Python Knowledge : Preferred but not mandatory.
High competency in at least one programming language : Absolutely.

Send your Github/Bitbucket URLs twitter handles, linkedin profiles and
/ or CVs to : dhanan...@vayana.in
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Language Parsing and output generation

2011-08-24 Thread Dhananjay Nene
On Tue, Aug 23, 2011 at 11:15 AM, Gopalakrishnan Subramani
 wrote:
> I could make a grammar compiled myself. I will look into SPARK.. Anybody has
> experience in pyparsing http://pyparsing.wikispaces.com/ ?
> Under Examples http://pyparsing.wikispaces.com/Examples Python language
> example is promising.
>

I had written up a little about it (using a question that was earlier
posted on bangpypers) and it included the pyparsing configuration as
well.

http://codeblog.dhananjaynene.com/2010/01/extracting-data-using-recursive-descent-parsing/

> Regards,
>
> Gopal
>
>
> On Mon, Aug 22, 2011 at 11:25 PM, Noufal Ibrahim  wrote:
>
>> Gopalakrishnan Subramani  writes:
>>
>> > Source language IO is very limited and it has functions to map to IO and
>> UI.
>> > As a total, they have around 100+ function.
>> >
>> > Those can be easily done in Lua.
>>
>> [...]
>>
>> For a project in one of my earlier companies, I used SPARK[1] to write a
>> little parser for a language of my own making to used to specify some
>> conditionals.
>>
>> The parser would convert this into a python expression which could be
>> evaluated with some objects to return a true or a false.
>>
>> If you have the grammar of your source language at hand, it's a fews
>> hours job to write a parser for it using SPARK. Once you do that, you
>> have to write a backend to convert it into LUA which might be a little
>> more complex but not impossibly so.
>>
>>
>>
>>
>> Footnotes:
>> [1]  http://pages.cpsc.ucalgary.ca/~aycock/spark/
>>
>> --
>> ~noufal
>> http://nibrahim.net.in
>>
>> An empty cab drove up and Sarah Bernhardt got out. -Arthur Baer, American
>> comic and columnist
>> ___
>> BangPypers mailing list
>> BangPypers@python.org
>> http://mail.python.org/mailman/listinfo/bangpypers
>>
> ___
> BangPypers mailing list
> BangPypers@python.org
> http://mail.python.org/mailman/listinfo/bangpypers
>



-- 
--
http://blog.dhananjaynene.com twitter: @dnene google plus:
http://gplus.to/dhananjaynene
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Embedded python mail server

2011-08-24 Thread Dhananjay Nene
On Wed, Aug 24, 2011 at 12:48 PM, Gopalakrishnan Subramani
 wrote:
> fakemail seems to be right solution to me. interesting discovery.
>
Had troubles with easy_install. Colleague recommended
http://packages.python.org/lazr.smtptest/docs/queue.html

Quickly tried out in shell .. works and looks like a very appropriate tool.

Dhananjay

> On Wed, Aug 24, 2011 at 1:10 AM, Dhananjay Nene 
> wrote:
>
>> Just discovered http://www.lastcraft.com/fakemail.php
>>
>> On Wed, Aug 24, 2011 at 12:37 PM, Dhananjay Nene
>>  wrote:
>> > On Wed, Aug 24, 2011 at 12:34 PM, Dhananjay Nene
>> >  wrote:
>> >> On Wed, Aug 24, 2011 at 12:25 PM, Gopalakrishnan Subramani
>> >>  wrote:
>> >>> So you basically look for SMTP and also a POP3 access to the server?
>> With
>> >>> that you could send a mail using SMTP and retrieve using POP3 to make
>> sure
>> >>> the mail reached safely? There is no way to get the return receipt in
>> SMTP
>> >>> (sorry, I could be wrong since I coded SMTP & POP3 6 years back with
>> limited
>> >>> support).
>> >>
>> >> Only SMTP with programmatic access to query received emails is good
>> enough.
>> >>>
>> >>> I used jmailsrv which is simple to configure and test on your
>> scenarios.
>> >>>
>> >>> If you could share your testing strategy to test email, it would lead
>> to
>> >>> good discussion.
>> >>>
>> >>
>> >> There is an released artifact "X". X needs to be tested for acceptance
>> >> criteria. No code changes can be introduced into X. X sends out
>> >> emails. Test cases need to test whether the mails got sent out
>> >> correctly. Thus after running test sequences, the mails that have gone
>> >> out need to be verified. The intent is to embed the mail server into
>> >> the test case (not X). Thus outgoing emails from X will get dispatched
>> >> to and received by the embedded mail server. Since test cases (but not
>> >> X) have programmatic access to X and its datastore, using whatever is
>> >> the available mail server api to query the mails it has received is
>> >> acceptable mechanism of verification. Using a embedded python mail
>> >> server helps the test cases to just test the received emails using
>> >> python calls rather than having to do POP3 calls instead.
>> >>
>> > s/programmatic access to X and its datastore/programmatic access to
>> > mail server and its datastore/g
>> >> Dhananjay
>> >>
>> >>>
>> >>> On Wed, Aug 24, 2011 at 12:42 AM, Dhananjay Nene
>> >>> wrote:
>> >>>
>> >>>> On Wed, Aug 24, 2011 at 12:03 PM, Gopalakrishnan Subramani
>> >>>>  wrote:
>> >>>> > Use the http://hg.python.org/cpython/file/2.7/Lib/smtpd.py server.
>> smtpd
>> >>>> is
>> >>>> > a proxy so only look at the client interface level, you may not need
>> to
>> >>>> push
>> >>>> > to local server, no need to store to DB etc.
>> >>>> >
>> >>>> > you copy the file and modify and wrap to meet your automation needs
>> and
>> >>>> to
>> >>>> > get the response confirmation once the mail delivered.
>> >>>> >
>> >>>> > SMTP RFC is very simple to code even in C++ & Java.  But until or
>> unless
>> >>>> you
>> >>>> > have mail client or mail proxy or a email server as your core
>> >>>> > business/module or automating the application functional testing,
>> you
>> >>>> don't
>> >>>> > need to worry about testing with real mail server.
>> >>>> >
>> >>>> > Since you have mentioned as automated test, I assume that you don't
>> mean
>> >>>> > unit testing.
>> >>>>
>> >>>> It is automated acceptance testing .. so testing is strictly at the
>> >>>> system boundaries. So it has to test the released version of the
>> >>>> artifact - without *any* changes. I presume that would constrain me
>> >>>> from introducing a different smtpd.py
>> >>>>
>> >>>> > Gopal
>> >>>> >
>> >>>> >
>> >>>> &

Re: [BangPypers] Embedded python mail server

2011-08-24 Thread Dhananjay Nene
Just discovered http://www.lastcraft.com/fakemail.php

On Wed, Aug 24, 2011 at 12:37 PM, Dhananjay Nene
 wrote:
> On Wed, Aug 24, 2011 at 12:34 PM, Dhananjay Nene
>  wrote:
>> On Wed, Aug 24, 2011 at 12:25 PM, Gopalakrishnan Subramani
>>  wrote:
>>> So you basically look for SMTP and also a POP3 access to the server? With
>>> that you could send a mail using SMTP and retrieve using POP3 to make sure
>>> the mail reached safely? There is no way to get the return receipt in SMTP
>>> (sorry, I could be wrong since I coded SMTP & POP3 6 years back with limited
>>> support).
>>
>> Only SMTP with programmatic access to query received emails is good enough.
>>>
>>> I used jmailsrv which is simple to configure and test on your scenarios.
>>>
>>> If you could share your testing strategy to test email, it would lead to
>>> good discussion.
>>>
>>
>> There is an released artifact "X". X needs to be tested for acceptance
>> criteria. No code changes can be introduced into X. X sends out
>> emails. Test cases need to test whether the mails got sent out
>> correctly. Thus after running test sequences, the mails that have gone
>> out need to be verified. The intent is to embed the mail server into
>> the test case (not X). Thus outgoing emails from X will get dispatched
>> to and received by the embedded mail server. Since test cases (but not
>> X) have programmatic access to X and its datastore, using whatever is
>> the available mail server api to query the mails it has received is
>> acceptable mechanism of verification. Using a embedded python mail
>> server helps the test cases to just test the received emails using
>> python calls rather than having to do POP3 calls instead.
>>
> s/programmatic access to X and its datastore/programmatic access to
> mail server and its datastore/g
>> Dhananjay
>>
>>>
>>> On Wed, Aug 24, 2011 at 12:42 AM, Dhananjay Nene
>>> wrote:
>>>
>>>> On Wed, Aug 24, 2011 at 12:03 PM, Gopalakrishnan Subramani
>>>>  wrote:
>>>> > Use the http://hg.python.org/cpython/file/2.7/Lib/smtpd.py server. smtpd
>>>> is
>>>> > a proxy so only look at the client interface level, you may not need to
>>>> push
>>>> > to local server, no need to store to DB etc.
>>>> >
>>>> > you copy the file and modify and wrap to meet your automation needs and
>>>> to
>>>> > get the response confirmation once the mail delivered.
>>>> >
>>>> > SMTP RFC is very simple to code even in C++ & Java.  But until or unless
>>>> you
>>>> > have mail client or mail proxy or a email server as your core
>>>> > business/module or automating the application functional testing, you
>>>> don't
>>>> > need to worry about testing with real mail server.
>>>> >
>>>> > Since you have mentioned as automated test, I assume that you don't mean
>>>> > unit testing.
>>>>
>>>> It is automated acceptance testing .. so testing is strictly at the
>>>> system boundaries. So it has to test the released version of the
>>>> artifact - without *any* changes. I presume that would constrain me
>>>> from introducing a different smtpd.py
>>>>
>>>> > Gopal
>>>> >
>>>> >
>>>> >
>>>> >
>>>> > On Tue, Aug 23, 2011 at 11:39 PM, Dhananjay Nene
>>>> > wrote:
>>>> >
>>>> >> On Wed, Aug 24, 2011 at 11:06 AM, Anand Chitipothu <
>>>> anandol...@gmail.com>
>>>> >> wrote:
>>>> >> > 2011/8/24 Dhananjay Nene :
>>>> >> >> What would be good options to embed a python mail server ?
>>>> >> >>
>>>> >> >> The scope is strictly restricted to automated testing. So the
>>>> embedded
>>>> >> >> mail server (embedded in the test cases) acts as the server which
>>>> >> >> receives email and is in turn further queried to ensure receipt of
>>>> >> >> email correctly.
>>>> >> >>
>>>> >> >> One option is http://lamsonproject.org/
>>>> >> >>
>>>> >> >> Are there any other options you might suggest?
>>>> >> >
>>>> >> > Do you really want to run a mail server fo

Re: [BangPypers] Embedded python mail server

2011-08-24 Thread Dhananjay Nene
On Wed, Aug 24, 2011 at 12:34 PM, Dhananjay Nene
 wrote:
> On Wed, Aug 24, 2011 at 12:25 PM, Gopalakrishnan Subramani
>  wrote:
>> So you basically look for SMTP and also a POP3 access to the server? With
>> that you could send a mail using SMTP and retrieve using POP3 to make sure
>> the mail reached safely? There is no way to get the return receipt in SMTP
>> (sorry, I could be wrong since I coded SMTP & POP3 6 years back with limited
>> support).
>
> Only SMTP with programmatic access to query received emails is good enough.
>>
>> I used jmailsrv which is simple to configure and test on your scenarios.
>>
>> If you could share your testing strategy to test email, it would lead to
>> good discussion.
>>
>
> There is an released artifact "X". X needs to be tested for acceptance
> criteria. No code changes can be introduced into X. X sends out
> emails. Test cases need to test whether the mails got sent out
> correctly. Thus after running test sequences, the mails that have gone
> out need to be verified. The intent is to embed the mail server into
> the test case (not X). Thus outgoing emails from X will get dispatched
> to and received by the embedded mail server. Since test cases (but not
> X) have programmatic access to X and its datastore, using whatever is
> the available mail server api to query the mails it has received is
> acceptable mechanism of verification. Using a embedded python mail
> server helps the test cases to just test the received emails using
> python calls rather than having to do POP3 calls instead.
>
s/programmatic access to X and its datastore/programmatic access to
mail server and its datastore/g
> Dhananjay
>
>>
>> On Wed, Aug 24, 2011 at 12:42 AM, Dhananjay Nene
>> wrote:
>>
>>> On Wed, Aug 24, 2011 at 12:03 PM, Gopalakrishnan Subramani
>>>  wrote:
>>> > Use the http://hg.python.org/cpython/file/2.7/Lib/smtpd.py server. smtpd
>>> is
>>> > a proxy so only look at the client interface level, you may not need to
>>> push
>>> > to local server, no need to store to DB etc.
>>> >
>>> > you copy the file and modify and wrap to meet your automation needs and
>>> to
>>> > get the response confirmation once the mail delivered.
>>> >
>>> > SMTP RFC is very simple to code even in C++ & Java.  But until or unless
>>> you
>>> > have mail client or mail proxy or a email server as your core
>>> > business/module or automating the application functional testing, you
>>> don't
>>> > need to worry about testing with real mail server.
>>> >
>>> > Since you have mentioned as automated test, I assume that you don't mean
>>> > unit testing.
>>>
>>> It is automated acceptance testing .. so testing is strictly at the
>>> system boundaries. So it has to test the released version of the
>>> artifact - without *any* changes. I presume that would constrain me
>>> from introducing a different smtpd.py
>>>
>>> > Gopal
>>> >
>>> >
>>> >
>>> >
>>> > On Tue, Aug 23, 2011 at 11:39 PM, Dhananjay Nene
>>> > wrote:
>>> >
>>> >> On Wed, Aug 24, 2011 at 11:06 AM, Anand Chitipothu <
>>> anandol...@gmail.com>
>>> >> wrote:
>>> >> > 2011/8/24 Dhananjay Nene :
>>> >> >> What would be good options to embed a python mail server ?
>>> >> >>
>>> >> >> The scope is strictly restricted to automated testing. So the
>>> embedded
>>> >> >> mail server (embedded in the test cases) acts as the server which
>>> >> >> receives email and is in turn further queried to ensure receipt of
>>> >> >> email correctly.
>>> >> >>
>>> >> >> One option is http://lamsonproject.org/
>>> >> >>
>>> >> >> Are there any other options you might suggest?
>>> >> >
>>> >> > Do you really want to run a mail server for testing? I usually monkey
>>> >> > patch the function to send email and store the emails in a global
>>> >> > variable for later access.
>>> >> >
>>> >>
>>> >> In automated acceptance testing context I believe it would be
>>> >> appropriate to implement a mail server. With unit tests, stubbing the
>>> >> mail server with a mock would've been fine.
>>> >>
>>> >> Dhananjay
>>> ___
>>> BangPypers mailing list
>>> BangPypers@python.org
>>> http://mail.python.org/mailman/listinfo/bangpypers
>>>
>> ___
>> BangPypers mailing list
>> BangPypers@python.org
>> http://mail.python.org/mailman/listinfo/bangpypers
>>
>
>
>
> --
> --
> http://blog.dhananjaynene.com twitter: @dnene google plus:
> http://gplus.to/dhananjaynene
>



-- 
--
http://blog.dhananjaynene.com twitter: @dnene google plus:
http://gplus.to/dhananjaynene
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Embedded python mail server

2011-08-24 Thread Dhananjay Nene
On Wed, Aug 24, 2011 at 12:25 PM, Gopalakrishnan Subramani
 wrote:
> So you basically look for SMTP and also a POP3 access to the server? With
> that you could send a mail using SMTP and retrieve using POP3 to make sure
> the mail reached safely? There is no way to get the return receipt in SMTP
> (sorry, I could be wrong since I coded SMTP & POP3 6 years back with limited
> support).

Only SMTP with programmatic access to query received emails is good enough.
>
> I used jmailsrv which is simple to configure and test on your scenarios.
>
> If you could share your testing strategy to test email, it would lead to
> good discussion.
>

There is an released artifact "X". X needs to be tested for acceptance
criteria. No code changes can be introduced into X. X sends out
emails. Test cases need to test whether the mails got sent out
correctly. Thus after running test sequences, the mails that have gone
out need to be verified. The intent is to embed the mail server into
the test case (not X). Thus outgoing emails from X will get dispatched
to and received by the embedded mail server. Since test cases (but not
X) have programmatic access to X and its datastore, using whatever is
the available mail server api to query the mails it has received is
acceptable mechanism of verification. Using a embedded python mail
server helps the test cases to just test the received emails using
python calls rather than having to do POP3 calls instead.

Dhananjay

>
> On Wed, Aug 24, 2011 at 12:42 AM, Dhananjay Nene
> wrote:
>
>> On Wed, Aug 24, 2011 at 12:03 PM, Gopalakrishnan Subramani
>>  wrote:
>> > Use the http://hg.python.org/cpython/file/2.7/Lib/smtpd.py server. smtpd
>> is
>> > a proxy so only look at the client interface level, you may not need to
>> push
>> > to local server, no need to store to DB etc.
>> >
>> > you copy the file and modify and wrap to meet your automation needs and
>> to
>> > get the response confirmation once the mail delivered.
>> >
>> > SMTP RFC is very simple to code even in C++ & Java.  But until or unless
>> you
>> > have mail client or mail proxy or a email server as your core
>> > business/module or automating the application functional testing, you
>> don't
>> > need to worry about testing with real mail server.
>> >
>> > Since you have mentioned as automated test, I assume that you don't mean
>> > unit testing.
>>
>> It is automated acceptance testing .. so testing is strictly at the
>> system boundaries. So it has to test the released version of the
>> artifact - without *any* changes. I presume that would constrain me
>> from introducing a different smtpd.py
>>
>> > Gopal
>> >
>> >
>> >
>> >
>> > On Tue, Aug 23, 2011 at 11:39 PM, Dhananjay Nene
>> > wrote:
>> >
>> >> On Wed, Aug 24, 2011 at 11:06 AM, Anand Chitipothu <
>> anandol...@gmail.com>
>> >> wrote:
>> >> > 2011/8/24 Dhananjay Nene :
>> >> >> What would be good options to embed a python mail server ?
>> >> >>
>> >> >> The scope is strictly restricted to automated testing. So the
>> embedded
>> >> >> mail server (embedded in the test cases) acts as the server which
>> >> >> receives email and is in turn further queried to ensure receipt of
>> >> >> email correctly.
>> >> >>
>> >> >> One option is http://lamsonproject.org/
>> >> >>
>> >> >> Are there any other options you might suggest?
>> >> >
>> >> > Do you really want to run a mail server for testing? I usually monkey
>> >> > patch the function to send email and store the emails in a global
>> >> > variable for later access.
>> >> >
>> >>
>> >> In automated acceptance testing context I believe it would be
>> >> appropriate to implement a mail server. With unit tests, stubbing the
>> >> mail server with a mock would've been fine.
>> >>
>> >> Dhananjay
>> ___
>> BangPypers mailing list
>> BangPypers@python.org
>> http://mail.python.org/mailman/listinfo/bangpypers
>>
> ___
> BangPypers mailing list
> BangPypers@python.org
> http://mail.python.org/mailman/listinfo/bangpypers
>



-- 
--
http://blog.dhananjaynene.com twitter: @dnene google plus:
http://gplus.to/dhananjaynene
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Embedded python mail server

2011-08-23 Thread Dhananjay Nene
On Wed, Aug 24, 2011 at 12:03 PM, Gopalakrishnan Subramani
 wrote:
> Use the http://hg.python.org/cpython/file/2.7/Lib/smtpd.py server. smtpd is
> a proxy so only look at the client interface level, you may not need to push
> to local server, no need to store to DB etc.
>
> you copy the file and modify and wrap to meet your automation needs and to
> get the response confirmation once the mail delivered.
>
> SMTP RFC is very simple to code even in C++ & Java.  But until or unless you
> have mail client or mail proxy or a email server as your core
> business/module or automating the application functional testing, you don't
> need to worry about testing with real mail server.
>
> Since you have mentioned as automated test, I assume that you don't mean
> unit testing.

It is automated acceptance testing .. so testing is strictly at the
system boundaries. So it has to test the released version of the
artifact - without *any* changes. I presume that would constrain me
from introducing a different smtpd.py

> Gopal
>
>
>
>
> On Tue, Aug 23, 2011 at 11:39 PM, Dhananjay Nene
> wrote:
>
>> On Wed, Aug 24, 2011 at 11:06 AM, Anand Chitipothu 
>> wrote:
>> > 2011/8/24 Dhananjay Nene :
>> >> What would be good options to embed a python mail server ?
>> >>
>> >> The scope is strictly restricted to automated testing. So the embedded
>> >> mail server (embedded in the test cases) acts as the server which
>> >> receives email and is in turn further queried to ensure receipt of
>> >> email correctly.
>> >>
>> >> One option is http://lamsonproject.org/
>> >>
>> >> Are there any other options you might suggest?
>> >
>> > Do you really want to run a mail server for testing? I usually monkey
>> > patch the function to send email and store the emails in a global
>> > variable for later access.
>> >
>>
>> In automated acceptance testing context I believe it would be
>> appropriate to implement a mail server. With unit tests, stubbing the
>> mail server with a mock would've been fine.
>>
>> Dhananjay
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Embedded python mail server

2011-08-23 Thread Dhananjay Nene
On Wed, Aug 24, 2011 at 11:06 AM, Anand Chitipothu  wrote:
> 2011/8/24 Dhananjay Nene :
>> What would be good options to embed a python mail server ?
>>
>> The scope is strictly restricted to automated testing. So the embedded
>> mail server (embedded in the test cases) acts as the server which
>> receives email and is in turn further queried to ensure receipt of
>> email correctly.
>>
>> One option is http://lamsonproject.org/
>>
>> Are there any other options you might suggest?
>
> Do you really want to run a mail server for testing? I usually monkey
> patch the function to send email and store the emails in a global
> variable for later access.
>

In automated acceptance testing context I believe it would be
appropriate to implement a mail server. With unit tests, stubbing the
mail server with a mock would've been fine.

Dhananjay
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


[BangPypers] Embedded python mail server

2011-08-23 Thread Dhananjay Nene
What would be good options to embed a python mail server ?

The scope is strictly restricted to automated testing. So the embedded
mail server (embedded in the test cases) acts as the server which
receives email and is in turn further queried to ensure receipt of
email correctly.

One option is http://lamsonproject.org/

Are there any other options you might suggest?

Dhananjay
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Create Better Python community

2011-08-21 Thread Dhananjay Nene
On Fri, Aug 19, 2011 at 10:05 PM, Noufal Ibrahim  wrote:
> Anand Chitipothu  writes:
>
>>> Since Noufal is out this week-end, how about next Sat or Sun ?
>>> We can all do a bit of reading up of PyPy this week-end,
>>> discuss in the mailing list over next week, arrive (hopefully)
>>> at a common problem of interest to talk on or hack on next
>>> week-end.
>>
>> Noufal is away until 3rd of September. I think we should go ahead and
>> meet without him.
>>
>> +1 for next weekend.
>
> [...]
>
> Do post a summary to the list. I'll follow it and try to do some reading
> and research by myself.
>
> The JIT parts of PyPy were preceeded by Psyco (which was written by one
> of the PyPy contributors). There is a presentation on Psyco over here
> http://psyco.sourceforge.net/accu2004-psyco.tgz which is quite detailed.
>

These are good reads (they are sequential reads in the pypy docs)

http://codespeak.net/pypy/dist/pypy/doc/jit/overview.html
http://codespeak.net/pypy/dist/pypy/doc/jit/pyjitpl5.html
http://codespeak.net/svn/pypy/extradoc/talk/icooolps2009/bolz-tracing-jit-final.pdf

While I haven't tried it, for advanced study a tool like this is quite
likely to be useful

http://morepypy.blogspot.com/2011/08/visualization-of-jitted-code.html
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


[BangPypers] Would pypy result in a recast of what are the more efficient pythonic idioms ?

2011-08-11 Thread Dhananjay Nene
I had done some benchmarking of code in various languages 3 years ago. I had
not chosen to implement either the most efficient code, instead preferring
to stick to a specific style of implementation. (The experiment is
documented at
http://blog.dhananjaynene.com/2008/07/performance-comparison-c-java-python-ruby-jython-jruby-groovy/)

Curiously I revisited it today and tried it with pypy. The results were most
remarkable.

The python code as mentioned today required 112 μseconds on cPython 2.6
while it ended up requiring only 4.4 μseconds on PyPy (1.5 alpha).

What was even more curious was if one wrote the code differently eg. the
following alternative implementation as suggested in one of the comments.

def findlast(chainlength = 40, kill = 3):
firstinc, c = 1, range(1,chainlength + 1)
while len(c)>1:
c, firstinc = [x for n,x in enumerate(c) if (firstinc+n) % 3], (n+1
+ firstinc) %3
return c

import time
ITER = 10
print findlast()
start = time.time()
for i in range(ITER):
findlast()
end = time.time()
print 'Time per iteration = %s microseconds ' % ((end - start) * 100 /
ITER)

This code times in at about 31 μsec on cPython 2.6 vs 7.45 μseconds on PyPy

So - the code that was 4 times faster on cPython is now 60% as fast on PyPy.
Assuming more examples like this show up - I would imagine the definition of
efficient pythonic idiom to be evolving rather fast in a different direction
as pypy catches traction.

Dhananjay

-- 
--
http://blog.dhananjaynene.com twitter: @dnene
google plus:
http://gplus.to/dhananjaynene
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] PyPy outperforms C in microbenchmark

2011-08-03 Thread Dhananjay Nene
On Wed, Aug 3, 2011 at 9:58 PM, Gopalakrishnan Subramani
 wrote:
> I could not understand the PyPy intention in having another run-time.
>
> Can we see having PyPy running Python programs,
>
> 1.  As a challenge? (A language can have its own runtime with little
> improved performance) or
> 2.  Potential for future to replace/co-exists CPython forever with strong
> community support?
>
> I like to understand, nowhere I am arguing. I don't code full time in
> Python, but I do code till I sleep like reading.

For starters, you might want to check out
http://stackoverflow.com/questions/2970108/pypy-what-is-all-the-buzz-about
(I thought I had seen a much more detailed articulation of the reasons
for pypy, but couldn't quickly enough google for it). A Virtual
Machine based approach is a rather different approach which has over
the last decade started to show strong benefits (especially thanks to
the JVM really making strong advances in the area of virtual machine
engineering, and advanced memory management / garbage collection
algorithms).

There is often a chain of thought that manually handcrafted code is
superior to generated code (in many ways higher level languages often
logically generate low level languages). However as the amount of code
that is written starts getting substantial, the sheer amount of logic
we implement often overwhelms any ability to micro-optimise by
carefully handcrafting code. Moreover as some control is taken away
from programmers (eg, malloc/free), eventually good machine optimised
algorithms can outperform manual code especially when done on a large
scale (eg. generational garbage collectors do a wonderful job on the
JVM). Most importantly the ability of virtual machines to dynamically
monitor program execution and then generate native code for only the
most frequently used parts of the code allows a wonderful balance. eg.
in the article that set of this thread sprintf could not be inlined.
Assuming it was feasible to inline it - it would effectively get
inlined everywhere resulting in a much larger code bloat. Dynamic VMs
can generate native inlined code only for the most frequently used
call-sites (places where sprintf is called) of sprintf (as a arbitrary
hypothetical case say only 5 out of 200 locations in the code - but
these 5 effectively make up 99% of the runtime number of calls to
sprintf). Finally because virtual machines can inspect the actual code
behaviour at runtime make optimisations at runtime which are virtually
impossible at compile or link time (eg. see
http://en.wikipedia.org/wiki/Inline_caching for optimising dispatch to
virtual methods).

All put together there are a number of advantages that this approach
has the potential to offer. In many ways PyPy is starting to show
promise of delivering on these advantages now. However the design of a
virtual machine based approach cannot be an incremental bolt-on to
traditional runtimes, for all practical purposes, it needs a complete
rewrite.
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] PyPy outperforms C in microbenchmark

2011-08-03 Thread Dhananjay Nene
On Wed, Aug 3, 2011 at 1:22 PM, Noufal Ibrahim  wrote:
> Anand Balachandran Pillai  writes:
>
>> On Wed, Aug 3, 2011 at 12:50 PM, Noufal Ibrahim  wrote:
>>
>>>
>>> PyPy outperforms C in a little benchmark capitalising on gcc's inability
>>> to optimise across files.
>>>
>>>
>>> http://morepypy.blogspot.com/2011/08/pypy-is-faster-than-c-again-string.html
>>>
>>
>>  Not sure if that is the only factor playing here. I am pretty sure
>>  the malloc/free every cycle is killing the C program.
>
> [...]
>
> Well, the original benchmark without dynamic allocation is slower that
> the PyPy version too. Your point however is sound.
>
In this case its the difficulty with inlining rather than malloc
(though there could be other situations where a C program could appear
not as fast as others due to malloc/free taking time). Java hotspot
depends to a fair extent on inlining and I presume the same is true
for pypy. Given that hotspot can inline method calls, while gcc is
unable to inline calls into a different library (unless declared as
inline in the headers) thats clearly an area where bytecode based
runtimes can perform superior optimisation. Yet some of it are
advantages that may not remain under code written a little
differently.

I sometimes find people falsely assuming that because some of the
newer JVM based languages compile to byte code they will be as fast as
java - yet sometimes code slows down by orders of magnitude, because
the generated bytecode is difficult to inline.  For an interesting
detailed account of the inlining matter see
http://www.azulsystems.com/blog/cliff/2011-04-04-fixing-the-inlining-problem
I would imagine, similar questions will crop up in the context of PyPy
VM and what constructs of python lend themselves to easy inlining
(functions ??) vs. which ones don't (dynamic dispatch calls on a deep
object tree ??)

Good to see pypy being able to inline well at least in a specific
context. I am sure a well designed garbage collector will also often
outperform naively written free/malloc. So I do hope to see lots of
performance improvements thanks to pypy over a period of time (I
actually am even more keen to see the non-GIL implementation, though
thats likely to be some time away). Definitely exciting developments
(this is but one amongst many other benchmarks they've been publishing
lately).

Dhananjay
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] if not with comparision statement in python

2011-08-02 Thread Dhananjay Nene
On Tue, Aug 2, 2011 at 11:12 AM, Anand Balachandran Pillai
 wrote:
> On Mon, Aug 1, 2011 at 7:51 PM, Dhananjay Nene 
> wrote:
>
>> On Mon, Aug 1, 2011 at 7:26 PM, Anand Balachandran Pillai
>>  wrote:
>> >  IMHO, map/filter/reduce and the inevitable companion lambda were
>> >  added on to Python when it was still trying to find its identity on
>> where
>> >  it stood in the pantheon of dynamic typed languages - since it wanted
>> >  to be everything for everyone it borrowed some of these constructs
>> >  from Lisp or other functional languages.
>> >
>> >  With addition of list comps, generators etc, these right now stand
>> >  out like sore thumbs in the language and should be got ridden
>> >  of at the earliest.
>>
>> I am certain there are contrary opinions, even though the BDFL has
>> weighed in. So yes, python is unlikely to be the playground for these
>> constructs. I find a degree of elegance and utility to these
>> constructs, though it is as well likely that these may seem like sore
>> thumbs to others.
>>
>
>  I also used to think likewise when I first encountered these functions
>  when I was playing around with Python many years back.
>
>  However, I think the "elegancy" is actually a myth and is perhaps
>  a pseudonym for being cryptic.
>
>  For example, look at these competing solutions for summing
>  the squares of first 10 integers.
>
>  1. List comp
>
>  >>> sum([x*x for x in range(10)])
>  285
>
>  2. Map
>
>  >>> sum(map(lambda x: x*x, range(10)))
>  285
>
>  3. Reduce
>
>  >>> reduce(lambda x,y: x + y*y, range(10))
>  285
>
> I dont think there will be much disagreement that the listing is also in the
> order
> of decreasing readability.

There is a risk of conflating three different aspects together

a. Syntax
b. Runtime
c. Concepts

It is understandable that these get conflated in a mailing list
specific to one language and thats fine. But I need to elaborate on
the difference, since that difference is important given that the
elegance is being contested.

a. Syntax :

I am pretty darned sure - in python the syntax when using functions
like map reduce, can sometimes be quite odd. The List comprehension
syntax is succinct and natural. To that end, I immediately clarified
in the thread earlier where I suggested that


def in_range(number, min_max_pairs):
return any(x <= number <=y for x, y in min_max_pairs)


was syntactically superior to


def in_range(number) :
return any(map(lambda (x,y) : x <= number <= y,
 ((0,10),(11,20), (21,30), (31,40


2. Runtime : There's a discussion on the mailing list about how the
runtime influences the performance. Thats adequate reference to the
topic

3. Concepts : I insist the concepts are extremely elegant (which is
what I meant when I referred to elegance earlier).

I mentioned another example from scala :


println(0 to 4 map {_ * 2} map {_ + 1} reduce {_ + _})


It would be interesting to contrast the above in terms of syntax
(expressivity), runtime (absolute runtime performance) and concepts
with


print sum(n * 2 + 1 for n in range(5))


It is my perception that both are readable. The python version is a
bit more concise as well. The key part (which I emphasised a bit
earlier) is composition. While the python version is based out of a
particular syntax which assembles the entire logic as one construct,
the scala version is based on composition of smaller constructs, each
being an independent function (FWIW scala also has an equivalent which
is referred to as the for comprehension). This is but one reason why I
find functional constructs more elegant. This elegance is not a myth,
and I find the ability to compose a program out of smaller building
blocks appealing. As the problems become bigger (than few liners),
this elegance starts becoming quite powerful. And I think it helps all
programmers python or otherwise to use these constructs in their
thought process. Which is where I again meant functions like map are
quite atomic and portable. So the entire reason why I lay this out in
great detail is that I believe - some programmers will be better
served as they start understanding these constructs.

>
> The list comp solution is graspable at one look, the map one takes one
> step of mental computation and the reduce one takes a few mental hoops
> to jump through and is utterly confusing to anyone not familiar with
> list/functional programming.

Absolutely. But just take a look at the scala version - that is not
true. So the issue isn't with the concepts. Its not even an issue with
prefix/postfix or object being a destination of a method call (a la
ruby blocks). Since haskell has a nice syntax for composing 

Re: [BangPypers] List Comprehensions Vs. map/filter (Was: if not with comparision statement in python)

2011-08-01 Thread Dhananjay Nene
On Mon, Aug 1, 2011 at 8:30 PM, Anand Chitipothu  wrote:

> I was trying to translate Python list-comprehensions into Javascript
> and here is what I've come up with.
>
> $pyjs.listcomp(
>    function(x, y, z) { return [x, y, z]},
>    [
>        range(1, 100),
>        function(x) { return range(x, 100)},
>        function(x, y) { return range(y, 100)},
>    ],
>    function(x, y, z) { return x*x + y*y == z*z;}
> )
>
> I haven't worked out the $pyjs.listcomp function implementation yet.
>
There's another one you might want to take a look at
http://rosettacode.org/wiki/List_comprehensions#JavaScript
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] List Comprehensions Vs. map/filter (Was: if not with comparision statement in python)

2011-08-01 Thread Dhananjay Nene
On Mon, Aug 1, 2011 at 8:30 PM, Anand Chitipothu  wrote:
>> I knew there was a way to better implement flatmap - its a combination
>> of itertools.chain.from_iterable and map. Here's a much cleaner code
>>
>> from itertools import chain
>>
>> print filter(lambda (x,y,z) : x*x + y*y == z*z,
>>    chain.from_iterable(map(
>>        lambda x: chain.from_iterable(map(
>>            lambda y: chain.from_iterable(map(
>>                lambda z: [[x,y,z]],
>>                range(y,100))),
>>            range(x,100))),
>>        range(1,50
>>
>
> Impressive. But having to return [[x, y, z]] instead of [x, y,z] is a
> compromise.

No longer. It was there to compensate for an extra chain.from_iterable
(which is not required for the innermost map)

print filter(lambda (x,y,z) : x*x + y*y == z*z,
chain.from_iterable(map(
lambda x: chain.from_iterable(map(
lambda y: map(
lambda z: [x,y,z],
range(y,100)),
range(x,100))),
range(1,50
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] parsing xml

2011-08-01 Thread Dhananjay Nene
On Mon, Aug 1, 2011 at 7:51 PM, Noufal Ibrahim  wrote:
> Anand Balachandran Pillai  writes:
>
>> On Mon, Aug 1, 2011 at 6:08 AM, Anand Chitipothu wrote:
>
> [...]
>
>> It is more subtler than that.
>>
>> List comprehensions are faster than map functions when
>> the latter needs to invoke a user-defined function call or a lambda.
>>
>> Maps score over list comprehensions in most cases where the function
>> is a Python built-in and when no lambda is used.
>>
>> Example of former:
>>
> def f1(): map(sqr, range(1, 100))
>> ...
> def f2(): [sqr(x) for x in range(1, 100)]
>> ...
> mytimeit.Timeit(f1)
>> '37.91 usec/pass'
> mytimeit.Timeit(f2)
>> '37.50 usec/pass'
>>
>> Example of latter:
>>
> def f1(): map(hex, range(1, 100))
>> ...
> def f2(): [hex(x) for x in range(1, 100)]
>> ...
> mytimeit.Timeit(f1)
>> '49.41 usec/pass'
> mytimeit.Timeit(f2)
>> '55.29 usec/pass'
>
> This is confusing. Why is
>
> map(sqr, range(1, 100))
>
> faster than
>
> map(hex, range(1, 100))
>
> Assuming sqr is implemented in python, it should be slower than hex
> which is implemented in C.
Here's what I get (note: sqrt is faster than hex - not sqr)

Program
===
from math import sqrt
from timeit import Timer
def sqr(x) : x * x
print "Simple sqr",  Timer("sqr(50)","from __main__ import sqr").timeit()
print "Simple sqrt", Timer("sqrt(50)","from math import sqrt").timeit()
print "Simple hex",  Timer("hex(50)").timeit()
print "Map sqr", Timer("map(sqr,range(1,100))","from __main__
import sqr").timeit()
print "Map sqrt",Timer("map(sqrt,range(1,100))","from math import
sqrt").timeit()
print "Map hex", Timer("map(hex,range(1,100))").timeit()

Output
==
Simple sqr 0.185955047607
Simple sqrt 0.108409881592
Simple hex 0.143438816071
Map sqr 21.4051530361
Map sqrt 12.3786129951
Map hex 13.8608310223
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] if not with comparision statement in python

2011-08-01 Thread Dhananjay Nene
On Mon, Aug 1, 2011 at 7:26 PM, Anand Balachandran Pillai
 wrote:
>  IMHO, map/filter/reduce and the inevitable companion lambda were
>  added on to Python when it was still trying to find its identity on where
>  it stood in the pantheon of dynamic typed languages - since it wanted
>  to be everything for everyone it borrowed some of these constructs
>  from Lisp or other functional languages.
>
>  With addition of list comps, generators etc, these right now stand
>  out like sore thumbs in the language and should be got ridden
>  of at the earliest.

I am certain there are contrary opinions, even though the BDFL has
weighed in. So yes, python is unlikely to be the playground for these
constructs. I find a degree of elegance and utility to these
constructs, though it is as well likely that these may seem like sore
thumbs to others.

>  Also, using any of the m/f/r trio with lambda is a performance killer.
>  See an earlier post in a different thread for more on this.

Its a performance killer only for cPython - its a function of runtime
not the construct. cPython is likely to stay a poorly performing
runtime for these. I do hope PyPy will fare much better - but that
remains to be seen.  These constructs also help parallelisation (but
only when combined with immutability), and thats a feature python is
likely to be therefore unable to implement as far as I can imagine. Is
this a big deal - frankly no, since the sweet spot of python is pretty
broad.
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] if not with comparision statement in python

2011-08-01 Thread Dhananjay Nene
On Mon, Aug 1, 2011 at 5:44 PM, Dhananjay Nene  wrote:
> On Mon, Aug 1, 2011 at 5:07 PM, Anand Chitipothu  wrote:
>> 2011/8/1 Dhananjay Nene :
>>> On Mon, Aug 1, 2011 at 4:17 PM, Anand Chitipothu  
>>> wrote:
>>>> 2011/8/1 Dhananjay Nene :
>>>>> On Sat, Jul 30, 2011 at 2:15 PM, Asif Jamadar  
>>>>> wrote:
>>>>>> What if I have two lists for both minimum and maximum values
>>>>>>
>>>>>> Minimum  Maximum
>>>>>> 0               10
>>>>>> 11              20
>>>>>> 21              30
>>>>>> 31              40
>>>>>>
>>>>>>
>>>>>> Now how should I check if actual result is not laying between above 
>>>>>> ranges
>>>>>>
>>>>>> if not minimum<=actual_result and  not maximum>=actual_result:
>>>>>>
>>>>>> Any suggestions?
>>>>>
>>>>> def in_range(number) :
>>>>>    return any(map(lambda (x,y) : x <= number <= y,
>>>>>                  ((0,10),(11,20), (21,30), (31,40
>>>>
>>>> How about this?
>>>>
>>>> def in_range(number, min_max_pairs):
>>>>    return any(x <= number <=y for x, y in min_max_pairs)
>>>
>>> Definitely better
>>>>
>>>> List comprehensions and generation expressions are usually more
>>>> readable and expressive than using map.
>>>
>>> Thats probably truer for the python and python trained eyes than any
>>> other (in other words its both subjective and contextual and a bit to
>>> do with syntax). Allow me to illustrate :
>>>
>>> If I want to double all elements in a list and then increment them by
>>> one, here's how I would use a map in python
>>>
>>> def double(x) : return x * 2
>>> def increment(x) : return x + 1
>>> print map(increment,map(double,range(5)))
>>>
>>> and here's how I would do it in scala - notice the last (third) line
>>> and consider its readability (I'm sure a scala non-novice will offer
>>> something even superior)
>>>
>>> def double(n: Int) = n * 2
>>> def increment(n: Int) = n + 1
>>> println(0 to 4 map double map increment)
>>>
>>> so readability is often a function of what one's eyes are trained ot
>>> read and also the syntactic capabilities in the language
>>
>> This is just the prefix/postfix thing.
>>
>> Yes, prefix style is difficult to read if there are too many nested
>> levels. Look at lisp code for example. Yes, it feel it awkward when I
>> have to do range(len(x)). Unix pipes and chaining methods are postfix.
>> What you are doing in scala is just that.
>>
>> If map was a list method, I could do this:
>>
>> range(0, 4).map(douple).map(increment)
>>
>> And as unix pipe:
>>
>> seq 0 4 | double | increment
>>
>>> I also find map much more atomic and portable construct to think in -
>>> after all every list comprehension is syntactic sugar around map +
>>> filter, and map/reduce/filter are far more omnipresent than list
>>> comprehensions.
>>
>> Recently, I was thinking about converting a list comprehension to
>> map/filter calls and It turned out that list comprehensions are more
>> than map+filter.
>>
>> [i * i for i in range(10)]  ~ map(lambda i*i, range(10))
>>
>> [i * i for i in range(10) if i % 2 == 0] ~  map(lambda i*i,
>> filter(lambda i%2 == 0, range(10)))
>>
>> But the situation gets tricky when there are multiple loop items in
>> the list comprehension.
>>
>> Here is a list comprehension to find all Pythagorean triplets below 100.
>>
>> [(x, y, z) for x in range(1, 50) for y in range(x, 100) for z in
>> range(y, 100) if x*x + y*y == z*z]
>>
>> Try converting this into map/filter and you'll understand the difference.
>>
>
> Well, I cheated - there's one more important function (which at least
> I haven't seen in the python library - flatmap)
>
> I constructed my own version
>
> I also constructed my own append_to_list since I didn't know how to
> implement it as a lambda
>
> Here's the code
>
I knew there was a way to better implement flatmap - its a combination
of itertools.chain.from_iterable and map. Here's a much cleaner code

from itertools import chain

print filter(lambda (x,y,z) : x*x + y*y == z*z,
chain.from_iterable(map(
lambda x: chain.from_iterable(map(
lambda y: chain.from_iterable(map(
lambda z: [[x,y,z]],
range(y,100))),
range(x,100))),
range(1,50

PS: There are no more functions required (that I cheated about :))
map, reduce, filter, flatmap equivalent should do it.
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] #lazyweb - How would the wsgi lite proposal help in ..

2011-08-01 Thread Dhananjay Nene
On Mon, Aug 1, 2011 at 5:41 PM, Anand Chitipothu  wrote:
> 2011/8/1 Dhananjay Nene :
>> [..]
>>
>> How could the above proposal (if it does) help in
>>
>> a) Creating simpler, lighter frameworks (eg. flask)
>> b) Help support greater asynchronicity (a la tornado, node.js etc.)
>
> WSGILite looks just like a syntactic sugar for changing:
>
> def app(env, start_response):
>    ...
>    start_response(status, headers)
>    ...
>    return body
>
> to
>
> @lite
> def app(env):
>    return status, headers, body
>
> I don't see how it is solving the async problem.
>
Thanks. That will probably save me some time :)

Dhananjay
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] if not with comparision statement in python

2011-08-01 Thread Dhananjay Nene
On Mon, Aug 1, 2011 at 4:41 PM, Baishampayan Ghose  wrote:
> On Mon, Aug 1, 2011 at 4:38 PM, Dhananjay Nene  
> wrote:
>> I also find map much more atomic and portable construct to think in -
>> after all every list comprehension is syntactic sugar around map +
>> filter, and map/reduce/filter are far more omnipresent than list
>> comprehensions.
>
> The above will especially make sense to someone who programs in
> multiple programming languages in his day job.
>
> Regards,
> BG
>
Actually there was one more aspect I didn't touch upon - why atomic
functions are helpful. So its easier to construct bigger building
smaller building blocks. And one doesn't need to work in different
languages - its doable in python as well.

Functions compose.

I stole a python compose function from
http://en.wikipedia.org/wiki/Function_composition_%28computer_science%29#First-class_composition
(though I reversed the order of functions to help it make a little
easier on the eyes)

If we take the earlier functions double, increment and then want to
also sum up the results, here's how it looks in python using function
compositon
(note the [::-1] - thats the only change I made)

from functools import partial
def compose(*funcs, **kfuncs):
return reduce(lambda f, g: lambda *args, **kaargs: f(g(*args,
**kaargs)), funcs[::-1])

def double(x) : return x * 2
def increment(x) : return x + 1

print compose(partial(map,double), partial(map,increment),
partial(reduce,lambda x,y : x + y))(range(5))

Notice the sequential application of the double, increment and then a
sum operator

The same again in scala (since it is easier in syntax - it will help
relate what the function above is doing

println(0 to 4 map {_ * 2} map {_ + 1} reduce {_ + _})

(the _ refer to the arguments passed to the function - point free programming).

Dhananjay
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] if not with comparision statement in python

2011-08-01 Thread Dhananjay Nene
On Mon, Aug 1, 2011 at 5:07 PM, Anand Chitipothu  wrote:
> 2011/8/1 Dhananjay Nene :
>> On Mon, Aug 1, 2011 at 4:17 PM, Anand Chitipothu  
>> wrote:
>>> 2011/8/1 Dhananjay Nene :
>>>> On Sat, Jul 30, 2011 at 2:15 PM, Asif Jamadar  
>>>> wrote:
>>>>> What if I have two lists for both minimum and maximum values
>>>>>
>>>>> Minimum  Maximum
>>>>> 0               10
>>>>> 11              20
>>>>> 21              30
>>>>> 31              40
>>>>>
>>>>>
>>>>> Now how should I check if actual result is not laying between above ranges
>>>>>
>>>>> if not minimum<=actual_result and  not maximum>=actual_result:
>>>>>
>>>>> Any suggestions?
>>>>
>>>> def in_range(number) :
>>>>    return any(map(lambda (x,y) : x <= number <= y,
>>>>                  ((0,10),(11,20), (21,30), (31,40
>>>
>>> How about this?
>>>
>>> def in_range(number, min_max_pairs):
>>>    return any(x <= number <=y for x, y in min_max_pairs)
>>
>> Definitely better
>>>
>>> List comprehensions and generation expressions are usually more
>>> readable and expressive than using map.
>>
>> Thats probably truer for the python and python trained eyes than any
>> other (in other words its both subjective and contextual and a bit to
>> do with syntax). Allow me to illustrate :
>>
>> If I want to double all elements in a list and then increment them by
>> one, here's how I would use a map in python
>>
>> def double(x) : return x * 2
>> def increment(x) : return x + 1
>> print map(increment,map(double,range(5)))
>>
>> and here's how I would do it in scala - notice the last (third) line
>> and consider its readability (I'm sure a scala non-novice will offer
>> something even superior)
>>
>> def double(n: Int) = n * 2
>> def increment(n: Int) = n + 1
>> println(0 to 4 map double map increment)
>>
>> so readability is often a function of what one's eyes are trained ot
>> read and also the syntactic capabilities in the language
>
> This is just the prefix/postfix thing.
>
> Yes, prefix style is difficult to read if there are too many nested
> levels. Look at lisp code for example. Yes, it feel it awkward when I
> have to do range(len(x)). Unix pipes and chaining methods are postfix.
> What you are doing in scala is just that.
>
> If map was a list method, I could do this:
>
> range(0, 4).map(douple).map(increment)
>
> And as unix pipe:
>
> seq 0 4 | double | increment
>
>> I also find map much more atomic and portable construct to think in -
>> after all every list comprehension is syntactic sugar around map +
>> filter, and map/reduce/filter are far more omnipresent than list
>> comprehensions.
>
> Recently, I was thinking about converting a list comprehension to
> map/filter calls and It turned out that list comprehensions are more
> than map+filter.
>
> [i * i for i in range(10)]  ~ map(lambda i*i, range(10))
>
> [i * i for i in range(10) if i % 2 == 0] ~  map(lambda i*i,
> filter(lambda i%2 == 0, range(10)))
>
> But the situation gets tricky when there are multiple loop items in
> the list comprehension.
>
> Here is a list comprehension to find all Pythagorean triplets below 100.
>
> [(x, y, z) for x in range(1, 50) for y in range(x, 100) for z in
> range(y, 100) if x*x + y*y == z*z]
>
> Try converting this into map/filter and you'll understand the difference.
>

Well, I cheated - there's one more important function (which at least
I haven't seen in the python library - flatmap)

I constructed my own version

I also constructed my own append_to_list since I didn't know how to
implement it as a lambda

Here's the code

def append_to_list(first,second) :
l = first
l.extend(second)
return l

def flatmap(func, val) :
return reduce(append_to_list, map(func,val),[])

print filter(lambda (x,y,z,pred) : pred, flatmap(lambda x:
flatmap(lambda y: flatmap(lambda z: [[x,y,z,x*x + y*y ==
z*z]],range(y,100)), range(x,100)), range(1,50)))



-- 
--
http://blog.dhananjaynene.com twitter: @dnene google plus:
http://gplus.to/dhananjaynene
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] if not with comparision statement in python

2011-08-01 Thread Dhananjay Nene
On Mon, Aug 1, 2011 at 4:17 PM, Anand Chitipothu  wrote:
> 2011/8/1 Dhananjay Nene :
>> On Sat, Jul 30, 2011 at 2:15 PM, Asif Jamadar  
>> wrote:
>>> What if I have two lists for both minimum and maximum values
>>>
>>> Minimum  Maximum
>>> 0               10
>>> 11              20
>>> 21              30
>>> 31              40
>>>
>>>
>>> Now how should I check if actual result is not laying between above ranges
>>>
>>> if not minimum<=actual_result and  not maximum>=actual_result:
>>>
>>> Any suggestions?
>>
>> def in_range(number) :
>>    return any(map(lambda (x,y) : x <= number <= y,
>>                  ((0,10),(11,20), (21,30), (31,40
>
> How about this?
>
> def in_range(number, min_max_pairs):
>    return any(x <= number <=y for x, y in min_max_pairs)

Definitely better
>
> List comprehensions and generation expressions are usually more
> readable and expressive than using map.

Thats probably truer for the python and python trained eyes than any
other (in other words its both subjective and contextual and a bit to
do with syntax). Allow me to illustrate :

If I want to double all elements in a list and then increment them by
one, here's how I would use a map in python

def double(x) : return x * 2
def increment(x) : return x + 1
print map(increment,map(double,range(5)))

and here's how I would do it in scala - notice the last (third) line
and consider its readability (I'm sure a scala non-novice will offer
something even superior)

def double(n: Int) = n * 2
def increment(n: Int) = n + 1
println(0 to 4 map double map increment)

so readability is often a function of what one's eyes are trained ot
read and also the syntactic capabilities in the language

I also find map much more atomic and portable construct to think in -
after all every list comprehension is syntactic sugar around map +
filter, and map/reduce/filter are far more omnipresent than list
comprehensions.
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] parsing xml

2011-08-01 Thread Dhananjay Nene
On Mon, Aug 1, 2011 at 12:46 AM, Noufal Ibrahim  wrote:
> Venkatraman S  writes:
>
>
>> Hang around in #django or #python. The most elegant code that you
>> *should* write would invariably be pretty fast (am not ref to asm).
>
> I agree with you here. Pythonicity is best defined as what the
> experienced python core devs do and the stuff they use the most is
> optimised a lot. Pythonic python code is often the fastest python code.

This is one aspect of python that I am not a fan of. Because being
pythonic conflates the idioms for expression and idioms for
performance. There are situations when the needs of performance
overshadow the needs of expression. As an example creating classes
with attributes - and setting them is more expensive than creating a
dict, and writing a bigger block of sequential code is preferable
(again due to performance considerations) rather than breaking it into
multiple functions and especially when calling functions along with
map, filter, reduce or other itertool constructs (as opposed to say
list comprehensions).

Other languages also have situations where one has to do such
tradeoffs, but these are more in python, and especially alternative
styles of expression imo get buried under the label pythonic. So yes
there is a lot of importance associated with what is pythonic, but I
would've felt more comfortable if these were influence by expression,
rather than performance.

Dhananjay
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] if not with comparision statement in python

2011-08-01 Thread Dhananjay Nene
On Sat, Jul 30, 2011 at 2:15 PM, Asif Jamadar  wrote:
> What if I have two lists for both minimum and maximum values
>
> Minimum  Maximum
> 0               10
> 11              20
> 21              30
> 31              40
>
>
> Now how should I check if actual result is not laying between above ranges
>
> if not minimum<=actual_result and  not maximum>=actual_result:
>
> Any suggestions?

def in_range(number) :
return any(map(lambda (x,y) : x <= number <= y,
  ((0,10),(11,20), (21,30), (31,40

assert in_range(-5) == False
assert in_range(0) == True
assert in_range(5) == True
assert in_range(10) == True
assert in_range(10.5) == False
assert in_range(11) == True
assert in_range(40) == True
assert in_range(41) == False

If the above test cases (asserts) don't match your expectations, the
code may need to be changed correspondingly.
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


[BangPypers] #lazyweb - How would the wsgi lite proposal help in ..

2011-08-01 Thread Dhananjay Nene
After Armin Ronacher's post
http://lucumr.pocoo.org/2011/7/27/the-pluggable-pipedream/ P. J. Eby
responded with 
http://dirtsimple.org/2011/07/wsgi-is-dead-long-live-wsgi-lite.html
with an implementation at https://bitbucket.org/pje/wsgi_lite/

While I could potentially read up the details and find the answers -
wondering if I can lazily wait to find their way into my inbox :)

How could the above proposal (if it does) help in

a) Creating simpler, lighter frameworks (eg. flask)
b) Help support greater asynchronicity (a la tornado, node.js etc.)

Dhananjay

--
--
http://blog.dhananjaynene.com twitter: @dnene google plus:
http://gplus.to/dhananjaynene
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] parsing xml

2011-08-01 Thread Dhananjay Nene
On Mon, Aug 1, 2011 at 12:43 AM, Noufal Ibrahim  wrote:

> Dhananjay Nene  writes:
>
>
> [...]
>
> > re.search("\s*(\d+)\s*",data).group(1)
> >
> > would appear to be the most succinct and quite fast. Adjust for
> whitespace
> > as and if necessary.
>
> Whitespace (including newlines), mixed cases etc.
>
> Actually newlines are handled in the regex above. (so no longer sure why I
even mentioned it), XML (assuming it is as per spec) is not mixed case.


> [...]
>
> > As far as optimisation goes - I can see at least 3 options
> >
> > a. the minidom performance is acceptable - no further optimisation
> required
> > b. minidom performance is not acceptable - try the regex one
> > c. python library performance is not acceptable - switch to 'c'
>
> I'd switch b and c. If elementree is not fast enough, I'd switch to
> celementree and if that's not fast enough, I'd try some hand parsing.
>
+1

Dhananjay
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] parsing xml

2011-07-31 Thread Dhananjay Nene
On Thu, Jul 28, 2011 at 3:18 PM, Kenneth Gonsalves  wrote:

> hi,
>
> here is a simplified version of an xml file:
>
> 
>
>
>
>CloudMade
>
>http://maps.cloudmade.com";>
>
>
>http://cloudmade.com/faq#license
>
>2011-07-28T07:04:01
>
>
>1489
>344
>Sägerstraße
>Im Gisinger Feld
>
>
>
> I want to get the value of the distance element - 1489. What is the
> simplest way of doing this?
>

re.search("\s*(\d+)\s*",data).group(1)

would appear to be the most succinct and quite fast. Adjust for whitespace
as and if necessary.

Yet I would probably use the minidom based approach, if I was sure the input
was likely to be continue to be xml. Anand C's solution (elsewhere in the
thread) reflects the programmers intent in a simpler, less obfuscated form
(both correctly working solutions will communicate the intent with exactly
the same precision - the precision required to make the program work).

As far as optimisation goes - I can see at least 3 options

a. the minidom performance is acceptable - no further optimisation required
b. minidom performance is not acceptable - try the regex one
c. python library performance is not acceptable - switch to 'c'

I can imagine people starting with a and then deciding to move along the
path a->b->c if and as necessary.
I believe starting with b risks obfuscating code (imo regex is obfuscated
compared to xml nodes - YMMV)
I don't know of any python programmers who are speed-maniacs. I am worried
anytime someone programs in something else than assembly/machine code and
uses the latter word. The rest of us are just trading off development speed
vs. runtime speed.

Dhananjay
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Python and Employment

2011-07-16 Thread Dhananjay Nene
On Fri, Jul 15, 2011 at 6:51 PM, kunal ghosh  wrote:
> Hi all,
>
> I read a lot of emails in this list and others, posting job offerings.
> They all list, "years of experience" required by a candidate to be
> considered for the job.
>
> But what is the metric to measure this experience.

The years of experience comes from a broader industry practice (across
all industries - not s/w) where years of experience is a good proxy
for ability to add value at a vocation. As an arbitrary example
consider hospitality management or event management.

The fact remains that there are many occupations where years of
experience has less stronger correlation to potential performance eg.
say a chaffeur.  So many companies tend to quote years of experience
simply out of habit rather than an explicit understanding of the
relationship of experience to potential performance.

However there are factors which can still be influenced by years of
experience even within s/w programming. Ability to interact with
customers, ability to involve oneself into the business domain or
problem space, ability to take on tasks and complete them without
requiring oversight or fine grained guidance still do get influenced
to some extent based on the experience. (I am suggesting there is some
correlation - not how strong it is).

Yet another reason is to increase the probability of finding the right
candidate. A threshold of years of experience is sometimes kept to
reduce the number of interviews that need to be conducted to recruit
one person (presumably because people with lesser years of experience
are lesser likely as a universe to get recruited and thus save
recruitment time).

On the whole recruitment is a very imprecise and brownian process. As
companies realise github commits are an important proxy variable for
potential success on work that will eventually find a way into the
recruitment criteria as well. In the meanwhile, its generally best to
make clear how exactly your experience stacks up against the expected
experience, and if it does not meet the minimum criteria, highlight
the strengths (eg. opensource involvement) which could cause a resume
to be looked as more likely to be eventually recruited than average.
If the company cares for this strengths, great, if not, it probably
was not one you were seeking anyways :)

Dhananjay
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] [OT] language fanaticism

2011-07-16 Thread Dhananjay Nene
On Sat, Jul 16, 2011 at 3:30 PM, Noufal Ibrahim  wrote:
>
> Dhananjay Nene  writes:
>
> [...]
>
> > I suspect it all boils down to whether I value my time and my
> > customer's money over or under my preferred language. Once thats
> > clear - the path ahead also is.
>
> This brings in another variable which is the customer (and therefore
> money). That can alter the stakes quite a bit.
>
> Suppose you were doing something on your own time (like setting up a
> blog), would you rather choose something already built (like wordpress
> or jekyll) or write your own django app *just because the others are not
> in your favourite language*?
>
While that would definitely raise the probability of me doing it in
one of my favourite languages, I would decide that based on
opportunity cost. ie. if it takes me x hours to set up a wordpress
blog and y hours to write / custom craft my own (y being orders of
magnitude bigger than x) then I would trade it off with what else
could I do in those y-x hours.

Looking back, if I assessed that I would get to learn a lot about
something thats on my yet to learn list - I would go write that
blogging platform myself. Else I would use wordpress and use the time
to learn something else. But thats also driven by the fact that I
value learning something new much more than the satisfaction (without
substantial incremental learning) of programming something in the
environment I find most enjoyable.

Dhananjay
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] [OT] language fanaticism

2011-07-15 Thread Dhananjay Nene
On Thu, Jul 14, 2011 at 2:33 PM, Kenneth Gonsalves  wrote:

> On Thu, 2011-07-14 at 10:31 +0530, Baishampayan Ghose wrote:
> > > what fun!
> >
> > I don't understand how Django apps can automatically guarantee a
> > certain level of security while PHP applications can't. Are you trying
> > to indicate that each and every Django app that you've built is free
> > from any security hole?
>
> I would not know - I use standard django with no extra security. When
> they announce that there is a hole, (which they have done twice in the
> last 6 years) I just do an 'svn up'.
>
> Hmm.. I've seen people invest enormous amounts of time and money in
building far more into security than whats provided by the language or the
platform. Built in security features in the platform are critical, but only
the starting point on a very long road.

Dhananjay

-- 
--
http://blog.dhananjaynene.com twitter: @dnene
google plus:
http://gplus.to/dhananjaynene
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] [OT] language fanaticism

2011-07-15 Thread Dhananjay Nene
On Thu, Jul 14, 2011 at 10:03 AM, Noufal Ibrahim  wrote:

> My basic point is that if there's a tool written already that *does* the
> job you want done, would you stay away from it purely because its not in
> your favourite language?
>

No.

Boils down to whether I am going to be a user or a developer. If I am just
going to "use" a blogging platform - wordpress makes a lot of sense to use
simply because you can have a blog up and running before you can even
schedule a meeting to decide what features one needs to build in the
blogging platform. And if the incremental changes are look and feel or
rather modest in their reach - its far easier to just outsource. It all
stems from how one values customers money and one's own time. If I am going
to use the blog just as a starting point for a much bigger CMS, then a whole
host of issues such as self's skills, proclivities, team skills, skill
availability, learning curve, platform features, performance features, all
need to get factored in.

I suspect it all boils down to whether I value my time and my customer's
money over or under my preferred language. Once thats clear - the path ahead
also is.
-- 
--
http://blog.dhananjaynene.com twitter: @dnene
google plus:
http://gplus.to/dhananjaynene
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


[BangPypers] Cool developments on the PyPy front

2011-06-30 Thread Dhananjay Nene
This is an informational post only. I've been watching some of the
performance developments on PyPy, but this one made me feel real good.
Apparently PyPy is going to lose the GIL and implement locking via STM

http://morepypy.blogspot.com/2011/06/global-interpreter-lock-or-how-to-kill.html

-- 
---
http://blog.dhananjaynene.com twitter: @dnene
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Web Application Development

2011-05-19 Thread Dhananjay Nene
On Thu, May 5, 2011 at 3:47 PM, OOMMEN KM  wrote:

> Hi All,
>
> I would like to know which technology should I use for developing a web
> based application.
> The application will have to handle a huge amount of data and we are using
> MySQL.
> Will mod_python a good option for the development of this application? Or I
> need to choose some frame works?
>
> Please help me.
>
> I cannot speak for whether mod_python is dead or alive. Resolving the
Schrödinger's cat paradox could perhaps be easier. My opinions however would
be that it would depend very substantially upon the nature of the
application.

a. For extremely high concurrency I would look at tornado. However it has
relatively limited features - so more often than not I would usually give it
a pass.
b. For most apps, and especially if I wanted a comprehensive well integrated
framework - I would look to django. It also happens to perhaps be one of the
most frequently used.
c. I chose pylons since it better followed my preference of integrating
multiple tightly focused frameworks (for templating / databases etc.). Note
that pylons is now no longer actively developed and its successor is
pyramid. However I haven't really looked at pyramid though thats the one you
would want to look at. One particular aspect of pylons is that it does not
itself contain a ORM and is usually used with sqlalchemy. Since you
specifically mentioned large data - this option of pyramid + sqlalchemy
might give you better mileage if the huge data needs to be maintained in a
RDBMS.

There are a number of other useful frameworks as well including web.py,
turbogears etc, but I am not experienced enough to comment on them.

Also there are many other light weight / micro frameworks (eg. flask, bottle
etc.) You could also consider using sqlalchemy in conjunction with such
micro frameworks as well if you need a simple web tier with some complex
database handling.

Dhananjay

Oommen Mathew | +91 9446917322
> ___
> BangPypers mailing list
> BangPypers@python.org
> http://mail.python.org/mailman/listinfo/bangpypers
>



-- 
---
http://blog.dhananjaynene.com twitter: @dnene
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] The myth of free software

2011-05-19 Thread Dhananjay Nene
On Wed, May 18, 2011 at 6:41 PM, Anand Balachandran Pillai <
abpil...@gmail.com> wrote:

> On Wed, May 18, 2011 at 6:34 PM, Santosh Rajan 
> wrote:
>
> > Ok I will agree to stop, under one condition, can you please explain  the
> > code I have written above?
> >
>
> Well, thank you for the wholesome entertainment you provided.
> Well, it was fun while it lasted... Goodbye.
>
> Ahh .. didn't realise this thread had ended when sending my earlier mail
since I was scanning the thread chronologically.  I think dead threads
should remain so, and people like me who dig such threads out of their grave
should go and do some penance for such a heinous deed.
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] The myth of free software

2011-05-19 Thread Dhananjay Nene
Precisely my question on your original post.

On Tue, May 17, 2011 at 11:23 AM, Santosh Rajan  wrote:

> Are you talking to thin air? You haven't quoted anything???
>
> On Tue, May 17, 2011 at 11:19 AM, Noufal Ibrahim  wrote:
>
> > You're confusing open source, free software and free of cost software.
> > Also, your approach and choice of words is not one that kindles a
> > healthy debate. I don't expect this thread to lead anywhere useful.
> >
> > --
> > ~noufal
> > http://nibrahim.net.in
> > ___
> > BangPypers mailing list
> > BangPypers@python.org
> > http://mail.python.org/mailman/listinfo/bangpypers
> >
>
>
>
> --
> http://about.me/santosh.rajan
>
> “The *young man* knows the rules but the *old man* knows the
> exceptions”. *Oliver
> Wendell Holmes*
> ___
> BangPypers mailing list
> BangPypers@python.org
> http://mail.python.org/mailman/listinfo/bangpypers
>
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] Interesting post on Ruby concurrency model

2011-02-23 Thread Dhananjay Nene
On Thu, Feb 24, 2011 at 8:08 AM, Ramdas S  wrote:
> On Thu, Feb 24, 2011 at 1:58 AM, Dhananjay Nene 
> wrote:
>
>> http://merbist.com/2011/02/22/concurrency-in-ruby-explained/
>>
>>
> nice one. I didn't quite follow some of the stuff. For eg:the fiber in Ruby,
> do we have something similar in Python?

I think the details may vary but at least at a high level stackless
python has the same intent with its micro threads. I remember Anand P.
also posting this link a while back to be able to implement similar
functionality in CPython
http://www.ibm.com/developerworks/library/l-pythrd.html

Dhananjay
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


[BangPypers] Interesting post on Ruby concurrency model

2011-02-23 Thread Dhananjay Nene
http://merbist.com/2011/02/22/concurrency-in-ruby-explained/

Posting here since there's probably a lot of matters here which
pythonistas would be interested in. While there are a few comments on
the post, the twittersphere had actually some far more interesting
discussions.
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] NoSQL

2011-02-13 Thread Dhananjay Nene
This is not in response to any specific comment as opposed to an addition to
the overall thread, and just a quick formatting of some of my findings on
the matter.

a. Understanding of CAP theorem
http://www.julianbrowne.com/article/viewer/brewers-cap-theorem and its
relevance in the specific set of use cases in consideration is extremely
important before wading into the noSQL land. One needs to decide whether one
wants to build a CA, AP or CP system. Note that it is rather easy to get
confused between the implications of A and P - so spend some time on that.

b. The candidate databases once the constraints are decided becomes visible
http://blog.nahurst.com/visual-guide-to-nosql-systems . Now there exist a
number of differences within these databases. eg. Simple key value vs.
document, relational vs. schemaless, disk based vs. in memory, etc. etc.

There are at least two applications where I actively approached the problem
space with an intent to use noSQL database but concluded that it simply was
not possible given the fact that the expectations were indeed CA. Recently I
was able to explore using a noSQL since I decided the usecase required an AP
set of requirements.

Dhananjay


-- 

blog: http://blog.dhananjaynene.com
twitter: http://twitter.com/dnene
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] NoSQL

2011-02-13 Thread Dhananjay Nene
On Sun, Feb 13, 2011 at 3:06 PM, Anand Balachandran Pillai <
abpil...@gmail.com> wrote:

> On Sun, Feb 13, 2011 at 2:21 PM, Noufal Ibrahim  wrote:
>
> > On Sun, Feb 13 2011, Anand Balachandran Pillai wrote:
> >
> > > I am sure many of you must have gone through this discussion, but
> > > sharing it anyway since I liked the analogy he makes with SQL against
> > > NoSQL compared to transmission in cars.
> >
> > I liked the analogy but don't agree with the second paragraph. It's not
> > only about size. Thanks to the dominance of SQL databases, everyone
> > tends to think of them as the "default" and use noSQL only if
> > necessary. That needn't be the case. Small (non Google, non Facebook)
> > applications that need to store documents (e.g. a wiki) *might* work
> > better with a noSQL backend than a relational one
> >
>
> Does it really matter in a small-size wiki project whether you are
> using SQLite to store your data, vs a mongodb that just runs on
> your machine ?


Well, its easier to look up wiki pages from their slugs (primary keys).
Besides you could store additional metadata about the page easily using a
json syntax to go over and beyond the wiki markdown text as an example.


> I would rather go for the sqlite solution since,
>
> 1. It is the most simplistic RDBMs one can think of.
> 2. You get the power of SQL, thereby chance of writing
>  adhoc queries in the future.
>

Not specifically referring to a single machine use case, but a nosql +
lucene solution could perceivably be more natural. In a wiki the adhoc
queries beyond free text search are likely to be less frequently used.


>
> I don't agree with it. One of the basic premises from where the nosql
> platforms come is that they are trying to solve problems where your
> data is distributed in a scale that traditional RDBMs would find it
> difficult
> to address with sufficient performance. If I use the "CAP" terminology,
> nosql is solving the problems of A and P on a large scale while
> making no promises on the C side.
>
> Unless your wiki need to scale to at least 100K nodes or more,
> I don't see a real technical reason to use document stores apart from
> relieving you upfront of complex schema design and writing SQL queries.
> If you mean that is "better" for you, then we are talking of different
> problems here. Mileages vary.
>
>
> >
> > > http://stackoverflow.com/questions/2559411/sql-mysql-vs-nosql-couchdb
> > >
> > > It might be a cliche, but I kind of feel the current "NoSQL movement"
> > > is simply a case of "The grass must be greener on the other side".
> >
> > I don't really follow "movements" but disagree agree with your general
> > statement.
> >
> > The kinds of data and hardware that people are dealing with have changed
> > and different problems are cropping up. The constraints and requirements
> > have changed as well. New technologies have come up to address these
> > problems and given that we live in these times, it's quite possible that
> > the problems we face might fall into the categories for which these
> > systems have been designed. It's unwise to summarily dismiss document
> > stores out of the box.
> >
> > Also, the transition is not abrupt (SQL yesterday, noSQL today). SQL
> > databases have been used in a semi schemaless fashion e.g. Triple
> > stores[1], Entity-attribute-value model[2] etc.
> >
> > For some kinds of datasets, sound RDMS rules are violated to gain
> > performance. e.g. Denormalisation[3]. These kinds of things indicate
> > that RDBMs systems are not designed to handle certain classes of
> > problems that are cropping up and new solutions have to be sought out.
> >
> > It's an engineering problem. Different situations call for different
> > tools and solutions.
> >
> > I personally tend to ignore the whippersnappers with their "SQL suxx0rZ!
> > noSQL roX!" outlook and the grumpy SQL advocates with their "Get off my
> > lawn!" attitude.
> >
>
> You might have got me wrong. My point was that there seems to be a
> trend where programmers and designers choose to implicitly assume that
> just because their data is expected to scale to gigabytes or terabytes
> in the future, the right choice upfront is a Document store (I prefer to
> use this term as against the confusing "nosql" one), which is not
> the correct way to do this.
>

+1. I tend to prefer viewing the situation as a set of prioritised CAP
requirements.

There are quite a few situations where one might require a very high
scalability but CA requirements abound (eg. banking / financial apps) -
where introducing noSQL would be a pain, whereas one might just want a 3
node wiki (to reuse the example above) which simply is always available
regardless of partition failures even though it serves say only 10 users
- and many noSQL solutions might serve that situation just fine.

Because noSQL emerged out of an unsatisfied demand for the scalability in
the extreme hardly means there is a very strong correlation between noSQL
and scalability 

Re: [BangPypers] Ideas for Python concurrency...

2011-02-08 Thread Dhananjay Nene
On Tue, Feb 8, 2011 at 2:15 PM, Vishal  wrote:

> On Tue, Feb 8, 2011 at 2:10 PM, Baishampayan Ghose  >wrote:
>
> > > Mutliprocessing means, data copying, talking to each other through
> PIPES,
> > > also it has its issues with running on Windows (all function calls
> should
> > be pickelable)
> > >
> > > Threads seems pretty stable on most platforms where Python runs.
> >
> > Threads won't help you much because of the Python GIL.
> >
> > Regards,
> > BG
> >
> > --
> > Baishampayan Ghose
> > b.ghose at gmail.com
> > '
> >
>
> The GIL is only limited to one interpreter. GIL comes into picture because
> Threads in python create a new interpreter context, so the same interpreter
> switches to new byte codes. The original idea was to create a new
> interpreter for each thread, each one with its own GIL !!!. All within the
> same process.
>

Interesting. But that does raise some curious issues of sharing data across
interpreters.
So as per the original thought - would threads be able to access data across
multiple
interpreters (to implement shared data), or would they have completely
isolated
data islands via message passing ?

Dhananjay

>
> Vishal
> ___
> BangPypers mailing list
> BangPypers@python.org
> http://mail.python.org/mailman/listinfo/bangpypers
>
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] refactoring

2010-12-06 Thread Dhananjay Nene
On Wed, Dec 1, 2010 at 4:33 PM, Kenneth Gonsalves  wrote:

> hi,
>
> I know that this has cropped up in a parallel thread, but anyway I would
> like a new thread on this. In a LUG list a ruby guy made a statement
> that 'No self respecting developer could function without having read
> the refactoring book'. How relevant is this to python? I do not see much
> except years ago something called bicycle repair man - is that still
> used? or is this whole thing buzz?
>

This thread seems to have gone all over the place. So I would add my
thoughts on the original question and slink away.

Refactoring is often performed by most developers independently of whether
or not they have read the book.
Yes a self respecting developer can function without reading the refactoring
book.
Yes the self respecting developer just might develop a little bit more of
self respect if he read the refactoring book.

Restricting to my own experience in java and python

a. I used to refactor like crazy in java. I tend to do it less often in
python.
b. The likely reason is that I find eclipse refactoring capabilities in java
very very strong. OTOH, with python automated refactoring, one can never be
too sure.
c. Generally speaking in java, I've found myself refactoring - in python
I've found myself rewriting. Should I need to refactor, I usually rearrange
the code to decompose it better at a higher level, and then rewrite the
lower level functions entirely. Part of the reason why I find myself doing
that would be that in most cases my python functions are quite small - so
rewriting them is often no big deal.
d. Refactoring without having test cases is a strong test for bravery.
Usually I classify myself as timid in such situations and either write some
tests or back off.

Dhananjay

--
> regards
> Kenneth Gonsalves
>
> ___
> BangPypers mailing list
> BangPypers@python.org
> http://mail.python.org/mailman/listinfo/bangpypers
>



-- 

blog: http://blog.dhananjaynene.com
twitter: http://twitter.com/dnene
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] regular expression for Indian landline numbers

2010-11-25 Thread Dhananjay Nene
On Fri, Nov 26, 2010 at 11:59 AM, Dhananjay Nene
wrote:

>
>
> On Fri, Nov 26, 2010 at 11:40 AM, Kenneth Gonsalves wrote:
>
>> On Fri, 2010-11-26 at 11:30 +0530, Mandar Vaze / मंदार वझे wrote:
>> > look at
>> > http://en.wikipedia.org/wiki/Mobile_telephone_numbering_in_India
>> > (But kenneth may have already looked at this)
>>
>> no, I had not looked at this - I was not looking for the mobile scheme
>> which is fairly simple.
>>
>
> For a generic scheme
> http://en.wikipedia.org/wiki/Telephone_numbers_in_India
>
> But I couldn't find out any programmable pattern to identify how long is a
> STD code given a full number. Having said that, at least for most generic
> scenarios STD code is simply an indicator relic of how telephone exchanges
> work, in most cases an unimportant part of the full 10 digit number
>
> Here's another link which is quite topical :
http://blog.stevenlevithan.com/archives/validate-phone-number

>
>> regards
>> Kenneth Gonsalves
>>
>> ___
>> BangPypers mailing list
>> BangPypers@python.org
>> http://mail.python.org/mailman/listinfo/bangpypers
>>
>
>
>
> --
> 
> blog: http://blog.dhananjaynene.com
> twitter: http://twitter.com/dnene
>



-- 

blog: http://blog.dhananjaynene.com
twitter: http://twitter.com/dnene
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] regular expression for Indian landline numbers

2010-11-25 Thread Dhananjay Nene
On Fri, Nov 26, 2010 at 11:40 AM, Kenneth Gonsalves wrote:

> On Fri, 2010-11-26 at 11:30 +0530, Mandar Vaze / मंदार वझे wrote:
> > look at
> > http://en.wikipedia.org/wiki/Mobile_telephone_numbering_in_India
> > (But kenneth may have already looked at this)
>
> no, I had not looked at this - I was not looking for the mobile scheme
> which is fairly simple.
>

For a generic scheme http://en.wikipedia.org/wiki/Telephone_numbers_in_India

But I couldn't find out any programmable pattern to identify how long is a
STD code given a full number. Having said that, at least for most generic
scenarios STD code is simply an indicator relic of how telephone exchanges
work, in most cases an unimportant part of the full 10 digit number

--
> regards
> Kenneth Gonsalves
>
> ___
> BangPypers mailing list
> BangPypers@python.org
> http://mail.python.org/mailman/listinfo/bangpypers
>



-- 

blog: http://blog.dhananjaynene.com
twitter: http://twitter.com/dnene
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] regular expression for Indian landline numbers

2010-11-25 Thread Dhananjay Nene
On Thu, Nov 25, 2010 at 3:11 PM, Kenneth Gonsalves wrote:

> hi,
>
> on looking at the telephone book, Indian landline numbers have three
> forms
>
> 3 digit STD code followed by 8 digits
> 4 digit STD code followed by 7 digits
> 5 digit STD code followed by 6 digits
>
> the first digit of the STD code has to be 0. The first digit of the
> landline number starts from 1-6. Of course I am not dead sure of the
> starting numbers, but I have seen mobile numbers starting with 9 and 8,
> and I think 7 is also reserved for mobile. I could not find any
> authorative info on this. This is the re:
>
> r'(^0\d{2}[-\s]{1}[1-6]{1}\d{7})|(^0\d{3}[-\s]{1}[1-6]{1}\d{6})|(^0
> \d{4}[-\s]{1}[1-6]{1}\d{5})'
>
> any clues on how to make it shorter? And any info as to whether my
> assumptions as to the landline numbers is correct?
>

Not to take away the fun that so many are obviously having on this thread,
but at least from a business perspective what generally matters (barring
some rare exceptions) is that Indian phone numbers are all 10 digits. :)

Thus there could be the optional prefixes +91 or 0 followed by an additional
sequence of numbers which may have embedded some spaces, hyphens or in rare
cases parenthesis which are quite ignorable.

So all one really needs to do (say if one wants to call back) is to extract
one single 10 digit number using the above logic by stripping off the
optional prefixes and the extra characters (which I presume would be quite
trivial). But then maybe my mind is not working well today early morning :)

Dhananjay

--
> regards
> Kenneth Gonsalves
>
> ___
> BangPypers mailing list
> BangPypers@python.org
> http://mail.python.org/mailman/listinfo/bangpypers
>



-- 

blog: http://blog.dhananjaynene.com
twitter: http://twitter.com/dnene
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] parsing directory and subdirecties

2010-11-19 Thread Dhananjay Nene
On Sat, Nov 20, 2010 at 5:28 AM, Vasudevan N  wrote:

> The simplest way would be to use recursive calls.
>
Vasu,

a. That could still entail a loop on a files per directory basis
b. If you avoid the loop and recurse on a per file (eg by shaving the head
off the sequence and passing on the tail), there's no tail call optimization
to avoid a stack overflow.

Dhananjay

>
> Thanks,
> Vasu
>
> On Wed, Nov 17, 2010 at 8:05 PM, Nitin Kumar  wrote:
>
> > hi all,
> >
> > is there any simple way where a can parse into directory and
> subdirectories
> > to get the detail of files and count.
> >
> > or do i need to use looping and other functionalities.
> >
> > --
> > Nitin K
> > ___
> > BangPypers mailing list
> > BangPypers@python.org
> > http://mail.python.org/mailman/listinfo/bangpypers
> >
> ___
> BangPypers mailing list
> BangPypers@python.org
> http://mail.python.org/mailman/listinfo/bangpypers
>



-- 

blog: http://blog.dhananjaynene.com
twitter: http://twitter.com/dnene
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


  1   2   >