Re: [Tutor] Advise with coding

2016-10-11 Thread Alan Gauld via Tutor
On 11/10/16 10:16, tracey jones-Francis wrote: > Is it possible someone on here can advise me where I am going wrong. Yesm, thats what this list is for but... We need to see code - we can't guess what you did. We need to know what input you used, what output you got and why its not what you expec

[Tutor] Advise with coding

2016-10-11 Thread tracey jones-Francis
Hi I have just started Com Sci in Uni and I am new to coding. I feel pretty inadequate as I am really struggling with the latest tasks. Most of the work is self-directed learning so we need to figure it out ourselves but I am running out of time. Is it possible someone on here can advise me wh

Re: [Tutor] advise on this loop

2009-06-04 Thread Norman Khine
On Thu, Jun 4, 2009 at 3:48 PM, W W wrote: > On Thu, Jun 4, 2009 at 8:29 AM, Norman Khine wrote: >> >> Hello, >> I have the following code, which searches through a directory structure >> such as: >> >> $ tree -L 2 companies >> companies >> |-- aberdeen-airport-ltd >> |   |-- aberdeen-airport-dyc

Re: [Tutor] advise on this loop

2009-06-04 Thread W W
On Thu, Jun 4, 2009 at 8:29 AM, Norman Khine wrote: > Hello, > I have the following code, which searches through a directory structure > such as: > > $ tree -L 2 companies > companies > |-- aberdeen-airport-ltd > | |-- aberdeen-airport-dyce-grampian > | `-- aberdeen-airport-dyce-grampian.meta

[Tutor] advise on this loop

2009-06-04 Thread Norman Khine
Hello, I have the following code, which searches through a directory structure such as: $ tree -L 2 companies companies |-- aberdeen-airport-ltd | |-- aberdeen-airport-dyce-grampian | `-- aberdeen-airport-dyce-grampian.metadata |-- aberdeen-airport-ltd.metadata |-- aberdeen-motor-company-ltd |

Re: [Tutor] advise on using re

2009-02-15 Thread Kent Johnson
On Sun, Feb 15, 2009 at 5:53 AM, Norman Khine wrote: MXlocate = re.compile('^.*preference = (\d*).*exchanger = (.*)$', > On the shell, the command > > $ nslookup -querytype=MX abakuc.com > Server: 193.252.19.3 > Address:193.252.19.3#53 > > Non-authoritative answer: > abakuc.c

[Tutor] advise on using re

2009-02-15 Thread Norman Khine
Hello, What am I doing wrong here. >>> import smtplib, socket, re, os, operator, sys >>> domain = 'abakuc.com' >>> validMXservers = [] >>> MXlocate = re.compile('^.*preference = (\d*).*exchanger = (.*)$', re.IGNORECASE) >>> MXservers = os.popen('nslookup -querytype=MX %s' %domain, 'r') >>> for

Re: [Tutor] Advise...

2005-01-28 Thread Johan Nilsson
Jacob, Apart from all the other comments you received, here are my thoughts. I think you could do one more thing to speed up your calculations and that is to use a more efficient method. The Reimann sum is not a very efficient. One simple method that is rahter popular is Simpson's rule. The

Re: [Tutor] Advise...

2005-01-26 Thread Jacob S.
Thanks everyone! Kent started the suggestion of making a code object, but everyone else seems to have worked their way to it. Beautiful! I only have to call exec once, and it cuts down time considerably. Here is the new code. Jacob Schmidt Please remind me if I've forgotten anything. ### Start #

Re: [Tutor] Advise...

2005-01-26 Thread Alan Gauld
> If the user must be able to enter in the function, then it would be better > to evaluate this once and turn it into some sort of function that you can > call inside the loop (it's the eval that is so expensive). How to do that > depends a lot on how complex the possible functions can be (if they

Re: [Tutor] Advise...

2005-01-26 Thread Danny Yoo
> > There has been alot of talk on this list about using list comprehensions > > lately, and this could be one of those useful places. While I don't > > have time to experiment with real code, I would suggest changing your > > function to look like: > > > > steps = [ min_x + i*delta_x for i in r

Re: [Tutor] Advise...

2005-01-26 Thread Danny Yoo
On Wed, 26 Jan 2005, Bill Kranec wrote: > There has been alot of talk on this list about using list comprehensions > lately, and this could be one of those useful places. While I don't > have time to experiment with real code, I would suggest changing your > function to look like: > > steps = [

Re: [Tutor] Advise...

2005-01-26 Thread Bill Kranec
There has been alot of talk on this list about using list comprehensions lately, and this could be one of those useful places. While I don't have time to experiment with real code, I would suggest changing your function to look like: steps = [ min_x + i*delta_x for i in range(steps) ] totalare

Re: [Tutor] Advise...

2005-01-26 Thread Kent Johnson
There was a discussion about this same question (in the context of graphing a user-supplied function) just a few weeks ago. My suggestion was to use exec to create a real function object that you can call directly; you can read it here: http://mail.python.org/pipermail/tutor/2005-January/034696.h

Re: [Tutor] Advise...

2005-01-26 Thread TJ
What is the function? 3*x*x What is the minimum? 2 What is the maximum? 5 117.000435 Which, considering that it is supposed to be exactly 117, It's darn good. Unfortunately, it also takes about 10 seconds to do all that. Any suggestions? Any advice? TIA Jacob Schmidt Jacob, You can get better acc

RE: [Tutor] Advise...

2005-01-25 Thread Tony Meyer
[Tony Meyer] > If the user must be able to enter in the function, then it > would be better to evaluate this once and turn it into some > sort of function that you can call inside the loop (it's the > eval that is so expensive). I should have included some code that does this: """ from __futur

RE: [Tutor] Advise...

2005-01-25 Thread Tony Meyer
> Anyway, I know the first thing that some of you are going to > say is using eval(). [...] > Which, considering that it is supposed to be exactly 117, > It's darn good. > Unfortunately, it also takes about 10 seconds to do all that. > Any suggestions? Any advice? On my machine your version ta

[Tutor] Advise...

2005-01-25 Thread Jacob S.
Hi all. Long time no see. (About five days, right?) Anyway, I know the first thing that some of you are going to say is using eval(). I don't want a whole guilt trip on security risks and all that. I do not want to share the code with anyone else while it's on my computer, and I sure don't hav