firkin 0.02

2008-10-15 Thread Florian Diesch

I'm happy to announce release 0.02 of firkin
http://www.florian-diesch.de/software/firkin/



What is firkin?
===

   firkin is a python module to convert between different measurement
   units.

Status
==

   firkin is alpha software. So far it seems to work for me but it may
   have severe bugs I didn't noticed yet. Use it at your own risk.

   Firkin is still under development and the API may change in the future.

Requirements


   firkin only needs the Python standard lib

License
===

   GPL




   Florian
-- 
http://www.florian-diesch.de/
---
**  Hi! I'm a signature virus! Copy me into your signature, please!  **
---
--
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


Re: strip module bug

2008-10-15 Thread Tim Roberts
Poppy [EMAIL PROTECTED] wrote:

Thanks Steven and Tim, I understand the strip module a lot more today.

It's NOT a module.  It is a method of string objects.
-- 
Tim Roberts, [EMAIL PROTECTED]
Providenza  Boekelheide, Inc.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Deviation from object-relational mapping (pySQLFace)

2008-10-15 Thread sulyokpeti
On okt. 14, 10:09, Bruno Desthuilliers bruno.
[EMAIL PROTECTED] wrote:
 [EMAIL PROTECTED] a écrit :
 (snip)

  It is not convincing to look at an XML file alone. Let me give you an
  example. Glade is a GTK+ application for creating GTK+ GUI. It
  generates an XML file, that can be loaded in every programming
  language that has libglade binding.
  Similarly, there could be a
  database design tool to create a database, and save SQL/DML
  expressions into an XML config file.

 Why so ? What's wrong with a plain SQL file ? We already have a language
 for RDBMS schema description, and the schema description is itself
 stored in the RDBMS catalog so the SQL description can be regenerated
 from the RDBMS. I just don't see the point of storing all this in XML.

  Then you create the RDB command
  objects by loading the XML in your favourite language.
  I think programming languages are intended for describing neither relational
  databases nor GUIs.

 SQLAlchemy is an interesting attempt at integrating the relational model
 in a programming language.

 Ok, I don't mean neither of us is necessarily right and the other wrong
 - different POV, mostly, so I guess we can at least agree to disagree !-)

Plain SQL does not have a structure to easily handle metadata. XML has
several parsers, transformators like xmlto.
I am not going to reimplement relational stuff in XML or any
programming language. In my approach relational model is described in
SQL, processing is in a programming language, and XML is used for
interchange data. That data is actually SQL, and metadata to create
documentation.

I have looked into SQLAlchemy. I have seen this:
  users_table = Table('users', metadata, Column('id', Integer,
primary_key=True), Column('name', String), ...
  session.query(User,
Address).filter(User.id==Address.user_id).filter(Address.email_address=='[EMAIL 
PROTECTED]').all()
  users_table = Table('users', metadata, Column('id', Integer,
primary_key=True), Column('name', String), ...
...and I do not like it.
My favourite programming language is python because of its simple and
practical syntax. SQLAlchemy is something different, something like
what I do in full time, and something I am fed up with.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Anyone Have (XP) 2.4.4 Installed and Can Check This Simple matplotlib Program?

2008-10-15 Thread pjacobi . de
On Oct 15, 6:38 am, W. eWatson [EMAIL PROTECTED] wrote:
 I'm going to try another stab at this problem again. I'd like someone with
 2.4.4 and  matplotlib-0.98.3.win32-py2.4exe to try it (below).

IMHO an important detail of your configuration is missing. What's your
numerical library? Did you install a Win32 distribution including a
numerical library (which?), or which package do you have installed
separately?

In general I've used matplotlib with every Python version between 2.2
and 2.5 (inclusive) on Win32 without problem, but the separate
installation
was sometimes a problem.

Regards,
Peter

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


Re: Deviation from object-relational mapping (pySQLFace)

2008-10-15 Thread sulyokpeti
On okt. 14, 13:26, Paul Boddie [EMAIL PROTECTED] wrote:
 On 14 Okt, 00:43, [EMAIL PROTECTED] wrote:



  It is not convincing to look at an XML file alone. Let me give you an
  example. Glade is a GTK+ application for creating GTK+ GUI. It
  generates an XML file, that can be loaded in every programming
  language that has libglade binding. Similarly, there could be a
  database design tool to create a database, and save SQL/DML
  expressions into an XML config file. Then you create the RDB command
  objects by loading the XML in your favourite language.

 I'd agree that XML makes a good interchange representation which saves
 everyone from having to parse various things, but having worked a bit
 with relational databases and having had to actively manage their
 schemas, I have to say that my primary representation for a schema is
 SQL/DDL, and that my primary representation for queries is also SQL.
 Now, there's a lot to be said for making that SQL more consumable, and
 I've done a little work on converting SQL to XML (as have many others)
 in order to make life easier for, say, tool authors, and I'd even go
 as far as saying that it should be possible to convert XML back to
 SQL, but in doing so there would potentially remain a need for the XML
 dialect to be as expressive as SQL, which then means that you have to
 replicate SQL in XML.

  I think programming languages are intended for describing neither relational
  databases nor GUIs.

 The above discussion is somewhat tangential to what you've done,
 though, and I certainly didn't mean to say that the use of XML was in
 any way wrong, especially in the way you've been using it. I suppose
 that when you state the above about programming languages, you
 actually mean languages other than SQL. Even so, I'd much rather use
 SQL to describe a database table than one of the many different Python-
 based, class-plus-attributes representations so beloved of the various
 object-relational mappers.

 I look forward to seeing where you take your project in future,
 however.

 Paul

I agree more than you thought. I do not want to replace SQL with XML
either. I only use XML to interchange data (SQL/DML) between the
database designer (tool) and the application interface in order to
create a specific database interface for a certain database. It is the
focus of database design using different RDBMS-s and different
programming languages. There is an other reason for XML. At this point
my XML structure contains the SQL/DML expressions as you use it in sql
clients, and some metadata to generate documentation using XSL
transformation. That's why I provided that sqlface.xsl in the src
directory. Yes I have to relocate DTD and XSL from the python source
directory.
Relational stuff stays in the relational language SQL. Data
processing, and business logic goes into a programming language like
python. Otherwise I plan to support other languages with such an SQL
interface.

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


Re: problem using ctypes with MMX intrinsics

2008-10-15 Thread Lawrence D'Oliveiro
In message [EMAIL PROTECTED], dcharno
wrote:

 I can load the library and access functions inside it, but
 I getting a seg fault when I hit one of the intrinsics.

I assume that SIGSEGV indicates some (mis)alignment issue. If the
instructions were not valid, you'd get SIGILL instead.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Sending multi-part MIME package via HTTP-POST

2008-10-15 Thread Lawrence D'Oliveiro
In message
[EMAIL PROTECTED],
[EMAIL PROTECTED] wrote:

 ... but I'm getting a very vague server error message ...

Which is?

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


Re: Deviation from object-relational mapping (pySQLFace)

2008-10-15 Thread J Peyret
On Oct 12, 8:19 am, [EMAIL PROTECTED] wrote:

 I would like to get some opinions on this approach.
 Thanks.

I realize I will be minority here, but...

I've never quite understood why folks want to repeat the database's
metadata in XML files.  I've gotten much better results just using
plain ol' SQL throughout, sprinkled in with generated-on-the-fly SQL.


1.  A select clause identifies what is coming back from the db in the
cursor's description.  20 lines of code shoves that in a dictionary
for each row for any result set.  'Select * from table' works 90% of
the time for 1 table queries.  What does XML add?

2.  Inserts and deletes are relatively trivial to derive from
INFORMATION SCHEMA lookups on any given table and templates can be
generated for them.  Updates are admittedly less trivial, but not
horribly so.

3.  Query parameters can be added by simple %(colname)s embedded in
the query templates.That works great with dictionaries.  You can
extract them with a regular expression and replace them with '?' and a
list, if your DB-API flavor requires that.

4.  Plain ol' SQL can be cut and pasted in a query editor and can be
tested there.

5.  If you unit test somewhat aggressively, any db-schema changes will
result in unhappy queries dying because they don't see the columns
that they expect in the resultsets.  That keeps your Python code in
synch without feeding a layer of XML cruft.

6.  XML is plain nasty for simple local usage where you don't need
to communicate with a 3rd party app or module.  Conversely, XML is
great when you need to communicate data somewhere else, potentially
with recursive and nested structures.

7.  ANSI SQL is actually quite portable, if you know what to avoid
doing.

8.  Last, but not least.  Performance.

In complex processing on a database with large volumes, the last thing
you want to do is to fetch data to your client codeline, process it
there, and spew it back to the database.  Instead you want to shoot
off series of updates/deletes/insert-selects queries to the server and
you want to rely on set-based processing rather than row-by-row
approaches.  How do ORMs+XML help here?

My biggest hassle has been managing connection strings and catching
the weird Exception structures every Python db module figures it has
to re-implement, not the SQL itself.

Granted, if this were Java, you would need special data transfer
objects to encapsulate the results.  But is not Java.  And, also
granted, I _enjoy_ coding in SQL rather than trying to hide from it,
so YMMV.

Bottom line:  SQL is extremely dynamic in nature, even more so than
Python.  Why shackle it to static XML files?

P.S.

SQL Alchemy _is_ something I've been meaning to look at, because it
seems like they also _like_ SQL.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Can Python fix vcard files?

2008-10-15 Thread Dotan Cohen
2008/10/15 Lawrence D'Oliveiro [EMAIL PROTECTED]:
 I didn't find anything which forbids splitting quoted-printable
 character values in these specifications.

 What adds to the confusion is that quoted-printable has its own convention
 for soft-wrapping long lines, using an equals sign followed by a newline.

My test file has newlines not preceded by an equals sign:
NOTE;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:=D7=A9=D7=95=D7=A8=D7=94 =D7=A
 8=D7=90=D7=A9=D7=95=D7=A0=D7=94.\n=D7=94=D7=A9=D7=95=D7=A8=D7=94 =D7=94=D7=
 A9=D7=A0=D7=99=D7=94 =D7=9B=D7=\n

Is this not standards-compliant?

It is going to be a pain writing code to work around that!

-- 
Dotan Cohen

http://what-is-what.com
http://gibberish.co.il
א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת

ä-ö-ü-ß-Ä-Ö-Ü
--
http://mail.python.org/mailman/listinfo/python-list


Win32api.MessageBox

2008-10-15 Thread Unkwntech
When I use win32api.MessageBox from the interactive console from an
app that runs at the command line, it works and displays my alert just
fine however when I use it in a service that I built I can hear the
'beep' but the alert does not show and the program seems to stall
waiting for the alert to close, how can I have the alert show so that
the user can see what it says and press the button?
--
http://mail.python.org/mailman/listinfo/python-list


Re: Win32api.MessageBox

2008-10-15 Thread Bruno Desthuilliers

Unkwntech a écrit :

When I use win32api.MessageBox from the interactive console from an
app that runs at the command line, it works and displays my alert just
fine however when I use it in a service that I built I can hear the
'beep' but the alert does not show and the program seems to stall
waiting for the alert to close, how can I have the alert show so that
the user can see what it says and press the button?


I'm by no mean a Win32 expert, but IIRC, Windows 'services' (IOW : 
daemons) are not suppose to directly interact with the user. Now you'd 
better not take me on words on this...

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


Home Shop 18 - Zenith Desktop

2008-10-15 Thread Ayushi Mehra
Home Shop 18 - Zenith Desktop Model No: G31644
Features:

Processor:

* Pentium Core2Duo - E4600
* 2.4GHz
* 2 MB Cache
* 800 MHz FSB

Motherboard:

* Intel G31 Chipset Motherboard
* Supports 800/1066/1333 MHZ FSB
* Supports new generation 45nm CPU
* 2 DIMM Slots (RAM Slots), Upgradeable to 4GB using 2GB, Supports
Dual Channel
* Ultra DMA 100/66/33, Supports One IDE Device

Please visit :- http://www.diwali.homeshop18.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: replace mothod for only one object but not for a class

2008-10-15 Thread Bruno Desthuilliers

George Sakkis a écrit :
(snip)

You're right of course; that's what you get with minimal testing ;)
Still it works with a small modification, binding self to b as default
argument:

b.foo = lambda self=b: modified called on %s % self


Ok, now with a real use case : use a named function instead of a lambda, 
 and define the function before having access to b !-)



The functools.partial() solution shown before is the generalization of
this for more than one arguments. So I'm wondering, except for the
callable's exact type (bound method vs function vs functools.partial
object)  is there any other difference and a reason to prefer one over
the other ?


Consistency ? Possibly performances (NB : not benchmarked - might be 
worth a little homework to check this out) ?





If not, functools.partial() seems more readable than
calling explicitly the descriptor.


Perhaps is it just me starting to getting senile and resistant to new 
ideas, but while it does indeed work, I see the partial() solution as a 
WTF. Invoking function.__get__ *is* the obvious[1] way to get a bound 
method from a function.


[1] for anyone that know how Python turns functions into methods, that is...

But indeed, methods are specialized partial applications, and your 
solution is perfectly valid.

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


rope python-emacs problem

2008-10-15 Thread Rustom Mody
Ive been trying to use rope for python in emacs and I get
a backtrace which starts with
AttributeError: 'module' object has no attribute 'samefile'

Any ideas?
--
http://mail.python.org/mailman/listinfo/python-list


Re: xor: how come so slow?

2008-10-15 Thread John Machin
On Oct 15, 10:19 pm, Michele [EMAIL PROTECTED] wrote:
 Hi,
 I'm trying to encode a byte data. Let's not focus on the process of
 encoding; in fact, I want to emphasize that the method
 create_random_block takes 0.5s to be executed (even Java it's faster) on
 a Dual-Core 3.0Ghz machine:

 took 46.74679s, avg: 0.4674679s

 Thus I suppose that the xor operation between bytes raise the execution
 time to 0.5; why I suppose that?
 Because in Python there's no support for bytes and even for xoring
 bytes, so I used a workaround:
 I cycle on the two strings to be xor-red
     for every char in the strings
         convert one char on integer and then xor them; (ord)
         insert one char in the result, transforming the previous integer
 in char (chr)

 I suppose that ord() and char() are the main problems of my
 implementation, but I don't know either way to xor two bytes of data
 (bytes are represented as strings).
 For more information, see the code attached.

 How should I decrease the execution time?

 Thank you

 from __future__ import division
 import random
 import time
 import sha
 import os

 class Encoder(object):
     def create_random_block(self, data, seed, blocksize):
         number_of_blocks = int(len(data)/blocksize)
         random.seed(seed)
         random_block = ['0'] * blocksize

You possibly mean '\0' i.e. the byte all of whose bits are zero.

         for index in range(number_of_blocks):
             if int(random.getrandbits(1)) == 1:

getrandbits(1) produces a *long* with one random bit. Any good reason
for preferring this to randrange(2) and randint(0, 1)?

So there's a 50% chance that this block will be XORed into the result;
is that what you intend?

                 block = data[blocksize*index:blocksize*index+blocksize]

You don't need to slice out block, certainly not so awkwardly.


                 for bit in range(len(block)):


Perhaps you mean byte_index, not bit.

On my assumption that range(len(block)) is invariant: calculate it
once. That assumption is incorrect, so is your code for calculating
the number of blocks; it ignores a possible short block at the end.


                     random_block[bit] =
 chr(ord(random_block[bit])^ord(block[bit]))

The chr() and one ord() are utterly wasteful; leave random_block as a
list of ints and do the chr() thing in the return statement.

 # workaround per fare xor
 bit a bit di str; xor e' solo supportato per int - ord
         return ''.join(random_block)

this will become
   return ''.join(map(chr, random_block))
or
   return ''.join(chr(i) for i in random_block)
as taste or speed dictates :-)

So the whole thing becomes [not tested]:
def create_random_block(self, data, seed, blocksize):
datalen = len(data)
assert datalen % blocksize == 0
random.seed(seed)
random_block = [0] * blocksize
block_range = range(blocksize)
for start in xrange(0, datalen, blocksize):
if random.randrange(2):
for x in block_range:
random_block[x] ^= ord(data[start + x])
return ''.join(map(chr, random_block))

Looks slightly more athletic than before :-)

BTW, +1 misleading subject of the week; it's not XOR that's slow!!

Cheers,
John
--
http://mail.python.org/mailman/listinfo/python-list


multiprocessing: queue.get() blocks even if queue.qsize() != 0

2008-10-15 Thread redbaron
I run into problem with queue from multiprocessing. Even if I
queue.qsize() != 0 queue.get() still blocks and queue.get_nowait()
raises Emtpy error.

I'm unable to cut my big part to small test case, because smaller test
case similair to my real app by design is works. In what conditions is
it possible?

while qresult.qsize():
result = qresult.get()  #this code blocks!
doWithResult(result)
--
http://mail.python.org/mailman/listinfo/python-list


Re: Sending multi-part MIME package via HTTP-POST

2008-10-15 Thread Steve Holden
Lawrence D'Oliveiro wrote:
 In message
 [EMAIL PROTECTED],
 [EMAIL PROTECTED] wrote:
 
 ... but I'm getting a very vague server error message ...
 
 Which is?
 
very vague ...
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.com/

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


BDSM in BDSM mpeg

2008-10-15 Thread fernandena
BDSM http://youtubeplayer.byethost9.com/jpeg/bdsm.html BDSM
--
http://mail.python.org/mailman/listinfo/python-list


urllib accept-language doesn't have any effect

2008-10-15 Thread Martin Bachwerk

Hello,

I'm trying to load a couple of pages using the urllib2 module. The 
problem is that I live in Germany and some sites seem to look at the IP 
of the client and forward him to a localized page.. Here's an example of 
the code, how I want to access google.com main english page, but get 
German instead. (For those of you who live in US, you will probably get 
correct results.. try emulating with 'fr' in accepted languages or 
something)


opener = urllib2.build_opener()
opener.addheaders = [('Host', 'www.google.com'), 
('Accept-Language','en-gb,en;q=0.5'), ('User-agent', 'Mozilla/5.0 
(Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.1) Gecko/2008070208 
Firefox/3.0.1')]

webfile = opener.open(url)

Any help would be greatly appreciated!

Thank you!

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


Re: urllib accept-language doesn't have any effect

2008-10-15 Thread Diez B. Roggisch
Martin Bachwerk wrote:

 Hello,
 
 I'm trying to load a couple of pages using the urllib2 module. The
 problem is that I live in Germany and some sites seem to look at the IP
 of the client and forward him to a localized page.. Here's an example of
 the code, how I want to access google.com main english page, but get
 German instead. (For those of you who live in US, you will probably get
 correct results.. try emulating with 'fr' in accepted languages or
 something)
 
 opener = urllib2.build_opener()
 opener.addheaders = [('Host', 'www.google.com'),
 ('Accept-Language','en-gb,en;q=0.5'), ('User-agent', 'Mozilla/5.0
 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.1) Gecko/2008070208
 Firefox/3.0.1')]
 webfile = opener.open(url)
 
 Any help would be greatly appreciated!

What is your actual problem - does it work with *other* requests you somehow
produce (browser or some such)?

In the end, it's up to the site you query to return you whatever they see
fit. Nothing urllib or python in general can change.

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


Re: python3 - the hardest hello world ever ?

2008-10-15 Thread Helmut Jarausch

Ben Finney wrote:

Helmut Jarausch [EMAIL PROTECTED] writes:


I have to set an internal property (with leading underscore)
for each output file I'm using - right?


If you're referring to the source encoding declaration: No,
underscores have no effect. The specification is at
URL:http://www.python.org/doc/2.5.2/ref/encodings.html.


#!/usr/local/bin/python3.0
# _*_ coding: latin1 _*_


I'm not sure why you use underscores in this line. The usual form is
to use a mode line as recognised by Emacs::

# -*- coding: latin1 -*-

or Vim::

# vim: fileencoding=latin1 :



No, I meant the underscore in sys.stdout._encoding='latin1'
 ^

As for the source encoding, I have used the underscore version
which seems to work, as well.

Thanks,
Helmut.


--
Helmut Jarausch

Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany
--
http://mail.python.org/mailman/listinfo/python-list


Re: PyGUI as a standard GUI API for Python?

2008-10-15 Thread lkcl
On Oct 15, 12:27 am, greg [EMAIL PROTECTED] wrote:
 Paul Boddie wrote:
  there are a few things with
  regard to layouts which are very difficult with Web technologies (and
  aren't getting any easier, either) but which are almost trivial with
  classic graphical user interface toolkits, and of course there are
  cases where the roles are reversed.

 I've written quite a lot of desktop gui apps, and I
 don't think I've ever felt the need for free-flowing
 widget layouts.

 i have.  an image library.  placed in a scrollpanel, the images
automatically flow left-to-right then down the page.  the application
doesn't dictate what size of panel the user _must_ view the images
in.  if they want to use the whole screen width, they can.  if they
want to view the images in a single column, they can.


 To say that a desktop gui api is
 severely lacking without this feature is somewhat
 overstating the case.

 it's the _combination_ of the limitations that makes them severely
lacking.  each limitation on its own does not, of course.

 the key point is, really, that if you take away one particular layout
methodology from designers, they _will_ adapt - they _will_ cope, and
rejig the design of the app to fit the widget set.

 ... but that's cart-before-horse. that's IT tail wagging the
business Dog.

 so, when it comes to moving the same application functionality to a
different platform, or to the web, people freak out.  you're locked
in.  the cost is too great.  the effort is too much.

 ... as you might be aware, i'm not really a big fan of restrictions
imposed by software design :)


 Also, I think that proportional resizing is overrated.

 proportional resizing is very difficult to do well, and so many
people don't even consider it.  many designers will say this app is
to be used on a 1024x768 screen (and now of course they're running
into difficulties with the netbook pcs with the 1024x600 screens, and
KDE's control panel close button is now off-screen for example!)

it took several months to design a 2d graph widget which was useful
when scaled down to 200x150, especially given that the axes could be
logarithmic (!)  starting with the axes themselves, we had to break
things down into small, medium and large graticules, where the
distance between each range of graticules would no longer be
displayed, below a certain number of pixels (5 or so).  likewise with
the axes numbering. then the axis description had to go, below a
certain size.

then, we had controls (sliders and dials) where, again, the graticules
automatically disappeared, and, also, if below a certain size, the
readout would also disappear.

so if you're doing _simple_ applications, then yes, proportional
resizing is entirely unnecessary.

but if you're doing applications where you have to display vast
amounts of interactive graphical data (the example above was a real-
time digital audio restoration GUI) then you really do have to think a
bit harder about what you're going to present the user with.

  Proportional resizing is a
 compromise that just ends up annoying me.

 if it's done badly, then yeah, i agree.

 if you look, for example, at the source code of my web site,
http://lkcl.net/site_code, you'll see that the site is capable of
resizing to deal with anything down to about 300 pixels in width.  the
onResize function redoes the layout, placing the seven components in a
hexagon if there's space, a side-on H below 800 pixels, and a single
line below 640 pixels.

 it didn't take too much effort, and it means that anyone viewing my
web site even on a QVGA screen won't have to do horizontal scrolling.

not that i'm _expecting_ anyone to do that - i just wanted to prove a
point :)


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


recommendations for a web CMS (content management system)?

2008-10-15 Thread Joe Strout
We need to set up a content management system that allows nontechnical  
users to manage the content of their web site.  Rather than starting  
from scratch, I'd prefer to start with an existing CMS that we can  
extend as needed.  So, I'd prefer something with nice clean, easy-to- 
follow code over something that includes everything but the kitchen  
sink.


Any suggestions?

Thanks,
- Joe


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


Kicking off a python script using Windows Scheduled Task

2008-10-15 Thread korean_dave
Does anyone know how to properly kick off a script using Windows
Scheduled Task? The script calls other python modules within itself.
HERE'S THE CATCH:
I am used to running the script directly from the command window and
the print() is very handy for us to debug and monitor. When running
the task from Windows Scheduled Task, we'd like to be able to view the
command window and keep it up after the Task has completed...

I used the commands

CMD /K

cd C:\testdirectory\script_RunTests

python AutomatedTestRun.py

but when AutomatedTestRun.py calls other python modules, we don't see
output.
--
http://mail.python.org/mailman/listinfo/python-list


Re: urllib accept-language doesn't have any effect

2008-10-15 Thread Martin Bachwerk

Hi,

yes, well my browser settings are set to display sites in following 
languages en-gb then en.


As a matter of fact, Google does indeed show me the German site first, 
before I click on go to google.com and it probably stores a cookie to 
remember that.


But a site like gizmodo.com forwards me directly to the English site 
(even though they have a German version available). But the Python call 
returns the German version. How does that make sense?


Cheers,
Martin

Martin Bachwerk wrote:

  

Hello,

I'm trying to load a couple of pages using the urllib2 module. The
problem is that I live in Germany and some sites seem to look at the IP
of the client and forward him to a localized page.. Here's an example of
the code, how I want to access google.com main english page, but get
German instead. (For those of you who live in US, you will probably get
correct results.. try emulating with 'fr' in accepted languages or
something)

opener = urllib2.build_opener()
opener.addheaders = [('Host', 'www.google.com'),
('Accept-Language','en-gb,en;q=0.5'), ('User-agent', 'Mozilla/5.0
(Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.1) Gecko/2008070208
Firefox/3.0.1')]
webfile = opener.open(url)

Any help would be greatly appreciated!



What is your actual problem - does it work with *other* requests you somehow
produce (browser or some such)?

In the end, it's up to the site you query to return you whatever they see
fit. Nothing urllib or python in general can change.

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

  


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


Re: recommendations for a web CMS (content management system)?

2008-10-15 Thread Bruno Desthuilliers

Joe Strout a écrit :
We need to set up a content management system that allows nontechnical 
users to manage the content of their web site.  Rather than starting 
from scratch, I'd prefer to start with an existing CMS that we can 
extend as needed.  So, I'd prefer something with nice clean, 
easy-to-follow code over something that includes everything but the 
kitchen sink.


Any suggestions?


You may find something - at least a starting point - in the couple CMS 
built with Django...


And by all means avoid Plone - great CMS but certainly falls in your 
second category !-)


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


Re: python3 - the hardest hello world ever ?

2008-10-15 Thread Paul Boddie
On 15 Okt, 12:08, Helmut Jarausch [EMAIL PROTECTED]
wrote:

 What defines me as latin1-user?

What does sys.stdout.encoding say? In Python 2.x, at least, that
attribute should reflect the capabilities of your environment
(specifically, the character encoding) and help determine whether it
makes sense for Python to try and encode Unicode objects (plain
strings in Python 3.x) using a particular output encoding when
printing those objects to the display.

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


Re: urllib accept-language doesn't have any effect

2008-10-15 Thread Diez B. Roggisch
Martin Bachwerk wrote:

 Hi,
 
 yes, well my browser settings are set to display sites in following
 languages en-gb then en.
 
 As a matter of fact, Google does indeed show me the German site first,
 before I click on go to google.com and it probably stores a cookie to
 remember that.
 
 But a site like gizmodo.com forwards me directly to the English site
 (even though they have a German version available). But the Python call
 returns the German version. How does that make sense?

I don't know. You need to have a look at what the browser communicates,
through a tool like tcpmon or wireshark. Once you've gathered all needed
header-information, you can mimic the same request using urllib.

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


Re: recommendations for a web CMS (content management system)?

2008-10-15 Thread Diez B. Roggisch
Joe Strout wrote:

 We need to set up a content management system that allows nontechnical
 users to manage the content of their web site.  Rather than starting
 from scratch, I'd prefer to start with an existing CMS that we can
 extend as needed.  So, I'd prefer something with nice clean, easy-to-
 follow code over something that includes everything but the kitchen
 sink.

I can recommend ZMS (zms-publishing.com). While being ZOPE-based, it's
custom content object system (fully web-interface-driven design for these,
plus DTML) hasn't left me with the desire to code anything apart from a few
Extension-methods where ZOPE's restricted environment forced me to.

And it is very feature-complete.

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


Python equivalent to SharePoint?

2008-10-15 Thread Joe Strout
We've got a client who has been planning to use SharePoint for  
managing their organization documents, but has recently dropped that  
idea and is looking for an alternative.  Is there any Python package  
with similar functionality?


I confess that I've never used SharePoint myself, and what I know  
about is mainly from these sources:


  http://en.wikipedia.org/wiki/SharePoint
  http://discuss.joelonsoftware.com/default.asp?joel.3.66103.7

I found a reference to CPS, but its developers have dropped the Python  
source to rewrite it in Java.  That's disturbing, and I don't want to  
recommend an abandoned platform.  Anything else I should consider?


Thanks,
- Joe

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


RE: Kicking off a python script using Windows Scheduled Task

2008-10-15 Thread Andreas Tawn
 Does anyone know how to properly kick off a script using Windows
 Scheduled Task? The script calls other python modules within itself.
 HERE'S THE CATCH:
 I am used to running the script directly from the command window and
 the print() is very handy for us to debug and monitor. When running
 the task from Windows Scheduled Task, we'd like to be able to view the
 command window and keep it up after the Task has completed...
 
 I used the commands
 
 CMD /K
 
 cd C:\testdirectory\script_RunTests
 
 python AutomatedTestRun.py
 
 but when AutomatedTestRun.py calls other python modules, we don't see
 output.

Import os and add os.system(pause) at the end of AutomatedTestRun.py
to keep cmd open.

As far as not seeing any output, I haven't had any trouble with that
before. Maybe you're doing something unusual?

Have you tried using the logging module, rather than print? Might be
more useful for what you're trying to do.

Cheers,

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


Re: multiprocessing: queue.get() blocks even if queue.qsize() != 0

2008-10-15 Thread MRAB
On Oct 15, 2:05 pm, redbaron [EMAIL PROTECTED] wrote:
 I run into problem with queue from multiprocessing. Even if I
 queue.qsize() != 0 queue.get() still blocks and queue.get_nowait()
 raises Emtpy error.

 I'm unable to cut my big part to small test case, because smaller test
 case similair to my real app by design is works. In what conditions is
 it possible?

 while qresult.qsize():
     result = qresult.get()  #this code blocks!
     doWithResult(result)

From Python v2.5 onwards queues also have a task_done() method. Try:

while qresult.qsize():
result = qresult.get()  #this code blocks!
doWithResult(result)
qresult.task_done()
--
http://mail.python.org/mailman/listinfo/python-list


Re: [CentOS] App Question.

2008-10-15 Thread Les Mikesell

bruce wrote:

Hi list!!

Got a question, and I can't find a good answer for, so I figured i'd post
here. I'm working on a project that involves a number of smaller apps to be
developed, and run. In order to build this overall application, I'm trying
to find a web based app that I can use to manage the entire process.

I need to be able to create the basic app, and then to test the app, and
then to run the app in a production environment. I need to be able to
schedule when the app is tested/run in the production system, as well as be
able to track the status of the test/production app. My overall system will
have 100's of these smaller child apps.

Has anyone heard of, or have any pointers to any kind of webbased app that I
can use (open source) to manage this entire kind of process. I would prefer
a web based app, that runs on a LAMP platform to manage this overall
process


It is sort of java-oriented, but cruisecrontrol manages that sort of 
thing: http://cruisecontrol.sourceforge.net/index.html.


--
  Les Mikesell
   [EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list


Re: urllib accept-language doesn't have any effect

2008-10-15 Thread Philip Semanchuk


On Oct 15, 2008, at 9:50 AM, Martin Bachwerk wrote:


Hello,

I'm trying to load a couple of pages using the urllib2 module. The  
problem is that I live in Germany and some sites seem to look at the  
IP of the client and forward him to a localized page.. Here's an  
example of the code, how I want to access google.com main english  
page, but get German instead. (For those of you who live in US, you  
will probably get correct results.. try emulating with 'fr' in  
accepted languages or something)


opener = urllib2.build_opener()
opener.addheaders = [('Host', 'www.google.com'), ('Accept- 
Language','en-gb,en;q=0.5'), ('User-agent', 'Mozilla/5.0 (Windows;  
U; Windows NT 5.1; en-GB; rv:1.9.0.1) Gecko/2008070208 Firefox/ 
3.0.1')]

webfile = opener.open(url)


Martin,
It looks to me like what you're sending is correct. Debugging  
suggestions --


- Set up a Web server on 127.0.0.1 and see what that server receives  
when your Python code connects to it. Maybe you're not sending quite  
what you think.
- Try emulating your Python code with wget or a similar command line  
tool that lets you set headers.
- Sniff the conversation you're having with google using Wireshark.  
Maybe you're getting redirected by the remote server.


Good luck
Philip
--
http://mail.python.org/mailman/listinfo/python-list


Ooo 3.0 Python user macros

2008-10-15 Thread Lawrence D'Oliveiro
Has anyone been able to run user-defined Python macros in OpenOffice.org
3.0? I had one in ~/.ooo-2.0/user/Scripts/python/try.py which did work
under Ooo2.x. So I put the same thing in ~/.ooo3/user/Scripts/python/, but
it will not show up in any macro dialog in Ooo 3.0.

The provided example macros seem to work: under the Tools - Macros -
Organize Macros - Python... menu, there is an entry named OpenOffice.org
Macros, and I can run the macros that are listed in there. So that
suggests the basic Ooo 3.0 Python macro system is functional.

Thanks for any suggestions.
--
http://mail.python.org/mailman/listinfo/python-list


Re: newbie - merging xls files using xldt and xlwt

2008-10-15 Thread Albert-jan Roskam
Hi John,

Thanks! Using a higher xlrd version did the trick! Regarding your other remarks:
-yep, input files with multiple sheets don't work yet. I kinda repressed that 
;-) Spss outputs only single-sheet xls files, but I agree it's nicer if the 
programs works in other cases too.
-and no, I don't intend to use data fields. Wouldn't it be easier to convert 
those to string values if I ever came across them?

Thanks again!
Albert-Jan


--- On Wed, 10/15/08, John Machin [EMAIL PROTECTED] wrote:

 From: John Machin [EMAIL PROTECTED]
 Subject: Re: newbie - merging xls files using xldt and xlwt
 To: python-list@python.org
 Date: Wednesday, October 15, 2008, 3:14 PM
 On Oct 15, 9:16 pm, Albert-jan Roskam
 [EMAIL PROTECTED] wrote:
  Hi,
 
  I wrote the program below to merge all xls files in a
 given directory into one multisheet xls file. It uses xlwt
 and xlrd. The xls files I use for input are generated by
 Spss. When I open and re-save the files in Excel, the
 program works, but when I use the xls files as they were
 created by Spss, the program returns an error message (see
 below). Some details: Python 2.4, xlwt version 0.7.0, xlrd
 version 0.5.2, Win NT.
 
  Any ideas?
 
 The version of xlrd that you are using is an antique. Go to
 http://pypi.python.org/pypi/xlrd and get the latest
 version. If that
 doesn't work, send me a copy of one of the files that
 is displaying
 this problem.
 
  Thanks in advance!
 
  Albert-Jan
 
  
  Merge all xls files in a given directory into one
 multisheet xls file.
  The sheets get the orginal file name, without the
 extension.
  File names should not exceed 31 characters, as this is
 the maximum
  sheet name length
  
 
  import xlrd, xlwt
  import glob, os.path
 
  def merge_xls (in_dir,
 out_file=d:/merged_output.xls):
 
      xls_files   = glob.glob(in_dir +
 *.xls)
      sheet_names = []
      merged_book = xlwt.Workbook()
 
      [sheet_names.append(os.path.basename(v)[:-4])
 for k, v in enumerate(xls_files)]
 
 Wah! Try this:
 sheet_names = [os.path.basename(v)[:-4]) for v in
 xls_files]
 
 
      for k, xls_file in enumerate(xls_files):
          if len (sheet_names[k]) = 31:
              book = xlrd.open_workbook(xls_file)
              ws =
 merged_book.add_sheet(sheet_names[k])
              for sheetx in range(book.nsheets):
                  sheet =
 book.sheet_by_index(sheetx)
                  for rx in range(sheet.nrows):
                      for cx in
 range(sheet.ncols):
                           ws.write(rx, cx,
 sheet.cell_value(rx, cx))
 
 I presume that you're not too worried about any date
 data.
 
 If an input file has more than 1 sheet, you are creating
 only one
 sheet in the output file, and overwriting cells.
 
          else:
 [snip]
 
  merge_xls(in_dir=d:/temp/)
 
  *** WARNING: OLE2 inconsistency: SSCS size is 0 but
 SSAT size is non-zero ***
  put_cell 0 1
 
  Traceback (most recent call last):
 [snip]
      self._cell_types[rowx][colx] = ctype
  IndexError: list assignment index out of range
 
 Yeah, symptom of an xls file with a DIMENSIONS records that
 lies ...
 xlrd has like Excel become more resilient over time :-)
 
 BTW, consider joining the python-excel group at
 http://groups.google.com/group/python-excel
 
 Cheers,
 John
 --
 http://mail.python.org/mailman/listinfo/python-list


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


Re: docpicture

2008-10-15 Thread Pete Forman
Scott David Daniels [EMAIL PROTECTED] writes:

  or you could even use:
'''docpicture name=fig1.png code=base64 version=1
1234567890ABCDEF...
/docpicture'''
  A comment _not_ a docstring (only found by scanning the source).
  which is easy enough to hunt for.

-1 for XML based syntax, we should instead look to reST.  It already
has image and figure directives.  The docs say that image takes a URI
argument and some options.  So an external file should work now.
Maybe someone would like to play with the data URL scheme (RFC 2397)
to meet the OP's desire to embed the image.  AFAIK a downside is that
MS are only starting to support that in IE8.
-- 
Pete Forman-./\.-  Disclaimer: This post is originated
WesternGeco  -./\.-   by myself and does not represent
[EMAIL PROTECTED]-./\.-   the opinion of Schlumberger or
http://petef.22web.net   -./\.-   WesternGeco.
--
http://mail.python.org/mailman/listinfo/python-list


ANN: eGenix mx Base Distribution 3.1.1 for Python 2.6

2008-10-15 Thread eGenix Team: M.-A. Lemburg


ANNOUNCING

eGenix.com mx Base Distribution

 Version 3.1.1 for Python 2.6

  Open Source Python extensions providing important and useful
  services for Python programmers.


This announcement is also available on our web-site for online reading:
http://www.egenix.com/company/news/eGenix-mx-Base-Distribution-3.1.1-for-Python-2.6.html



ABOUT

The eGenix.com mx Base Distribution for Python is a collection of
professional quality software tools which enhance Python's usability
in many important areas such as fast text searching, date/time
processing and high speed data types.

The tools have a proven record of being portable across many Unix and
Windows platforms. You can write applications which use the tools on
Windows and then run them on Unix platforms without change due to the
consistent platform independent interfaces.

Contents of the distribution:

 * mxDateTime - Date/Time Library for Python
 * mxTextTools - Fast Text Parsing and Processing Tools for Python
 * mxProxy - Object Access Control for Python
 * mxBeeBase - On-disk B+Tree Based Database Kit for Python
 * mxURL - Flexible URL Data-Type for Python
 * mxUID - Fast Universal Identifiers for Python
 * mxStack - Fast and Memory-Efficient Stack Type for Python
 * mxQueue - Fast and Memory-Efficient Queue Type for Python
 * mxTools - Fast Everyday Helpers for Python

All available packages have proven their stability and usefulness in
many mission critical applications and various commercial settings all
around the world.

* About Python:
Python is an object-oriented Open Source programming language which
runs on all modern platforms (http://www.python.org/). By integrating
ease-of-use, clarity in coding, enterprise application connectivity
and rapid application design, Python establishes an ideal programming
platform for todays IT challenges.

* About eGenix:
eGenix is a consulting and software product company focused on
providing professional quality services and products to Python
users and developers (http://www.egenix.com/).



NEWS

The 3.1.1 release of the eGenix mx Base Distribution is the latest
release of our open-source Python extensions.

Now that Python 2.6 has been released by the Python Software
Foundation, we have added pre-built binaries for all supported
platforms, currently: Windows 32-bit, Linux 32-bit, Linux 64-bit,
FreeBSD 32-bit, FreeBSD 64-bit.

Whether you are using a pre-built package or the source distribution,
installation is a simple python setup.py install command in all
cases. The only difference is that the pre-built packages do not
require a compiler to be installed.

For a list of changes, please refer to the eGenix mx Base Distribution
change log at

http://www.egenix.com/products/python/mxBase/changelog.html

and the change logs of the various included Python packages.



DOWNLOADS

The download archives and instructions for installing the packages can
be found on the eGenix mx Base Distribution page:

http://www.egenix.com/products/python/mxBase/



LICENSE

The eGenix mx Base package is distributed under the eGenix.com Public
License 1.1.0 which is a CNRI Python License style Open Source
license.  You can use the package in both commercial and
non-commercial settings without fee or charge.

The package comes with full source code



SUPPORT

Commercial support for this product is available from eGenix.com.
Please see

http://www.egenix.com/services/support/

for details about our support offerings.

Enjoy,
-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Oct 15 2008)
 Python/Zope Consulting and Support ...http://www.egenix.com/
 mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
 mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/


 Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! 


   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
   Registered at Amtsgericht Duesseldorf: HRB 46611


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


ANN: eGenix mxODBC - ODBC Database Interface for Python 3.0.2

2008-10-15 Thread eGenix Team: M.-A. Lemburg


ANNOUNCING

eGenix.com mxODBC - ODBC Database Interface for Python

  Version 3.0.2


   mxODBC is our commercially supported Python extension providing
ODBC database connectivity to Python applications
 on Windows and Unix platforms


This announcement is also available on our web-site for online reading:
http://www.egenix.com/company/news/eGenix-mxODBC-3.0.2-GA.html



INTRODUCTION

mxODBC provides an easy-to-use, high-performance, reliable and robust
Python interface to ODBC compatible databases such as MS SQL Server,
MS Access, Oracle Database, IBM DB2 and Informix , Sybase ASE and
Sybase Anywhere, MySQL, PostgreSQL, SAP MaxDB and many more.

The eGenix mxODBC - ODBC Database Interface for Python product is a
commercial extension to our open-source eGenix mx Base Distribution.

* About Python:
Python is an object-oriented Open Source programming language which
runs on all modern platforms (http://www.python.org/). By integrating
ease-of-use, clarity in coding, enterprise application connectivity
and rapid application design, Python establishes an ideal programming
platform for todays IT challenges.

* About eGenix:
eGenix is a consulting and software product company focused on
providing professional quality services and products to Python
users and developers (http://www.egenix.com/).



NEWS

mxODBC 3.0.2 is a patch-level release and includes the following
updates:

* Python 2.6 support

  mxODBC 3.0.2 is now available for Python 2.6, compiled with the same
  MS VS 2008 edition used by the Python developers to build Python 2.6
  binaries for enhanced compatibility.

* Enhanced support for using TEXT and VARCHAR columns with binary
  data

  ODBC drivers which need the Python type binding, like e.g. the
  FreeTDS ODBC driver, will now be able to pass binary data to text
  columns in most cases.

* Updated work-arounds for various ODBC drivers

  eGenix always aims to make using mxODBC as easy and robust as
  possible. For this reason, we regularly add or update work-arounds
  for problems found in recent ODBC driver versions.

  This release includes updated or new work-arounds for the MySQL ODBC
  driver, the Informix ODBC driver and the SQL Server 2005 ODBC
  driver.

* Enhanced Python datetime module support

  mxODBC 3.0 already supports the datetime module found in Python 2.4
  and later.

  With this release, we have additionally added support for the
  datetime module found in Python 2.3.

For the full set of changes please check the mxODBC change log:

http://www.egenix.com/products/python/mxODBC/changelog.html



DOWNLOADS

The download archives and instructions for installing the package can
be found at:

http://www.egenix.com/products/python/mxODBC/

In order to use the eGenix mxODBC package you will first need to
install the eGenix mx Base package:

http://www.egenix.com/products/python/mxBase/



UPGRADING

You are encouraged to upgrade to this latest mxODBC release,
especially if you are using MS SQL Server or Informix as database
server.

Customers who have purchased mxODBC 3.0 licenses can download and
install this patch-level release on top of their existing
installations. The licenses will continue to work with version 3.0.2.

Users of mxODBC 2.0 will have to purchase new licenses from our online
shop in order to upgrade to mxODBC 3.0.2.

You can request 30-day evaluation licenses by visiting our web-site at

http://www.egenix.com/products/python/mxODBC/#Evaluation

or writing to [EMAIL PROTECTED], stating your name (or the name of the
company) and the number of eval licenses that you need.

___

SUPPORT

Commercial support for this product is available from eGenix.com.
Please see

http://www.egenix.com/services/support/

for details about our support offerings.

Enjoy,
-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Oct 15 2008)
 Python/Zope Consulting and Support ...http://www.egenix.com/
 mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
 mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/


 Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! 


   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
   Registered at Amtsgericht Duesseldorf: HRB 46611


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


Re: Kicking off a python script using Windows Scheduled Task

2008-10-15 Thread korean_dave
Hey all. i solved this problem by logging on with my network domain
login (log in using...)

instead of NT AUTHORITY\SYSTEM which only gave out local privleges to
the process started off by Task scheduler.

On Oct 15, 10:36 am, korean_dave [EMAIL PROTECTED] wrote:
 Does anyone know how to properly kick off a script using Windows
 Scheduled Task? The script calls other python modules within itself.
 HERE'S THE CATCH:
 I am used to running the script directly from the command window and
 the print() is very handy for us to debug and monitor. When running
 the task from Windows Scheduled Task, we'd like to be able to view the
 command window and keep it up after the Task has completed...

 I used the commands

 CMD /K

 cd C:\testdirectory\script_RunTests

 python AutomatedTestRun.py

 but when AutomatedTestRun.py calls other python modules, we don't see
 output.

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


Re: python3 - the hardest hello world ever ?

2008-10-15 Thread Helmut Jarausch

Paul Boddie wrote:

On 15 Okt, 12:08, Helmut Jarausch [EMAIL PROTECTED]
wrote:

What defines me as latin1-user?


What does sys.stdout.encoding say? In Python 2.x, at least, that


It says  ansi_x3.4-1968

Where can I change this?

attribute should reflect the capabilities of your environment
(specifically, the character encoding) and help determine whether it
makes sense for Python to try and encode Unicode objects (plain
strings in Python 3.x) using a particular output encoding when
printing those objects to the display.



Thanks,
Helmut.


--
Helmut Jarausch

Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany
--
http://mail.python.org/mailman/listinfo/python-list


Re: Can Python fix vcard files?

2008-10-15 Thread Dotan Cohen
2008/10/14  [EMAIL PROTECTED]:

Dotan Can Python go through a directory of files and replace each
Dotan instance of newline-space with nothing?

 Sure.  Something like (*completely* untested, so caveat emptor):

import glob
import os

for f in glob.glob('*.vcf'):
# corrupt data
uncooked = open(f, 'rb').read()
# fix it
cooked = uncooked.replace('\n ', '')
# backup original file for safety
os.rename(f, '%s.orig' % f)
# and save it
open(f, 'wb').write(cooked)


The regex seems to be catching more than I would expect it to:

[EMAIL PROTECTED]:~/test$ cat test.vcf
BEGIN:VCARD
FN:First Last
N:Last;First;;;
NOTE;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:First Line.\nThe Second Line i
 s long so that it will wrap. Long\, long\, and wrapping!=\n\nThird Line.\n
UID:frh74xvYZ9
VERSION:2.1
END:VCARD

BEGIN:VCARD
FN;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:=D7=90=D7=90=D7=A4=D7=A8=D7=98=D
 7=99 =D7=9E=D7=A9=D7=A4=D7=97=D7=94
N;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:=D7=9E=D7=A9=D7=A4=D7=97=D7=94;=D
 7=90=D7=90=D7=A4=D7=A8=D7=98=D7=99;;;
NOTE;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:=D7=A9=D7=95=D7=A8=D7=94 =D7=A
 8=D7=90=D7=A9=D7=95=D7=A0=D7=94.\n=D7=A9=D7=95=D7=A8=D7=94 =D7=A9=D7=A0=D7=
 99=D7=94 =D7=94=D7=99=D7=90 =D7=\n=90=D7=A8=D7=95=D7=9B=D7=94\, =D7=9B=D7=9
 3=D7=99 =D7=A9=D7=A0=D7=A8=D7=90=\n =D7=90=D7=95=D7=AA=D7=94 =D7=92=D7=95=D
 7=9C=D7=A9=D7=AA. =D7=90=D7=A8=D7=\n=95=D7=9B=D7=94\, =D7=90=D7=A8=D7=95=D7
 =9B=D7=94\, =D7=95=D7=92=D7=95=D7=9C=\n=D7=A9=D7=AA!\n=D7=A9=D7=95=D7=A8=D7
 =94 =D7=A9=D7=9C=D7=99=D7=A9=D7=99=D7=AA.\n
UID:KqbQKbfBaF
VERSION:2.1
END:VCARD

[EMAIL PROTECTED]:~/test$ python ./fix.py
[EMAIL PROTECTED]:~/test$ cat test.vcf
BEGIN:VCARD
FN:First Last
N:Last;First;;;
s long so that it will wrap. Long\, long\, and wrapping!=\n\nThird Line.\ni
UID:frh74xvYZ9
VERSION:2.1
END:VCARD

BEGIN:VCARD
7=99 =D7=9E=D7=A9=D7=A4=D7=97=D7=94INTABLE:=D7=90=D7=90=D7=A4=D7=A8=D7=98=D
7=90=D7=90=D7=A4=D7=A8=D7=98=D7=99;;;ABLE:=D7=9E=D7=A9=D7=A4=D7=97=D7=94;=D
=94 =D7=A9=D7=9C=D7=99=D7=A9=D7=99=D7=AA.\nA9=D7=AA!\n=D7=A9=D7=95=D7=A8=D7
UID:KqbQKbfBaF
VERSION:2.1
END:VCARD

[EMAIL PROTECTED]:~/test$


Why is that? I tried to fix it, but I do not even see what is wrong to
fix! It looks god to me.

-- 
Dotan Cohen

http://what-is-what.com
http://gibberish.co.il
א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת

ä-ö-ü-ß-Ä-Ö-Ü
--
http://mail.python.org/mailman/listinfo/python-list


xor: how come so slow?

2008-10-15 Thread Michele
Hi,
I'm trying to encode a byte data. Let's not focus on the process of
encoding; in fact, I want to emphasize that the method
create_random_block takes 0.5s to be executed (even Java it's faster) on
a Dual-Core 3.0Ghz machine:

took 46.74679s, avg: 0.4674679s

Thus I suppose that the xor operation between bytes raise the execution
time to 0.5; why I suppose that?
Because in Python there's no support for bytes and even for xoring
bytes, so I used a workaround:
I cycle on the two strings to be xor-red
for every char in the strings
convert one char on integer and then xor them; (ord)
insert one char in the result, transforming the previous integer
in char (chr)

I suppose that ord() and char() are the main problems of my
implementation, but I don't know either way to xor two bytes of data
(bytes are represented as strings).
For more information, see the code attached.

How should I decrease the execution time? 

Thank you


from __future__ import division
import random
import time
import sha
import os

class Encoder(object):
def create_random_block(self, data, seed, blocksize):
number_of_blocks = int(len(data)/blocksize)
random.seed(seed)
random_block = ['0'] * blocksize
for index in range(number_of_blocks):
if int(random.getrandbits(1)) == 1:
block = data[blocksize*index:blocksize*index+blocksize]
for bit in range(len(block)):
random_block[bit] =
chr(ord(random_block[bit])^ord(block[bit])) # workaround per fare xor
bit a bit di str; xor e' solo supportato per int - ord
return ''.join(random_block)


x = Encoder()
piece = os.urandom(1024*1024)
blocksize = 16384
t1 = time.time()
for l in range(100):
seed = random.getrandbits(32)
block = x.create_random_block(piece, seed, blocksize)
t2 = time.time()
print 'took ' + str(t2-t1) + 's, avg: ' + str((t2-t1)/100.0) + 's'
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python equivalent to SharePoint?

2008-10-15 Thread Paul Boddie
On 15 Okt, 17:17, Joe Strout [EMAIL PROTECTED] wrote:
 We've got a client who has been planning to use SharePoint for  
 managing their organization documents, but has recently dropped that  
 idea and is looking for an alternative.  Is there any Python package  
 with similar functionality?

Here's a starting point:

http://wiki.python.org/moin/ContentManagementSystems

Plone is probably the first thing that comes to mind.

 I confess that I've never used SharePoint myself, and what I know  
 about is mainly from these sources:

    http://en.wikipedia.org/wiki/SharePoint
    http://discuss.joelonsoftware.com/default.asp?joel.3.66103.7

The Wiki vs. CMS thing is relevant, even though I imagine that
corporate types like to pooh-pooh the idea of Wikis, preferring as
they do to use their CMS or intranet solution as yet another shared
folder for their Word documents. What I know from experiences trying
to build a willing editing community around the EuroPython site was
that people didn't like to stray anywhere near CPS, but people could
be coerced into editing Wiki content; the PyCon UK site had even more
contributions from random conference attendees. Of course, a corporate
CMS typically involves the imposition of such a system on employees -
that's one way not to bother about user acceptance since everyone
implicitly says yes once the roll-out begins - but as one commenter
on Joel's article notes, even the fanciest solutions require a degree
of willing maintenance, and if it all starts to rot then the whole
point of introducing such a system is undermined.

 I found a reference to CPS, but its developers have dropped the Python  
 source to rewrite it in Java.  That's disturbing, and I don't want to  
 recommend an abandoned platform.  Anything else I should consider?

There may be other solutions not included on the page I mention above.
I remember being shown SharePoint a few years back by a fellow
consultant, and apart from the fancy drag-and-drop layout tools I was
strongly reminded of Slashdot, of which the consultant was naturally
unaware. At that time, for the basics of a community site such as
certain kinds of intranets, Zope plus Squishdot would have been
acceptable, but any absence of steep licensing costs isn't necessarily
an advantage in the consulting business since such stuff usually gets
passed onto the brand-obsessed customer.

With regard to proper document management, I think we'll
increasingly see developments around the revitalised area of version
control systems and their integration with Web-based solutions.
Subversion, for example, is already a Web-based solution in itself -
you'd just need to put a presentation logic layer on top.

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


Using variable in storbinary function of ftpilb module

2008-10-15 Thread Arya, Manish Kumar
Hi,

  I am new to python.

I have written a simple code to upload a file via ftp to remote server

-
import sys
import ftplib
host=sys.argv[1]
username=sys.argv[2]
passwd=sys.argv[3]
filename=sys.argv[4]

print host,username,passwd

ftp = ftplib.FTP(host,username,passwd)
fd=open(filename,'rb')
ftp.storbinary('STOR filename',fd)
---

I am passing file name in cmd line arg. but I have no idea how to use 
filename variable value in ftp.storbinary('STOR filename',fd) ?




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


Re: Anyone Have (XP) 2.4.4 Installed and Can Check This Simple matplotlib Program?

2008-10-15 Thread W. eWatson

[EMAIL PROTECTED] wrote:

On Oct 15, 6:38 am, W. eWatson [EMAIL PROTECTED] wrote:

I'm going to try another stab at this problem again. I'd like someone with
2.4.4 and  matplotlib-0.98.3.win32-py2.4exe to try it (below).


IMHO an important detail of your configuration is missing. What's your
numerical library? Did you install a Win32 distribution including a
numerical library (which?), or which package do you have installed
separately?

In general I've used matplotlib with every Python version between 2.2
and 2.5 (inclusive) on Win32 without problem, but the separate
installation
was sometimes a problem.

Regards,
Peter

I'm pretty new to Python, so how do I find the versions? I see IDLE provides 
a path browser. Can it tell me? I see various items in a tree: scipy PIL, 
Numeric_headers:package, LibearAlgebra.py, numpy etc. Under 
numeric_version.py, it shows 2.4.


--
   W. eWatson

 (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
  Obz Site:  39° 15' 7 N, 121° 2' 32 W, 2700 feet

Web Page: www.speckledwithstars.net/

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


Re: python3 - the hardest hello world ever ?

2008-10-15 Thread Paul Boddie
On 15 Okt, 17:59, Helmut Jarausch [EMAIL PROTECTED] wrote:
 Paul Boddie wrote:
  What does sys.stdout.encoding say? In Python 2.x, at least, that

 It says  ansi_x3.4-1968

That's ASCII, yes.

 Where can I change this?

What's your locale? I can provoke the same setting if I run a Python
program like this:

LC_ALL=en_US.ascii python xxx.py

Are you running some kind of GNU/Linux distribution or something else?
If the former, have you installed various language/locale packages? If
you're not sure, which language or country did you select when
installing or configuring your system? This may seem like an odd line
of questioning, but UNIX-like systems have a history of treating
everything as bytes, which works acceptably until you have to take a
stand on what those bytes mean.

Another important question: what does Python 2.x do with the following
program...?

import sys
print sys.stdout.encoding
print u\xe6\xf8\xe5

You should get three Scandinavian characters if the encoding and
locales match. Otherwise, you'll either get a different output
(indicating a mismatch) or an error (indicating that the environment
cannot handle the characters output by the program). Sometimes you can
persuade a terminal to use a different character set, and this might
help, too.

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


Re: python3 - the hardest hello world ever ?

2008-10-15 Thread Diez B. Roggisch
Helmut Jarausch wrote:

 Paul Boddie wrote:
 On 15 Okt, 12:08, Helmut Jarausch [EMAIL PROTECTED]
 wrote:
 What defines me as latin1-user?
 
 What does sys.stdout.encoding say? In Python 2.x, at least, that
 
 It says  ansi_x3.4-1968
 
 Where can I change this?

By changing your console's terminal settings. See what

locale -a

outputs. 

See this:


(devtools)[EMAIL PROTECTED]:~$ locale -a
C
en_AU.utf8
en_BW.utf8
en_CA.utf8
en_DK.utf8
en_GB.utf8
en_HK.utf8
en_IE.utf8
en_IN
en_NZ.utf8
en_PH.utf8
en_SG.utf8
en_US.utf8
en_ZA.utf8
en_ZW.utf8
POSIX
(devtools)[EMAIL PROTECTED]:~$ python
Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type help, copyright, credits or license for more information.
Welcome to rlcompleter2 0.96
for nice experiences hit tab multiple times
 import sys
 sys.stdout.encoding
'UTF-8'



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


Re: [egenix-info] ANN: eGenix mx Base Distribution 3.1.1 for Python 2.6

2008-10-15 Thread M.-A. Lemburg
Just to let you know: we also provide binaries and support for
Mac OS X Intel and PPC.

Thanks to Joe Strout for pinging us about this.

On 2008-10-15 17:41, eGenix Team: M.-A. Lemburg wrote:
 
 
 ANNOUNCING
 
 eGenix.com mx Base Distribution
 
  Version 3.1.1 for Python 2.6
 
   Open Source Python extensions providing important and useful
   services for Python programmers.
 
 
 This announcement is also available on our web-site for online reading:
 http://www.egenix.com/company/news/eGenix-mx-Base-Distribution-3.1.1-for-Python-2.6.html
 
 
 
 ABOUT
 
 The eGenix.com mx Base Distribution for Python is a collection of
 professional quality software tools which enhance Python's usability
 in many important areas such as fast text searching, date/time
 processing and high speed data types.
 
 The tools have a proven record of being portable across many Unix and
 Windows platforms. You can write applications which use the tools on
 Windows and then run them on Unix platforms without change due to the
 consistent platform independent interfaces.
 
 Contents of the distribution:
 
  * mxDateTime - Date/Time Library for Python
  * mxTextTools - Fast Text Parsing and Processing Tools for Python
  * mxProxy - Object Access Control for Python
  * mxBeeBase - On-disk B+Tree Based Database Kit for Python
  * mxURL - Flexible URL Data-Type for Python
  * mxUID - Fast Universal Identifiers for Python
  * mxStack - Fast and Memory-Efficient Stack Type for Python
  * mxQueue - Fast and Memory-Efficient Queue Type for Python
  * mxTools - Fast Everyday Helpers for Python
 
 All available packages have proven their stability and usefulness in
 many mission critical applications and various commercial settings all
 around the world.
 
 * About Python:
 Python is an object-oriented Open Source programming language which
 runs on all modern platforms (http://www.python.org/). By integrating
 ease-of-use, clarity in coding, enterprise application connectivity
 and rapid application design, Python establishes an ideal programming
 platform for todays IT challenges.
 
 * About eGenix:
 eGenix is a consulting and software product company focused on
 providing professional quality services and products to Python
 users and developers (http://www.egenix.com/).
 
 
 
 NEWS
 
 The 3.1.1 release of the eGenix mx Base Distribution is the latest
 release of our open-source Python extensions.
 
 Now that Python 2.6 has been released by the Python Software
 Foundation, we have added pre-built binaries for all supported
 platforms, currently: Windows 32-bit, Linux 32-bit, Linux 64-bit,
 FreeBSD 32-bit, FreeBSD 64-bit.
 
 Whether you are using a pre-built package or the source distribution,
 installation is a simple python setup.py install command in all
 cases. The only difference is that the pre-built packages do not
 require a compiler to be installed.
 
 For a list of changes, please refer to the eGenix mx Base Distribution
 change log at
 
 http://www.egenix.com/products/python/mxBase/changelog.html
 
 and the change logs of the various included Python packages.
 
 
 
 DOWNLOADS
 
 The download archives and instructions for installing the packages can
 be found on the eGenix mx Base Distribution page:
 
 http://www.egenix.com/products/python/mxBase/
 
 
 
 LICENSE
 
 The eGenix mx Base package is distributed under the eGenix.com Public
 License 1.1.0 which is a CNRI Python License style Open Source
 license.  You can use the package in both commercial and
 non-commercial settings without fee or charge.
 
 The package comes with full source code
 
 
 
 SUPPORT
 
 Commercial support for this product is available from eGenix.com.
 Please see
 
 http://www.egenix.com/services/support/
 
 for details about our support offerings.
 
 Enjoy,

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Oct 15 2008)
 Python/Zope Consulting and Support ...http://www.egenix.com/
 mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
 mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/


 Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! 


   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
   Registered at Amtsgericht Duesseldorf: HRB 46611
--
http://mail.python.org/mailman/listinfo/python-list

Re: python3 - the hardest hello world ever ?

2008-10-15 Thread Orestis Markou

I would just use UTF-8 and be done with it.

Set your editor to write UTF-8 files, set the correct #coding at your  
python script, make sure your terminal supports outputting UTF-8  
characters (and your font has the correct glyphs) and everything  
should be fine. No trickery required.


Even for Python 2.x, the only extra thing needed was the u kind of  
strings. No other trickery in sys.stdout required. What platform do  
you use?


Orestis
--
[EMAIL PROTECTED]
http://orestis.gr/




On 15 Oct 2008, at 11:12, Helmut Jarausch wrote:


Brian Quinlan wrote:

Hey Helmut,
Did you try just:
print(Hallo, Süßes Python)


Yes, but that doesn't work here.
Please see my reply to Martin's reply.

Thanks,
Helmut.



--
Helmut Jarausch

Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany
--
http://mail.python.org/mailman/listinfo/python-list


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


Re: [ANN] Data Plotting Library DISLIN 9.4

2008-10-15 Thread M�ta-MCI (MVP)

Hello!



version 9.4 of DISLIN


Thanks! 
I like Dislin.

But...
I don't found the release (binary/win) for Python 2.6...

--
Michel Claveau


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


Re: xor: how come so slow?

2008-10-15 Thread Seun Osewa
My answer is: never do things like this with python.
You will find this module useful: www.pycrypto.org

On Oct 15, 12:19 pm, Michele [EMAIL PROTECTED] wrote:
 Hi,
 I'm trying to encode a byte data. Let's not focus on the process of
 encoding; in fact, I want to emphasize that the method
 create_random_block takes 0.5s to be executed (even Java it's faster) on
 a Dual-Core 3.0Ghz machine:

 took 46.74679s, avg: 0.4674679s

 Thus I suppose that the xor operation between bytes raise the execution
 time to 0.5; why I suppose that?
 Because in Python there's no support for bytes and even for xoring
 bytes, so I used a workaround:
 I cycle on the two strings to be xor-red
     for every char in the strings
         convert one char on integer and then xor them; (ord)
         insert one char in the result, transforming the previous integer
 in char (chr)

 I suppose that ord() and char() are the main problems of my
 implementation, but I don't know either way to xor two bytes of data
 (bytes are represented as strings).
 For more information, see the code attached.

 How should I decrease the execution time?

 Thank you

 from __future__ import division
 import random
 import time
 import sha
 import os

 class Encoder(object):
     def create_random_block(self, data, seed, blocksize):
         number_of_blocks = int(len(data)/blocksize)
         random.seed(seed)
         random_block = ['0'] * blocksize
         for index in range(number_of_blocks):
             if int(random.getrandbits(1)) == 1:
                 block = data[blocksize*index:blocksize*index+blocksize]
                 for bit in range(len(block)):
                     random_block[bit] =
 chr(ord(random_block[bit])^ord(block[bit])) # workaround per fare xor
 bit a bit di str; xor e' solo supportato per int - ord
         return ''.join(random_block)

 x = Encoder()
 piece = os.urandom(1024*1024)
 blocksize = 16384
 t1 = time.time()
 for l in range(100):
     seed = random.getrandbits(32)
     block = x.create_random_block(piece, seed, blocksize)
 t2 = time.time()
 print 'took ' + str(t2-t1) + 's, avg: ' + str((t2-t1)/100.0) + 's'

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


Re: Overloading operators

2008-10-15 Thread Aaron Castironpi Brady
On Oct 15, 7:34 am, Mr.SpOOn [EMAIL PROTECTED] wrote:
 Hi,
 in a project I'm overloading a lot of comparison and arithmetic
 operators to make them working with more complex classes that I
 defined.

 Sometimes I need a different behavior of the operator depending on the
 argument. For example, if I compare a object with an int, I get a
 result, but if I compare the same object with a string, or another
 object, I get another result.

 What is the best way to do this? Shall I use a lot of if...elif
 statements inside the overloaded operator? Or is there a more pythonic
 and dynamic way?

Multimethods do the thing you're looking for.  Google: 'python
multimethods' gives:

http://www.artima.com/weblogs/viewpost.jsp?thread=101605

by van Rossum.  Some examples:

from mm import multimethod

@multimethod(int, int)
def foo(a, b):
...code for two ints...

@multimethod(float, float):
def foo(a, b):
...code for two floats..

It is especially good if you're using inheritance.  You could also
collect the names of the types, and call a function by name:

(untested)
fname= a.__class__.__name__+ '_'+ b.__class__.__name__
or
fname= re.sub( '[^a-Za-z0-9]+', '', str( type( a ) ) ) + same
type( b )
ffunc= getattr( namespace, fname )

or build a dictionary.

(untested)
f= {}
f[ int, int ]= compA
f[ int, str ]= compB
...
ffunc= f[ type( a ), type( b ) ]

What's your favorite?
--
http://mail.python.org/mailman/listinfo/python-list


Re: Overloading operators

2008-10-15 Thread Robert Lehmann
On Wed, 15 Oct 2008 14:34:14 +0200, Mr.SpOOn wrote:

 Hi,
 in a project I'm overloading a lot of comparison and arithmetic
 operators to make them working with more complex classes that I defined.
 
 Sometimes I need a different behavior of the operator depending on the
 argument. For example, if I compare a object with an int, I get a
 result, but if I compare the same object with a string, or another
 object, I get another result.
 
 What is the best way to do this? Shall I use a lot of if...elif
 statements inside the overloaded operator? Or is there a more pythonic
 and dynamic way?

If all your comparison methods do more or less the same (even if not but 
then it will be kinda less useful for complex operations) you could use 
dictionary-based dispatching. You would basically construct a dictionary 
of type-comparator mappings, like this::

dispatch = {
int: int_compare_function,
str: str_compare_function,
}

And dispatch according to the other object's type::

def __cmp__(self, other):
return dispatch[type(other)]()

(Assuming good faith and just throwing a `KeyError` for unimplemented 
types.)

If you just needed to dispatch on a special attribute depending on the 
other object's type, you could redesign the dispatch dictionary to be a 
type-attribute mapping and go somewhere along this way::

dispatch = {
int: 'value',
str: 'name',
}
def __cmp__(self, other):
return cmp(getattr(self, dispatch[type(other)]), other)

HTH,

-- 
Robert Stargaming Lehmann
--
http://mail.python.org/mailman/listinfo/python-list


Re: xor: how come so slow?

2008-10-15 Thread bearophileHUGS
Few suggestions for your code:
- Use xrange instead of range.
- Loop over lists where you can instead of their indexes.
- array.array(B, somestring) may help you because it gives a byte
view of a string.
- Using psyco helps a lot for such kind of code.
- I think numpy arrays can contain text/chars too, so it may offer you
ways to speed up your code a lot.
- Generally Python is fit to download pages from the net or to act as
glue between different subsystems, or to do bulk string processing,
etc, but for grunt low-level works like this it's often too much slow,
and you can use other lower-level languages.
- You can use a lib already written, or use an extension, for example
you can try ShedSkin, or Pyd.

Bye,
bearophile
--
http://mail.python.org/mailman/listinfo/python-list


Re: python3 - the hardest hello world ever ?

2008-10-15 Thread Helmut Jarausch

Martin v. Löwis wrote:

do I miss something (I do hope so) or is switching to Python3
really hard for Latin1-users?


Why do you want to switch? sys.stdout.encoding should already be
iso-8859-1, if you are a Latin1-user.



What defines me as latin1-user?

commenting
# sys.stdout._encoding='latin1'


I get
Traceback (most recent call last):
  File latin1.py, line 8, in module

  File /usr/local/lib/python3.0/io.py, line 1485, in write
b = encoder.encode(s)
  File /usr/local/lib/python3.0/encodings/ascii.py, line 22, in encode
return codecs.ascii_encode(input, self.errors)[0]
UnicodeEncodeError: 'ascii' codec can't encode characters in position 1-2: 
ordinal not in range(128)


So my system seems to be an ASCII system?


Thanks,
Helmut

--
Helmut Jarausch

Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany
--
http://mail.python.org/mailman/listinfo/python-list


Re: Distributing compiled (swig) python modules

2008-10-15 Thread Diez B. Roggisch
mathieu wrote:

 Hi there,
 
   I have prepared binaries of a python module that I wrote. Basically
 the lib is written in C++ and wrapped in python using SWIG. Of course
 it links to the python dynamic libraries. I found out that this is
 version dependant. For instance if I prepare the binaries on my
 machine with a python 2.4 installation this module will not load
 properly on a python 2.5 / 2.6 installation.
 
   Is there some documentation (that I missed in my previous google
 search) that describe how to prepare python module that can be
 redistributed with some kind of backward compatibility (= so that when
 prepared on python 2.4, it works on 2.5/2.6 at least) ?

There is no such way, and can't be because of C-API-changes in python.dlls.
You will have to offer your library separately for each python version you
support.

I don't know too much about SWIG, but if you can make your whole
build-process based on distutils or setuptools, you should be able to
produce eggs to install that your users then can install very easy.

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


Re: replace mothod for only one object but not for a class

2008-10-15 Thread hofer
On Oct 14, 7:50 pm, hofer [EMAIL PROTECTED] wrote:
 Hi,

 I have multiple objects all belonging to the same class
  (which I didn't implement and whose code I don't want to modify)

 Now I'd like to change one method for one object only (after it has
 been created) without adding any overhead
 to the call of the other object's methods.

 Is this possible?

 Example
 # This is NOT what I'd like to do
 # as it overwrites the method for all objects of this class
 o1 = aclass()
 o2 = aclass()
 # call original method
 o1.method()
 o2.method()
 # overwrite the method for the entire class
 aclass.method = mymethod
 o1.method() # now new method
 o2.method() # now new method

 ### What doesn't work, but what I'd like to do
 o1 = aclass()
 o2 = aclass()
 # call original method
 o1.method()
 o2.method()
 # overwrite the method for the entire class
 o1.method = mymethod
 o1.method() # now new method
 o2.method() # still old method

 thanks for any pointers.

 P.S. I guess, that there is a computer science term for what I try to
 achieve.
 If anybody knew it I would be interested to learn it as well.


Thanks a lot this works.
Though I must admint, that even after reading the doc I don't really
understand why.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Using variable in storbinary function of ftpilb module

2008-10-15 Thread Diez B. Roggisch
Arya, Manish Kumar wrote:

 Hi,
 
   I am new to python.
 
 I have written a simple code to upload a file via ftp to remote server
 
 -
 import sys
 import ftplib
 host=sys.argv[1]
 username=sys.argv[2]
 passwd=sys.argv[3]
 filename=sys.argv[4]
 
 print host,username,passwd
 
 ftp = ftplib.FTP(host,username,passwd)
 fd=open(filename,'rb')
 ftp.storbinary('STOR filename',fd)
 ---
 
 I am passing file name in cmd line arg. but I have no idea how to use
 filename variable value in ftp.storbinary('STOR filename',fd) ?

ftp.storbinary(STOR %s % filename, fd)

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


Distributing compiled (swig) python modules

2008-10-15 Thread mathieu
Hi there,

  I have prepared binaries of a python module that I wrote. Basically
the lib is written in C++ and wrapped in python using SWIG. Of course
it links to the python dynamic libraries. I found out that this is
version dependant. For instance if I prepare the binaries on my
machine with a python 2.4 installation this module will not load
properly on a python 2.5 / 2.6 installation.

  Is there some documentation (that I missed in my previous google
search) that describe how to prepare python module that can be
redistributed with some kind of backward compatibility (= so that when
prepared on python 2.4, it works on 2.5/2.6 at least) ?

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


Re: Deviation from object-relational mapping (pySQLFace)

2008-10-15 Thread Bruno Desthuilliers

J Peyret a écrit :

On Oct 12, 8:19 am, [EMAIL PROTECTED] wrote:


I would like to get some opinions on this approach.
Thanks.


I realize I will be minority here, but...


Then count me in - as long as all SQL stuff is cleanly encapsulated in 
it's own module and called via appropriate functions / objects (have 
mercy, no SQL in controler and views).


(snip - mostly agree)

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


Re: python3 - the hardest hello world ever ?

2008-10-15 Thread Helmut Jarausch

Brian Quinlan wrote:

Hey Helmut,

Did you try just:

print(Hallo, Süßes Python)



Yes, but that doesn't work here.
Please see my reply to Martin's reply.

Thanks,
Helmut.



--
Helmut Jarausch

Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany
--
http://mail.python.org/mailman/listinfo/python-list


Re: Installing Python 2.4 over 2.4?

2008-10-15 Thread Martin v. Löwis
   More a generic -- some applications allow one control over optional
 features. Change would let one, uhm, change the options that were
 installed; repair attempt to restore the installation to the
 configuration that had been last installed.

In the specific case of Python, the typical choice is whether or not to
install the tests, and whether or not to install Tkinter.

Regards,
Martin
--
http://mail.python.org/mailman/listinfo/python-list


Re: Can Python fix vcard files?

2008-10-15 Thread skip
Dotan The regex seems to be catching more than I would expect it to:
...

Worked for me.  The directory I ran the script in had your sample and one
other VCF file.  It made the apparently correct changes to yours.  The other
was unchanged.

Dotan Why is that? I tried to fix it, but I do not even see what is
Dotan wrong to fix! It looks god to me.

Just out of curiosity, are the line endings CRLF perchance?  If so, try
changing the replace call like this:

cooked = uncooked.replace('\r\n ', '')

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


IDE Question

2008-10-15 Thread Steve Phillips
Hi All,
I am just wondering what seems to be the most popular IDE. The reason
I ask is I am currently at war with myself when it comes to IDE's. It
seems like every one I find and try out has something in it that
others don't and viceversa. I am in search for the perfect IDE and
after many months of searching, I always come back to IDLE to do what
I need to do. I want to use Komodo badly but the one issue I have with
that is sometimes the auto-complete works and other times it doesn't.
Even if I carbon copy a script.

Thanks in advance,
Steve P
--
http://mail.python.org/mailman/listinfo/python-list


multiprocessing: Queue.get_nowait() never returns data

2008-10-15 Thread redbaron
I stuck in new multiprocessing module (ex. processing). I dont'
understand why queue.get_nowait() never returns data, but always
raises Empty, even if it is guaranteed that queue is not empty.

I've created small test case, here it is: http://pastebin.ca/1227666

Hope someone could explain why I'm wrong.It designed for 2.6 with
multiprocessing module,but it's trivial to convert it to processing
module for 2.5, just replace multiprocessing with processing and
freeze_support with freezeSupport
--
http://mail.python.org/mailman/listinfo/python-list


Re: Win32api.MessageBox

2008-10-15 Thread Duncan Booth
Bruno Desthuilliers [EMAIL PROTECTED] wrote:

 Unkwntech a écrit :
 When I use win32api.MessageBox from the interactive console from an
 app that runs at the command line, it works and displays my alert just
 fine however when I use it in a service that I built I can hear the
 'beep' but the alert does not show and the program seems to stall
 waiting for the alert to close, how can I have the alert show so that
 the user can see what it says and press the button?
 
 I'm by no mean a Win32 expert, but IIRC, Windows 'services' (IOW : 
 daemons) are not suppose to directly interact with the user. Now you'd 
 better not take me on words on this...
 
It's an option when you install the service. By default services will run 
under the 'local system' account and have no access to the desktop. You can 
either give the service permission to interact with the desktop from the 
service properties (or specify --interactive if installing it with 
win32serviceutil).

-- 
Duncan Booth http://kupuguy.blogspot.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: Can Python fix vcard files?

2008-10-15 Thread Paul Boddie
On 15 Okt, 06:40, Lawrence D'Oliveiro [EMAIL PROTECTED]
central.gen.new_zealand wrote:
 In message [EMAIL PROTECTED], Paul Boddie wrote:
  I didn't find anything which forbids splitting quoted-printable
  character values in these specifications.

 What adds to the confusion is that quoted-printable has its own convention
 for soft-wrapping long lines, using an equals sign followed by a newline.

I think the necessary approach involves interpreting data in the vCard
content model before interpreting data in the quoted-printable
content model. That is, follow the vCard rules around line
formatting to first reconstruct encoded content, then do what you
would normally do with that encoded content. It's a bit like parsing
XML and then attempting to read text from the document's parsed
representation, rather than just matching a particular region with a
regular expression and finding that it yields lt; and gt;
instead of the expected  and .

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


Re: multiprocessing: Queue.get_nowait() never returns data

2008-10-15 Thread redbaron
my fault. changing continue to break solves the problem
--
http://mail.python.org/mailman/listinfo/python-list


Re: replace mothod for only one object but not for a class

2008-10-15 Thread Bruno Desthuilliers

hofer a écrit :

Hi


hofer a écrit :

I have multiple objects all belonging to the same class
 (which I didn't implement and whose code I don't want to modify)
Now I'd like to change one method for one object only (after it has
been created) without adding any overhead
to the call of the other object's methods.


Thanks for all of your answers:

Here an example with three of the suggested solutions:
(I didn't succeed in implementing Jason's solution with my
example)


import threading
# some objects
a = threading.Event()
b = threading.Event()
c = threading.Event()
d = threading.Event()

def run_dly(o): # a test function
print o,start,
o.wait(1)
print stop

# unmodified test
run_dly(a)
run_dly(b)
run_dly(c)
run_dly(d)

# The new Method
def verbose_wait(self,dly):
print VERBOSE,
threading._Event.wait(self,dly)


Note that given your use case, you could have used a decorator here 
instead...


def verbose(method):
def _verbose(*args, **kw):
print %s called on %s % (method.__name__, method.im_self)
print args : , args,  - kwargs : , kw
return method(*args, **kw)

_verbose.__name__ = verbose wrapper for %s % method.__name__
return _verbose

b.wait = verbose(b.wait)



Or if you want a more extensible - and reversible - solution:


class VerboseMethod(object):
def __init__(self, method, before=None, after=None):
# we only want bound methods here
obj = getattr(method, im_self, None)
if obj is None:
err = %s expected a bound method, got %s % (
   type(self), method
   )
raise ValueError(err)

self._method = method
self._before = before
self._after = after

def _verbose_before(self, *args, **kw):

You subclass VerboseMethod and taylor this to your own needs,
or alternatively pass a 'before' callback to VerboseMethod
that will get called with method, *args, **kw

if callable(self._before):
self._before(self._method, *args, **kw)
return
# default
m = self._method
print %s about to be called on %s % (m.__name__, m.im_self)
print args : , args,  - kwargs : , kw

def _verbose_after(self, result, *args, **kw):

You subclass VerboseMethod and taylor this to your own needs,
or alternatively pass an 'after' callback to VerboseMethod
that will get called with method, result, *args, **kw

if callable(self._after):
self._after(self._method, result, *args, **kw)
return
# default
m = self._method
print %s called on %s % (m.__name__, m.im_self)
print args : , args,  - kwargs : , kw
print result : , result

def __call__(self, *args, **kw):
self._verbose_before(*args, **kw)
result = self._method(*args, **kw)
self._verbose_after(result, *args, **kw)
return result

def drop(self):
restore the original method...
obj = self._method.im_self
delattr(obj, self._method.__name__)



class B(object):
def __init__(self, name):
self.name = name

def wait(self, dly=42):
return %s.wait(%s) % (self.name, dly)

b1 = B('b1')
b2 = B('b2')

print b1.wait()
print b2.wait()

b1.wait = VerboseMethod(b1.wait)
print b1.wait()
print b2.wait()

b1.wait.drop()
print b1.wait()
print b2.wait()

def before(m, *args, **kw):
print test before
print m, args, kw


def after(m, r, *args, **kw):
print test after
print m, r, args, kw

b1.wait = VerboseMethod(b1.wait, before=before, after=after)
print b1.wait()
print b2.wait()

b1.wait.drop()
print b1.wait()
print b2.wait()


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


Re: replace mothod for only one object but not for a class

2008-10-15 Thread hofer
Hi

  hofer a écrit :
  I have multiple objects all belonging to the same class
   (which I didn't implement and whose code I don't want to modify)

  Now I'd like to change one method for one object only (after it has
  been created) without adding any overhead
  to the call of the other object's methods.

Thanks for all of your answers:

Here an example with three of the suggested solutions:
(I didn't succeed in implementing Jason's solution with my
example)


import threading
# some objects
a = threading.Event()
b = threading.Event()
c = threading.Event()
d = threading.Event()

def run_dly(o): # a test function
print o,start,
o.wait(1)
print stop

# unmodified test
run_dly(a)
run_dly(b)
run_dly(c)
run_dly(d)

# The new Method
def verbose_wait(self,dly):
print VERBOSE,
threading._Event.wait(self,dly)

### Implemented with partial
from functools import partial
b.wait = partial(verbose_wait,b)

###   with __get__ for new classes
c.wait = verbose_wait.__get__(c,type(c))

## with new for old classes
import new
d.wait = new.instancemethod(verbose_wait,d,type(d))

run_dly(a)
run_dly(b)
run_dly(c)
run_dly(d)
# end
thanks again

Hofer

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


Re: IDE Question

2008-10-15 Thread Chris Rebert
You can find a list and several reviews on
http://wiki.python.org/moin/IntegratedDevelopmentEnvironments
I think Wing IDE (http://www.wingware.com/products) is generally
thought to be the most sophisticated one; but it's neither open-source
nor gratis (they do let noncommerical open-source devs get a free copy
though).
From what I've heard anecdotally, most Pythonistas don't use IDEs,
instead opting for just a text editor (often vim or emacs). So the
answer to your question is probably None.

Cheers,
Chris
-- 
Follow the path of the Iguana...
http://rebertia.com

On Wed, Oct 15, 2008 at 10:19 AM, Steve Phillips [EMAIL PROTECTED] wrote:
 Hi All,
 I am just wondering what seems to be the most popular IDE. The reason
 I ask is I am currently at war with myself when it comes to IDE's. It
 seems like every one I find and try out has something in it that
 others don't and viceversa. I am in search for the perfect IDE and
 after many months of searching, I always come back to IDLE to do what
 I need to do. I want to use Komodo badly but the one issue I have with
 that is sometimes the auto-complete works and other times it doesn't.
 Even if I carbon copy a script.

 Thanks in advance,
 Steve P
 --
 http://mail.python.org/mailman/listinfo/python-list

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


Re: IDE Question

2008-10-15 Thread Fabio Zadrozny
 I am just wondering what seems to be the most popular IDE. The reason
 I ask is I am currently at war with myself when it comes to IDE's. It
 seems like every one I find and try out has something in it that
 others don't and viceversa. I am in search for the perfect IDE and
 after many months of searching, I always come back to IDLE to do what
 I need to do. I want to use Komodo badly but the one issue I have with
 that is sometimes the auto-complete works and other times it doesn't.
 Even if I carbon copy a script.


Sorry, but the perfect IDE of choice is a way too subjective thing to
have only one answer. Take a look at
http://wiki.python.org/moin/IntegratedDevelopmentEnvironments and take
your own conclusions...

Cheers,

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


Re: Can Python fix vcard files?

2008-10-15 Thread Dotan Cohen
2008/10/15  [EMAIL PROTECTED]:
 Just out of curiosity, are the line endings CRLF perchance?  If so, try
 changing the replace call like this:

cooked = uncooked.replace('\r\n ', '')


Apparently they were CRLF. Actually, I think that is part of the Vcard
spec. Now, it seems that I have a few other problems, but they seem to
be bugs in Kontact.

Thank you very much for the help. I've learned how to open and save
files, and how to search and replace text. I probably could have
gotten that far after a some time googling, but you've probably saved
me a good day or two. Furthermore, I would have had trouble finding
out which libraries to include at the head. Thanks!

-- 
Dotan Cohen

http://what-is-what.com
http://gibberish.co.il
א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת

ä-ö-ü-ß-Ä-Ö-Ü
--
http://mail.python.org/mailman/listinfo/python-list


newbie - merging xls files using xldt and xlwt

2008-10-15 Thread Albert-jan Roskam
Hi,

I wrote the program below to merge all xls files in a given directory into one 
multisheet xls file. It uses xlwt and xlrd. The xls files I use for input are 
generated by Spss. When I open and re-save the files in Excel, the program 
works, but when I use the xls files as they were created by Spss, the program 
returns an error message (see below). Some details: Python 2.4, xlwt version 
0.7.0, xlrd version 0.5.2, Win NT.

Any ideas? 

Thanks in advance!

Albert-Jan


 
Merge all xls files in a given directory into one multisheet xls file. 
The sheets get the orginal file name, without the extension. 
File names should not exceed 31 characters, as this is the maximum 
sheet name length 
 

import xlrd, xlwt 
import glob, os.path 

def merge_xls (in_dir, out_file=d:/merged_output.xls): 

xls_files   = glob.glob(in_dir + *.xls) 
sheet_names = [] 
merged_book = xlwt.Workbook() 

[sheet_names.append(os.path.basename(v)[:-4]) for k, v in 
enumerate(xls_files)] 
for k, xls_file in enumerate(xls_files): 
if len (sheet_names[k]) = 31: 
book = xlrd.open_workbook(xls_file) 
ws = merged_book.add_sheet(sheet_names[k]) 
for sheetx in range(book.nsheets): 
sheet = book.sheet_by_index(sheetx) 
for rx in range(sheet.nrows): 
for cx in range(sheet.ncols): 
 ws.write(rx, cx, sheet.cell_value(rx, cx)) 
else: 
print File name too long: %s.xls (maximum is 31 chars)  % 
(sheet_names[k]) 
print File %s.xls is *not* included in the merged xls file. % 
(sheet_names[k]) 
merged_book.save(out_file) 

print --- Merged xls file written to %s using the following source files: 
 % (out_file) 
for k, v in enumerate(sheet_names): 
if len(v) = 31: print \t, str(k+1).zfill(3), %s.xls % (v) 

merge_xls(in_dir=d:/temp/) 

*** WARNING: OLE2 inconsistency: SSCS size is 0 but SSAT size is non-zero *** 
put_cell 0 1 

Traceback (most recent call last): 
  File G:\generic_syntaxes\merge_xls.py, line 37, in -toplevel- 
merge_xls(in_dir=d:/temp/) 
  File G:\generic_syntaxes\merge_xls.py, line 21, in merge_xls 
book = xlrd.open_workbook(xls_file) 
  File C:\Python24\lib\site-packages\xlrd\__init__.py, line 139, in 
open_workbook 
bk.get_sheets() 
  File C:\Python24\lib\site-packages\xlrd\__init__.py, line 389, in 
get_sheets 
sht = self.get_sheet(sheetno) 
  File C:\Python24\lib\site-packages\xlrd\__init__.py, line 379, in get_sheet 
sh.read(self) 
  File C:\Python24\lib\site-packages\xlrd\sheet.py, line 285, in read 
self.put_cell(rowx, colx, XL_CELL_TEXT, bk._sharedstrings[index]) 
  File C:\Python24\lib\site-packages\xlrd\sheet.py, line 214, in put_cell 
self._cell_types[rowx][colx] = ctype 
IndexError: list assignment index out of range 


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


Re: IDE Question

2008-10-15 Thread tomohiro kusumi
How about pyscripter or pydev (eclipse plugin), although I don't know if
they
are the most popular one. I use them on Windows.

Tomohiro Kusumi

2008/10/16 Steve Phillips [EMAIL PROTECTED]

 Hi All,
 I am just wondering what seems to be the most popular IDE. The reason
 I ask is I am currently at war with myself when it comes to IDE's. It
 seems like every one I find and try out has something in it that
 others don't and viceversa. I am in search for the perfect IDE and
 after many months of searching, I always come back to IDLE to do what
 I need to do. I want to use Komodo badly but the one issue I have with
 that is sometimes the auto-complete works and other times it doesn't.
 Even if I carbon copy a script.

 Thanks in advance,
 Steve P
 --
 http://mail.python.org/mailman/listinfo/python-list

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


Overloading operators

2008-10-15 Thread Mr . SpOOn
Hi,
in a project I'm overloading a lot of comparison and arithmetic
operators to make them working with more complex classes that I
defined.

Sometimes I need a different behavior of the operator depending on the
argument. For example, if I compare a object with an int, I get a
result, but if I compare the same object with a string, or another
object, I get another result.

What is the best way to do this? Shall I use a lot of if...elif
statements inside the overloaded operator? Or is there a more pythonic
and dynamic way?
--
http://mail.python.org/mailman/listinfo/python-list


Re: PyGUI as a standard GUI API for Python?

2008-10-15 Thread lkcl
   hello_loader.py is the main err um  i just double-
  checked, so i'd be able to advise you and... err... the problem i
  described (with the GridTest) seems to have... gone away!!

 There are lots of references to PyGTK classes in there.

 yes, that's because i had started with the gtk port, and was going
through the examples one-by-one removing them and replacing them with
qt.

 as i only got up to the Info tab of KitchenSink, there is still
quite a bit to do.  i _say_ quite a bit - but it's only about ...
16-24 hours of work.

 pyjamas is surprisingly small.

 Is there a way to select Qt instead of GTK?

 sorry!  removing them :)

 Hacking the code a bit,

 :)

 I can run the hello_loader.py example. The items
 on the left do indeed overlap. It looks like the minimum size of the
 labels aren't being respected for some reason.

 yeah.  and the pyjamas ui.HTML() class is based on a Qt.QLabel().  if
that can be fixed, then there's a fair good reason to continue.

 Yes, there are ways to relate the height of a widget to its width, and
 there may well be a way to do that for a standard text widget, but it
 might involve some experimentation with the underlying text document.

  *sharp intake of breath* :)  yehhh, i did word-breaking by wrapping
groups of 8 letters at a time in floating-divs once, to simulate word-
breaking in a situation where the column width was 200px and people
were putting in web site addresses of 50 chars in length yukk.
--
http://mail.python.org/mailman/listinfo/python-list


File Management

2008-10-15 Thread erict1689
I am writing this program in which I open up a file and update that
information but to a new file.  I already have a global variable for
it but how do I go about creating an openable file in the source code?
 If it helps here is what I have:

def startUp():
# Purpose: opens files and print report headings
global empName, previousYTD, payRate, hoursWorked, recordCount,
eof, payFile, \
   payFileUpdated, newYTD, currentPay
payFile=open(payroll.txt, r)
payFile.readline()


def readRecord():
# Purpose: reads a record
global empName, previousYTD, payRate, hoursWorked, recordCount,
eof, payFile, \
   payFileUpdated, newYTD, currentPay

employeeRec = payFile.readline()
if employeeRec == :
eof = True
else:
# parse file line for record fields and format/convert for
final output
empName = employeeRec[0:25].strip()
previousYTD = float(employeeRec[25:40])
payRate = float(employeeRec[40:55])
hoursWorked = float(employeeRec[55:70])
recordCount += 1
eof = False

def writeRecord():
# Purpose: writes the updated record to the output file
#Parameter
global empName, previousYTD, payRate, hoursWorked, recordCount,
eof, payFile, \
   payFileUpdated, newYTD, currentPay
   
def processRecords():
# Purpose: loops through input file and processes each record
global empName, previousYTD, payRate, hoursWorked, recordCount,
eof, payFile, \
   payFileUpdated, newYTD, currentPay

while not eof:
calculatePay()
printReportLine()
writeRecord()
readRecord()

def calculatePay():
# Purpose: calculates pay and updated YTD
# Return values: float - calculated pay, float - updated YTD amount 
global empName, previousYTD, payRate, hoursWorked, recordCount,
eof, payFile, \
   payFileUpdated, newYTD, currentPay

def printReportLine():
# Purpose: prints employee pay information
# Parameters passed: float - calculated pay, float - updated YTD
amount
global empName, previousYTD, payRate, hoursWorked, recordCount,
eof, payFile, \
   payFileUpdated, newYTD, currentPay

def closeUp():
# Purpose: end of program housekeeping
global empName, previousYTD, payRate, hoursWorked, recordCount,
eof, payFile, \
   payFileUpdated, newYTD, currentPay
   
payFile.close()
payFileUpdated.close()
print \nNumber of records in the file was,recordCount

Any and all help is appreciated.

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


Re: Sending multi-part MIME package via HTTP-POST

2008-10-15 Thread [EMAIL PROTECTED]
On Oct 15, 2:42 am, Lawrence D'Oliveiro [EMAIL PROTECTED]
central.gen.new_zealand wrote:
 In message
 [EMAIL PROTECTED],

 [EMAIL PROTECTED] wrote:
  ... but I'm getting a very vague server error message ...

 Which is?

In this case it's not really something that will be readily recognized
here, nor is it extremely helpful diagnostic-wise. This is the only
debug output I can get from the logs or stdout:

Failed to parse content as JDF.
--
http://mail.python.org/mailman/listinfo/python-list


File management

2008-10-15 Thread erict1689
I am writing a program in which i open up a file and read the contents
then do some calculations and update the information but in a new
file.  So my question is how do i go about declaring the new file so
that the program will know that the new information goes into the new
file and not the original?  if it helps here is the code that i have
so far:
def startUp():
# Purpose: opens files and print report headings
global empName, previousYTD, payRate, hoursWorked, recordCount,
eof, payFile, \
   payFileUpdated, newYTD, currentPay
payFile=open(payroll.txt, r)
payFile.readline()


def readRecord():
# Purpose: reads a record
global empName, previousYTD, payRate, hoursWorked, recordCount,
eof, payFile, \
   payFileUpdated, newYTD, currentPay

employeeRec = payFile.readline()
if employeeRec == :
eof = True
else:
# parse file line for record fields and format/convert for
final output
empName = employeeRec[0:25].strip()
previousYTD = float(employeeRec[25:40])
payRate = float(employeeRec[40:55])
hoursWorked = float(employeeRec[55:70])
recordCount += 1
eof = False

def writeRecord():
# Purpose: writes the updated record to the output file
#Parameter
global empName, previousYTD, payRate, hoursWorked, recordCount,
eof, payFile, \
   payFileUpdated, newYTD, currentPay
   
def processRecords():
# Purpose: loops through input file and processes each record
global empName, previousYTD, payRate, hoursWorked, recordCount,
eof, payFile, \
   payFileUpdated, newYTD, currentPay

while not eof:
calculatePay()
printReportLine()
writeRecord()
readRecord()

def calculatePay():
# Purpose: calculates pay and updated YTD
# Return values: float - calculated pay, float - updated YTD amount 
global empName, previousYTD, payRate, hoursWorked, recordCount,
eof, payFile, \
   payFileUpdated, newYTD, currentPay

def printReportLine():
# Purpose: prints employee pay information
# Parameters passed: float - calculated pay, float - updated YTD
amount
global empName, previousYTD, payRate, hoursWorked, recordCount,
eof, payFile, \
   payFileUpdated, newYTD, currentPay

def closeUp():
# Purpose: end of program housekeeping
global empName, previousYTD, payRate, hoursWorked, recordCount,
eof, payFile, \
   payFileUpdated, newYTD, currentPay
   
payFile.close()
payFileUpdated.close()
print \nNumber of records in the file was,recordCount

any and all help is appreciated.

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


OOP books?

2008-10-15 Thread Ken D'Ambrosio
Hi, all.  Over the years, I've programmed in a fair number of languages; 
the ones with which I became most familiar were assembler, BASIC, 
Pascal, and lately (the last fifteen years or so) Perl.  Now I'm 
trying my hand at Python.  While I don't have any problems with the ins 
and outs of the language (at least thus-far), I'm afraid I'm taking the 
wrong approach.  The common thread in all the languages I speak is 
that they're all procedural languages, and I'm treating Python the same. 
  [Okay: Perl does have OOP, but it's retrofitted and ugly.]  Is there 
an intro-to-Python book where the emphasis isn't so much on the 
language, but on OOP, itself?  Or, failing that, at least a Python book 
which doesn't just introduce the language, but gives equal billing to 
OOP practices, etc.


Thanks much!

-Ken
** Posted from http://www.teranews.com **
--
http://mail.python.org/mailman/listinfo/python-list


Re: IDE Question

2008-10-15 Thread jdd
On Oct 15, 1:19 pm, Steve Phillips [EMAIL PROTECTED] wrote:
 Hi All,
 I am just wondering what seems to be the most popular IDE. The reason
 I ask is I am currently at war with myself when it comes to IDE's. It
 seems like every one I find and try out has something in it that
 others don't and viceversa. I am in search for the perfect IDE and
 after many months of searching, I always come back to IDLE to do what
 I need to do. I want to use Komodo badly but the one issue I have with
 that is sometimes the auto-complete works and other times it doesn't.
 Even if I carbon copy a script.

 Thanks in advance,
 Steve P

I would personally recommend that you take the time to learn your way
around a powerful text editor such as emacs or vim (I use emacs,
myself), however that may not fit well with your personal editing
tastes, and the learning curve is a bit steep. The editing tastes
problem can be solved once you learn your way around a powerful text
editor (emacs, for instance, is practically infinitely customizable),
and the power you get from using them is amazing.

If you're set on using an IDE, the python wiki link that other people
have linked to has a decent overview of good options.
--
http://mail.python.org/mailman/listinfo/python-list


Re: IDE Question

2008-10-15 Thread Stef Mientki

Steve Phillips wrote:

Hi All,
I am just wondering what seems to be the most popular IDE. The reason
I ask is I am currently at war with myself when it comes to IDE's. It
seems like every one I find and try out has something in it that
others don't and viceversa. I am in search for the perfect IDE and
after many months of searching, I always come back to IDLE to do what
I need to do. I want to use Komodo badly but the one issue I have with
that is sometimes the auto-complete works and other times it doesn't.
Even if I carbon copy a script.
  

So what are the specs of the perfect IDE ?
I've the same experience with python-IDEs as you,
and as I'm a very spoiled guy, used to work with Delphi.
I'm interested in your specs,
as I've decided to write my own,
it will not be perfect,
but I don't want to miss features of the  almost perfect IDE  ;-)
I also know of others who are doing the same at this moment,
building other almost perfect IDE's .

For now I use PyScripter and SPE in that order.

cheers,
Stef


Thanks in advance,
Steve P
--
http://mail.python.org/mailman/listinfo/python-list
  


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


Re: IDE Question

2008-10-15 Thread Fabio Zadrozny
 I would personally recommend that you take the time to learn your way
 around a powerful text editor such as emacs or vim (I use emacs,
 myself), however that may not fit well with your personal editing
 tastes, and the learning curve is a bit steep. The editing tastes
 problem can be solved once you learn your way around a powerful text
 editor (emacs, for instance, is practically infinitely customizable),
 and the power you get from using them is amazing.

Now, following that route, many people call Eclipse is the 21st
century Emacs... ;-)

Interesting link related to that:
http://blogs.nuxeo.com/sections/blogs/julien_anguenot/2006_09_15_switching-from-emacs-to-pydev

Cheers,

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


Re: newbie - merging xls files using xldt and xlwt

2008-10-15 Thread Terry Reedy

Albert-jan Roskam wrote:

Hi,
When you start a new topic/, make sure that you start a new thread by 
hitting the appropriate button on your program and not by replying to a 
different thread.  Your post has nothing to do with GUIs and will be 
missed by anyone who has threads collapsed and who skips the GUI thread.


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


Re: xor: how come so slow?

2008-10-15 Thread Peter Otten
Michele wrote:

 I'm trying to encode a byte data. Let's not focus on the process of
 encoding; in fact, I want to emphasize that the method
 create_random_block takes 0.5s to be executed (even Java it's faster) on
 a Dual-Core 3.0Ghz machine:
 
 took 46.74679s, avg: 0.4674679s

 How should I decrease the execution time?

Use numpy. You should be able to swap in the following in your script

import numpy
from numpy.core import multiarray as ma
class Encoder(object):
def create_random_block(self, data, seed, blocksize):
number_of_blocks = len(data)//blocksize
random.seed(seed)
random_block = ma.fromstring(0*blocksize, numpy.uint8)

for index in range(number_of_blocks):
if random.getrandbits(1):
block =
ma.fromstring(data[blocksize*index:blocksize*index+blocksize], numpy.uint8)
random_block ^= block
return random_block.tostring()

There are absolutely no warranties as I'm just a random tinkerer when it
comes to numpy. But if it works you should get a nice speedup...

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


Re: Distributing compiled (swig) python modules

2008-10-15 Thread Scott David Daniels

mathieu wrote:

...Is there some documentation (that I missed in my previous google
search) that describe how to prepare python module that can be
redistributed with some kind of backward compatibility (= so that when
prepared on python 2.4, it works on 2.5/2.6 at least) ?


Nope, you didn't miss it.  Each major version change (2.3.X - 2.4.X,
2.4.X - 2.5.X, ...) changes the Python VM and internals.  There is no
way below Python source (.pyc, .pyo, or .pyd) to stay compatible.  That
is why Python projects offer code in Python version-specific packages.

--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list


[ANN] Data Plotting Library DISLIN 9.4

2008-10-15 Thread Helmut Michels

Dear Python users,

I am pleased to announce version 9.4 of the data plotting software
DISLIN.

DISLIN is a high-level and easy to use plotting library for
displaying data as curves, bar graphs, pie charts, 3D-colour plots,
surfaces, contours and maps. Several output formats are supported
such as X11, VGA, PostScript, PDF, CGM, WMF, HPGL, TIFF, GIF, PNG,
BMP and SVG.

The software is available for the most C, Fortran 77 and Fortran 90/95
compilers. Plotting extensions for the interpreting languages Perl,
Python and Java are also supported.

DISLIN distributions and manuals in PDF, PostScript and HTML format
are available from the DISLIN home page

 http://www.dislin.de

and via FTP from the server

 ftp://ftp.gwdg.de/pub/grafik/dislin

All DISLIN distributions are free for non-commercial use. Licenses
for commercial use are available from the site http://www.dislin.de.

 ---
  Helmut Michels
  Max Planck Institute for
  Solar System Research   Phone: +49 5556 979-334
  Max-Planck-Str. 2   Fax  : +49 5556 979-240
  D-37191 Katlenburg-Lindau   Mail : [EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list


Re: Compiling Webkit-Glib and PyWebkitGTK for Win32

2008-10-15 Thread lkcl
terry, hi:
instructions to ensure that you have the right build environment for
windows is here:
http://webkit.org/building/tools.html

it's not made clear whether the use of VS 2005 will _automatically_
download all of the build dependencies for you - you'll have to find
out :)

regarding pywebkitgtk:

  http://www.python.org/doc/2.5.2/ext/win-cookbook.html

not sure how much use this will be, but i'm sure you'll definitely
need gnu autoconf and friends, so i'd start here:

   http://gnuwin32.sourceforge.net/

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


Re: OOP books?

2008-10-15 Thread Mike Driscoll
On Oct 15, 1:02 pm, Ken D'Ambrosio [EMAIL PROTECTED] wrote:
 Hi, all.  Over the years, I've programmed in a fair number of languages;
 the ones with which I became most familiar were assembler, BASIC,
 Pascal, and lately (the last fifteen years or so) Perl.  Now I'm
 trying my hand at Python.  While I don't have any problems with the ins
 and outs of the language (at least thus-far), I'm afraid I'm taking the
 wrong approach.  The common thread in all the languages I speak is
 that they're all procedural languages, and I'm treating Python the same.
    [Okay: Perl does have OOP, but it's retrofitted and ugly.]  Is there
 an intro-to-Python book where the emphasis isn't so much on the
 language, but on OOP, itself?  Or, failing that, at least a Python book
 which doesn't just introduce the language, but gives equal billing to
 OOP practices, etc.

 Thanks much!

 -Ken
 ** Posted fromhttp://www.teranews.com**

Python Power has a couple chapters on OOP, but you might also find
the free Dive Into Python helpful:

http://diveintopython.org/object_oriented_framework/index.html

I have yet to read a Python book that only focuses on the OOP part,
probably because everything in Python is an object, so even if you
don't realize it, you're probably using some OOP concepts whenever you
write in it.

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


Re: ANN: eGenix mxODBC - ODBC Database Interface for Python 3.0.2

2008-10-15 Thread Terry Reedy

FYI
I initially parsed the subject line as
eGenix mxODBC - ODBC Database Interface for Python 3.0.2
and thought, Wow, already prepared for the future (6 months to a year) 
;-).


tjr

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


Problem with py2exe

2008-10-15 Thread Srinivasa NL
Hi,
  I am having problem with running exe generated using py2exe.  I wrote a
simple script test.py which prints a line (e.g print 'Hello World') and
generated an exe using py2exe. I used the command python setup.py py2exe.
When I run the exe test.exe in the dist directory I get the error message

LoadLibrary(pythondll) failedInvalid access to memory location
E:\programming\python\dist\PYTHON25.DLL

When I just start the IDE and load the same library using
win32api.LoadLibrary(python25.dll) it seems to load correctly.
I tried it with both python 2.4 and python 2.5.2 on an machine running
window XP but I get the same error message.
I would be very grateful if somebody helps since my work depends
significantly on python tools.
Kind Regards,
Srinivas.
--
http://mail.python.org/mailman/listinfo/python-list


Re: replace mothod for only one object but not for a class

2008-10-15 Thread Bruno Desthuilliers

Bruno Desthuilliers a écrit :

hofer a écrit :

Hi,

I have multiple objects all belonging to the same class
 (which I didn't implement and whose code I don't want to modify)

Now I'd like to change one method for one object only (after it has
been created) without adding any overhead
to the call of the other object's methods.


Is this possible?


Yes.

If the class is a new-style one [1], it just requires invoking the 
descriptor protocol by yourself to get a bound method, ie:



(snip)


If it's a classic class, you can get by using either new.instancemethod 
or types.MethodType:


Either I'm starting to get old or I need some vacations... Manually 
invoking function.__get__(obj, type(obj)) also work with classic 
classes, of course.


(snip)
--
http://mail.python.org/mailman/listinfo/python-list


Re: [ANN] final 2008 Python courses, San Francisco

2008-10-15 Thread wesley chun
*** FINAL REMINDER

also, the course begins on monday immediately following the *free* CodeCamp
conference http://siliconvalley-codecamp.com (click Program =
Sessions to see all the talks)... 5 straight days of learning in the
San Francisco Bay Area!!
***

-- Forwarded message --
From: wesley chun [EMAIL PROTECTED]
Date: Fri, Sep 5, 2008 at 1:21 AM
Subject: [ANN] final 2008 Python courses, San Francisco
To: python-list@python.org, [EMAIL PROTECTED]

Need to get up-to-speed with Python as quickly as possible? Come join
me, Wesley Chun, author of Prentice-Hall's bestseller Core Python
Programming, for another comprehensive intro course plus a 1-day
Internet programming course coming up in November in beautiful
Northern California! I look forward to meeting you!

(Comprehensive) Introduction to Python
Mon-Wed, 2008 Nov 10-12, 9am-5pm

Internet Programming with Python
Sat, 2008 Nov 15, 9am-5pm

courses can be taken separately or combined for a discounted price.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(COMPREHENSIVE) INTRODUCTION TO PYTHON

Although this course may appear to those new to Python, it is also
perfect for those who have tinkered with it and want to fill in the
gaps and/or want to get more in-depth formal training.  It combines
the best of both an introduction to the language as well as a Python
Internals training course.

We will immerse you in the world of Python in only a few days, showing
you more than just its syntax (which you don't really need a book to
learn, right?). Knowing more about how Python works under the covers,
including the relationship between data objects and memory management,
will make you a much more effective Python programmer coming out of
the gate. 3 hands-on labs each day will help hammer the concepts home.

Come find out why Google, Yahoo!, Disney, ILM/LucasFilm, VMware, NASA,
Ubuntu, YouTube, and Red Hat all use Python. Users supporting or
jumping to Plone, Zope, TurboGears, Pylons, Django, Google App Engine,
Jython, IronPython, and Mailman will also benefit!

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
INTERNET PROGRAMMING WITH PYTHON

This is a one-day course with lecture and lab exposing attendees to
FOUR distinct areas of Internet programming:

* Network Programming using Sockets -- we introduce client/server
architecture and how to program sockets using Python.

* Internet Client Programming -- we learn how to use Python's standard
library to create FTP, NNTP, POP3, and SMTP clients

* Web Programming -- before you jump on all the web framework
bandwagons, it's a good idea to learn basics and the basis of how all
web servers deliver dynamic content back to the client browser to
prepare you better when jumping to a full-stack web framework

* Intro to Django -- a lightweight introduction to the Django web
framework including whipping up a very simple blog application in
20min!

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

WHERE: near the San Francisco Airport (SFO/San Bruno), CA, USA

WEB:   http://cyberwebconsulting.com (click Python Training)

FLYER: http://starship.python.net/crew/wesc/flyerPP1combo.pdf

LOCALS: easy freeway (101/280/380) with lots of parking plus public
transit (BART and CalTrain) access via the San Bruno stations, easily
accessible from all parts of the Bay Area

VISITORS: free shuttle to/from the airport, free high-speed internet,
free breakfast and regular evening receptions; fully-equipped suites

See website for costs, venue info, and registration.  Discounts are
available for multiple registrations as well as for teachers/students.

Hope to see you there!
-- wesley

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Core Python Programming, Prentice Hall, (c)2007,2001
 http://corepython.com

wesley.j.chun :: wescpy-at-gmail.com
python training and technical consulting
cyberweb.consulting : silicon valley, ca
http://cyberwebconsulting.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: IDE Question

2008-10-15 Thread Steve Phillips
Thanks for all of your responses.  I did forget to mention that I do use
Notepad++ for just about everything.  My larger scripts I use that and just
say the hell with the auto-complete and the call-tips.  I lived on that wiki
page and actually still do waiting to see if something new was going to be
added.

It is safe to say that my definition of the perfect IDE would be one that
has reliable call-tips and auto-completions.  I have been doing Python for
about 2-2.5 years now.  Prior to using IDLE for modules that I am unfamiliar
with I have always used NP++.

Before Python was my primary language, it was straight VB, VBA, VBScript,
etc... That should give you some insight to where I am coming from.

Steve P

On 10/15/08, Steve Phillips [EMAIL PROTECTED] wrote:

 Hi All,
 I am just wondering what seems to be the most popular IDE. The reason
 I ask is I am currently at war with myself when it comes to IDE's. It
 seems like every one I find and try out has something in it that
 others don't and viceversa. I am in search for the perfect IDE and
 after many months of searching, I always come back to IDLE to do what
 I need to do. I want to use Komodo badly but the one issue I have with
 that is sometimes the auto-complete works and other times it doesn't.
 Even if I carbon copy a script.

 Thanks in advance,
 Steve P

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


Re: IDE Question

2008-10-15 Thread jdd
On Oct 15, 2:13 pm, Fabio Zadrozny [EMAIL PROTECTED] wrote:
 Now, following that route, many people call Eclipse is the 21st
 century Emacs... ;-)


I don't want to kick off an editor war or anything, but I don't think
that Eclipse is anywhere near being a 21st century emacs, unless
there's been a whole lot of progress with it since the last time I
used it. With emacs, I can have multiple files open in one window,
with the window split (I don't remember eclipse being able to do this,
although it allowed multiple files in their own tabs), and I can
customize the actions of the editor on the fly, without restarting it,
in a variant of LISP. That may be possible in Eclipse, I don't really
know.

I used to use Eclipse and pydev, but once I learned my way around
emacs, I haven't gone back to it for anything. I probably would if I
did any coding in Java - but I don't. I'm exponentially more
productive with emacs while writing python code than I ever was with
Eclipse.

Add to that the degree to which emacs is customizable (just about
everything that the editor does can be customized, you can jump
quickly to the source of the functions you're running while editing,
you can easily patch behavior in before or after specific function
calls, you can easily define keyboard macros and bind them to
keystrokes, and / or save them for future use, you can easily create
keystrokes that correspond to interactive filling out of templates -
skeletons, etc), and I really don't see how someone could think that
Eclipse is anywhere near being a replacement for emacs.

Not to mention that I don't need to have X installed to run emacs if I
don't need it.

I may be wrong about the capabilities of Eclipse, as I haven't used it
in about a year, and emacs certainly has it's own set of quirks and
annoyances - one of which being the very steep learning curve.

Watching the screencasts linked in the blog post you linked to, I
might prefer Eclipse to emacs if I wasn't very used to never touching
a mouse, or if I was developing under windows. With my editing mindset
the way it is right now, when I see that, I just see a lot of wasted
screen space, and a lot of wasted time doing things like intellisense.
Also, the blog post didn't really give any reasons as to _why_ the
person switched over, other than that they were impressed with
Eclipse.

Meh, I'm not talking trash on Eclipse - it's a fine tool if it fits
how you work with text / code. It's just not for me, and I would feel
crippled while using it if I switched back to it. I used IDEs like
that for a few years, but after about a month and a half of using
emacs, I haven't looked back. I even use it as my IRC client when I
jump on IRC.

I do think that people should try a variety of styles of editors to
find what works best for them though - although it does take a lot of
time to learn your way around 3 or 4 different editors, once you find
what fits with you, you will probably get a huge boost in productivity.
--
http://mail.python.org/mailman/listinfo/python-list


UICrawler

2008-10-15 Thread mccarth . jack
Hello all, I am trying to run the Universal information crawler wed
spider on my mac. It seems to install without any trouble but when, in
unix command line, I try to run  paster create --list-templates it
returns this Value Code error. I followed instructions provided at
http://lucasmanual.com/mywiki/UICrawler. This is what comes up.

Traceback (most recent call last):
  File /Library/Frameworks/Python.framework/Versions/Current/bin/
paster, line 8, in module
load_entry_point('PasteScript==1.6.3', 'console_scripts', 'paster')
()
  File /Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/site-packages/PasteScript-1.6.3-py2.6.egg/paste/script/
command.py, line 78, in run
command = commands[command_name].load()
  File /Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/site-packages/setuptools-0.6c9-py2.6.egg/pkg_resources.py,
line 1913, in load
  File /Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/site-packages/PasteScript-1.6.3-py2.6.egg/paste/script/
create_distro.py, line 8, in module
import copydir
  File /Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/site-packages/PasteScript-1.6.3-py2.6.egg/paste/script/
copydir.py, line 398, in module
class LaxTemplate(string.Template):
  File /Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/string.py, line 119, in __init__
cls.pattern = _re.compile(pattern, _re.IGNORECASE | _re.VERBOSE)
  File /Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/re.py, line 188, in compile
return _compile(pattern, flags)
  File /Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/re.py, line 236, in _compile
raise ValueError('Cannot process flags argument with a compiled
pattern')
ValueError: Cannot process flags argument with a compiled pattern

Has anyone else encountered this problem or have any suggestions as to
what might be causing the problem?
--
http://mail.python.org/mailman/listinfo/python-list


Re: problem using ctypes with MMX intrinsics

2008-10-15 Thread Robert Kern

dcharno wrote:
Is it possible to use ctypes with a shared library which uses MMX/SSE 
intrinsics?  I can load the library and access functions inside it, but 
I getting a seg fault when I hit one of the intrinsics.  I'm wondering 
if there might be some sort of stack alignment problem.


I am using gcc version 4.2.3 and Python 2.5.2 on Ubuntu 8.04.

Any suggestions would be helpful.


Well, stack alignment would be a problem with how the shared library gets 
compiled, nothing to do with ctypes (I think). However, if you are passing in 
arrays from ctypes, *they* may also be misaligned. Try to check the addresses of 
the ctypes values you are passing in. I'm not entirely sure how to do that, though.


--
Robert Kern

I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth.
  -- Umberto Eco

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


Re: OOP books?

2008-10-15 Thread Alan G Isaac

Mike Driscoll wrote:

I have yet to read a Python book that only focuses on the OOP part,


http://www.amazon.com/Scripting-Objects-Comparative-Presentation-Object-Oriented/dp/047039725X

fwiw,
Alan Isaac
--
http://mail.python.org/mailman/listinfo/python-list


  1   2   >