Re: Decorators (was: Re: I love assert)

2014-11-14 Thread Richard Riehle
Mayank, Thanks. I have only been using Python for about four years, so there are features I have only recently discovered. Decorators are one of them. So far, I encounter other Python users who are also unfamiliar with them. When I discovered them, I instantly saw how they could be valuable.

Re: Decorators

2014-11-14 Thread Marko Rauhamaa
Tim Chase : > And decorators are used pretty regularly in just about every code-base > that I've touched (I've been programming in Python since early 2004, > so I've maintained pre-2.4 code without decorators and then brought it > forward to 2.4 where decorators were usable). Funny. My experience

Re: Efficient Threading

2014-11-14 Thread Cameron Simpson
On 14Nov2014 18:42, Empty Account wrote: I am thinking about writing a load test tool in Python, so I am interested in how I can create the most concurrent threads/processes with the fewest OS resources. I would imagine that I/O would need to be non-blocking. There are a number of options inclu

Re: Question about installing python and modules on Red Hat Linux 6

2014-11-14 Thread Cameron Simpson
On 14Nov2014 19:01, pythonista wrote: I am developing a python application as a contractor. I would like to know if someone can provide me with some insight into the problems that then infrastructure team has been having. The scope of the project was to install python 2.7.8 and 4 modules/site

Re: Question about installing python and modules on Red Hat Linux 6

2014-11-14 Thread Chris Angelico
On Sat, Nov 15, 2014 at 2:01 PM, pythonista wrote: > The scope of the project was to install python 2.7.8 and 4 modules/site > packages on a fresh linux build. > > The first team failed after almost 3 weeks of work. > > Then they put their star Linux administrator on the task and it took almost

Re: Decorators (was: Re: I love assert)

2014-11-14 Thread Tim Chase
On 2014-11-14 18:19, Richard Riehle wrote: > Decorators are new in Python, so there are not a lot of people > using them. Um...they were introduced in 2.4 which was released in late 2004. So they've only been around for about (almost exactly) a decade. Not sure that qualifies as "new in Python"

Re: I love assert

2014-11-14 Thread Ethan Furman
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 11/14/2014 06:58 PM, Steven D'Aprano wrote: > Ethan Furman wrote: >> >> My point being: a safety net that is so easily disabled does not count >> (IMHO) as a backup. > > Assertions are not a backup or a safety net. [...] Would you be happier if

Re: fileno() not supported in Python 3.1

2014-11-14 Thread Cameron Simpson
On 14Nov2014 09:51, Ian Kelly wrote: On Fri, Nov 14, 2014 at 12:36 AM, Cameron Simpson wrote: On 13Nov2014 15:48, satishmlm...@gmail.com wrote: import sys for stream in (sys.stdin, sys.stdout, sys.stderr): print(stream.fileno()) io.UnsupportedOperation: fileno Is there a workaroun

Question about installing python and modules on Red Hat Linux 6

2014-11-14 Thread pythonista
I am developing a python application as a contractor. I would like to know if someone can provide me with some insight into the problems that then infrastructure team has been having. The scope of the project was to install python 2.7.8 and 4 modules/site packages on a fresh linux build. The f

Re: I love assert

2014-11-14 Thread Steven D'Aprano
Ethan Furman wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > On 11/14/2014 03:33 AM, Steven D'Aprano wrote: >> >> I agree with Marko in this case. Marko's example of defensive programming >> is very similar to the one I gave in my essay here: >> >> http://import-that.dreamwidth.org

Re: Decorators (was: Re: I love assert)

2014-11-14 Thread Mayank Tripathi
Decorators were there in Python 2.4, released in 2005. Not exactly new. On Sat Nov 15 2014 at 7:51:11 AM Richard Riehle wrote: > On Friday, November 14, 2014 2:18:48 PM UTC-8, Marko Rauhamaa wrote: > > Richard Riehle : > > > > > I find that not a lot of Python user really appreciate the power of

Re: Decorators (was: Re: I love assert)

2014-11-14 Thread Richard Riehle
On Friday, November 14, 2014 2:18:48 PM UTC-8, Marko Rauhamaa wrote: > Richard Riehle : > > > I find that not a lot of Python user really appreciate the power of > > decorators. > > Well, I don't. > > All it means is that I've never seen a use of decorators that has > enhanced the code. Once I "

Re: I love assert

2014-11-14 Thread Chris Angelico
On Sat, Nov 15, 2014 at 1:14 PM, Tim Chase wrote: > On 2014-11-15 12:48, Chris Angelico wrote: >> conn = establish_database_connection() >> try: >> do_stuff() >> finally: >> conn.rollback() > > this sounds suspiciously like you'd never actually commit. Do you > mean something like > > c

Re: I love assert

2014-11-14 Thread Tim Chase
On 2014-11-15 12:48, Chris Angelico wrote: > conn = establish_database_connection() > try: > do_stuff() > finally: > conn.rollback() this sounds suspiciously like you'd never actually commit. Do you mean something like conn = establisth_database_connection() try: do_stuff(conn)

Re: I love assert

2014-11-14 Thread Chris Angelico
On Sat, Nov 15, 2014 at 12:30 PM, Marko Rauhamaa wrote: > Chris Angelico : > >> On Sat, Nov 15, 2014 at 11:12 AM, Marko Rauhamaa wrote: >>> Most importantly, assertion failures are not supposed to be recovered >>> from (within the program). Assertion failures can result in the loss >>> of life an

Re: I love assert

2014-11-14 Thread Marko Rauhamaa
Chris Angelico : > On Sat, Nov 15, 2014 at 11:12 AM, Marko Rauhamaa wrote: >> Most importantly, assertion failures are not supposed to be recovered >> from (within the program). Assertion failures can result in the loss >> of life and limb. They can result in database corruption. They can >> resu

Re: I love assert

2014-11-14 Thread Chris Angelico
On Sat, Nov 15, 2014 at 11:12 AM, Marko Rauhamaa wrote: > Most importantly, assertion failures are not supposed to be recovered > from (within the program). Assertion failures can result in the loss of > life and limb. They can result in database corruption. They can result > in monetary losses. T

Re: I love assert

2014-11-14 Thread Marko Rauhamaa
Steven D'Aprano : > Marko Rauhamaa wrote: > >> Asserts are not about notification, checking or optimization. They are >> about communicating what's going on in the programmer's mind. They are >> comments. > > Assertions can be used for *all of these things*. > > Assertions can be used for: > > - c

Re: Array of Functions

2014-11-14 Thread Terry Reedy
On 11/14/2014 5:17 PM, Richard Riehle wrote: In C, C++, Ada, and functional languages, I can create an array of functions, albeit with the nastiness of pointers in the C family. For example, an array of functions where each function is an active button, or an array of functions that behave like f

Re: I love assert

2014-11-14 Thread Steven D'Aprano
Marko Rauhamaa wrote: > Asserts are not about notification, checking or optimization. They are > about communicating what's going on in the programmer's mind. They are > comments. Assertions can be used for *all of these things*. Assertions can be used for: - checking internal program logic; -

Re: Array of Functions

2014-11-14 Thread MRAB
On 2014-11-14 22:17, Richard Riehle wrote: In C, C++, Ada, and functional languages, I can create an array of functions, albeit with the nastiness of pointers in the C family. For example, an array of functions where each function is an active button, or an array of functions that behave like for

Re: Array of Functions

2014-11-14 Thread Ian Kelly
On Fri, Nov 14, 2014 at 3:17 PM, Richard Riehle wrote: > In C, C++, Ada, and functional languages, I can create an array of functions, > albeit with the nastiness of pointers in the C family. For example, an > array of functions where each function is an active button, or an array of > functi

Re: Decorators

2014-11-14 Thread Marko Rauhamaa
Mark Lawrence : > Perhaps this helps > http://blog.dscpl.com.au/2014/01/how-you-implemented-your-python.html ? Thanks, but sorry, it didn't. I couldn't even relate to the supposed WSGI craze. I'm yet to face the situation where a colleague would point out, "See how elegantly you could have done

Re: Array of Functions

2014-11-14 Thread Sam Raker
I second the call for a more concrete implementation, but if you want the results of the functions in c3 to be responsive to the values of c1 and c2 (i.e., if you change r1c1, r1c3 returns a different value), it might be worth encapsulating the whole thing in an object and making the c3 function

Re: Decorators

2014-11-14 Thread Mark Lawrence
On 14/11/2014 22:18, Marko Rauhamaa wrote: Richard Riehle : I find that not a lot of Python user really appreciate the power of decorators. Well, I don't. All it means is that I've never seen a use of decorators that has enhanced the code. Once I "see the light," I'll have no problem changin

Re: Array of Functions

2014-11-14 Thread Marko Rauhamaa
Richard Riehle : > Example: > > r1c1 r1c2 r1c3 > r2c1 r2c2 r2c3 > r3c1 r3c2 r3c3 > > where r1 is row 1 and c1 is column 1. Suppose I want an array where the > colum three is a set of functions that operates on the other two > columns, depending on the v

Decorators (was: Re: I love assert)

2014-11-14 Thread Marko Rauhamaa
Richard Riehle : > I find that not a lot of Python user really appreciate the power of > decorators. Well, I don't. All it means is that I've never seen a use of decorators that has enhanced the code. Once I "see the light," I'll have no problem changing my view. Marko -- https://mail.python.

Array of Functions

2014-11-14 Thread Richard Riehle
In C, C++, Ada, and functional languages, I can create an array of functions, albeit with the nastiness of pointers in the C family. For example, an array of functions where each function is an active button, or an array of functions that behave like formulae in a spreadsheet. I am finding th

Re: I love assert

2014-11-14 Thread Richard Riehle
On Tuesday, November 11, 2014 11:41:06 AM UTC-8, Peter Cacioppi wrote: > I get the impression that most Pythonistas aren't as habituated with assert > statements as I am. Is that just a misimpression on my part? If not, is there > a good reason to assert less with Python than other languages? >

Re: Two locations for module struct ?

2014-11-14 Thread Terry Reedy
On 11/14/2014 10:11 AM, ast wrote: Hello In module wave there is a sub module struct. struct is not a documented part of the wave module. You can call function pack() with: import wave val = wave.struct.pack(...) wave imports several other stdlib modules. All are accessible the same way.

Re: I love assert

2014-11-14 Thread Marko Rauhamaa
Ethan Furman : > Python the language is just the opposite: debug mode is on /by > default/, and to turn it off you have to specify -O: C's the same way. When I did Java, we enabled assertions in production code. Marko -- https://mail.python.org/mailman/listinfo/python-list

Re: I love assert

2014-11-14 Thread Ethan Furman
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 11/14/2014 11:12 AM, Marko Rauhamaa wrote: > Ethan Furman wrote: > >> My point being: a safety net that is so easily disabled does not count >> (IMHO) as a backup. > > Correct. You never lean on assertions. They are primarily formal comments. On

Re: Help with Python Multiprocessing

2014-11-14 Thread sohcahtoa82
On Thursday, November 13, 2014 3:22:49 PM UTC-8, Anurag wrote: > On Thursday, November 13, 2014 2:18:50 PM UTC-5, sohca...@gmail.com wrote: > > On Thursday, November 13, 2014 10:07:56 AM UTC-8, Anurag wrote: > > > I am having trouble understanding the Multiprocessing module. > > > I need to run thr

Efficient Threading

2014-11-14 Thread Empty Account
Hi, I am thinking about writing a load test tool in Python, so I am interested in how I can create the most concurrent threads/processes with the fewest OS resources. I would imagine that I/O would need to be non-blocking. There are a number of options including standard library threading, gevent

Re: I love assert

2014-11-14 Thread Marko Rauhamaa
Ethan Furman : > My point being: a safety net that is so easily disabled does not count > (IMHO) as a backup. Correct. You never lean on assertions. They are primarily formal comments. However, assertion failures do help in troubleshooting occasionally. Most importantly, they immediately, unques

Re: I love assert

2014-11-14 Thread Ethan Furman
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 11/14/2014 03:33 AM, Steven D'Aprano wrote: > > I agree with Marko in this case. Marko's example of defensive programming is > very similar to the one I gave in my > essay here: > > http://import-that.dreamwidth.org/676.html > > You're correct o

Re: Two locations for module struct ?

2014-11-14 Thread ast
"Peter Otten" <__pete...@web.de> a écrit dans le message de news:mailman.15823.1415983912.18130.python-l...@python.org... Do you see the pattern? You should ;) Understood thx -- https://mail.python.org/mailman/listinfo/python-list

Re: I love assert

2014-11-14 Thread Ian Kelly
On Fri, Nov 14, 2014 at 4:37 AM, Steven D'Aprano wrote: > Ethan Furman wrote: > >>> There's no way to make the CONFUSED status be handled without actually >>> changing the code. The difference is that this version will not >>> incorrectly treat CONFUSED as WARNING; it just won't do anything at >>>

Re: fileno() not supported in Python 3.1

2014-11-14 Thread Ian Kelly
On Fri, Nov 14, 2014 at 12:36 AM, Cameron Simpson wrote: > On 13Nov2014 15:48, satishmlm...@gmail.com wrote: >> >> import sys >> for stream in (sys.stdin, sys.stdout, sys.stderr): >> print(stream.fileno()) >> >> >> io.UnsupportedOperation: fileno >> >> Is there a workaround? > > > The f

Re: python on android: where to start

2014-11-14 Thread Phil Thompson
On 14/11/2014 2:18 pm, maurog wrote: I looked at the newsgroup, but I didn't find recent infos on this topic. On the other side I went lost by looking for this topic with google. So I'm asking you my question, if I want to develop or run some code with python on android, what are the resources t

Re: Two locations for module struct ?

2014-11-14 Thread Peter Otten
ast wrote: > In module wave there is a sub module struct. > You can call function pack() with: > > import wave > val = wave.struct.pack(...) > > but the same function can be called with: > > import struct > val = struct.pack(...) > > Is it exactly the same module in both location ? You can an

Re: Two locations for module struct ?

2014-11-14 Thread Chris Angelico
On Sat, Nov 15, 2014 at 2:11 AM, ast wrote: > In module wave there is a sub module struct. > You can call function pack() with: > > import wave > val = wave.struct.pack(...) > > but the same function can be called with: > > import struct > val = struct.pack(...) > > Is it exactly the same module i

Two locations for module struct ?

2014-11-14 Thread ast
Hello In module wave there is a sub module struct. You can call function pack() with: import wave val = wave.struct.pack(...) but the same function can be called with: import struct val = struct.pack(...) Is it exactly the same module in both location ? Why putting struct in two places ?

Re:python on android: where to start

2014-11-14 Thread Dave Angel
maurog Wrote in message: > I looked at the newsgroup, but I didn't find recent infos on this topic. > On the other side I went lost by looking for this topic with google. So > I'm asking you my question, if I want to develop or run some code with > python on android, what are the resources to s

Re: python on android: where to start

2014-11-14 Thread Mayank Tripathi
You can try Kivy. http://kivy.org On Fri Nov 14 2014 at 7:51:08 PM maurog wrote: > I looked at the newsgroup, but I didn't find recent infos on this topic. > On the other side I went lost by looking for this topic with google. So > I'm asking you my question, if I want to develop or run some cod

python on android: where to start

2014-11-14 Thread maurog
I looked at the newsgroup, but I didn't find recent infos on this topic. On the other side I went lost by looking for this topic with google. So I'm asking you my question, if I want to develop or run some code with python on android, what are the resources to start with? Thanks mauro -- http

Authentication method with txjson-rpc.

2014-11-14 Thread ali . hallaji1
Hi, I want to write authentication by txjson, Please help me in this way. -- https://mail.python.org/mailman/listinfo/python-list

Re: Twisted and txJSON-RPC

2014-11-14 Thread ali . hallaji1
Hi, I want to write authentication with txjson-rpc. please guide me in this method! best Regards, Ali Hallaji -- https://mail.python.org/mailman/listinfo/python-list

Islam prohibited women to be Unveiled....why?

2014-11-14 Thread bv4bv4bv4
Islam prohibited women to be Unveiledwhy? Are there any harmful effects on women if they used to display parts of their body? Let us read. According to the latest figures, the incidence of melanoma, a potentially fatal skin cancer, is increasing dramatically. It is currently

Re: fileno() not supported in Python 3.1

2014-11-14 Thread Joel Goldstick
On Fri, Nov 14, 2014 at 8:59 AM, Nobody wrote: > On Thu, 13 Nov 2014 15:48:32 -0800, satishmlmlml wrote: > >> import sys >> for stream in (sys.stdin, sys.stdout, sys.stderr): >>print(stream.fileno()) >> >> >> io.UnsupportedOperation: fileno >> >> Is there a workaround? > > Try: >

Re: fileno() not supported in Python 3.1

2014-11-14 Thread Nobody
On Thu, 13 Nov 2014 15:48:32 -0800, satishmlmlml wrote: > import sys > for stream in (sys.stdin, sys.stdout, sys.stderr): >print(stream.fileno()) > > > io.UnsupportedOperation: fileno > > Is there a workaround? Try: sys.stdin.buffer.fileno() or maybe sys.stdin

Re: Python 3.x (beazley): __context__ vs __cause__ attributes in exception handling

2014-11-14 Thread Veek M
It's been answered here: http://stackoverflow.com/questions/26924045/python-3-x-beazley-context-vs- cause-attributes-in-exception-handling?noredirect=1#comment42403467_26924045 -- https://mail.python.org/mailman/listinfo/python-list

Re: UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 308: character maps to

2014-11-14 Thread Joel Goldstick
On Fri, Nov 14, 2014 at 6:57 AM, wrote: > For 'mimetypes' in the code given below, python is giving the following > error. Kindly help. > import os matches = [] for (dirname, dirshere, fileshere) in os.walk(r'C:\Python34'): > for filename in fileshere: > if

UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 308: character maps to

2014-11-14 Thread satishmlmlml
For 'mimetypes' in the code given below, python is giving the following error. Kindly help. >>> import os >>> matches = [] >>> for (dirname, dirshere, fileshere) in os.walk(r'C:\Python34'): for filename in fileshere: if filename.endswith('.py'): pat

Re: I love assert

2014-11-14 Thread Steven D'Aprano
Ethan Furman wrote: >> There's no way to make the CONFUSED status be handled without actually >> changing the code. The difference is that this version will not >> incorrectly treat CONFUSED as WARNING; it just won't do anything at >> all if the code is optimized. > > So, a different wrong thing,

Re: io.UnsupportedOperation: fileno

2014-11-14 Thread Thomas Rachel
Am 14.11.2014 00:42 schrieb satishmlm...@gmail.com: fileno() in not supported. Is it only in 3.1? What is the workaround? You have been asked many times about the details of your environment. Especially, you have been told that it is important to know if you directly use the Python CLI or som

Re: I love assert

2014-11-14 Thread Steven D'Aprano
Ethan Furman wrote: > On 11/12/2014 01:41 PM, Marko Rauhamaa wrote: >> >> Or I might indicate the exhaustion of possibilities: >> >> if status == OK: >> ... >> elif status == ERROR: >> ... >> else: >> assert status == WARNING >> ... > > An

Re: I love assert

2014-11-14 Thread Steven D'Aprano
Peter Cacioppi wrote: > I get the impression that most Pythonistas aren't as habituated with > assert statements as I am. Is that just a misimpression on my part? If > not, is there a good reason to assert less with Python than other > languages? I love assert, and use it frequently. But there ar

Re: I don't read docs and don't know how to use Google. What does the print function do?

2014-11-14 Thread Chris Angelico
On Fri, Nov 14, 2014 at 9:58 PM, Steven D'Aprano wrote: > http://blog.codinghorror.com/why-cant-programmers-program/ > > Not everyone agrees that this is a thing: > > http://www.skorks.com/2010/10/99-out-of-100-programmers-cant-program-i-call-bullshit/ > > I'm inclined to accept that maybe 99 out

Re: What does zip mean?

2014-11-14 Thread Steven D'Aprano
Grant Edwards wrote: > What the zipper on a coat does is convert two separate sequences into > a single sequence where the members alternate between the two input > sequences.  IOW if we want to do something analogous to a zipper > fastener it should do this: > > zip([a,b,c,d,e,f],[1,2,3,4,5,6])

Re: I don't read docs and don't know how to use Google. What does the print function do?

2014-11-14 Thread Steven D'Aprano
Chris Angelico wrote: > There are blog posts out there about how large proportions of > applicants can't even write simple code on command... and I've taken > the questions and shown them to my siblings (who protest that they're > definitely not programmers), proving that a basic smattering of > m

Re: netaddr value back to IP

2014-11-14 Thread Michael Ströder
Noah wrote: > I am trying to get a value back to IP using the netaddr python module. > How do I get the value 'ip' back to IP format? how is it done? > > snip > > print IPNetwork(v4_peer_ip).value > ip = IPNetwork(v4_peer_ip).value + 1 > print ip > > --- snip --- >>> ip=n

Re: A Freudian slip of *EPIC PROPORTIONS*!

2014-11-14 Thread KO
On 2014-11-13, Rick Johnson wrote: > On the other hand, if the author is not GvR, then he is most > likely someone of great importance within the community. As much as I love Python, I hate the amount of appeal to authority that is present in the Python community. Ok, GvR created Python, great.

Re: Bad file descriptor

2014-11-14 Thread Cameron Simpson
On 13Nov2014 15:40, satishmlm...@gmail.com wrote: import os os.write(1, b'Hello descriptor world\n') OSError: Bad file descriptor How to give a file descriptor number to this function? How to get a file descriptor number? Wow, this must be at least the 4th post of the same question. It now o