ANN: SIP v4.4 Released

2006-03-25 Thread Phil Thompson
Riverbank Computing is pleased to announce the release of SIP v4.4 available 
from http://www.riverbankcomputing.co.uk/sip/.

SIP is a tool for generating Python modules that wrap C or C++ libraries.  It 
is similar to SWIG.  It is used to generate PyQt and PyKDE.  Full 
documentation is available at 
http://www.riverbankcomputing.com/Docs/sip4/sipref.html.

SIP is licensed under the Python License and runs on Windows, UNIX, Linux and 
MacOS/X.  SIP requires Python v2.3 or later (SIP v3.x is available to support 
earlier versions of Python).

This release includes the following changes:

- support for class and mapped type templates
- support for global operators
- support for signed char, long long and unsigned long long types
- support for Python's buffer interface
- support for ellipsis in function arguments
- support for __hash__
- namespaces can now be split across Python modules.

Other features of SIP include:

- extension modules are implemented as a single binary .pyd or .so file (no
  Python stubs)
- support for Python new-style classes
- generated modules are quick to import, even for large libraries
- support for Qt's signal/slot mechanism
- thread support
- the ability to re-implement C++ abstract and virtual methods in Python
- the ability to define Python classes that derive from abstract C++ classes
- the ability to spread a class hierarchy across multiple Python modules
- support for C++ namespaces
- support for C++ exceptions
- support for C++ operators
- an extensible build system written in Python that supports over 50
  platform/compiler combinations.

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

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


ANN: eric3 3.8.2 release

2006-03-25 Thread Detlev Offenbach
Hi,

this is to let all of you know about the release of eric3 3.8.2. This
version fixes a compatibility bug with the latest PyQt release (PyQt
3.16).

Eric3 is a Python and Ruby IDE with batteries included. It is written
using PyQt and is available via

http://www.die-offenbachs.de/detlev/eric3.html

Regards,
Detlev
-- 
Detlev Offenbach
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

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


Re: a problem to solve

2006-03-25 Thread [EMAIL PROTECTED]

John Salerno wrote:
 [EMAIL PROTECTED] wrote:

  If you need help in figuring out how to walk through all 4096 possible
  switch sets, just ask.

 Ok, thanks to your list, I figured out a program that works! It's
 probably not the best, and it doesn't really display which switches are
 correct in any apparent way (you have to look for them in the list), but
 it works! Here's the code. I'd love to see your implementation too.

 from gmpy import digits

 panelOne = [0xf5fdc,0xf6edb,0xbddb7,0x6fddd,0xeb7ed,0xb977f,0xbfed3,0xedef5]
 panelTwo = [0xddb7d,0xfaddb,0xde75f,0xeef7a,0xdd77b,0xdfbce,0xb77dd,0x7ef5d]
 panelThree =
 [0xf37bd,0xdfaee,0xddd6f,0xddfb6,0xb9efb,0xb7bbe,0xecfbd,0xb75df]
 panelFour =
 [0x77edb,0xbb7ee,0xdf773,0x7bdeb,0x7ddaf,0xdeeeb,0xfb35f,0xbb7dd]

 for a in panelOne:
   for b in panelTwo:
   for c in panelThree:
   for d in panelFour:
   if (a  b  (c ^ d)) | (c  d  (a ^ b)) == 
 1048575:
   print 'Solution is:', digits(a, 16), 
 digits(b, 16), digits(c, 16),
 digits(d, 16)
   raw_input()

Well, I don't get the prize for most elegant.

But that's partly because I included the ooloop6
function. That's real handy to have in your puzzle
solving toolbox. It can generate all the subsets of
the cartesian product of a string of characters:

Permutations withReplacement
Combinations withReplacement
Permutations without Replacement
Combinations without Replacement

It will dynamically create as many nested for loops
as you need (up to the Python limit of 20, but keep
in mind that there are 19928148895209409152340197376
possible 20 letter words). Of course, we only need
Permutations with Replacement for THIS problem,
which can be done more elegantly the way you did it.


import gmpy
# and gmpy can do much more than base conversion
# lots of functions of interest to the bit-banger
# example below

def ooloop6(a, n, perm=True, repl=True):
if (not repl) and (nlen(a)): return
r0 = range(n)
r1 = r0[1:]
if perm and repl:  # ok
v = ','.join(['c%s' % i for i in r0])
f = ' '.join(['for c%s in a' % i for i in r0])
e = ''.join([p = [''.join((,v,)) ,f,]])
exec e
return p
if (not perm) and repl:# ok
v = ','.join(['c%s' % i for i in r0])
f = ' '.join(['for c%s in a' % i for i in r0])
i = ' and '.join(['(c%s=c%s)' % (j,j-1) for j in r1])
e = ''.join([p = [''.join((,v,)) ,f, if ,i,]])
exec e
return p
if perm and (not repl):# ok
v = ','.join(['c%s' % i for i in r0])
f = ' '.join(['for c%s in a' % i for i in r0])
i = ' and '.join([' and '.join(['(c%s!=c%s)' % (j,k) for k in
range(j)]) for j in r1])
e = ''.join([p = [''.join((,v,)) ,f, if ,i,]])
exec e
return p
if (not perm) and (not repl):  # ok
v = ','.join(['c%s' % i for i in r0])
f = ' '.join(['for c%s in a' % i for i in r0])
i = ' and '.join(['(c%sc%s)' % (j,j-1) for j in r1])
e = ''.join([p = [''.join((,v,)) ,f, if ,i,]])
exec e
return p

a = [0xf5fdc,0xf6edb,0xbddb7,0x6fddd,0xeb7ed,0xb977f,0xbfed3,0xedef5]
b = [0xddb7d,0xfaddb,0xde75f,0xeef7a,0xdd77b,0xdfbce,0xb77dd,0x7ef5d]
c = [0xf37bd,0xdfaee,0xddd6f,0xddfb6,0xb9efb,0xb7bbe,0xecfbd,0xb75df]
d = [0x77edb,0xbb7ee,0xdf773,0x7bdeb,0x7ddaf,0xdeeeb,0xfb35f,0xbb7dd]

p = ooloop6('01234567',4)
# p is a list of all 4096 possible switch patterns
# ['','0001','0002',...'7775','7776','']

for q in p:
h = int(q[0]) # have to convert the characters to
i = int(q[1]) # ints so that they can be used as
j = int(q[2]) # indexes into the panel lists
k = int(q[3])
y = ((c[j]  d[k])  (a[h] ^ b[i])) | ((a[h]  b[i])  (c[j] ^
d[k]))
z = gmpy.digits(y,2) # y converted to base 2
r = gmpy.popcount(y) # a real neat gmpy bit function!
 # popcount is the number of 1 bits
 # in the number
# in case there is no solution, I want to see how close
# I come, so I print all solutions that have over 15
# 1-bits
if r15:
print '%2d  %s%s' % (r,'0'*(20-len(z)),z),h,i,j,k
# it's not wrong to iterate through the list directly,
# but by using an index instead of saying for a in Panel1,
# I can then print the index when I find a solution.
# so I can simply say the switches are 7 2 5 3

# note the expression '0'*(20-len(z))
# the base 2 conversion stops at the most significant 1-bit
# this pads it out to 20 characters if necessary

##program output
##
##16  00110110 2 3 1 7
##16  110110110011 3 4 5 5
##16  1101110111010111 5 5 6 0
##16  1101101110111011 6 3 0 4
##16  01100011 7 1 5 2
##20  

how to format a return value by using re.sub(regx,rep1,str)?

2006-03-25 Thread dongdong
for example:
 re.sub('a( [^]+)+\s?[^^]*/a','',' asd gaa target=_blank
href=http://www.sine.com; class=wordstyle asdgasdghae rha/a')

I wish to get the return value asd ga asdgasdghae rha,how do do?
I have a impression on % and {number},but forgot how to use them.

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


ANN: PyQt v3.16 Released

2006-03-25 Thread Phil Thompson
Riverbank Computing is pleased to announce the release of PyQt v3.16 available 
from http://www.riverbankcomputing.co.uk/pyqt/.

The main benefit of this release is that it can be installed side by side with 
the soon-to-be-released PyQt v4 (for Qt v4).

Other changes since the last release include:

- improved interoperability between QString and Python's string and unicode
  objects.

PyQt is a comprehensive set of Qt bindings for the Python programming language 
and supports the same platforms as Qt.  Like Qt, PyQt is available under the 
GPL (for UNIX, Linux and MacOS/X), a commercial license (for Windows, UNIX, 
Linux and MacOS/X) and a free educational license (for Windows).

PyQt is implemented as a set of 9 extension modules containing 300 classes and 
over 5,750 functions and methods.

PyQt also includes bindings to QScintilla, the port to Qt of the Scintilla 
editor component.

PyQt can be used either as a rapid prototyping tool, or as an alternative to 
C++ for developing large Qt applications.

PyQt includes the pyuic utility which generates Python code to implement user 
interfaces created with Qt Designer in the same way that the uic utility 
generates C++ code.

Third party tools are also available - such as eric3, a comprehensive IDE 
(including an editor, debugger, class browser, integration with Qt Designer, 
re-factoring tools, unit testing tools and integration with source code 
control systems).  eric3 is written entirely using PyQt and is available from 
http://www.die-offenbachs.de/detlev/eric3.html.

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


Comparisons and singletons

2006-03-25 Thread Steven Watanabe
PEP 8 says, Comparisons to singletons like None should always be done
with 'is' or 'is not', never the equality operators. I know that is
is an identity operator, == and != are the equality operators, but
I'm not sure what other singletons are being referred to here.

Also, I've seen code that does things like:

  if foo is 3:
  if foo is not '':

Are these valid uses of is?

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


Building Python extensions from sources on Windows

2006-03-25 Thread TPJ
Hello, I have another, probably stupid, question.

I'm working on some Python project, and I use some extensions written
in C. I do all the development on my GNU/Linux box, so my setup.py
script works just as it's supposed to work on a GNU/Linux system. But
in the nearest future I'll have to make an executable program for
Windows.

I know, that there are some useful tools to make executables from
Python programs for Windows (Py2Exe, PyInstaller - that's what I have
heard about), but, as far as I understand the subject, I'll need the
extensions modules (dll files? on my GNU/Linux system I always get some
so files - shared libraries) in the compiled form in order to make any
executable program.

In the Python standard documentation I have read, that:

(...) Since the metadata is taken from the setup script, creating
Windows installers is usually as easy as running:

python setup.py bdist_wininst
(...)

If you have a non-pure distribution, the extensions can only be created
on a Windows platform, and will be Python version dependent. (...)

And that's the problem: I understand the fact, that in order to build a
non-pure distrubution, all the C sources have to be compiled (to dll
libraries?). But there's the problem: I don't know which one compiler
should I use. Do I have to use the same compiler, that the Python has
been compiled with? If so, which one of the Windows compilers has been
used to compile Python?

Or perhaps could I use an another compiler? Which one, then?

I have no idea what to do. I haven't done anything on Windows for so
long...

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


Re: Comparisons and singletons

2006-03-25 Thread Ziga Seilnacht
Steven Watanabe wrote:
 PEP 8 says, Comparisons to singletons like None should always be done
 with 'is' or 'is not', never the equality operators. I know that is
 is an identity operator, == and != are the equality operators, but
 I'm not sure what other singletons are being referred to here.

Other builtin singeltons are NotImplemented and Ellipsis, see:
http://docs.python.org/ref/types.html
for details.


 Also, I've seen code that does things like:

   if foo is 3:
   if foo is not '':

 Are these valid uses of is?

No. Try this examples:

 a = 'spam'
 b = ''.join(list(a))
 b
'spam'
 a == b
True
 a is b
False
 a = 1
 b = 1
 a == b
True
 a is b
False

 
 Thanks in advance.
 --
 Steven.

Hope this helps.

Ziga

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


ANN: eric3 3.8.2 release

2006-03-25 Thread Detlev Offenbach
Hi,

this is to let all of you know about the release of eric3 3.8.2. This
version fixes a compatibility bug with the latest PyQt release (PyQt
3.16).

Eric3 is a Python and Ruby IDE with batteries included. It is written
using PyQt and is available via

http://www.die-offenbachs.de/detlev/eric3.html

Regards,
Detlev
-- 
Detlev Offenbach
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Multiplying sequences with floats

2006-03-25 Thread Christoph Zwerschke
Caleb Hattingh wrote:
 4.0//2 doesn't return an integer, but the equality against an integer
 still holds.   I agree that integer division should return an integer,
 because using the operator at all means you expect one.

There are actually two conflicting expectations here: You're right, the 
semantics of a floor operation let you expect an int, but on the other 
hand, the result type of all other binary operations is the common type 
into which the operands are casted before the operation, and the result 
type of math.floor() is always float, even for an int operand.

The thing that I thought is a bit awkward is that

a//b * some_list

will not work if a or b is a float, even if it represents an integer and 
even though the result of a//b always represents an integer.

Now there are two ways to resolve this:

a) a//b always returns an int (or long)
b) n * some_list works if n is a float representing an integer

I was actually considering solution b), not a).

By the way, solution a) has another drawback: What would you return if 
a=1e200 and b=1, or a=1 and b=1e-200? Of course, a floor division would 
be pretty silly with such numbers, but returning a long number with 200 
digits of which most are wrong anyway somehow does not look like the 
right thing to do.

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


************************************LOOK AT THIS*************************************

2006-03-25 Thread lezhewitt67
I am trying to gain sponsorship for a charity The Stroke Association for
which i am doing the London Marathon in April this year.  I would be
greatful if all those persons who see this message would visit my webpage at
www.justgiving.com/lezmarathon.  All donations are welcome no matter how
small.  If anyone can think of any other groups that this message could be
posted to, please contact me at my email address [EMAIL PROTECTED]
Please Give Generously many thanks LezHewitt
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Programming challenge: wildcard exclusion in cartesian products

2006-03-25 Thread Dirk Thierbach
Dinko Tenev [EMAIL PROTECTED] wrote:
 Dirk Thierbach wrote:

 [A lot of stuff]

 Now clearer?

 Let's leave it there, and take a break.

Maybe it would help to just take a concrete example, and work through
it. Then you'll see exactly what happens.

- Dirk

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


OT: unix newbie questions

2006-03-25 Thread Gerard Flanagan
Hello all

Some basic unix questions which pure laziness prevents me from googling
for.  Anyone feeling charitable? I'm using FreeBSD 6.0:

* To create an empty __init__.py file I do 'vim __init__.py' then
immediately exit vim, is there a shell or vim command which will create
an empty file without opening the editor?

* If I want to do :

mv mypackage-1.0.2.tar.gz subdir/mypackage-1.0.2.tar.gz

  then tab-completion gives me the first occurrence of the file, but I
have to type the second  occurrence - is there a way of not having to
type it?

* cd ~ brings me to my home directory, is there a means by which I can
set up a similar alias for, say, /usr/local/www, so I can do: eg. cd ^
to get to that directory?

* I'm using the tcsh shell and have no problems with it, but bash seems
more popular - any reason to change? (I don't intend writing many shell
scripts)

* Any other unix/vim tips for a 'nix newb?!

Thanks in advance

Gerard

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


Re: Incremental Compression

2006-03-25 Thread Eyal Lotem
Adam DePrince wrote:

 On Sat, 2006-03-25 at 03:08 +0200, Eyal Lotem wrote:
 Hey.
 
 I have a problem in some network code. I want to send my packets
 compressed, but I don't want to compress each packet separately (via
 .encode('zlib') or such) but rather I'd like to compress it with regard
 to the history of the
 compression stream.  If I use zlib.compressobj and flush it to get the
 packet data, I cannot continue to compress with that stream.
 
 Yes, you can.
 
 Help on built-in function flush:
 
 flush(...)
 flush( [mode] ) -- Return a string containing any remaining
 compressed data.
 mode can be one of the constants Z_SYNC_FLUSH, Z_FULL_FLUSH,
 Z_FINISH; the
 default value used when mode is not specified is Z_FINISH.
 If mode == Z_FINISH, the compressor object can no longer be used
 after
 calling the flush() method.  Otherwise, more data can still be
 compressed.
 
 you want to call
 
 mycompressor.flush( zlib.Z_SYNC_FLUSH )
 
 The difference between the flushes is this:
 
 1. Z_SYNC_FLUSH.  This basically send enough data so that the receiver
 will get everything you put in.  This does decerase your compression
 ratio (however, in weird case when I last played with it, it helped.)
 
 2. Z_FULL_FLUSH.  This sends enough data so that the receiver will get
 everything you put in.  This also wipes the compressors statistics, so
 the when you pick up where you left of, the compressor will compress
 about as well as if you had just started, you are wiping its memory of
 what it saw in the past.
 
 3. Z_FINISH.  This is the default action, this is what is killing you.
 
 Good luck - Adam DePrince

Thanks! That really helps.

 
 
 I cannot wait until the end of the stream and then flush, because I need
 to flush after every packet.
 
 Another capability I require is to be able to copy the compression
 stream. i.e: To be able to create multiple continuations of the same
 compression stream. Something like:
 
 a = compressobj()
 pre_x = a.copy()
 x = a.compress('my_packet1')
 # send x
 # x was not acked yet, so we must send another packet via the pre_x
 compressor
 y = pre_x.compress('my_packet2')
 
 Is there a compression object that can do all this?
 
 
 Ahh, you are trying to pretune the compressor before sending a little
 bit ... I think C-zlib does this, but I don't know for sure.

Yeah, but I don't need a powerful tuning, just a means to copy the
compressor's state.  I guess I'll need to write some C for this.

Thanks again!

 
 - Adam DePrince

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


Re: OT: unix newbie questions

2006-03-25 Thread Rene Pijlman
Gerard Flanagan:
* To create an empty __init__.py file I do 'vim __init__.py' then
immediately exit vim, is there a shell or vim command which will create
an empty file without opening the editor?

touch __init__.py

* cd ~ brings me to my home directory, is there a means by which I can
set up a similar alias for, say, /usr/local/www, so I can do: eg. cd ^
to get to that directory?

You could create an alias in your shell.

-- 
René Pijlman

Wat wil jij leren?  http://www.leren.nl
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to format a return value by using re.sub(regx,rep1,str)?

2006-03-25 Thread Kent Johnson
dongdong wrote:
 for example:
  re.sub('a( [^]+)+\s?[^^]*/a','',' asd gaa target=_blank
 href=http://www.sine.com; class=wordstyle asdgasdghae rha/a')
 
 I wish to get the return value asd ga asdgasdghae rha,how do do?
 I have a impression on % and {number},but forgot how to use them.
 
Use a group to capture the text between a and /a:

In [10]: re.sub('a( [^]+)+\s?([^^]*)/a',r'\2',' asd gaa 
target=_blank href=http://www.sine.com; class=wordstyle 
asdgasdghae rha/a')
Out[10]: ' asd ga asdgasdghae rha'

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


Re: OT: unix newbie questions

2006-03-25 Thread Diez B. Roggisch
 * If I want to do :
 
 mv mypackage-1.0.2.tar.gz subdir/mypackage-1.0.2.tar.gz
 
   then tab-completion gives me the first occurrence of the file, but I
 have to type the second  occurrence - is there a way of not having to
 type it?

No need to give it the name the second time.

# touch foo
# mkdir d
# mv foo d
# ls d
foo
#

Diez

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


MySQLDB - return strange type of variable

2006-03-25 Thread Grzegorz Smith
Hi all. I'm trying get data from text field in MySQl 5.0 with my National
characters. Data are stored in utf8 encodings. Here is the script:
import MySQLdb, MySQLdb.cursors
conn = MySQLdb.connect(host='localhost', user='root', passwd='123456',
db='profile_locale')
c = conn.cursor(MySQLdb.cursors.DictCursor)
c.execute(SET CHARACTER SET utf8)
c.execute(SELECT string_value FROM lang_pl_pl WHERE id=8)
row = c.fetchone()
print row
and i get:
{'string_value': array('c', 'Zmie\xc5\x84 has\xc5\x82o')}
where it come array type?
How can i get value 'Zmie\xc5\x84 has\xc5\x82o' ?? because I trying do this
and I can't achieve. If I do c.fetchone -shouldn't i get type tuple?
I'm using MySQLdb 1.2.0 on Windows XP Professional SP2 installed
Any help will be appreciated
-- 
http://mail.python.org/mailman/listinfo/python-list


MyghtyBoard 0.0.1

2006-03-25 Thread piotr maliński
MyghtyBoard 0.0.1 alfa have been released. It's a forum script written
in python/myghty/hk_classes.

Download: 
http://sourceforge.net/project/showfiles.php?group_id=163611package_id=185021release_id=404570

Few old screens:
http://www.fotosik.pl/pokaz_obrazek/q0pq9tc1i6aphwc4.html
http://www.fotosik.pl/pokaz_obrazek/4xdrt560ove5i0gf.html
http://www.fotosik.pl/pokaz_obrazek/tf2tqifsog43eiuv.html

Requirements:
- Python :)
- Myghty - http://www.myghty.org/
- hk_classes python module -
http://hk-classes.sourceforge.net/tiki-page.php?pageName=Description
- MySQL database

Installation howto is in the readme. All comments and suggestions are welcome.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: encoding problems (é and è)

2006-03-25 Thread Martin v. Löwis
Serge Orlov wrote:
 The problem is that U+0587 is a ligature in Western Armenian dialect
 (hy locale) and a character in Eastern Armenian dialect (hy_AM locale).
 It is strange the code point is marked as compatibility char. It either
 mistake or political decision. It used to be a ligature before
 orthographic reform in 1930s by communist government in Armenia, then
 it became a character, but after end of Soviet Union (1991) they
 started to think about going back to old orthography. Though it hasn't
 happened and it's not clear if it will ever happen. So U+0587 is a
 character.

Thanks for the explanation. Without any knowledge, I would suspect
a combination of mistake and political decision. The Unicode consortium
(and ISO) always uses native language experts to come up with character
definitions, although the process is today likely more elaborate and
precise than in the early days. Likely, the Unicode consortium found
somebody speaking the Western Armenian dialect (given that many of these
speakers live in North America today); the decision might have been
a mixture of lack of knowledge, ignorance, and perhaps even political
bias.

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


Re: Building Python extensions from sources on Windows

2006-03-25 Thread Martin v. Löwis
TPJ wrote:
 And that's the problem: I understand the fact, that in order to build a
 non-pure distrubution, all the C sources have to be compiled (to dll
 libraries?). But there's the problem: I don't know which one compiler
 should I use. Do I have to use the same compiler, that the Python has
 been compiled with? If so, which one of the Windows compilers has been
 used to compile Python?
 
 Or perhaps could I use an another compiler? Which one, then?

You should use the same compiler; for Python 2.4, that was Visual Studio
.NET 2003. More specifically, you need to use the same version of the
C library - the compiler does not matter that much. The C library is
msvcr71.dll.

It is possible to build extensions with other compilers as well, e.g.
GNU mingw32.

If you don't VS 2003, but want to use that compiler, take a look at

http://www.vrplumber.com/programming/mstoolkit/

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


Beginner's question: executing scripts under Win XP pro

2006-03-25 Thread Jean-Claude Garreau
Hi,

I'm a beginner with python 2.4. I use it on Win XP Pro. I have no problems 
with the GUI IDLE, but
when I copy the instructions in a script file, say 'test.py' and double 
click on the file, I have just a
console window for a few moments, no output shown and the window closes 
automatically before
I can do anything else. I am greatful if anyone can help me.

Please reply also to [EMAIL PROTECTED]

Thanks a lot,

Jean-Claude 


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


Re: Beginner's question: executing scripts under Win XP pro

2006-03-25 Thread [EMAIL PROTECTED]
there seems to be an error in your script.
Why don't you execute it directly from IDLE (F5) ? There, you should
see where the problem is.

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


Re: How do I handle #

2006-03-25 Thread Michael Sperlle
On Sat, 25 Mar 2006 07:06:59 +0100, Fredrik Lundh wrote:

 Michael Sperlle wrote:
 
 I need to write out a file containing the # comment. When I try to
 specify it as part of a literal, everything afterward turns into a
 comment.
 
 turns into a comment in what sense ?  from your description, it sounds
 like a bug in your editor's syntax highlighter.  Python itself definitely
 won't look for comment markers inside string literals.
 

Thanks, I just tried it again and it worked. I must have had a misplaced
bit.





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


Re: Beginner's question: executing scripts under Win XP pro

2006-03-25 Thread Jean-Claude Garreau
Thank you for your answer. I did it. It executes perfectly in IDLE. I made a 
copy/paste
from IDLE into the 'test.py' and I obseved the behavior I discribed. The 
script is extremely simple
(it is just a test):

n=0

while( n10 ):

print n,n*n

n+=1

[EMAIL PROTECTED] a écrit dans le message de news: 
[EMAIL PROTECTED]
 there seems to be an error in your script.
 Why don't you execute it directly from IDLE (F5) ? There, you should
 see where the problem is.
 


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

Re: What's The Best Editor for python

2006-03-25 Thread gene tani

Christoph Zwerschke wrote:
 Just because nobody has mentioned them so far:

 - SciTe is a perfect editor for Pyhton on Win and Linx
 - PyScripter is a wonderful IDE (but only on Win)
 - DrPython is a nice platform independent editor/mini-IDE



http://www.artima.com/forums/flat.jsp?forum=106thread=148389start=0msRange=15

http://activestate.com/Products/Komodo/?utm_source=home_pageutm_medium=bannerutm_campaign=Komodo
http://wingware.com/

Also vim, emacs, jedit or eclipse, textmate, Leo, Kate,

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


Re: Beginner's question: executing scripts under Win XP pro

2006-03-25 Thread Scott Souva
On Sat, 25 Mar 2006 14:45:34 +0100, Jean-Claude Garreau
[EMAIL PROTECTED] wrote:

Hi,

I'm a beginner with python 2.4. I use it on Win XP Pro. I have no problems 
with the GUI IDLE, but
when I copy the instructions in a script file, say 'test.py' and double 
click on the file, I have just a
console window for a few moments, no output shown and the window closes 
automatically before
I can do anything else. I am greatful if anyone can help me.

Please reply also to [EMAIL PROTECTED]

Thanks a lot,

Jean-Claude 


Your script may be working properly, but XP simply removes the window
after the script runs.  Here is a simple fix that will stop at the end
of the script and leave the Command window open:

print Hello World
raw_input()
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What's The Best Editor for python

2006-03-25 Thread gene tani

gene tani wrote:
 Christoph Zwerschke wrote:
  Just because nobody has mentioned them so far:
 


http://spyced.blogspot.com/2006/02/pycon-python-ide-review.html

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


Re: __slots__

2006-03-25 Thread David Isaac
Aahz [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Because __slots__ breaks with inheritance.

I believe that was the point of Ziga's example,
which I acknowledged as a good one in my reply.
So there still appears to be this single reason, which
applies if your class may be subclassed.

Does this beg the question of whether __slots__
*should* break with inheritance?

One other question I did not get answered:  is there any
simple example of a Pythonic use of __slots__ that does NOT
involve the creation of **many** instances.

Thanks,
Alan Isaac


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


Re: overlapping sets

2006-03-25 Thread Alex Martelli
Lonnie Princehouse [EMAIL PROTECTED] wrote:

 There is a sets.Set class built in to Python.  You might want to use

In 2.4, there's also a set builtin type -- you can keep using the sets
module from the standard library, but the built-in set is faster.

If you need compatibility with both 2.3 and 2.4, getting the best set
implementation available in each case, the common idiom is:

try:
set
except NameError:
from sets import Set as set

The interface to use the set type/class is the same in either case.


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


Re: Comparisons and singletons

2006-03-25 Thread David Isaac
Ziga Seilnacht [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
  a = 1
  b = 1
  a == b
 True
  a is b
 False

Two follow up questions:

1. I wondered about your example,
and noticed
 a = 10
 b = 10
 a is b
True

Why the difference?

2. If I really want a value True will I ever go astray with the test:
if a is True:
 a = True
 b = 1.
 c = 1
 a is True, b is True, c is True
(True, False, False)

Thanks,
Alan Isaac


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


Re: __slots__

2006-03-25 Thread Alex Martelli
David Isaac [EMAIL PROTECTED] wrote:
   ...
 Does this beg the question of whether __slots__
 *should* break with inheritance?

How would you expect the following code to behave:

class Base(object):
def __init__(self): self.x = 23

class Derived(Base):
__slots__ = 'y',

?  I would expect it to work (as it does in Python), therefore I think
it's fit and proper that __slots__ breaks with inheritance, meaning it
basically has no effect unless every class in the inheritance DAG has
slots.


 One other question I did not get answered:  is there any
 simple example of a Pythonic use of __slots__ that does NOT
 involve the creation of **many** instances.

Since the only benefit of __slots__ is saving a few bytes per instance,
it's not worth the bother unless there are many instances -- so, the
answer is 'no'.


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


check object being a compiled regular expression

2006-03-25 Thread Helmut Jarausch
Hi,
sorry, this seems to be a FAQ but I couldn't find anything

I need to check if an object is a compiled regular expression

Say
import re
RX= re.compile('^something')

how to test

if RX is a compiled regular expression

type(RX)  says
type '_sre.SRE_Pattern'

but

if isinstance(RX,_sre.SRE_Pattern)
and
if isinstance(RX,re._sre.SRE_Pattern)
both fail.

Many thanks for a hint,

Helmut Jarausch

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


Re: Comparisons and singletons

2006-03-25 Thread Chris Mellon
On 3/25/06, David Isaac [EMAIL PROTECTED] wrote:
 Ziga Seilnacht [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
   a = 1
   b = 1
   a == b
  True
   a is b
  False

 Two follow up questions:

 1. I wondered about your example,
 and noticed
  a = 10
  b = 10
  a is b
 True

 Why the difference?

 2. If I really want a value True will I ever go astray with the test:
 if a is True:
  a = True
  b = 1.
  c = 1
  a is True, b is True, c is True
 (True, False, False)


None, True, and False are all singletons and should be compared with
is. There are some other singletons - small integers (up to 10, I
believe) as well as the empty string. However, I am not sure (and I am
sure someone will correct me if I'm wrong) but I believe that these
are not specified as singletons, and that it's an implementation
detail that they are.

 Thanks,
 Alan Isaac


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

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


Re: MySQLDB - return strange type of variable

2006-03-25 Thread Jeffrey Froman
Grzegorz Smith wrote:

 Hi all. I'm trying get data from text field in MySQl 5.0 with my National
 characters. Data are stored in utf8 encodings. Here is the script:
 import MySQLdb, MySQLdb.cursors
 conn = MySQLdb.connect(host='localhost', user='root', passwd='123456',
 db='profile_locale')
 c = conn.cursor(MySQLdb.cursors.DictCursor)
 c.execute(SET CHARACTER SET utf8)
 c.execute(SELECT string_value FROM lang_pl_pl WHERE id=8)
 row = c.fetchone()
 print row
 and i get:
 {'string_value': array('c', 'Zmie\xc5\x84 has\xc5\x82o')}
 where it come array type?

Recent versions of MySQL/MySQLdb return binary strings as Python array
objects, rather than bytestrings (I think the change was around version 4.2
of MySQL.) Details on array objects are here:

http://www.python.org/doc/lib/module-array


 How can i get value 'Zmie\xc5\x84 has\xc5\x82o' ??

array('c', 'Zmie\xc5\x84 has\xc5\x82o').tostring()


 If I do c.fetchone -shouldn't i get type tuple? 

If you use the default MySQLdb cursor object you will get a tuple. Using the
DictCursor as you are returns a dictionary instead.


Jeffrey


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


Re: how to format a return value by using re.sub(regx,rep1,str)?

2006-03-25 Thread Paul McGuire
dongdong [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 for example:
  re.sub('a( [^]+)+\s?[^^]*/a','',' asd gaa target=_blank
 href=http://www.sine.com; class=wordstyle asdgasdghae rha/a')

 I wish to get the return value asd ga asdgasdghae rha,how do do?
 I have a impression on % and {number},but forgot how to use them.


Well, here's the pyparsing rendition (two, actually).  I hope it's easier to
follow then trying to pick apart the above regexp.  Both

Download pyparsing at http://pyparsing.sourceforge.net.

-- Paul


instr = ' asd gaa target=_blank
href=http://www.sine.com; class=wordstyle asdgasdghae rha/a'

from pyparsing import makeHTMLTags,Suppress,MatchFirst

# makeHTMLTags returns a tuple of the start and end pattern for the given
tag
aStart,aEnd = makeHTMLTags(a)

# define a filter that will suppress the opening and closing tags
# this is easily extended to filter additional patterns, too
filter = Suppress(aStart) | Suppress(aEnd)

# invoke transformString using the filter
print filter.transformString(instr)

# or for the dense-code minded...
filter = MatchFirst( map( Suppress, makeHTMLTags(a) ) )
print filter.transformString(instr)


Prints:
' asd ga asdgasdghae rha'
' asd ga asdgasdghae rha'


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


Re: check object being a compiled regular expression

2006-03-25 Thread James Thiele
This is crude, but works:

 import re
 RX= re.compile('^something')
 str(RX).find(_sre.SRE_Pattern) == 0
True

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


Re: Python types

2006-03-25 Thread BWill
Salvatore wrote:
 Hello,
 
 I've read several articles where it's said that Python is weakly typed.
 I'm a little surprised. All objects seem to have a perfectly defined
 type
 
 Am i wrong?
 
 Regards
 
Aye, the other posters are right about you being right. This is just one 
of the great mass confusions in programming (sadly, there are a lot of 
them these days).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python types

2006-03-25 Thread Salvatore
Thank's everybody :-)


Here is a type définition I've found on the net which I agree with :

Attribute of a variable which determines the set of the values this
variabe can take and the
operations we can apply on it.

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


Re: Comparisons and singletons

2006-03-25 Thread Ziga Seilnacht
David Isaac wrote:
 Ziga Seilnacht [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
   a = 1
   b = 1
   a == b
  True
   a is b
  False

 Two follow up questions:

 1. I wondered about your example,
 and noticed
  a = 10
  b = 10
  a is b
 True

 Why the difference?

Python has a special internal list of integers in which it caches
numbers smaller than 1000 (I'm not sure that the number is correct),
but that is an implementation detail and you should not rely on it.

 2. If I really want a value True will I ever go astray with the test:
 if a is True:
  a = True
  b = 1.
  c = 1
  a is True, b is True, c is True
 (True, False, False)

I think that True and False, although they were added in version
2.3, were not true singeltons until version 2.4. You should finish
reading the PEP, see especially this part:

- Don't compare boolean values to True or False using ==

Yes:   if greeting:

No:if greeting == True:

Worse: if greeting is True:

 
 Thanks,
 Alan Isaac

Ziga

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


Re: check object being a compiled regular expression

2006-03-25 Thread Diez B. Roggisch
Helmut Jarausch schrieb:
 Hi,
 sorry, this seems to be a FAQ but I couldn't find anything
 
 I need to check if an object is a compiled regular expression
 
 Say
 import re
 RX= re.compile('^something')
 
 how to test
 
 if RX is a compiled regular expression
 
 type(RX)  says
 type '_sre.SRE_Pattern'
 
 but
 
 if isinstance(RX,_sre.SRE_Pattern)
 and
 if isinstance(RX,re._sre.SRE_Pattern)
 both fail.
 
 Many thanks for a hint,


Just invoke type on a compiled expression and store that:

Python 2.4.1 (#2, Mar 31 2005, 00:05:10)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1666)] on darwin
Type help, copyright, credits or license for more information.
Welcome to rlcompleter2 0.96
for nice experiences hit tab multiple times
  import re
  re_type = type(re.compile(foo))
  isinstance(re.compile(bar), re_type)
True
 


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


Custom behavior defined in the imported module

2006-03-25 Thread Paul McGuire
I have a new enhancement to pyparsing that doubles the parse speed (using a
technique called packrat parsing), but which is not suitable for all
parsers, specifically those that have complex parse actions.  I don't want
to just enable this feature by default - I think there is too much risk of
it breaking existing code.  Actually, I think the chance is 10%, but I
think I'm better off leaving the feature dormant unless explicitly enabled,
so that it doesn't take someone by surprise when they install the new
version.

The alternatives I've come up with for the user to enable this packrat parse
mode are:

1. Add a staticmethod enablePackrat() to the pyparsing ParserElement class,
to modify the ParserElement defintion of the internal (non-packrat) parse()
method.  This method essentially runs code looking like:

ParserElement.parse,ParserElement.originalParse = \
ParserElement.packratParse,ParserElement.parse

where the packratParse method is a memoizing wrapper around calls to
originalParse.  This technique requires the caller to invoke
ParserElement.enablePackrat() after having imported pyparsing.

This renaming trick actually breaks when using psyco, if psyco has compiled
the pyparsing methods before calling enablePackrat().  You have to import
pyparsing, call enablePackrat(), then call psyco.full(), or whatever psyco
commands to cache compiled versions of the pyparsing function code.

2. Implement some sort of onImport hook to allow the calling routine to
use a specialized import statement, something like from pyparsing import
packratParsing that would do the same as the above enablePackrat() call,
but perhaps in a more Pythonic-looking manner. (I was inspired along these
lines from Jim Hugunin's IronPython talk, in which he used import hooks to
modify the behavior of the base Python string class.)  I've looked a bit at
imp, imputil, and ihooks, and these all seem to be modifiers to the import
mechanism as called from the importing module.  What import hooks are
accessible from within the module being imported?  Is there any way to see
which form of import was used, and to access the arguments of the import
command as invoked from the calling module?

I was hoping that by hooking into the import command, I could make this
mode-setting command more atomic with the actual import of pyparsing's class
and function definitions, to avoid problems like the psyco issue.


Plus I'm open to other suggestions as well.

Thanks,
-- Paul



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


Re: __slots__

2006-03-25 Thread Ron Garret
In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Alex Martelli) wrote:

  One other question I did not get answered:  is there any
  simple example of a Pythonic use of __slots__ that does NOT
  involve the creation of **many** instances.
 
 Since the only benefit of __slots__ is saving a few bytes per instance,
 it's not worth the bother unless there are many instances -- so, the
 answer is 'no'.

I can think of at least two other benefits to using __slots__:

1.  If you have a typo in an attribute assignment you get an exception 
instead of a latent downstream bug.

2.  Implicit documentation.

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


Re: Python types

2006-03-25 Thread Alex Martelli
Salvatore [EMAIL PROTECTED] wrote:

 Thank's everybody :-)
 
 
 Here is a type définition I've found on the net which I agree with :
 
 Attribute of a variable which determines the set of the values this
 variabe can take and the
 operations we can apply on it.

Hmmm -- that doesn't work very well for languages in which a variable
is just a name, because we cannot apply any operations at all on THE
NAME -- we apply operations on the OBJECT to which the name refer.  This
issue arises with both languages where names can take any object, like
Python, and ones where the compiler infers the subset (type) of objects
that each name can take, like Boo.

Moreover, asserting that 'type' is an attribute of a variable means, for
example, that a function's return-value, not being a variable, has no
type -- that really makes no sense.  And similarly for other
expressions; e.g., consider, in Java, something like...:

( (Fooable) zip() ).getFoo() + ( (Barable) zop() ).getBar()

no variables in sight, yet a lot of types in Java's normal sense -- the
types of whatever objects zip() and zop() return, the (Fooable and
Barable, respectively) types after the cast, the type of whatever getFoo
and getBar return, and the type of their sum...

Saying that an _object_ has a type thus makes more sense (even in Java
and similar languages) than considering type to be an attribute of a
variable -- *in addition* to objects, which have types, other language
constructs, depending on the language, may or may not be imbued with
type-constraints, be that declaratively (as, say, in Java), by compiler
inference (as, say, in Boo), or by other means yet such as stropping
(e.g., in Perl, you can tell from just looking at the name whether a
variable refers to a scalar, $something, an array, @something, or a
hash, %something -- in Python, Java or Boo you can't tell from just the
name, but rather must find a declaration [Java], assignment [Python] or
use [Boo] to let you read or infer the scalar vs array type issue).


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


Re: imap folder scanner

2006-03-25 Thread Sebastjan Trepca
senders is list, that is why that regex does not work. I don't like regexes that much so you can try this:parsed_senders = []sender = for item in senders: if isinstance(item,tuple):
 item= ''.join(item) if item==')': parsed_senders.append(sender[sender.find('From:')+5:].strip()) sender =  else: sender+=itemprint parsed_sendersSebastjan

On 3/25/06, Kun [EMAIL PROTECTED] wrote:

Marco Carvalho wrote: On 3/24/06, Sebastjan Trepca [EMAIL PROTECTED] wrote: 
m.select('myfolder') Some attention is required here to retrieve subfolders.
 Some imap servers like Cyrus and Courier uses INBOX.subfolder to access subfolders. -- Marco Carvalho (macs) | marcoacarvalho(a)gmail.com 

http://arrakis.no-ip.info| http://cdd.debian-br.org Maceio - Alagoas - Brazil Debian GNU/Linux unstable (Sid)
 GNU-PG ID:08D82127 - Linux Registered User #141545
 Notícias Semanais do Debian em Português: http://www.debian.org/News/weekly Alertas de Segurança Debian (DSA): 
http://www.debian.org/security
so i have used the following code and have successfully saved a list ofsenders as a string.however, the string has much more information thanjust the email address and i am wondering what is the best way to parse
the email address out of the entire string.sample string:  print status, sendersOK [('460 (BODY[HEADER.FIELDS (FROM)] {46}', 'From: Friend
[EMAIL PROTECTED]
\r\n\r\n'), ')', ('462 (BODY[HEADER.FIELDS (FROM)] {37}','From: Kun [EMAIL PROTECTED]\r\n\r\n'), ')']
how do i just get the two email addresses out of there?
my code is:from imaplib import *import getpassm = IMAP4()m.login('xx', 'xxx')m.select('Inbox')status, data = "" BIKES)')

assert status=='OK', Error. Message: %s%datadata = "" #you get your results in a list and search returns onlyone resultassert data,No results#cool, we have results, but IMAP's search command only returns IDs so we
have to fetch#msgs nowstatus,senders = m.fetch(data.replace(' ',','),'(BODY.PEEK[HEADER.FIELDS(FROM)])')assert status=='OK', Error. Message: %s%dataprint senders--

http://mail.python.org/mailman/listinfo/python-list-- Sebastjan
http://www.trepca.si/blog

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

Re: newbie parsing question

2006-03-25 Thread Paul McGuire
Kun [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 i have a list of that is:

 [('460 (BODY[HEADER.FIELDS (FROM)] {46}', 'From: Friend
 [EMAIL PROTECTED]\r\n\r\n'), ')', ('462 (BODY[HEADER.FIELDS (FROM)] {37}',
 'From: Kun [EMAIL PROTECTED]\r\n\r\n'), ')']


 how do i parse the email addresses out of it into another list or string?

data = [('460 (BODY[HEADER.FIELDS (FROM)] {46}',
'From: Friend [EMAIL PROTECTED]\r\n\r\n'), ')',
   ('462 (BODY[HEADER.FIELDS (FROM)] {37}',
'From: Kun [EMAIL PROTECTED]\r\n\r\n'), ')']

for s in data:
   if type(s) is tuple:
   print s[1][6:].strip().split()[1]

Gives:
[EMAIL PROTECTED]
[EMAIL PROTECTED]


-- Paul


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


Re: __slots__

2006-03-25 Thread Alex Martelli
Ron Garret [EMAIL PROTECTED] wrote:

 In article [EMAIL PROTECTED],
  [EMAIL PROTECTED] (Alex Martelli) wrote:
 
   One other question I did not get answered:  is there any
   simple example of a Pythonic use of __slots__ that does NOT
   involve the creation of **many** instances.
  
  Since the only benefit of __slots__ is saving a few bytes per instance,
  it's not worth the bother unless there are many instances -- so, the
  answer is 'no'.
 
 I can think of at least two other benefits to using __slots__:
 
 1.  If you have a typo in an attribute assignment you get an exception
 instead of a latent downstream bug.

If your unittests are so feeble that they won't catch such typos, you
have far bigger problems -- and you should be using pychecker or pylint
anyway, as they'll catch far more typos than __slots__ ever will (far
from all, of course -- a simple typo of + vs - can still kill you --
which is why they can't *substitute* for unittests in any case).

 2.  Implicit documentation.

If you don't document what the sundry variables are FOR, you're really
not documenting your code at all -- just listing the names of some
attributes is far too weak.  If the existence of such listing can in any
way give the programmer an excuse to NOT do real documentation (as your
classifying it as implicit documentation strongly suggests), then the
net effet is not a benefit, but a serious detriment to code quality.


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


Re: image reduction script

2006-03-25 Thread Philippe Martin
Larry,

I actually did not find what I needed in PIL (missed it ?) but found this
package quite usefull: http://www.imagemagick.org/script/index.php

Philippe





Larry Bates wrote:

 Philippe Martin wrote:
 Hi,
 
 I need to write a script to reduce the resolution/color depth of an image
 (ex: .jpg) based on a target size.
 
 The point is for the target picture to still be understandable - yet I
 target getting down to 5K.
 
 Are there libraries out there that could help me start ?
 
 Thanks
 
 Philippe
 
 
 Python Imaging Library (PIL).
 
 http://www.pythonware.com/products/pil/
 
 -Larry Bates

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


Accessing func_name from inside a function

2006-03-25 Thread James Thiele
I'd like to access the name of a function from inside the function. My
first idea didn't work.

 def foo():
... print func_name
...
 foo()
Traceback (most recent call last):
  File stdin, line 1, in ?
  File stdin, line 2, in foo
NameError: global name 'func_name' is not defined

My second attempt works but looks ugly.

 def foo():
... import inspect
... print inspect.stack()[0][3]
...
 foo()
foo

Is there a standard way of getting the name of a function from inside
the function?

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


Re: Python types

2006-03-25 Thread Salvatore
Grazie ALex, for your comment.

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


Re: __slots__

2006-03-25 Thread Duncan Booth
Ron Garret wrote:

  [EMAIL PROTECTED] (Alex Martelli) wrote:
 
  One other question I did not get answered:  is there any
  simple example of a Pythonic use of __slots__ that does NOT
  involve the creation of **many** instances.
 
 Since the only benefit of __slots__ is saving a few bytes per instance,
 it's not worth the bother unless there are many instances -- so, the
 answer is 'no'.
 
 I can think of at least two other benefits to using __slots__:
 
 1.  If you have a typo in an attribute assignment you get an exception 
 instead of a latent downstream bug.

Only if all classes in the inheritance define __slots__, and don't include 
__dict__ in their slots. In particular, it means you can never rely on 
this in any code you write which inherits from a library class over which 
you have no control.

In other words, it is such a risky thing to depend on that you would be 
much better never to rely on it. Try writing some unit tests instead.

 
 2.  Implicit documentation.

Explicit is better than implicit.

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


Re: Accessing func_name from inside a function

2006-03-25 Thread Martin v. Löwis
James Thiele wrote:
 Is there a standard way of getting the name of a function from inside
 the function?

No, there isn't.

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


HIRING: PHP Developer

2006-03-25 Thread HiringDivision
 From:  In Need - view profile
Date:  Fri, Mar 24 2006 10:39 pm
Email:   In Need [EMAIL PROTECTED]
Groups:   hfx.forsale
Not yet ratedRating:
show options


Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Report Abuse | Find messages by this author


We are hiring a PHP developer!

The site must contain the following:
- database
- administrator panel (implementing multiple employee logins /
permissions)
- credit card / paypal processing
- affiliate program
- news scripting control panel
- image design
- coupons / discounts,  gift certificates
- customer log in / log out
- specials page
- contests
- forum


Would like to have:
- flash design
- various language support
- pages that have pre-loaded data (click the link and no new page opens

within the main frame.  Simply brings the information forward).


The individual(s) that are selected for this project will have the
opportunity to remain our company's web and image designer(s).  Please
send
a price quote for the above mentioned request, as well as a quote for a

design similar to www.IGE.com to [EMAIL PROTECTED]


Thank you.

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


detecting drives for windows and linux

2006-03-25 Thread BWill
Hi, I'm writing a file browser, but I'm not sure how I could go about 
detecting the drives available on windows and linux systems (preferably 
using the standard modules if possible). I guess I could just try to 
list root on each letter of the alphabet for windows and see if it 
works, but that seems crude; besides, I want to know what kind of drive 
each drive/partition is (i.e. is it local and is it a harddrive or 
optical drive).

Thanks,

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


Re: Custom behavior defined in the imported module

2006-03-25 Thread Kent Johnson
Paul McGuire wrote:
 The alternatives I've come up with for the user to enable this packrat parse
 mode are:
 
 1. Add a staticmethod enablePackrat() to the pyparsing ParserElement class,
 to modify the ParserElement defintion of the internal (non-packrat) parse()
 method.  This method essentially runs code looking like:
 
 ParserElement.parse,ParserElement.originalParse = \
 ParserElement.packratParse,ParserElement.parse

Could you just define a module pyparsingpackrat like this:
from pyparsing import *
ParserElement.parse,ParserElement.originalParse = \
 ParserElement.packratParse,ParserElement.parse

Then users would just import pyparsingpackrat instead of pyparsing.

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


Re: Accessing func_name from inside a function

2006-03-25 Thread Kent Johnson
James Thiele wrote:
 I'd like to access the name of a function from inside the function. 

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66062

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


Re: Custom behavior defined in the imported module

2006-03-25 Thread Paul McGuire
Kent Johnson [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Paul McGuire wrote:
  The alternatives I've come up with for the user to enable this packrat
parse
  mode are:
 
  1. Add a staticmethod enablePackrat() to the pyparsing ParserElement
class,
  to modify the ParserElement defintion of the internal (non-packrat)
parse()
  method.  This method essentially runs code looking like:
 
  ParserElement.parse,ParserElement.originalParse = \
  ParserElement.packratParse,ParserElement.parse

 Could you just define a module pyparsingpackrat like this:
 from pyparsing import *
 ParserElement.parse,ParserElement.originalParse = \
  ParserElement.packratParse,ParserElement.parse

 Then users would just import pyparsingpackrat instead of pyparsing.

 Kent

I *really* like keeping pyparsing's footprint down


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


Re: Custom behavior defined in the imported module

2006-03-25 Thread Paul McGuire
Kent Johnson [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Paul McGuire wrote:
  The alternatives I've come up with for the user to enable this packrat
parse
  mode are:
 
  1. Add a staticmethod enablePackrat() to the pyparsing ParserElement
class,
  to modify the ParserElement defintion of the internal (non-packrat)
parse()
  method.  This method essentially runs code looking like:
 
  ParserElement.parse,ParserElement.originalParse = \
  ParserElement.packratParse,ParserElement.parse

 Could you just define a module pyparsingpackrat like this:
 from pyparsing import *
 ParserElement.parse,ParserElement.originalParse = \
  ParserElement.packratParse,ParserElement.parse

 Then users would just import pyparsingpackrat instead of pyparsing.

 Kent
(damned touchy touchpad!)

... anyway...

I *really* like keeping pyparsing's footprint down to just one Python
module.  It would be nice if I could pass an argument along with the import
statement:

import pyparsing(packrat=True)

or some such.

-- Paul


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


Re: Accessing func_name from inside a function

2006-03-25 Thread James Thiele
OK. But that's just as ugly as my attempt.

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


Re: Custom behavior defined in the imported module

2006-03-25 Thread Paul McGuire
Kent Johnson [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Paul McGuire wrote:
  The alternatives I've come up with for the user to enable this packrat
parse
  mode are:
 
  1. Add a staticmethod enablePackrat() to the pyparsing ParserElement
class,
  to modify the ParserElement defintion of the internal (non-packrat)
parse()
  method.  This method essentially runs code looking like:
 
  ParserElement.parse,ParserElement.originalParse = \
  ParserElement.packratParse,ParserElement.parse

 Could you just define a module pyparsingpackrat like this:
 from pyparsing import *
 ParserElement.parse,ParserElement.originalParse = \
  ParserElement.packratParse,ParserElement.parse

 Then users would just import pyparsingpackrat instead of pyparsing.

 Kent

I'm also not overkeen on elevating the word packrat into the module name
itself!

-- Paul


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


a somewhat off-topic question about linux

2006-03-25 Thread John Salerno
I'm interested in trying out Linux, probably Ubuntu, but I was wondering 
which distribution you guys like to use (because it's a pain trying to 
decide!) and you guys are smart.

And to keep it Python related, I'll also ask, is there anything special 
I need to know about using Python on Linux? Do any things change, or can 
it be used just as I use it on Windows?

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


Re: a somewhat off-topic question about linux

2006-03-25 Thread Christoph Haas
On Sat, Mar 25, 2006 at 03:09:53PM -0500, John Salerno wrote:
 I'm interested in trying out Linux, probably Ubuntu, but I was wondering 
 which distribution you guys like to use (because it's a pain trying to 
 decide!) and you guys are smart.

We had this discussion a couple of time during the last months already. :)
I believe the most frequently recommended distribution was Ubuntu (or
Debian which Ubuntu is based upon).

 And to keep it Python related, I'll also ask, is there anything special 
 I need to know about using Python on Linux? Do any things change, or can 
 it be used just as I use it on Windows?

Some issues are platform-dependant. You will not be able to read the
registry or start a Microdoze-based program of course. Otherwise most parts
of Python are working the same way unless the documentation tells otherwise
in certain details.

 Christoph
 (Hoping to prevent a huge thread discussing pros/cons of distributions)
-- 
~
~
.signature [Modified] 1 line --100%--1,48 All
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: detecting drives for windows and linux

2006-03-25 Thread Tim Golden
BWill wrote:
 Hi, I'm writing a file browser, but I'm not sure how I could go about
 detecting the drives available on windows and linux systems (preferably
 using the standard modules if possible). I guess I could just try to
 list root on each letter of the alphabet for windows and see if it
 works, but that seems crude; besides, I want to know what kind of drive
 each drive/partition is (i.e. is it local and is it a harddrive or
 optical drive).

I'm not aware of any cross-platform way of doing this.
On Windows you have a few options, but I'd go down
the WMI route; it just makes life easier for doing this
kind of thing. You might want to start by adapting this
example:

http://tgolden.sc.sabren.com/python/wmi_cookbook.html#percentage_free

by removing the restriction to fixed disk (DriveType=3)

TJG

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


Re: Comparisons and singletons

2006-03-25 Thread Felipe Almeida Lessa
Em Sáb, 2006-03-25 às 09:11 -0800, Ziga Seilnacht escreveu:
 Python has a special internal list of integers in which it caches
 numbers smaller than 1000 (I'm not sure that the number is correct),
 but that is an implementation detail and you should not rely on it.

By testing:
 a = 10
 b = 10
 a is b
True
 a = 100
 b = 100
 a is b
False
 a = 50
 b = 50
 a is b
True
 a = 70
 b = 70
 a is b
True
 a = 99
 b = 99
 a is b
True

And to the other side:

 a = -10
 b = -10
 a is b
False
 a = -5
 b = -5
 a is b
True
 a = -6
 b = -6
 a is b
False

And then, when looking to Python 2.4's code[1]:

#ifndef NSMALLPOSINTS
#define NSMALLPOSINTS   100
#endif
#ifndef NSMALLNEGINTS
#define NSMALLNEGINTS   5
#endif
#if NSMALLNEGINTS + NSMALLPOSINTS  0
/* References to small integers are saved in this array so that they
   can be shared.
   The integers that are saved are those in the range
   -NSMALLNEGINTS (inclusive) to NSMALLPOSINTS (not inclusive).
*/
static PyIntObject *small_ints[NSMALLNEGINTS + NSMALLPOSINTS];
#endif


However, as stated before, don't rely on these numbers. The trunk[2] defines 
now 256, not 99, as the biggest integer shared.

[1]
http://svn.python.org/projects/python/tags/release24-fork/Objects/intobject.c 
[2] http://svn.python.org/projects/python/trunk/Objects/intobject.c

HTH,

-- 
Felipe.

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

Re: a somewhat off-topic question about linux

2006-03-25 Thread John Salerno
Christoph Haas wrote:
 On Sat, Mar 25, 2006 at 03:09:53PM -0500, John Salerno wrote:
 I'm interested in trying out Linux, probably Ubuntu, but I was wondering 
 which distribution you guys like to use (because it's a pain trying to 
 decide!) and you guys are smart.
 
 We had this discussion a couple of time during the last months already. :)
 I believe the most frequently recommended distribution was Ubuntu (or
 Debian which Ubuntu is based upon).

Oh sorry! I should have checked first. And yeah, I don't mean to start a 
big argument about which is better... :)

But thanks for the answer. I'm comforted to know that my choice is a 
good one. And as for Python, as long as there are no surprises, I should 
be okay.
-- 
http://mail.python.org/mailman/listinfo/python-list


pondering about the essence of types in python

2006-03-25 Thread gangesmaster
let's start with a question:

==
 class z(object):
... def __init__(self):
... self.blah=5
...
 class x(object):
... def __init__(self):
... z.__init__(self)
...
 y=x()
Traceback (most recent call last):
  File stdin, line 1, in ?
  File stdin, line 3, in __init__
TypeError: unbound method __init__() must be called with z instance as
first argument (got x instance instead)
==

and the question is -- WHY?

what is a type? generally speaking, if everything were an object, the
type only defines the MRO (method resolution order) for that object.
x.y first looks at the instance, then the class, then the parent
classes, etc. (this was changed a little in python2.3 to something more
complicated, but it's basically the same).

you can see the mro like this:
==
 class x(object): pass
 class y(x): pass
 class z(y): pass
 a=z()
 print a.__class__.mro()
[class '__main__.z', class '__main__.y', class '__main__.x',
type 'object']
==

after all, if we stay out of builtin types, all python objects are
dicts, which support chian-lookup according to the mro. and a method is
just a function that takes the instance as a first argument. so why is
all this type hassle necessary?

if we've taken it that far already, then let's really go over the edge.
I WANT TO DERIVE FROM INSTANCES. not only types.

why? i'm the developer of rpyc (http://rpyc.sf.net), and i got a
request from someone to add support for deriving from remote types. the
concrete example he gave was quite silly, but after i thought about it
a little, i said why not try?

a little intro about rpyc: it gives you proxies (instances) to remote
objects, which can be instances, functions, or classes. and that user
wanted to do something like this:

class my_frame(conn.modules.wx.Frame):
...

so the client was actually creates the graphics on the server. not very
usable, but why not?  all it means is, when he does my_frame.xyz,
python should add the remote type to the mro chain. not too bizar.

but __mro__ is a readonly attribute, and deriving from instances is
impossible (conn.modules.wx.Frame is a PROXY to the class)...

and again -- WHY? these all look like INTENTIONAL limitations. someone
went around and added type checks (which are NOT pythonic) into the
cPython implementation. argh. why do that?

so i thought -- let's be nasty. i created a function that creates a
class that wraps an instance. very ugly. small children and peope with
heart problems should close their eyes.


def derive_from(obj):
class cls(object):
def __getattr(self, name):
return getattr(obj, name)
return cls

class my_frame(derive_from(conn.modules.wx.Frame)):



the actual implementation is quite more complex, but that shows the
concept.
so now i'm experimenting with that little shit. but then i came to the
problem that methods check the type of the first argument... ARGH. dont
check types. DONT. the whole point of duck-typing is you DONT CHECK THE
TYPES. you just work with objects, and instead of TypeError you'd get
AttribiuteError, which is much better.  AAARRGGGHH.

python is EVIL at the low level. the high-level is just fine, but when
you try to go under the hood... you better go with an exorcist.



-tomer

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


Re: detecting drives for windows and linux

2006-03-25 Thread BWill
Tim Golden wrote:
 BWill wrote:
 Hi, I'm writing a file browser, but I'm not sure how I could go about
 detecting the drives available on windows and linux systems (preferably
 using the standard modules if possible). I guess I could just try to
 list root on each letter of the alphabet for windows and see if it
 works, but that seems crude; besides, I want to know what kind of drive
 each drive/partition is (i.e. is it local and is it a harddrive or
 optical drive).
 
 I'm not aware of any cross-platform way of doing this.
 On Windows you have a few options, but I'd go down
 the WMI route; it just makes life easier for doing this
 kind of thing. You might want to start by adapting this
 example:
 
 http://tgolden.sc.sabren.com/python/wmi_cookbook.html#percentage_free
 
 by removing the restriction to fixed disk (DriveType=3)
 
 TJG
 

oh, I wasn't expecting a single solution for both platforms, just some 
good solutions

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


Re: a somewhat off-topic question about linux

2006-03-25 Thread Duncan Booth
John Salerno wrote:

 I'm interested in trying out Linux, probably Ubuntu, but I was wondering 
 which distribution you guys like to use (because it's a pain trying to 
 decide!) and you guys are smart.

If you just want to try out Linux then a very easy way is to use VMWare 
Player: download it from http://www.vmware.com/products/player/. You can 
then run almost any Linux you wish directly on your windows system, no need 
to reboot or anything. Start with Browser Appliance which is a cut-down 
installation of Ubuntu (but it is configured so that things like the 
clipboard interact properly with Windows clipboard, and you can share files 
by sharing folders on windows and connecting to them from Ubuntu). Then you 
can use the package manager (on the System menu) to install Python and 
other packages (when it asks for a password use 'vmware' if you are using 
the default 'vmware' user).

You need about 2Gb of free disk space to install and use VMWare and Browser 
appliance: all of the Linux file system is stored in one file which expands 
as required up to 9.5Gb maximum (it helps performance if you keep the file 
defragmented: use contig.exe from www.sysinternals.com).

Once you have Vmware installed, as well as Ubuntu, you can also download 
Linux images for Novell/Suse, RedHat and literally dozens of other versions 
of Linux and Unix variants, some preconfigured for specific applications 
try them out and then throw them away. The only limits are your disc space.

 
 And to keep it Python related, I'll also ask, is there anything special 
 I need to know about using Python on Linux? Do any things change, or can 
 it be used just as I use it on Windows?
 
The main difference is that it is much easier to install packages which are 
part of the Ubuntu distribution: just run up the package manager, select 
the ones to install and download and install happen automatically.

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


simple string search and replace

2006-03-25 Thread Kun
hey guys, here's my code,

senders = [('460 (BODY[HEADER.FIELDS (FROM)] {46}', 'From: Friend 
[EMAIL PROTECTED]\r\n\r\n'), ')', ('462 (BODY[HEADER.FIELDS 
(FROM)] {37}', 'From: Kun [EMAIL PROTECTED]\r\n\r\n'), ')']
print senders
parsed_senders = []
sender = 
for item in senders:
if isinstance(item,tuple):
   item= ''.join(item)
if item==')':
   parsed_senders.append(sender[sender.find('')+1:].strip())
   sender = 
else:
   sender+=item
print parsed_senders




wondering if anyone knows how i can remove the ''s from the list, which 
outputs to something like ['[EMAIL PROTECTED]', '[EMAIL PROTECTED]']
-- 
http://mail.python.org/mailman/listinfo/python-list


(not really) randon ideas

2006-03-25 Thread oluoluolu
I have been programming in Python for many years, and I generally have
run into alot of the same problems repeatedly.

What is the consensus on these ideas please?

* enums
* constants
* an imagefile ala smalltalk
* symbols ala lisp/scheme

thx in advance

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


Re: a somewhat off-topic question about linux

2006-03-25 Thread John Salerno
Duncan Booth wrote:
 John Salerno wrote:
 
 I'm interested in trying out Linux, probably Ubuntu, but I was wondering 
 which distribution you guys like to use (because it's a pain trying to 
 decide!) and you guys are smart.
 
 If you just want to try out Linux then a very easy way is to use VMWare 
 Player: download it from http://www.vmware.com/products/player/. You can 
 then run almost any Linux you wish directly on your windows system, no need 
 to reboot or anything. Start with Browser Appliance which is a cut-down 
 installation of Ubuntu (but it is configured so that things like the 
 clipboard interact properly with Windows clipboard, and you can share files 
 by sharing folders on windows and connecting to them from Ubuntu). Then you 
 can use the package manager (on the System menu) to install Python and 
 other packages (when it asks for a password use 'vmware' if you are using 
 the default 'vmware' user).
 
 You need about 2Gb of free disk space to install and use VMWare and Browser 
 appliance: all of the Linux file system is stored in one file which expands 
 as required up to 9.5Gb maximum (it helps performance if you keep the file 
 defragmented: use contig.exe from www.sysinternals.com).
 
 Once you have Vmware installed, as well as Ubuntu, you can also download 
 Linux images for Novell/Suse, RedHat and literally dozens of other versions 
 of Linux and Unix variants, some preconfigured for specific applications 
 try them out and then throw them away. The only limits are your disc space.
 
 And to keep it Python related, I'll also ask, is there anything special 
 I need to know about using Python on Linux? Do any things change, or can 
 it be used just as I use it on Windows?

 The main difference is that it is much easier to install packages which are 
 part of the Ubuntu distribution: just run up the package manager, select 
 the ones to install and download and install happen automatically.
 

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


is mysqlsb compatible with MySQL 5.0?

2006-03-25 Thread John Salerno
My web server told me it isn't, which is why they are sticking with 
MySQL 4.0 for now, but I'm obsessed with using the latest versions, so I 
just want to be sure. According to the mysqldb download page at 
sourceforge, it is compatible with 5.0

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


Re: simple string search and replace

2006-03-25 Thread bearophileHUGS
Generally, to remove a substring (like ) from a string you can use
the replace method (that returns a new string):

 s = ...anon.wharton.com...
 s.replace(, )
'...anon.wharton.com...'

You can use it with something like:
print [s.replace(, ) for s in parsed_senders]

or you can put the replace() somewhere in the main loop.

Probably to solve your problem there are other solutions, like using a
RE to find email addresses inside the string...

Bye,
bearophile

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


Re: Why are so many built-in types inheritable?

2006-03-25 Thread Fabiano Sidler
Kent Johnson [EMAIL PROTECTED] wrote:
 You could do this with a simple decorator:
 http://wiki.python.org/moin/PythonDecoratorLibrary#head-d4ce77c6d6e75aad25baf982f6fec0ff4b3653f4

 or I think your class PrintingFunction would work as
 class PrintingFunction(object):
def __init__(self, func):
  self.func = func
def __call__(self, *args, **kwargs):
  print args, kwargs
  return self.func(*args, **kwargs)

The problem with this is that the func_code attribute would contain
the code of PrintingFunction instead of func. What I wanted to do, is
to keep the original behaviour, i.e. set the variable __metaclass__ to
DebugMeta and so get debug output, without changing a function and
getting the original function's code object by the func_code
attribute, not PrintigFunction's one. That's why I *must* inherit from
type 'function'.

Greetings,
F. Sidler
-- 
http://mail.python.org/mailman/listinfo/python-list


using regex to pull out email addresses

2006-03-25 Thread Kun
i have a regular expression that searches a string and plucks out email 
addresses however it doesn't work for email addresses w/a subdomain e.g. 
[EMAIL PROTECTED]


emails = re.findall('([EMAIL PROTECTED])', senderlist) -- my code


is there any way to modify that to include email addresses that also 
have subdomains?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: is mysqlsb compatible with MySQL 5.0?

2006-03-25 Thread Ravi Teja
Yes! It does.

Assuming that you are not terribly bandwidth constrained, isn't it
easier for you to try it
yourself on your own machine than wait for other people to assure you,
given that both are free and pretty much run on any platform?

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


noobie mkdir problem/question

2006-03-25 Thread ProvoWallis
Hi,

I'm trying to write a script that will create a new directory and then
write the results to this newly created directory but it doesn't seem
to work for me and I don't know why. I'm hoping someone can see my
mistake or at least point me in the right direction.

I start like this capturing the root directory and making my new
xrefs directory (I can see the new folder in windows explorer):

root = raw_input(Enter the path where the program should run: )

xrefs = os.path.join(root,'xrefs')

if (os.path.isdir(xrefs) == 0):
 os.mkdir(xrefs)
else:
 sys.exit('LOG folder already exists. Exiting program.')

...I do everything else...

And then I'm trying to write the results out to xrefs. But instead of
writing to xrefs they're written to the original directory, i.e., root.
and I'm not sure why.

outputFname = given + '.log'
outputFile = open(os.path.join(xrefs,outputFname), 'w')
outputFile.write(data)
outputFile.close()

Anyone?

Thanks,

Greg

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


Re: HIRING: PHP Developer

2006-03-25 Thread Jerry Stuckle
[EMAIL PROTECTED] wrote:
  From:  In Need - view profile
 Date:  Fri, Mar 24 2006 10:39 pm
 Email:   In Need [EMAIL PROTECTED]
 Groups:   hfx.forsale
 Not yet ratedRating:
 show options
 
 
 Reply | Reply to Author | Forward | Print | Individual Message | Show
 original | Report Abuse | Find messages by this author
 
 
 We are hiring a PHP developer!
 
 The site must contain the following:
 - database
 - administrator panel (implementing multiple employee logins /
 permissions)
 - credit card / paypal processing
 - affiliate program
 - news scripting control panel
 - image design
 - coupons / discounts,  gift certificates
 - customer log in / log out
 - specials page
 - contests
 - forum
 
 
 Would like to have:
 - flash design
 - various language support
 - pages that have pre-loaded data (click the link and no new page opens
 
 within the main frame.  Simply brings the information forward).
 
 
 The individual(s) that are selected for this project will have the
 opportunity to remain our company's web and image designer(s).  Please
 send
 a price quote for the above mentioned request, as well as a quote for a
 
 design similar to www.IGE.com to [EMAIL PROTECTED]
 
 
 Thank you.
 

I want to buy a car.  It must seat four people and be read.  Please send quote.

That's basically what you're asking for.  No way would I ever make a quote to 
do 
a project based on this information.  However, I can quote you an hourly rate 
for the design you can use to get a quote.


-- 
==
Remove the x from my email address
Jerry Stuckle
JDS Computer Training Corp.
[EMAIL PROTECTED]
==
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: (not really) randon ideas

2006-03-25 Thread Marc 'BlackJack' Rintsch
In [EMAIL PROTECTED], oluoluolu
wrote:

 I have been programming in Python for many years, and I generally have
 run into alot of the same problems repeatedly.
 
 What is the consensus on these ideas please?
 
 * enums

There's a cookbook recipe:

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/413486

And a package in the Chesseshop:

http://cheeseshop.python.org/pypi/enum/0.4.1

 * constants

People tend to write the names of constants all uppercase.  Example::

  ANSWER = 42

Ciao,
Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: is mysqlsb compatible with MySQL 5.0?

2006-03-25 Thread John Salerno
Ravi Teja wrote:
 Yes! It does.
 
 Assuming that you are not terribly bandwidth constrained, isn't it
 easier for you to try it
 yourself on your own machine than wait for other people to assure you,
 given that both are free and pretty much run on any platform?
 

Yeah, actually I went ahead and installed them both to try it out, but 
Norton Internet Security is causing huge problems with the MySQL setup. 
Even when I disable it, it won't let me get past the configuration steps. :(
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: using regex to pull out email addresses

2006-03-25 Thread Arne Ludwig
 senderlist=na nu [EMAIL PROTECTED] hu [EMAIL PROTECTED] [EMAIL PROTECTED] 
 fa hu
 print [ s[0] for s in re.findall((\w+@(\w+\.)+\w+),senderlist) ]
['[EMAIL PROTECTED]', '[EMAIL PROTECTED]']

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


Re: pondering about the essence of types in python

2006-03-25 Thread Steve Holden
gangesmaster wrote:
 let's start with a question:
 
 ==
 
class z(object):
 
 ... def __init__(self):
 ... self.blah=5
 ...
 
class x(object):
 
 ... def __init__(self):
 ... z.__init__(self)
 ...
 
y=x()
 
 Traceback (most recent call last):
   File stdin, line 1, in ?
   File stdin, line 3, in __init__
 TypeError: unbound method __init__() must be called with z instance as
 first argument (got x instance instead)
 ==
 
 and the question is -- WHY?
 
 what is a type? generally speaking, if everything were an object, the
 type only defines the MRO (method resolution order) for that object.
 x.y first looks at the instance, then the class, then the parent
 classes, etc. (this was changed a little in python2.3 to something more
 complicated, but it's basically the same).
 
 you can see the mro like this:
 ==
 
class x(object): pass
class y(x): pass
class z(y): pass
a=z()
print a.__class__.mro()
 
 [class '__main__.z', class '__main__.y', class '__main__.x',
 type 'object']
 ==
 
 after all, if we stay out of builtin types, all python objects are
 dicts, which support chian-lookup according to the mro. and a method is
 just a function that takes the instance as a first argument. so why is
 all this type hassle necessary?
 
 if we've taken it that far already, then let's really go over the edge.
 I WANT TO DERIVE FROM INSTANCES. not only types.
 
 why? i'm the developer of rpyc (http://rpyc.sf.net), and i got a
 request from someone to add support for deriving from remote types. the
 concrete example he gave was quite silly, but after i thought about it
 a little, i said why not try?
 
 a little intro about rpyc: it gives you proxies (instances) to remote
 objects, which can be instances, functions, or classes. and that user
 wanted to do something like this:
 
 class my_frame(conn.modules.wx.Frame):
 ...
 
 so the client was actually creates the graphics on the server. not very
 usable, but why not?  all it means is, when he does my_frame.xyz,
 python should add the remote type to the mro chain. not too bizar.
 
 but __mro__ is a readonly attribute, and deriving from instances is
 impossible (conn.modules.wx.Frame is a PROXY to the class)...
 
 and again -- WHY? these all look like INTENTIONAL limitations. someone
 went around and added type checks (which are NOT pythonic) into the
 cPython implementation. argh. why do that?
 
 so i thought -- let's be nasty. i created a function that creates a
 class that wraps an instance. very ugly. small children and peope with
 heart problems should close their eyes.
 
 
 def derive_from(obj):
 class cls(object):
 def __getattr(self, name):
 return getattr(obj, name)
 return cls
 
 class my_frame(derive_from(conn.modules.wx.Frame)):
 
 
 
 the actual implementation is quite more complex, but that shows the
 concept.
 so now i'm experimenting with that little shit. but then i came to the
 problem that methods check the type of the first argument... ARGH. dont
 check types. DONT. the whole point of duck-typing is you DONT CHECK THE
 TYPES. you just work with objects, and instead of TypeError you'd get
 AttribiuteError, which is much better.  AAARRGGGHH.
 
 python is EVIL at the low level. the high-level is just fine, but when
 you try to go under the hood... you better go with an exorcist.
 
Take a look at languages like Self. Self was actually the first 
prototype-based OO language. You could consider Javascript to be a 
prototype-based language as well.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd www.holdenweb.com
Love me, love my blog holdenweb.blogspot.com

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


Re: simple string search and replace

2006-03-25 Thread Steve Holden
Kun wrote:
 hey guys, here's my code,
 
 senders = [('460 (BODY[HEADER.FIELDS (FROM)] {46}', 'From: Friend 
 [EMAIL PROTECTED]\r\n\r\n'), ')', ('462 (BODY[HEADER.FIELDS 
 (FROM)] {37}', 'From: Kun [EMAIL PROTECTED]\r\n\r\n'), ')']
 print senders
 parsed_senders = []
 sender = 
 for item in senders:
 if isinstance(item,tuple):
item= ''.join(item)
 if item==')':
parsed_senders.append(sender[sender.find('')+1:].strip())
sender = 
 else:
sender+=item
 print parsed_senders
 
 
 
 
 wondering if anyone knows how i can remove the ''s from the list, which 
 outputs to something like ['[EMAIL PROTECTED]', '[EMAIL PROTECTED]']

Where you append to parsed_senders, replace

   sender[sender.find('')+1:]

with

   sender[sender.find('')+1:-1]

and that will use a string one shorter, omitting the  character.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd www.holdenweb.com
Love me, love my blog holdenweb.blogspot.com

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


sending emails to a list of recipients

2006-03-25 Thread Kun
i have the following code:

--
import smtplib

from email.MIMEText import MIMEText
fp = open('confirmation.txt', 'rb')
msg = MIMEText(fp.read())

 From = '[EMAIL PROTECTED]'

msg['Subject'] = 'Purchase Confirmation'
msg ['From'] = From
msg['To'] = emails

s = smtplib.SMTP('.xxx.xxx.edu')
s.login('x','')
s.sendmail(msg['From'], msg['To'], msg.as_string())
s.close()
--

it works if msg['To'] = '[EMAIL PROTECTED]'

however, i'm trying to attach a list of emails named 'emails' to msg['To']

emails is in the following format: ['[EMAIL PROTECTED]', '[EMAIL PROTECTED]', 
'[EMAIL PROTECTED]']


anyone have an idea how i can modify this script to work with sending a 
list? note this is a snippet of a larger code, 'emails' is as a string 
defined earlier.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: sending emails to a list of recipients [update]

2006-03-25 Thread Kun
Kun wrote:
 i have the following code:
 
 --
 import smtplib
 
 from email.MIMEText import MIMEText
 fp = open('confirmation.txt', 'rb')
 msg = MIMEText(fp.read())
 
  From = '[EMAIL PROTECTED]'
 
 msg['Subject'] = 'Purchase Confirmation'
 msg ['From'] = From
 msg['To'] = emails
 
 s = smtplib.SMTP('.xxx.xxx.edu')
 s.login('x','')
 s.sendmail(msg['From'], msg['To'], msg.as_string())
 s.close()
 --
 
 it works if msg['To'] = '[EMAIL PROTECTED]'
 
 however, i'm trying to attach a list of emails named 'emails' to msg['To']
 
 emails is in the following format: ['[EMAIL PROTECTED]', '[EMAIL PROTECTED]', 
 '[EMAIL PROTECTED]']
 
 
 anyone have an idea how i can modify this script to work with sending a 
 list? note this is a snippet of a larger code, 'emails' is as a string 
 defined earlier.

this is my error msg of leaving the code in its current state... (brave 
yourself)

Traceback (most recent call last):
   File /Tutorial/IMAP/scannermailer.py, line 41, in -toplevel-
 s.sendmail(msg['From'], msg['To'], msg.as_string())
   File 
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/email/Message.py,
 
line 129, in as_string
 g.flatten(self, unixfrom=unixfrom)
   File 
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/email/Generator.py,
 
line 82, in flatten
 self._write(msg)
   File 
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/email/Generator.py,
 
line 120, in _write
 self._write_headers(msg)
   File 
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/email/Generator.py,
 
line 166, in _write_headers
 header_name=h, continuation_ws='\t').encode()
   File 
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/email/Header.py,
 
line 395, in encode
 return self._encode_chunks(newchunks, maxlinelen)
   File 
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/email/Header.py,
 
line 355, in _encode_chunks
 _max_append(chunks, s, maxlinelen, extra)
   File 
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/email/quopriMIME.py,
 
line 79, in _max_append
 L.append(s.lstrip())
AttributeError: 'list' object has no attribute 'lstrip'
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: (not really) randon ideas

2006-03-25 Thread [EMAIL PROTECTED]
regarding the constants, this is more for the vm (and type safety).
actually enums, constants and symbols can prolly be implemented more or
less the same.

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


Re: __slots__

2006-03-25 Thread John J. Lee
[EMAIL PROTECTED] (Alex Martelli) writes:
[...]
 you should be using pychecker or pylint
[...]

I'm curious, as somebody who doesn't regularly use these tools: How do
they fit into your workflow?  Do you run them every few hours, every
day, every time you run functional tests, every release, every so
often, on gut feeling about when it's likely to catch problems...?

How do you cope with spurious warnings?  Does it involve tweaking code
to quell warnings?  Keeping suppression lists?  Maintaining special
invocations of pychecker / pylint per-project?  Do they cope well with
other people's code who do not use these tools?


John

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


Re: is mysqlsb compatible with MySQL 5.0?

2006-03-25 Thread Ravi Teja
Ah! An overzealous firewall! My sympathies :-). I am using the free
Kerio personal firewall on Windows.

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


Re: __slots__

2006-03-25 Thread Alex Martelli
John J. Lee [EMAIL PROTECTED] wrote:

 [EMAIL PROTECTED] (Alex Martelli) writes:
 [...]
  you should be using pychecker or pylint
 [...]
 
 I'm curious, as somebody who doesn't regularly use these tools: How do
 they fit into your workflow?  Do you run them every few hours, every
 day, every time you run functional tests, every release, every so
 often, on gut feeling about when it's likely to catch problems...?

I use them before mailing code off for review (which in our workflow is
mandatory before the code is submitted into the codebase) -- not quite
as often as unittests, which I run with just about every keystroke in my
editor;-). I'd rather have such a tool run automatically, as a presubmit
check, but that depends on convincing every colleague that it's worth it
(probably hopeless for pychecker as long as it needs to i


 How do you cope with spurious warnings?  Does it involve tweaking code
 to quell warnings?  Keeping suppression lists?  Maintaining special
 invocations of pychecker / pylint per-project?  Do they cope well with
 other people's code who do not use these tools?

If said other people's code, for example, does pointless (but
hopefully innocuous, otherwise unittests would have caught that;-)
things such as importing modules it never uses, the warning tools
complain. I do not consider such complaints spurious, and prefer to
fix those things (sending the brief codereview to the original author
with advice to start using the checking tools -- it usually works;-).

Very occasionally, there _are_ warnings which are indeed spurious: the
typical example is a function which, to comply with a certain API, MUST
take three arguments named exactly x, y, and z (no more, no less, not
with any different names) but only needs x; in such cases, you do need
to add, e.g.,
__pychecker__ = 'unusednames=y,z'
I pay the price gladly, since this will also serve to reassure human
readers that my code's anomalous behavior (accepting arguments y and z
but ignoring them) is by design, and not an accident or mistake.  I do
just about the same thing with the lint variant we use for C++, btw.


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


Re: noobie mkdir problem/question

2006-03-25 Thread [EMAIL PROTECTED]
if (os.path.isdir(xrefs) == 0):
 os.mkdir(xrefs)



os.path.isdir(stuff) returns 
True or False

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


Re: sending emails to a list of recipients

2006-03-25 Thread Gerard Flanagan
Kun wrote:

 i have the following code:

 --
 import smtplib

 from email.MIMEText import MIMEText
 fp = open('confirmation.txt', 'rb')
 msg = MIMEText(fp.read())

  From = '[EMAIL PROTECTED]'

 msg['Subject'] = 'Purchase Confirmation'
 msg ['From'] = From
 msg['To'] = emails

 s = smtplib.SMTP('.xxx.xxx.edu')
 s.login('x','')
 s.sendmail(msg['From'], msg['To'], msg.as_string())
 s.close()
 --

 it works if msg['To'] = '[EMAIL PROTECTED]'

 however, i'm trying to attach a list of emails named 'emails' to msg['To']

 emails is in the following format: ['[EMAIL PROTECTED]', '[EMAIL PROTECTED]',
 '[EMAIL PROTECTED]']


 anyone have an idea how i can modify this script to work with sending a
 list? note this is a snippet of a larger code, 'emails' is as a string
 defined earlier.


maybe try :  msg['To'] = ', '.join( emails )

taken from:

http://docs.python.org/lib/node597.html

Gerard

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


Re: pondering about the essence of types in python

2006-03-25 Thread gangesmaster
i was taking about python...

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


Re: Accessing func_name from inside a function

2006-03-25 Thread Ben Finney
James Thiele [EMAIL PROTECTED] writes:

 I'd like to access the name of a function from inside the function.

A function, like most other objects in Python, can have any number of
names bound to it without the object being informed. Any of those
names can then be used to reference the object, and the object has no
way of knowing by what name it was referenced.

Because of this fallacy, it's generally considered bad programming
style to want to know the name of the current object from inside
that object.

What is it you're trying to achieve?

-- 
 \ Unix is an operating system, OS/2 is half an operating system, |
  `\   Windows is a shell, and DOS is a boot partition virus.  -- |
_o__)  Peter H. Coffin |
Ben Finney

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


Re: __slots__

2006-03-25 Thread Ben Caradoc-Davies
John J. Lee wrote:
 [EMAIL PROTECTED] (Alex Martelli) writes:
you should be using pychecker or pylint
 
 I'm curious, as somebody who doesn't regularly use these tools: How do
 they fit into your workflow?  Do you run them every few hours, every
 day, every time you run functional tests, every release, every so
 often, on gut feeling about when it's likely to catch problems...?

I use pychecker when I have finished a chunk of work that is supposed to 
be syntactically correct, but before I try any unit testing. Think of it 
as an optional step that takes the place of running the compiler in 
statically-typed language development. I use pytchecker again before I 
release anything, just to be sure.

 How do you cope with spurious warnings?  Does it involve tweaking code
 to quell warnings?  Keeping suppression lists?

Suppression lists work for me.

 From http://pychecker.sourceforge.net/

*** begin quote ***

You can also define suppressions in your code by doing:

 __pychecker__ = 'no-namedargs maxreturns=0 unusednames=foo,bar'

*** end quote ***

 Do they cope well with other people's code who do not use these tools?

pychecker complains a lot when used on code that is poorly written and 
includes bad practices such as using builtin function names as local 
variable names. I consider pychecker's complaints in these cases to be a 
*feature*.

-- 
Ben Caradoc-Davies [EMAIL PROTECTED]
http://wintersun.org/
Those who deny freedom to others deserve it not for themselves.
- Abraham Lincoln
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: noobie mkdir problem/question

2006-03-25 Thread ProvoWallis
I understand that but I'm still puzzled. Is this the reason why I can't
write files to this directory?

The xrefs directory is created the way I expect it would be using mkdir
but I can't seem to write to it. I thought that my results would be
written to the xrefs directory here but they're ending up in the
original folder not the subfolder.

  outputFile = open(os.path.join(xrefs,outputFname), 'w')
  outputFile.write(data)
  outputFile.close()

What am I missing?

[EMAIL PROTECTED] wrote:
 if (os.path.isdir(xrefs) == 0):
  os.mkdir(xrefs)

 
 
 os.path.isdir(stuff) returns 
 True or False

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


Re: Beginner's question: executing scripts under Win XP pro

2006-03-25 Thread J Correia

Scott Souva [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Your script may be working properly, but XP simply removes the window
 after the script runs.  Here is a simple fix that will stop at the end
 of the script and leave the Command window open:

 print Hello World
 raw_input()

That'll work (it waits for input from the user, and, as soon as it
receives it shuts down the window).

Another way to do it is instead of doubleclicking on the script,
open a command prompt window (StartRuncmd OR
StartProgramsAccessoriesCommand Prompt) then type
'python test.py' at the prompt.  Now the window stays open
until you specifically close it and you can rerun the script many times.

HTH,

JC 


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


Re: years later DeprecationWarning

2006-03-25 Thread Steven D'Aprano
On Wed, 22 Mar 2006 13:59:00 -0800, Chris Lasher wrote:

 Two things:
 1) math.floor returns a float, not an int. Doing an int() conversion on
 a float already floors the value, anyways.

No it doesn't, or rather, int() is only equivalent to floor() if you limit
the input to non-negative numbers:

int(-2.2) = -2, but floor(-2.2) should give -3.

The standard definition of floor() and ceil() are:

floor(x) = maximum integer n such that n = x
ceil(x) = minimum integer n such that n = x

or as Python functions:

def floor(x):
Returns the maximum integer less than or equal to x
if x = 0:
return int(x)
else:
if x % 1: return int(x)-1
else: return int(x)

def ceil(x):
Returns the minimum integer greater than or equal to x
return -floor(-x)

or even simpler:

from math import floor, ceil

(Caution: the functions defined in the math module return the floor and
ceiling as floats, not int, so you may want to wrap them in a call to int.)



-- 
Steven.

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


Re: Why are so many built-in types inheritable?

2006-03-25 Thread Fabiano Sidler
25 Mar 2006 13:58:17 -0800, Ziga Seilnacht [EMAIL PROTECTED]:
 No, you don't have to:

Okay, but I'd prefer! ;)

 [a lot of python code]

That's what I wanted to avoid. Additionally, the possibility to do it
this way doesn't make it reasonable that type 'function' is
inheritable. Are there any reasons for that?

Greetings,
F.Sidler
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: sending emails to a list of recipients [update]

2006-03-25 Thread Larry Bates
smtplib docs http://python.active-venture.com/lib/SMTP-example.html
say that the to should be a list of addresses (your emails);

s.sendmail(msg['From'], emails, msg.as_string())

-Larry Bates


Kun wrote:
 Kun wrote:
 i have the following code:

 --
 import smtplib

 from email.MIMEText import MIMEText
 fp = open('confirmation.txt', 'rb')
 msg = MIMEText(fp.read())

  From = '[EMAIL PROTECTED]'

 msg['Subject'] = 'Purchase Confirmation'
 msg ['From'] = From
 msg['To'] = emails

 s = smtplib.SMTP('.xxx.xxx.edu')
 s.login('x','')
 s.sendmail(msg['From'], msg['To'], msg.as_string())
 s.close()
 --

 it works if msg['To'] = '[EMAIL PROTECTED]'

 however, i'm trying to attach a list of emails named 'emails' to
 msg['To']

 emails is in the following format: ['[EMAIL PROTECTED]',
 '[EMAIL PROTECTED]', '[EMAIL PROTECTED]']


 anyone have an idea how i can modify this script to work with sending
 a list? note this is a snippet of a larger code, 'emails' is as a
 string defined earlier.
 
 this is my error msg of leaving the code in its current state... (brave
 yourself)
 
 Traceback (most recent call last):
   File /Tutorial/IMAP/scannermailer.py, line 41, in -toplevel-
 s.sendmail(msg['From'], msg['To'], msg.as_string())
   File
 /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/email/Message.py,
 line 129, in as_string
 g.flatten(self, unixfrom=unixfrom)
   File
 /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/email/Generator.py,
 line 82, in flatten
 self._write(msg)
   File
 /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/email/Generator.py,
 line 120, in _write
 self._write_headers(msg)
   File
 /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/email/Generator.py,
 line 166, in _write_headers
 header_name=h, continuation_ws='\t').encode()
   File
 /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/email/Header.py,
 line 395, in encode
 return self._encode_chunks(newchunks, maxlinelen)
   File
 /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/email/Header.py,
 line 355, in _encode_chunks
 _max_append(chunks, s, maxlinelen, extra)
   File
 /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/email/quopriMIME.py,
 line 79, in _max_append
 L.append(s.lstrip())
 AttributeError: 'list' object has no attribute 'lstrip'
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: noobie mkdir problem/question

2006-03-25 Thread [EMAIL PROTECTED]
First, what version of python are you using? 2.4.2 (and some previous
versions) use file() instead of open(), although open may still work.

also, if your code in the previous post is still using:

outputFname = given + '.log'
outputFile = open(os.path.join(xrefs,outputFname), 'w')
I hope you have 'given' defined somewhere, since it's not in the code
you show.

give this a try:

output = file(xrefs + r'\filenamewhatever', 'w')
output.write(data)
output.close()

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


  1   2   >