Python 3.1 cx_Oracle 5.0.2 "ImportError: DLL load failed: The specified module could not be found."

2009-11-19 Thread André
Hello,

I'm trying to get Python 3.1 and cx_Oracle 5.02
(cx_Oracle-5.0.2-10g.win32-py3.0.msi) to connect to an Oracle
11.1.0.7.0 database via OraClient10g 10.2.0.3.0 with Pydev
1.5.1.1258496115 in Eclipse 20090920-1017 on Windows XP SP 3 v2002.
The import cx_Oracle line appears as an unresolved import and when I
run the application I get the following error to console:
Traceback (most recent call last):
  File "FILEPATHHERE", line 1, in 
import cx_Oracle
ImportError: DLL load failed: The specified module could not be found.

Apparently the error is caused by cx_Oracle not being able to find the
Oracle client DLLs (oci.dll and others). The client home path and the
client home path bin directory are in the PATH System Variable and
oci.dll is there.

I tried getting the Oracle Instant Client (instantclient-basic-
win32-11.1.0.7.0.zip from 
http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/winsoft.html)
and installing it as directed. I added the instant client path to the
PATH System Variable but that didn't work either.

I have scoured the internet and have not found a solution.

Please help!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: is there any FIX message handle modules in Python?

2009-11-19 Thread Simon Hibbs
On 19 Nov, 05:25, alex23  wrote:
> On Nov 19, 3:21 pm, "Stephen.Wu" <[email protected]> wrote:
>
> > FIX message is the "Financial information Exchange" protocol
> > messages...
> > any 3rd libs we have?
>
> You mean like this one that was the first result when I googled
> 'python "financial information exchange"'?
>
> http://www.quickfixengine.org/

There are no prebuilt Python modules available based on quickfix, at
least that I'm aware of. It has Python bindings available, but you
have to complie it with them yourself from the C++ source.

Simon Hibbs


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python gui builders

2009-11-19 Thread sturlamolden
On 18 Nov, 20:19, Dave Cook  wrote:

> If it's an issue for your project, I suggest wxPython.  It's
> cross-platform, fairly complete, and extensible.  But the API is
> clunky compared to Qt.

Not if we use wxFormBuilder 3.1.
-- 
http://mail.python.org/mailman/listinfo/python-list


Communication between python and wxWidgets.. Help needed...

2009-11-19 Thread Jebagnana Das
Hi Friends,

I want to thank you all for doing a great job.. I seek your
suggestions and valuable guidance regarding two things.

1) I'm using python 3.1.1 and wxWidgets for GUI development in my project ..
I want to have a half-duplex communication between widgets and python(say
passing something from wxWidgets to python and processing there and sending
it back to display the results in widgets). When i googled around i found
that we have to have SWIG or Boost::Python and some other third party
applications to make this to work.. I'm wondering why it's really tough to
establish a communication between the two though wxWidgets which is an
excellent tool is mainly projected as a GUI toolkit especially for c++ and
python and python is described as a powerful scripting language.. Can u
suggest an efficient way by which i could make these two programs to
interact(back and forth) easily??

2) My second question is even if i did that successfully if i want to
convert my project into an executable file how would i do that? (Bcoz. i
will be having two executables or binaries in linux one for python and other
for widgets) Do i need to convert it to lib or dll file with respect to
python and c++ or is there any other way for making a build-script? What are
the tools and libraries needed(like cx-freeze,pyWin32) to accomplish this??

 Please give me some useful links... All of your suggestions are highly
welcomed..

Thanks & Regards,
Jebagnanadas A,
Python-Developer.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: non-copy slices

2009-11-19 Thread tbourden
No I'm well aware that there is no deep copy of the objects and the lists
only keep references to the objects and in essence they have the same
objects in there. But this doesn't mean they are the same list.
Modifications to slices are not written back to the original list.

x = range(5)
y = x[1:3]
y[0] = 13
x[1] == y[0]  --> False

Of course if I modify the object in the slice then the original list will
see the change, but this is not what I was saying. Second and more
importantly it's the performance penalty from allocating a large number of
lists produced from the slices and the copy of the references. islice does
not have this penalty, it should only instantiate a small object that
iterates on the original list.

Themis


On Thu, Nov 19, 2009 at 3:00 AM, Rami Chowdhury wrote:

>
> I'm not sure you're understanding the point others have been making. A
> list item is merely another reference to an existing object -- it
> doesn't copy the object in any way.
>
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: getting properly one subprocess output

2009-11-19 Thread Jean-Michel Pichavant

Nobody wrote:

On Wed, 18 Nov 2009 12:25:14 +0100, Jean-Michel Pichavant wrote:

  
I'm currently inspecting my Linux process list, trying to parse it in 
order to get one particular process (and kill it).

I ran into an annoying issue:
The stdout display is somehow truncated (maybe a terminal length issue, 
I don't know), breaking my parsing.



  

As you can see, to complete process command line is truncated.
Any clue on how to get the full version ?



If you only need it to work on Linux, you can just enumerate 
/proc/[1-9]*/exe or /proc/[1-9]*/cmdline.


Or you can add -ww to "ps" to avoid truncating the output.

Note that the /proc/*/exe report the actual executable. The command line
reported by "ps" (from /proc/*/cmdline) can be modified by the program, so
it doesn't necessarily reflect the program being run.


  
That is what I was searching for. It's in ps man page, I don't know why 
I missed it in the first place.

Thanks.

JM
--
http://mail.python.org/mailman/listinfo/python-list


Re: non-copy slices

2009-11-19 Thread Daniel Stutzbach
On Wed, Nov 18, 2009 at 9:00 PM, Rami Chowdhury wrote:

> I'm not sure you're understanding the point others have been making. A
> list item is merely another reference to an existing object -- it
> doesn't copy the object in any way.
>

It still has to copy the reference, though.  That takes O(n) time if you're
taking a big slice.

--
Daniel Stutzbach, Ph.D.
President, Stutzbach Enterprises, LLC 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: non-copy slices

2009-11-19 Thread Ethan Furman

Please don't top post.  :)

[email protected] wrote:
On Thu, Nov 19, 2009 at 3:00 AM, Rami Chowdhury 
mailto:[email protected]>> wrote:


I'm not sure you're understanding the point others have been making. A
list item is merely another reference to an existing object -- it
doesn't copy the object in any way.

No I'm well aware that there is no deep copy of the objects and the 
lists only keep references to the objects and in essence they have the 
same objects in there. But this doesn't mean they are the same list. 
Modifications to slices are not written back to the original list.


x = range(5)
y = x[1:3]
y[0] = 13
x[1] == y[0]  --> False

Of course if I modify the object in the slice then the original list 
will see the change, but this is not what I was saying. Second and more 
importantly it's the performance penalty from allocating a large number 
of lists produced from the slices and the copy of the references. islice 
does not have this penalty, it should only instantiate a small object 
that iterates on the original list.


Themis


So "shallow copy" == "new label created for existing object".

So is your desired behavior to write back to the original list if your 
sub-list is modified?  In other words, you are creating a window onto an 
existing list?  If not, what would happen when a sublist element was 
modified (or deleted, or appended, or ...)?


~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list


Re: A Good Mailer

2009-11-19 Thread Victor Subervi
On Wed, Nov 18, 2009 at 6:30 PM, Nick Stinemates wrote:

> On Wed, Nov 18, 2009 at 03:27:11PM -0400, Victor Subervi wrote:
> > Hi;
> > I need a good mailer that will enable me to mail email from web forms.
>
> smtplib
>
> > Suggestions?
>
> silly example..
>
> #!/usr/bin/env python
> import smtplib
>
> session = smtplib.SMTP("localhost")
> username = "abc"
> password = "def"
> session.login(username, password) # only if it requires auth
>
> subject = "Hello, "
>
> header = "Subject: %s \r\nContent-type: text/html;
> charset=utf-8\r\n\r\n"
>
> message = "world!"
>
> email_from = "[email protected]"
> email_to = ["[email protected]"]
>
> session.sendmail(email_from, email_to, header+messages)
>
> HTH,
>

Helps a lot! Thanks!
V
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: non-copy slices

2009-11-19 Thread Rami Chowdhury

On Thu, 19 Nov 2009 02:39:42 -0800,  wrote:


Second and more
importantly it's the performance penalty from allocating a large number  
of

lists produced from the slices and the copy of the references.


Ah, I see what you were getting at -- thanks for clarifying.



On Thu, Nov 19, 2009 at 3:00 AM, Rami Chowdhury  
wrote:




I'm not sure you're understanding the point others have been making. A
list item is merely another reference to an existing object -- it
doesn't copy the object in any way.






--
Rami Chowdhury
"Never attribute to malice that which can be attributed to stupidity" --  
Hanlon's Razor

408-597-7068 (US) / 07875-841-046 (UK) / 0189-245544 (BD)
--
http://mail.python.org/mailman/listinfo/python-list


Python Will Not Send Email!!

2009-11-19 Thread Victor Subervi
Hi;
I created this testMail.py file as root:

#!/usr/bin/env python
import smtplib
session = smtplib.SMTP("localhost")
subject = "Hello, "
header = "Subject: %s \r\nContent-type: text/html; charset=utf-8\r\n\r\n"
message = "world!"
email_from = "[email protected]"
email_to = ["[email protected]"]
session.sendmail(email_from, email_to, header+messages)

[r...@13gems globalsolutionsgroup.vi]# chmod 755 testMail.py
[r...@13gems globalsolutionsgroup.vi]# python testMail.py
Traceback (most recent call last):
  File "testMail.py", line 2, in ?
import smtplib
  File "/usr/lib64/python2.4/smtplib.py", line 49, in ?
from email.base64MIME import encode as encode_base64
ImportError: No module named base64MIME

What gives??
TIA,
Victor
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Will Not Send Email!!

2009-11-19 Thread Victor Subervi
On Thu, Nov 19, 2009 at 11:28 AM, Victor Subervi wrote:

> Hi;
> I created this testMail.py file as root:
>
> #!/usr/bin/env python
> import smtplib
> session = smtplib.SMTP("localhost")
> subject = "Hello, "
> header = "Subject: %s \r\nContent-type: text/html; charset=utf-8\r\n\r\n"
> message = "world!"
> email_from = "[email protected]"
> email_to = ["[email protected]"]
> session.sendmail(email_from, email_to, header+messages)
>
> [r...@13gems globalsolutionsgroup.vi]# chmod 755 testMail.py
> [r...@13gems globalsolutionsgroup.vi]# python testMail.py
> Traceback (most recent call last):
>   File "testMail.py", line 2, in ?
> import smtplib
>   File "/usr/lib64/python2.4/smtplib.py", line 49, in ?
> from email.base64MIME import encode as encode_base64
> ImportError: No module named base64MIME
>
> What gives??
> TIA,
> Victor
>
PS Python 2.4 on CentOS
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python and web pages

2009-11-19 Thread Gerhard Häring
Daniel Dalton wrote:
> Hi,
> 
> Here is my situation:
> I'm using the command line, as in, I'm not starting gnome or kde (I'm on
> linux.)
> I have a string of text attached to a variable,. So I need to use one of
> the browsers on linux, that run under the command line, eg. lynx,
> elinks, links, links2 and do the following.

No, you don't need any text mode browser. It's much easier to do with
modules from the Python standard library.

> 1. Open a certain web page and find the first text box on the page, and
> put this text into the form.

I assume you know HTML and HTTP.

You can use urllib or urllib2 to submit the form.

> 2. Press the submit button, and wait for the result page to load.
> 3. Click on the 15th link down the page.

You will then get the returned HTML from a function and you will have to
parse it for the link you're interested in. There are many approaches to
get there. Manual parsing, regular expressions or one of the XML parsers
in the standard library (etree is the easiest).

> So, how do I do this, can anyone point me to some docs or modules that
> may help out here?

While all of this may seem overwhelming at first, I guess the solution
can be written in 20 - 30 lines of code.

-- Gerhard

-- 
http://mail.python.org/mailman/listinfo/python-list


make two tables having same orders in both column and row names

2009-11-19 Thread Ping-Hsun Hsieh
Hi,

I would like to compare values in two table with same column and row names, but 
with different orders in column and row names.
For example, table_A in a file looks like the follows:
AA100   AA109   AA101   AA103   AA102
BB1 2   9   2.3 1   28
BB3 12  9   2.3 1   28
BB9 0.5 2   2.3 1   28
BB2 2   9   21  1   20

Table_B in the other file looks like the follows:
AA101   AA109   AA100   AA103   AA102
BB1 2   9   2.3 2   28
BB2 2   9   2.3 1   28
BB9 2   9   2.3 1   28
BB3 2   2   2   1   28

Can anyone give an efficient way to make the two tables having same orders in 
column and row names so I can easily and correctly compare the values in 
positions?

Thanks,
PingHsun

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Writing a Carriage Return in Unicode

2009-11-19 Thread Doug

Hi! Thanks for clearing this up!!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Communication between python and wxWidgets.. Help needed...

2009-11-19 Thread Jonas Geiregat


Op 19-nov-09, om 09:42 heeft Jebagnana Das het volgende geschreven:


Hi Friends,

I want to thank you all for doing a great job.. I  
seek your suggestions and valuable guidance regarding two things.


1) I'm using python 3.1.1 and wxWidgets for GUI development in my  
project .. I want to have a half-duplex communication between  
widgets and python(say passing something from wxWidgets to python  
and processing there and sending it back to display the results in  
widgets). When i googled around i found that we have to have SWIG or  
Boost::Python and some other third party applications to make this  
to work.. I'm wondering why it's really tough to establish a  
communication between the two though wxWidgets which is an excellent  
tool is mainly projected as a GUI toolkit especially for c++ and  
python and python is described as a powerful scripting language..  
Can u suggest an efficient way by which i could make these two  
programs to interact(back and forth) easily??





For your first question check out: wx.lib.pubsub: 
http://www.wxpython.org/docs/api/wx.lib.pubsub-module.html

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Will Not Send Email!!

2009-11-19 Thread Carsten Haese
Victor Subervi wrote:
> Hi;
> I created this testMail.py file as root:
> 
> #!/usr/bin/env python
> import smtplib
> session = smtplib.SMTP("localhost")
> subject = "Hello, "
> header = "Subject: %s \r\nContent-type: text/html; charset=utf-8\r\n\r\n"
> message = "world!"
> email_from = "[email protected]"
> email_to = ["[email protected] "]
> session.sendmail(email_from, email_to, header+messages)
> 
> [r...@13gems globalsolutionsgroup.vi ]#
> chmod 755 testMail.py
> [r...@13gems globalsolutionsgroup.vi ]#
> python testMail.py
> Traceback (most recent call last):
>   File "testMail.py", line 2, in ?
> import smtplib
>   File "/usr/lib64/python2.4/smtplib.py", line 49, in ?
> from email.base64MIME import encode as encode_base64
> ImportError: No module named base64MIME
> 
> What gives??

Do you have a file called "email.py" in your current directory or
anywhere else on Python's path outside of the standard library? If so,
it's hiding the real email module from your script and you'll need to
get rid of "your" email.py by renaming or moving it.

--
Carsten Haese
http://informixdb.sourceforge.net

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: non-copy slices

2009-11-19 Thread Themis Bourdenas
On Thu, Nov 19, 2009 at 2:44 PM, Ethan Furman  wrote:

> Please don't top post.  :)
>
> So "shallow copy" == "new label created for existing object".
>
> So is your desired behavior to write back to the original list if your
> sub-list is modified?  In other words, you are creating a window onto an
> existing list?  If not, what would happen when a sublist element was
> modified (or deleted, or appended, or ...)?
>
> ~Ethan~
> --
> http://mail.python.org/mailman/listinfo/python-list
>

Yes a window / view on the existing list describes it best. So every
modification you make in this view is actually modifying the original list
accordingly. Blist that was suggested in a previous email in the thread
seems lightweight but it does create a new list when a modification is made.
In any case, I've already implemented the object myself and I can post it if
you care to have a look, but I was just wondering if there was already
something in the standard library.

Themis
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: mechanize login problem with website

2009-11-19 Thread elca



elca wrote:
> 
> Hello
> 
> I'm making auto-login script by use mechanize python.
> 
> Before I was used mechanize with no problem, but http://www.gmarket.co.kr
> in this site I couldn't make it .
> 
> whenever i try to login always login page was returned even with correct
> gmarket id , pass, i can't login and I saw some suspicious message
> 
> "top.location.reload();"
> 
> I think this related with my problem, but don't know exactly how to handle
> .
> 
> i was upload my script in here
> 
> # -*- coding: cp949 -*-
> from lxml.html import parse, fromstring
> import sys,os
> import mechanize, urllib
> import cookielib
> import re
> from BeautifulSoup import BeautifulSoup,BeautifulStoneSoup,Tag
> 
> try:
> 
> params = urllib.urlencode({'command':'login',
>'url':'http%3A%2F%2Fwww.gmarket.co.kr%2F',
>'member_type':'mem',
>'member_yn':'Y',
>'login_id':'tgi177',
>'image1.x':'31',
>'image1.y':'26',
>'passwd':'tk1047',
>'buyer_nm':'',
>'buyer_tel_no1':'',
>'buyer_tel_no2':'',
>'buyer_tel_no3':''
> 
>})
> rq = mechanize.Request("http://www.gmarket.co.kr/challenge/login.asp";)
> rs = mechanize.urlopen(rq)
> data = rs.read()
> 
> 
> logged_in = r'input_login_check_value'  in data   
>  
> if logged_in:
> print ' login success !'  
> rq = mechanize.Request("http://www.gmarket.co.kr";) 
> rs = mechanize.urlopen(rq)
> data = rs.read()   
> print data  
>  
> else:
> print 'login failed!'
> pass
> quit()  
> except:
> pass
> 
> 
> if anyone can help me much appreciate thanks in advance
> 
> 
i was updated my script source
-- 
View this message in context: 
http://old.nabble.com/mechanize-login-problem-with-website-tp26420202p26421474.html
Sent from the Python - python-list mailing list archive at Nabble.com.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Communication between python and wxWidgets.. Help needed...

2009-11-19 Thread Dave Angel

Jonas Geiregat wrote:


Op 19-nov-09, om 09:42 heeft Jebagnana Das het volgende geschreven:


Hi Friends,

I want to thank you all for doing a great job.. I 
seek your suggestions and valuable guidance regarding two things.


1) I'm using python 3.1.1 and wxWidgets for GUI development in my 
project .. I want to have a half-duplex communication between widgets 
and python(say passing something from wxWidgets to python and 
processing there and sending it back to display the results in 
widgets). When i googled around i found that we have to have SWIG or 
Boost::Python and some other third party applications to make this to 
work.. I'm wondering why it's really tough to establish a 
communication between the two though wxWidgets which is an excellent 
tool is mainly projected as a GUI toolkit especially for c++ and 
python and python is described as a powerful scripting language.. Can 
u suggest an efficient way by which i could make these two programs 
to interact(back and forth) easily??





For your first question check out: wx.lib.pubsub: 
http://www.wxpython.org/docs/api/wx.lib.pubsub-module.html



I looked at your query a couple of times, and I don't see wxPython 
listed there anywhere.  You don't need SWIG or Boost or anything else -- 
that's what wxPython is.


Instead of just getting wxWidgets, get wxPython, which includes 
wxWidgets as a black box underneath.


binaries here:  http://wxpython.org/download.php#binaries
dos here:  http://www.wxpython.org/docs/api/wx-module.html

Of course, the catch is that this whole project supports Python 2.4 
through 2.6.  If you want to get it to work on 3.1, you have to either 
wait, or do it yourself.


DaveA

--
http://mail.python.org/mailman/listinfo/python-list


Re: make two tables having same orders in both column and row names

2009-11-19 Thread Emile van Sebille

On 11/18/2009 12:57 PM Ping-Hsun Hsieh said...

Hi,

I would like to compare values in two table with same column and row names, but 
with different orders in column and row names.
For example, table_A in a file looks like the follows:
AA100   AA109   AA101   AA103   AA102
BB1 2   9   2.3 1   28
BB3 12  9   2.3 1   28
BB9 0.5 2   2.3 1   28
BB2 2   9   21  1   20

Table_B in the other file looks like the follows:
AA101   AA109   AA100   AA103   AA102
BB1 2   9   2.3 2   28
BB2 2   9   2.3 1   28
BB9 2   9   2.3 1   28
BB3 2   2   2   1   28

Can anyone give an efficient way to make the two tables having same orders in 
column and row names so I can easily and correctly compare the values in 
positions?

Thanks,
PingHsun



This is one way... (python 2.4.1)
#For example, table_A in a file looks like the follows:
table_A = [ line.split()
  for line in """AA100  AA109   AA101   AA103   AA102
BB1 2   9   2.3 1   28
BB3 12  9   2.3 1   28
BB9 0.5 2   2.3 1   28
BB2 2   9   21  1   20""".split('\n')
  ]

#Table_B in the other file looks like the follows:
table_B = [ line.split()
  for line in """AA101  AA109   AA100   AA103   AA102
BB1 2   9   2.3 2   28
BB2 2   9   2.3 1   28
BB9 2   9   2.3 1   28
BB3 2   2   2   1   28""".split('\n')
  ]


for table in table_A,table_B:
table[:] = [['']+table[0]]+sorted(table[1:])
table = zip(*sorted(zip(*table)))
for ii in table: print ii


Emile

--
http://mail.python.org/mailman/listinfo/python-list


Re: Python-list Digest, Vol 74, Issue 245

2009-11-19 Thread Threader Slash
On Thu, Nov 19, 2009 at 7:05 PM,  wrote:

>
> --  --
> From: Threader Slash 
> To: [email protected]
> Date: Thu, 19 Nov 2009 14:51:27 +1100
> Subject: Qt Python radiobutton: activate event
> Hi Guys,
>
> I am trying to get the choice made by the user on Python Qt with
> radiobutton.
>
> QtCore.QObject.connect(self.radioButton1,
> QtCore.SIGNAL("toggled()"),self.radio_activateInput)
> QtCore.QObject.connect(self.radioButton2,
> QtCore.SIGNAL("toggled()"),self.radio_activateInput)
>
> and that
>
> QtCore.QObject.connect(self.performGroupBox,
> QtCore.SIGNAL("toggled()"),self.radio_activateInput)
>
> But it didn't make anything when I click on the option.
>
> Yes, I have enabled it:
>
> self.radioButton1.setCheckable(True)
> self.radioButton1.setChecked(True)
> self.radioButton2.setCheckable(True)
>
> Any suggestion?
>
>
> -- Forwarded message --
>

Here is solution... now working:

QtCore.QObject.connect(self.radioButton1,QtCore.SIGNAL("toggled(bool)"),self.radio_activateInput)

when have the parameter bool included into toggled to signal, it worked.

ThreadeSlash
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Will Not Send Email!!

2009-11-19 Thread Kev Dwyer
On Thu, 19 Nov 2009 11:28:37 -0400, Victor Subervi wrote:

Hello Victor, 

There are some pages on the internet that suggest that this problem my be 
caused by a module named email.py (or email.pyc) in your pythonpath.  If 
you try import smtplib in the interpreter do you get this error message?  
If so, start a new interpreter session and try import email - is the 
email module imported from the stdlib?

If these steps don't help, it might be useful if you can tell us which 
Linux distribution you are using.

Cheers,

Kev

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: make two tables having same orders in both column and row names

2009-11-19 Thread Simon Forman
On Wed, Nov 18, 2009 at 3:57 PM, Ping-Hsun Hsieh  wrote:
> Hi,
>
> I would like to compare values in two table with same column and row names, 
> but with different orders in column and row names.
> For example, table_A in a file looks like the follows:
> AA100   AA109   AA101   AA103   AA102
> BB1     2       9       2.3     1       28
> BB3     12      9       2.3     1       28
> BB9     0.5     2       2.3     1       28
> BB2     2       9       21      1       20
>
> Table_B in the other file looks like the follows:
> AA101   AA109   AA100   AA103   AA102
> BB1     2       9       2.3     2       28
> BB2     2       9       2.3     1       28
> BB9     2       9       2.3     1       28
> BB3     2       2       2       1       28
>
> Can anyone give an efficient way to make the two tables having same orders in 
> column and row names so I can easily and correctly compare the values in 
> positions?
>
> Thanks,
> PingHsun

Depending on the kind of comparisons you want to do and the sizes of
your input files you could build a dict of dicts.
For example:


def generate_dict_values(F):
column_names = f.readline().split()
for line in F:
row = line.split()
yield row[0], dict(zip(column_names, row[1:]))


# Fake a file.
from StringIO import StringIO
f = StringIO('''\
AA100   AA109   AA101   AA103   AA102
BB1 2   9   2.3 1   28
BB3 12  9   2.3 1   28
BB9 0.5 2   2.3 1   28
BB2 2   9   21  1   20
''')


d = dict(generate_dict_values(f))

# Now you can access the values without regards to the order in the
file like so:

d['BB9']['AA109']



# "Pretty print" the dict of dicts.
from pprint import pprint
pprint(d)

# Prints:
#
#{'BB1': {'AA100': '2',
# 'AA101': '2.3',
# 'AA102': '28',
# 'AA103': '1',
# 'AA109': '9'},
# 'BB2': {'AA100': '2',
# 'AA101': '21',
# 'AA102': '20',
# 'AA103': '1',
# 'AA109': '9'},
# 'BB3': {'AA100': '12',
# 'AA101': '2.3',
# 'AA102': '28',
# 'AA103': '1',
# 'AA109': '9'},
# 'BB9': {'AA100': '0.5',
# 'AA101': '2.3',
# 'AA102': '28',
# 'AA103': '1',
# 'AA109': '2'}}
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: hex

2009-11-19 Thread Rhodri James
On Thu, 19 Nov 2009 02:29:59 -, hong zhang   
wrote:



List,

I want to input hex number instead of int number. in type="int" in  
following,


parser.add_option("-F", "--forcemcs", dest="force_mcs", type="int",  
default=0, help="index of 11n mcs table. Default: 0.")


How can I do it?


Assuming you're talking about "optparse", just prefix the number with "0x"  
on the command line:


python myscript.py -F 0xDEAD

If you don't want to have to type the leading "0x", you'll either have to  
make yourself a custom type for optparse, or treat it as a string and do  
the parsing and error handling afterwards.  My recommendation is that you  
don't do this: not prefixing your constants if they aren't decimal is an  
accident waiting to happen.


--
Rhodri James *-* Wildebeest Herder to the Masses
--
http://mail.python.org/mailman/listinfo/python-list


Re: non-copy slices

2009-11-19 Thread Ethan Furman

Themis Bourdenas wrote:
On Thu, Nov 19, 2009 at 2:44 PM, Ethan Furman > wrote:


So "shallow copy" == "new label created for existing object".

So is your desired behavior to write back to the original list if your
sub-list is modified?  In other words, you are creating a window onto an
existing list?  If not, what would happen when a sublist element was
modified (or deleted, or appended, or ...)?

~Ethan~

Yes a window / view on the existing list describes it best. So every 
modification you make in this view is actually modifying the original 
list accordingly. Blist that was suggested in a previous email in the 
thread seems lightweight but it does create a new list when a 
modification is made. In any case, I've already implemented the object 
myself and I can post it if you care to have a look, but I was just 
wondering if there was already something in the standard library.


Themis


Unfortunately, I am not very familiar with the stdlib yet (gotta buy 
that book!).  I'm going to guess 'No' since nobody has chimed in with a 
'Yes', though.


I'd love to see what you have for that.  Does in support a stepped 
window, or only contiguous sequences?  The one I put together this 
afternoon only does contiguous sequences, as I had no use cases to 
decide how assignments of multiple items should be handled, and not a 
lot of time to implement something generic -- so, to answer John's 
question from a completely different thread, yes I do enjoy working on 
small projects even if IAGNI.  :)


Cheers!

~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list