Re: zip list, variables
flebber wrote: > Thank you for the replies. > > Looking at the replies I am wondering which solution is more scalable. At > the moment it is only 2 nested lists but what about 5, 10, 20 or more? > > Should I start looking into numpy to handle this or will list > comprehension > >>> [ [ x + y for x, y in zip(x,y) ] for x, y in zip(a,b) ] > Be sufficient ? I would certainly prefer >>> a + b array([[ 6, 8], [10, 12]]) over the incomprehensible comprehension. But if it is the only usecase for numpy in your script and you are OK with its current performance, just put your listcomp into an aptly named function. Then you can write the easily understandable c = matrix_add(a, b) and avoid the numpy dependency. -- https://mail.python.org/mailman/listinfo/python-list
Re: Off-topic: Pop culture references [was Re: Newbie - Trying to Help a Friend]
On 21/11/2013 00:27, Steven D'Aprano wrote: > I fully support the right of everyone to make cryptic references to > movies, television shows, science fiction and fantasy novels, internet > memes, and assorted pop culture references. One of the (occasionally humbling) effects of internet communication is the realisation that the pop-culture reference you assumed would be instantly shared and understood by *any normal person anywhere* is, in fact, confined to your own back yard. You may or may not have caught sight of the BBC's recent blanket marketing of the upcoming 50th anniversary of Dr Who, a somewhat iconic British TV series. I was genuinely perplexed when US-based websites started running articles like "What the *** is this Dr Who all about?" and "All you need to know about Dr Who: a Guide for the Unknowing". Here in Britain, even if you've never watched and/or hate the thing, you can't help at least knowing *something* about Dr Who. At least the basics: Doctor, TARDIS, Daleks; that sort of thing. In reverse, I'm sometimes bemused by (often, but not always) references to things which apparently sit centrally in the American pop-culture psyche but which are unknown over here, or at least simply known *about*. It's not usually a problem -- it's always fun to gain a bit of an insight into some other culture. Just occasionally, though, someone says, eg, "You keep using that word; I don't think it means what you think it means", intending it as a humorous reference to "The Princess Bride". But if you have (as I strongly suspect 99% of the world's population has) no knowledge of that film, or at least of its catchphrases, then it can come across instead as a slightly blunt admonition of someone else's ignorance. (Of course, if some were to say "My name is Inigo Montoya; you killed my father; prepare to die" without any further comment then you'd either have to assume that they were making a reference to a film or book unknown to you or that someone going by that alias genuinely believed you were responsible and had tracked you down across the internet to confront you finally on comp.lang.python. Who knows?) TJG -- https://mail.python.org/mailman/listinfo/python-list
Re: Off-topic: Pop culture references [was Re: Newbie - Trying to Help a Friend]
On Thu, Nov 21, 2013 at 8:08 PM, Tim Golden wrote: > Of course, if some were to say "My name is Inigo Montoya; you killed my > father; prepare to die"... You killfiled my address - prepare to be ignored! ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Recursive generator for combinations of a multiset?
On 21 November 2013 06:46, John O'Hagan wrote: > > I found a verbal description of such an algorithm and came up with > this: > > def multicombs(it, r): > result = it[:r] > yield result > while 1: > for i in range(-1, -r - 1, -1): > rep = result[i] > if rep < it[i]: > break > else: > break > for j, n in enumerate(it): > if n > rep: > break > result = result[:i] + it[j:j - i] > yield result I'm not really sure what it is you're asking for. I thought if I ran the code I'd understand but that just confused me more. Is the output below correct? If not what should it be? multicombs("abracadabra", 0) [''] multicombs("abracadabra", 1) ['a'] multicombs("abracadabra", 2) ['ab', 'br', 'ra'] multicombs("abracadabra", 3) ['abr', 'ara', 'bra'] multicombs("abracadabra", 4) ['abra'] multicombs("abracadabra", 5) ['abrac', 'abrbr', 'abrra', 'braca', 'brara', 'brbra', 'racad', 'racbr', 'racra'] Oscar -- https://mail.python.org/mailman/listinfo/python-list
Re: Traceback when using multiprocessing, less than helpful?
On Thursday, November 21, 2013 12:53:07 PM UTC-8, Chris Angelico wrote: > What you could try is Suggestion 1: > printing out the __cause__ and __context__ of > the exception, to see if there's anything useful in them; Suggestion 2: > if there's > nothing, the next thing to try would be some kind of wrapper in your > inner handler (the evaluate function) that retains additional > information. Suggestion 3: > Oh, something else to try: It might be that the proper exception > chaining would happen, except that the info isn't traversing processes > properly due to pickling or something. Can you patch your code to use > threading instead of multiprocessing? That might reveal something. > (Don't worry about abysmal performance at this stage.) I have tried the first suggestion, at the top level of my code. Here are the modified lines, and the output: == try: out = evaluate(net, domain) except ValueError as e: print(type(e)) print(e) # this just produces the exception string itself print(e.__context__) print(e.__cause__) raise e # just so my program actually stops == operands could not be broadcast together with shapes (1,3) (4) None None == So, once I catch the exception, both __context__ and __cause__ are undefined. I will proceed as you have suggested -- but if anything comes to mind based on what I have already done, please feel free to chime in! -- https://mail.python.org/mailman/listinfo/python-list
Re: Traceback when using multiprocessing, less than helpful?
Followup: I didn't need to go as far as Chris Angelico's second suggestion. I haven't looked at certain parts of my own code for a while, but it turns out that I wrote it REASONABLY logically... My evaluate() calls another function through pool.map_async() -- _evaluate(), which actually processes the data, on a single CPU. So I didn't need to hassle with threading, as Chris suggested. All I did was to import _evaluate in my top-level code, then change my function calls from evaluate() to _evaluate(). Out popped my numpy error, with a proper traceback. I can now debug it! I can probably refactor my code to make it even cleaner. I'll have to deal with the fact that pool.map() requires that all arguments to each subprocess be submitted as a single, iterable object. I didn't want to have to do this when I only had a single process to run, but perhaps the tradeoff will be acceptable. So now, for anyone who is still reading this: is it your opinion that the traceback that I obtained through multiprocessing.pool._map_async().get() SHOULD have allowed me to see what the ultimate cause of the exception was? I think so. Is it a bug? Should I request a bugfix? How do I go about doing that? -- https://mail.python.org/mailman/listinfo/python-list
Re: Traceback when using multiprocessing, less than helpful?
On 11/21/2013 01:49 PM, John Ladasky wrote: So now, for anyone who is still reading this: is it your opinion that the traceback that I obtained through multiprocessing.pool._map_async().get() SHOULD have allowed me to see what the ultimate cause of the exception was? It would certainly be nice. I think so. Is it a bug? Should I request a bugfix? How do I go about doing that? Check out bugs.python.org. Search for multiprocessing and tracebacks to see if anything is already there; if not, create a new issue. -- ~Ethan~ -- https://mail.python.org/mailman/listinfo/python-list
Traceback when using multiprocessing, less than helpful?
Hi folks, Somewhat over a year ago, I struggled with implementing a routine using multiprocessing.Pool and numpy. I eventually succeeded, but I remember finding it very hard to debug. Now I have managed to provoke an error from that routine again, and once again, I'm struggling. Here is the end of the traceback, starting with the last line of my code: "result = pool.map(evaluate, bundles)". After that, I'm into Python itself. File ".../evaluate.py", line 81, in evaluate result = pool.map(evaluate, bundles) File "/usr/lib/python3.3/multiprocessing/pool.py", line 228, in map return self._map_async(func, iterable, mapstar, chunksize).get() File "/usr/lib/python3.3/multiprocessing/pool.py", line 564, in get raise self._value ValueError: operands could not be broadcast together with shapes (1,3) (4) Notice that no line of numpy appears in the traceback? Still, there are three things that make me think that this error is coming from numpy. 1. "raise self._value" means that an exception is stored in a variable, to be re-raised. 2. The words "operands" and "broadcast" do not appear anywhere in the source code of multiprocessing.pool. 3. The words "operands" and "broadcast" are common to numpy errors I have seen before. Numpy does many very tricky things when dealing with arrays of different dimensions and shapes. Of course, I am sure that the bug must be in my own code. I even have old programs which are using my evaluate.evaluate() without generating errors. I am comparing the data structures that my working and my non-working programs send to pool.map(). I am comparing the code between my two programs. There is some subtle difference that I haven't spotted. If I could only see the line of numpy code which is generating the ValueError, I would have a better chance of spotting the bug in my code. So, WHY isn't there any reference to numpy in my traceback? Here's my theory. The numpy error was generated in a subprocess. The line "raise self._value" is intercepting the exception generated by my subprocess, and passing it back to the master Python interpreter. Does re-raising an exception, and/or passing an exception from a subprocess, truncate a traceback? That's what I think I'm seeing. Thanks for any advice! -- https://mail.python.org/mailman/listinfo/python-list
Re: Traceback when using multiprocessing, less than helpful?
On 11/21/2013 12:01 PM, John Ladasky wrote: This is a case where you need to dig into the code (or maybe docs) a bit File ".../evaluate.py", line 81, in evaluate > result = pool.map(evaluate, bundles) File "/usr/lib/python3.3/multiprocessing/pool.py", line 228, in map > return self._map_async(func, iterable, mapstar, chunksize).get() The call to _map_async gets a blank MapResult (a subclass of ApplyResult), queues tasks to fill it in, and returns the filled in result. This call is designed to always return as task exceptions are caught and assigned to MapResult._value in both ApplyResult._set and MapResult._set. result = MapResult(self._cache, chunksize, len(iterable), callback, error_callback=error_callback) self._taskqueue.putresult._job, i, mapper, (x,), {}) for i, x in enumerate(task_batches)), None)) return result It is the subsequent call to get() that 'fails', because it raises the caught exception. > File "/usr/lib/python3.3/multiprocessing/pool.py", line 564, in get > raise self._value ValueError: operands could not be broadcast together with shapes (1,3) (4) Notice that no line of numpy appears in the traceback? Still, there are three things that make me think that this error is coming from numpy. It comes from one of your tasks as the 'result', and your tasks use numpy. If I could only see the line of numpy code which is generating the ValueError, I would have a better chance of spotting the bug in my code. Definitely. > So, WHY isn't there any reference to numpy in my traceback? I suspect that raising the exception may replace its __traceback__ attribute. Anyway, there are three things I might try. 1. Use 3.3.3 or latest 3.4 to see if there is any improvement in output. I vaguely remember a tracker issue that might be related. 2. _map_async takes an error_callback arg that defaults to None and which is passed on to MapResult. When _value is set to an exception, "error_callback(_value)" is called in ._set() before the later .get() re-raises it. pool.map does not allow you to set either the (success) callback or the error_callback, but pool.map_async does (this is the difference between the two methods). So switch to the latter so you can pass a function that uses the traceback module to print (or log) the traceback attached to _value, assuming that there is one. 3. If that does not work, wrap the current body of your task function in try: except exception as e: raise e -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Newbie - Trying to Help a Friend
Coming back to the second question "The collatz process is as follows. Take a positive integer n greater than 1. while n is greater than 1 repeat the following; if N is even halve it and if N is odd multiply it by 3 and add 1. The (Unsolved) collatz conjecture is that this process always terminates. The user should be prompted to supply the number n, and your program should build the list of values taken by sucessive iteration of the algorithm, and print it out. For example, if 7 is input your program should print the list [7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1] We've managed to come up with this, but obviously it's wrong. Any Idea's? def collatz_sequence (n) : seq = [ ] if n < 1 : return [ ] while n > 1: if n % 2 == 0: n = n/2 else: n = 3*n+ 1 seq.append (n) return seq -- https://mail.python.org/mailman/listinfo/python-list
Re: Recursive generator for combinations of a multiset?
On Wed, Nov 20, 2013 at 10:46 PM, John O'Hagan wrote: > > Short story: the subject says it all, so if you have an answer already, > fire away. Below is the long story of what I'm using it for, and why I > think it needs to be recursive. It may even be of more general > interest in terms of filtering the results of generators. > I think you probably need permutations rather than combinations. Also, I think you'll need to form a word (partitioned off by spaces), and then check it against a set containing /usr/share/dict/words before recursing for the remainder of the sentence - this should speed things up a LOT. -- https://mail.python.org/mailman/listinfo/python-list
Re: Newbie - Trying to Help a Friend
On 11/21/2013 03:17 PM, bradleybooth12...@gmail.com wrote: Coming back to the second question "The collatz process is as follows. Take a positive integer n greater than 1. while n is greater than 1 repeat the following; if N is even halve it and if N is odd multiply it by 3 and add 1. The (Unsolved) collatz conjecture is that this process always terminates. The user should be prompted to supply the number n, and your program should build the list of values taken by sucessive iteration of the algorithm, and print it out. For example, if 7 is input your program should print the list [7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1] We've managed to come up with this, but obviously it's wrong. Any Idea's? def collatz_sequence (n) : seq = [ ] if n < 1 : return [ ] while n > 1: if n % 2 == 0: n = n/2 else: n = 3*n+ 1 seq.append (n) return seq Why do you say it's wrong? What does it do? What was expected? I see that your indentations don't match, but I can't tell if that's your error or an email problem. Is that the 'obviously wrong' part? I also see that you create an (apparently correct) function, which returns a nice result. But you haven't called the function to actually run it with a specific value to be printed out. Perhaps that's the 'obviously wrong' part you refer to. However, the function itself looks correct otherwise, although you may want to start the sequence off with [n] rather than [] so as to match the suggested output. Gary Herron -- https://mail.python.org/mailman/listinfo/python-list
Re: how to deal with deprecating API functionality in python module?
Chris Angelico writes: > 1) Keep deprecated APIs around for as long as you can, even if they're > implemented messily on top of your current API. > > 2) Design your API with future-proofing in mind. 2.1) Have a generous deprecation schedule, and go to significant lengths to ensure all developers using your library are aware of the schedule. The PEP 4 http://www.python.org/dev/peps/pep-0004/> procedure for deprecating Python standard library modules is a good example. 2.2) The schedule needs to spread over several versions; allow the impending removal of the feature to be preceded by staged deprecation. Use warnings (especially DeprecationWarning) to increase awareness of the removal, and to gradually increase the effort needed to continue using the feature anyway as its removal gets closer. -- \ “That's all very good in practice, but how does it work in | `\ *theory*?” —anonymous | _o__) | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: Newbie - Trying to Help a Friend
the problem i have is that it's just giving me the first number of the sequence not the actual sequence -- https://mail.python.org/mailman/listinfo/python-list
using getattr/setattr for local variables in a member function
Hello, If I have a class that has some member functions, and all the functions define a local variable of the same name (but different type), is there some way to use getattr/setattr to access the local variables specific to a given function? Obviously there's no need to do this for the small test case below, but I'm working on a bigger code where being able to loop through variables that are local to func2 would come in handy. For example: class A(object): def __init__(self): pass def func1(self): a = {"A": 1} b = {"B": 2} def func2(self): a = [1] b = [2] for attr in ("a", "b"): var = getattr(self, attr) ! What do I put in place of self var.append(100)! to access vars "a" and "b" that ! are local to this function? Catherine -- https://mail.python.org/mailman/listinfo/python-list
Re: Newbie - Trying to Help a Friend
On 11/21/2013 6:17 PM, bradleybooth12...@gmail.com wrote: Coming back to the second question "The collatz process is as follows. Take a positive integer n greater than 1. while n is greater than 1 repeat the following; if N is even halve it and if N is odd multiply it by 3 and add 1. The (Unsolved) collatz conjecture is that this process always terminates. The user should be prompted to supply the number n, and your program should build the list of values taken by sucessive iteration of the algorithm, and print it out. For example, if 7 is input your program should print the list [7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1] The specification does not say what the result should be when the input is 1, but given the example above, [1] seems reasonable (rather than an exception or []). [] is ok for 0 (or negative). We've managed to come up with this, but obviously it's wrong. In what way is it wrong? The answer to that tells you what to fix. A syntax error about indentation? Fix the indentation. > Any Idea's? Write test code before writing the function. for inn,out in [(0, []), (1, [1]), (2, [2,1]), (3, [3,10,5,16,8,4,2,1]), (7, [7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1]), ]: s = collatz(inn) print(inn, ':', s) if s != out: print('is not', out) def collatz_sequence (n) : seq = [ ] 4 space indents are best; a good editor, like the one with Idle, will convert to 4 spaces if n < 1 : return [ ] while n > 1: if n % 2 == 0: dedent if so it lines up with else below n = n/2 else: n = 3*n+ 1 seq.append (n) return seq does not line up with while Once you get indents consistent, test failure should suggest the remaining error. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Traceback when using multiprocessing, less than helpful?
On Fri, Nov 22, 2013 at 5:25 AM, John Ladasky wrote: > On Thursday, November 21, 2013 9:24:33 AM UTC-8, Chris Angelico wrote: > >> Hmm. This looks like a possible need for the 'raise from' syntax. > > Thank you, Chris, that made me feel like a REAL Python programmer -- I just > did some reading, and the "raise from" feature was not implemented until > Python 3! And I might actually need it! :^) > > I think that the article http://www.python.org/dev/peps/pep-3134/ is > relevant. Reading it now. To be clear: the complete exception change is > stored in every class, it's just not being displayed? I hope that's the > case. I shouldn't have to install a "raise from" hook in > multiprocessing.map_async itself. > That PEP is all about the 'raise from' notation, yes; but the exception chaining is presumably not being stored, or else you would be able to see it in the default printout. So the best solution to this is, most likely, a patch to multiprocessing to have it chain exceptions properly. I think that would be considered a bugfix, and thus back-ported to all appropriate versions (rather than a feature enhancement that goes in 3.4 or 3.5 only). What you could try is printing out the __cause__ and __context__ of the exception, to see if there's anything useful in them; if there's nothing, the next thing to try would be some kind of wrapper in your inner handler (the evaluate function) that retains additional information. Oh, something else to try: It might be that the proper exception chaining would happen, except that the info isn't traversing processes properly due to pickling or something. Can you patch your code to use threading instead of multiprocessing? That might reveal something. (Don't worry about abysmal performance at this stage.) Hopefully someone with more knowledge of Python's internals can help out, here. One way or another, I suspect this will result in a tracker issue. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Newbie - Trying to Help a Friend
On Thu, Nov 21, 2013 at 10:53 PM, Antoon Pardon wrote: > Op 20-11-13 19:09, Mark Lawrence schreef: >> I suggest that you write to the BBC and get all episodes of the >> extremely popular *COMEDY* "Dad's Army" withdrawn as "typical shabby >> Nazi trick" was one of Captain Mainwearing's main lines. > > Honestly? You expect people to recognize a main line from an old > television series? Well, a good British comedy does go around a long way. I have to say, though, the shortness of the line makes it harder to recognize. Only in the tightest of circles could one say "Bother that telephone!" and have people understand that it's a reference to the Fat Controller from The Railway Series (aka the Thomas the Tank Engine books). The more quote you make, the more likely that pieces of it will be recognized. But as I said, all it takes is a little footnote, or something like "... typical shabby Nazi trick, as Capt Mainwearing would say", to make it clear. Most (all?) of us would understand that as a joke/reference and as not offensive. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: using getattr/setattr for local variables in a member function
On 21/11/2013 23:12, Catherine M Moroney wrote: Hello, If I have a class that has some member functions, and all the functions define a local variable of the same name (but different type), is there some way to use getattr/setattr to access the local variables specific to a given function? Obviously there's no need to do this for the small test case below, but I'm working on a bigger code where being able to loop through variables that are local to func2 would come in handy. For example: class A(object): def __init__(self): pass def func1(self): a = {"A": 1} b = {"B": 2} def func2(self): a = [1] b = [2] for attr in ("a", "b"): var = getattr(self, attr) ! What do I put in place of self var.append(100)! to access vars "a" and "b" that ! are local to this function? You can get the local names of a function using locals(): class A(object): def __init__(self): pass def func1(self): a = {"A": 1} b = {"B": 2} def func2(self): a = [1] b = [2] for name in ("a", "b"): var = locals()[name] var.append(100) BTW, in Python they're called "methods". (C++ calls them "member functions", but Python isn't C++!) -- https://mail.python.org/mailman/listinfo/python-list
Re: Newbie - Trying to Help a Friend
Op 20-11-13 19:09, Mark Lawrence schreef: > On 20/11/2013 17:51, Ned Batchelder wrote: >> On Wednesday, November 20, 2013 12:37:31 PM UTC-5, Mark Lawrence wrote: >>> On 20/11/2013 17:12, Ned Batchelder wrote: Nazi? Perhaps we could stick to more appropriate analogies? --Ned. >>> >>> It's an excellent analogy that I've used before, hence the smiley. >>> Clearly you don't do any research before bothering to say anything. >>> >>> -- >>> Python is the second best programming language in the world. >>> But the best has yet to be invented. Christian Tismer >>> >>> Mark Lawrence >> >> You think these two things make an excellent analogy? 1) a newsgroup >> mishap being actively investigated, and 2) calculated genocide. It is >> not an excellent analogy, it's wildly disproportionate. >> >> Using a smiley doesn't fix it, and using it previously doesn't give >> you a free pass. What research was I supposed to have done? Examine >> your previous posts to see you overreacting before? That would hardly >> have convinced me that this was OK. >> >> --Ned. >> > > I suggest that you write to the BBC and get all episodes of the > extremely popular *COMEDY* "Dad's Army" withdrawn as "typical shabby > Nazi trick" was one of Captain Mainwearing's main lines. Honestly? You expect people to recognize a main line from an old television series? > And if I want > to overreact, I'll overreact, as I couldn't care two hoots whether I'm > dealing with an arsehole from the Python Software Foundation or one > who's not. Now you sound just like Nikos. -- Antoon Pardon -- https://mail.python.org/mailman/listinfo/python-list
Re: Newbie - Trying to Help a Friend
On 11/21/2013 6:55 PM, bradleybooth12...@gmail.com wrote: the problem i have is that it's just giving me the first number of the sequence not the actual sequence Please show actually copy/pasted input and output. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Newbie - Trying to Help a Friend
On Fri, Nov 22, 2013 at 3:29 AM, Neil Cerutti wrote: > Many of the main villains in > the book are hilarious and mean-spirited parodies of > a series of British children's literature, The Wombles, > and a British TV show, Steptoe and Son, but the characters work > fine on their own. Yeah, that's definitely the best way to do it. You don't need to know The Beauty Stone to understand that Colinette, in the city of Lenalede, is trying to get herself appointed as Lord Chief Justice on the grounds that (she claims) the current incumbent is unfair in his rulings. But if you _do_ know that obscure 19th century opera, you'll know there's a line in it "And Colinette from Lenalede, who counts herself the fairest there". (The opera has absolutely nothing to do with justice, incidentally. Colinette is entering herself in a beauty contest. Quite a different meaning of "fairest".) ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Having trouble setting up an extremely simple server...
I'm attempting to set up an extremely simple server that receives a string, and returns a string. However, I have 2 problems. I'm able to receive the string from the client fine, but it only will receive it once. After I send another string from the client, it doesn't come up on the server... Also, I want to send something BACK to the client-side, but I can't seem to see how... Please help! I'm very new to networking, but I've been using Python for a while now, just recent;y getting into networking, trying to get things down. SERVER.PY: import socket; serverReady = True; serverSock = socket.socket(socket.AF_INET, socket.SOCK_STREAM); serverSock.bind(('localhost', 8081)); serverSock.listen(10); while (True): connection, address = serverSock.accept(); if (serverReady): serverSockBuffer = connection.recv(1024); if (len(serverSockBuffer) > 0): print serverSockBuffer; if (raw_input("Ready?: ") in ['yes', 'y']): serverReady = True; else: serverReady = False; CLIENT.PY: import socket; clientSock = socket.socket(socket.AF_INET, socket.SOCK_STREAM); clientSock.connect(('localhost', 8081)); user = raw_input("Username: "); while (True): sendData = raw_input("Send: "); clientSock.send(str(sendData + ' -- ' + user)); print clientSock; -- https://mail.python.org/mailman/listinfo/python-list
Re: using getattr/setattr for local variables in a member function
On Thursday, November 21, 2013 6:12:10 PM UTC-5, Catherine M Moroney wrote: > Hello, > > If I have a class that has some member functions, and all the functions > define a local variable of the same name (but different type), is there > some way to use getattr/setattr to access the local variables specific > to a given function? > > Obviously there's no need to do this for the small test case below, > but I'm working on a bigger code where being able to loop through > variables that are local to func2 would come in handy. > > For example: > > class A(object): > def __init__(self): > pass > > def func1(self): > a = {"A": 1} > b = {"B": 2} > > def func2(self): > a = [1] > b = [2] > > for attr in ("a", "b"): > var = getattr(self, attr) ! What do I put in place of self > var.append(100)! to access vars "a" and "b" that > ! are local to this function? > > Catherine Catherine, it's a little hard to know what your real code is doing from this toy sample. Usually, if you want to work with "variable variables" as you're suggesting here, the better approach is to use one dictionary instead of many variables. Then you can deal with them as a single collection much more conveniently. Can you show us the real code in question? It will be much easier to make a good recommendation if we can see what you are doing with these variables. --Ned. -- https://mail.python.org/mailman/listinfo/python-list
Re: Traceback when using multiprocessing, less than helpful?
On Thursday, November 21, 2013 9:24:33 AM UTC-8, Chris Angelico wrote: > Hmm. This looks like a possible need for the 'raise from' syntax. Thank you, Chris, that made me feel like a REAL Python programmer -- I just did some reading, and the "raise from" feature was not implemented until Python 3! And I might actually need it! :^) I think that the article http://www.python.org/dev/peps/pep-3134/ is relevant. Reading it now. To be clear: the complete exception change is stored in every class, it's just not being displayed? I hope that's the case. I shouldn't have to install a "raise from" hook in multiprocessing.map_async itself. -- https://mail.python.org/mailman/listinfo/python-list
Re: using getattr/setattr for local variables in a member function
On Fri, 22 Nov 2013 00:52:21 +, MRAB wrote: > If I have a class that has some member functions, and all the functions > define a local variable of the same name (but different type), is there > some way to use getattr/setattr to access the local variables specific > to a given function? If you mean to access them from within the same method, someone else has already shown it using locals(). But you cannot access locals from a method that's already terminated. They no longer exist. -- DaveA -- https://mail.python.org/mailman/listinfo/python-list
Re: Recursive generator for combinations of a multiset?
On Thursday, November 21, 2013 5:01:15 AM UTC-8, John O'Hagan wrote: > On Thu, 21 Nov 2013 11:42:49 + > > Oscar Benjamin wrote: > > > > > On 21 November 2013 06:46, John O'Hagan > > > wrote: > > > > > > > > I found a verbal description of such an algorithm and came up with > > > > this: > > > > > > > > def multicombs(it, r): > > > > result = it[:r] > > > > yield result > > > > while 1: > > > > for i in range(-1, -r - 1, -1): > > > > rep = result[i] > > > > if rep < it[i]: > > > > break > > > > else: > > > > break > > > > for j, n in enumerate(it): > > > > if n > rep: > > > > break > > > > result = result[:i] + it[j:j - i] > > > > yield result > > > > > > I'm not really sure what it is you're asking for. I thought if I ran > > > the code I'd understand but that just confused me more. Is the output > > > below correct? If not what should it be? > > > > > > multicombs("abracadabra", 0) > > > [''] > > > multicombs("abracadabra", 1) > > > ['a'] > > > multicombs("abracadabra", 2) > > > ['ab', 'br', 'ra'] > > > multicombs("abracadabra", 3) > > > ['abr', 'ara', 'bra'] > > > multicombs("abracadabra", 4) > > > ['abra'] > > > multicombs("abracadabra", 5) > > > ['abrac', 'abrbr', 'abrra', 'braca', 'brara', 'brbra', 'racad', > > > 'racbr', 'racra'] > > > > > > I neglected to mention that multicombs takes a sorted iterable; > > it doesn't work right otherwise. I'd forgotten that because my > > wordlists are guaranteed sorted by the way they're built. Sorry about > > that. > > > > In my use-case the first argument to multicombs is a tuple of words > > which may contain duplicates, and it produces all unique combinations > > of a certain length of those words, eg: > > > > list(multicombs(('cat', 'hat', 'in', 'the', 'the'), 3)) > > > > [('cat', 'hat', 'in'), ('cat', 'hat', 'the'), ('cat', 'in', 'the'), > > ('cat', 'the', 'the'), ('hat', 'in', 'the'), ('hat', 'the', 'the'), > > ('in', 'the', 'the')] > > > > Contrast this with: > > > > list(itertools.combinations(('cat', 'hat', 'in', 'the', 'the'), 3)) > > > > [('cat', 'hat', 'in'), ('cat', 'hat', 'the'), ('cat', 'hat', 'the'), > > ('cat', 'in', 'the'), ('cat', 'in', 'the'), ('cat', 'the', 'the'), > > ('hat', 'in', 'the'), ('hat', 'in', 'the'), ('hat', 'the', 'the'), > > ('in', 'the', 'the')] > > > > which produces results which are redundant for my purposes. > > > > What I'm looking for is a recursive algorithm which does what > > multicombs does (order unimportant) so that I can apply a pruning > > shortcut like the one I used in the recursive cartesian product > > algorithm in my original post. > > > > Multiset combination algorithms seem pretty thin on the ground out > > there - as I said, I could only find a description of the procedure > > above, no actual code. The ones I did find are non-recursive. I'm > > hoping some combinatorics and/or recursion experts can offer advice. > > > > Regards, > > > > -- > > > > John Could convert the following perl script to python? use Data::Dump qw(dump); dump combo([@ARGV], 3); sub combo { my ($t, $k) = @_; my @T = @$t; my @R = (); my %g = (); if ($k == 1) { for (@T) { push @R, $_ unless $g{$_}++; } } else { while (my $x = shift @T) { $p = combo([@T], $k-1); for (@{$p}) { my $q = $x.",".$_; push @R, $q unless $g{$q}++; } } } [@R]; } $ prog.pl cat hat in the the [ "cat,hat,in", "cat,hat,the", "cat,in,the", "cat,the,the", "hat,in,the", "hat,the,the", "in,the,the", ] James -- https://mail.python.org/mailman/listinfo/python-list
Re: Newbie - Trying to Help a Friend
On Thu, Nov 21, 2013 at 10:48 AM, Chris Angelico wrote: > Well, a good British comedy does go around a long way. I have to say, > though, the shortness of the line makes it harder to recognize. Only > in the tightest of circles could one say "Bother that telephone!" and > have people understand that it's a reference to the Fat Controller > from The Railway Series (aka the Thomas the Tank Engine books). The > more quote you make, the more likely that pieces of it will be > recognized. The best sort of reference is one you can miss completely and still not be confused by. For example, The Borribles by De Larrabeiti is one of my favorite books despite my knowing virtually nothing of the back-streets of London or the (now dated) pop-culture satire it contained. Many of the main villains in the book are hilarious and mean-spirited parodies of a series of British children's literature, The Wombles, and a British TV show, Steptoe and Son, but the characters work fine on their own. But even so, I agree that a footnote is a good idea. And I haven't always lived up to that ideal, myself. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list
Re: Having trouble setting up an extremely simple server...
On Thursday, November 21, 2013 9:33:13 PM UTC-5, Roy Smith wrote: > In article <9e773107-5a6c-486b-bef2-186101d8f...@googlegroups.com>, > > cilantr...@gmail.com wrote: > > > > > I'm attempting to set up an extremely simple server that receives a string, > > > and returns a string. However, I have 2 problems. I'm able to receive the > > > string from the client fine, but it only will receive it once. After I send > > > another string from the client, it doesn't come up on the server... Also, I > > > want to send something BACK to the client-side, but I can't seem to see > > > how... Please help! I'm very new to networking, but I've been using Python > > > for a while now, just recent;y getting into networking, trying to get > > things > > > down. > > > > > > SERVER.PY: > > > > > > import socket; > > > serverReady = True; > > > > > > serverSock = socket.socket(socket.AF_INET, socket.SOCK_STREAM); > > > serverSock.bind(('localhost', 8081)); > > > serverSock.listen(10); > > > > > > while (True): > > > connection, address = serverSock.accept(); > > > if (serverReady): > > > serverSockBuffer = connection.recv(1024); > > > if (len(serverSockBuffer) > 0): > > > print serverSockBuffer; > > > if (raw_input("Ready?: ") in ['yes', 'y']): > > > serverReady = True; > > > else: > > > serverReady = False; > > > > First thing, get rid of all those semicolons. This is Python you're > > writing, not C++. Likewise, the extra parens in your while statements. > > > > Your problem is that you're doing the accept() inside your main loop on > > the server. You want to be doing it once, outside the loop. I prefer using the semicolons... They aren't making my code wrong... I use other programming languages from time to time, and I'd rather just always use semicolons, as with the parentheses. I will try that though, moving the accept(). What about sending information back to the client? -- https://mail.python.org/mailman/listinfo/python-list
Re: Having trouble setting up an extremely simple server...
In article , Cilantro MC wrote: > > First thing, get rid of all those semicolons. This is Python you're > > > > writing, not C++. Likewise, the extra parens in your while statements. > > > > > > > > Your problem is that you're doing the accept() inside your main loop on > > > > the server. You want to be doing it once, outside the loop. I suggest you find another way to post other than Google Groups. As you can see from what I've quoted above, their interface ends up double-spacing everything and making it difficult to read. > I prefer using the semicolons... They aren't making my code wrong... I use > other programming languages from time to time, and I'd rather just always use > semicolons, as with the parentheses. Well, no, they're not making your code wrong, but it's just not the way people write Python. >What about sending information back to the client? You can use the same socket for communication in both directions. The client and server need to alternate doing send() and recv() calls. Client does send() and server does recv(). Then, the server does send() and the client does recv(). -- https://mail.python.org/mailman/listinfo/python-list
Re: Having trouble setting up an extremely simple server...
On Thursday, November 21, 2013 9:36:32 PM UTC-5, Cilantro MC wrote: > On Thursday, November 21, 2013 9:33:13 PM UTC-5, Roy Smith wrote: > > In article <9e773107-5a6c-486b-bef2-186101d8f...@googlegroups.com>, > > cilantr...@gmail.com wrote: > > > > > I'm attempting to set up an extremely simple server that receives a > > > string, > > > and returns a string. However, I have 2 problems. I'm able to receive the > > > string from the client fine, but it only will receive it once. After I > > > send > > > another string from the client, it doesn't come up on the server... Also, > > > I > > > want to send something BACK to the client-side, but I can't seem to see > > > how... Please help! I'm very new to networking, but I've been using > > > Python > > > for a while now, just recent;y getting into networking, trying to get > > > things > > > down. > > > > > > SERVER.PY: > > > > > > import socket; > > > serverReady = True; > > > > > > serverSock = socket.socket(socket.AF_INET, socket.SOCK_STREAM); > > > serverSock.bind(('localhost', 8081)); > > > serverSock.listen(10); > > > > > > while (True): > > > connection, address = serverSock.accept(); > > > if (serverReady): > > > serverSockBuffer = connection.recv(1024); > > > if (len(serverSockBuffer) > 0): > > > print serverSockBuffer; > > > if (raw_input("Ready?: ") in ['yes', 'y']): > > > serverReady = True; > > > else: > > > serverReady = False; > > > > First thing, get rid of all those semicolons. This is Python you're > > writing, not C++. Likewise, the extra parens in your while statements. > > > > Your problem is that you're doing the accept() inside your main loop on > > the server. You want to be doing it once, outside the loop. > > I prefer using the semicolons... They aren't making my code wrong... I use > other programming languages from time to time, and I'd rather just always use > semicolons, as with the parentheses. Well then, why not use two semicolons at the end of each statement? Or even three? If your answer is, "Because that looks silly and is unnecessary," then now you know how Python programmers feel about one semicolon! :) --Ned. -- https://mail.python.org/mailman/listinfo/python-list
Re: Recursive generator for combinations of a multiset?
On Thu, 21 Nov 2013 11:42:49 + Oscar Benjamin wrote: > On 21 November 2013 06:46, John O'Hagan > wrote: > > > > I found a verbal description of such an algorithm and came up with > > this: > > > > def multicombs(it, r): > > result = it[:r] > > yield result > > while 1: > > for i in range(-1, -r - 1, -1): > > rep = result[i] > > if rep < it[i]: > > break > > else: > > break > > for j, n in enumerate(it): > > if n > rep: > > break > > result = result[:i] + it[j:j - i] > > yield result > > I'm not really sure what it is you're asking for. I thought if I ran > the code I'd understand but that just confused me more. Is the output > below correct? If not what should it be? > > multicombs("abracadabra", 0) > [''] > multicombs("abracadabra", 1) > ['a'] > multicombs("abracadabra", 2) > ['ab', 'br', 'ra'] > multicombs("abracadabra", 3) > ['abr', 'ara', 'bra'] > multicombs("abracadabra", 4) > ['abra'] > multicombs("abracadabra", 5) > ['abrac', 'abrbr', 'abrra', 'braca', 'brara', 'brbra', 'racad', > 'racbr', 'racra'] I neglected to mention that multicombs takes a sorted iterable; it doesn't work right otherwise. I'd forgotten that because my wordlists are guaranteed sorted by the way they're built. Sorry about that. In my use-case the first argument to multicombs is a tuple of words which may contain duplicates, and it produces all unique combinations of a certain length of those words, eg: list(multicombs(('cat', 'hat', 'in', 'the', 'the'), 3)) [('cat', 'hat', 'in'), ('cat', 'hat', 'the'), ('cat', 'in', 'the'), ('cat', 'the', 'the'), ('hat', 'in', 'the'), ('hat', 'the', 'the'), ('in', 'the', 'the')] Contrast this with: list(itertools.combinations(('cat', 'hat', 'in', 'the', 'the'), 3)) [('cat', 'hat', 'in'), ('cat', 'hat', 'the'), ('cat', 'hat', 'the'), ('cat', 'in', 'the'), ('cat', 'in', 'the'), ('cat', 'the', 'the'), ('hat', 'in', 'the'), ('hat', 'in', 'the'), ('hat', 'the', 'the'), ('in', 'the', 'the')] which produces results which are redundant for my purposes. What I'm looking for is a recursive algorithm which does what multicombs does (order unimportant) so that I can apply a pruning shortcut like the one I used in the recursive cartesian product algorithm in my original post. Multiset combination algorithms seem pretty thin on the ground out there - as I said, I could only find a description of the procedure above, no actual code. The ones I did find are non-recursive. I'm hoping some combinatorics and/or recursion experts can offer advice. Regards, -- John -- https://mail.python.org/mailman/listinfo/python-list
Re: Newbie - Trying to Help a Friend
Dennis Lee Bieber writes: > Does Pan have an option to generate its own Message-ID header? > > Headers seem to indicate multiple injections somewhere Perhaps Pan doesn't? Someone else had multipostings in the Android group but he was posting via aioe. -- https://mail.python.org/mailman/listinfo/python-list
Re: Traceback when using multiprocessing, less than helpful?
On Fri, Nov 22, 2013 at 4:01 AM, John Ladasky wrote: > Here is the end of the traceback, starting with the last line of my code: > "result = pool.map(evaluate, bundles)". After that, I'm into Python itself. > > File ".../evaluate.py", line 81, in evaluate > result = pool.map(evaluate, bundles) > File "/usr/lib/python3.3/multiprocessing/pool.py", line 228, in map > return self._map_async(func, iterable, mapstar, chunksize).get() > File "/usr/lib/python3.3/multiprocessing/pool.py", line 564, in get > raise self._value > ValueError: operands could not be broadcast together with shapes (1,3) (4) > > Notice that no line of numpy appears in the traceback? Still, there are > three things that make me think that this error is coming from numpy. Hmm. This looks like a possible need for the 'raise from' syntax. I just checked multiprocessing/pool.py from 3.4 alpha, and it has much what you're seeing there, in the definition of AsyncResult (of which MapResult is a subclass). The question is, though, how well does the information traverse the process boundary? ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Having trouble setting up an extremely simple server...
In article <9e773107-5a6c-486b-bef2-186101d8f...@googlegroups.com>, cilantr...@gmail.com wrote: > I'm attempting to set up an extremely simple server that receives a string, > and returns a string. However, I have 2 problems. I'm able to receive the > string from the client fine, but it only will receive it once. After I send > another string from the client, it doesn't come up on the server... Also, I > want to send something BACK to the client-side, but I can't seem to see > how... Please help! I'm very new to networking, but I've been using Python > for a while now, just recent;y getting into networking, trying to get things > down. > > SERVER.PY: > > import socket; > serverReady = True; > > serverSock = socket.socket(socket.AF_INET, socket.SOCK_STREAM); > serverSock.bind(('localhost', 8081)); > serverSock.listen(10); > > while (True): > connection, address = serverSock.accept(); > if (serverReady): > serverSockBuffer = connection.recv(1024); > if (len(serverSockBuffer) > 0): > print serverSockBuffer; > if (raw_input("Ready?: ") in ['yes', 'y']): > serverReady = True; > else: > serverReady = False; First thing, get rid of all those semicolons. This is Python you're writing, not C++. Likewise, the extra parens in your while statements. Your problem is that you're doing the accept() inside your main loop on the server. You want to be doing it once, outside the loop. -- https://mail.python.org/mailman/listinfo/python-list
Re: using getattr/setattr for local variables in a member function
On 11/21/2013 06:02 PM, Dave Angel wrote: Catherine Moroney wrote: If I have a class that has some member functions, and all the functions define a local variable of the same name (but different type), is there some way to use getattr/setattr to access the local variables specific to a given function? If you mean to access them from within the same method, someone else has already shown it using locals(). But you cannot access locals from a method that's already terminated. They no longer exist. Also, accessing is fine, but not all pythons support changing them. -- ~Ethan~ -- https://mail.python.org/mailman/listinfo/python-list
Re: Traceback when using multiprocessing, less than helpful?
On Thursday, November 21, 2013 2:32:08 PM UTC-8, Ethan Furman wrote: > Check out bugs.python.org. Search for multiprocessing and tracebacks to see > if anything is already there; if not, create a new issue. And on Thursday, November 21, 2013 2:37:13 PM UTC-8, Terry Reedy wrote: > 1. Use 3.3.3 or latest 3.4 to see if there is any improvement in output. > I vaguely remember a tracker issue that might be related. All right, there appear to be two recent bug reports which are relevant. http://bugs.python.org/issue13831 http://bugs.python.org/issue17836 The comments in the first link, from Richard Oudkerk, appear to indicate that pickling an Exception (so that it can be sent between processes) is difficult, perhaps impossible. I have never completely understood what can be pickled, and what cannot -- or, for that matter, why data needs to be pickled to pass it between processes. In any case, a string representation of the traceback can be pickled. For debugging purposes, that can still help. So, if I understand everything correctly, in this link... http://hg.python.org/cpython/rev/c4f92b597074/ ...Richard submits his "hack" (his description) to Python 3.4 which pickles and passes the string. When time permits, I'll try it out. Or maybe I'll wait, since Python 3.4.0 is still in alpha. -- https://mail.python.org/mailman/listinfo/python-list
Re: Having trouble setting up an extremely simple server...
Cilantro MC wrote: I prefer using the semicolons... They aren't making my code wrong... I use other programming languages from time to time, and I'd rather just always use semicolons, as with the parentheses. It's your choice, but just be aware that other Python programmers reading your code will find it annoying, and it's not generally a good idea to annoy people that you're asking for help. :-) -- Greg -- https://mail.python.org/mailman/listinfo/python-list
Re: using getattr/setattr for local variables in a member function
Catherine M Moroney wrote: is there some way to use getattr/setattr to access the local variables specific to a given function? No, because those variables don't even exist when there isn't a call to the function in progress. Your example suggests that, instead of local variables, you really want them to be attributes of your object somehow. The best way to go about that will depend on how you want to use them. If you explain more about the problem you're trying to solve, we may be able to suggest a solution. -- Greg -- https://mail.python.org/mailman/listinfo/python-list
Re: Off-topic: Pop culture references [was Re: Newbie - Trying to Help a Friend]
Tim Golden wrote: One of the (occasionally humbling) effects of internet communication is the realisation that the pop-culture reference you assumed would be instantly shared and understood by *any normal person anywhere* is, in fact, confined to your own back yard. Obviously we need a mail/newsreader plugin that googles for cultural references in the messages you're reading and inserts helpful footnote links! -- Greg -- https://mail.python.org/mailman/listinfo/python-list
Re: Traceback when using multiprocessing, less than helpful?
On Fri, Nov 22, 2013 at 2:57 PM, John Ladasky wrote: > or, for that matter, why data needs to be pickled to pass it between > processes. Oh, that part's easy. Let's leave the multiprocessing module out of it for the moment; imagine you spin up two completely separate instances of Python. Create some object in one of them; now, transfer it to the other. How are you going to do it? Ultimately, the operating system isn't going to give you facilities for moving complex objects around - what you almost exclusively get is streams of bytes (or occasionally messaged chunks with lengths, but still of bytes). Pickling is one method of turning an object into a stream of bytes, in such a way that it can be turned back into an equivalent object on the other side. And therein is the problem with exceptions; since the traceback includes references to stack frames and such, it's not as simple as saying "Two to beam up" and hearing the classic sound effect - somehow you need to transfer all the appropriate information across processes. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Newbie - Trying to Help a Friend
On 11/21/2013 03:55 PM, bradleybooth12...@gmail.com wrote: the problem i have is that it's just giving me the first number of the sequence not the actual sequence Not when I run it. After correcting the indentation errors, I get the correct sequence *except* that it's missing the first number. You are making it very hard to help you. Please show us the *whole* session: the procedure (correctly indented please), the call of the procedure, the print that outputs the result and the actual printed result. Also provide an explanation of why the output is not what you wanted. Then perhaps we can get to the bottom of this. Gary Herron -- https://mail.python.org/mailman/listinfo/python-list
Re: Having trouble setting up an extremely simple server...
On Fri, Nov 22, 2013 at 3:02 PM, Gregory Ewing wrote: > Cilantro MC wrote: >> >> I prefer using the semicolons... They aren't making my code wrong... I use >> other programming languages from time to time, and I'd rather just always >> use >> semicolons, as with the parentheses. > > > It's your choice, but just be aware that other Python > programmers reading your code will find it annoying, > and it's not generally a good idea to annoy people > that you're asking for help. :-) Or, worse, to confuse us as to the purpose of your code. People here are used to spotting bugs, and that bug-spotting is hugely aided by certain conventions - many of which are laid out in PEP 8 [1], though of course you don't need to follow all of those guidelines. I'm a polyglot programmer, myself, so I completely understand your desire to put semicolons around the place. Actually, my work in C/C++ and Pike, where semicolons are mandatory, isn't why I want to put them in; no, it's because of JavaScript, where they're technically optional but the omission can sometimes lead to misparsing of code - THAT is where I'll be careful to put them in. Omit a semi in C? Simple compilation error, almost certainly. Omit one in JS? Works perfectly... or at least seems to. Omit them all in Python? Actually genuinely works perfectly. :) ChrisA [1] http://www.python.org/dev/peps/pep-0008/ -- https://mail.python.org/mailman/listinfo/python-list
Re: Having trouble setting up an extremely simple server...
On Thu, 21 Nov 2013 18:36:32 -0800, Cilantro MC wrote: > I prefer using the semicolons... They aren't making my code wrong... I > use other programming languages from time to time, and I'd rather just > always use semicolons, as with the parentheses. There are all sorts of things that you can do that don't make your code "wrong" but do make it difficult to deal with. Why stop with semi-colons? import socket; pass; pass; pass; pass; pass; serverReady = ((True is True) is True) is True) is True); serverSock = socket . \ socket( socket . \ AF_INET\ , \ socket.\ SOCK_STREAM\ ) \ ; is legal, correct code and works fine. So why not write that? Because it is *annoying* code. It doesn't read fluently. The unnecessary punctuation and silly spacing makes it harder to read. To a fluent Python programmer, that's what semi-colons are like, although to a lesser degree. An unnecessary distraction and annoyance, rather like people who talk like this: "Er, I prefer, um, using the semicolons, um... They, um, aren't making my, um, code wrong... er, I use other, um, programming languages, um, from time to time, um, and I'd, er, rather, um, just always, um, use semicolons, um, as with, er, the parentheses, um." Pretty horrible. The sentences are still grammatically correct. But that doesn't mean it's a good idea to talk like that. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: Having trouble setting up an extremely simple server...
On Friday, November 22, 2013 11:02:43 AM UTC+5:30, Steven D'Aprano wrote: > To a fluent Python programmer, that's what semi-colons are like, although > to a lesser degree. An unnecessary distraction and annoyance, rather like > people who talk like this: > "Er, I prefer, um, using the semicolons, um... They, um, aren't making > my, um, code wrong... er, I use other, um, programming languages, um, > from time to time, um, and I'd, er, rather, um, just always, um, use > semicolons, um, as with, er, the parentheses, um." > Pretty horrible. The sentences are still grammatically correct. But that > doesn't mean it's a good idea to talk like that. LOL!! -- https://mail.python.org/mailman/listinfo/python-list
Web framework
I'm thinking of porting a Python application that uses numpy for web, basically would like to upload a user-defined data, perform the calculations with numpy and plot charts with the general structure of a site such as a blog for example, I have studied a bit of django and web2py, but I wonder if there is some better framework? or how to choose a particular framework over another? Since now, thanks -- https://mail.python.org/mailman/listinfo/python-list
Re:Web framework
bottle webpy flask ? what does "better" means ? -- Original -- From: "Renato Barbosa Pim Pereira";; Date: Fri, Nov 22, 2013 02:15 PM To: "python list"; Subject: Web framework I'm thinking of porting a Python application that uses numpy for web, basically would like to upload a user-defined data, perform the calculations with numpy and plot charts with the general structure of a site such as a blog for example, I have studied a bit of django and web2py, but I wonder if there is some better framework? or how to choose a particular framework over another? Since now, thanks -- https://mail.python.org/mailman/listinfo/python-list ..-- https://mail.python.org/mailman/listinfo/python-list