Re: [Tutor] Filling orders FIFO

2011-07-16 Thread Izz ad-Din Ruhulessin
Why are you doing it at the low level? Have you consideren using a framework
like Django for example?

2011/7/16 Steven D'Aprano 

> Charles John wrote:
>
>> Hi I am new to python and was wondering what the best way to create an
>> order(bid and offer) queue, then match a bid and offer so that if
>> bid==offer, creates a filled order FIFO in python cgi using mysql? Does
>> anybody have any ideas? It would be greatly appreciated.
>>
>
> The simplest way to use a queue is with a list:
>
> queue = []
>
> You push items onto the queue with queue.append(item) and pop them off with
> queue.pop(0).
>
> However, popping items may be slow if the queue grows very large (tens of
> thousands of items). It might be better to use a deque (double ended queue)
> instead of a list:
>
> from collections import deque
> queue = deque()
>
> To push items onto the right hand side of the queue, then pop them off the
> left hand side:
>
> queue.append(item)
> queue.popleft()
>
>
> As for the rest of your question, I don't understand what you mean by an
> order(bid and offer) queue. Perhaps you could give an example of what you
> mean.
>
>
> --
> Steven
> __**_
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/**mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Program to Predict Chemical Properties and Reactions

2011-07-16 Thread B G
I was just wondering how feasible it would be to build something like the
following:

Brief background, in chemistry, the ionization energy is defined as the
energy required to remove an electron from an atom. The ionization energies
of different elements follow general trends (ie moving left to right across
the periodic table, the ionization energy increases; moving down a group the
ionization energy decreases).

What if I wanted something such that we could type in a few elements and the
program would list the elements in order of increasing ionization energy
(for, say, the first ionization energy).  Any suggestions for going about
this?  I'm trying to brush up on my chemistry and thought the funnest way to
do it would be to build a program that can do this (if it works, I'd also
like to replicate it for level of electronegativity, atomic radius size,
electron affinity, and ionization levels 2, 3, and 4). I have a good idea of
pseudocode that could make this happen in terms of the rules of chemistry,
but having some trouble visualizing the actual implementation.

Thanks!
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Program to Predict Chemical Properties and Reactions

2011-07-16 Thread Emile van Sebille

On 7/16/2011 9:24 AM B G said...

I was just wondering how feasible it would be to build something like
the following:

Brief background, in chemistry, the ionization energy is defined as the
energy required to remove an electron from an atom. The ionization
energies of different elements follow general trends (ie moving left to
right across the periodic table, the ionization energy increases; moving
down a group the ionization energy decreases).

What if I wanted something such that we could type in a few elements and
the program would list the elements in order of increasing ionization
energy (for, say, the first ionization energy).  Any suggestions for
going about this?


Build a dictionary of elements and ionization energies.  Then it's 
simply a matter of looking up the entered elements related values, 
sorting, and displaying.



I'm trying to brush up on my chemistry and thought
the funnest way to do it would be to build a program that can do this
(if it works, I'd also like to replicate it for level of
electronegativity, atomic radius size, electron affinity, and ionization
levels 2, 3, and 4).


Extend the dictionary for the additional attributes.

Emile



I have a good idea of pseudocode that could make
this happen in terms of the rules of chemistry, but having some trouble
visualizing the actual implementation.

Thanks!



___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor



___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] what is 'doubleword alignment'?

2011-07-16 Thread Albert-Jan Roskam
Hello,

What is 'doubleword alignment'? It is used in the following sentence: "Fill up 
the buffer with the correctly encoded numeric and string values, taking care of 
blank padding and doubleword alignment." 

I know that the buffer is comprised of variables of 8-bytes, or multiples 
thereof, each. Numeric variables are 8 bytes, char vars are at least 8 bytes. 
For example, a 10-byte value is 'ceiled' to 18 bytes. This is done with padding 
(spaces, I think). But the aligment part...?

TIA

Cheers!!

Albert-Jan



~~

All right, but apart from the sanitation, the medicine, education, wine, public 
order, irrigation, roads, a fresh water system, and public health, what have 
the Romans ever done for us?

~~___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] what is 'doubleword alignment'?

2011-07-16 Thread Albert-Jan Roskam
Got it already, I think. The word boundary of one chunk of information (in my 
case 8 bytes) is aligned in the computer's memory such that the boundary's 
address is a power of two.

But correct me if I'm wrong ;-)

Cheers!!

Albert-Jan



~~

All right, but apart from the sanitation, the medicine, education, wine, public 
order, irrigation, roads, a fresh water system, and public health, what have 
the Romans ever done for us?

~~

--- On Sat, 7/16/11, Albert-Jan Roskam  wrote:

From: Albert-Jan Roskam 
Subject: [Tutor] what is 'doubleword alignment'?
To: "Python Mailing List" 
Date: Saturday, July 16, 2011, 8:23 PM

Hello,

What is 'doubleword alignment'? It is used in the following sentence: "Fill up 
the buffer with the correctly encoded numeric and string values, taking care of 
blank padding and doubleword alignment." 

I know that the buffer is comprised of variables of 8-bytes, or multiples 
thereof, each. Numeric variables are 8 bytes, char vars are at least 8 bytes. 
For example, a 10-byte value is 'ceiled' to 18 bytes. This is done with padding 
(spaces, I think). But the aligment part...?

TIA

Cheers!!

Albert-Jan



~~

All right, but apart from the sanitation, the medicine, education, wine, public 
order, irrigation, roads, a fresh water system, and public health, what have 
the Romans ever done for us?

~~
-Inline Attachment Follows-

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Program to Predict Chemical Properties and Reactions

2011-07-16 Thread B G
Thanks, Emile-- although I'm not sure I was completely clear about my
objective. What I really meant is that is there a way (via machine learning)
to give the computer a list of rules and exceptions, and then have it
predict based on these rules the ionization energy. Ultimately I'm pretty
interested in the idea of building a program that could predict the expected
result of a chemical reaction, but that's a huge project, so I wanted to
start with something much, much, much smaller and easier.

So I don't really want to manually input ionization energy, atomic radius
size, etc, since I'm not sure how much that would help towards the bigger
goal.  For this project, I already have the ~15 rules that describe trends
on the periodic table.  I want to write a program that, based on these rules
(and the few exceptions to them), could predict the inputs that I want.
 Does this make sense?
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] what is 'doubleword alignment'?

2011-07-16 Thread Alan Gauld

Albert-Jan Roskam wrote:
Got it already, I think. The word boundary of one chunk of information 

> in my case 8 bytes) is aligned in the computer's memory
> such that the boundary's address is a power of two.

Yes, you are right. It means that the storage of your data should always 
be aligned with addressable locations on your computer. The computers 
addressing scheme may not be linear and may not correspond to the "word" 
size in the programming environment. (eg The old Intel 8086 CPU used a 
segment:offset addressing scheme that meant any given memory location 
could be addressed in multiple ways. This was great for clever 
multi-tasking schemes but murder for normal computing because variable 
addresses could easily get messed up and accidentally overwrite other 
bits of data. Other CPUs have other schemes and running 32bit programs 
on 64bit hardware is another example where the two don't match!)



Ensuring that the programming view of memory and the hardware view 
matches up is A Very Good Thing(TM)...


HTH,

Alan G.

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] what is 'doubleword alignment'?

2011-07-16 Thread Dave Angel



--- On Sat, 7/16/11, Albert-Jan Roskam  wrote:

From: Albert-Jan Roskam
Subject: [Tutor] what is 'doubleword alignment'?
To: "Python Mailing List"
Date: Saturday, July 16, 2011, 8:23 PM

Hello,

What is 'doubleword alignment'? It is used in the following sentence: "Fill up the 
buffer with the correctly encoded numeric and string values, taking care of blank padding 
and doubleword alignment."

I know that the buffer is comprised of variables of 8-bytes, or multiples 
thereof, each. Numeric variables are 8 bytes, char vars are at least 8 bytes. 
For example, a 10-byte value is 'ceiled' to 18 bytes. This is done with padding 
(spaces, I think). But the aligment part...?

TIA

Cheers!!

Albert-Jan


On 07/16/2011 04:53 PM, Albert-Jan Roskam wrote:

Got it already, I think. The word boundary of one chunk of information (in my 
case 8 bytes) is aligned in the computer's memory such that the boundary's 
address is a power of two.

But correct me if I'm wrong ;-)

Cheers!!

Albert-Jan





(please put your new text AFTER the text you're quoting.  I moved it in 
this case, but couldn't also get the indentation right)


Not quite.  Doubleword alignment is alignment on an 8byte boundary.  The 
address of such a boundary will be a multiple of 8, not a power of two.


So in your earlier example, the 10 byte string will be padded to 16, not 
18 bytes.  If the buffer starts aligned, then each such element will 
also be aligned.



--

DaveA

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Program to Predict Chemical Properties and Reactions

2011-07-16 Thread Dave Angel

On 07/16/2011 05:32 PM, B G wrote:

Thanks, Emile-- although I'm not sure I was completely clear about my
objective. What I really meant is that is there a way (via machine learning)
to give the computer a list of rules and exceptions, and then have it
predict based on these rules the ionization energy. Ultimately I'm pretty
interested in the idea of building a program that could predict the expected
result of a chemical reaction, but that's a huge project, so I wanted to
start with something much, much, much smaller and easier.

So I don't really want to manually input ionization energy, atomic radius
size, etc, since I'm not sure how much that would help towards the bigger
goal.  For this project, I already have the ~15 rules that describe trends
on the periodic table.  I want to write a program that, based on these rules
(and the few exceptions to them), could predict the inputs that I want.
  Does this make sense?


Neither ordering nor trends will give values for individual items.  So 
unless these rules are much more numerical than the clues you've 
mentioned so far, the problem is clearly impossible.


But I suspect the problem is possible, and that you have much more 
information than you intend to tell us.


--

DaveA

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] what is 'doubleword alignment'?

2011-07-16 Thread Alan Gauld

Dave Angel wrote:

--- On Sat, 7/16/11, Albert-Jan Roskam  wrote:


(in my case 8 bytes) is aligned in the computer's memory such that the 
boundary's address is a power of two.
Not quite.  Doubleword alignment is alignment on an 8byte boundary.  The 
address of such a boundary will be a multiple of 8, not a power of two.


Oops, when I said Albert was "right" I meant in terms of aligning with 
computer memory, I didn't register the "power of two" bit, which is, as 
you say, not correct. Apologies for any confusion caused!



Alan G.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Program to Predict Chemical Properties and Reactions

2011-07-16 Thread Christopher King
Actually maybe not, depending on the complexity of the pattern, but it would
be difficult. You would have to know how much it decreases for every time
you go down or to the right.
If its more complex than that, you may have to program each rule in, not
just enter them in a prompt. I'm assuming none of the rules conflict,
because that would be a problem too.

On Sat, Jul 16, 2011 at 6:06 PM, Dave Angel  wrote:

> On 07/16/2011 05:32 PM, B G wrote:
>
>> Thanks, Emile-- although I'm not sure I was completely clear about my
>> objective. What I really meant is that is there a way (via machine
>> learning)
>> to give the computer a list of rules and exceptions, and then have it
>> predict based on these rules the ionization energy. Ultimately I'm pretty
>> interested in the idea of building a program that could predict the
>> expected
>> result of a chemical reaction, but that's a huge project, so I wanted to
>> start with something much, much, much smaller and easier.
>>
>> So I don't really want to manually input ionization energy, atomic radius
>> size, etc, since I'm not sure how much that would help towards the bigger
>> goal.  For this project, I already have the ~15 rules that describe trends
>> on the periodic table.  I want to write a program that, based on these
>> rules
>> (and the few exceptions to them), could predict the inputs that I want.
>>  Does this make sense?
>>
>>
>>  Neither ordering nor trends will give values for individual items.  So
> unless these rules are much more numerical than the clues you've mentioned
> so far, the problem is clearly impossible.
>
> But I suspect the problem is possible, and that you have much more
> information than you intend to tell us.
>
> --
>
> DaveA
>
>
> __**_
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/**mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Program to Predict Chemical Properties and Reactions

2011-07-16 Thread Dave Angel

On 07/16/2011 07:21 PM, Christopher King wrote:

Actually maybe not, depending on the complexity of the pattern, but it would
be difficult. You would have to know how much it decreases for every time
you go down or to the right.
If its more complex than that, you may have to program each rule in, not
just enter them in a prompt. I'm assuming none of the rules conflict,
because that would be a problem too.

(Your response should always be after the part you're quoting.  There 
are far too many people lately breaking the tradition of these forums)


I certainly wouldn't be entering in "rules" at a prompt.  And I 
seriously doubt if the formulas are as simple as "how much it decreases 
for every time."


Anyway, this is a much different problem than the original post.


--

DaveA
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] how to add directory to python search list

2011-07-16 Thread Surya P.K. Kasturi
OS : Ubuntu Linux
Python Version : 2.6.4

I have some third party modules to be installed in my computer.
So, I want to add the module directory to python search list.

I used :

*>>> import sys*
*>>> sys.path.append('directory address')*
*
*
this could do my work but as soon as I close the terminal and reopen it, I
am not able to find the new directory I have just added.
I used the following code to check.

*>>> sys.path*
*
*
*how do I fix this problem ? *
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] how to add directory to python search list

2011-07-16 Thread Alan Gauld

Surya P.K. Kasturi wrote:

OS : Ubuntu Linux
Python Version : 2.6.4

I have some third party modules to be installed in my computer.
So, I want to add the module directory to python search list.

I used :

*>>> import sys*
*>>> sys.path.append('directory address')*
*
*
this could do my work but as soon as I close the terminal and reopen it, I


You need to add the folder to your PYTHONPATH environment variable.
You usually do this your .login or .profile file.

Python will add the contents of PYTHONPATH to sys.path on startup.

HTH,


Alan G
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] how to add directory to python search list

2011-07-16 Thread Surya P.K. Kasturi
Mr. Gauld

can you tell me in detail how to do this.
I am new to linux.

On Sat, Jul 16, 2011 at 11:48 AM, Alan Gauld wrote:

> Surya P.K. Kasturi wrote:
>
>> OS : Ubuntu Linux
>> Python Version : 2.6.4
>>
>> I have some third party modules to be installed in my computer.
>> So, I want to add the module directory to python search list.
>>
>> I used :
>>
>> *>>> import sys*
>> *>>> sys.path.append('directory address')*
>> *
>> *
>> this could do my work but as soon as I close the terminal and reopen it, I
>>
>
> You need to add the folder to your PYTHONPATH environment variable.
> You usually do this your .login or .profile file.
>
> Python will add the contents of PYTHONPATH to sys.path on startup.
>
> HTH,
>
>
> Alan G
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor