Re: Python Data base help
(Apologies for the old thread reviving) On Sun, Oct 09, 2016 at 09:27:11PM +0200, Irmen de Jong wrote: > What is your 'database'? > >From the little information you provided it seems that it is just a text > >file where > every drone measurement is on a line. So simply read every line and check if > the time > entered is in that line, then print it. On the other hand, if your "database" really is just a text file and you want to find the records that match a strict time string there's already a fast native utility for this available: grep (*nix) or findstr (Windows). The advantage being that you could search for more than just the time. It's still limited to only textual matches, not smart matches (e.g., ranges). In the end, a custom program will be more powerful to process the data. Alternatively, if the data is a text file and you want to query it regularly, consider learning a bit about SQL and sqlite3 and import the data into a "real" database first. Then you'll get the full expressive power of a query language and the performance improvements of binary data and indexing (if you tune it right). Regards, -- Brandon McCaig Castopulence Software <https://www.castopulence.org/> Blog <http://www.bambams.ca/> perl -E '$_=q{V zrna gur orfg jvgu jung V fnl. }. q{Vg qbrfa'\''g nyjnlf fbhaq gung jnl.}; tr/A-Ma-mN-Zn-z/N-Zn-zA-Ma-m/;say' -- https://mail.python.org/mailman/listinfo/python-list
Re: Quick way to calculate lines of code/comments in a collection of Python scripts?
(Sorry for the late reply) On Wed, Oct 05, 2016 at 01:56:59PM -0400, Malcolm Greene wrote: > Looking for a quick way to calculate lines of code/comments in a > collection of Python scripts. This isn't a LOC per day per developer > type analysis - I'm looking for a metric to quickly judge the complexity > of a set of scripts I'm inheriting. There is a CPAN module for a Perl application that calculates SLOC. You or somebody else may find it useful for this task... I believe it is packaged for some Linux distros. If applicable you should be able to just install it: sudo aptitude install cloc Otherwise, if you have Perl installed already (e.g., *nix) and already have a CPAN client [configured] it should be relatively easy. cpanm is the most user-friendly client I've used. cpanm App::cloc Alternatively, you can do it with 'cpan' too, but that will typically prompt you 3 million times... There are a few other clients available. Use whatever suits you. You could also fetch the module directly from CPAN and install it manually if so inclined. If you have none of these things (e.g., Windows) you could install the free software Strawberry Perl distribution. It comes with batteries included. If you're lucky cpanm will just work(tm) to install it from there. Hope that helps... Regards, -- Brandon McCaig Castopulence Software <https://www.castopulence.org/> Blog <http://www.bambams.ca/> perl -E '$_=q{V zrna gur orfg jvgu jung V fnl. }. q{Vg qbrfa'\''g nyjnlf fbhaq gung jnl.}; tr/A-Ma-mN-Zn-z/N-Zn-zA-Ma-m/;say' signature.asc Description: Digital signature -- https://mail.python.org/mailman/listinfo/python-list
Re: How coding in Python is bad for you
On Tue, Jan 24, 2017 at 07:31:18PM +, Ben Bacarisse wrote: > The trouble is that I've been programming for so long that I > can't remember what it's like to make block and/or indent > errors. Obviously I make typos but they don't survive more > than a few seconds. Agreed. In very rare circumstances (likely very tired) you might make such a mistake without catching it, but typically you'll catch it during testing, and code review is another chance to catch it. Source control FTW. I think that a lot of these kinds of problems happen to beginners and the beginners make the most noise about how it will be a problem. I initially was against Python's significant white-space, but in hindsight I can see how it saves a bit of typing and is not necessarily any worse off. Hell, considering the code that I have seen in the wild it might even catch some extra errors that become syntax errors! It's not at all rare for indentation to not match in languages that don't require it to at least fit a pattern. I think that an apples to apples comparison of an erroneous indentation level would be comparing a misplaced brace: foo { bar; } baz; wapz. Was that supposed to be "foo { bar; baz; }" or "foo { bar; } baz;" ? That's effectively the same problem that you might have with Python code. The answer? Hopefully it's obvious when looking at the code! If it's not, hopefully source control can tell you. And if you can't be certain, *talk* to somebody. There's no substitute for communication. > In Python the editor could, for example, highlight the block > you are typing in, so as soon as you leave the body of the 'if' > it would stop being marked and the containing code would be > highlighted. Just moving the cursor up and down would show you > what block everything is in. I don't know if any editors help > like this -- that's part of my reason to ask. That's actually a pretty neat idea. I don't think I've ever encoutered an editor that does (or if I have, it has either been too long or so subtle that it doesn't stand out). I think that it is a pretty good idea though. I certainly find it useful to highlight matching braces in editors, but it can be a pain still. I think that highlighting the entire block could be useful. Though I suppose it might be too noisy and distract from what matters? Alternatively, you'd need different levels of indentation to capture nested indentation. That shouldn't be a problem if people are limiting their indentation levels though... Regards, -- Brandon McCaig Castopulence Software <https://www.castopulence.org/> Blog <http://www.bambams.ca/> perl -E '$_=q{V zrna gur orfg jvgu jung V fnl. }. q{Vg qbrfa'\''g nyjnlf fbhaq gung jnl.}; tr/A-Ma-mN-Zn-z/N-Zn-zA-Ma-m/;say' signature.asc Description: Digital signature -- https://mail.python.org/mailman/listinfo/python-list
Re: How coding in Python is bad for you
On Tue, Jan 24, 2017 at 07:50:20PM +, Ben Bacarisse wrote: > I suspect that part of the reason these errors occur is > precisely because they don't matter to the interpreter and > students are doing a lot of self-easement based on "does it > work?" tests. I cringe when I hear "it works"! In particular, because it's often followed by "but I don't know how". I can't even count the number of times I have reviewed code, spotted something questionable, approached the author about it, and heard "but it works!" Well if my analysis is correct it shouldn't so one of us is obviously wrong. Unfortunately, in my experience, they usually expect the conversation to be over after "but it works"... Regards, -- Brandon McCaig Castopulence Software <https://www.castopulence.org/> Blog <http://www.bambams.ca/> perl -E '$_=q{V zrna gur orfg jvgu jung V fnl. }. q{Vg qbrfa'\''g nyjnlf fbhaq gung jnl.}; tr/A-Ma-mN-Zn-z/N-Zn-zA-Ma-m/;say' signature.asc Description: Digital signature -- https://mail.python.org/mailman/listinfo/python-list
Re: How coding in Python is bad for you
On Tue, Jan 24, 2017 at 07:54:30PM -0600, Tim Chase wrote: > The editor I use (vim) doesn't even require me to re-select the range > to shift it. Just using > > >'] > > or > > <'] > > will indent/dedent from the cursor to the line where your paste ended. (O_O) You learn something every day. Thank you. I have been using Vim and vi for probably close to a decade by now, but I still have a lot to learn... But nevertheless hate to go without for even a few seconds. Regards, -- Brandon McCaig Castopulence Software <https://www.castopulence.org/> Blog <http://www.bambams.ca/> perl -E '$_=q{V zrna gur orfg jvgu jung V fnl. }. q{Vg qbrfa'\''g nyjnlf fbhaq gung jnl.}; tr/A-Ma-mN-Zn-z/N-Zn-zA-Ma-m/;say' signature.asc Description: Digital signature -- https://mail.python.org/mailman/listinfo/python-list
Re: Were is a great place to Share your finished projects?
On Fri, Jul 15, 2016 at 10:39:05AM +1000, Steven D'Aprano wrote: > About seven years ago, the senior technical manager at my work chose hg over > git. When he left to go to greener pastures, the dev team took about 30 > seconds to to reverse his decision and migrate to git, after which the > level of VCS-related screw-ups and queries went through the roof. Git used to have much sharper edges than Mercurial, but that is pretty much a thing of the past. With Git you pretty much can't permanently lose history unless you try really, really hard. It'll always be there in the reflog for a period of several days minimum (I think 2 weeks by default?) and if you're worried about it you can configure it to put that off for months or years... On the other hand, I have had Mercurial bugs repeatedly lose work of mine. The kind of bugs that aren't easy to reproduce so nearly impossible to report and nearly impossible to fix. The ecosystem of "extensions" makes this problem inevitable. You depend on extensions, typically third-party extensions for the first few years of their life, for all of the power-user stuff, and the extensions have as much power to corrupt or lose history as the main library does. And of course, they have the potential to alter the behavior of the core library making reporting bugs that much more difficult ("ok, but which extensions, official or unofficial, do you have installed?"). Now instead of one team writing bugs you have N teams writing them in isolation. Combined with their failure to accomodate the distributed development model properly you now have a bunch of incompatible ideas for managing branches and history editing and they still haven't gotten it all right yet (but they're getting closer the more and more they model the design after Git). > To give you an idea of how screwed up things are, even though I'm not one of > the developer team, and have never pushed a thing into the code > repositories (I have pushed into documentation repos), somehow according > to "git blame" I'm responsible for a bunch of code. The user name and email fields are not controlled in either Git or Mercurial so anybody can commit code under your name without you being involved. That would be pretty unprofessional though... I can't imagine Git magically pulling your name out of nowhere when it looks up the author of commits that are responsible for lines of code... Maybe you should report that to the mailing list and get to the bottom of it... I suspect that the explanation has nothing to do with any bugs in Git. Regards, -- Brandon McCaig Castopulence Software <https://www.castopulence.org/> Blog <http://www.bambams.ca/> perl -E '$_=q{V zrna gur orfg jvgu jung V fnl. }. q{Vg qbrfa'\''g nyjnlf fbhaq gung jnl.}; tr/A-Ma-mN-Zn-z/N-Zn-zA-Ma-m/;say' signature.asc Description: Digital signature -- https://mail.python.org/mailman/listinfo/python-list