Re: Image Upload with FalconFramework

2014-07-03 Thread Mark Lawrence
On 03/07/2014 04:54, Peter Romfeld wrote: Hi, I am stuck at a simple image upload function, in django i just used: for feature phones: file = request.body iOS with Form: class ImageForm(forms.Form): image = forms.FileField() What is forms? image is defined at the class level, not the i

Re: TypeError expected in an augmented assignment

2014-07-03 Thread candide
> >>> seq = [1,2] > > >>> seq.extend((3,4)) OK, this feature is referenced in the Python Library reference here : https://docs.python.org/3.2/library/stdtypes.html#typesseq-mutable not thoroughly referenced but, anyway, referenced. > > >>> seq+= {5, 6} # the order of extending is n

Re: Success with subprocess communicate on Windows?

2014-07-03 Thread Wolfgang Maier
On 07/03/2014 06:09 AM, Terry Reedy wrote: Yes, but what puzzled me is that running subprocess.check_output(r'pyflakes c:\programs\python34\lib') in the regular interpreter *does* produce output instead of the error message. My guess is that it fills up the pipe, so that check_output starts read

Re: TypeError expected in an augmented assignment

2014-07-03 Thread Chris Angelico
On Thu, Jul 3, 2014 at 5:51 PM, candide wrote: > Good and interesting observation. But I can't find out where this feature is > referenced in the Language/Library Reference. Because, as my first post > explains, augmented assignment performs the binary operation associated to > the augmented as

OT: speeds (physical, not computing) [was Re: 1-0.95]

2014-07-03 Thread Steven D'Aprano
On Wed, 02 Jul 2014 21:06:52 -0700, Rustom Mody wrote: > On Thursday, July 3, 2014 7:49:30 AM UTC+5:30, Steven D'Aprano wrote: >> On Wed, 02 Jul 2014 23:00:15 +0300, Marko Rauhamaa wrote: > >> > On the other hand, floating-point numbers are perfect whenever you >> > deal with science and measurem

Re: Success with subprocess communicate on Windows?

2014-07-03 Thread Wolfgang Maier
On 07/03/2014 10:03 AM, Wolfgang Maier wrote: On 07/03/2014 06:09 AM, Terry Reedy wrote: - what is happening to the stderr output when run in IDLE ? I guess it is caught and suppressed somewhere, but to add to your observations the check_output call doesn't hang on IDLE, but finishes eventually

Re: general module auditing

2014-07-03 Thread Rita
On Thu, Jul 3, 2014 at 2:54 AM, Mark Lawrence wrote: > On 03/07/2014 02:17, Rita wrote: > >> >> On Wed, Jul 2, 2014 at 2:46 PM, Irmen de Jong > > wrote: >> >> On 2-7-2014 4:04, Rita wrote: >> > yes, this helps. But I want to know who uses the module, serpen

Re: TypeError expected in an augmented assignment

2014-07-03 Thread candide
> >From that link: > > > > """ > > An augmented assignment expression like x += 1 can be rewritten as x = > > x + 1 to achieve a similar, but not exactly equal effect. In the > > augmented version, x is only evaluated once. Also, when possible, the > > actual operation is performed in-plac

Re: 1-0.95

2014-07-03 Thread Steven D'Aprano
On Thu, 03 Jul 2014 09:51:35 +0300, Marko Rauhamaa wrote: > Steven D'Aprano : [...] >> By the way, there's no need to use an invented example. Here is an >> actual example: >> >> py> import math >> py> from fractions import Fraction >> py> math.sqrt(Fraction(2))**2 >> 2.0004 > > Sure,

threading.Condition.wait() is not catching SIGTERM

2014-07-03 Thread Sangeeth Saravanaraj
Hi All, I have the following code which when executed waits to be interrupted by SIGINT, SIGTERM or SIGQUIT. When an object is initialized, it creates a threading.Condition() and acquires() it! The program then registers the signal handlers where notify() and release() is called when the above

Re: threading.Condition.wait() is not catching SIGTERM

2014-07-03 Thread Roy Smith
In article , Sangeeth Saravanaraj wrote: > Hi All, > > I have the following code which when executed waits to be interrupted by > SIGINT, SIGTERM or SIGQUIT. We need more information. What version of Python are you using? And, what operating system is this running on? -- https://mail.pyt

Re: threading.Condition.wait() is not catching SIGTERM

2014-07-03 Thread Sangeeth Saravanaraj
On 03-Jul-2014, at 3:49 pm, Roy Smith wrote: > In article , > Sangeeth Saravanaraj wrote: > >> Hi All, >> >> I have the following code which when executed waits to be interrupted by >> SIGINT, SIGTERM or SIGQUIT. > > We need more information. What version of Python are you using? And, >

Re: threading.Condition.wait() is not catching SIGTERM

2014-07-03 Thread Chris Angelico
On Thu, Jul 3, 2014 at 8:27 PM, Sangeeth Saravanaraj wrote: > But does the behavior of threading.Condition.wait() depends on operating > system?! The behaviour of signals certainly does - there's a huge difference between Windows and POSIX, and there are lesser differences between Linux and Mac

Re: 1-0.95

2014-07-03 Thread Marko Rauhamaa
Steven D'Aprano : > If you don't think Fraction counts as "arbitrary precision rational > number", what do you think does? I was assuming you were referring to an idealized datatype. Fraction() doesn't have a square root method. Let's make one: def newton(x, n): guess = Fraction(1)

Re: general module auditing

2014-07-03 Thread Mark Lawrence
On 03/07/2014 10:27, Rita wrote: On Thu, Jul 3, 2014 at 2:54 AM, Mark Lawrence mailto:breamore...@yahoo.co.uk>> wrote: On 03/07/2014 02:17, Rita wrote: On Wed, Jul 2, 2014 at 2:46 PM, Irmen de Jong mailto:irmen.nos...@xs4all.nl>

Re: TypeError expected in an augmented assignment

2014-07-03 Thread Mark Lawrence
On 03/07/2014 10:35, candide wrote: >From that link: """ An augmented assignment expression like x += 1 can be rewritten as x = x + 1 to achieve a similar, but not exactly equal effect. In the augmented version, x is only evaluated once. Also, when possible, the actual operation is perf

Re: OOP with MyTime

2014-07-03 Thread kjakupak
On Wednesday, July 2, 2014 4:02:00 PM UTC-4, MRAB wrote: > > > > If you want 'between' to be an instance method of the MyTime class, it > > needs 'self' as well as the 2 arguments 't1' and 't2'. > > > > You can then compare the hours, minutes and seconds of self against > > those of t1 and t2

Re: OOP with MyTime

2014-07-03 Thread Chris Angelico
On Thu, Jul 3, 2014 at 10:51 PM, wrote: > So I've now gotten this: > class MyTime: > def between(self, t1, t2): > return (t1.hours, t1.minutes, t1.seconds) <= (self.hours, > self.minutes, self.seconds) and (self.hours, self.minutes, self.seconds) <= > (t2.hours, t2.minutes, t2.secon

Re: OOP with MyTime

2014-07-03 Thread kjakupak
On Thursday, July 3, 2014 9:01:09 AM UTC-4, Chris Angelico wrote: > > > > And what happens when you run this code? A NameError, I would expect. > > Do you understand how to define and call methods? > > > > ChrisA Altered the code. But yes a nameerror came up class MyTime: def __init__

Re: OOP with MyTime

2014-07-03 Thread MRAB
On 2014-07-03 13:51, kjaku...@gmail.com wrote: On Wednesday, July 2, 2014 4:02:00 PM UTC-4, MRAB wrote: > If you want 'between' to be an instance method of the MyTime class, it needs 'self' as well as the 2 arguments 't1' and 't2'. You can then compare the hours, minutes and seconds of self

Re: OOP with MyTime

2014-07-03 Thread Chris Angelico
On Thu, Jul 3, 2014 at 11:08 PM, wrote: > Altered the code. But yes a nameerror came up When that sort of thing happens, you have three basic approaches to solving the problem. 1) Read the traceback, look at the line of code it points to, and see if you can figure out what it means. 2) Post her

Re: OOP with MyTime

2014-07-03 Thread kjakupak
On Thursday, July 3, 2014 9:11:49 AM UTC-4, MRAB wrote: > On 2014-07-03 13:51, kjaku...@gmail.com wrote: > > > On Wednesday, July 2, 2014 4:02:00 PM UTC-4, MRAB wrote: > > >> > > > >> > > >> If you want 'between' to be an instance method of the MyTime class, it > > >> > > >> needs 'self' as w

Re: OOP with MyTime

2014-07-03 Thread Chris Angelico
On Fri, Jul 4, 2014 at 1:21 AM, wrote: > I keep getting an invalid syntax on the t1 = (9, 59, 59) line, not sure why? > > t1 = (9, 59, 59) Two points. Firstly, as I said before, posting the entire exception helps us enormously. Secondly, with most computerized parsers, the file is processed top-

Re: OOP with MyTime

2014-07-03 Thread Mark Lawrence
On 03/07/2014 16:21, kjaku...@gmail.com wrote: On Thursday, July 3, 2014 9:11:49 AM UTC-4, MRAB wrote: I'm pleased to see that you have answers. In return would you please use the mailing list https://mail.python.org/mailman/listinfo/python-list or read and action this https://wiki.python.o

PEP8 and 4 spaces

2014-07-03 Thread Tobiah
Coworker takes PEP8 as gospel and uses 4 spaces to indent. I prefer tabs. Boss want's us to unify. The sole thing you get with spaces as far as I can tell, is that someone loading the code into Notepad will still see a 4 character indent. That may be true, but that same person is going to have

Re: PEP8 and 4 spaces

2014-07-03 Thread Chris Angelico
On Fri, Jul 4, 2014 at 3:31 AM, Tobiah wrote: > Coworker takes PEP8 as gospel and uses 4 spaces > to indent. I prefer tabs. Boss want's us to > unify. 1) PEP 8 is meant to be guidelines, *not* a set of hard-and-fast rules. 2) Tabs let different people display the indents at different widths. Yo

Re: PEP8 and 4 spaces

2014-07-03 Thread Roy Smith
In article , Tobiah wrote: > Coworker takes PEP8 as gospel and uses 4 spaces > to indent. I prefer tabs. > [...] > Just need ammo for when the hammer of code > unification comes down. There are so many battles to fight that are worth fighting. This isn't one of them. Just go with pep-8 and

Re: PEP8 and 4 spaces

2014-07-03 Thread Peter Otten
Tobiah wrote: > Coworker takes PEP8 as gospel and uses 4 spaces > to indent. I prefer tabs. Boss want's us to > unify. The sole thing you get with spaces as > far as I can tell, is that someone loading the > code into Notepad will still see a 4 character > indent. That may be true, but that sa

Re: PEP8 and 4 spaces

2014-07-03 Thread Toby Shepard
On 07/03/2014 10:46 AM, Tim Chase wrote: Any evidence out there that this part of PEP8 is becoming more optional or even obsolete, as I've heard others say about the 80 char line length? Just need ammo for when the hammer of code unification comes down. I'm not sure you'll get a whole lot of "

Re: PEP8 and 4 spaces

2014-07-03 Thread Paul Sokolovsky
Hello, On Fri, 4 Jul 2014 03:38:27 +1000 Chris Angelico wrote: > On Fri, Jul 4, 2014 at 3:31 AM, Tobiah wrote: > > Coworker takes PEP8 as gospel and uses 4 spaces > > to indent. I prefer tabs. Boss want's us to > > unify. > > 1) PEP 8 is meant to be guidelines, *not* a set of hard-and-fast >

Re: PEP8 and 4 spaces

2014-07-03 Thread Grant Edwards
On 2014-07-03, Tobiah wrote: > Coworker takes PEP8 as gospel and uses 4 spaces to indent. I prefer > tabs. Boss want's us to unify. The sole thing you get with spaces > as far as I can tell, is that someone loading the code into Notepad > will still see a 4 character indent. Or any editor at

Re: PEP8 and 4 spaces

2014-07-03 Thread Tim Chase
> Any evidence out there that this part of PEP8 is becoming > more optional or even obsolete, as I've heard others > say about the 80 char line length? > > Just need ammo for when the hammer of code > unification comes down. I'm not sure you'll get a whole lot of "PEP8 is optional or obsolete", t

Re: PEP8 and 4 spaces

2014-07-03 Thread Tim Chase
On 2014-07-03 19:02, Grant Edwards wrote: > > That may be true, but that same person is going to have a > > difficult time editing the code. > > That's true with Notepad, but with dozens of other programming > editors, code indented with spaces will read and edit prefectly. > Not so for tab-inde

Re: threading.Condition.wait() is not catching SIGTERM

2014-07-03 Thread Ned Deily
In article <17f05a1b-44c8-4f25-afe9-5dbcffb99...@gmail.com>, > I have the following code which when executed waits to be interrupted by > SIGINT, SIGTERM or SIGQUIT. When an object is initialized, it creates a > threading.Condition() and acquires() it! The program then registers the > signal han

Re: PEP8 and 4 spaces

2014-07-03 Thread Toby Shepard
On 07/03/2014 12:44 PM, Simon Ward wrote: On 3 July 2014 18:31:04 BST, Tobiah wrote: Coworker takes PEP8 as gospel and uses 4 spaces to indent. I prefer tabs. Boss want's us to unify. This isn't worth arguing about. How point of view changes things. Anyway, I gave up the 80 char lin

Re: threading.Condition.wait() is not catching SIGTERM

2014-07-03 Thread Roy Smith
In article , Ned Deily wrote: > In article <17f05a1b-44c8-4f25-afe9-5dbcffb99...@gmail.com>, > > I have the following code which when executed waits to be interrupted by > > SIGINT, SIGTERM or SIGQUIT. When an object is initialized, it creates a > > threading.Condition() and acquires() it! The

Re: PEP8 and 4 spaces

2014-07-03 Thread Simon Ward
On 3 July 2014 18:31:04 BST, Tobiah wrote: >Coworker takes PEP8 as gospel and uses 4 spaces >to indent. I prefer tabs. Boss want's us to >unify. This isn't worth arguing about. Pick a convention, it's probably going to be a compromise, get used to it. PEP8 is as good a base as any, and is (m

Re: PEP8 and 4 spaces

2014-07-03 Thread Tobiah
On 07/03/2014 12:40 PM, Tim Chase wrote: On 2014-07-03 19:02, Grant Edwards wrote: That may be true, but that same person is going to have a difficult time editing the code. That's true with Notepad, but with dozens of other programming editors, code indented with spaces will read and edit pre

Re: PEP8 and 4 spaces

2014-07-03 Thread Tobiah
Anyway, I gave up the 80 char line length long ago, having little feeling for some dolt Same to you. Haha, the language was too strong. The code I'm talking about is only going to be seen by a small group of programmers. The current trio has all been here for over 20 years. I'd be more co

Re: general module auditing

2014-07-03 Thread Rita
On Thu, Jul 3, 2014 at 8:36 AM, Mark Lawrence wrote: > On 03/07/2014 10:27, Rita wrote: > >> >> >> >> On Thu, Jul 3, 2014 at 2:54 AM, Mark Lawrence > > wrote: >> >> On 03/07/2014 02:17, Rita wrote: >> >> >> On Wed, Jul 2, 2014 at 2:46 PM, Irmen de Jong

Re: PEP8 and 4 spaces

2014-07-03 Thread Emile van Sebille
On 7/3/2014 2:23 PM, Tobiah wrote: I think your suggestion of having GIT handle the transformations is the way we'll go. nothing to quibble or worry about. Well put spaces in the repository since it still seems to be the community's preference and I'll convert to tabs with GIT on the fly. Prob

Re: general module auditing

2014-07-03 Thread Mark Lawrence
On 04/07/2014 00:09, Rita wrote: here is what I am doing now, egrep 'from|import' *.py | wc -l which is giving me that. But this does not give me the number of times the particular module gets called. I was thinking of adding a logging feature to all of my modules so every time they get called

Re: Get named groups from a regular expression

2014-07-03 Thread Philip Shaw
On 2014-07-01, Florian Lindner wrote: > > Is there a way I can extract the named groups from a regular > expression? e.g. given "(?P\d)" I want to get something > like ["testgrp"]. The match object has an attribute called "groupdict", so you can get the found named groups using match.groupdict.k

Re: threading.Condition.wait() is not catching SIGTERM

2014-07-03 Thread Cameron Simpson
On 03Jul2014 16:43, Roy Smith wrote: [...] Hmmm, I just also noticed what I think is a bug in the docs (https://docs.python.org/2/library/threading.html). It says, "If a call with blocking set to True would block, return False immediately". Isn't that backwards? Doesn't that describe the bloc

Re: threading.Condition.wait() is not catching SIGTERM

2014-07-03 Thread Sangeeth Saravanaraj
On 04-Jul-2014, at 1:43 am, Ned Deily wrote: > In article <17f05a1b-44c8-4f25-afe9-5dbcffb99...@gmail.com>, >> I have the following code which when executed waits to be interrupted by >> SIGINT, SIGTERM or SIGQUIT. When an object is initialized, it creates a >> threading.Condition() and acquir

Re: PEP8 and 4 spaces

2014-07-03 Thread Steven D'Aprano
On Thu, 03 Jul 2014 10:31:04 -0700, Tobiah wrote: > Coworker takes PEP8 as gospel and uses 4 spaces to indent. I prefer > tabs. Boss want's us to unify. Point out to your boss, and your co-worker, that PEP 8 *explicitly* states that it is not compulsory except for the standard library, and

Re: PEP8 and 4 spaces

2014-07-03 Thread Chris Angelico
On Fri, Jul 4, 2014 at 11:02 AM, Steven D'Aprano wrote: > As I understand it, Unix coders tend to prefer spaces, and Windows users > tend to be more comfortable with tabs. This isn't a hard-and-fast rule, > you'll find plenty of exceptions, but it seems to me that Unix tools are > unforgiving of t

Re: PEP8 and 4 spaces

2014-07-03 Thread Steven D'Aprano
On Thu, 03 Jul 2014 21:07:28 +0300, Paul Sokolovsky wrote: > Hello, > > On Fri, 4 Jul 2014 03:38:27 +1000 > Chris Angelico wrote: > >> On Fri, Jul 4, 2014 at 3:31 AM, Tobiah wrote: >> > Coworker takes PEP8 as gospel and uses 4 spaces to indent. I prefer >> > tabs. Boss want's us to unify. >>

Re: PEP8 and 4 spaces

2014-07-03 Thread Chris Angelico
On Fri, Jul 4, 2014 at 11:21 AM, Steven D'Aprano wrote: >> Summing up: if you care about other human beings, use spaces. If you >> don't care about other human beings, you may use tabs, but other human >> beings surely will take how you treat them into account ;-). > > Ha ha, that's funny, I would

Re: PEP8 and 4 spaces

2014-07-03 Thread Roy Smith
In article , Chris Angelico wrote: > On Fri, Jul 4, 2014 at 11:21 AM, Steven D'Aprano > wrote: > >> Summing up: if you care about other human beings, use spaces. If you > >> don't care about other human beings, you may use tabs, but other human > >> beings surely will take how you treat them in

Re: PEP8 and 4 spaces

2014-07-03 Thread Demian Brecht
On Jul 3, 2014 10:31 AM, "Tobiah" wrote: > Just need ammo for when the hammer of code unification comes down. One issue that I've encountered in the past (one of the reasons outside of pep8) that I switched to spaces is when working with libraries other than your own. If you want to stick print s

Re: fixing an horrific formatted csv file.

2014-07-03 Thread flebber
I have taken the code and gone a little further, but I need to be able to protect myself against commas and single quotes in names. How is it the best to do this? so in my file I had on line 44 this trainer name. "Michael, Wayne & John Hawkes" and in line 95 this horse name. Inz'n'out this t

Re: fixing an horrific formatted csv file.

2014-07-03 Thread Gregory Ewing
flebber wrote: so in my file I had on line 44 this trainer name. "Michael, Wayne & John Hawkes" and in line 95 this horse name. Inz'n'out this throws of my capturing correct item 9. How do I protect against this? Use python's csv module to read the file. Don't try to do it yourself; the rule

Re: PEP8 and 4 spaces

2014-07-03 Thread Gregory Ewing
Steven D'Aprano wrote: Disadvantages of tabs: - Many standard Unix/Linux/POSIX tools have a hard time dealing with tabs. I call such tools *broken*, They're not broken, they're just using a different set of conventions. Unix traditionally uses tab characters as a form of space compression. The