Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Python Knowledge Base Update -- July 26th, 2000
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Fiona Czuczman  
View profile  
 More options Jul 26 2000, 3:00 am
Newsgroups: comp.lang.python
From: Fiona Czuczman <fi...@sitegnome.com>
Date: 2000/07/26
Subject: [FAQTS] Python Knowledge Base Update -- July 26th, 2000

Hi All,

The latest entries into http://python.faqts.com

regards,

Fiona Czuczman

Including:

- Manipulating PNG files using Win32 PIL
- How can I map the read() function of a file object?
- What is the fastest way to search a binary file for a certain byte
pattern (**** in my case)?
- Embedding Python code in a C++ program, I get dynamic linking errors
if I try to import any non-built in module, what's wrong?

## New Entries #################################################

-------------------------------------------------------------
Manipulating PNG files using Win32 PIL
http://www.faqts.com/knowledge-base/view.phtml/aid/5025
-------------------------------------------------------------
Fiona Czuczman
Olivier A. Dagenais

Problem:

I've writen a script to generate PNG images using PIL.  It works a treat
under Linux, but when I try to port it to MSWindows, the
PIL/PngImagePlugin spits saying that I don't have a zip encoder. I
already have a copy of pkzip, but I got hold of a copy of gzip.exe and
stuck it in C:\Windows\zip.exe but to no avail. Can anyone confirm that
I need a zip executable, or is the PIL wanting a DLL, etc?

Solution:

http://www.pythonware.com/downloads.htm

Says this, near the end of the page:

"Optional support libraries must be downloaded separately: jpeg and
zlib."

...you'll want to follow the zlib link:

ftp://ftp.freesoftware.com/.0/infozip/zlib/zlib.html

The zlib library is used for manipulating PNG files...

-------------------------------------------------------------
How can I map the read() function of a file object?
http://www.faqts.com/knowledge-base/view.phtml/aid/5028
-------------------------------------------------------------
Fiona Czuczman
Peter Schneider-Kamp, Bjorn Pettersen

Just use a lambda like this:

map(lambda f:open(f,"r").read(), list_of_filenames)

or perhaps:

  def openAndRead(filename):
      return open(filename).read()

  map( openAndRead, listOfFilenames )

-------------------------------------------------------------
What is the fastest way to search a binary file for a certain byte pattern (**** in my case)?
http://www.faqts.com/knowledge-base/view.phtml/aid/5029
-------------------------------------------------------------
Fiona Czuczman
Bjorn Pettersen

Use:

import string
string.find( open('my_binary_file','rb').read(), '****' )

-------------------------------------------------------------
Embedding Python code in a C++ program, I get dynamic linking errors if I try to import any non-built in module, what's wrong?
http://www.faqts.com/knowledge-base/view.phtml/aid/5030
-------------------------------------------------------------
Fiona Czuczman
Ted Drain

Problem:

I am trying to learn how to embed Python code in a C++ program. I got
the example from the docs (the one that imports sys and prints out a
couple of strings -- search from initxyzzy in google). The problem I get
is that if I try to import any non-built in module, I get dynamic
linking errors. For example, adding the following line 31 works:

_______________________________________________________________________
...
     29         /* Execute some Python statements (in module __main__)
*/
     30         PyRun_SimpleString("import sys\n");
-->  31         PyRun_SimpleString("import thread\n");
     32         PyRun_SimpleString("print sys.builtin_module_names\n");
...
_______________________________________________________________________

but adding the following line instead:

_______________________________________________________________________
...
     29         /* Execute some Python statements (in module __main__)
*/
     30         PyRun_SimpleString("import sys\n");
-->  31         PyRun_SimpleString("import random\n");
     32         PyRun_SimpleString("print sys.builtin_module_names\n");
...
_______________________________________________________________________

produces:

_______________________________________________________________________
[lopes@groucho lopes]$ ./demo
Hello, brave new world

Traceback (innermost last):
  File "<string>", line 1, in ?
  File "/usr/lib/python1.5/random.py", line 22, in ?
    import whrandom
  File "/usr/lib/python1.5/whrandom.py", line 140, in ?
    _inst = whrandom()
  File "/usr/lib/python1.5/whrandom.py", line 46, in __init__
    self.seed(x, y, z)
  File "/usr/lib/python1.5/whrandom.py", line 58, in seed
    import time
ImportError: /usr/lib/python1.5/lib-dynload/timemodule.so: undefined
symbol: PyExc_IOError
('__builtin__', '__main__', 'imp', 'marshal', 'pcre', 'posix', 'regex',
'signal', 'sys', 'thread')
['xyzzy', 'os.path', 'os', 'exceptions', '__main__', 'posix',
'whrandom', 'sys', '__builtin__', 'site', 'random', 'signal',
'UserDict', 'posixpath', 'stat']
./demo
['./demo']
_______________________________________________________________________

Solution:

If you're building w/ gcc, add the link line option:

-Wl,-E

This says to pass the -E option to the linker.  This option tells the
linker to make all statically linked symbols available to the dynamic
libraries.  Without it, the symbols linked from libpython1.5.a aren't
seen by symbols in the dynamic libraries.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »