Re: [BangPypers] Python training material
On Mon, Jan 19, 2015 at 11:39 PM, Suyash Bhatt bhatt.suy...@gmail.com wrote: Hi Friends, I am looking for any Basic training material for Python which can be shared across (with due credit). Please let me know if anyone can help me with that. There's a list the Pune Python community compiled = http://pune.python.org.in/pages/python-resources.html It's not comprehensive, but there's a few good books in there. - d ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Python certifications in India
On Wed, Dec 24, 2014 at 12:02 AM, Noufal Ibrahim KV nou...@nibrahim.net.in wrote: On Wed, Dec 24 2014, Saager Mhatre wrote: [...] We... I wouldn't put quite as much stock in the CCNA given the people we interviewed at TW for a sysad position. CCNA's are the lowest rung as far as I know. They're fairly easy to get too. CCIEs are very hard to get and the ones I know who have the certification are top players in their game. [...] Agreed. - d ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] How to dynamically load modules in Django/Python
On Wed, Dec 17, 2014 at 11:19 PM, Navin Kabra na...@smriti.com wrote: Saager Mhatre saager.mha...@gmail.com writes: I suppose the __import__ function https://docs.python.org/3/library/functions.html#__import__ should be a good start. Also check out the imp module. from imp import load_source load_source('myname', 'myname.py') Navin/Dhruv, I believe the documentation indicates that the imp module is deprecated in 3.4 in favour of importlib, which is what the __import__ function wraps anyway. - d ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] How to dynamically load modules in Django/Python
On Thu, Dec 18, 2014 at 12:18 AM, mithun chackravarthy vbnetmit...@gmail.com wrote: Thanks Saager, got it. http://imdb.to/glad-to = One is glad to be of service. - d ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Python certifications in India
On Mon, Dec 22, 2014 at 2:36 AM, Bibhas Ch Debnath m...@bibhas.in wrote: Is there anyone or any company here that actually values a certificate for Python? In my experience, certification courses mean nothing, at least for Python developers. None of the people I know or have worked with, cares about a certificate. I'd love to meet someone who thinks otherwise. That's putting the cart before the horse, wouldn't you say? There isn't really a question of anyone valuing them because they don't quite exist. :) - d ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Python certifications in India
On Mon, Dec 22, 2014 at 2:54 AM, Noufal Ibrahim KV nou...@nibrahim.net.in wrote: On Mon, Dec 22 2014, Bibhas Ch Debnath wrote: Is there anyone or any company here that actually values a certificate for Python? In my experience, certification courses mean nothing, at least for Python developers. None of the people I know or have worked with, cares about a certificate. I'd love to pmeet someone who thinks otherwise. [...] Some companies sell products that require a lot of expertise for the end user (e.g. Cisco). Configuring their equipment/software can be a full time task in itself. If the company themselves do this for their end clients, they'll get a services component bolted onto their product and that will affect their long term plans. However, if they can create some kind of qualification in the market and provide material for that, people unassociated with the company will try to get it and will become employable. In that sense, certifications do have value. Given two people of roughly equal experience, if I were hiring someone to watch over a network of Cisco gear, I'd pick the one who has a Cisco certification. We... I wouldn't put quite as much stock in the CCNA given the people we interviewed at TW for a sysad position. Language certifications don't really fall into this but I suppose when the ecosystem is large enough (e.g. Java), you can cut off a piece and certify people in that department. I have my own views about language/framework certifications http://www.quora.com/What-IT-training-institution-in-Mumbai-Maharashtra-India-will-best-help-me-in-attaining-a-certification-in-the-Java-programming-language/answer/Saager-Mhatre, but IMHO, Sun did the best job of the lot. Their tests really tested your understanding of the nuances of the language/framework. It will have marketing value for a class of clients. Python doesn't (yet) come under this category so I don't think there are any certifications in India. I don't know many people who use Python that would consider a certificate as something valuable. The only certificate course for Python that I know of is the O'Reilly one. [1]. Footnotes: [1] http://www.oreillyschool.com/certificate-programs/python-programming/ Third party certifications bear only as much weight as the... well, third party! Granted O'Reilly has a lot of clout in the publishing and tech event space, but I'm not too enthusiastic about them certifying peoples' python skills; more to the point, who's building the curriculum/tests? The certificates would have to be handed out by the PSF or any of the other bodies core to the python development effort for them to carry enough weight. Just saying. - d ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] combine multiple modules in one
On Wed, Dec 17, 2014 at 1:05 PM, Nitin Kumar nitin.n...@gmail.com wrote: Hi, say I am installing a module abc and it got multiple dependent modules say xyz pqr. pip easy install will take care of downloading and installing these. but i need to install abc on a device which doesnt have net connection. how do you currently install 'abc' onto the device? So do i need to copy tar.gz for each abc, pqr, xyz and install all individually or is there a way i can create one installer say final.tar.gz out of abc, xyz, pqr (on off box) and copy final.tar.gz to device and install using it. If I am thinking in totally worng direction, do let me know what all option i have. is there any already existing sdk for the same?? Nitin K ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers - d ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] How to dynamically load modules in Django/Python
On Mon, Dec 15, 2014 at 1:52 AM, mithun chackravarthy vbnetmit...@gmail.com wrote: How can I achieve this.Thanks for your time. I suppose the __import__ function https://docs.python.org/3/library/functions.html#__import__ should be a good start. - d ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Python Gotcha Fibonacci
Spend some time to logically think about what is semantically different in the two implementations, focus on the types of the values and operations invoked thereon. - d ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Python is still greek to india's top IT firms
On Wed, Sep 17, 2014 at 6:54 AM, Senthil Kumaran sent...@uthcode.com wrote: [...] Given that world is moving to multiple language shops and almost all companies will use more than one language in their offerings Some would beg to differ http://tek.io/1yjHw0U - d ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Python is still greek to india's top IT firms
On Wed, Sep 17, 2014 at 6:54 AM, Senthil Kumaran sent...@uthcode.com wrote: [...] From my experience at Akamai Bangalore, when we had to hire Java developers for my team, we had 100s of resumes competing for single spot, but we looked for quality python developers, there were very less 10 (and all of them known folks) who could easily land up in the role. Not to sound overly disparaging, but that argument reeks of survivorship bias, or at least confirmation bias.What about all the shops looking for python devs but not finding any good ones; you know, like the ones that aren't connected to the community? Contrast that with the number of 'conventional language' programmers and recruiters who aren't connected to the community but still manage to get jobs. Personally, I think us tech-savvy types tend to get too caught up in these debates and read too much into it. IMHO, language choice tends to me more flavour of the day than we'd like to admit; and there's nothing wrong with that. While we're so worried about how technology works, the other side is too busy figuring out what they want to do with it to care about our concerns. That said, I'm not saying they get it right all the time either; just that we need to tone down the, my language kicks your language's ass, 'cause... well, check out all the cool people we can hire rhetoric. Just sayin' - d ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Return values
On Sat, Sep 20, 2014 at 6:53 AM, Noufal Ibrahim KV nou...@nibrahim.net.in wrote: On Sat, Sep 20 2014, Anand Chitipothu wrote: [...] Oh, that feels like PHP. That style seems to be popular in that side of the world. It might be a good idea to add consolidate method on the return value. Something like: class StatsList(list): def consolidate(self): .. print get_stats(..) print get_stats(..).consolidate() [...] That's a nice solution. It's similar to what Senthil suggested but I like the API better. Alternatively, would it be possible to model Stats/StatsList as a composite hierarchy (potentially with Courtesy Implementations http://martinfowler.com/bliki/CourtesyImplementation.html)? - d ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] python in news
On Wed, Sep 3, 2014 at 2:37 AM, Nitin Kumar nitin.n...@gmail.com wrote: http://economictimes.indiatimes.com/tech/software/programming-language-python-yet-to-find-place-in-teaching-curriculum-in-india-despite-its-popularity/articleshow/41464925.cms Anyone have a link to that IEEE report mentioned in the article that puts Python as the 2nd most popular web-dev language? Curious about who else is on the list and why. - d ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] The Python I would like to see - Armin Ronacher
On Tue, Aug 19, 2014 at 11:23 AM, Noufal Ibrahim nou...@nibrahim.net.in wrote: On 2014-08-19 11:11, Sriram Narayanan wrote: Hi Noufal, could you elaborate on this? I have enjoyed the freedom of non-static typing that Python and Ruby offer, but also sometimes miss the static type checking that C# and Java offer. Yes. I like the freedom and they're great for prototyping. When things get large with a lot of moving parts, you need to write elaborate tests at every layer to validate the whole thing and even then, things slip through. That's just a question of testing strategy. If you're writing 'elaborate' tests at every layer, you're probably validating too much or exercising too much of the system at each layer of testing. The cartesian product of tests required to validate every implementation at a level of abstraction is inevitable if you want confidence in all those implementations; but these need to be limited to each pair of collaborator as far as possible so that so single test becomes too elaborate. But that's a different discussion altogether. However, I always got the sense that dynamic languages made this both easier and hard at the same time. Easier in that you didn't have to declare explicit interfaces between layers; harder in that all barking ducks are only identified at runtime! I've also felt that the freedom encourages a kind of loose thinking that I have to guard against. I'm glad somebody finally said this; and doubly so that it was Noufal! ;) - d ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] The Python I would like to see - Armin Ronacher
On Tue, Aug 19, 2014 at 12:45 PM, Noufal Ibrahim nou...@nibrahim.net.in wrote: On 2014-08-19 12:31, Saager Mhatre wrote: That's just a question of testing strategy. If you're writing 'elaborate' tests at every layer, you're probably validating too much or exercising too much of the system at each layer of testing. The cartesian product of tests required to validate every implementation at a level of abstraction is inevitable if you want confidence in all those implementations; but these need to be limited to each pair of collaborator as far as possible so that so single test becomes too elaborate. But that's a different discussion altogether. However, I always got the sense that dynamic languages made this both easier and hard at the same time. Easier in that you didn't have to declare explicit interfaces between layers; harder in that all barking ducks are only identified at runtime! I suppose so. My epiphany was that tests, at the end of the day, are code. They need to be maintained, refactored, cleaned up, optimised, cajoled and worshipped just like one does with the actual application. The less code I write, the better. So, yes, it's a tradeoff. Once upon a time, a more naive version of myself loved the freedom that I got from this kind of thing. The cynical version of myself that's typing this email is not so sure anymore. He, at some level, feels that the extra headache of specifying interfaces is a better investment than using a dynamic language and writing tests to validate all the possible inputs. Hear, hear! All he younglings pay heed, the master hath spoken. Again, glad this was said without beating about the bush; and glad *you* said it! ;) I'm glad somebody finally said this; and doubly so that it was Noufal! ;) I'm surprised that you've never heard this from me before. It's something that I decided on a LONG time ago. I realized this myself a long time ago, around the time I joined TW and started putting Ruby in production. However, all the dynlang love in the air at the time seemed to be blinding people to it. Since then I've sensed this sentiment among those that have grown wiser with age and experience. But you're the first one I've heard call it out without mincing words. - d On 2014-08-19 12:31, Saager Mhatre wrote: That's just a question of testing strategy. If you're writing 'elaborate' tests at every layer, you're probably validating too much or exercising too much of the system at each layer of testing. The cartesian product of tests required to validate every implementation at a level of abstraction is inevitable if you want confidence in all those implementations; but these need to be limited to each pair of collaborator as far as possible so that so single test becomes too elaborate. But that's a different discussion altogether. However, I always got the sense that dynamic languages made this both easier and hard at the same time. Easier in that you didn't have to declare explicit interfaces between layers; harder in that all barking ducks are only identified at runtime! I suppose so. My epiphany was that tests, at the end of the day, are code. They need to be maintained, refactored, cleaned up, optimised, cajoled and worshipped just like one does with the actual application. The less code I write, the better. So, yes, it's a tradeoff. Once upon a time, a more naive version of myself loved the freedom that I got from this kind of thing. The cynical version of myself that's typing this email is not so sure anymore. He, at some level, feels that the extra headache of specifying interfaces is a better investment than using a dynamic language and writing tests to validate all the possible inputs. I'm glad somebody finally said this; and doubly so that it was Noufal! ;) I'm surprised that you've never heard this from me before. It's something that I decided on a LONG time ago. ___ 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] Mailing list etiquette
On Fri, Aug 8, 2014 at 12:03 AM, Noufal Ibrahim KV nou...@nibrahim.net.in wrote: On Mon, Aug 04 2014, Jeffrey Jose wrote: [...] .. and since I use browser, I appreciate an email that's nicely formatted. Yes, that includes contextual information with embedded images. Fair enough. However, large attachments being duplicated on a *mailing list* is unnecessary. That's the consderation. Things are different for your personal communication. [...] Didn't we already have this discussion on this list? Besides, doesn't mailman let us set a limit on the attachment size? One configuration to rule them all! - d ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Mailing list etiquette
On Mon, Aug 4, 2014 at 9:06 PM, Anand Chitipothu anandol...@gmail.com wrote: Not only that, it is a pain to download something and open it in some application just to know what is inside. It is a lot better to send a link instead of sending attachments. Anand, how do you consume your emails? I get my emails on my phones as well, in gmail, which has a preview feature in both desktop and on mobile. Even when it is a python file? Attached source code files generally open up as text files. - d ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] how to override sys.stdin
On Mon, Aug 4, 2014 at 2:38 PM, Nitin Kumar nitin.n...@gmail.com wrote: Hi All, is there a way i can override raw_input or input function. This sooo smells of the XY Problem http://bitly.com/XyProblem. What are you really trying to do here? - d ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Packaging in Python
On Jan 10, 2014 4:26 AM, Venu Murthy ve...@thoughtworks.com wrote: Hello friend! This was the first time, we are actually writing some serious code and it found it quite not like Python when packing for the code to be deployed on a windows machine. We were using the setuptools build and install to do this... and it wasn't easy and finally had to install PIP on our windows machine install the dependencies... please let me know if there is a better way of packaging and deployment for python! You're half way there. distribute + pip + virtualenv is the way to go. Use pypiserver to host your private packages if you don't want to push them to PyPI; or Gemfury if you want a hosted solution. However, if you're developing on python3, you might have to look at the new distutils 'cause it covers (at least tries to cover) the feature set from all those. - d ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Object Oriented Programming in python
On Oct 22, 2013 10:54 AM, Sirtaj Singh Kang sir...@sirtaj.net wrote: I agree with you partially - MOP in python can get ugly, but there's plenty of power there. I'll try to explain, though this stuff is notoriously hard to articulate (may be just for me). Oh, trust me, it's not just you! We should start a club, I'm sure we'll find plenty of members. :) So the main role of metaprogramming was to expose the language's object system as an object model to the programmer, so that it could be queried and manipulated at runtime. Does python do this? Yes, but not quite in the way that Kiczales outlined. Like I said, the reflective metaprogramming nuts and bolts are all there; it's just that Python expects you to pick up a spanner and put all of them together every time. No thank you. BTW, thanks for the Kiczales reference. Added to my reading list. Instead we get some rough-and-ready tools with which you can simulate the effects that a proper MOP system (such as in CLOS) might have, and when having to make a choice between flexibility vs performance and code clarity, python's designers have almost invariably chosen the latter. I guess we're going to have to agree to disagree on that last point. I don't find the MOP implementation in Ruby or Groovy less per for many or leading to obscure code. On the contrary, I find Python's 'rough-and-ready tools' make for more confusing metaprogramming code. YMMV To begin with, there is a level of metacircularity in the new-style type system: isinstance(object, object) True isinstance(type, type) True isinstance(object, type) True isinstance(type, object) True I think the metacircularity is almost in avoidable if reflective metaprogramming is a goal. I don't mind it much now that I understand it. This is what the metaclass system uses. With old-style classes, you had a lot of flexibility to change the class of objects at runtime. Nowadays there are a lot more restrictions, mostly due to performance, but you can still do some silly stuff: MyType = type('MyType', (type,), {}) MyCircularType = MyType('MyCircularType', (MyType,), {}) MyCircularType.__class__ = MyCircularType isinstance(MyCircularType, MyCircularType) True Ah yes, old-style classes! But I'd be hard pressed to call that MOP as there are no real metaobjects at play. It's just classes and instances where instances could have their class swapped out from under them (yikes!) That's a fun example, though. :) And then of course there's things like get/setattribute - combined with the abc module in the standard library, the type trickery above and python's basic metaclass system, you could effectively create your own metacircular MOP protocol on top of python.* Yeah, Python's fundamental unit being the function causes me some cognitive dissonance when a lot of the OO utilities (like get/setattr) work outside-in while others (like the dunder methods) work inside-out. As for the abc module, the documentation was involved enough to turn me off that part of the toolkit. But that's another discussion altogether. Also, you could create/simulate MOP using the tools Python provides you, but I'd much rather the platform give me a consistent implementation than have to deal with N people each implementing their own special variant of what they think MOP should be. Another major issue is that python's syntax makes it just not a great language for embedded DSLs and MOP, even to the extent that other dynamic languages (Ruby!) are. That's not going to change though, and I'm personally okay with it for the most part. If I wanted to program CLOS, I'd program CLOS. Agreed on the bit about syntax; never delved into CLOS, so I'll stay away from that bit. Like I said, I believe Python has a sweet spot and I'm OK using it for that. It's just that some of these features don't figure in that spot IMHO. * In fact, I spent quite a while doing so a few years ago - implementing the OMG MOF on python - and it worked pretty well, but it proved difficult to get it to the point where I could even properly explain it to people. You did... what!?! :O I'm not sure whether that deserves respect or sympathy! :D - d ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Object Oriented Programming in python
On Oct 21, 2013 11:34 AM, Noufal Ibrahim nou...@nibrahim.net.in wrote: [...] It's the final frontier beyond which space lies (sorry). Dude, Space __is__ the final frontier! (Heh, see what I did there? :) Anyway, thanks for the other refs. - d ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Object Oriented Programming in python
On Oct 21, 2013 11:39 AM, Dhananjay Nene dhananjay.n...@gmail.com 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. 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. 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. - d ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Object Oriented Programming in python
On Oct 21, 2013 12:09 PM, Dhananjay Nene dhananjay.n...@gmail.com 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 dhananjay.n...@gmail.com 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. 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) ? Yup! Look for Categories. The Groovy guides have a bunch of examples. (Nothing to do with category theory AFAIK) 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 While I haven't implemented any yet, Groovy's AST transforms make implementation as well as application fairly easy. But, that wasn't my point. What I meant was that Python's meta classes only kick in at module/lass load time whereas Metaclasses in the other languages play a greater role at runtime. - d ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Object Oriented Programming in python
On Oct 21, 2013 3:21 PM, Dhananjay Nene dhananjay.n...@gmail.com wrote: On Mon, Oct 21, 2013 at 3:02 PM, Saager Mhatre saager.mha...@gmail.com wrote: On Oct 21, 2013 12:09 PM, Dhananjay Nene dhananjay.n...@gmail.com 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 dhananjay.n...@gmail.com 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! 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 to/methods of the class (or object) are dispatched. Python conflates metaprogramming into metaclasses where it is not a necessity, in that Python metaclasses can do little more of value than add/remove/modify attributes of the class; in other words, metaprogram elements of class definition. Man, I should start a list of misnamed concepts in Python! Hey, there's my talk for the next PyCon- Python, the misnamed bits! :D That said, I've been meaning to do a decent talk on metaprogramming and wanted to do a first round at PythonPune. Maybe if thinrhino bugs me about it enough, I might just... :) - d ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Object Oriented Programming in python
On Mon, Oct 21, 2013 at 7:11 PM, Dhananjay Nene dhananjay.n...@gmail.comwrote: 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 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'll discover the benefits. My grievance with Python's metaprogramming capabilities is another matter altogether and warrants a different thread. But, just because you mentioned it, I''ll put it down in one line- I don't find Python's metaprogramming inadequate, it's all there; it's just that the capability is (both syntactically and semantically) cumbersome at best and clumsy at worst. 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 to/methods of the class (or object) are dispatched. Python conflates metaprogramming into metaclasses where it is not a necessity, in that Python metaclasses can do little more of value than add/remove/modify attributes of the class; in other words, metaprogram elements of class definition. Sure python does do a lot of things differently. But the question I am interested in an answer to is does it empower the user to do / constrain the user from doing certain things as compared to similar languages, distribution of functionality within meta* terms notwithstanding. To reiterate, yes, I believe Python's metaclasses (differently implemented as they are) are constraining specifically for the point I mentioned above in this very note. Python's metaclasses do not allow for the modification of the behaviour of a class/object at runtime. The way I see it, the best they do is extract boilerplate code from class definitions. I can get that with class decorators and avoid all the confusion about how Python does metaclasses differently as well as how metaclasses wire into the type system. To me, Python's metaclasses provide too little value for the cognitive load they add, YMMV. - d * They really should've stuck to Class Decorators and avoided the confusion, or did those come after metaclasses? ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Object Oriented Programming in python
On Fri, Oct 18, 2013 at 11:33 AM, Dhananjay Nene dhananjay.n...@gmail.comwrote: On Tue, Oct 15, 2013 at 2:33 PM, Dhruv Baldawa dhruvbald...@gmail.com 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. :| - d ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Object Oriented Programming in python
On Tue, Oct 15, 2013 at 1:46 AM, Pranav Raj pranav09...@hotmail.com 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? Pranav, dude, really sorry man, but I don't know if we answered your question! We seem to have gone off on a somewhat different direction on this thread. Feel free to jump in and refocus if you deem necessary. Apologies again. :P - d ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Object Oriented Programming in python
On Oct 15, 2013 4:10 AM, Dhananjay Nene dhananjay.n...@gmail.com wrote: On Tue, Oct 15, 2013 at 1:46 AM, Pranav Raj pranav09...@hotmail.com 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. 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.) Trust me, I spent almost a week trying to wrap my head around this before I figured out that Python Metaclasses are just Class Decorators done differently (read- requiring you to understand more of the internals without providing too much more benefit.) Just start using the features and over a period of time you will gain a reasonable understanding of the subtleties. thank you, Pranav Raj Pranav, I'd suggest you keep an open mind and go with what the language/platform provides you. Python is one of those 'get stuff done' kind of languages and has a sweet spot, but OO isn't quite all in that spot. There is some overlap, but it can be hard to find. ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Object Oriented Programming in python
On Oct 18, 2013 10:54 AM, s|s supr.e.etse...@gmail.com 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. I think it's a little unfair to club C++ and Java in the same bucket just because one borrows some syntactic elements from the other in order to maintain a smooth migration path. Python implements OOP differently from imperative languages of C family like C++ and Java. Umm... I don't know if anyone's told you yet, but Python is also essentially an imperative programming language. The reason, I think is C++ and Java are very much driven towards machine code efficiency whereas Python is very much about developers productive. You couldn't be far from the truth. While, syntactically, Python is touted to be more reader-friendly, that was also one of the design goals of Java. Just because a bunch of people write bad Java code doesn't mean that the language leans toward low-level optimizations; I've seen enough atrocious Python code in my 2.5 years working with it that has obliterated any notion of readability/productivity. And anyone suggesting LOC comparisons better be prepared for some righteous Monty Pythonic Trout Slapping! Also, comparing a dynamically typed language to two statically typed languages is hardly fair. A comparison to other dynamically typed, imperative languages like Groovy, Ruby or SmallTalk would be more useful; all of which, BTW, provide primitives for the kind of encapsulation the OP is looking for. To this end Python developers must have thought of data hiding as not an important language goal. That makes no sense. Implementing the notion of encapsulation doesn't particularly get in the way of developer productivity. If anything, it enhances productivity by providing compiler/interpreter hints that communicate when developers are engaging in undesirable resource access. Mind you Python does allow data hiding through slots but it is not as straight forward as C++ or Java. Sigh! Implementing a reasonably important feature in an obscure manner (that too, not completely, since even slots are accessible from outside an object) is not in keeping with friendliness. I say this feature is reasonably important since it is repeatedly brought up every few months with little to no satisfactory responses most of which is 'we are all adults here', which I am hard pressed to accept as a generalization on account of all the atrocious code mentioned above. - d ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Object Oriented Programming in python
On Oct 21, 2013 1:18 AM, s|s supr.e.etse...@gmail.com wrote: 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. Seriously, we're arguing primitive types here?!? I mean, I'll admit they're a blemish, but (as Dhananjay mentioned) they're hardly there to improve bytecode generation. They were put in to appease the (memory) bean counters so that they could control the heap sizes of objects, at least in their heads. That said, the Tiger release introduced autoboxing, which dealt with this. The JVMs runtime performance magic lies elsewhere entirely. I'm banging this mail out on a tablet over GPRS, otherwise I would've hunted down a few references for you. Honestly, I urge you to look at other OO languages like SmallTalk (where it sort of all began), Ruby Groovy, or even JavaScript for that matter. Just like we don't want to be narrow about what comprises OO, we should also not restrict our examples/experience of OO implementations to C++ Java (aside from Python*). - d * The OO implementation in which I find somewhat questionable, but I digress... :) ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Object Oriented Programming in python
On Oct 21, 2013 11:14 AM, Noufal Ibrahim nou...@nibrahim.net.in wrote: Saager Mhatre saager.mha...@gmail.com writes: [...] since even slots are accessible from outside an object __slots__ are not meant for data hiding. They're meant as a final trick to save memory when you have a large number of objects of the class you're interested in. If you define a __slots__ variable, you lose the class dictionary (since that consumes some amount of memory) but you get smaller objects. The gory details are here http://hg.python.org/cpython/file/9e322a8f80d9/Objects/typeobject.c [...] Ah, that explains so much. I've always been confused about slots and the documentation almost always added to it. Does this mean that once you drop to slots, you also lose the descriptor- based dispatch magic? That would make this a pretty desperate hack for some last resort memory conservation! - d ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Noob trying to get into python
On Mon, Oct 7, 2013 at 3:18 PM, Avneesh Chadha avneesh.cha...@gmail.comwrote: Hi, I have been working in java for the last 6 months, but really want to get into python .Could anyone point me to any open source project which could help me get relevant experience for a python based development. http://pune.python.org.in/pages/python-resources.html Anything from that list should be a good start. - d ___ 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!
On Thu, Oct 3, 2013 at 11:01 AM, Mandar Vaze / मंदार वझे mandarv...@gmail.com wrote: http://bit.ly/1dXgwqD Dude, that was mean! :S A lmgtfy link behind a bitly link!?! :) - d ___ 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!
On Oct 3, 2013 9:40 AM, Dhananjay Nene dhananjay.n...@gmail.com wrote: On Thu, Oct 3, 2013 at 8:19 AM, Mandar Vaze / मंदार वझे mandarv...@gmail.com 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. - d ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] need help w.r.t itertools
On Sep 16, 2013 12:50 PM, Dhananjay Nene dhananjay.n...@gmail.com wrote: On Mon, Sep 16, 2013 at 12:27 PM, Suyash Bhatt bhatt.suy...@gmail.com 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'] Suyash, Again, since you started with itertools, I'm assuming you don't want to have the entire lost evaluated before hand. In which case you're looking for the itertools.ifilter [ http://docs.python.org/2.7/library/itertools.html#itertools.ifilter ] function. Alternatively, you could just change that last statement to be a generator expression instead of a lost comprehension[1]. I suggest you sit down with the itertools docs [ http://docs.python.org/2.7/library/itertools.html ] open in one window, a python console in another; and experiment with the tool set provided to see how best you can express your problem. The module is one of the better documented ones and is reasonably intuitive. Feel free to get back to the list with any specific technical issues you encounter, but, IMHO, us regurgitating the relevant docs here is not the best use of either of our time. That said, this thread is starting to smell of the XY Problem [ http://bit.ly/XyProblem ]. Suyash, it will probably be very helpful to all if you could give us a general idea of what it is that you are trying to achieve with all these tid-bits of information. Maybe could someone could point you to a simple or more appropriate solution. - d [1] unless I'm missing something and list comprehension are inherently lazy. ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Do you pin your requirements.txt ?
On Sep 16, 2013 8:46 AM, Dhananjay Nene dhananjay.n...@gmail.com 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. 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. Either approach could very well be put down as a stylistic difference, but the specific compatibility of these approaches with different build tools (distutils, setuptools/easy_install, distribute/pip) makes it significant, IMHO. Noufal, maybe this could be something to consider exploring in your course. That said, I can't believe what a wonderful conversation this has turned into. For the benefit of members outside the overlap, I'm cross posting to the other python lists with a link to the entire conversation = http://bit.ly/16c6Kv8 - d ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Debugging functions/tools/ways
On Sep 14, 2013 11:00 AM, Balachandran Sivakumar benignb...@gmail.com wrote: When you find some time, please do post a few Python dtrace one-liners here. It would be useful to the rest of us. Thanks Oh... man... I want to +1 this... so... many... times!!! Ram, you should totally share your experiences with this. - d ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Regd feedback (was: Online Python workshop)
On Sun, Sep 15, 2013 at 9:25 PM, Saager Mhatre saager.mha...@gmail.comwrote: On Sep 15, 2013 6:12 PM, Noufal Ibrahim nou...@nibrahim.net.in wrote: Annapoornima Koppad a.kop...@gmail.com writes: HI Noufal, Thanks for the tutorial. I read through the tutorial. The topic was definitely different than most of the tutorials that are online. So I have to write the code myself before I give other comments. Thanks. I'd appreciate the feedback. Dude, what's the best way to send you feedback on this? Do we just mail you or is there a repo we can comment/pull from? (facepalm) Apologies, I intended to send this just to Noufal; accidentally sent to list. - d ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
[BangPypers] Regd feedback (was: Online Python workshop)
On Sep 15, 2013 6:12 PM, Noufal Ibrahim nou...@nibrahim.net.in wrote: Annapoornima Koppad a.kop...@gmail.com writes: HI Noufal, Thanks for the tutorial. I read through the tutorial. The topic was definitely different than most of the tutorials that are online. So I have to write the code myself before I give other comments. Thanks. I'd appreciate the feedback. Dude, what's the best way to send you feedback on this? Do we just mail you or is there a repo we can comment/pull from? - d ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Mail formatting for this list
On Sun, Sep 15, 2013 at 9:14 AM, Mandar Vaze / मंदार वझे mandarv...@gmail.com wrote: I dont understand. What's your viewport width? Can that only support 80ish chars? Are you on mobile/tablet? It is not uncommon for people to read/respond to emails on mobile/tablet. So for emails, 80-character width isn't bad choice. My Google Nexus 7 wrapped your mail thusly = http://twitpic.com/ddnb3k 'Nuff said. - d ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Do you pin your requirements.txt ?
On Sep 16, 2013 12:38 AM, Kiran Jonnalagadda j...@pobox.com wrote: We deploy multiple times a day and I don't find that the gap between a Travis test and production deployment is so long that an upstream release within those few seconds broke compatibility. Kiran Dude, can I quote you on that? 'Cause that's probably *the* most awesome pitch for agile, lean, fail early-fail often, short feedback loops, automation, CI CD all rolled into one that I've heard in quite a while! Like, totally WOW! - d ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Do you pin your requirements.txt ?
On Sep 13, 2013 9:19 AM, Dhananjay Nene dhananjay.n...@gmail.com wrote: [...] Given adequate test coverage to verify negative side effects of any transitive dependency version upgrades, pinning could be skipped imo. Dhananjay +1 for automated tests to cover relevant API contracts of dependencies. That's a great approach to decide when to pin. Thanks for pointing that out Dhananjay. - d ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Favorite tips/techniques
On Sep 9, 2013 8:51 PM, CsquaredinOmaha c2inom...@yahoo.com wrote: For a while I had thought it would be interesting to hear tips/techniques you find yourself often using - or perhaps found useful at one point (and thus would be valuable to newbies). It could be simple snippet, or some description of logic, technique or steps. From simple to sophisticated is less the issue - more that you found it handy and used it alot. Whatever use area: ETL data files, servers, SQL maintenance, webcrawlers, anything. == Writing tests as top-level functions as opposed to methods of a unittest.TestCase subclass == Aside from the obvious advantage of eliminating ceremony, this has the effect of forcing me to make sure that each test is entirely and atomically independent of other tests. That way, I only ever have to read one function to understand the nature of a given test failure. Also, not having the ability to easily slap on setup/teardown functions/methods forces me to make tests self-contained. Add in the heuristic that tests with long/complicated arrange and/or act sections are indicative of potential design flaws and you have the requisite TDD feedback. It also helps tremendously that both nosetest and pytest support this idiom. - d ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
[BangPypers] Python packages and modules (was: Favorite tips/techniques)
On Fri, Sep 13, 2013 at 1:10 PM, Saju M sajup...@gmail.com 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 stdin, line 1, in module NameError: name 'json' is not defined * import json* * json* module 'json' from '/usr/lib/python2.7/json/__init__.py' * json.tool* Traceback (most recent call last): File stdin, line 1, in module AttributeError: 'module' object has no attribute 'tool' * from json import tool* * json* module 'json' from '/usr/lib/python2.7/json/__init__.py' * tool* module 'json.tool' from '/usr/lib/python2.7/json/tool.py' * json.tool* module 'json.tool' from '/usr/lib/python2.7/json/tool.py' * * 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] (steps behind transparent blast shield to calmly enjoy the sight of more exploding heads) - d [1] I don't believe it would be entirely in the best interest of either of our healths to use this term outside of this thread! [2] IIRC, this was not true for python 2.5 (I think); I recall hitting some really weird import errors when running newer code on a really old interpreter when it suddenly couldn't reference the packages that a loaded module belonged to until they were explicitly loaded. [3] To those in the know, I would be tremendously obliged if you could tell me what brand of blow they were using when they came up with this byzantine, labyrinthine nomenclature and related implementation. I bet it was, as they say, like, totally radical dude! ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Debugging functions/tools/ways
On Fri, Sep 13, 2013 at 2:46 PM, Anand Chitipothu anandol...@gmail.comwrote: On Fri, Sep 13, 2013 at 2:36 PM, Dhruv Baldawa dhruvbald...@gmail.com wrote: This is what I use for debugging: from IPython.core.debugger import Tracer; Tracer()() works mostly like pdb, with some nice features like tab completions The best debugging tool I've used so far is the print statement. What about others? Unit tests... anyone? :) - d ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
[BangPypers] Mail formatting for this list
Mods/Admins, Is there a specific reason we've set this list to wrap all mail messages at 80 characters? Just that it seems a little unnecessary to me, give all the hi-resolution wide-screen displays in general use. Just saying. - d ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Favorite tips/techniques
On Sep 9, 2013 8:51 PM, CsquaredinOmaha c2inom...@yahoo.com wrote: For a while I had thought it would be interesting to hear tips/techniques you find yourself often using - or perhaps found useful at one point (and thus would be valuable to newbies). It could be simple snippet, or some description of logic, technique or steps. From simple to sophisticated is less the issue - more that you found it handy and used it alot. Whatever use area: ETL data files, servers, SQL maintenance, webcrawlers, anything. The 'returning' function = http://bit.ly/13VNdBJ - d ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] need help w.r.t itertools
On Fri, Sep 13, 2013 at 5:01 PM, Dhruv Baldawa dhruvbald...@gmail.comwrote: d = [''.join(x) for x in itertools.product(a, b, c)] Actually, using itertools.imap would ensure that the elements aren't computed till necessary. So... d = itertools.imap(''.join, itertools.product(a, b, c)) - d ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Python packages and modules (was: Favorite tips/techniques)
On Fri, Sep 13, 2013 at 6:50 PM, Dhananjay Nene dhananjay.n...@gmail.comwrote: Nice. I reached out for the Favourite button but realised emails/mailing lists don't have it. (takes a bow) 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. I specifically chose not to generalize both of them into a single abstraction of 'namespace' because of the inconsistency in behaviour. Treating them as two different abstractions helps me keep the inconsistency as well as conflation clear in my head. In my experience, the last time I tried to resolve that into a single notion, it kept tripping me up at the 'loading' cases, esp when trying to include how older versions worked. But YMMV. Here's the result (Have attempted to only make minor structural corrections without adjusting any of the opinions or rationale expressed herein) Your result is not bad, but I still prefer my original approach. No offence. :) Oh, and I'm still waiting on an answer for [3]. ;) - d ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Python packages and modules (was: Favorite tips/techniques)
On Sep 13, 2013 9:10 PM, venkatakrishnan g superpuls...@gmail.com wrote: Oh, dexterous just blew my head! Music to my ears. :D - d ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Python Wats
On Tue, Sep 10, 2013 at 10:14 AM, Shabda Raaj sha...@agiliq.com wrote: This is a popular talk on quircks of ruby/js https://www.destroyallsoftware.com/talks/wat What are the quircks/unexpected behavior you find in Python? (Aka Python wats). Wait a second... wasn't there a talk about just this captioned Python, the weird bits http://bit.ly/P5aECR at last years PyCon India? Oh right, I delivered it! :P Here's my repo https://github.com/dexterous/python-the-weird-bits from which I demo'd the 'wat' code. Also linked were my noteshttp://simp.ly/publish/FJPwPcthat include more weird bits that I couldn't fit into the talk for lack of time contrived examples. HTH -d ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Favorite tips/techniques
On Tue, Sep 10, 2013 at 10:39 AM, Shabda Raaj sha...@agiliq.com wrote: https://github.com/webpy/webpy/blob/master/web/utils.py#L52 Wow, thats better than the bare bunch impl. Gonna use it now. plug type=shamelessIt's just s much nicer when the map/dict in your platform http://groovy.codehaus.org/Collections#Collections-Mapsmaps just does that for you :)/plug - d ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Do you pin your requirements.txt ?
On Thu, Sep 12, 2013 at 6:30 PM, Abdul Muneer abdulmun...@gmail.com 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 - d ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Favorite tips/techniques
On Tue, Sep 10, 2013 at 4:54 PM, Noufal Ibrahim nou...@nibrahim.net.inwrote: Saju M sajup...@gmail.com writes: [...] * Why dir(json) not showing tool ?? Because of the __all__ variable in the module. http://docs.python.org/2/tutorial/modules.html Noufal, Well, not quite, right? I posit it's basically because as per python module-import semantics, sub-modules don't end up as names in the package-module[*] unless explicitly added, right? Saju, I sincerely hope your head didn't just explode! :P - d [*] for lack of a better word! ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Help Required with understanding Python Import
On Tue, Sep 10, 2013 at 3:39 PM, konark modi modi.kon...@gmail.com wrote: Hi Jagan, This should be of your interest : http://pyvideo.org/video/1707/how-import-works Jagan, This makes for an interesting read too = http://lucumr.pocoo.org/2009/7/24/singletons-and-their-problems-in-python/ - d ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] How to run a block of code just before the interpreter is being exited like END{} in perl ??
On Tue, Sep 3, 2013 at 1:27 AM, Anand B Pillai anandpil...@letterboxes.orgwrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Monday 02 September 2013 08:09 PM, venkatakrishnan g wrote: import atexit def callback(): print about to exit! atexit.register( callback ) Better use it as decorator. import atexit @atexit.register def last_man_standing(): print Hasta la vista, Baby.p With a verb name like *register* I'd much prefer to call the function as opposed to using it as a decorator. The more idiomatic decorators have noun names, viz- property, classmethod, staticmethod, unittest.expectedFailure, (or the one you used below) contextmanager, etc. I'll admit 'unittest.skipTest' is an anomaly, but I've always felt that the unittest module was a somewhat unpythonic 1-1 port of JUnit, so we'll let that one slide. :) The other reason in favour of the invocation syntax over the decorator syntax would be that the 'atexit.register' function is variadic and it would not be possible to send in the arguments to be passed in at exit if 'atexit.register' were used as a decorator. Of course, we could nest the decorated function in another function to provide a lexical closure that would then allow us to specify those arguments, but explicitly declaring the parameters to the cleanup function and explicitly passing them to register just seems much more idiomatic to me. [...] - -- Regards, - --Anand - -- Software Architect/Consultant anandpil...@letterboxes.org Please note my updated email address anandpil...@letterboxes.org. Kindly update your address books. -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBAgAGBQJSJO29AAoJEHKU2n17CpvDSK4IALaLNb/tP3MjUE6EvQskn8EQ SLg2BuUY0dy2f+QfHQ2bBZLj3unuHHPHlugfK8wGbNpB80rGm0lpoyqxiU7H2JnN aSXGyAS435VemqohOr26ZN/5nsYdSkz87KnJNlZ8YagPd+RaDZd/dc6BNM3er7va DioJnm+txAqIenv3xGeYNQfs7U7QljKcdrzqPjJuQp65ZmSUbcfmPls1I7B6Oxxe 1Xj+ax/N3wJeNKkWZKsvOJsHgQNMjNhTICfH8Ofsv0c04mlXI/Ej3+yIzQ/2tZwc k9jQrlX/Wgv+Mza41RPCtJTJGkbfFVTCOiQQjvwA4ZnriuwmTAcH2axELbSr1aU= =E2cM -END PGP SIGNATURE- ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers I realize I'm a little late to the thread, but just thought I'd put in my 2c. - d ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] How to run a block of code just before the interpreter is being exited like END{} in perl ??
On Tue, Sep 3, 2013 at 8:47 AM, Anand B Pillai anandpil...@letterboxes.orgwrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Tuesday 03 September 2013 06:27 AM, Anand Chitipothu wrote: This is another version of this by mucking around directly with sys.exitfunc using a with context. from contextlib import contextmanager @contextmanager def end_of_days(): def wrapper(): print 'Goodbye.' yield wrapper with end_of_days() as sys.exitfunc: print 3+4 How is this different from: import sys def goodbye(): print Goodbye sys.exitfunc = goodbye I don't think we are really doing anything with the context in your example except initializing sys.exitfunc. I'm with Anand C on this one, the context manager serves no real purpose here; the initialization of sys.exitfunc is entirely incidental and has little bearing on the fact that it is being initialized from the value returned by the context manager. This seems to me even more un-idiomatic than using atexit.register as a decorator. YMMV, but this is more like shoehorning in a 'cute' language feature just for the heck of it. Well, nothing really except maybe, @contextmanager def end_of_days(): before_context() def wrapper(): print 'Goodbye.' yield wrapper print after_context() with end_of_days() as sys.exitfunc: print 3+4 This just conflates context/resource management with registering cleanup functions, which seems entirely unnecessary. Just provides a context manager as well to do things before entering context and after exiting (just before sys.exit in this case), in a modular way. That would only hold if there's nothing following the with block in my thread of execution. In any other case the cleanup function will be executed much later and encapsulating it inside the context manager only elides the intent of the code and makes it harder to read. Even if this were just a single-file standalone script, I would much rather explicitly serialize the code. I honestly fail to see the modularity in this idiom. Anand ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers - -- Regards, - --Anand - -- Software Architect/Consultant anandpil...@letterboxes.org Please note my updated email address anandpil...@letterboxes.org. Kindly update your address books. -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBAgAGBQJSJVS7AAoJEHKU2n17CpvDbdsIAJD8T8AJp49jmE5l/tEpUCKu k5U0e3cTcy7rAevxhE40lFjvmTAENw6K85Eh1hTbVt0uRQDhdDs7Lv47WuVHEppH 28WlGkufwMHc5fIPb1XVbL7UbzPcqZd/6tUTXN+AAYZYtx2OB1rRiG6REhiFyY+Z +8hPwMWcs6n3oV8hCJbdFITaRM9pm4RozBolFVe+r5LWBp1IO56fSt0IFDS9gceI 5NhLI9JZReoqYEfK8cPtNBjM9y1tLGJ8AZP60E0n3WGgVZMFK0Mw1xloefIZvaBC xa5l81BVq+zov50WkXTQ/FVCGQpJM7l9A9XRfTznC5nnx2QVbitOPgFNNZpIYQc= =V14p -END PGP SIGNATURE- ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers Also, aside from the point about python idioms, most of this discussion is rendered moot by the fact that sys.exitfunchttp://docs.python.org/2/library/sys.html#sys.exitfunchas been flagged as deprecated in favour of atexit.register since 2.4 and suggesting it to a newbie just feels inappropriate. - d ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] folder initialization issues
On Thu, Aug 29, 2013 at 9:43 AM, Noufal Ibrahim nou...@nibrahim.net.inwrote: Anand Chitipothu anandol...@gmail.com writes: [...] Lets say you a python file x.py. You can import it just using import x. If you have y/x.py, you would import it using import y.x or from y import x. Here x is a submodule of y and y is also a module. But where is the file for module y now? Since y is a folder, Python expects y/__init__.py for module y. That is a convention that Python uses. So to use a folder as a module you need add __init__.py to it. Got it? [...] Also, directories as modules are often called packages. http://docs.python.org/2/tutorial/modules.html#packages Not to be confused with python packages as packaged and distributed from a package index like https://pypi.python.org (ducks) - d ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
[BangPypers] XPOST: Pyladies Bangalore
XPOSTING to PythonPune. -- Forwarded message -- From: Annapoornima Koppad a.kop...@gmail.com Date: Thu, Aug 22, 2013 at 4:04 PM Subject: [BangPypers] Pyladies Bangalore To: bangpypers@python.org Dear All, I recently started the Pyladies Bangalore chapter. I wanted to know how many lady python programmers are on Bangalore python users group. I will be really interested in the numbers in terms of, 1. How many lady python programmers are on Bangalore python users group? 2. How many are active in attending the Bangalore meetups? 3. How much is the participation of these women for any of Bangalore Python outreach activities. 4. Of the active members, how many have been active in producing good quality talks, workshops, etc. I did a little bit of research before deciding to email the group here. There are 570 members on the Bangalore Python user groups. Of which 20 are ladies. Of the 20 number, 3 are recruiters. This number is really disconcerting to me. Am I missing out some people here? This is leading me to ask these questions. 1. How many women really attend workshops/meetups? 2. Are there any efforts to understand the problems associated with the poor attendance of women? 3. Aren't there any women who want to learn Python but are too afraid to ask questions. What is being done to address these problems? That said, I am attaching the links to Pyladies Bangalore. While I want to keep this community pro-woman, I am not restricting it to women alone. I would really appreciate if there are men willing to come forward to help, and build this community. Apart from a few concerns (which I am sure everyone would understand), this community is open to men as well. Even if you are not a programmer, have never coded a single line, this community still welcomes you to be a part of it and will try to help you learn. If you are an ace programmer, I would be really glad host a couple of talks wherein you could inspire other people to take up coding. Perhaps you could talk about your office work, thesis work, etc. Here are the links to Pyladies Bangalore chapter. http://www.meetup.com/PyladiesBangalore https://www.facebook.com/pyladies.bangalore https://twitter.com/pyladiesblore http://mail.python.org/mailman/listinfo/pyladies-blr Please feel free to circulate this email to friends in your circle. Any kind of participation is welcome. Thanks and regards, Annapoornima Koppad ___ 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] [Ticket #27] A Comparison of Mocking Frameworks
That list is pretty dated. If I were starting a new project I'd just reach for doublex http://pypi.python.org/pypi/doublex. It's got, by far, the nicest API of test doubles I've encountered. - d On Thu, May 9, 2013 at 1:52 PM, Prashant R. Naik prash...@triconinfotech.com wrote: On May 09, 2013 @ 01:50 pm, bangpypers-bounces+prashant= triconinfotech@python.org wrote: Hi everyone: A colleague pointed me to this comparison of mocking frameworks: http://garybernhardt.github.io/python-mock-comparison/ -- Sriram Belenix: www.belenix.org Twitter: @sriramnrn ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers This is an automated response. Your issue has been noted. We'll be in touch soon. Please reply to this email or visit the URL below with any additional details. http://DB01:9675/portal/view-help-request/27 ___ 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] A Comparison of Mocking Frameworks
On Thu, May 9, 2013 at 8:36 AM, Sriram Narayanan sriram...@gmail.comwrote: Hi everyone: A colleague pointed me to this comparison of mocking frameworks: http://garybernhardt.github.io/python-mock-comparison/ That list is pretty dated. If I were starting a new project I'd just reach for doublex http://pypi.python.org/pypi/doublex. It's got, by far, the nicest API of test doubles I've encountered. - d ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] [OT] Microsoft Office 365 for Education made mandatory for approved institutions by AICTE
On Mon, Apr 15, 2013 at 8:54 PM, Kaushik Kalyanaraman dialkforkaus...@gmail.com wrote: 10 replies to Godwin Damn, nice catch! ;) - d ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Python/Perl Scripting resource
On Thu, May 24, 2012 at 6:42 PM, Noufal Ibrahim nou...@nibrahim.net.inwrote: Senthil Kumaran sent...@uthcode.com writes: [...] [...] Could someone just point the OP to the Posting guidelines for this list, especially the ones around job postings? Harpal, at the least, job postings are required to have their subjects prefixed with '[JOB]' so that those like me can ignore them faster. :) - d ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Handling bit sized fields in network headers
On Fri, May 4, 2012 at 3:40 PM, Balachandran Sivakumar benignb...@gmail.com wrote: Hi, What is the best way to handle bit sized fileds in network headers, if the data is binary ? The struct module doesn't support sizes in bits, and I have scenarios where there are fields of 2 bits, 3 bits and 5 bits in size. Thanks While I never got around to using it much, I remember from PyCon last year that Scapy [http://pypi.python.org/pypi/Scapy] had a pretty extensive library for network packet manipulation. HTH - d ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Handling bit sized fields in network headers
On Fri, May 4, 2012 at 5:09 PM, Saager Mhatre saager.mha...@gmail.comwrote: On Fri, May 4, 2012 at 3:40 PM, Balachandran Sivakumar benignb...@gmail.com wrote: Hi, What is the best way to handle bit sized fileds in network headers, if the data is binary ? The struct module doesn't support sizes in bits, and I have scenarios where there are fields of 2 bits, 3 bits and 5 bits in size. Thanks While I never got around to using it much, I remember from PyCon last year that Scapy [http://pypi.python.org/pypi/Scapy] had a pretty extensive library for network packet manipulation. Just realized that the PyPi links lead nowhere, so here's the link to some better resources that I could google up = http://www.secdev.org/projects/scapy/ HTH - d ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] JOB - Senior Web Developer - Talented Team!
On Fri, Mar 16, 2012 at 11:44 AM, Noufal Ibrahim nou...@nibrahim.net.inwrote: Anand Balachandran Pillai abpil...@gmail.com writes: On Fri, Mar 16, 2012 at 11:30 AM, Kenneth Gonsalves law...@gmail.com wrote: On Fri, 2012-03-16 at 10:39 +0530, Anand Balachandran Pillai wrote: Ah well, that was supposed to go to the sender. My bad. Ignore it. welcome to the club Bad karma. I should set the return address for the group to the sender perhaps :) [...] Please don't. A mail client should have some way of specifying reply to sender or reply to reply-to address. +3 (I'd +1 the three replies individually, but I'm just lazy) - d ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] JOB - Senior Web Developer - Talented Team!
On Fri, Mar 16, 2012 at 10:39 AM, Anand Balachandran Pillai abpil...@gmail.com wrote: Ah well, that was supposed to go to the sender. My bad. Ignore it. Was about to call a troll alert on that just then :) - d ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Truth Tests (bool)
https://gist.github.com/1327614#file_truth.py I hacked together this little script to cover (hopefully) all the cases for my reference. - d ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] python framework for android
On Tue, Jan 10, 2012 at 7:43 AM, Anand Chitipothu anandol...@gmail.comwrote: 2012/1/4 Navin Kabra navin.ka...@gmail.com On Wed, Jan 4, 2012 at 11:37 AM, Kenneth Gonsalves law...@gmail.com wrote: can anyone recommend a python framework for android? Negative vote for SL4A (previously known as ASE - Android Scripting Environment). I have played with it, and I think it is largely a toy - it is good for personal use - quick scripts for automating things you like to do, but not useful for anything serious. Also, I haven't found anything else that allows Python programming for Android and could be used in developing serious apps. Might be forced to use Java or JavaScript :-( If it has Java, why not use write the apps in Python using Jython? IIRC, that's what SL4A does. - d ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Background ping - check for server availability
On Fri, Dec 30, 2011 at 1:02 AM, Nikunj Badjatya nikunjbadja...@gmail.comwrote: Hi, I think the commands.getstatusoutput() is only for unix systems. When I run on windows I get this error: {{{ ret = commands.getstatusoutput('ping 192.168.1.1') ret (1, '{' is not recognized as an internal or external command,\noperable program or batch file.) }}} on windows, try `commads.getstatusoutput('cmd ping 192.168.1.1')` - d ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Auto Login to Website and Capturing more details
On Thu, Dec 22, 2011 at 10:27 PM, Noufal Ibrahim nou...@gmail.com wrote: [snip] The Python stdlib can handle this using urllib2 and cookielib. I've managed something like this here https://gist.github.com/3811b566df4005a012c7which you can use as a starting point. After this, you have a session. Now you should be able to GET the URL you want directly and parse it for the information you need. Wouldn't something like mechanize http://pypi.python.org/pypi/mechanizesimplify all this? - d ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] ElementTree object instance evaluates to False?
Refer https://gist.github.com/1327614#file_truth.py to see if it helps any. - d On Tue, Dec 6, 2011 at 11:15 AM, Noufal Ibrahim nou...@gmail.com wrote: Vikas BN vikas...@gmail.com writes: [...] Anyone else encountered this or even have any insights regarding this behaviour? I'm using Python2.7.2 on Linux if that matters. ElementTree's `Element` objects behave this way. The booleanness is not conformant to the rest of Python. I don't know if or when it's been fixed but here's how to do it. http://effbot.org/zone/element.htm#truth-testing The method you need to work with is `__nonzero__`[1] if you want `bool` to work with your classes. With Python 2.7.2, The `Element` class defined in /usr/lib/python2.7/xml/etree/ElementTree.py has def __nonzero__(self): warnings.warn( The behavior of this method will change in future versions. Use specific 'len(elem)' or 'elem is not None' test instead., FutureWarning, stacklevel=2 ) return len(self._children) != 0 # emulate old behaviour, for now So, it will evaluate to False only if the number of children is zero. Annoying but when I stumbled on this, it did make me aware of how consistent Python libraries generally are so that this stuck out. [...] Footnotes: [1] http://docs.python.org/reference/datamodel.html#object.__nonzero__ -- ~noufal http://nibrahim.net.in I am a deeply superficial person. -Andy Warhol ___ 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
[BangPypers] Mailing list etiquette
http://catb.org/~esr/faqs/smart-questions.html Considering there's been a spate of similar incidents, I figured it might just be valuable to collect all these references into a thread of their own. - d PS- If I had a nickel for every time I've wanted to point people to this article, I'd be a rich man who wouldn't have to even lurk on mailing lists like this one. ;) On Wed, Nov 16, 2011 at 11:27 AM, Kenneth Gonsalves law...@gmail.comwrote: On Tue, 2011-11-15 at 22:32 +0530, Gora Mohanty wrote: * A smart person on the Solr mailing list put together this Wiki page on how best to use mailing lists. Somewhat Solr-specific, but definitely worth a read: http://wiki.apache.org/solr/UsingMailingLists this is the django equivalent: https://code.djangoproject.com/wiki/UsingTheMailingList -- regards Kenneth Gonsalves ___ 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] collections
On Wed, Nov 9, 2011 at 5:05 PM, Kenneth Gonsalves law...@gmail.com wrote: hi, python collections are cool and I am dying to use them in production. But so far I am yet to find a use case for using them - any experiences? I'm assuming you mean the Python collections package that provides 'High-performance container datatypes'. We use defaultdict to good effect at work, but as far as I can tell, that's the only one we use from that package; other than Callable that I used in a bunch of test utilities, but that usage wasn't really valuable. Sorry if I wan't much help. - d ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] collections
On Wed, Nov 9, 2011 at 5:30 PM, Kenneth Gonsalves law...@gmail.com wrote: On Wed, 2011-11-09 at 17:23 +0530, Saager Mhatre wrote: [snip] other than Callable that I used in a bunch of test utilities, but that usage wasn't really valuable. but it must be useful for *something* ;-) Not really, initially I thought I might actually have to extend Callable for the callable function to consider objects of my class... callable. :) But, it turns out you pretty much just need a __call__ attribute in the object for callable to return true. So it's mostly vestigial in the code. - d ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] [chennaipy 1126] [XPost][Slightly OT] Could you share your experiences about Python Freelance programming, from a programmer's perspective
On Wed, Nov 2, 2011 at 9:26 PM, kracekumar ramaraju kracethekingma...@gmail.com wrote: I'd go so far as to suggest that they join a mid-to-large sized company and spend the first couple of years maintaining somebody else's crap code. It's one hell of a learning experience. Don't join Big companies, you're learning is not in your hand, large companies work on diverse areas, so chance of getting into the area which interests you is less. I personally feel joining small or little mid size companies can help you learn much better. In larger size companies it is process oriented and easy to pass the buck. True... to some extent. Like just about anything else, you have to choose wisely. My four years at Kanbay (now CapGemini) taught me a lot of lessons in organization, management as well as presentation. Of course, like Sidu said earlier, none of these skills can substitute good engineering chops. And that, IMHO, is a decision that must come from within. - d ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] [chennaipy 1126] [XPost][Slightly OT] Could you share your experiences about Python Freelance programming, from a programmer's perspective
On Wed, Nov 2, 2011 at 10:31 PM, kracekumar ramaraju kracethekingma...@gmail.com wrote: True... to some extent. Like just about anything else, you have to choose wisely. My four years at Kanbay (now CapGemini) taught me a lot of lessons in organization, management as well as presentation. Well my question is how much did you learn about programming, api design, Unit testing, algo design Don't get me wrong, I'm not discounting engineering skills; we're all on the same side there. What I was hinting at above is that if you get lucky and get good managers at a mid-to-large co, you have the opportunity to learn how organization in the large works, and that's an important skill too. That said, I should clarify, when I say, 'spend the first couple of years maintaining somebody else's crap code', I say that from personal experience. Maintaining something you didn't build teaches you a lot about the importance of building good readable, maintainable, malleable code. I know I write good code because I don't want people who end up maintaining it (myself included) to go through the agony I had to back then. That's probably one the biggest takeaways I have from back there; and that was what I was primarily pointing to. It usually turns out to be a bit of a trial by fire and you have to fight the urge to just get sh!t done. Not to mention the people around you who churn out bad code on a regular basis. But if you can battle through it, you'll have a better appreciation for these practices. I realize this is a little backwards, but then again I know it worked for me. YMMV. As for core engineering skills, programming, API design, algorithms, etc- I learned most of that on my own and guess I would have no matter where I was. But that's just me. We got a computer at home very early on, a trusty 386 way back in the early 90's and started off right then and never looked back. Arguably, Kanbay didn't really ^help^ on that front, but I did end up with a few good colleagues to bounce ideas off. But in my experience, this usually is something that has to come from within. Once you've established that the person has an innate need to better themselves there's a whole slew of resources out there at your disposal. Of course, having totally awesome programmers around you doesn't hurt (loosely translated from- helps a whole whopping bunch!) :) I'll concede the bit on testing here. I don't think I would ever have appreciated testing if it wasn't for my time at ThoughtWorks. , agility Interestingly enough, I got my first lessons in agility from a client director at one of the projects at Kanbay. Although, we didn't call it agile or lean back then and he was quite the visionary, so I guess I got lucky again. :) how to distinguish good programmer from bad programmer. There was a fairly simple heuristic some of us went with, a good programmer is simply someone *you* would like to learn from. I liked that so much, that I haven't really bothered to ponder that question much beyond that. Sorry If i am rude :) I promise to take offence ^only^ if you meant to be rude. ;) - d ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] [chennaipy 1126] [XPost][Slightly OT] Could you share your experiences about Python Freelance programming, from a programmer's perspective
On Wed, Nov 2, 2011 at 10:56 PM, kracekumar ramaraju kracethekingma...@gmail.com wrote: I am advanced python novice. There's an interesting tautology I can use, and... People who learn python are passionate about programming, others learn java and c# to get a job. ... there's a line that was uncalled for - d ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] [chennaipy 1126] [XPost][Slightly OT] Could you share your experiences about Python Freelance programming, from a programmer's perspective
On Wed, Nov 2, 2011 at 11:15 PM, kracekumar ramaraju kracethekingma...@gmail.com wrote: In most support project you don't change code until there is a requirement from client, else you end up supporting the tickets etc... They're not all support (as in keep the lights on) projects, there's maintenance (as in make the lights brighter) and enhancements (as in put in more/new lights) gigs out there too. - d ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] [chennaipy 1126] [XPost][Slightly OT] Could you share your experiences about Python Freelance programming, from a programmer's perspective
On Wed, Nov 2, 2011 at 10:47 PM, Rajeev J Sebastian rajeev.sebast...@gmail.com wrote: As you suggested, the most important change we can make is to test directly with code. +1 to Sidu's suggestion about having candidates write code before they come in; have used that to much success. Do you do your tests in Python, or whatever language the fresher knows? So far, we have not received a single resume mentioning Python. Let the candidate submit code in a language/platform of their choosing. You want to give them the opportunity to put _their best foot_ forward. That said, you should also list out languages/platforms that you prefer; these would be the ones you've worked in and can evaluate the best in. They don't necessarily have to be the primary tool you use at work every day, just a common medium to trade insights into code. - d ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] [chennaipy 1126] [XPost][Slightly OT] Could you share your experiences about Python Freelance programming, from a programmer's perspective
On Wed, Nov 2, 2011 at 11:33 PM, Saager Mhatre saager.mha...@gmail.comwrote: On Wed, Nov 2, 2011 at 10:47 PM, Rajeev J Sebastian rajeev.sebast...@gmail.com wrote: As you suggested, the most important change we can make is to test directly with code. +1 to Sidu's suggestion about having candidates write code before they come in; have used that to much success. Almost forgot about this- while we're talking about code submissions I'd like to plug reliscore.com It's like a market place for organizations to put up code assignments and candidates/students to solve them and submit answers back. Our own Navin Kabra is deeply involved with this initiative. - d ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Generate Dynamic lists
On Fri, Oct 21, 2011 at 12:40 AM, Gora Mohanty g...@mimirtech.com wrote: On Fri, Oct 21, 2011 at 12:38 AM, Gora Mohanty g...@mimirtech.com wrote: On Fri, Oct 21, 2011 at 12:10 AM, Asif Jamadar asif.jama...@rezayat.net wrote: [...] list1 = [] for i in criteria_list[:2]: for j in range(4): l.append( ( i, j + 1 ) ) Oops, that last line should be list1.append(...) instead of l.append(...) While I'd usually suggest a list comprehension like... [(criteria, level) for level in range(1, 4) for criteria in criteria_list[:2]] ... I'd say a zip'd do the trick as well... zip(criteria[:2], range(1, 4)) just my 2c - d ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] About pypy and bangpypers
On Mon, Sep 26, 2011 at 10:57 PM, Sriram Narayanan sriram...@gmail.comwrote: I can talk about my experiences with porting it. -- Sriram Porting it to... Belenix? - d ___ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers