[BangPypers] Volunteer for Conduct Basic Python workshop at GEC Hassan on 21st of Sept

2013-09-11 Thread vijay
Hi,     We need volunteer to conduct Basic Python workshop at Govt Engineering college , Hassan on Sept 21st      Expected Student Strength :  60.     Travel and Food expense will be taken care by college. With Thanks Vijay ___ BangPypers mailing list

Re: [BangPypers] Python "Wat"s

2013-09-11 Thread Noufal Ibrahim
Jeffrey Jose writes: [...] > I come from a place where you use *batteries* as much as possible, and > where shelling out is the last resort. [...] I think so too. Perl programmers are much more comfortable with the whole qx business than Python programmers are with os and subprocess. -- C

Re: [BangPypers] Python "Wat"s

2013-09-11 Thread Jeffrey Jose
On Wed, Sep 11, 2013 at 9:02 PM, Vardhan Varma wrote: > On Wed, Sep 11, 2013 at 8:42 PM, Pranjal Mittal < > pranjal.mittal.ec...@iitbhu.ac.in> wrote: > > > Here you go- > > > > import socket > > socket.gethostbyaddr(socket.gethostname())[2] > > > > > > On Wed, Sep 11, 2013 at 8:16 PM, ashish makan

Re: [BangPypers] Python "Wat"s

2013-09-11 Thread Vardhan Varma
On Wed, Sep 11, 2013 at 8:42 PM, Pranjal Mittal < pranjal.mittal.ec...@iitbhu.ac.in> wrote: > Here you go- > > import socket > socket.gethostbyaddr(socket.gethostname())[2] > > > On Wed, Sep 11, 2013 at 8:16 PM, ashish makani >wrote: > > > Found this quick, nifty way to determine the ip address o

Re: [BangPypers] Python "Wat"s

2013-09-11 Thread Pranjal Mittal
Here you go- import socket socket.gethostbyaddr(socket.gethostname())[2] On Wed, Sep 11, 2013 at 8:16 PM, ashish makani wrote: > Found this quick, nifty way to determine the ip address of the machine your > py script is running on > > import commands > commands.getoutput("/sbin/ifconfig").split

Re: [BangPypers] Python "Wat"s

2013-09-11 Thread ashish makani
Found this quick, nifty way to determine the ip address of the machine your py script is running on import commands commands.getoutput("/sbin/ifconfig").split("\n")[1].split()[1][5:] ( via http://stackoverflow.com/a/3177266/559456 ) cheers ashish *The only way to do great work is to love what y

Re: [BangPypers] Favorite tips/techniques

2013-09-11 Thread Amit Sethi
1. I do like the accessing dict attributes as keys and specifically where they make more sense as structure by itselfI do use class ABC(object): a = '' def __init__(self, **kwargs): self.__dict__.update(**kwargs) 2. When creating a dictionary of constants create it dynamica

Re: [BangPypers] Favorite tips/techniques

2013-09-11 Thread s|s
There are times when the project requires a large blob of data which needs to be loaded with the python code. A general practice is to use pickle and json object which is opened using file functions etc. I tend to convert this kind of data (depending on size) into python file using pprint and stor

Re: [BangPypers] Favorite tips/techniques

2013-09-11 Thread Anand Chitipothu
Another script I use often is repr. https://github.com/anandology/hacks/blob/master/repr It reads each line from stdin and prints it as python repr. Useful to see hidden/non-alphanumeric characters. $ echo -e "a\bc" c $ echo -e "a\bc" | repr a\x08c\n This is similar to od, but od prints fixed n

Re: [BangPypers] Favorite tips/techniques

2013-09-11 Thread s|s
This use case where one needs to keep related values together as logical group: Properties, getattr, setattr are quite interesting option but I prefer collections.namedtuple Example EmployeeRecord = namedtuple('EmployeeRecord', 'name, age, title, department, paygrade') import csvfor emp in map(E