Emile van Sebille | 1 Dec 2011 05:15

Re: pass tuples to user defined function(beginner)

On 11/29/2011 4:44 PM Dave Angel said...

> Any chance you were a customer or vendor of Wang? That 80mb drive,
> dumbed down, for prices around $20k, rings a bell.

That was around 1980 as an ISV -- a Basic Four 610 -- we paid I think 
$50k? retailed at $70k. 8 user, 256k memory, two 35Mb drives that for 
$15k a piece you could get the tech to come out and clip the strap on 
the high order bit of the address space register which would double the 
usable space.  Kinda like getting a discount on a caddy but they deliver 
the car with the back doors welded shut.

Emile

_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Steven D'Aprano | 1 Dec 2011 01:49

Re: is there a better way to organise this code

Norman Khine wrote:
> hello,
> 
> is there a better way to organise this code or optimise it.
> http://pastie.org/2944797

Is that a question? Because I get a syntax error in my brain when I parse it 
without the question mark. <wink>

Sorry to pick on you, but it astonishes me when people don't bother with basic 
English syntax, and yet try writing code where syntax is *much* more 
important. If they can't be bothered with writing correct English, that sends 
all the wrong signals about the quality of their code.

You should write as if you were coding, otherwise people will assume you code 
like you write.

Laziness is one of the cardinal virtues of the programmer, but it has to be 
the right sort of laziness. "Don't reinvent the wheel, use an existing 
library" is good laziness. "Leave out required syntax elements and hope 
someone else will fix them" is not.

Before worrying about optimising the code, how about checking whether it works?

(1) What is CSVFile? It appears to be a class, because you inherit from it, 
but it isn't defined anywhere and isn't a builtin. So your code fails on the 
very first line.

(2) You have a class WorldSchema with no methods, and a top-level function 
get_world that *looks* like a method because it has an argument "self", but 
(Continue reading)

Dave Angel | 1 Dec 2011 02:46

Re: is there a better way to organise this code

On 11/30/2011 07:49 PM, Steven D'Aprano wrote:
> Norman Khine wrote:
>> hello,
>>
>> is there a better way to organise this code or optimise it.
>> http://pastie.org/2944797
>
> Is that a question? Because I get a syntax error in my brain when I 
> parse it without the question mark. <wink>
>
> Sorry to pick on you, but it astonishes me when people don't bother 
> with basic English syntax, and yet try writing code where syntax is 
> *much* more important. If they can't be bothered with writing correct 
> English, that sends all the wrong signals about the quality of their 
> code.
>
> You should write as if you were coding, otherwise people will assume 
> you code like you write.
>
> Laziness is one of the cardinal virtues of the programmer, but it has 
> to be the right sort of laziness. "Don't reinvent the wheel, use an 
> existing library" is good laziness. "Leave out required syntax 
> elements and hope someone else will fix them" is not.
>
> Before worrying about optimising the code, how about checking whether 
> it works?
>
> (1) What is CSVFile? It appears to be a class, because you inherit 
> from it, but it isn't defined anywhere and isn't a builtin. So your 
> code fails on the very first line.
(Continue reading)

Asokan Pichai | 1 Dec 2011 05:26
Favicon

Re: plotting in python

On Thu, Dec 1, 2011 at 2:38 AM, stm atoc <stm.at.oc <at> googlemail.com> wrote:
> Hi there,
>
> I have a question regarding plotting with Python.
>
> I have the following python script:

[SNIPPED]
> plot(Conc[0],z)

[SNIPPED]
> -------So, What would you suggest?

What is the output of
print len(Conc[0]), len(z)

You may insert that line above the plot and see

Asokan Pichai
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

stm atoc | 1 Dec 2011 09:01

Re: plotting in python

The output of the print len(Conc[0]), len(z) is 100 3600.
Now I changed Conc[0] to Conc[1], and the output is: 100 100
But still I need to see from Concentration from 0.

On Thu, Dec 1, 2011 at 5:26 AM, Asokan Pichai <pasokan <at> talentsprint.com> wrote:
> On Thu, Dec 1, 2011 at 2:38 AM, stm atoc <stm.at.oc <at> googlemail.com> wrote:
>> Hi there,
>>
>> I have a question regarding plotting with Python.
>>
>> I have the following python script:
>
> [SNIPPED]
>> plot(Conc[0],z)
>
> [SNIPPED]
>> -------So, What would you suggest?
>
> What is the output of
> print len(Conc[0]), len(z)
>
> You may insert that line above the plot and see
>
> Asokan Pichai
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

(Continue reading)

Peter Otten | 1 Dec 2011 09:48
Picon

Black pastie, was Re: is there a better way to organise this code

Dave Angel wrote:

> I stopped looking at his pastie once the background turned black.  I'd
> have had to copy it elsewhere to even read it.

There is a combobox in the top right corner of the black area where you can 
select a sane theme, e. g. "IDLE".

_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Andreas Perstinger | 1 Dec 2011 10:44
Picon

Re: plotting in python

[Please don't top-post. Put your answers below the text you cite.]

On 2011-12-01 09:01, stm atoc wrote:
> The output of the print len(Conc[0]), len(z) is 100 3600.
> Now I changed Conc[0] to Conc[1], and the output is: 100 100

So, you've changed the line

print len(Conc[0]), len(z)

to

print len(Conc[1]), len(z)

and the only thing that changed in the output is the length of "z" which 
is calculated independently of "Conc" in your script?

This would be very strange.

Does your script run if you use "Conc[1]" (or some other indexes) 
instead of "Conc[0]" when you call the "plot"-function?
If yes, it's very likely that you have the "wrong" data in "Conc[0]". 
But that's impossible to tell without your data file ("ourtest_out.list").

Bye, Andreas
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

(Continue reading)

Andreas Perstinger | 1 Dec 2011 12:39
Picon

Re: plotting in python

[Still top-posting :-( ]

On 2011-12-01 11:13, stm atoc wrote:
> Well, I did also change the line in the python script to this:
>
> plot(Conc[0],z,'r-',label='initial')
> plot(Conc[1],z,'b-',label='after 20s')
>
> to see both Conc[0] and [1].

And did it work?

> I will send the output data attaches to this email  ("ourtest_out.list").
>
> I wonder if this way is fine.

I'm not sure about the policy regarding attachements on this list but I 
think it would have been better to provide a link than attach it.

Anyways, I've reduced your original script, did a test run and it works 
as expected (at least it shows a plot):

import numpy
import matplotlib.pyplot as pyplot

with open("ourtest_out.list", "r") as f:
     z = numpy.array([float(v) for v in f.readline().split()[1:]])

a = numpy.loadtxt("ourtest_out.list", skiprows=3)
N = 100
(Continue reading)

stm atoc | 1 Dec 2011 13:11

Re: plotting in python

For previous script that I have written, I had trouble having one plot
for all data at the same time and I could see two line for Conc[0] and
Conc[1] separately. Now, even I modified Conc = a[1:, N+1:] to  Conc =
a[0:, N+1:], still one plot is created...which is pretty good and no
error!

Thank you so much,
Sue

On Thu, Dec 1, 2011 at 12:39 PM, Andreas Perstinger
<andreas.perstinger <at> gmx.net> wrote:
> [Still top-posting :-( ]
>
>
> On 2011-12-01 11:13, stm atoc wrote:
>>
>> Well, I did also change the line in the python script to this:
>>
>> plot(Conc[0],z,'r-',label='initial')
>> plot(Conc[1],z,'b-',label='after 20s')
>>
>> to see both Conc[0] and [1].
>
>
> And did it work?
>
>
>> I will send the output data attaches to this email  ("ourtest_out.list").
>>
>> I wonder if this way is fine.
(Continue reading)

Robert Sjoblom | 1 Dec 2011 14:15
Picon

Prime Factorization Tool

So I've recently started poking at the Project Euler site, because I
feel that I need to practice writing code. For those of you interested
in solving the problems on your own I advice you to not read this, as
it will spoil the solution.

Problem 3 is this:
The prime factors of 13195 are 5, 7, 13 and 29.

What is the largest prime factor of the number 600851475143 ?

I came up with this pseudocode:
#pseudocode:
#    divide by x until non-prime is found:
#        if not remainder:
#            check if it's prime or not:
#                if not prime: exit loop
#            if not prime: store in variable
#        increment x by 1

Here are the functions I came up with:

def isprime(n):
    if n == 1:
        return False
    for x in range(2, n):
        if n % x == 0:
            return False
    else:
        return True

(Continue reading)


Gmane