[RELEASE] Python 2.7.6 release candidate 1
I'm happy to announce the availability of Python 2.7.6 release candidate 1. Most importantly, this release candidate resolves crashes of the interactive interpreter on OS X 10.9. It also includes the usual collection of bugfixes over 2.7.5. These are described in excruciating detail in the Misc/NEWS file of the source tarball. You can view it online at http://hg.python.org/cpython/raw-file/9750acbf7c40/Misc/NEWS Downloads are at http://python.org/download/releases/2.7.6/ As always, please test the release and report bugs to http://bugs.python.org/ With any luck, the final release will follow in a week. Enjoy, Benjamin Peterson 2.7 Release Manager -- https://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
[ANN] jsonrpclib-pelix 0.1.6
== jsonrpclib-pelix 0.1.6 == jsonrpclib-pelix v0.1.6 has been released ! About jsonrpclib-pelix == This library is an implementation of the JSON-RPC specification. It supports both the original 1.0 specification, as well as the 2.0 specification, which includes batch submission, keyword arguments, etc. This is a patched version of the original jsonrpclib project by Josh Marshall, available at https://github.com/joshmarshall/jsonrpclib. The suffix -pelix only indicates that this version works with Pelix Remote Services, but it is not a Pelix specific implementation. jsonrpclib-pelix supports both Python 2 (tested on 2.7) and Python 3 (tested on 3.2). It is licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0.html). What's new in 0.1.6 === - Corrected a bug in the unmarshalling process: now beans can be correctly used in RPC - Corrected a bug on Python 2.7: the io module was imported instead of StringIO - The configuration of a jsonrpclib server or client can now be an instance of the Config class, instead of using a singleton. This allows to use mutliple servers/clients with different configurations. jsonrpclib-pelix is available on : - PyPI: https://pypi.python.org/pypi/jsonrpclib-pelix/0.1.6 - Github: https://github.com/tcalmant/jsonrpclib Have fun ! Thomas -- https://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Nimbits 0.1 released
Hi, I released the first version of Nimbits python libraries. Nimbits ( http://www.nimbits.com) is a collection of software for recording time series data to the cloud and with this library you can store and retrieve values of your data points, for example you can store the value taken from a temperature sensor attached to your Raspberry every 20 seconds ( https://github.com/astagi/tempsender_sample ) The interface is simple and intuitive, look at the sample.py script :) Repo: https://github.com/astagi/pynimbits Download: https://pypi.python.org/pypi/nimbits/0.1 -- Andrea Stagi (@4stagi) - Software Engineer @ Atooma Inc. Job profile: http://linkedin.com/in/andreastagi Website: http://4spills.blogspot.it/ Github: http://github.com/astagi -- https://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Vancouver Python Day - Tickets On Sale Friday!
We're pleased to announce that tickets for Vancouver Python Day will be released on Friday, October 25 at 10AM. You can purchase tickets at http://vanpyday.eventbrite.com/ Space is extremely limited, so we advise buying your tickets as early as possible if you plan to attend. Thanks to our generous sponsors, tickets will be priced very affordably. We've also just released the list of scheduled talks. Visit http://www.vanpyday.com/ to view the list of speakers, and to learn more about the event. Finally, we're really happy to announce that A Thinking Ape, OpenRoad Communications, and Mobify have stepped up to sponsor this event. Vancouver Python Day would not be possible without their support. Hope to see you at the conference! -- https://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea.
On Monday, October 28, 2013 11:10:21 AM UTC+5:30, ru...@yahoo.com wrote: I updated the page, hopefully it's an improvement? Most people who top-post have no idea that they are top-posting and that there are alternatives and they are preferred (out here) http://en.wikipedia.org/wiki/Posting_style#Placement_of_replies should help Otherwise ok I think -- https://mail.python.org/mailman/listinfo/python-list
Re: Try-except for flow control in reading Sqlite
On Sun, 27 Oct 2013 20:43:07 -0700, Victor Hooi wrote: Hi, I'd like to double-check something regarding using try-except for controlling flow. I have a script that needs to lookup things in a SQLite database. If the SQLite database file doesn't exist, I'd like to create an empty database, and then setup the schema. Is it acceptable to use try-except in order to achieve this? E.g.: try: # Try to open up the SQLite file, and lookup the required entries except OSError: # Open an empty SQLite file, and create the schema Yes, that's the right way to do it. My thinking is that it is (easier to ask forgiveness than permission), but I just wanted to check if there is a better way of achieving this? I'd also be doing the same thing for checking if a file is gzipped or not - we try to open it as a gzip, then as an ordinary text file, and if that also fails, raise a parsing error. Correct. The problem with checking in advance is that there is a race condition between checking and the using the file: if database exists: # at this moment, the file is guaranteed to exist # but a moment later, guarantee is no longer valid open database In a multitasking operating system, some other process may have deleted the database. Or changed its name, removed your access privileges, even replaced it with a different file. Apart from hard-to-diagnose bugs, this is also the source of some security vulnerabilities: https://www.owasp.org/index.php/Race_Conditions Scroll down and read the section on Time of check, time of use race condition. So using a try...except block is precisely the right solution. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: Try-except for flow control in reading Sqlite
On Mon, Oct 28, 2013 at 2:43 PM, Victor Hooi victorh...@gmail.com wrote: Is it acceptable to use try-except in order to achieve this? E.g.: try: # Try to open up the SQLite file, and lookup the required entries except OSError: # Open an empty SQLite file, and create the schema My thinking is that it is (easier to ask forgiveness than permission), but I just wanted to check if there is a better way of achieving this? That looks fine as a model, but is OSError what you want to be catching? I'd go with FileNotFoundError if that's what you're looking for - OSError would also catch quite a bit else, like permissions errors. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: How to find where data files are installed for my Python program
On Mon, Oct 28, 2013 at 11:34 AM, Mark Lawrence breamore...@yahoo.co.uk wrote: What is the difference between script code (like Javascript and visual) made for the screen (where such magic values are utilized) and compiled source (made for the machine)? This obviously impacts on the discussion above, so how does Unix, Windows and other operating systems distinguish these with respect to binary, executable, code library or whatever? Suppose you pull up a shell - for argument's sake, let's say it's Debian GNU/Linux and you're running bash. You get a prompt that ends with a dollar sign, and you type ls. What's going to get executed? * An alias? You might have an internal function defined in your .bashrc, or maybe a wrapper that adds parameters to your command. * A bash internal command? The shell might directly interpret what you specified. (I don't think ls is like that, but time is, on my systems.) * An external binary? On my systems, /bin/ls is an executable binary, compiled and ready to run. * A script? Another alternative to the shell alias, you could have /usr/local/bin/ls that does something different, then maybe drops through to /bin/ls. If it starts with #!/usr/bin/python, it'll get dropped through to Python for execution. Chances are you wouldn't know the difference, as a human executing the commands. And you shouldn't need to care, except in really weird circumstances (maybe you broke your Python install and need to type /bin/ls to figure out what's going on). Most programs, trying to execute code, won't care about the difference between binaries and scripts, though of course exec*() won't parse bash aliases or internals. But if you need to distinguish for whatever reason, the easiest way is to look at the magic numbers, which can be done with the 'file' command: rosuav@sikorsky:~$ file `which ls` /bin/ls: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.26, BuildID[sha1]=0x55f1e005df252708d4c456dcc2c7dccea1006553, stripped rosuav@sikorsky:~$ file `which zcat` /bin/zcat: Bourne-Again shell script, ASCII text executable Executables happily together, regardless of type. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea.
On Monday, October 28, 2013 11:26:21 AM UTC+5:30, rusi wrote: On Monday, October 28, 2013 11:10:21 AM UTC+5:30, ru...@yahoo.com wrote: I updated the page, hopefully it's an improvement? Otherwise ok I think Just looked at the general netiquette link -- its long and not much use for a technical oriented forum. Some items missed (irrespective of GG usage) 1. Good subject line 2. Good code examples http://sscce.org/ 3. http://www.catb.org/esr/faqs/smart-questions.html -- https://mail.python.org/mailman/listinfo/python-list
Re: Try-except for flow control in reading Sqlite
Hi, We're on Python 2.6 (RHEL based system...) - I don't believe this exposes FileNotFoundError =(. Cheers, Victor On Monday, 28 October 2013 17:36:05 UTC+11, Chris Angelico wrote: On Mon, Oct 28, 2013 at 2:43 PM, Victor Hooi victorh...@gmail.com wrote: Is it acceptable to use try-except in order to achieve this? E.g.: try: # Try to open up the SQLite file, and lookup the required entries except OSError: # Open an empty SQLite file, and create the schema My thinking is that it is (easier to ask forgiveness than permission), but I just wanted to check if there is a better way of achieving this? That looks fine as a model, but is OSError what you want to be catching? I'd go with FileNotFoundError if that's what you're looking for - OSError would also catch quite a bit else, like permissions errors. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Try-except for flow control in reading Sqlite
On Mon, Oct 28, 2013 at 5:57 PM, Victor Hooi victorh...@gmail.com wrote: Hi, We're on Python 2.6 (RHEL based system...) - I don't believe this exposes FileNotFoundError =(. Ah! I forgot about 2.x, sorry for the nose. Yep, catching OSError would be the thing to do, then! ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Try-except for flow control in reading Sqlite
On Mon, Oct 28, 2013 at 6:01 PM, Chris Angelico ros...@gmail.com wrote: Ah! I forgot about 2.x, sorry for the nose. Yep, catching OSError would be the thing to do, then! A nose, apparently, is what happens when your typing stinks. I meant noise, of course. :) ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Try-except for flow control in reading Sqlite
On Mon, 28 Oct 2013 18:01:49 +1100, Chris Angelico wrote: On Mon, Oct 28, 2013 at 5:57 PM, Victor Hooi victorh...@gmail.com wrote: Hi, We're on Python 2.6 (RHEL based system...) - I don't believe this exposes FileNotFoundError =(. Ah! I forgot about 2.x, sorry for the nose. Yep, catching OSError would be the thing to do, then! I believe that in 2.x the error will be IOError, not OSError, at least for the built-in open() function. But in either case, you should still check the errno, and if it isn't the error number you expect, re-raise. try: ... except OSError as e: if e.errno == 2: # recover from file not found ... else: # any other error raise See the errno module for symbolic names for the various constants. http://docs.python.org/2/library/errno.html -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: Cookie fucking problem
On Sun, 27 Oct 2013 14:30:52 +0100, Antoon Pardon wrote: Op 26-10-13 23:43, Ben Finney schreef: Mark Lawrence breamore...@yahoo.co.uk writes: I could almost feel sorry for you. But the more of your time I waste the longer it'll take you to get your website working. Feel free to occupy your time with baiting Nikos. But *do not* do it in this forum. Would you mind telling this to others too. AFAICS Chris Angelico is just as much baiting Nikos, as Mark Lawrence is. Chris is not baiting Nikos, he is giving him useful information that unfortunately Nikos doesn't want to hear. There is a difference between the answer you want and the answer you need. But I don't see you reacting to Chris. So it seems you don't have a problem so much with baiting as long as the baiting is done in a way you find acceptable. Personnaly I don't see much difference between the two, so if you allow Chris baiting Nikos, I don't see why Mark should hold back. Here's an analogy: Person A: Clean my room for me! Person B: No. Clean it yourself. Here's the vacuum cleaner. Person A: CLEAN MY ROOM!!! Person B: No. You made the mess, you're old enough to clean it yourself. Person A: Clean my room for me! Person C: You're stupid and ugly and I hope you die! Do you see the difference yet? -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: Try-except for flow control in reading Sqlite
On 10/28/13 05:43, Victor Hooi wrote: Hi, I'd like to double-check something regarding using try-except for controlling flow. I have a script that needs to lookup things in a SQLite database. If the SQLite database file doesn't exist, I'd like to create an empty database, and then setup the schema. Is it acceptable to use try-except in order to achieve this? E.g.: try: # Try to open up the SQLite file, and lookup the required entries except OSError: # Open an empty SQLite file, and create the schema this doesn't protect against a partially-created schema. do you have something like a version table in your database as the last created table? you can check for its existence in the except block and if it's not there, you should remove the file and re-create it. to get a list of tables: select * from sqlite_master where type='table'; best, burak -- https://mail.python.org/mailman/listinfo/python-list
Re: Cookie fucking problem
Op 28-10-13 00:26, Ben Finney schreef: Antoon Pardon antoon.par...@rece.vub.ac.be writes: Op 26-10-13 23:43, Ben Finney schreef: Feel free to occupy your time with baiting Nikos. But *do not* do it in this forum. Would you mind telling this to others too. I'm not in any special position of power here; I'm not beholden to address every instance of bad behaviour or none at all. Fine. But if what people see, is that you address specific people instead of specific behaviour then don't expect your addressing to carry much weight. Any member of this community can apply the same social pressure, and together we can cover as many of them as we choose. Yes and can be as effective as as a cow cathing rabbits. I have no particular objection to you responding to those instances of bad behaviour that I've omitted. You are missing the point. I don't think it would be very effective if I would start critisising people I don't like and wouldn't address the same behaviour from people I am sympathic with. That would just turn this group in tribal factions. Personnaly I don't mind baiting but if I feel there grows some kind of consensus that baiting is considered off limits I'll reframe myself and may even help to enforce it. However when I see the addressing of baiting is limited to specific people, then all I see is an expression of personal dislike. -- Antoon Pardon. -- https://mail.python.org/mailman/listinfo/python-list
Re: Cookie fucking problem
Op 28-10-13 08:44, Steven D'Aprano schreef: On Sun, 27 Oct 2013 14:30:52 +0100, Antoon Pardon wrote: Op 26-10-13 23:43, Ben Finney schreef: Mark Lawrence breamore...@yahoo.co.uk writes: I could almost feel sorry for you. But the more of your time I waste the longer it'll take you to get your website working. Feel free to occupy your time with baiting Nikos. But *do not* do it in this forum. Would you mind telling this to others too. AFAICS Chris Angelico is just as much baiting Nikos, as Mark Lawrence is. Chris is not baiting Nikos, he is giving him useful information that unfortunately Nikos doesn't want to hear. There is a difference between the answer you want and the answer you need. Yes Chris is baiting. That he also provides contributions that are helpful, doesn't contradict other contributions are baiting. It is even possible for a helpful contribution to be baiting. If you know that a generally helpful contribution, will probably just invite Nikos to plead, insist, whine, ... that you solve the problem for him then you are baiting him just as well. But I don't see you reacting to Chris. So it seems you don't have a problem so much with baiting as long as the baiting is done in a way you find acceptable. Personnaly I don't see much difference between the two, so if you allow Chris baiting Nikos, I don't see why Mark should hold back. Here's an analogy: Person A: Clean my room for me! Person B: No. Clean it yourself. Here's the vacuum cleaner. Person A: CLEAN MY ROOM!!! Person B: No. You made the mess, you're old enough to clean it yourself. Person A: Clean my room for me! Person C: You're stupid and ugly and I hope you die! Do you see the difference yet? That difference is only important the first few times. If you already suggested the vacuum cleaner countless times and you know that suggesting the vacuum cleaner will result in a temper tantrum then after a while, you suggesting the vaccuum cleaner is just as much baiting. Sure it is more subtle and people who don't know the situation may not see it, but for those who know what is likely going to happen the difference is insignificant. We all know that whatever answer you give to Nikos, that if it doesn't completly solve his answer for him in a way he likes, he wil just return and demand more. So limiting your contribution to information that was already provided and which IHE didn't help, is baiting. So stop excusing this kind of behaviour under the guise that it is helpful. It isn't. -- Antoon Pardon -- https://mail.python.org/mailman/listinfo/python-list
Re: Python interactive segfaults on OS X 10.9 Mavericks
In article nad-13c89c.17244325102...@news.gmane.org, Ned Deily n...@acm.org wrote: SInce OS X 10.9 Mavericks is now out, people are running into a severe problem when using some Python interpreters interactively. The symptom is that the interpreter in interactive mode crashes after typing two lines: [...] The fix for the problem has been released in the current 3.4.0a4 installers. It will be available in the installers for Python 3.3.3 and 2.7.6, which are expected to be released in the near future. Release candidate installers for both should be available by Monday. http://bugs.python.org/issue18458 Otherwise, for the most part, the transition to OS X 10.9 appears to be relatively problem-free so far. Please open issues on the Python bug tracker for any new problems you encounter (after doing a quick search to see if it has already been reported!). Update: Release candidate installers for 3.3.3 and 2.7.6 are now available: http://www.python.org/download/releases/3.3.3/ http://www.python.org/download/releases/2.7.6/ In addition, a problem in the Tk 8.5 gui library that may affect users of IDLE or other tkinter-based applications running on OS X 10.9 has been fixed upstream. rc1_rev1 installers including the fixed Tk library should be available shortly. -- Ned Deily, n...@acm.org -- https://mail.python.org/mailman/listinfo/python-list
Re: Parsing multiple lines from text file using regex
On 28 October 2013 00:35, Marc m...@marcd.org wrote: What was wrong with the answer Peter Otten gave you earlier today on the tutor mailing list? -- Python is the second best programming language in the world. But the best has yet to be invented. Christian Tismer Mark Lawrence I did not receive any answers from the Tutor list, so I thought I'd ask here. If an answer was posted to the Tutor list, it never made it to my inbox. Thanks to all that responded. Hi Marc, did you actually subscribe to the tutor list or did you just send an email there? Peter replied to you and you can see the reply here: https://mail.python.org/pipermail/tutor/2013-October/098156.html He only sent the reply back to the tutor list and didn't email it directly to you because it is assumed that you would also be subscribed to the list. Oscar -- https://mail.python.org/mailman/listinfo/python-list
Re: Try-except for flow control in reading Sqlite
Op 28-10-13 07:18, Steven D'Aprano schreef: On Sun, 27 Oct 2013 20:43:07 -0700, Victor Hooi wrote: Hi, I'd like to double-check something regarding using try-except for controlling flow. I have a script that needs to lookup things in a SQLite database. If the SQLite database file doesn't exist, I'd like to create an empty database, and then setup the schema. Is it acceptable to use try-except in order to achieve this? E.g.: try: # Try to open up the SQLite file, and lookup the required entries except OSError: # Open an empty SQLite file, and create the schema Yes, that's the right way to do it. My thinking is that it is (easier to ask forgiveness than permission), but I just wanted to check if there is a better way of achieving this? I'd also be doing the same thing for checking if a file is gzipped or not - we try to open it as a gzip, then as an ordinary text file, and if that also fails, raise a parsing error. Correct. The problem with checking in advance is that there is a race condition between checking and the using the file: There is also a race condition here. You open the SQLite file and it fails. Then another process creates the SQLite file and stores things in it and then when you open the SQLite file as an empty file and create the schema, the previous work is lost. -- Antoon Pardon -- https://mail.python.org/mailman/listinfo/python-list
how to avoid checking the same condition repeatedly ?
Dear all, this is a recurring programming problem that I'm just not sure how to solve optimally, so I thought I'd ask for your advice: imagine you have a flag set somewhere earlier in your code, e.g., needs_processing = True then in a for loop you're processing the elements of an iterable, but the kind of processing depends on the flag, e.g.,: for elem in iterable: if needs_processing: pre_process(elem) # reformat elem in place print(elem) this checks the condition every time through the for loop, even though there is no chance for needs_processing to change inside the loop, which does not look very efficient. Of course, you could rewrite the above as: if needs_processing: for elem in iterable: pre_process(elem) # reformat elem in place print(elem) else: for elem in iterable: print(elem) but this means unnecessary code-duplication. You could also define functions (or class methods): def pre_process_and_print (item): pre_process(item) print(item) def raw_print (item): print(item) then: process = pre_process_and_print if needs_processing else raw_print for elem in iterable: process(elem) but while this works for the simple example here, it becomes complicated if pre_process requires more information to do its job because then you will have to start passing around (potentially lots of) arguments. So my question is: is there an agreed-upon generally best way of dealing with this? Thanks for your help, Wolfgang -- https://mail.python.org/mailman/listinfo/python-list
Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea.
Skybuck Flying wrote: Because it's logical. What is logical? If the exit condition was placed on the top, the loop would exit immediatly. This might be the programmer's intention? Instead the desired behaviour might be to execute the code inside the loop first and then exit. It might ... but it might be something very different, too. Let us assume a function with variable iteration count for its loop, where the count is passed as parameter. If the loop body always was executed completely before the final conditional test, we had to check at least the iteration count to avoid crashes if the iteration count is used as an array index, someone passed a negative number or zero. Moreover, we had to restore all data manipulated by instructions inside the loop body if we only wanted to alter data whenever the final condition was met. Thus seperating logic into enter and exit conditions makes sense. No. It introduces tons of -avoidable- extra cycles, but nothing of true value. If exit code always was placed at the bottom, and we have a loop with variable iterations passed as one of the function's input parameters, we had to reverse all manipulations applied within the loop, if the exit conditions were not met at the end of the first iteration. Moreover, every erroneously passed negative iteration count caused a crash if the passed count was used as an array index. Hence, we had to insert input parameter tests prior to the first execution of the loop, adding more misprediction penalties. To get a picture: Each misprediction penalty costs an absolute minimum of ~ 20 clock cycles on recent machines. It surely is not zher best idea to add a lot of mispredictions with the (questionable) intention to force other programmers to obey your universal Condition checks belong to the bottom! law. As assembler programmers, we can write the fastest possible code without being bound to counter-productive rules. Compiler developers who declare conventions just to force programmer to use delay mechanisms like condition checks belong to the bottom! are a dangerous species. With compilers like that, it is quite obvious why software became slower and slower while processor power is growing from one hardware generation to the next. BTW: I placed label 0 at the wrong place. The proper loop should look like this: func:... ... 0:dec rcx jbe 1f ... some code to perform ... jmp 0b p2align 5,,31 1:continue with something else ... Greetings from Augsburg Bernhard Schornak -- https://mail.python.org/mailman/listinfo/python-list
Re: Cookie fucking problem
Op 26-10-13 23:22, Mark Lawrence schreef: On 26/10/2013 18:23, Antoon Pardon wrote: Op 26-10-13 18:19, Mark Lawrence schreef: On 26/10/2013 17:00, Steven D'Aprano wrote: On Sat, 26 Oct 2013 15:34:23 +0100, Mark Lawrence wrote: On 26/10/2013 14:27, Nick the Gr33k wrote: Buy a sex manual. Mark, please resist the urge to bait Nick with insults. As entertaining as they may be, they don't actually help reduce the problem. I promise to stop baiting this complete and utter moron when I observe that nobody on this group says a single word to him as that's the only message that he'll understand. Any word to him from anybody and I reserve the right to join in. I fear this strategy is not stable. Just suppose most people follow this strategy but someone reacts to Nikos anyhow. Now suddenly a lot of people feel they have the right to join in. And of course these reactions will feed this feeling. I understand you feel you don't have to keep silent if others aren't but I wish your trigger would be less sensitive. I wish I didn't have a combination of Asperger Syndrome, Chronic Fatigue Syndrome and Clinical Depression but sadly I'm stuck with the lot :( I can't help you with your wish. You can help with mine. Do you think I am unreasonable in what I wish for? Regardless of what others (rusi?) said earlier I'll keep my sense of humour going, it least that helps me to survive :) Sure, the question is how you are going to use it. If we all follow your strategy, sense of humour or not, the net result will be a lot of people feeling righteous about their contributions to the list all expecting the others to curb their behaviour first and resulting in a big mess. Sure you can say your piece when you notice there is still a substantial respons to Nikos and that you don't feel the need to keep quiet as long as that is going on. But if you think that a single word from anyone to Nikos is enough to make you feel righteous about responding, then your behaviour becomes part of the problem. -- Antoon Pardon -- https://mail.python.org/mailman/listinfo/python-list
Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea.
Due to unknown improvements, SeaMonkey's built-in news editor meanwhile ignores saved changes and sends long deleted text parts rather than thwe last seen text - What you See Is _Not_ What You Get... This is the real reply to Skybuck's posting. Please ignore the mixture of deleted text parts, older and newer text posted at 10:58 h. Unfortunately, the option to remove messages from the server became the victim of another improvement, so it is impossible for me to delete the other post. Bernhard Schornak Skybuck Flying wrote: Because it's logical. What is logical? If the exit condition was placed on the top, the loop would exit immediatly. This might be the programmer's intention? Instead the desired behaviour might be to execute the code inside the loop first and then exit. With a 50 percent chance it might not. Are we fortune tellers who guess which one might be true? Thus seperating logic into enter and exit conditions makes sense. Let us assume a loop with variable iterations where the iteration count is passed as function parameter. The code inside the loop body uses this iteration count as index into an array and alters data in other arrays depending on computations and set flags. If we probed the loop's repeat condition at the end of the loop body per default, we had to verify the passed iteration count before we enter the loop - otherwise, the program crashed with erroneously passed negative numbers. We also had to sort out zero. Otherwise, we started a count down through the full 32 or 64 bit range. The last problem pops up, if the loop's repeat condition isn't met. In this case, we had to restore all altered data before we could continue with the instructions following the loop body. Programming on machine language level grants us the freedom to create the fastest possible code. It is no good idea to slow down our code just to obey questionable Universal Laws. BTW: I placed label 0 at the wrong place. The proper loop should look like this: func:... ... 0:dec rcx jbe 1f ... some code to perform ... jmp 0b p2align 5,,31 1:continue with something else ... Greetings from Augsburg Bernhard Schornak -- https://mail.python.org/mailman/listinfo/python-list
Re: how to avoid checking the same condition repeatedly ?
On Mon, 28 Oct 2013 09:50:19 +, Wolfgang Maier wrote: Dear all, this is a recurring programming problem that I'm just not sure how to solve optimally, so I thought I'd ask for your advice: imagine you have a flag set somewhere earlier in your code, e.g., needs_processing = True then in a for loop you're processing the elements of an iterable, but the kind of processing depends on the flag, e.g.,: for elem in iterable: if needs_processing: pre_process(elem) # reformat elem in place print(elem) this checks the condition every time through the for loop, even though there is no chance for needs_processing to change inside the loop, which does not look very efficient. If there is absolutely no chance the flag could change, then the best way is to test the flag once: if needs_processing: for elem in iterable: pre_process(elem) # reformat elem in place print(elem) else: for elem in iterable: print(elem) The amount of duplication here is trivial. Sometimes you can avoid even that: if needs_preprocessing: preprocess(sequence) process(sequence) This is especially useful if you can set up a pipeline of generators: if flag1: data = (preprocess(item) for item in data) if flag2: data = (process(item) for item in data) if flag3: data = (postprocess(item) for item in data) for item in data: print(item) Another option is to use a factory-function: def factory(flag): def process(item): do_this(item) do_that(item) do_something_else(item) print(item) if flag: def func(item): preprocess(item) process(item) return func else: return process func = factory(needs_preprocessing) for elem in iterable: func(elem) So my question is: is there an agreed-upon generally best way of dealing with this? No. It's mostly a matter of taste. Those coming from a Java background will probably prefer the factory or builder idiom. Those coming from a functional language background, like Haskell or Lisp, or with experience with Unix pipes, will probably prefer using chained generators. The only solution you absolutely should avoid is the naive copy and paste solution, where the amount of code duplication is extensive: if needs_preprocessing: for elem in iterable: # If you change this block, you must remember to change the # block below too! preprocess(item) do_this(item) do_that(item) do_something_else(item, arg1, arg2, expression) do_another_thing(item + arg3, key=whatever) print(item) else: for elem in iterable: # If you change this block, you must remember to change the # block above too! preprocess(item) do_this(item) do_that(item) do_something_else(item, arg1, arg2, expression) do_another_thing(item, key=whatever) print(item) The careful reader will notice that there's already a bug in this. Even checking the variable inside the loop is okay, provided you don't care too much about performance, although I wouldn't call it best practice. Merely acceptable for code that isn't performance-critical. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: how to avoid checking the same condition repeatedly ?
On Mon, Oct 28, 2013 at 10:14 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: if needs_preprocessing: for elem in iterable: # If you change this block, you must remember to change the # block below too! preprocess(item) do_this(item) do_that(item) do_something_else(item, arg1, arg2, expression) do_another_thing(item + arg3, key=whatever) print(item) else: for elem in iterable: # If you change this block, you must remember to change the # block above too! preprocess(item) do_this(item) do_that(item) do_something_else(item, arg1, arg2, expression) do_another_thing(item, key=whatever) print(item) The careful reader will notice that there's already a bug in this. For a start, you're preprocessing in the second block... I don't think that was your intentional bug :) ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Python3 doc, operator reflection
Hi group, in http://docs.python.org/3/reference/datamodel.html#customization the doc reads: There are no swapped-argument versions of these methods (to be used when the left argument does not support the operation but the right argument does); rather, __lt__() and __gt__() are each other’s reflection, __le__() and __ge__() are each other’s reflection, and __eq__() and __ne__() are their own reflection. But shouldn't __lt__ be the reflection or __ge__ and __gt__ the reflection of __le__? Best regards, Johannes -- https://mail.python.org/mailman/listinfo/python-list
Re: Python3 doc, operator reflection
On Mon, Oct 28, 2013 at 11:00 PM, Johannes Bauer dfnsonfsdu...@gmx.de wrote: There are no swapped-argument versions of these methods (to be used when the left argument does not support the operation but the right argument does); rather, __lt__() and __gt__() are each other’s reflection, __le__() and __ge__() are each other’s reflection, and __eq__() and __ne__() are their own reflection. But shouldn't __lt__ be the reflection or __ge__ and __gt__ the reflection of __le__? lt is the negation of ge, but it's the reflection of gt. Consider this: 1 2 2 1 If Python can't ask 1 if it's less than 2, it'll ask 2 if it's greater than 1. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Animated PNG Vs Gif: 120fr 3D Python Powered Logo
On Tuesday, October 22, 2013 4:15:05 PM UTC-5, Ian wrote: I used a freeware called Photoscape to open the gif, change the delays, and resave it. Thanks, I have used the program before and recall some aspects of it, but as far as gif goes I try to not deal with them much because of the headaches involved with making them. So Animation technology has advanced in general(Blender, ImageReady, GIMP), so it seems a slightly offbrand from the standards app shines though for once, for a such a thing as an outdated format. gif. Cheers. As a graphic artist myself, some free softwares you might like to try. Most are all still active. * Pixel Image Editor * TwistedBrush Open Studio * Deep Paint * MyPaint * Artweaver * AndreaMosaic * Sumo Paint Pro (Adobe Online) Anywho... Here is the official art link for the Animated Python Logo APNG. http://fav.me/d6rdza2 I'll whip up a pack of gifs when I get the time... here in a few... todo. -- https://mail.python.org/mailman/listinfo/python-list
Re: Python3 doc, operator reflection
Am 28.10.2013 13:23, schrieb Chris Angelico: On Mon, Oct 28, 2013 at 11:00 PM, Johannes Bauer dfnsonfsdu...@gmx.de wrote: There are no swapped-argument versions of these methods (to be used when the left argument does not support the operation but the right argument does); rather, __lt__() and __gt__() are each other’s reflection, __le__() and __ge__() are each other’s reflection, and __eq__() and __ne__() are their own reflection. But shouldn't __lt__ be the reflection or __ge__ and __gt__ the reflection of __le__? lt is the negation of ge, but it's the reflection of gt. Consider this: 1 2 2 1 If Python can't ask 1 if it's less than 2, it'll ask 2 if it's greater than 1. Ah, I see. Thanks for clearing that up! Best regards, Joe -- https://mail.python.org/mailman/listinfo/python-list
Re: Debugging decorator
On 10/26/2013 01:55 AM, Yaşar Arabacı wrote: Hi people, I wrote this decorator: https://gist.github.com/yasar11732/7163528 When this code executes: @debugging def myfunc(a, b, c, d = 48): a = 129 return a + b print myfunc(12,15,17) This is printed: function myfunc called a 12 c 17 b 15 d 48 assigned new value to a: 129 returning 144 144 I think I can be used instead of inserting and deleting print statements when trying to see what is passed to a function and what is assingned to what etc. I think it can be helpful during debugging. It works by rewriting ast of the function and inserting print nodes in it. What do you think? Looks very nice, but I've three questions: 1. What happens, if a function has more then one decorator? Wouldn't it be better to just remove the debugging decorator instead of removing all decorators? 2. In the case of an assignment (but holds for the return statement too). think about the following code: a = 0 @debugging def foo(): a = a + 1 def bar(): #assign something else to a Imagine foo() and bar() being called in two different threads. Wouldn't it be better to replace a = a + 1 by |global_debugging_lock_objekt.acquire()| a = a + 1 print assigned new value to a, %r, a |global_debugging_lock_objekt.release()| for some global lock object. 3. What happens in the case of a += 1? bg, Johannes -- GLOBE Development GmbH Königsberger Strasse 260 48157 MünsterGLOBE Development GmbH Königsberger Strasse 260 48157 Münster 0251/5205 390 -- https://mail.python.org/mailman/listinfo/python-list
Re: How to find where data files are installed for my Python program
In article mailman.1678.1382943105.18130.python-l...@python.org, Chris Angelico ros...@gmail.com wrote: If it starts with #!/usr/bin/python, it'll get dropped through to Python for execution. Even better (for most purposes), use #!/usr/bin/env python. What that does is (slight handwave here) search your PATH to find the same version of Python you would get if you typed python at a shell prompt. If you've only got a single version of python installed, it doesn't matter. But it'll matter a lot if you have multiple versions (or even multiple installations of the same version, but with different sets of installed modules). -- https://mail.python.org/mailman/listinfo/python-list
Re: Debugging decorator
On Mon, Oct 28, 2013 at 11:43 PM, Schneider j...@globe.de wrote: 2. In the case of an assignment (but holds for the return statement too). think about the following code: a = 0 @debugging def foo(): a = a + 1 def bar(): #assign something else to a Imagine foo() and bar() being called in two different threads. I think threading considerations are rather outside the scope of this tool. If you're trying to figure out what happens when two threads mutate the same global, you really want something a lot more heavy-duty... possibly static code analysis to work out what *might* happen, rather than what *did* happen this particular run. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: How to find where data files are installed for my Python program
On Mon, Oct 28, 2013 at 11:51 PM, Roy Smith r...@panix.com wrote: In article mailman.1678.1382943105.18130.python-l...@python.org, Chris Angelico ros...@gmail.com wrote: If it starts with #!/usr/bin/python, it'll get dropped through to Python for execution. Even better (for most purposes), use #!/usr/bin/env python. What that does is (slight handwave here) search your PATH to find the same version of Python you would get if you typed python at a shell prompt. Yeah, I'm aware of that... but I dodged a bit of complexity by hard-coding the path :) The shebang you quote drops it through to env, which waves its hands vigorously and says Abracadabra, before dropping it through to the Python that you forgot you ran 'make install' instead of 'make altinstall' on. :) ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Organising packages/modules - importing functions from a common.py in a separate directory?
- Original Message - Hi, I have a collection of Python scripts I'm using to load various bits of data into a database. I'd like to move some of the common functions (e.g. to setup loggers, reading in configuration etc.) into a common file, and import them from there. I've created empty __init__.py files, and my current directory structure looks something like this: foo_loading/ __init__.py common/ common_foo.py em_load/ __init__.py config.yaml sync_em.py pg_load/ __init__.py config.yaml sync_pg.py So from within the sync_em.py script, I'm trying to import a function from foo_loading/common/common_foo.py. from ..common.common_foo import setup_foo_logging I get the error: ValueError: Attempted relative import in non-package If I change directories to the parent of foo_loading, then run python -m foo_loading.em_load.sync_em sync_em.py it works. However, this seems a bit roundabout, and I suspect I'm not doing things correctly. Ideally, I want a user to be able to just run sync_em.py from it's own directory, and have it correctly import the logging/config modules from common_foo.py, and just work. What is the correct way to achieve this? Secondly, if I want to move all of the config.yaml files to a common foo_loading/config.yaml, or even foo_loading/config/config.yaml, what is the correct way to access this from within the scripts? Should I just be using ../, or is there a better way? Cheers, Victor Long story short : use absolute imports. name properly your module with a distinct name and import that way, even inside your package: import foo_loading.common.common_foo Names like common, lib, setup are farely prone to collision with other badly referenced import from other modules. One way to solve this is to use a distinct namespace, in other words, prefix every import with the module name. cheers, JM -- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you. -- https://mail.python.org/mailman/listinfo/python-list
Re: Cookie fucking problem
On 2013-10-27, Ben Finney ben+pyt...@benfinney.id.au wrote: I have no particular objection to you responding to those instances of bad behaviour that I've omitted. So you omitted them, eh? You just omitted the body of the letter, that's all! You've left out the body of the letter, that's all. Yours is not to reason why, Jamison. You've left out the body of the letter! ... Fine. Send it that way, and tell them the body will follow. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list
Re: Tkinter tutorial?
Lundh, Fredrik. (2005). An Introduction to Tkinter, Draft revision. Retrieved from http://effbot.org/tkinterbook/ Shipman, John. (2013) Tkinter 8.5 reference. Retrieved from http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/index.html Lutz, Mark. (2011) Programming Python, 4th ed. Chapters 7-11 are on Tkinter. Grayson, John (2000). Python and Tkinter Programming. Ferg, Steve. (2011). Thinking in Tkinter. Retrieved from http://thinkingtkinter.sourceforge.net/ which I only recently discovered (indeed, he pointed me this morning to this Google group for a non-tkinter question). Owen, Russell. (2006) Tkinter Summary. Retrieved from http://www.astro.washington.edu/users/rowen/TkinterSummary.html I have both Grayson and Lutz books but find that 90% of the time I get what I need from Lundh or Shipman and the other 10% are covered by online knowledge base or Lutz. Ferg and Owen might be great too, I only discovered them yesterday. Indeed, Steve Ferg is the one who pointed me to this Google group for a non-Tkinter question. Bennett Brown Director of Curriculum and Instruction Project Lead for CSE, a new CS course from Project Lead The Way, piloting now in 60 schools. -- https://mail.python.org/mailman/listinfo/python-list
Re: trying to strip out non ascii.. or rather convert non ascii
Le dimanche 27 octobre 2013 04:21:46 UTC+1, Nobody a écrit : Simply ignoring diactrics won't get you very far. Right. As an example, these four French words : cote, côte, coté, côté . Most languages which use diactrics have standard conversions, e.g. ö - oe, which are likely to be used by anyone familiar with the language e.g. when using software (or a keyboard) which can't handle diactrics. I'm quite confortable with Unicode, esp. with the Latin blocks. Except this German case (I remember very old typewriters), what are the other languages presenting this kind of allowed feature ? Just as a reminder. They are 1272 characters considered as Latin characters (how to count them it not a simple task), and if my knowledge is correct, they are covering and/or are here to cover the 17 languages, to be exact, the 17 European languages based on a Latin alphabet which can not be covered with iso-8859-1. And of course, logically, they are very, very badly handled with the Flexible String Representation. jmf -- https://mail.python.org/mailman/listinfo/python-list
Re: trying to strip out non ascii.. or rather convert non ascii
On 28/10/2013 14:01, wxjmfa...@gmail.com wrote: Just as a reminder. They are 1272 characters considered as Latin characters (how to count them it not a simple task), and if my knowledge is correct, they are covering and/or are here to cover the 17 languages, to be exact, the 17 European languages based on a Latin alphabet which can not be covered with iso-8859-1. And of course, logically, they are very, very badly handled with the Flexible String Representation. jmf Please provide us with evidence to back up your statement. -- Python is the second best programming language in the world. But the best has yet to be invented. Christian Tismer Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: trying to strip out non ascii.. or rather convert non ascii
On 2013-10-28 07:01, wxjmfa...@gmail.com wrote: Simply ignoring diactrics won't get you very far. Right. As an example, these four French words : cote, côte, coté, côté . Distinct words with distinct meanings, sure. But when a naïve (naive? ☺) person or one without the easy ability to enter characters with diacritics searches for cote, I want to return possible matches containing any of your 4 examples. It's slightly fuzzier if they search for coté, in which case they may mean coté or they might mean be unable to figure out how to add a hat and want to type côté. Though I'd rather get more results, even if it has some that only match fuzzily. Circumflexually-circumspectly-yers, -tkc -- https://mail.python.org/mailman/listinfo/python-list
Re: Don't use default Google Group client (was re:....)
On 2013-10-26, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Fri, 25 Oct 2013 16:44:45 -0700, rurpy wrote: On 10/25/2013 02:05 PM, Terry Reedy wrote: On 10/25/2013 2:57 PM, Peter Cacioppi wrote: The default Google Group client is notoriously cruddy with quotes attribution. So don't use it. Get any decent newsreader, such as Thunderbird, and access the list at news.gmane.org as gmane.comp.python.general. Peter, you can ignore Terry's advice if Google Groups works for you. There are a small number of Google haters here who seem larger due to their obnoxious noisiness. There are people here who hate Google Groups but simply don't chime in. I'm one of them. Perhaps I should. More that a few of us just filter out all posts made from Google Groups. -- Grant Edwards grant.b.edwardsYow! I'm having a MID-WEEK at CRISIS! gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Python Front-end to GCC
On 2013-10-26, Mark Lawrence breamore...@yahoo.co.uk wrote: On 26/10/2013 22:25, Mark Janssen wrote: Please give it a rest Mark, nobody is falling for your pseudo babel. I think you do him a disservice. I'm pretty sure it's genuine, bona-fide, 24K, dyed-in-the-wool, 99 and 44/100 pure babble. -- Grant Edwards grant.b.edwardsYow! I have many CHARTS at and DIAGRAMS.. gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Python Front-end to GCC
On Tue, Oct 29, 2013 at 1:21 AM, Grant Edwards invalid@invalid.invalid wrote: On 2013-10-26, Mark Lawrence breamore...@yahoo.co.uk wrote: On 26/10/2013 22:25, Mark Janssen wrote: Please give it a rest Mark, nobody is falling for your pseudo babel. I think you do him a disservice. I'm pretty sure it's genuine, bona-fide, 24K, dyed-in-the-wool, 99 and 44/100 pure babble. I think it's even better than that... maybe even 28.8K! ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Cookie fucking problem
On 2013-10-28, Steven D'Aprano st...@pearwood.info wrote: Chris is not baiting Nikos, he is giving him useful information that unfortunately Nikos doesn't want to hear. So he's replying to Nikos with responses that aren't helping Nikos and just encourage more posts from Nikos. I'm sure the _intent_ is different than Mark's, but unfortunately, the result is identical. -- Grant Edwards grant.b.edwardsYow! I guess you guys got at BIG MUSCLES from doing too gmail.commuch STUDYING! -- https://mail.python.org/mailman/listinfo/python-list
Re: Cookie fucking problem
On Tue, Oct 29, 2013 at 1:33 AM, Grant Edwards invalid@invalid.invalid wrote: On 2013-10-28, Steven D'Aprano st...@pearwood.info wrote: Chris is not baiting Nikos, he is giving him useful information that unfortunately Nikos doesn't want to hear. So he's replying to Nikos with responses that aren't helping Nikos and just encourage more posts from Nikos. I'm sure the _intent_ is different than Mark's, but unfortunately, the result is identical. I still maintain that I'm not *baiting* him, though. Maybe it would be better overall if I never even try to help him, but sometimes I just get all paladiny... it feels wrong to *not* answer. And yeah, I know pallies are fairly often doing the wrong thing just to be Lawful Good. The weird bit is, I generally consider myself to be Chaotic Good... or Chaotic Neutral even. I'm not a paladin at all! ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Cookie fucking problem
On 2013-10-26, Antoon Pardon antoon.par...@rece.vub.ac.be wrote: Op 26-10-13 18:00, Steven D'Aprano schreef: On Sat, 26 Oct 2013 15:34:23 +0100, Mark Lawrence wrote: On 26/10/2013 14:27, Nick the Gr33k wrote: Buy a sex manual. Mark, please resist the urge to bait Nick with insults. As entertaining as they may be, they don't actually help reduce the problem. So? I haven't seen any reaction to Nikos reducing the problem. So if that is your criterium, you should stop reacting yourself and ask everyone else to stop reacting. I think that's hit the nail on the head. Any reponse to Nikos produces the _exact_ same result: Nikos's web site is still broken, Nikos still has no clue what's going on or what to do, and we get more posts from Nikos. None of the responses are helping Nikos, none of them are solving problems. Some of them are more entertaining that others, but that's highly subjective. -- Grant Edwards grant.b.edwardsYow! I'm not an Iranian!! at I voted for Dianne gmail.comFeinstein!! -- https://mail.python.org/mailman/listinfo/python-list
Re: Function for the path of the script?
On 2013-10-27, Chris Angelico ros...@gmail.com wrote: On Sun, Oct 27, 2013 at 1:52 PM, Gary Herron gary.her...@islandtraining.com wrote: Huh? In what kind of a workflow are you running a python file without knowing *what* file you are runnung? I've been writing Python programs for 10+ years. Never have I felt a need to know the location of the file that's running. I do sometimes want to know the _name_ of the file (for multipurpose programs), but I don't ever remember caring where that file was. It's very common to want to know what directory you're in - it's a good way to find data files. From a Unix point of view, that's also very wrong. Data files don't belong in the same directory as the executable. -- Grant Edwards grant.b.edwardsYow! Is this an out-take at from the BRADY BUNCH? gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Function for the path of the script?
On Tue, Oct 29, 2013 at 1:49 AM, Grant Edwards invalid@invalid.invalid wrote: On 2013-10-27, Chris Angelico ros...@gmail.com wrote: It's very common to want to know what directory you're in - it's a good way to find data files. From a Unix point of view, that's also very wrong. Data files don't belong in the same directory as the executable. For installed programs, maybe; but we run a lot of scripts out of source control, like a sanity checker that gets run immediately before a commit. Some of them need data files that are also source-managed, so we have them in the same directory. Locating those files is usually easiest done by tailing onto the script's path. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Function for the path of the script?
On 2013-10-27, Ben Finney ben+pyt...@benfinney.id.au wrote: What workflow requires you to know the filename of the module, within the module? If you have a utility that can be used to do several related things, one way to tell that utility which you want to do is with command line arguments. For example your utility checks sys.argv[1] for a command or option flag. Another way is to give the file multiple names, and check sys.argv[0] to see what name you've been invoked under. The latter approach not unusual in the Unix world, and has been carried to a rather astounding extent by the busybox project: http://www.busybox.net/about.html It's all the command-line utilities you need for a small Unix system in a single binary: one executable with dozens and dozens of links (hard or symbolic). -- Grant Edwards grant.b.edwardsYow! I request a weekend in at Havana with Phil Silvers! gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Python Front-end to GCC
On 2013-10-28, Chris Angelico ros...@gmail.com wrote: On Tue, Oct 29, 2013 at 1:21 AM, Grant Edwards invalid@invalid.invalid wrote: On 2013-10-26, Mark Lawrence breamore...@yahoo.co.uk wrote: On 26/10/2013 22:25, Mark Janssen wrote: Please give it a rest Mark, nobody is falling for your pseudo babel. I think you do him a disservice. I'm pretty sure it's genuine, bona-fide, 24K, dyed-in-the-wool, 99 and 44/100 pure babble. I think it's even better than that... maybe even 28.8K! From my own bailiwick I'd say it's Grade A Medium Amber. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list
Re: Cookie fucking problem
Op 28-10-13 15:38, Chris Angelico schreef: On Tue, Oct 29, 2013 at 1:33 AM, Grant Edwards invalid@invalid.invalid wrote: On 2013-10-28, Steven D'Aprano st...@pearwood.info wrote: Chris is not baiting Nikos, he is giving him useful information that unfortunately Nikos doesn't want to hear. So he's replying to Nikos with responses that aren't helping Nikos and just encourage more posts from Nikos. I'm sure the _intent_ is different than Mark's, but unfortunately, the result is identical. I still maintain that I'm not *baiting* him, though. I don't care. Maybe you can find some semantical rule, that will give your behaviour an other etiket than baiting, in the end the effect on the list is the same, with Nikos feeling entitled to insist to get an answer. And if we want this to be a welcoming community, then we have to care about the effects and not about the semantical category. So should you want this to be a welcoming community, then you are focussing on the wrong point. Maybe it would be better overall if I never even try to help him, but sometimes I just get all paladiny... it feels wrong to *not* answer. What do you mean it feels wrong not to answer? Do you participate in every subject? Do you engage at least everybody? Do you answer every question that went unanswered? As far as I can see the answer is no to each of these questions, so how come it feels wrong to not answer Nikos? -- Antoon Pardon -- https://mail.python.org/mailman/listinfo/python-list
Re: Cookie fucking problem
On Monday, October 28, 2013 1:14:50 PM UTC+5:30, Steven D'Aprano wrote: Here's an analogy: Person A: Clean my room for me! Person B: No. Clean it yourself. Here's the vacuum cleaner. Person A: CLEAN MY ROOM!!! Person B: No. You made the mess, you're old enough to clean it yourself. Person A: Clean my room for me! Person C: You're stupid and ugly and I hope you die! Do you see the difference yet? Since we are exchanging analogies (analogy to exchanging anecdotes?) here's mine. Mommy: Johnny your room needs to be cleaned up Johnny: Yes Mom (A few days later) Mommy: Johnny your room's a real mess. Are you going to clean it? Johnny: Yes Mom. Mommy: When are you going to? Johnny: Uh uh… Tomorrow (Many tomorrow's more and Mommy-doing-basic-survival cleaning later…) Mommy: Johny today's a Sunday. I expect your room thoroughly cleaned today! Johnny: Uh uh… (10 am as Johnny is going out with 'friends'…) Mommy: I expect your room clean before you go out today! Johnny: I'll be back in just 15 minutes. Only 15 minutes. Please Mom! Mommy: Johnny if your room is not cleaned today, there will be no lunch Johnny: Uh uh Mommy: You heard me right? No lunch if your room is a mess. Johnny: Ok (15 minutes stretches to 4 hours) Johnny: Mom! I am hungry! Mommy: Remember? No food until your room is cleaned up. Johnny: MOM! Im HUNGRY! I'll do it after lunch! Mommy: There's no food -- neither for you nor me -- until your room's done. Johnny: (begins to scream bawl throw an tantrum) Mommy: (screams back) Neighbours are disturbed (Its Sunday afternoon!) They force their way in. Immediately Johnny's tune changes -- all weak and tearful. Johnny: Ive had no food… for days… Neighbours: Whoa?! Whats happening? Johnny: Mommy's VERY angry with me. And I dont even know why (sob)! (Too bewildered to protest or retort… Mom soon finds herself marched off to the police station for child-abuse) -- https://mail.python.org/mailman/listinfo/python-list
Re: Cookie fucking problem
On 10/28/13 11:07 AM, Antoon Pardon wrote: Op 28-10-13 15:38, Chris Angelico schreef: On Tue, Oct 29, 2013 at 1:33 AM, Grant Edwardsinvalid@invalid.invalid wrote: On 2013-10-28, Steven D'Apranost...@pearwood.info wrote: Chris is not baiting Nikos, he is giving him useful information that unfortunately Nikos doesn't want to hear. So he's replying to Nikos with responses that aren't helping Nikos and just encourage more posts from Nikos. I'm sure the_intent_ is different than Mark's, but unfortunately, the result is identical. I still maintain that I'm not*baiting* him, though. I don't care. Maybe you can find some semantical rule, that will give your behaviour an other etiket than baiting, in the end the effect on the list is the same, with Nikos feeling entitled to insist to get an answer. And if we want this to be a welcoming community, then we have to care about the effects and not about the semantical category. So should you want this to be a welcoming community, then you are focussing on the wrong point. I agree it is probably best to err on the side of ignoring Nikos. But there is a distinction between (say) Chris' response and Mark's. The effect on Nikos is the same, but the effect on other readers, especially readers new to the list, is very different. We've already seen a few new people explicitly asking, is this what usually happens on this list? and they weren't referring to the Chris-style response, they were referring to the Mark-style response. If we want this to be a welcoming community, we have to understand that there are many more readers than there are authors, and the impression we make on them matters too. Responding negatively, no matter how humorously, is not going to improve the group. It might amuse the regulars, but it is not building a strong and welcoming community. I also happen to think that responding negatively won't even achieve its stated purpose of making the help-vampire go away. --Ned. -- https://mail.python.org/mailman/listinfo/python-list
RE: Parsing multiple lines from text file using regex
Hi Marc, did you actually subscribe to the tutor list or did you just send an email there? Peter replied to you and you can see the reply here: https://mail.python.org/pipermail/tutor/2013-October/098156.html He only sent the reply back to the tutor list and didn't email it directly to you because it is assumed that you would also be subscribed to the list. Oscar Thanks Oscar - yes, I am subscribed to both lists - the python-list through this email address and the tutor list through my work email. I think my work spam filter may be the issue - I will subscribe to the tutor list through this email and unsubscribe from my work email. Thanks again, Marc -- https://mail.python.org/mailman/listinfo/python-list
RE: Parsing multiple lines from text file using regex
Hi Marc, did you actually subscribe to the tutor list or did you just send an email there? Peter replied to you and you can see the reply here: https://mail.python.org/pipermail/tutor/2013-October/098156.html He only sent the reply back to the tutor list and didn't email it directly to you because it is assumed that you would also be subscribed to the list. Oscar I again Oscar - apparently I am already subscribed to the Tutor list with this email also: 'An attempt was made to subscribe your address to the mailing list tu...@python.org. You are already subscribed to this mailing list.' I control the spam filter for this domain, so I am not sure why I am not getting the updates. Marc -- https://mail.python.org/mailman/listinfo/python-list
Re: Python on a MacBook Pro (not my machine)
In article 0799708c-59d5-41c2-9fcc-24b7ca873...@googlegroups.com, John Ladasky john_lada...@sbcglobal.net wrote: So, what other free and lightweight editing options do I have for a Mac? I have found a few (fairly old) discussions on comp.lang.python which suggest Eric (http://eric-ide.python-projects.org/) and Editra (http://editra.org/). Opinions on these and other choices are appreciated. I use BBEdit (paid) and MacVim (free) for Mac editing. Bare Bones Software has a free version of BBEdit called TextWrangler that a lot of people use. http://www.barebones.com/products/bbedit/ http://www.barebones.com/products/textwrangler/ http://code.google.com/p/macvim/ -- Jim Gibson -- https://mail.python.org/mailman/listinfo/python-list
Re: Cookie fucking problem
On Monday, October 28, 2013 10:38:45 PM UTC+5:30, Ned Batchelder wrote: We've already seen a few new people explicitly asking, is this what usually happens on this list? and they weren't referring to the Chris-style response, they were referring to the Mark-style response. Here's the post of Vladimir Bugaj earlier in this same thread: I rarely ever post here. But I wanted to say that people responding to this Nikos troll makes reading this list a nuisance. You've never ever been successful in convincing him to behave, and it's been going on for quite a while now. I remain subscribed for occasional interesting new idioms and tips, but always have to sift through this nonsense. And all of you who take the bait are as much a part of the problem as the troll. Just ignore the guy. - How do you read this that he minds the 'Mark-style' post more than the 'Chris-style' post? -- https://mail.python.org/mailman/listinfo/python-list
Re: Python on a MacBook Pro (not my machine)
On Sunday, October 27, 2013 12:37:40 AM UTC+5:30, John Ladasky wrote: So, what other free and lightweight editing options do I have for a Mac? I have found a few (fairly old) discussions on comp.lang.python which suggest Eric (http://eric-ide.python-projects.org/) and Editra (http://editra.org/). Opinions on these and other choices are appreciated. Have you considered emacs? Yeah it requires some setup to run for python. But then its a lifetime investment. [About mac Ive no idea. As far as I know some of the current hot emacs projects are being developed by people on macs -- so it surely runs but how smoothly I wont venture] -- https://mail.python.org/mailman/listinfo/python-list
Re: Cookie fucking problem
On 10/28/13 1:53 PM, rusi wrote: On Monday, October 28, 2013 10:38:45 PM UTC+5:30, Ned Batchelder wrote: We've already seen a few new people explicitly asking, is this what usually happens on this list? and they weren't referring to the Chris-style response, they were referring to the Mark-style response. Here's the post of Vladimir Bugaj earlier in this same thread: I rarely ever post here. But I wanted to say that people responding to this Nikos troll makes reading this list a nuisance. You've never ever been successful in convincing him to behave, and it's been going on for quite a while now. I remain subscribed for occasional interesting new idioms and tips, but always have to sift through this nonsense. And all of you who take the bait are as much a part of the problem as the troll. Just ignore the guy. - How do you read this that he minds the 'Mark-style' post more than the 'Chris-style' post? First, let's keep in mind that I am also in favor of completely ignoring help vampires, including Nikos. I agree with Vladimir that we should just ignore him. The posts I was thinking of started with Daniel Stojanov: I just signed up the this mailing list. To the regulars, is this what normally happens on this list? https://mail.python.org/pipermail/python-list/2013-October/656639.html and the next day, Ravi Sahni said in response: Lurker here: I too was wondering whether I have got into the wrong place https://mail.python.org/pipermail/python-list/2013-October/656695.html When people walk through the door, we should speak well to them. If they are trouble, we should deal with them without it turning into a negative storm. Remember that there are people looking in the windows trying to decide whether to come through the door. --Ned. -- https://mail.python.org/mailman/listinfo/python-list
Re: Python3 doc, operator reflection
On Mon, Oct 28, 2013, at 8:00, Johannes Bauer wrote: Hi group, in http://docs.python.org/3/reference/datamodel.html#customization the doc reads: There are no swapped-argument versions of these methods (to be used when the left argument does not support the operation but the right argument does); rather, __lt__() and __gt__() are each other’s reflection, __le__() and __ge__() are each other’s reflection, and __eq__() and __ne__() are their own reflection. But shouldn't __lt__ be the reflection or __ge__ and __gt__ the reflection of __le__? No... a b is b a - you're thinking of the relationship between a b and not(a = b), which is not the argument-swapping it is referring to. -- https://mail.python.org/mailman/listinfo/python-list
Re: how to avoid checking the same condition repeatedly ?
Wolfgang Maier wolfgang.ma...@biologie.uni-freiburg.de writes: Dear all, this is a recurring programming problem that I'm just not sure how to solve optimally, so I thought I'd ask for your advice: imagine you have a flag set somewhere earlier in your code, e.g., needs_processing = True then in a for loop you're processing the elements of an iterable, but the kind of processing depends on the flag, e.g.,: for elem in iterable: if needs_processing: pre_process(elem) # reformat elem in place print(elem) this checks the condition every time through the for loop, even though there is no chance for needs_processing to change inside the loop, which does not look very efficient. I bet in most cases you won't notice the time used to check the condition. Beware of premature optimization! -- Piet van Oostrum p...@vanoostrum.org WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list
Re: Python on a MacBook Pro (not my machine)
Just upgraded to Mavericks, the new OS X, Python is: Python 2.7.5 (default, Aug 25 2013, 00:04:04) [GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin Type help, copyright, credits or license for more information. (On Mountain Lion, it was 2.7.2. You can install Python 3 using Home Brew or even the packages from Python.org and run them on the same machine. Just change the shebang at the to of the script. I recommend MacVim for editing http://code.google.com/p/macvim/ On Saturday, October 26, 2013 2:07:40 PM UTC-5, John Ladasky wrote: Hi folks, My side job as a Python tutor continues to grow. In two weeks, I will start working with a high-school student who owns a MacBook Pro. I have had students with Linux systems (my preference) and Windows systems before, but not Macs. On my first visit, I set up each student's computer with Python 3.x, and SciTE for editing. I would like to do something similar for my Mac student, and I want to make sure that it goes smoothly. My first question is whether Mac OS X ships with Python 2.x, and whether I need to be aware of any compatibility issues when I install 3.x. (It's 2013, and my students are new to programming. I refuse to hitch them to Python 2.) Second: it doesn't look like I will be able to obtain SciTE for this student. SciTE is free for Windows and Linux. Apparently, it's $42 for Mac OSX? If I recall, SciTE is open-source, so I suppose that I could compile the source myself. But since it is not my computer, and I'm being paid for my time, and I haven't done much with Macs (to say nothing of building from source code), I don't think that this is appropriate. I know, we can use IDLE. I continue to find IDLE clumsy. Also, there are potential issues with event handling which arise when you use IDLE. I am working with an adult professional who is developing a Telnet application, which refuses to cooperate with IDLE/Tk. I had similar issues myself with wxPython applications I was writing. While these issues may not affect a beginning student, these experiences have informed my choices. So, what other free and lightweight editing options do I have for a Mac? I have found a few (fairly old) discussions on comp.lang.python which suggest Eric (http://eric-ide.python-projects.org/) and Editra (http://editra.org/). Opinions on these and other choices are appreciated. Thanks! -- https://mail.python.org/mailman/listinfo/python-list
Re: how to avoid checking the same condition repeatedly ?
On Mon, 28 Oct 2013 09:50:19 +, Wolfgang Maier wrote: So my question is: is there an agreed-upon generally best way of dealing with this? Yes. Just leave the test inside the loop. If you're sufficiently concerned about performance that you're willing to trade clarity for it, you shouldn't be using Python in the first place. -- https://mail.python.org/mailman/listinfo/python-list
Setting up for python django development with Debian Linux
Hi all, I have been trying to set up a python, django, mysql, virtualenvwrapper and git development project and am really confused. All of the documentation seems to ignore the apt-get installation methods used by Debian Linux and its derivatives. Does pip install the same as apt-get; I don't think so. If I use virtualenvwrapper, how does this fit with the normal debian (wheezy) installation. I also need git which just confuses the situation even more. Must I give up the automatic updating system that Debian provides when setting up the development environment? The documentation centers on Windoz, Mac and generic Linux distributions and ignores the automation of the Debian installation. All of the documentation I have found concentrates on the installation of individual packages or on the use of python-django and is very sketchy on the overall virtualenv(wrapper), git, python-django file structure and installation order. Any help with straightening out my brain in this area will be sincerely appreciated. Gary R. -- https://mail.python.org/mailman/listinfo/python-list
Curdling: Concurrent package installer for python
I've been working on a project called curdling. It's a package manager for python. It's pretty similar to pip but with a brand new design and way less lines of code. It uses exciting concurrency technology to provide a reliable and fast installer for Python packages. The current feature set includes: * Robust Concurrent model: it’s FAST! * Really good Error Handling and Report; * Conflict resolution for repeated requirements; * Distributed Cache System that includes a built-in cache server; * Simple command line interface; * Usage of bleeding edge technology available in the Python community; * Concurrent and Parallel, but Ctrl-C still works; It's currently a work in progress but I'm pretty excited about its stability and performance. There's a good amount of documentation available at http://clarete.github.io/curdling This project uses both wheel and distlib packages as part of the dependency stack. I'm working on an essay about my experience with both libraries that I'm planning to share on another opportunity. It will probably be available under the Design and Implementation section in the main website. Feel free to check it out right now if you don't want to wait: http://clarete.github.io/curdling/design-and-implementation.html Any feedback is highly appreciated. -- https://mail.python.org/mailman/listinfo/python-list
Re: Function for the path of the script?
Grant Edwards invalid@invalid.invalid writes: On 2013-10-27, Ben Finney ben+pyt...@benfinney.id.au wrote: What workflow requires you to know the filename of the module, within the module? If you have a utility that can be used to do several related things, one way to tell that utility which you want to do is with command line arguments. That's a case for inspecting the command line. For example your utility checks sys.argv[1] for a command or option flag. Another way is to give the file multiple names, and check sys.argv[0] to see what name you've been invoked under. Exactly so. This isn't a use case for finding the filesystem location of the module. -- \“We have to go forth and crush every world view that doesn't | `\believe in tolerance and free speech.” —David Brin | _o__) | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: Function for the path of the script?
Ben Finney asked What workflow requires you to know the filename of the module, within the module? So what I have is a project utility script in my scripts directory. I have a distinct file structure that holds my .py source, my test.py unit tests, and the file based data associated with the unit tests. Each test.py is in a dedicated directory. My utility script can be easily tweaked to do a variety of useful things, one of which is leave the interactive session with a variable that points to a testing directory whose unit test failed. It relies on each test.py having a same named function that knows its directory. It sounds like there is a more pythonic way to do what I am doing, but also that I am not completely out to lunch. Sounds about par for my python code at this point. As my code used to be almost exclusively out to lunch, I think I am improving (thanks guys!). -- https://mail.python.org/mailman/listinfo/python-list
How do I update a virtualenv?
I have a virtualenv I'm using for some Django development. Today I switched from MacPorts to HomeBrew on my Mac. I'm thus getting a different version of gcc and its libs. How do I reinstall the virtualenv? I've looked around and found a few descriptions of what to do, but as I am little more than a monkey-see-monkey-do user of virtualenv, I don't understand what appears to be a fairly complex set of steps. Does virtualenv not have some sort of upgrade command that just does what's necessary? Thanks, Skip -- https://mail.python.org/mailman/listinfo/python-list
Re: Setting up for python django development with Debian Linux
Gary Roach gary719_li...@verizon.net writes: I have been trying to set up a python, django, mysql, virtualenvwrapper and git development project and am really confused. (Side note: If you have the option, avoid MySQL and begin with PostgreSQL. It is much more standards-compliant, and avoids many of the misfeatures and never-fixed bugs in MySQL that will cause you great grief.) All of the documentation seems to ignore the apt-get installation methods used by Debian Linux and its derivatives. Do you mean the Django documentation? Does pip install the same as apt-get; I don't think so. If I use virtualenvwrapper, how does this fit with the normal debian (wheezy) installation. You're right, it doesn't. Pip is one step on a long, incomplete progress of the Python community's attempt to implement dependency-based package management. It lacks many of the useful features you've come to expect from modern operating system package managers. Not least: if your project has any dependencies other than Python packages, pip cannot help you since it is tied to Python's Distutils. I also need git which just confuses the situation even more. Must I give up the automatic updating system that Debian provides when setting up the development environment? No, you can develop your project on the assumption that APT is available and that particular repositories will be used. Then you are bound to only depend on those packages available from those repositories. There is a huge range of Python packages, Django-specific packages, and of course non-Python packages, in Debian. So you may find that this will work fine for you. But be aware that (unfortunately, in my view) many Python developers do not want to wait for libraries to be quality-tested in an operating system's ecosystem; they want to grab each one as soon as it's available and immediately depend on the latest version. It is for this desire that installing directly from PyPI is implemented. And for this, you do indeed abandon the operating system's package management and all the benefits it brings. The documentation centers on Windoz, Mac and generic Linux distributions and ignores the automation of the Debian installation. Yes. Python (and Django) are designed for a range of operating systems, on some of which package dependency management is nonexistent (MS Windows) or atrocious (OS/X). Dependency-based package management is a mature technology with implementations that avoid many of the problems in pip, but pip serves a real need: bringing some measure of dependency-based package management to at least Python libraries, in operating systems that lack anything better. Any help with straightening out my brain in this area will be sincerely appreciated. If you're fortunate enough to be developing on a modern operating system with dependency-based package management and a rich repository of OS packages, like Debian, then you can develop software as for anything else where the packages are available in the OS: ignore pip, and package your software to depend on other operating system packages. The Python and Django documentation aren't going to be of much help there, since they don't try to teach people to package their software to work with the rest of the operating system (instead advising developers to pretend the rest of the operating system doesn't exist, insulating the developer's software in a virtualenv). So you'll need to learn how to package software for Debian yourself. -- \ Those who will not reason, are bigots, those who cannot, are | `\fools, and those who dare not, are slaves. —“Lord” George | _o__)Gordon Noel Byron | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: Curdling: Concurrent package installer for python
On 10/28/2013 5:13 PM, Lincoln Clarete wrote: I've been working on a project called curdling. It's a package manager for python. It's pretty similar to pip but with a brand new design and way less lines of code. It uses exciting concurrency technology to provide a reliable and fast installer for Python packages. The current feature set includes: * Robust Concurrent model: it’s FAST! * Really good Error Handling and Report; * Conflict resolution for repeated requirements; * Distributed Cache System that includes a built-in cache server; * Simple command line interface; * Usage of bleeding edge technology available in the Python community; * Concurrent and Parallel, but Ctrl-C still works; It's currently a work in progress but I'm pretty excited about its stability and performance. There's a good amount of documentation available at http://clarete.github.io/curdling This project uses both wheel and distlib packages as part of the dependency stack. I'm working on an essay about my experience with both libraries that I'm planning to share on another opportunity. It will probably be available under the Design and Implementation section in the main website. Feel free to check it out right now if you don't want to wait: http://clarete.github.io/curdling/design-and-implementation.html Any feedback is highly appreciated. Are you aware that pip has been 'blessed' as the default installer? See http://python.org/dev/peps/pep-0453/ The intent and hope is that anyone who installs 3.4 will also have pip (1.5, due Dec 1) available. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: How do I update a virtualenv?
On 10/28/13 7:04 PM, Skip Montanaro wrote: I have a virtualenv I'm using for some Django development. Today I switched from MacPorts to HomeBrew on my Mac. I'm thus getting a different version of gcc and its libs. How do I reinstall the virtualenv? I've looked around and found a few descriptions of what to do, but as I am little more than a monkey-see-monkey-do user of virtualenv, I don't understand what appears to be a fairly complex set of steps. Does virtualenv not have some sort of upgrade command that just does what's necessary? Thanks, Skip Virtualenvs aren't built to be moved from one Python installation to another. If you used pip to install your packages (you should), then you can activate the virtualenv, and run: $ pip freeze requirements.txt Then you can create a new virtualenv using the new Python executable, activate it, and: $ pip install -r requirements.txt This will reinstall all the packages you had installed previously. Even better is to maintain your own requirements.txt that has just the packages you need. The pip freeze technique will also list packages installed as dependencies. --Ned. -- https://mail.python.org/mailman/listinfo/python-list
Re: Setting up for python django development with Debian Linux
On 10/28/13 3:46 PM, Gary Roach wrote: Hi all, I have been trying to set up a python, django, mysql, virtualenvwrapper and git development project and am really confused. All of the documentation seems to ignore the apt-get installation methods used by Debian Linux and its derivatives. Does pip install the same as apt-get; I don't think so. If I use virtualenvwrapper, how does this fit with the normal debian (wheezy) installation. I also need git which just confuses the situation even more. Must I give up the automatic updating system that Debian provides when setting up the development environment? The documentation centers on Windoz, Mac and generic Linux distributions and ignores the automation of the Debian installation. All of the documentation I have found concentrates on the installation of individual packages or on the use of python-django and is very sketchy on the overall virtualenv(wrapper), git, python-django file structure and installation order. The two installation techniques (OS-centric and language-centric) overlap in some ways, and each has their own strengths. Some people prefer one, some the other. I would use apt-get to install any non-Python packages, including Python itself. That would be Python, mysql, and git. I would also use apt-get to install virtualenv and/or virtualenvwrapper. Then create a virtualenv, activate it, and use pip to install the Python packages. The advantage of virtualenv is that you can have more than one (for experimenting with other projects), you can delete the whole thing by just removing the directory, and it isolates you from the system-installed Python packages so you can be sure of what packages you are using. The virtualenv is outside the scope of apt-get, so it's true, you won't have Debian helping to keep it up to date. On the plus side, not all Python packages are packaged as Debian packages, and those that are can lag, so virtualenv+pip will give you more Python packages to choose from, and more recent ones. --Ned. Any help with straightening out my brain in this area will be sincerely appreciated. Gary R. -- https://mail.python.org/mailman/listinfo/python-list
Re: How do I update a virtualenv?
In article canc-5uy367mu-zn30z8xkfe_zf9q4g15e_ovtb+howpja6m...@mail.gmail.com, Skip Montanaro s...@pobox.com wrote: I have a virtualenv I'm using for some Django development. Today I switched from MacPorts to HomeBrew on my Mac. Any particular reason for doing that? That seems like a step backwards, especially for Python-related work. -- Ned Deily, n...@acm.org -- https://mail.python.org/mailman/listinfo/python-list
Re: How do I update a virtualenv?
Virtualenvs aren't built to be moved from one Python installation to another. If you used pip to install your packages (you should), then you can activate the virtualenv, and run: $ pip freeze requirements.txt Then you can create a new virtualenv using the new Python executable, activate it, and: $ pip install -r requirements.txt This will reinstall all the packages you had installed previously. Even better is to maintain your own requirements.txt that has just the packages you need. The pip freeze technique will also list packages installed as dependencies. Hmmm... And my git repo? I imagine I will eventually figure this out, but updating an existing virtualenv in place to adapt to a new version of Python (say, a new micro) or some of its libraries (contents of requirements.txt) seems like it would be a very nice thing to have. Skip -- https://mail.python.org/mailman/listinfo/python-list
Re: How do I update a virtualenv?
On 10/28/13 7:53 PM, Skip Montanaro wrote: Virtualenvs aren't built to be moved from one Python installation to another. If you used pip to install your packages (you should), then you can activate the virtualenv, and run: $ pip freeze requirements.txt Then you can create a new virtualenv using the new Python executable, activate it, and: $ pip install -r requirements.txt This will reinstall all the packages you had installed previously. Even better is to maintain your own requirements.txt that has just the packages you need. The pip freeze technique will also list packages installed as dependencies. Hmmm... And my git repo? Usually the virtualenv is outside the git repo (and vice-versa), but git repos are also easy to recreate from the git server if you need to. Maybe I don't understand what you mean? I imagine I will eventually figure this out, but updating an existing virtualenv in place to adapt to a new version of Python (say, a new micro) or some of its libraries (contents of requirements.txt) seems like it would be a very nice thing to have. pip install --upgrade will upgrade your Python packages. pip install -r requirements.txt will install new packages or versions named in the requirements.txt file. Skip --Ned. -- https://mail.python.org/mailman/listinfo/python-list
Re: How do I update a virtualenv?
I have a virtualenv I'm using for some Django development. Today I switched from MacPorts to HomeBrew on my Mac. Any particular reason for doing that? That seems like a step backwards, especially for Python-related work. The guy who sits next to me at work recommended HomeBrew. (Someone to ask for help. :-) I didn't have all that much stuff installed via MacPorts, buncha libraries mostly, so it didn't seem like a huge sacrifice. Also, when I'd tried installing gcc 4.8 a few weeks ago things didn't go so well, so I figured I'd try HomeBrew. Skip -- https://mail.python.org/mailman/listinfo/python-list
Re: How do I update a virtualenv?
Skip Montanaro s...@pobox.com writes: Hmmm... And my git repo? You are keeping your virtualenv separate from your working tree, right? I put mine in ‘/var/local/devel/$USER/virtualenvs/foobar/’ where “foobar” is the specific virtualenv name. This allows an arbitrary number of virtualenvs separate for each user (‘/var/local/devel/$USER/’ is owned by each $USER), but all under one directory tree where they can be treated specially for backup, cleanup, permissions, or whatever. I imagine I will eventually figure this out, but updating an existing virtualenv in place to adapt to a new version of Python (say, a new micro) or some of its libraries (contents of requirements.txt) seems like it would be a very nice thing to have. Yes, you simply ‘pip install -r ./requirements.txt’ again. It does a simplistic “is the package already installed at this version in the currently-active virtualenv? If not, install it in that virtualenv”. The environment variables that determine where the virtualenv lives are managed by ‘/var/local/devel/$USER/virtualenvs/foobar/bin/activate’. You don't have the packages cluttering up your working tree. -- \ “I don't know anything about music. In my line you don't have | `\ to.” —Elvis Aaron Presley (1935–1977) | _o__) | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: How do I update a virtualenv?
In article mailman.1731.1383006012.18130.python-l...@python.org, Ned Batchelder n...@nedbatchelder.com wrote: pip install --upgrade will upgrade your Python packages. pip install -r requirements.txt will install new packages or versions named in the requirements.txt file. Yup, that's what we do. We've got a requirements.txt file that's checked into our source repo. Part of our deployment process is to run pip install -r requirements.txt. You want to start doing this from day one on any new project. One of the problems we had was we started not even using virtualenv. When we switched to do that, we needed to come up with a list of what should be in it. We started with pip freeze, and got a list of all the crap we currently had installed. We then needed to start sorting through it to figure out what we really needed and what was just excess baggage. It's a lot cleaner if you start out doing it right at the beginning. We build a fresh virtualenv on every code deployment. This makes sure we know exactly what's in the virtualenv all the time. It's a little extra work, but worth it. We're looking at https://pypi.python.org/pypi/wheel to reduce deployment time. -- https://mail.python.org/mailman/listinfo/python-list
Re: Organising packages/modules - importing functions from a common.py in a separate directory?
Hi, Ok, so I should be using absolute imports, not relative imports. Hmm, I just tried to use absolute imports, and it can't seem to locate the modules: In the file foo_loading/em_load/sync_em.py, I have: from common.common_bex import setup_foo_logging When I try to run that script: python sync_em.py I get: ImportError: No module named common.common_foo I've also tried adding foo_loading (the package name): from foo_loading.common.common_bex import setup_foo_logging Same error: ImportError: No module named foo_loading.common.bex_common Any thoughts? Cheers, Victor On Tuesday, 29 October 2013 00:12:58 UTC+11, Jean-Michel Pichavant wrote: - Original Message - Hi, I have a collection of Python scripts I'm using to load various bits of data into a database. I'd like to move some of the common functions (e.g. to setup loggers, reading in configuration etc.) into a common file, and import them from there. I've created empty __init__.py files, and my current directory structure looks something like this: foo_loading/ __init__.py common/ common_foo.py em_load/ __init__.py config.yaml sync_em.py pg_load/ __init__.py config.yaml sync_pg.py So from within the sync_em.py script, I'm trying to import a function from foo_loading/common/common_foo.py. from ..common.common_foo import setup_foo_logging I get the error: ValueError: Attempted relative import in non-package If I change directories to the parent of foo_loading, then run python -m foo_loading.em_load.sync_em sync_em.py it works. However, this seems a bit roundabout, and I suspect I'm not doing things correctly. Ideally, I want a user to be able to just run sync_em.py from it's own directory, and have it correctly import the logging/config modules from common_foo.py, and just work. What is the correct way to achieve this? Secondly, if I want to move all of the config.yaml files to a common foo_loading/config.yaml, or even foo_loading/config/config.yaml, what is the correct way to access this from within the scripts? Should I just be using ../, or is there a better way? Cheers, Victor Long story short : use absolute imports. name properly your module with a distinct name and import that way, even inside your package: import foo_loading.common.common_foo Names like common, lib, setup are farely prone to collision with other badly referenced import from other modules. One way to solve this is to use a distinct namespace, in other words, prefix every import with the module name. cheers, JM -- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you. -- https://mail.python.org/mailman/listinfo/python-list
Re: Organising packages/modules - importing functions from a common.py in a separate directory?
Victor Hooi victorh...@gmail.com writes: Ok, so I should be using absolute imports, not relative imports. I'd say it is fine to use relative imports, so long as they are explicit. (In Python 3, the default for an import is to be absolute, and the *only* way to do a relative import is to make it explicitly relative. So you may as well start doing so now.) Hmm, I just tried to use absolute imports, and it can't seem to locate the modules: In the file foo_loading/em_load/sync_em.py, I have: from common.common_bex import setup_foo_logging So I'd recommend this be done with an explicit relative import: from .common.common_bex import setup_foo_logging or, better, import a module: from .common import common_bex or a whole package: from . import common -- \ “I went over to the neighbor's and asked to borrow a cup of | `\ salt. ‘What are you making?’ ‘A salt lick.’” —Steven Wright | _o__) | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: How do I update a virtualenv?
Hmmm... And my git repo? Usually the virtualenv is outside the git repo (and vice-versa), but git repos are also easy to recreate from the git server if you need to. Maybe I don't understand what you mean? I'm using Heroku, following their instructions. They have a git init in the midst of things, so I wind up with a git repo that matches up one-to-one for my Django project. (git push installs). Part of the problem here is, of course, that I have done essentially no web work since the days of editing HTML directly. I just have to hunt around for something I can sort of understand and that has some recommendations from someone I trust (in this case, some of the denizens of chic...@python.org), and head off in that direction. I'm sure the combinations of packaging systems, web application platforms, and distribution tools are nearly limitless. I don't enough time left to investigate and try out every combination, so for now, it's HomeBrew+Django+Heroku. The decision to switch from MacPorts to HomeBrew may well turn out to be problematic, but it is what it is. I imagine I will eventually figure this out, but updating an existing virtualenv in place to adapt to a new version of Python (say, a new micro) or some of its libraries (contents of requirements.txt) seems like it would be a very nice thing to have. pip install --upgrade will upgrade your Python packages. pip install -r requirements.txt will install new packages or versions named in the requirements.txt file. Thanks. That's done. So, in addition to the various virtualenv bits I needed to * move .git and .gitignore from the old directory * recreate the heroku stuff * set up the remote heroku association again * push everything * sync the database None of these things have anything to do with virtualenv, but they all were things *in* the virtualenv. There are clearly various dot files left laying around in my old virtualenv. I still think it would have been easier overall if I was able to refresh the virtualenv in place. It all boils down to a virtualenv only being one piece of a larger puzzle. I'm not sure its constraints should drive the entire process. Skip -- https://mail.python.org/mailman/listinfo/python-list
Re: Organising packages/modules - importing functions from a common.py in a separate directory?
Hi, If I try to use: from .common.common_foo import setup_foo_logging I get: ValueError: Attempted relative import in non-package And the absolute imports don't seem to be able to find the right modules. Is it something to do with the fact I'm running the sync_em.py script from the foo_loading/em_load directory? I thought I could just refer to the full path, and it'd find it, but evidently not...hmm. Cheers, Victor On Tuesday, 29 October 2013 12:01:03 UTC+11, Ben Finney wrote: Victor Hooi victorh...@gmail.com writes: Ok, so I should be using absolute imports, not relative imports. I'd say it is fine to use relative imports, so long as they are explicit. (In Python 3, the default for an import is to be absolute, and the *only* way to do a relative import is to make it explicitly relative. So you may as well start doing so now.) Hmm, I just tried to use absolute imports, and it can't seem to locate the modules: In the file foo_loading/em_load/sync_em.py, I have: from common.common_bex import setup_foo_logging So I'd recommend this be done with an explicit relative import: from .common.common_bex import setup_foo_logging or, better, import a module: from .common import common_bex or a whole package: from . import common -- \ “I went over to the neighbor's and asked to borrow a cup of | `\ salt. ‘What are you making?’ ‘A salt lick.’” —Steven Wright | _o__) | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: How do I update a virtualenv?
On 2013-10-29 11:42, Ben Finney wrote: You are keeping your virtualenv separate from your working tree, right? This was one of the key bits I missed in most of the virtualenv{,wrapper} documentation and only figured out after asking several questions here on c.l.p Once I had that understanding, the usefulness of virtualenvwrapper made more sense (previously, I'd figured it was silly since I thought the code-base was supposed to be contained in the virtualenv, not independent from it). Now it's virtualenv{,wrapper} for just about all development. -tkc -- https://mail.python.org/mailman/listinfo/python-list
Re: How do I update a virtualenv?
Hmmm... And my git repo? You are keeping your virtualenv separate from your working tree, right? I put mine in ‘/var/local/devel/$USER/virtualenvs/foobar/’ where “foobar” is the specific virtualenv name. No, I'm no expert in these things. I was just following the directions on the Heroku getting started page. What you wrote is Greek to me. Skip -- https://mail.python.org/mailman/listinfo/python-list
Re: Curdling: Concurrent package installer for python
Sounds nice. I'll see about checking it out later. Good luck with the project. -- https://mail.python.org/mailman/listinfo/python-list
Re: Setting up for python django development with Debian Linux
On Tuesday, October 29, 2013 1:16:07 AM UTC+5:30, Gary Roach wrote: Hi all, I have been trying to set up a python, django, mysql, virtualenvwrapper and git development project and am really confused. All of the documentation seems to ignore the apt-get installation methods used by Debian Linux and its derivatives. Have you seen this? https://code.djangoproject.com/wiki/Distributions It seems to be saying that the standard debian/ubuntu package 'python-django' works -- https://mail.python.org/mailman/listinfo/python-list
Re: How do I update a virtualenv?
Skip Montanaro s...@pobox.com writes: I'm using Heroku, following their instructions. They have a git init in the midst of things, so I wind up with a git repo that matches up one-to-one for my Django project. (git push installs). That's not a good thing; you don't want loads of third-party files in your VCS repository. Instead, the deployment to the live system should be done from a wholly separate build area, and the virtualenv can serve as that build area. Then, your VCS need only contain the files you'll actually be changing as source code. Where specifically are these instructions that tell you to put the virtualenv under VCS control? As you are a Heroku customer (I'm not), would you be willing to suggest they alter them based on advice from this forum? -- \ “Pity the meek, for they shall inherit the earth.” —Donald | `\ Robert Perry Marquis | _o__) | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: How do I update a virtualenv?
Skip Montanaro s...@pobox.com writes: You are keeping your virtualenv separate from your working tree, right? I put mine in ‘/var/local/devel/$USER/virtualenvs/foobar/’ where “foobar” is the specific virtualenv name. No, I'm no expert in these things. I was just following the directions on the Heroku getting started page. What you wrote is Greek to me. Fair enough; virtualenv is a baroque system with many knobs to tune. It sucks that anything like this is needed. I don't know of better official documentation for virtualenv than URL:https://pypi.python.org/pypi/virtualenv. -- \ “It is forbidden to steal hotel towels. Please if you are not | `\ person to do such is please not to read notice.” —hotel, | _o__) Kowloon, Hong Kong | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: Function for the path of the script?
On 10/28/2013 08:49 AM, Grant Edwards wrote: On 2013-10-27, Chris Angelico ros...@gmail.com wrote: On Sun, Oct 27, 2013 at 1:52 PM, Gary Herron It's very common to want to know what directory you're in - it's a good way to find data files. From a Unix point of view, that's also very wrong. Data files don't belong in the same directory as the executable. In the case of applications installed in /opt, data files quite often go in a subdirectory of the executable (or a subdirectory of the executable's parent dir) and getting the executable's dir is the first step to find the data files. This is not only *not wrong* but the FHS prohibits locating such files outside of the /opt subdirectory tree, with some minor exceptions. This was pointed out before but since you said you ignore posts from GG you probably missed it, and will probably miss this one too, and thus continue to post bad information. This is a small but illustrative example of why such broad- brush filtering is a bad idea. But it is your choice. -- https://mail.python.org/mailman/listinfo/python-list
Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea.
On 10/28/2013 12:51 AM, rusi wrote: On Monday, October 28, 2013 11:26:21 AM UTC+5:30, rusi wrote: On Monday, October 28, 2013 11:10:21 AM UTC+5:30, ru...@yahoo.com wrote: I updated the page, hopefully it's an improvement? Otherwise ok I think Just looked at the general netiquette link -- its long and not much use for a technical oriented forum. I agree. Wikipedia is convenient but almost never suitable as a learning resource. I'll see if I can find a friendlier general netiquette link. Recommendations welcome. Some items missed (irrespective of GG usage) 1. Good subject line 2. Good code examples http://sscce.org/ 3. http://www.catb.org/esr/faqs/smart-questions.html I am hesitant to put too many general netiquette rules there. Such rules aren't applicable to only GG users. The alternate recommendations made to GG users here (to use usenet and email) are always made without a list of netiquette rules even though the recipients are the same people using GG. Why should GG users be told about those rules when they get advice about using GG but not when they get advice to use email or usenet? What would be best I think is a separate page with general guidelines for posting that any user could be pointed to. Regarding esr's smart-questions, although I acknowledge it has useful advice, I have always found it elitist and abrasive. I wish someone would rewrite it without the we are gods attitude. Thanks again for your feedback. -- https://mail.python.org/mailman/listinfo/python-list
Re: Running Python programmes
On 27/10/2013 11:31, Colin J. Williams wrote: On 27/10/2013 10:32 AM, David wrote: I am an absolute beginner and am working through the book Python Programming for the Absolute Beginner by Michael Dawson. Everything is fine except if I run a scripted programme, or one I have downloaded, and then run another one, the second one will not run, I just get the in the interactive window. I have to exit Python and start again, when the second programme then runs fine. Any suggestions much appreciated. You leave out a lot of details, including what version of Python, what OS, how you're running these programmes and what you mean will not run. For example, if you're on Linux, running Python 3.3, and you're running these programmes from the bash prompt, $ python3.3 prog1.py some results $ python3.3 prog2.py some other results I'd be amazed if you even saw the prompt. -- DaveA -- https://mail.python.org/mailman/listinfo/python-list
Re: how to avoid checking the same condition repeatedly ?
On Mon, 28 Oct 2013 22:18:45 +1100, Chris Angelico wrote: On Mon, Oct 28, 2013 at 10:14 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: if needs_preprocessing: for elem in iterable: # If you change this block, you must remember to change the # block below too! preprocess(item) do_this(item) do_that(item) do_something_else(item, arg1, arg2, expression) do_another_thing(item + arg3, key=whatever) print(item) else: for elem in iterable: # If you change this block, you must remember to change the # block above too! preprocess(item) do_this(item) do_that(item) do_something_else(item, arg1, arg2, expression) do_another_thing(item, key=whatever) print(item) The careful reader will notice that there's already a bug in this. For a start, you're preprocessing in the second block... I don't think that was your intentional bug :) Heh, no, that wasn't the intentional bug. But it does go to show the risks of copy-and-paste programming. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Being a welcoming place [was Re: Cookie fucking problem]
On Mon, 28 Oct 2013 14:22:09 -0400, Ned Batchelder wrote: When people walk through the door, we should speak well to them. If they are trouble, we should deal with them without it turning into a negative storm. Remember that there are people looking in the windows trying to decide whether to come through the door. +1 -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: trying to strip out non ascii.. or rather convert non ascii
On Mon, 28 Oct 2013 07:01:16 -0700, wxjmfauth wrote: And of course, logically, they are very, very badly handled with the Flexible String Representation. I'm reminded of Cato the Elder, the Roman senator who would end every speech, no matter the topic, with Ceterum censeo Carthaginem esse delendam (Furthermore, I consider that Carthage must be destroyed). But at least he had the good grace to present that as an opinion, instead of repeating a falsehood as if it were a fact. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Slicing with negative strides
Does anyone here use slices (or range/xrange) with negative strides other than -1? E.g. sequence[2:15:-3] If so, there is a discussion (long, long, looong discussion) on the python-ideas mailing list, debating whether or not to deprecate or change the behaviour of slicing with negative strides. So if you care about the current behaviour, now is the time to stand up and be counted. (Standing up *here* is fine, don't feel that you have to join yet another list.) -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: trying to strip out non ascii.. or rather convert non ascii
On Mon, 28 Oct 2013 09:23:41 -0500, Tim Chase wrote: On 2013-10-28 07:01, wxjmfa...@gmail.com wrote: Simply ignoring diactrics won't get you very far. Right. As an example, these four French words : cote, côte, coté, côté . Distinct words with distinct meanings, sure. But when a naïve (naive? ☺) person or one without the easy ability to enter characters with diacritics searches for cote, I want to return possible matches containing any of your 4 examples. It's slightly fuzzier if they search for coté, in which case they may mean coté or they might mean be unable to figure out how to add a hat and want to type côté. Though I'd rather get more results, even if it has some that only match fuzzily. The right solution to that is to treat it no differently from other fuzzy searches. A good search engine should be tolerant of spelling errors and alternative spellings for any letter, not just those with diacritics. Ideally, a good search engine would successfully match all three of naïve, naive and niave, and it shouldn't rely on special handling of diacritics. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: Function for the path of the script?
On Mon, 28 Oct 2013 21:00:39 -0700, rurpy wrote: This was pointed out before but since you said you ignore posts from GG you probably missed it, and will probably miss this one too, and thus continue to post bad information. This is a small but illustrative example of why such broad- brush filtering is a bad idea. But it is your choice. Yes, it is unfortunate that somebody such as yourself who takes the time to post well using Google Groups gets tared with the same brush as those who don't, but then as my granny used to say, if you lie down with dogs you'll get fleas. If you don't want to be associated with the typical GG posts, you have the choice to stop using GG. And just as you make the choice that the convenience of GG outweighs the annoyance of being filtered, I expect Grant has made the choice that the convenience of avoiding unwanted GG posts outweighs the risk of throwing out a useful post or two. Isn't freedom of choice wonderful? No matter what you choose, you'll annoy somebody, possibly yourself :-) -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: Cookie fucking problem
On Mon, 28 Oct 2013 13:20:17 +, Neil Cerutti wrote: On 2013-10-27, Ben Finney ben+pyt...@benfinney.id.au wrote: I have no particular objection to you responding to those instances of bad behaviour that I've omitted. So you omitted them, eh? You just omitted the body of the letter, that's all! You've left out the body of the letter, that's all. Yours is not to reason why, Jamison. You've left out the body of the letter! ... Fine. Send it that way, and tell them the body will follow. Was that the letter made out to the solicitors Hummerdinger, Hummerdinger, Hummerdinger, Hummerdinger, and McCormack? As I recall, not only did the secretary leave out one of the Hummerdingers, but he left out the most important one. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
[issue19403] Make contextlib.redirect_stdout reentrant
Raymond Hettinger added the comment: +1 -- nosy: +rhettinger ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19403 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19332] Guard against changing dict during iteration
Changes by Raymond Hettinger raymond.hettin...@gmail.com: -- resolution: - rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19332 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com