Re: [Tutor] pyqt4 set horizontal header item - solved

2013-04-01 Thread eryksun
On Sun, Mar 31, 2013 at 8:13 PM, Phil  wrote:
>
> I have the answer (provided by a member of another list) and I was correct,
> it was something basic.
>
> from PyQt4 import QtGui
> QtGui.QTable etc

Sorry, I assumed you were familiar with the package layout.

http://pyqt.sourceforge.net/Docs/PyQt4/qtablewidgetitem.html

Notice the subtitle that says "[QtGui module]".

http://pyqt.sourceforge.net/Docs/PyQt4/classes.html
http://pyqt.sourceforge.net/Docs/PyQt4/qtgui.html
http://pyqt.sourceforge.net/Docs/PyQt4/qtcore.html
http://pyqt.sourceforge.net/Docs/PyQt4/qt.html
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] pyqt4 set horizontal header item - solved

2013-04-01 Thread Phil

On 01/04/13 19:47, eryksun wrote:

On Sun, Mar 31, 2013 at 8:13 PM, Phil  wrote:


I have the answer (provided by a member of another list) and I was correct,
it was something basic.

from PyQt4 import QtGui
QtGui.QTable etc


Sorry, I assumed you were familiar with the package layout.

http://pyqt.sourceforge.net/Docs/PyQt4/qtablewidgetitem.html

Notice the subtitle that says "[QtGui module]".

http://pyqt.sourceforge.net/Docs/PyQt4/classes.html
http://pyqt.sourceforge.net/Docs/PyQt4/qtgui.html
http://pyqt.sourceforge.net/Docs/PyQt4/qtcore.html
http://pyqt.sourceforge.net/Docs/PyQt4/qt.html


Thanks for the links Eryksun, it's all now starting to make sense.

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


[Tutor] tadaahh! But how to identify zLinux?

2013-04-01 Thread Albert-Jan Roskam
tadaah, I uploaded my first package some time ago: 
http://pypi.python.org/pypi/savReaderWriter
Let me use this opportunity to say THANKS to all of you for all your advise!

I'm still stuck with a question though. The program is supposed to work with 
zLinux (IBM system Z). But how do I know that this system is used? Here's my 
attempt:

# 
https://pic.dhe.ibm.com/infocenter/tivihelp/v10r1/index.jsp?topic=%2Fcom.ibm.tsam.doc_7.1%2Fc_prep_ms_for_lx_sysz.html
import sys, platform
if sys.platform.startswith("lin"):
   #isSuSe = platform.linux_distribution() == "SuSe"
   sysname, nodename, release, version, machine = os.uname()
   isSLES = "suse linux enterprise server" in version.lower()
   isRelease2dot6 = release.startswith("2.6")
   isSystemZ = machine.startswith("s390")  # 
   isZLinux = isSLES and isRelease2dot6 and isSystemZ
   if isZLinux:
  pass

Regards,
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] tadaahh! But how to identify zLinux?

2013-04-01 Thread eryksun
On Mon, Apr 1, 2013 at 4:04 PM, Albert-Jan Roskam  wrote:
>
> I'm still stuck with a question though. The program is supposed to work
> with zLinux (IBM system Z). But how do I know that this system is used?

Have a look at the platform module for info on the Python
version/implementation, machine, and OS (e.g. linux_distribution):

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


Re: [Tutor] tadaahh! But how to identify zLinux?

2013-04-01 Thread Alan Gauld

On 01/04/13 21:04, Albert-Jan Roskam wrote:


program is supposed to work with zLinux (IBM system Z). But how do I

> know that this system is used?

I have no idea what the answer is but I'm curious why you would care?
Are you expecting that your code will be run on an IBM mainframe?

I'd have thought that in most cases those boxes would only be running 
Python  in situations where the admins have carefully controlled the 
code that's loaded - and by implication taken care of whatever you are 
trying to do - or, they would be running virtual machines that look like 
non-mainframes?


Now, I have no experience of either zLinux or of using Python on a 
mainframe so I don't know if my guesses are accurate, but I am curious 
why you are concerned? Is it a known issue or are you just being super 
careful?


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

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


Re: [Tutor] tadaahh! But how to identify zLinux?

2013-04-01 Thread Steven D'Aprano

On 02/04/13 09:00, Alan Gauld wrote:

On 01/04/13 21:04, Albert-Jan Roskam wrote:


program is supposed to work with zLinux (IBM system Z). But how do I
know that this system is used?


I have no idea what the answer is but I'm curious why you would care?
Are you expecting that your code will be run on an IBM mainframe?


Perhaps he is :-)

Albert-Jan asks because his package is an interface to an external binary
library, and the location of that library differs according to the platform:

https://bitbucket.org/fomcl/savreaderwriter/src/09b9c82406e82d43223d6610ba9cbfbf234b16d4/savReaderWriter/generic.py?at=master



By the way, I don't know that changing directory is a good idea, if you can
avoid it at all. I for one would be *extremely* annoyed if, after calling
what otherwise seems like an innocent library routine, opening files suddenly
started failing (or worse, the wrong file was opened!) because the current
directory was different. Even though you do restore the current directory
when you are done, that makes your routines unsafe for threads.



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


[Tutor] argparse iterable

2013-04-01 Thread kendy
Dear Tutor

I want to compare command line options, to options in a dictionary from a YAML
file. The command line will over-ride the options in my file. (The YAML file, 
and
its dictionary are not shown. That part works.)

My distilled code:

-
$ cat h.py
#!/usr/bin/python

import argparse
parser = argparse.ArgumentParser(description='Short sample app')

def GetArgs(parser):
parser.add_argument('-a', action="store_true", default=False)
parser.add_argument('-b', action="store", dest="b")
parser.add_argument('-c', action="store", dest="c", type=int)
return parser

GetArgs(parser)

print(parser.parse_args())
print("But this doesn't iter through a b and c:")
for k,v in parser.parse_args():
print('This arg is %s %s' % k, k[str(v)])
$ 
-

My error:
$ h.py -a -b hi -c 42
Namespace(a=True, b='hi', c=42)
But this doesn't iter through a b and c:
Traceback (most recent call last):
  File "./h.py", line 16, in 
for k,v in parser.parse_args():
TypeError: 'Namespace' object is not iterable
$ 

How can I get parser to be iterable?

After I get it to iter, I suppose that I'll be bitten by the boolean and integer
type conversions. I'm not sure how to handle that either. Will 'str()' save me?

Thanks a million (again!),
Ken

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


Re: [Tutor] argparse iterable

2013-04-01 Thread Jason Friedman
#!/usr/bin/python
import argparse
parser = argparse.ArgumentParser(description='Short sample app')
parser.add_argument('-a', action="store_true", default=False)
parser.add_argument('-b', action="store", dest="b")
parser.add_argument('-c', action="store", dest="c", type=int)
parser.parse_args()
for k,v in parser.parse_args().__dict__.items():
print('This arg is %s %s' % (k, v))



On Mon, Apr 1, 2013 at 6:31 PM,  wrote:

> Dear Tutor
>
> I want to compare command line options, to options in a dictionary from a
> YAML
> file. The command line will over-ride the options in my file. (The YAML
> file, and
> its dictionary are not shown. That part works.)
>
> My distilled code:
>
> -
> $ cat h.py
> #!/usr/bin/python
>
> import argparse
> parser = argparse.ArgumentParser(description='Short sample app')
>
> def GetArgs(parser):
> parser.add_argument('-a', action="store_true", default=False)
> parser.add_argument('-b', action="store", dest="b")
> parser.add_argument('-c', action="store", dest="c", type=int)
> return parser
>
> GetArgs(parser)
>
> print(parser.parse_args())
> print("But this doesn't iter through a b and c:")
> for k,v in parser.parse_args():
> print('This arg is %s %s' % k, k[str(v)])
> $
> -
>
> My error:
> $ h.py -a -b hi -c 42
> Namespace(a=True, b='hi', c=42)
> But this doesn't iter through a b and c:
> Traceback (most recent call last):
>   File "./h.py", line 16, in 
> for k,v in parser.parse_args():
> TypeError: 'Namespace' object is not iterable
> $
>
> How can I get parser to be iterable?
>
> After I get it to iter, I suppose that I'll be bitten by the boolean and
> integer
> type conversions. I'm not sure how to handle that either. Will 'str()'
> save me?
>
> Thanks a million (again!),
> Ken
>
> ___
> 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] argparse iterable

2013-04-01 Thread Mark Lawrence

On 02/04/2013 01:31, ke...@kendy.org wrote:

Dear Tutor

I want to compare command line options, to options in a dictionary from a YAML
file. The command line will over-ride the options in my file. (The YAML file, 
and
its dictionary are not shown. That part works.)

My distilled code:

-
$ cat h.py
#!/usr/bin/python

import argparse
parser = argparse.ArgumentParser(description='Short sample app')

def GetArgs(parser):
 parser.add_argument('-a', action="store_true", default=False)
 parser.add_argument('-b', action="store", dest="b")
 parser.add_argument('-c', action="store", dest="c", type=int)
 return parser

GetArgs(parser)

print(parser.parse_args())
print("But this doesn't iter through a b and c:")
for k,v in parser.parse_args():
 print('This arg is %s %s' % k, k[str(v)])


for a in vars(parser.parse_args()):
print('This arg is %s' % a)

http://docs.python.org/3/library/argparse.html#the-namespace-object

Please don't ask me for an explanation as it took me long enough to work 
this out from the docs :)



$
-

My error:
$ h.py -a -b hi -c 42
Namespace(a=True, b='hi', c=42)
But this doesn't iter through a b and c:
Traceback (most recent call last):
   File "./h.py", line 16, in 
 for k,v in parser.parse_args():
TypeError: 'Namespace' object is not iterable
$

How can I get parser to be iterable?

After I get it to iter, I suppose that I'll be bitten by the boolean and integer
type conversions. I'm not sure how to handle that either. Will 'str()' save me?

Thanks a million (again!),
Ken





--
If you're using GoogleCrap™ please read this 
http://wiki.python.org/moin/GoogleGroupsPython.


Mark Lawrence

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


Re: [Tutor] argparse iterable

2013-04-01 Thread Dave Angel

On 04/01/2013 09:31 PM, Mark Lawrence wrote:

On 02/04/2013 01:31, ke...@kendy.org wrote:

Dear Tutor

I want to compare command line options, to options in a dictionary
from a YAML
file. The command line will over-ride the options in my file. (The
YAML file, and
its dictionary are not shown. That part works.)

My distilled code:

-
$ cat h.py
#!/usr/bin/python

import argparse
parser = argparse.ArgumentParser(description='Short sample app')

def GetArgs(parser):
 parser.add_argument('-a', action="store_true", default=False)
 parser.add_argument('-b', action="store", dest="b")
 parser.add_argument('-c', action="store", dest="c", type=int)
 return parser

GetArgs(parser)

print(parser.parse_args())
print("But this doesn't iter through a b and c:")
for k,v in parser.parse_args():
 print('This arg is %s %s' % k, k[str(v)])


for a in vars(parser.parse_args()):
 print('This arg is %s' % a)

http://docs.python.org/3/library/argparse.html#the-namespace-object

Please don't ask me for an explanation as it took me long enough to work
this out from the docs :)



http://docs.python.org/2/library/argparse.html

see section 15.4.4.6 for a very brief explanation of vars()



$
-

My error:
$ h.py -a -b hi -c 42
Namespace(a=True, b='hi', c=42)
But this doesn't iter through a b and c:
Traceback (most recent call last):
   File "./h.py", line 16, in 
 for k,v in parser.parse_args():
TypeError: 'Namespace' object is not iterable
$

How can I get parser to be iterable?

After I get it to iter, I suppose that I'll be bitten by the boolean
and integer
type conversions. I'm not sure how to handle that either. Will 'str()'
save me?

Thanks a million (again!),
Ken








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


Re: [Tutor] argparse iterable

2013-04-01 Thread Don Jennings

On Apr 1, 2013, at 8:31 PM,   wrote:

> 
> 
> print("But this doesn't iter through a b and c:")
> for k,v in parser.parse_args():
>print('This arg is %s %s' % k, k[str(v)])
> $ 
> -
> 
> My error:
> $ h.py -a -b hi -c 42
> Namespace(a=True, b='hi', c=42)
> But this doesn't iter through a b and c:
> Traceback (most recent call last):
>  File "./h.py", line 16, in 
>for k,v in parser.parse_args():
> TypeError: 'Namespace' object is not iterable
> $ 
> 
> How can I get parser to be iterable?

Jason, Mark and Dave have addressed this part of your question already.

> 
> After I get it to iter, I suppose that I'll be bitten by the boolean and 
> integer
> type conversions. I'm not sure how to handle that either. Will 'str()' save 
> me?

What do you mean here? You're thinking that you have to convert them to strings 
before passing them to the print function? Actually, the string formatting 
operator, the percent sign, combined with the 's' will convert for you, using 
the str() method. So, the code above is redundant. Just use:

print('This arg is %s %s' % k, v)

Take care,
Don

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


Re: [Tutor] argparse iterable

2013-04-01 Thread kendy
You guys are awesome! You make it look easy and I learn every time.

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


Re: [Tutor] argparse iterable

2013-04-01 Thread Mark Lawrence

On 02/04/2013 02:37, Dave Angel wrote:

On 04/01/2013 09:31 PM, Mark Lawrence wrote:


for a in vars(parser.parse_args()):
 print('This arg is %s' % a)

http://docs.python.org/3/library/argparse.html#the-namespace-object

Please don't ask me for an explanation as it took me long enough to work
this out from the docs :)



http://docs.python.org/2/library/argparse.html

 see section 15.4.4.6 for a very brief explanation of vars()




Section 15.4.4.6. The Namespace object, but I can't for the life of me 
remember what my link referred to :)


--
If you're using GoogleCrap™ please read this 
http://wiki.python.org/moin/GoogleGroupsPython.


Mark Lawrence

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


Re: [Tutor] argparse iterable

2013-04-01 Thread Mark Lawrence

On 02/04/2013 03:28, ke...@kendy.org wrote:

You guys are awesome! You make it look easy and I learn every time.

Thank you
Ken


Think yourself lucky, I'm currently on the wagon or it'd cost you a 
couple of pints :)


--
If you're using GoogleCrap™ please read this 
http://wiki.python.org/moin/GoogleGroupsPython.


Mark Lawrence

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


Re: [Tutor] tadaahh! But how to identify zLinux?

2013-04-01 Thread eryksun
On Mon, Apr 1, 2013 at 6:42 PM, Steven D'Aprano  wrote:
> By the way, I don't know that changing directory is a good idea, if you can
> avoid it at all.

As far as loading linked libraries goes, changing the current
directory works on Windows, and I think OS X, but it doesn't work on
Linux. On Windows you can also add the directory to the system PATH at
run time.

I see 3 deb files in spssio/lin32. It doesn't seem like your plan is
to install these since you don't have them for lin64 as well. Is this
savReaderWriter supposed to be a self-contained system for
reading/writing IBM SPSS files, or dependent on an existing
installation of SPSS? (Not being a user of SPSS, I have no idea how
foolish that question may or may not sound. Oh well.)

Anyway, I downloaded and extracted the deb files to a temp directory
on a 32-bit Debian system. In addition to the libs that you've already
extracted, ldd determined that I also needed the following libs:

libimf.so  [intel-icc8-libs_8.0-1_i386.deb]
libcxaguard.so.5   [intel-icc8-libs_8.0-1_i386.deb
libstdc++.so.5.0.7 [libstdc++5_3.3.6-20_i386.deb]

and links for the ELF soname fields:

libstdc++.so.5->  libstdc++.so.5.0.7
libicudata.so.32  ->  libicudata.so.32.0
libicui18n.so.32  ->  libicui18n.so.32.0
libicuuc.so.32->  libicuuc.so.32.0

After setting up the above, I patched a runpath of $ORIGIN into
libspssdio.so.1. This instructs the loader to look for dependencies in
the same directory.

$ patchelf --set-rpath '$ORIGIN' libspssdio.so.1

Now I can load the library with ctypes:

>>> from ctypes import *
>>> spssio = CDLL('spssio/lin32/libspssdio.so.1')
>>> spssio.spssOpenRead
<_FuncPtr object at 0xb753b094>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor