Re: py 2.7.1 & openssl

2011-03-31 Thread nirinA

[V N]

import _md5
ImportError: No module named _md5

Any idea(s)?


try to build Python with pydebug to enable _md5:

 ./configure --with-pydebug

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


Re: py 2.7.1 & openssl

2011-04-01 Thread nirinA

hi,


Yes, _md5 is enabled but I get a very long list under
 Failed to build these modules:
... list of mostly all extension modules ...
This list was empty earlier.


at some point, the compilation failed to detect
needed headers or libraries files.
i suggest you to try something simple in order to
see  what is wrong in the compilation step.

first, when compiling openssl.
your wrote in original post:


I installed openssl-1.0.0d.tar.gz on my RHEL 5 box using:
./config --prefix=/usr/local --openssldir=/usr/local/openssl
shared zlib
make
sudo make install


just try:

./config
make
make install

and nothing else.
do su root, when you install, not sudo.
don't use any --prefix=xxx nor --openssldir=xxx.
use the default location, that is /usr/local/ssl
as this is the location where Python looks for
ssl headers and libraries.
don't use shared. Python uses static libraries and
as far as i can tell, shared libraries are not
supported yet on x86_64 platform.
with openssl-1.0.0d, i think you don't even need
to specify the -fPIC flag, but using it doesn't hurt.

you also wrote:


And, the following files are created in /usr/local/lib64:
libssl.a, libssl.so, libcrypto.a, libcrypto.so.  Also, the binary
openssl is created in the bin directory.


these files aren't used at all, unless you change the setup.py
file to build _ssl extension.
i repeat: Python uses /usr/local/ssl directory
(or /usr/contrib/ssl/) to look for ssl headers and libraries.

secondly, when compiling Python:


Then I installed python 2.7.1 using
PYHOME=/usr/local/Python-2.7.1; export PYHOME
LD_RUN_PATH=$PYHOME/lib; export LD_RUN_PATH
LDFLAGS="-L /usr/local/lib64 -L /usr/local/lib"; export
LDFLAGS
CPPFLAGS="-I /usr/local/include -I /usr/local/include/
openssl"; export CPPFLAGS
./configure --enable-shared --prefix=$PYHOME > log_cfg 2>&1
make > log_mk 2>&1
sudo make install > log_mk_i 2>&1


try something simple instead of these messy configurations!
just try:

./configure
make
make install

if you want to install Python in a specific directory,
e.g. /usr/local/Python-2.7.1 , use:

make install DESTDIR=/usr/local/Python-2.7.1

and then, you play with:

export LD_LIBRARY_PATH=/usr/local/Python-2.7.1/lib
/usr/local/Python-2.7.1/bin/python

if you really want to specify some libraries and include files,
but usually you don't, Python is smart enough to find them,
don't use :


 LDFLAGS="-L /usr/local/lib64 -L /usr/local/lib"; export
LDFLAGS
 CPPFLAGS="-I /usr/local/include -I /usr/local/include/
openssl"; export CPPFLAGS


pass them in the configuration line instead:

CPPFLAGS="-I/usr/local/include/openssl" \
LDFLAGS="-L/usr/local/lib64" \
./configure

notice that there is no space between
the -I or -L and the directory name.
and the backslash to continue long line.

finally, don't use sudo.
try to log as root if possible.
may be you cannot access some
files needed for compilation
as a simple user.
and some LD*** and CPP*** flags
are reset when you use sudo.

hope this helps

nirinA
--
Simple is better than complex.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Compiling python without ssl?

2011-04-01 Thread nirinA

[Austin Bingham]


Is there any way to compile python (3.1.3, in case it matters) without
ssl support? OpenSSL is on my system, and configure finds it, but I
can't find a way to tell configure to explicitly ignore it.

I need a version of python without ssl for trade compliance reasons (I
don't make the dumb rules, I just follow 'em), and we used to be able
to just remove the ssl module after the build. With more recent
releases, though, this approach causes problems with e.g. hashlib.

Ideally I'd like something like "configure --disable-ssl", but I can
also do surgery on configure or something if that's what it takes.
Thanks in advance!

Austin


you can change or erase the list of include and library files
related to ssl in setup.py before configuring.
but, as you say, this may break hashlib. and probably the socket
module, and may be other things, like idle.

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


Re:py 2.7.1 & openssl

2011-03-31 Thread nirinA raseliarison
[V N]
> I installed openssl-1.0.0d.tar.gz on my RHEL 5 box using:
>  ./config --prefix=/usr/local --openssldir=/usr/local/openssl
> shared zlib

you need to compile openssl with -fPIC flags,
depending on your system and compiler:

 ./config linux-generic:gcc -fPIC shared

and then recompile Python.
otherwise, look at the make log to see why
the building of ssl module failed.

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


Re: py 2.7.1 & openssl

2011-04-02 Thread nirinA raseliarison

[V N]

I tried all your suggestions. No success.

don't forget to run:
  make distclean
before you rerun configure

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


Re: PIL Question

2011-05-02 Thread nirinA raseliarison

[PyNewbie]


Question: I can't seem to find the captured image, where does it go?


for me, it just goes to the current working directory:

  $ python -i
  Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit  
(Intel)] on win32

  Type "help", "copyright", "credits" or "license" for more information.
  >>> from PIL import ImageGrab
  >>> ImageGrab.grab().save("screen_capture.jpg", "JPEG")
  >>> import os
  >>> os.listdir(os.getcwd())
  ['.appcfg_cookies', '.appcfg_nag', '.bash_history', '.idlerc',  
'.inputrc', '.povray',
  'bootex.log', 'buildBasicDemo.txt', 'glsample.cpp', 'glsample.o',  
'log.txt',

  'screen_capture.jpg', 'test.c']
  >>>

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


Re: BeautifulSoup import error

2011-05-06 Thread nirinA raseliarison

[1011_wxy]


I got a import error when I use Python 3.2 to import BeautifulSoup 3.2.0


the error i see is a SyntaxError.


Is there any differences between Python 3.2 and other version?


yes. and there is a tool, 2to3, which converts
Python 2.x scripts to work with 3.x.


And the error message will be as below.



from BeautifulSoup import BeautifulSoup

Traceback (most recent call last):
  File "", line 1, in 
from BeautifulSoup import BeautifulSoup
  File "C:\Python32\BeautifulSoup.py", line 448
raise AttributeError, "'%s' object has no attribute '%s'" %  
(self.__class__.__name__, attr)

^
SyntaxError: invalid syntax


a quick fix here, change:

raise AttributeError, "'%s' object has no attribute '%s'"
%(self.__class__.__name__, attr)

to:

raise AttributeError("'%s' object has no attribute '%s'"
%(self.__class__.__name__, attr))

enclose the string message with parentheses.
at least, you will not get the SyntaxError.
but a better solution is to use 2to3.

i don't use BeautifulSoup, and i'm still stick with
Python2.5.4 on windows, so can't help much.

with Linux, it is just:

  2to3 a_python_file_or_a_dir_package

on windows, i don't know, maybe:

  import subprocess
  subprocess.Popen(('python.exe', 'Tools/Scripts/2to3.py', 'the_package'))

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


Re: Python 3 dict question

2011-05-06 Thread nirinA raseliarison
[dmitrey]
> hi all,
> suppose I have Python dict myDict and I know it's not empty.
> I have to get any (key, value) pair from the dict (no matter which
> one) and perform some operation.
> In Python 2 I used mere
> key, val = myDict.items()[0]
> but in Python 3 myDict.items() return iterator.
> Of course, I could use
> for key, val in myDict.items():
>   do_something
>   break
> but maybe there is any better way?

key, val = list(myDict.items())[0]

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


test_argparse.py FAILED (failures=6)

2011-05-17 Thread nirinA raseliarison


==
FAIL: test_failures_many_groups_listargs (__main__.TestFileTypeW)
--
Traceback (most recent call last):
  File "Lib/test/test_argparse.py", line 216, in wrapper
test_func(self)
  File "Lib/test/test_argparse.py", line 235, in test_failures
raises(ArgumentParserError, parser.parse_args, args)
AssertionError: ArgumentParserError not raised by parse_args

==
FAIL: test_failures_many_groups_sysargs (__main__.TestFileTypeW)
--
Traceback (most recent call last):
  File "Lib/test/test_argparse.py", line 216, in wrapper
test_func(self)
  File "Lib/test/test_argparse.py", line 235, in test_failures
raises(ArgumentParserError, parser.parse_args, args)
AssertionError: ArgumentParserError not raised by parse_args

==
FAIL: test_failures_no_groups_listargs (__main__.TestFileTypeW)
--
Traceback (most recent call last):
  File "Lib/test/test_argparse.py", line 216, in wrapper
test_func(self)
  File "Lib/test/test_argparse.py", line 235, in test_failures
raises(ArgumentParserError, parser.parse_args, args)
AssertionError: ArgumentParserError not raised by parse_args

==
FAIL: test_failures_no_groups_sysargs (__main__.TestFileTypeW)
--
Traceback (most recent call last):
  File "Lib/test/test_argparse.py", line 216, in wrapper
test_func(self)
  File "Lib/test/test_argparse.py", line 235, in test_failures
raises(ArgumentParserError, parser.parse_args, args)
AssertionError: ArgumentParserError not raised by parse_args

==
FAIL: test_failures_one_group_listargs (__main__.TestFileTypeW)
--
Traceback (most recent call last):
  File "Lib/test/test_argparse.py", line 216, in wrapper
test_func(self)
  File "Lib/test/test_argparse.py", line 235, in test_failures
raises(ArgumentParserError, parser.parse_args, args)
AssertionError: ArgumentParserError not raised by parse_args

==
FAIL: test_failures_one_group_sysargs (__main__.TestFileTypeW)
--
Traceback (most recent call last):
  File "Lib/test/test_argparse.py", line 216, in wrapper
test_func(self)
  File "Lib/test/test_argparse.py", line 235, in test_failures
raises(ArgumentParserError, parser.parse_args, args)
AssertionError: ArgumentParserError not raised by parse_args

--
Ran 1599 tests in 6.298s

FAILED (failures=6)

Traceback (most recent call last):
  File "Lib/test/test_argparse.py", line 4681, in 
test_main()
  File "Lib/test/test_argparse.py", line 4673, in test_main
support.run_unittest(__name__)
  File "/mnt/sda14/pack_build/Python-3.2.1rc1/Lib/test/support.py", line  
1184, in run_unittest

_run_suite(suite)
  File "/mnt/sda14/pack_build/Python-3.2.1rc1/Lib/test/support.py", line  
1167, in _run_suite

raise TestFailed(err)
test.support.TestFailed: multiple errors occurred


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


test_ftplib.py failed with segmentation fault,gcc4.6.0,glibc-2.13

2011-05-17 Thread nirinA raseliarison
.1rc1/build/lib.linux-x86_64-3.2/select.cpython-32m.so
7f38f8b3f000-7f38f8d3f000 ---p 4000 08:0e 54345
/mnt/sda14/pack_build/Python-3.2.1rc1/build/lib.linux-x86_64-3.2/select.cpython-32m.so
7f38f8d3f000-7f38f8d41000 rw-p 4000 08:0e 54345
/mnt/sda14/pack_build/Python-3.2.1rc1/build/lib.linux-x86_64-3.2/select.cpython-32m.so
7f38f8d41000-7f38f8d55000 r-xp  08:0b 219
/usr/lib64/libz.so.1.2.3
7f38f8d55000-7f38f8f54000 ---p 00014000 08:0b 219
/usr/lib64/libz.so.1.2.3Aborted

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


smtplib is broken when using TLS

2011-05-17 Thread nirinA raseliarison

i think this has the same origin as the ftplib test failure.

Python 3.2.1rc1 (default, May 17 2011, 22:01:34)
[GCC 4.6.0] on linux2
Type "copyright", "credits" or "license()" for more information.
 RESTART  





send: 'ehlo [127.0.0.1]\r\n'
reply: b'250-mx.google.com at your service, [41.188.13.184]\r\n'
reply: b'250-SIZE 35882577\r\n'
reply: b'250-8BITMIME\r\n'
reply: b'250-STARTTLS\r\n'
reply: b'250 ENHANCEDSTATUSCODES\r\n'
reply: retcode (250); Msg: b'mx.google.com at your service,
[41.188.13.184]\nSIZE 35882577\n8BITMIME\nSTARTTLS\nENHANCEDSTATUSCODES'
send: 'STARTTLS\r\n'
reply: b'220 2.0.0 Ready to start TLS\r\n'
reply: retcode (220); Msg: b'2.0.0 Ready to start TLS'
Traceback (most recent call last):
File "/root/template_mail_text.py", line 49, in 
  server.starttls()
File "/usr/local/lib/python3.2/smtplib.py", line 649, in starttls
  self.sock = ssl.wrap_socket(self.sock, keyfile, certfile)
File "/usr/local/lib/python3.2/ssl.py", line 509, in wrap_socket
  ciphers=ciphers)
File "/usr/local/lib/python3.2/ssl.py", line 266, in __init__
  raise x
File "/usr/local/lib/python3.2/ssl.py", line 262, in __init__
  self.do_handshake()
File "/usr/local/lib/python3.2/ssl.py", line 441, in do_handshake
  self._sslobj.do_handshake()
ssl.SSLError: [Errno 1] _ssl.c:392: error:140943FC:SSL
routines:SSL3_READ_BYTES:sslv3 alert bad record mac


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


Re: Tkinter Bitmap Newbie question

2005-03-13 Thread Raseliarison nirinA
"Wim Goffin" wrote:

>>> Hi,

hello,

>>> I'm trying to get a bitmap onto a button, but I can't.
>>> Can anyone tell me where to look for a solution?
>>>
>>> The call I use is this one:
>>> self.b = Button(toolbar, text="nieuw", bitmap="@/test.xbm",
>>> width=20, command=self.print_msg)
>>>
>>> The message I get is this:
>>> Traceback (most recent call last):
>>>   File "C:\Documents and Settings\Wim\Mijn
>>> documenten\Python\overhoor.py", line 143, in -toplevel-
>>> app = App(root)
>>>   File "C:\Documents and Settings\Wim\Mijn
>>> documenten\Python\overhoor.py", line 71, in __init__
>>> self.b = Button(toolbar, text="nieuw", bitmap="@/test.xbm",
>>> width=20, command=self.print_msg)
>>>   File "C:\Python24\lib\lib-tk\Tkinter.py", line 1939, in __init__
>>> Widget.__init__(self, master, 'button', cnf, kw)
>>>   File "C:\Python24\lib\lib-tk\Tkinter.py", line 1868, in __init__
>>> self.tk.call(
>>> TclError: error reading bitmap file "\test.xbm"
>>>
>>> This is hapening on a WindowsXP system.
>>> It seems as though the file is not found. Because if specify the
>>> name of a non-existing file,
>>> then I get exactly the same error. What could I do to make sure
>>> first  that
>>> Puthon does find the file?

well, you do make sure that the file exists in the right place.

bitmap="@/test.xbm" means something like: look for a bitmap file
named test.xbm at location "/" , that is, at the top level directory.

bitmap="@c:/test.xbm" is equivalent.

some solutions:
1) copy (or cut)  and paste the file test.xbm to c:/ and continue to
use your code or,
2) if test.xbm is in the same directory as your code, you may write:
bitmap="@test.xbm" or bitmap="@./test.xbm"
where "./" means the current directory or,
3) you may write something like (one single string!):
bitmap="@C:/Documents and Settings\Wim/Mijn
documenten\Python/test.xbm"

notice also that if the bitmap appears in your button,
your text="nieuw" may not be visible.

>>> Thanks in advance,
>>> Wim Goffin

hope this help.

--
nirinA








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


Re: Install problem Windows xp HE

2005-03-13 Thread Raseliarison nirinA
"Jan Ekström" wrote:
> Here is the error.
> IDLE 1.1
> >>> python
>
> Traceback (most recent call last):
>   File "", line 1, in -toplevel-python
> NameError: name 'python' is not defined
> >>>

this should be a success install report! not an error.
start coding and see what happens.

>>> print "Hello World!"

--
nirinA





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


Re: Searching for a ComboBox for Tkinter?

2005-03-13 Thread Raseliarison nirinA
"Harlin Seritt" wrote:

> I've created a ghetto-ized ComboBox that should work nicely for
> Tkinter
> (unfortunately no dropdown capabilities yet).
>

how about:

>>> import Tix
>>> print Tix.ComboBox.__doc__
ComboBox - an Entry field with a dropdown menu. The user can select a
choice by either typing in the entry subwdget or selecting from
the listbox subwidget.

Subwidget   Class
-   -
entry   Entry
arrow   Button
slistboxScrolledListBox
tickButton
cross   Button : present if created with the fancy option

--
nirinA





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


Re: tkinter: always scroll to show last line of text

2005-03-13 Thread Raseliarison nirinA
"Martin Franklin"  wrote:

> Benjamin Rutt wrote:
> > I have a tkinter 'Text' and 'Scrollbar' connected and working
> > normally.  When a new line of text is inserted (because I'm
> > monitoring
> > an output stream), I'd like the text and scrollbar to be scrolled
> > to
> > the bottom, so the latest line of text is always shown.  How to do
> > this?  Thanks,
>
>
> text.yview_pickplace("end")
>

or

text.see('end')

there is also a "ScrolledText" module

>>> import ScrolledText
>>> 'see' in dir(ScrolledText.ScrolledText)
True

--
nirinA
--
same-response-again-and-again
--



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


Re: A Font Dialog (Tkinter)

2005-03-14 Thread Raseliarison nirinA
"Harlin Seritt" wrote:

> Is there a way to call up the Font dialog box (at least in the
> Windows API) from Tkinter or another module?
>

i'll use the tkFont module and the same way as IDLE calls it.
looking at the source code may help you:

>>> import tkFont, idlelib.configDialog, inspect
>>> print inspect.getsource(tkFont)
>>> print
inspect.getsource(idlelib.configDialog.ConfigDialog.CreatePageFontTab)

> thanks,
>
> Harlin Seritt
>

hope this helps

--
nirinA
--



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


Re: Listbox fill=BOTH expand=YES (Tkinter)

2005-03-14 Thread Raseliarison nirinA
"Martin Franklin" wrote:

> Harlin Seritt wrote:
> > I am trying the following:
> >
> > Listbox(parent).pack(fill=BOTH, expand=YES)
> >
> > I notice that the listbox will fill on the X axis but will not on
> > the Y axis unlike other widgets. 
> > Is there any way to force this?
> >
> > thanks,
> >
> > Harlin
> >
>
> Harlin,
>
> It should expand (and fill ) in both directions have you checked
> it's parents packing options?
>
> Martin
>

is YES a valid flag for expand?
maybe expand=1

--
nirinA


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


Re: distutils setup ignoring scripts

2005-03-15 Thread Raseliarison nirinA
"Jack Orenstein" wrote:

> I'm using Python 2.2 on RH9. I have a set of Python modules
> organized
> into a root package and one other package named foobar. setup.py
> looks
> like this:
>
>  from distutils.core import setup
>
>  setup(
>  name = 'foobar',
>  version = '0.3',
>  description = 'Foo Bar',
>  author = 'Jack Orenstein',
>  author_email = '[EMAIL PROTECTED]',
>  packages = ['', 'xyz'],
>  scripts = ['bin/foobar']
>  )
>
> The resulting package has everything in the specified directories,
> but
> does not include the script. I've tried making the path bin/foobar
> absolute, but that doesn't help. I've googled for known bugs of this
> sort but have come up emtpy. (The first line of bin/foobar is
> #!/usr/bin/python.)
>
> I've also tried using DISTUTIL_DEBUG, which has been uninformative,
> (e.g. no mention of bin/foobar at all).
>
> Can anyone see what I'm doing wrong?

i think there's nothing wrong.
the script (i guess you mean the setup.py file) is not included
into the package because you haven't specified it to be so.
add:
  setup(
...
py_modules=["setup"],
...
)
inside your script to perform inclusion.

another way to include other files not specified by the setup script
is to write a MANIFEST where you indicate those files. then build the
package with the sdist command:

$ cat > MANIFEST
bin/foobar
bin/anotherfoobar
anotherbin/barfoo
setup.py
MANIFEST

ctrl-D
$ python setup.py sdist

>
> Jack Orenstein
>

hope this helps.

--
nirinA












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


Re: Listbox fill=BOTH expand=YES (Tkinter)

2005-03-15 Thread Raseliarison nirinA
"Harlin Seritt" wrote:
> either YES, True, or 1 should work.
> 

yes, indeed. 
>>> import Tkconstants
>>> 'True' and 'YES' in dir(Tkconstants)
True

thanks Harlin,

--
nirinA


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


Re: distutils setup ignoring scripts

2005-03-15 Thread Raseliarison nirinA
yes i'm deadly wrong and should refuse the 
temptation to guess!
and ougth to read clearly the post.
> 
> No, I'm referring to bin/foobar, as specified 
> in "scripts = ['bin/foobar']".
> 
> Jack

so, you want the script foobar included in your package?
what command are you issueing?

does this include the file?
python setup.py sdist 

as you use Python22 (old) on RH9, maybe:
python setup.py bdist_rpm --install-script foobar

--
nirinA
--

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


Re: distutils setup ignoring scripts

2005-03-15 Thread Raseliarison nirinA
 Jack wrote:
> No, I'm referring to bin/foobar, as specified 
> in "scripts = ['bin/foobar']".

yes i'm deadly wrong and should refuse the 
temptation to guess!
and ougth to read clearly the post.
so, you want the script foobar included in your package?
what command are you issueing?

does this include the file?
python setup.py sdist 

as you use Python22  on RH9, maybe:
python setup.py bdist_rpm --install-script foobar

> Jack

--
nirinA


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


Re: distutils setup ignoring scripts

2005-03-15 Thread Raseliarison nirinA
"Jack Orenstein" wrote:
> No, I'm referring to bin/foobar, as specified 
> in "scripts = ['bin/foobar']".
 
yes i'm deadly wrong and should refuse the 
 temptation to guess!
and ougth to read clearly the post.
so, you want the script foobar included in your package?
what command are you issueing?
does this include the file?
python setup.py sdist 

 as you use Python22  on RH9, maybe:
python setup.py bdist_rpm --install-script foobar
 
> Jack

--
nirinA
--
i ougth to read clearly the post and
should refuse the  temptation to guess!




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


Re: distutils setup ignoring scripts

2005-03-15 Thread Raseliarison nirinA
"Jack Orenstein" wrote:
> Quoting [i]:
> > as you use Python22  on RH9, maybe:
> > python setup.py bdist_rpm --install-script foobar
>
> Is install-script really needed? I would have thought that
specifying
> setup( ... scripts = [...] ...) would suffice, based on the python
> docs.
>

i think you need to precise it, and even with some other rpm
specific options like:  --use-rpm-opt-flags
but ... i'm not sure that those options are already
implemented with Python22.
if not you may have to upgrade!

--
nirinA


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


Re: Listbox fill=BOTH expand=YES (Tkinter)

2005-03-16 Thread Raseliarison nirinA
"Christos TZOTZIOY Georgiou" wrote:
> On Tue, 15 Mar 2005 16:48:17 +0300,
> rumours say that [i] might have written:
>
> >yes, indeed.
> >>>> import Tkconstants
> >>>> 'True' and 'YES' in dir(Tkconstants)
> >True
> >
> >thanks Harlin,
>
> I hope you also know that
>
> .>> 'inexistent keyword' and 'YES' in dir(Tkconstants)
>
> is also True...

yeah, known but forgotten.

hmmm ...
let's try :

>>> import Tkconstants
>>> 'YES' in dir(Tkconstants)
True
>>> 'True' in dir(Tkconstants)
False
>>> 'TRUE' in dir(Tkconstants)
True
>>> ('inexistent keyword') in dir(Tkconstants)
False

so
>>> 'TRUE' and 'YES' in dir(Tkconstants)
True
>>> 'inexistent keyword' and 'YES' in dir(Tkconstants)
True

i'll recite 42 times truth tables before going to bed.
however i didn't expect the following:

>>> 'inexistent keyword' or 'YES' in dir(Tkconstants)
'inexistent keyword'
>>> False or 'YES' in dir(Tkconstants)
True

hmmm...

>>> ('inexistent keyword' or 'YES') in dir(Tkconstants)
False
>>> (False or 'YES') in dir(Tkconstants)
True

i'll recite 42 times precedence rules before going to bed.
but now i'm a bit confused by the -in- operator. as:

>>> set(['TRUE','YES']).issubset(set(dir(Tkconstants)))
True

i expected this to be true, but it's not:

>>> set(['TRUE','YES']) in set(dir(Tkconstants))
False

originaly, i'm thinking to short-cut the following,
>>> reduce(lambda t,f: t and f, [i in dir(Tkconstants) for i in
'YES','inexistent keyword'])
False
>>> reduce(lambda t,f: t and f, [i in dir(Tkconstants) for i in
'TRUE','YES'])
True

but that was too short and i miss something!
i do reset my brain somewhere between cell234 and cell241
thanks for reading!

--
nirinA
--


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


Re: Listbox fill=BOTH expand=YES (Tkinter)

2005-03-17 Thread Raseliarison nirinA
"Christos TZOTZIOY Georgiou" wrote:
>
> the 'in' operator searches for existance of *elements* in a set, not
> of *subsets*.  BTW, only a frozenset can be included in a set.

ah! yes. that's clear now. thanks!
after all:

>>> for element in aset:
  print element,

why did i think that 'in' was another different operator?
the test should be then:

>>> 'TRUE' in dir(Tkconstants) and 'YES' in dir(Tkconstants)
True

and then:

>>> 'inexistent keyword' in dir(Tkconstants) and 'YES' in
dir(Tkconstants)
False

a bit cumbersome if there is a lot of keys to test.
i also found in the itertools-recipes the way to avoid
the reduce-lambda construction i had previously in head:

>>> from itertools import *
>>> def all(seq, pred=bool):
"Returns True if pred(x) is True for every element in the
iterable"
for elem in ifilterfalse(pred, seq):
return False
return True

>>> all(i in dir(Tkconstants) for i in ['TRUE', 'YES'])
True
>>> all(i in dir(Tkconstants) for i in ['TRUE', 'YES', 'inexistent
key'])
False

lovely...
i do not regret the fate of reduce et al.

>
> To check for subsets, either use the issubset function, or the '<'
operator (I
> believe they both call the same code):
>
> .>> set(['TRUE','YES']).issubset(set(dir(Tkconstants)))
> True
>
> can be expressed as
>
> .>> set(['TRUE','YES']) < set(dir(Tkconstants))
> True

i noted! thanks again.

--
nirinA
--



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


Re: Submission for Python Limmerick Contest

2005-03-22 Thread Raseliarison nirinA
> A tuple, a dict, and a list,
> And whitespace which mus'n't be missed.
> Imported together,
> And stirred with a feather,
> Yields a language whose name must be hissed!

A char, an integer and a float,
And a decimal which precision is fixed
Computerised altogether
Then shaked down with a mixer
Asserts a community whose goal must be attained!

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


Re: Submission for Python Limmerick Contest

2005-03-24 Thread Raseliarison nirinA
a penguin, a gnu and a snake
and an X animal participate in
a poem contest. who will win?

Ellipsis

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