Re: [Tutor] Logging with proper format
Kent Johnson wrote: > Eric Brunson wrote: > >> claxo wrote: >> >>> dont indent the line after '\', that means 0 indent >>> >>> s = 'hello\ >>> boy' >>> >>> >> Or, arguably better: >> >> s = '''hello >> boy''' >> > > That is a different string, it contains a newline, the original does not: > > In [20]: s = 'hello\ > : boy' > In [21]: s2 = '''hello > : boy''' > In [22]: s==s2 > Out[22]: False > In [23]: print s > helloboy > In [24]: print s2 > hello > boy > You're right. I though he was looking to embed the newline, but I read it wrong. > > Kent > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Logging with proper format
On Sunday 07 October 2007 22:32, Kent Johnson wrote: > Eric Brunson wrote: > > claxo wrote: > >> dont indent the line after '\', that means 0 indent > >> > >> s = 'hello\ > >> boy' > > > > Or, arguably better: > > > > s = '''hello > > boy''' > And there is even a third way:-) >>> s = "hello " \ ... "world." >>> s 'hello world.' Two strings that are adjacent to each other, are concatenated into one string; like in C++. Regards, Eike. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Logging with proper format
> logger.info("Checked %s records in %s seconds, yielding an average of > \ > %s seconds per record." % (len(self.data), duration, avgquery) ) ^ Remove these spaces. It makes the source code look weird, but the output will be correct. Alan ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Logging with proper format
Eric Brunson wrote: > claxo wrote: >> dont indent the line after '\', that means 0 indent >> >> s = 'hello\ >> boy' >> > > Or, arguably better: > > s = '''hello > boy''' That is a different string, it contains a newline, the original does not: In [20]: s = 'hello\ : boy' In [21]: s2 = '''hello : boy''' In [22]: s==s2 Out[22]: False In [23]: print s helloboy In [24]: print s2 hello boy Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Logging with proper format
wormwood_3 wrote: > Hello tutors, > > I am adding logging to a program I am writing. I have some messages I want to > log that are rather long. The problem I am running into is that when the line > is more than the 80 character line recommendation and I split it across 2 > lines with "\", the output is affected. > > Example code: > > logger.info("Checked %s records in %s seconds, yielding an average of > \ > %s seconds per record." % (len(self.data), duration, avgquery) ) <- this is white space in your string! Try this: logger.info("Checked %s records in %s seconds, yielding an \ average of \ %s seconds per record." % (len(self.data), duration, avgquery) ) Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Logging with proper format
claxo wrote: > dont indent the line after '\', that means 0 indent > > s = 'hello\ > boy' > Or, arguably better: s = '''hello boy''' > > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Logging with proper format
dont indent the line after '\', that means 0 indent s = 'hello\ boy' ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Logging with proper format
Sent this almost an hour ago, did not get it from the list yet. No idea why, but sending again... -- Hello tutors, I am adding logging to a program I am writing. I have some messages I want to log that are rather long. The problem I am running into is that when the line is more than the 80 character line recommendation and I split it across 2 lines with "\", the output is affected. Example code: logger.info("Checked %s records in %s seconds, yielding an average of \ %s seconds per record." % (len(self.data), duration, avgquery) ) The current output: 2007-10-07 14:49:42,902 - ipinfo - INFO - Checked 4 records in 0.0698790550232 seconds, yielding an average of 0.0174697637558 seconds per record. Desired output would be: 2007-10-07 14:49:42,902 - ipinfo - INFO - Checked 4 records in 0.0698790550232 seconds, yielding an average of 0.0174697637558 seconds per record. So what is the best way to break long code lines and still preserve desired output? Thanks, Sam ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Logging with proper format
Hello tutors, I am adding logging to a program I am writing. I have some messages I want to log that are rather long. The problem I am running into is that when the line is more than the 80 character line recommendation and I split it across 2 lines with "\", the output is affected. Example code: logger.info("Checked %s records in %s seconds, yielding an average of \ %s seconds per record." % (len(self.data), duration, avgquery) ) The current output: 2007-10-07 14:49:42,902 - ipinfo - INFO - Checked 4 records in 0.0698790550232 seconds, yielding an average of 0.0174697637558 seconds per record. Desired output would be: 2007-10-07 14:49:42,902 - ipinfo - INFO - Checked 4 records in 0.0698790550232 seconds, yielding an average of 0.0174697637558 seconds per record. So what is the best way to break long code lines and still preserve desired output? Thanks, Sam ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor