Re: IDE+hg
welcome continue python (naturally not java:) less wind and less komdo since the 2 are unavailible, or I add button to drPython,Eric,Boa,PIDA alternatively oldschool emacs for this all natural function you make so difficult. -- http://mail.python.org/mailman/listinfo/python-list
datetime.datetime. or datetime. ?
Hello, my basic question is which recommendation is after slight restructuring datetime.datetime to datetime Both works but only one should be chosen probably adjust my package to comply to dependencies. Spec integrated code where datetime.datetime.now() refactored to datetime.now() set rather from datetime import datetime, timedelta than import datetime or no matter and completely flexible (then why gae error that datetime.datetime wasn't datetime?) Naturally better not to customize external dependencies but seemingly impossible to use both for a little xmpp project. Thanks with best regards -- http://mail.python.org/mailman/listinfo/python-list
Re: The rap against "while True:" loops
Russ P. wrote: > On Oct 10, 1:15pm, kj wrote: > > I'm coaching a group of biologists on basic Python scripting. One > > of my charges mentioned that he had come across the advice never > > to use loops beginning with "while True". Of course, that's one > > way to start an infinite loop, but this seems hardly a sufficient > > reason to avoid the construct altogether, as long as one includes > > an exit that is always reached. (Actually, come to think of it, > > there are many situations in which a bona fide infinite loops > > (typically within a try: block) is the required construct, e.g. > > when implementing an event loop.) > > > > I use "while True"-loops often, and intend to continue doing this > > "while True", but I'm curious to know: how widespread is the > > injunction against such loops? Has it reached the status of "best > > practice"? > > Never, ever use "while True". It's an abomination. The correct form is > "while 1". equivalently appears doable with for statement too, but not C-style for (;;), however like this from itertools import count for a in (2*b in itertools.count() if b**2 > 3): doThis() sleep(5) doThat() best regards, NR -- http://mail.python.org/mailman/listinfo/python-list
Re: The rap against "while True:" loops
On Oct 19, 2:51 am, Hendrik van Rooyen wrote: > On Sunday, 18 October 2009 11:31:19 Paul Rubin wrote: > > > Hendrik van Rooyen writes: > > > Standard Python idiom: > > > > if key in d: > > > d[key] += value > > > else: > > > d[key] = value > > > The issue is that uses two lookups. If that's ok, the more usual idiom is: > > > d[key] = value + d.get(key, 0) > > I was actually just needling Aahz a bit. The point I was trying to make > subliminally, was that there is a relative cost of double lookup for all > cases versus exceptions for some cases. - Depending on the frequency > of "some", I would expect a breakeven point. > > - Hendrik Looks similar to this idiomrelated dummyflag and formhandling edit I try understand some time whether it matters, default=False, same output, later chosen of nothing else to avoid casting since all inputs are text and no input is boolean: view=db.BooleanProperty(default=False,verbose_name="view") #view = not boo(self.request.get('invisible')) view = self.request.get('invisible',None) is not None Easier to keep things positive the longest we can so that above rather handles variable 'visible' than 'invisible' since double negatives, triple negatives or more unintelligibilize. Hence a 3rd way, all positive, shall easify readability, perhaps switch default from false to true. -- http://mail.python.org/mailman/listinfo/python-list
IDE+hg
Dear experts, Since no py IDE I found has easy hg access. IDEs PIDA and Eric claim Mercurial support not found i.e. buttons to clone, commit and push to repositories to define dev env dvcs, editor and deployment all in 1. I tested Boa Constructor, dr Python, Eric and PIDA none of which has other than commandline access to Mercurial which is faster bound to button. The editor Eric claims "Mercurial support" and no obvious (button or plugin) availability, same with dr Python. Mercurial support these IDEs claim may mean that it's compatible and you must add the hg button customizing the editor. programatically. If you know a good light IDE with hg, please inform. Topic handled earlier, still undecided http://groups.google.com/group/google-appengine-python/browse_thread/... Thanks in advance Niklas Rosencrantz -- http://mail.python.org/mailman/listinfo/python-list
Re: IDE+hg
On Nov 23, 11:37 pm, "Rhodri James" wrote: > On Mon, 23 Nov 2009 19:20:27 -0000, NiklasRTZ wrote: > > Dear experts, > > Since no py IDE I found has easy hg access. IDEs PIDA and Eric claim > > Mercurial support not found i.e. buttons to clone, commit and push to > > repositories to define dev env dvcs, editor and deployment all in 1. > > I don't really understand this urge to cram everything into a single > program, since that inevitably leads to compromises that will compromise > just how much of Mercurial's useful and interesting functionality you can > get at. Still, if you really must, Emacs (and presumably vim) seems to be > capable of working with most source control systems. > > -- > Rhodri James *-* Wildebeest Herder to the Masses Obvious explainations are commandline is slower and IDEs claim support (Eric) which may mean it's up2 programmer to add and enable the ui. Or any binding to enable 1 ui. Emacs sure can. Thank you -- http://mail.python.org/mailman/listinfo/python-list
Re: IDE+hg
On Nov 24, 2:35 pm, Gerhard Häring wrote: > Rhodri James wrote: > > On Mon, 23 Nov 2009 19:20:27 -, NiklasRTZ wrote: > > >> Dear experts, > >> Since no py IDE I found has easy hg access. IDEs PIDA and Eric claim > >> Mercurial support not found i.e. buttons to clone, commit and push to > >> repositories to define dev env dvcs, editor and deployment all in 1. > > > I don't really understand this urge to cram everything into a single > > program, since that inevitably leads to compromises that will compromise > > just how much of Mercurial's useful and interesting functionality you > > can get at. Still, if you really must, Emacs (and presumably vim) seems > > to be capable of working with most source control systems. > > I prefer the commandline tools, too. > > FWIW, Eclipse supports Mercurial > throughhttp://www.vectrace.com/mercurialeclipse/ > > -- Gerhard Good just Eclipse is too much and tested 4,5... python IDE where non can hg. Just 2 or 3 buttons to drPython with script enables it. -- http://mail.python.org/mailman/listinfo/python-list
Re: IDE+hg
On Nov 24, 3:13 pm, Richard Riley wrote: > Gerhard Häring writes: > > Rhodri James wrote: > >> On Mon, 23 Nov 2009 19:20:27 -, NiklasRTZ wrote: > > >>> Dear experts, > >>> Since no py IDE I found has easy hg access. IDEs PIDA and Eric claim > >>> Mercurial support not found i.e. buttons to clone, commit and push to > >>> repositories to define dev env dvcs, editor and deployment all in 1. > > >> I don't really understand this urge to cram everything into a single > >> program, since that inevitably leads to compromises that will > >> compromise > > Huh? Cram what? Nothing is crammed into anything. The IDE/Editor is > merely programmed to hook into the external tools > > >> just how much of Mercurial's useful and interesting functionality you > >> can get at. Still, if you really must, Emacs (and presumably vim) seems > >> to be capable of working with most source control systems. > > > I prefer the commandline tools, too. > > > FWIW, Eclipse supports Mercurial through > >http://www.vectrace.com/mercurialeclipse/ > > > -- Gerhard > > Why would you prefer the command line tools in a shell when the same > tools can be used in a way which makes navigating the output so much > easier? It strikes me as a kind of intransigence. it's a common > misconception that IDEs use their own tools all the time. They > don't. They integrate the very same tools. e.g Why the hell would I drop > to a command line to diff a file with a back version in GIT when I can > do the same in the buffer in emacs with a single hot key? Why would I > pipe the output of compile into a file then open that file when a single > hot key can fire off the SAME compiler and then list the errors in an > emacs buffer and another hot key can take me directly to the source > lines in question? Living in the past has its mements, but really. > > e.g I have pylint working live in python buffers. Big time > saver. Similar with C. true. While not many programmers lint the code. -- http://mail.python.org/mailman/listinfo/python-list
Re: IDE+hg
On Nov 25, 7:28 am, alex23 wrote: > NiklasRTZ wrote: > > no py IDE I found has easy hg access. > > ActiveState's Komodo IDE has support for CVS, Perforce, subversion, > bazaar, git and mercurial. unavailable via synaptic ubuntu karmic repos, presuming its commercially bound like wing. Boa constructor, PIDA, Eric, drPython are 4 where all should be configurable for obvious reasons + I like it. thanks for anyway prompt reply my friend -- http://mail.python.org/mailman/listinfo/python-list
Re: IDE+hg
On Nov 24, 5:47 pm, "Günther Dietrich" wrote: > NiklasRTZ wrote: > >Since no py IDE I found has easy hg access. > > Obviously, you didn't try Eclipse with PyDev (<http://www.pydev.org>) > and Mercurial Eclipse (<http://www.vectrace.com/mercurialeclipse/>) > plugins. > This combination is also available stuffed into one package as > 'EasyEclipse for Python' (<http://www.easyeclipse.org>). > > Both, pure Eclipse with plugins installed by hand, and EasyEclipse, are > very convenient for python development. > > Best regards, > > Günther thank you Günther for the most common recommendation I get (Eclipse) sure for C(++) eclipse works too and Netbeans just that pure python obviously closer to this min requirement + fed up with java generally here for decades moving all to python -- http://mail.python.org/mailman/listinfo/python-list
Re: IDE+hg
On Nov 24, 4:09 pm, rustom wrote: > On Nov 24, 8:13 pm, Richard Riley wrote: > > > > > Gerhard Häring writes: > > > Rhodri James wrote: > > >> On Mon, 23 Nov 2009 19:20:27 -, NiklasRTZ wrote: > > > >>> Dear experts, > > >>> Since no py IDE I found has easy hg access. IDEs PIDA and Eric claim > > >>> Mercurial support not found i.e. buttons to clone, commit and push to > > >>> repositories to define dev env dvcs, editor and deployment all in 1. > > > >> I don't really understand this urge to cram everything into a single > > >> program, since that inevitably leads to compromises that will > > >> compromise > > > Huh? Cram what? Nothing is crammed into anything. The IDE/Editor is > > merely programmed to hook into the external tools > > > >> just how much of Mercurial's useful and interesting functionality you > > >> can get at. Still, if you really must, Emacs (and presumably vim) seems > > >> to be capable of working with most source control systems. > > > > I prefer the commandline tools, too. > > > > FWIW, Eclipse supports Mercurial through > > >http://www.vectrace.com/mercurialeclipse/ > > > > -- Gerhard > > > Why would you prefer the command line tools in a shell when the same > > tools can be used in a way which makes navigating the output so much > > easier? It strikes me as a kind of intransigence. it's a common > > misconception that IDEs use their own tools all the time. They > > don't. They integrate the very same tools. e.g Why the hell would I drop > > to a command line to diff a file with a back version in GIT when I can > > do the same in the buffer in emacs with a single hot key? Why would I > > pipe the output of compile into a file then open that file when a single > > hot key can fire off the SAME compiler and then list the errors in an > > emacs buffer and another hot key can take me directly to the source > > lines in question? Living in the past has its mements, but really. > > > e.g I have pylint working live in python buffers. Big time > > saver. Similar with C. > > I sometimes think that the amount of time I spend tweaking emacs to > save my time is more than the time I spend on anything else :-) > > But more seriously: > I tried to use emacs with git recently -- it was a sorry experience. > The git.el that comes with git is broken (on windows) > vc was too old for git like systems > dvc is a joke (its supposedly generic for all Distributed Version > Systems -- but everything is couched in terms of tla. > TLA! For heavens sake! > magit would not run on windows and to use egghttp://github.com/bogolisk/egg > I must read magit docs. > Finally I decided to stay with what Ive used for the last 25 years -- > the shell git is easier via commandline than hg. hg wants gears for simple thing ie. hg commit -m wants spec note, too long to type each commit. -- http://mail.python.org/mailman/listinfo/python-list
The longest word
Newbie hello onwards to the .py manual asks meantime how the longest word gets determined? First word, ok 'a aa aaa aa'[:'a aa aaa aa'.find(' ',1,10)] 'a' rfind is another subset >>> 'a aa aaa aa'[:'a aa aaa aa'.rfind(' ',1,10)] 'a aa aaa' One row should be able. It's a direct word 'a aa aaa...' and can be a variable, it's no big deal it occurs twice still naturally easier if also occured just once. Sincere thanks & regards Niklas -- http://mail.python.org/mailman/listinfo/python-list
Re: The longest word
On Jul 28, 5:02 am, Bearophile wrote: > On Jul 28, 10:26 am, NiklasRTZ wrote: > > > Newbie hello onwards to the .py manual asks meantime how the longest > > word gets determined? > > First word, ok > > 'a aa aaa aa'[:'a aa aaa aa'.find(' ',1,10)] > > Your language is not easy to understand, but I think you want to find > the longest word in a string. > If this is the input string: > txt = "a aa aaa aa" > > There are several ways to do it, I'll show a simple one. > > You can split it into its parts (not having Python a built-in lazy > split yet, you can split it all at once). You can do it with the > string split method. It produces a list of the words, more or less > (but you may have words like "gone,", you may have to take care of > them too, this requires some code. > > Once you have a list of words, you have to take the longest. A simple > way is to replace each word with a tuple that contains the length of > the word and the word itself, then pick the tuple with the highest > length value. But Python allows you to do such operation in a faster > way: you can use the max() function, it has a "key" function that > allows you to remap on the fly what you mean by "max". So you just > have to give it a function (reference) that given the word spits its > length, such function is "len" itself. > > If you instead want to find the position of the longest word the > program gets a little longer. Ask if you need something different. > > Bye, > bearophile Thank you. This seems to work: sorted("a AAA aa a sdfsdfsdfsdf vv".split(' '),lambda a,b: len(a)- len(b))[-1] 'sdfsdfsdfsdf' -- http://mail.python.org/mailman/listinfo/python-list
Re: The longest word
On Jul 28, 7:03 am, Hrvoje Niksic wrote: > Piet van Oostrum writes: > > >>>>>> NiklasRTZ (N) wrote: > > >>N> Thank you. This seems to work: > >>N> sorted("a AAA aa a sdfsdfsdfsdf vv".split(' '),lambda a,b: len(a)- > >>N> len(b))[-1] > >>N> 'sdfsdfsdfsdf' > > > simpler: > > > sorted("a AAA aa a sdfsdfsdfsdf vv".split(' '), key=len)[-1] > > There is no need to sort the sequence to obtain the largest element. > The max function is designed to do exactly that, and also supports the > key argument: > > >>> max("a AAA aa a sdfsdfsdfsdf vv".split(' '), key=len) > > 'sdfsdfsdfsdf' Sincere thanks for strengthening python's superior flexibility. Same function also works around an exploding index problem returning results for longest word where otherwise a word with whitespace crashes the index: all().search(max(q.split(), key=len)).filter("modified >", timeline).filter("published =", True).filter("modified <=", bookmark ).order("-modified").fetch(PAGESIZE+1) Line below crashes the index for words with whitespace (unknown researchable, only occurs live, works with development) all().search(q).filter("modified >", timeline).filter("published =", True).filter("modified <=", bookmark ).order("-modified").fetch (PAGESIZE+1) best regards, Niklas -- http://mail.python.org/mailman/listinfo/python-list
Re: The longest word
There were 3 solutions. Everybody's homework is someone's "what's this?" max('asdasfd faop29v8 asejrhjhw awg5w35g aw3g5aw3g kajhsdkfhlskjdhfakljsdhf awg3 aw3'.split(), key=len) sorted("a AAA aa a sdfsdfsdfsdf vv".split(' '),key=len)[-1] sorted("a AAA aa a vv".split(' '),lambda a,b: len(a)-len(b))[-1] -- http://mail.python.org/mailman/listinfo/python-list