Re: [Tutor] repeated times
> > >I want to run an .exe file and get the output many times. >> Given that I know that you know about loops I have to >> ask what you see as the problem? > >I want to run it many times and export all the output to a text file. OK, Do you mean you want to run the program multiple times but put the output in the same file? Maybe at hourly intervals say? The schedulling of the jobs will depend on what OS you are using. Is it Linux/Unix or Windows? Writing to the same file should be as simple as using the append flag when opening the file. Or am I still not understanding what you want? Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Help with setting path
hi, I'm a beginner. Can someone help me with the installation? I've read several tutorials, possess a couple of books, and have followed the instructions, but I stil face a problem. None of the online tutorials address this issue in depth maybe because it could be too simple. I'm having problems setting my path and having the python interpreter recognize my modules in my python folders. My python path browser is showing that the main python directory is listed, along with my subdirectories like lib, and work. I've set python PATH in windows too. However, when I try to run the program, which is stored in pthon25/work using IDLE, I get a traceback error. I can run the program in dos though and it also seems to work when I open the file using the menu, and then select the run button in pythonwin. I'd greatly appreciate it if someone could guide me with a proper setup of path. Thanks. __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help with setting path
"sith ." <[EMAIL PROTECTED]> wrote > However, when I try to run the program, which is stored > in pthon25/work using IDLE, I get a traceback error. Cannyou send us the error, that helps a lot in trying to debug. Cut n paste the entire error text. > I can run the program in dos though and it also seems That suggests that there is nothing wroing with your PATH settings. They mainly affect how it works under DOS. It may be that IDLE is simply giving you a traceback for sys.exit() which it does because it catches the exit and prevents you from dropping out of IDLE itself. Let us see the error traceback and we can decide. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] List comp question
I am building a list like this: tree = [] for top in tops: l2 = level2(top) if l2: tree.append((top, l2)) I would really like to turn this into a list comprehension: tree = [ (top, level2(top)) for top in tops if level2(top) ] but the call to level2() is expensive enough that I don't want to repeat it. Is there any way to do this or am I stuck with the (IMO ugly) loop form? Kent who actually does have a question occasionally :-) ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] List comp question
Decorate level2 with a decorator that caches: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/425445 --Michael On 11/1/07, Kent Johnson <[EMAIL PROTECTED]> wrote: > > I am building a list like this: > > tree = [] > for top in tops: > l2 = level2(top) > if l2: > tree.append((top, l2)) > > I would really like to turn this into a list comprehension: > > tree = [ (top, level2(top)) for top in tops if level2(top) ] > > but the call to level2() is expensive enough that I don't want to repeat > it. Is there any way to do this or am I stuck with the (IMO ugly) loop > form? > > Kent > > who actually does have a question occasionally :-) > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > -- Michael Langford Phone: 404-386-0495 Consulting: http://www.TierOneDesign.com/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] subprocess stdout nohup question
When I run a python script with nohup, my print statements are not being written to nohup.out, why is that? Should nohup.out capture all stdout statements? -- Configuration `` Plone 2.5.3-final, CMF-1.6.4, Zope (Zope 2.9.7-final, python 2.4.4, linux2), Five 1.4.1, Python 2.4.4 (#1, Jul 3 2007, 22:58:17) [GCC 4.1.1 20070105 (Red Hat 4.1.1-51)], PIL 1.1.6 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help with setting path
How did you install Python? I've found that the Enthought distribution to be the simplest and quickest way to get up and running while having good functionality (i.e. scipy up and running). Active state releases a good version as well... and thus, welcome, to what in my humble opinion (a newbie as well) is the hell of Python... that is, there is a seemingly endless number of possible ways to configure the installations. But that's the hell, the rest is grreat! So it's a sugar coated hell once you get up and running ;) Good luck. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] List comp question
Kent Johnson wrote: > I am building a list like this: > > tree = [] > for top in tops: > l2 = level2(top) > if l2: > tree.append((top, l2)) > > I would really like to turn this into a list comprehension: > > tree = [ (top, level2(top)) for top in tops if level2(top) ] > > but the call to level2() is expensive enough that I don't want to repeat > it. Is there any way to do this or am I stuck with the (IMO ugly) loop form? > Just playing around here, but would this work and be better tree = [ pair for pair in [ (top, level2(top)) for top in tops ] if pair[1] ] ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] List comp question
"Kent Johnson" <[EMAIL PROTECTED]> wrote > I would really like to turn this into a list comprehension: > > tree = [ (top, level2(top)) for top in tops if level2(top) ] > > but the call to level2() is expensive enough that I don't want to > repeat > it. Is there any way to do this or am I stuck with the (IMO ugly) > loop form? Not sure how this would work but you might be able to use a temporary global var to hold the result if you wrap it in a function (I suspect this is similar to the decorator suggestion, just more explicit... Pseudo code tvar = None def lev2(t): global tvar tvar = level2(t) return tvar tree = [ (top, tvar) for top in tops if lev2(top) ] Is that any better than the loop? I'm not sure it is... unless you have to build the list in multiple places. Do I like relying on side effects of functions? No. HTH, Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help with setting path
"John" <[EMAIL PROTECTED]> wrote > How did you install Python? On Windoze I use the ActiveState version and then manually set the PATH and PYTHONPATH environment variables > Active state releases a good version as well... and thus, welcome, > to what > in my humble opinion (a newbie as well) is the hell of Python... > that is, > there is a seemingly endless number of possible ways to configure > the > installations. That's the hell of Open Source software. The basic package is there to use but lots of people think they know how to "improve" it and so you get multiple versions. On a bigger scale just look at the myriad of Linux distros out there. You just have to ask youself: Is the pain worth the gain? If the answer is yes find a distro that suits and stick to it. Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Installation
Hello all,I will try to make this quick.Since the installation topic is open I have a question. Bear in mind "newbie alert" I have 2.5 on windows M.E. and all is well,but if I try to use a dos box I get bad command etc. but if I use the python dos everything works.Is this normal or do I need to have windows dos in the path somehow?Or does it really matter,it's all the same dos isnt it.And how do you clear the Tkinter window.I must say that much of what I read here is beyond me NOW but it is like chess you are only as good as your opponents! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Help with setting path
Hi, Thanks for your input. I'm presently downloading enthought python - no asian mirror, so it'll take a really long time to download even on broadband at 10kbps) - but I don't think it's a distro problem. I'm probably not doing it right as I'm now using IDLE and still have the same problem. For example, here is the traceback for a simple file I made and tried to run in IDLE: # test.py x = 1 + 1 print x In IDLE, I tried to run it by typing test.py Traceback (most recent call last): File "", line 1, in test.py NameError: name 'test' is not defined However, when I open the file in IDLE using the menu, and then run it also from the menu, it works. Am I not calling the program properly? p.s. Wonder why word wrap didn't work on my first post. Thanks to all who scrolled. __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor