python noob help

2008-10-06 Thread toyko

So yeah, I have this assignment for my computer science class,
http://pages.cpsc.ucalgary.ca/~boyd/231/as1.pdf so far this is what I have
wrote, any suggestions cause I am stuck!


xc, yc = input()
r = input()
x1, y1 = input()
x2, y2 = input()

a = (x2 - x1)**2 + (y2 - y1)**2
b = 2((x1 - xc)(x2 - x1) + (y1 - yc)(y2 - y1))
c = (x1 - xc)**2 + (y1 - yc)**2 - r**2

discrim = (b * b - 4 * a * c) ** 0.5
Q = (-b + discrim) / (2 * a)
Q = (-b - discrim) / (2 * a)

x = (1-Q) * x1 + Qx2
y = (1-Q) * y1 + Qx2

# CIRCLE
print "circle", xc, yc, r

# LINE
print "line", x1, y1, x2, y2

-- 
View this message in context: 
http://www.nabble.com/python-noob-help-tp19832962p19832962.html
Sent from the Python - python-list mailing list archive at Nabble.com.

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


Re: Pr. Euler 18, recursion problem

2008-10-06 Thread process
On Oct 6, 8:13 am, Aidan <[EMAIL PROTECTED]> wrote:
> process wrote:
> > I am trying to solve project euler problem 18 with brute force(I will
> > move on to a better solution after I have done that for problem 67).
> >http://projecteuler.net/index.php?section=problems&id=18
>
> > However I can't get the recursive function right.
>
> > I always have to use return right? Unless I am printing? So I canät
> > stack to diffferent recursive calls after each other like so:
> > recur_left(t, p)
> > recur_right(t,p+1)
>
> > Some stuff I have tried:
>
> > def recur(tree, pos):
> >     if not tree:
> >         return []
> >     else:
> >         return [[tree[0][pos]] + recur(tree[1:], pos)] + \
> >                [[tree[0][pos]] + recur(tree[1:], pos+1)]
>
>  recur([[1],[2,3],[4,5,6]],0)
> > [[1, [2, [4], [4]], [2, [5], [5]]], [1, [3, [5], [5]], [3, [6], [6
>
> > SO it is kind of working, just not exactly like I want.
> > A more easily parseable/readable result would be nice, I want to be
> > able to sum() over each path preferrably.
>
> > So the result should be:
> > [[1,2,4],[1,2,5],[1,3,5],[1,3,6]]
>
> > I know conceptually what has to be done.
> > Base case: empty tree, return []
> > Else: recur to the left and to the right.
>
> This is just my opinion, but I felt the non-brute force solution to this
> problem was actually simpler than trying to define a brute force
> recursive solution I tried to implement a brute force algorithm at
> first, until I had an epiphany with regard to how simple the problem
> actually was.  Then I faced palmed.



But let's say you have [[1],[1,10],[1,2,300],[10,1,1,1]].

you must check all solutions right? there is no pattern. if you start
from the bottom and eliminate paths that seem to be losing can you
regain that later up in the pyramid if it turns out one side gets bigg
again?
--
http://mail.python.org/mailman/listinfo/python-list


Re: Pr. Euler 18, recursion problem

2008-10-06 Thread Aidan

process wrote:

On Oct 6, 8:13 am, Aidan <[EMAIL PROTECTED]> wrote:

process wrote:

I am trying to solve project euler problem 18 with brute force(I will
move on to a better solution after I have done that for problem 67).
http://projecteuler.net/index.php?section=problems&id=18
However I can't get the recursive function right.
I always have to use return right? Unless I am printing? So I canät
stack to diffferent recursive calls after each other like so:
recur_left(t, p)
recur_right(t,p+1)
Some stuff I have tried:
def recur(tree, pos):
if not tree:
return []
else:
return [[tree[0][pos]] + recur(tree[1:], pos)] + \
   [[tree[0][pos]] + recur(tree[1:], pos+1)]

recur([[1],[2,3],[4,5,6]],0)

[[1, [2, [4], [4]], [2, [5], [5]]], [1, [3, [5], [5]], [3, [6], [6
SO it is kind of working, just not exactly like I want.
A more easily parseable/readable result would be nice, I want to be
able to sum() over each path preferrably.
So the result should be:
[[1,2,4],[1,2,5],[1,3,5],[1,3,6]]
I know conceptually what has to be done.
Base case: empty tree, return []
Else: recur to the left and to the right.

This is just my opinion, but I felt the non-brute force solution to this
problem was actually simpler than trying to define a brute force
recursive solution I tried to implement a brute force algorithm at
first, until I had an epiphany with regard to how simple the problem
actually was.  Then I faced palmed.




But let's say you have [[1],[1,10],[1,2,300],[10,1,1,1]].

you must check all solutions right? there is no pattern. if you start
from the bottom and eliminate paths that seem to be losing can you
regain that later up in the pyramid if it turns out one side gets bigg
again?


It's difficult to say much here without giving the answer away... but, 
yes, you need to check all solutions - it's just that there's a very 
easy way to do that without having to recurse from the top of the tree 
to the bottom.


Hope that gives you a clue while not fully revealing the answer.
--
http://mail.python.org/mailman/listinfo/python-list


Re: python noob help

2008-10-06 Thread Marc 'BlackJack' Rintsch
On Mon, 06 Oct 2008 00:08:58 -0700, toyko wrote:

> So yeah, I have this assignment for my computer science class,
> http://pages.cpsc.ucalgary.ca/~boyd/231/as1.pdf so far this is what I
> have wrote, any suggestions cause I am stuck!

Learn Python and actually *think* about the problem and a solution.  We 
are not going to do your homework for you.  You have to show a little 
effort.  So far you have just tried to copy the formulas from the 
assignment to Python code -- and failed because there are runtime 
errors.  So you didn't even bother to test what you have so far before 
crying for help.

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


Re: sftp problem!

2008-10-06 Thread sa6113

Dear Mike,
Thanks for your help, but I am new in paramiko,would you please help me
more?

May I connect to server by password insted of private key? How?
I used this code:
...
t.auth_password(username, password, event)
...
but I received this error :
paramiko.SSHException : No existing session 

I think my problem is in authentication, Do you think I have to use pycrypto
module or something like that??

If not would you please tell me how should I precreate the key and ensure
the server
side has it in its authorized_keys? How do I share that as I mentioned it
before I am using two different platforms?

Thanks.



Mike Hjorleifsson wrote:
> 
> here is a snippet that works, you need to replace the default data or
> create a database etc.. and the fields to store it
> you also need to generate and share your public key to the receiving
> server to avoid password prompt
> 
> 
> # Standard library imports
> import os
> import sys
> import time
> import traceback
> import paramiko
> 
> 
> # my defaultdata is stored in a sqllite table called merchant.lib
> # you can just assign values to defaultdata or recreate a database of
> your own
> from merchant.lib import defaultdata
> 
> 
> # set up default values
> hostname = defaultdata.defaults['hostname']
> username = defaultdata.defaults['username']
> password = defaultdata.defaults['password']
> 
> # paramiko required data
> port = defaultdata.defaults['port']
> fname = defaultdata.defaults['fname']
> pathupload = defaultdata.defaults['pathupload']
> pathdownload = defaultdata.defaults['pathdownload']
> input_dir = defaultdata.defaults['input_dir']
> output_dir = defaultdata.defaults['output_dir']
> curdir = os.path.abspath(os.curdir)
> 
> # load ssh pkey  you need to precreate the key and ensure the server
> side
> # has it in its authorized_keys
> pkey_path = os.path.expanduser('~/.ssh/id_dsa')
> pkey = paramiko.DSSKey.from_private_key_file(pkey_path)
> 
> paramiko.util.log_to_file('transfer.log')
> logger = paramiko.util.get_logger('paramiko')
> 
> try:
> # set up connection
> t = paramiko.Transport((hostname, port))
> t.connect(username=username, pkey=pkey)
> sftp = paramiko.SFTPClient.from_transport(t)
> 
> # upload files
> files = [file for file in os.listdir(output_dir)
> if file.endswith('.txt')]
> logger.info("UPLOAD FILES %s" % files)
> os.chdir(output_dir)
> for file in files:
> sftp.put(file, os.path.join(pathupload, file))
> os.rename(file, file + '.old')
> 
> # download files
> response_files = [file for file in sftp.listdir(pathdownload)
> if file.startswith('DISCOVER_RESPONSE_')]
> 
> logger.info("RESPOSE FILES: %s" % response_files)
> os.chdir(os.path.join(curdir, input_dir))
> for file in response_files:
> file_path = os.path.join(pathdownload, file)
> sftp.get(file_path, file)
> sftp.remove(file_path)
> 
> 
>   # close connection
> t.close()
> --
> http://mail.python.org/mailman/listinfo/python-list
> 
> 

-- 
View this message in context: 
http://www.nabble.com/sftp-problem%21-tp19821106p19833497.html
Sent from the Python - python-list mailing list archive at Nabble.com.

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


Using python Serial module on windows

2008-10-06 Thread Holger
Hi

I'm using python Serial from:
http://switch.dl.sourceforge.net/sourceforge/pyserial/pyserial-2.4.tar.gz

to implement ymodem and other protocols on the PC com port

And it works like a charm in cygwin, but when I try to use it directly
in python under windows using active state python installation, it
says it's missing the module win32file.
But the win32file module looks like it is no longer in development and
support stopped at python 2.2

Am I going about this issue the wrong way?
Can anyone suggest a way out of this fix?

Thank You
Holger
--
http://mail.python.org/mailman/listinfo/python-list


Builing Python 2.6 on AIX 5.2

2008-10-06 Thread brasse
Hello!

I am having some trouble building Python 2.6 on AIX. The steps I have
taken are:

export PATH=/usr/bin/:/usr/vacpp/bin/
./configure --with-gcc=xlc_r --with-cxx=xlC_r --disable-ipv6
make

This is the error message I'm seeing:
./Modules/ld_so_aix xlc_r -bI:Modules/python.exp build/
temp.aix-5.2-2.6/home/mabr/Python-2.6/Modules/_multiprocessing/
multiprocessing.o build/temp.aix-5.2-2.6/home/mabr/Python-2.6/Modules/
_multiprocessing/socket_connection.o build/temp.aix-5.2-2.6/home/mabr/
Python-2.6/Modules/_multiprocessing/semaphore.o -L/usr/local/lib -o
build/lib.aix-5.2-2.6/_multiprocessing.so
ld: 0711-317 ERROR: Undefined symbol: .sem_timedwait
ld: 0711-317 ERROR: Undefined symbol: .CMSG_SPACE
ld: 0711-317 ERROR: Undefined symbol: .CMSG_LEN
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more
information.
*** WARNING: renaming "_multiprocessing" since importing it failed: No
such file or directory
error: No such file or directory
make: The error code from the last command is 1.

Have someone on this list had similar problems? Am I missing some
libraries? The configure script runs without errors, I would have
expected some kind of error there if I was missing something.

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


Re: how to get the thighest bit position in big integers?

2008-10-06 Thread Duncan Booth
"Aaron \"Castironpi\" Brady" <[EMAIL PROTECTED]> wrote:

> On Oct 5, 2:12 pm, "Aaron \"Castironpi\" Brady" <[EMAIL PROTECTED]>
> wrote:
>> Duncan Booth wrote:
>> > [EMAIL PROTECTED] wrote:
>>
>> > OFFSET = dict(("%x"%i, int(c)) for i,c in
>> > enumerate("5433")) def get_highest_bit_num(r):
>> >s = "%x"%r
>> >return len(s) * 4 - OFFSET[s[0]]
>>
>> OFFSET= tuple( int(x) for x in "5433" )
>> def get_highest_bit_num(r):
>>  s = "%x"%r
>>  return len(s) * 4 - OFFSET[int(s[0],16)]
> 
> That's really counterintuitive.  (That's the word, yes.)  They're both
> function calls and both global variables.  Maybe you could use 'len(s)
> * 4' to mask out the rest and lookup that index, rather than
> converting -back- to integer.  Or, better yet, take 'ord' of s[0].
> (Ha ha, -you- time it.)

No, the difference between the two is still an extra call to a global 
function.

'ord' may be slightly faster than calling 'int' (function calls with two 
arguments are slower than similar functions with only one), but you have 
still added one extra variable lookup and function call over the original.

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


Re: Python 2.6 / 3.0: Determining if a method is inherited

2008-10-06 Thread Fuzzyman
On Oct 6, 1:13 am, MRAB <[EMAIL PROTECTED]> wrote:
> Fuzzyman wrote:
> > Hello all,
>
> > I may well be being dumb (it has happened before), but I'm struggling
> > to fix some code breakage with Python 2.6.
>
> > I have some code that looks for the '__lt__' method on a class:
>
> > if hasattr(clr, '__lt__'):
>
> > However - in Python 2.6 object has grown a default implementation of
> > '__lt__', so this test always returns True.
>
> > >>> class X(object): pass
> > ...
> > >>> X.__lt__
> > 
> > >>> X.__lt__ == object.__lt__
> > False
>
> > So how do I tell if the X.__lt__ is inherited from object? I can look
> > in the '__dict__' of the class - but that doesn't tell me if X
> > inherits '__lt__' from a base class other than object. (Looking inside
> > the method wrapper repr with a regex is not an acceptable answer...)
>
> > Some things I have tried:
>
> > >>> X.__lt__.__self__
> > 
> > >>> dir(X.__lt__)
> > ['__call__', '__class__', '__cmp__', '__delattr__', '__doc__',
> > '__format__', '__getattribute__', '__hash__', '__init__', '__name__',
> > '__new__', '__objclass__', '__reduce__', '__reduce_ex__', '__repr__',
> > '__self__', '__setattr__', '__sizeof__', '__str__',
> > '__subclasshook__']
> > >>> X.__lt__.__func__
> > Traceback (most recent call last):
> >   File "", line 1, in 
> > AttributeError: 'method-wrapper' object has no attribute '__func__'
>
> > Hmmm... I can get this working with Python 2.6 with:
>
> > if '__lt__' in dir(cls):
>
> > The default implementation of '__lt__' doesn't appear in the dir of
> > classes. However this fails with Python 3 where the default
> > implementation *does* appear in the output of 'dir'. Any suggestions?
>
> Methods are objects. How do you know if two references refer to the
> same object? You use "is":
>
> X.__lt__ is object.__lt__

Didn't you see that even an equality test fails - so they are not the
same (that being the problem)...

They are unbound method objects - in Python 3 the unbound method has
gone away, so the problem is with Python 2.6.

Michael
--
http://www.ironpythoninaction.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Using python Serial module on windows

2008-10-06 Thread Diez B. Roggisch
Holger wrote:

> Hi
> 
> I'm using python Serial from:
> http://switch.dl.sourceforge.net/sourceforge/pyserial/pyserial-2.4.tar.gz
> 
> to implement ymodem and other protocols on the PC com port
> 
> And it works like a charm in cygwin, but when I try to use it directly
> in python under windows using active state python installation, it
> says it's missing the module win32file.
> But the win32file module looks like it is no longer in development and
> support stopped at python 2.2
> 
> Am I going about this issue the wrong way?
> Can anyone suggest a way out of this fix?

http://pyserial.wiki.sourceforge.net/pySerial

"""
Requirements

Python 2.2 or newer

pywin32 extensions on Windows

"Java Communications" (JavaComm) or compatible extension for Java/Jython
"""

Do you have pywin32? If not, you might consider installing active state
python, which comes included with them.

Diez

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


Re: how to get the thighest bit position in big integers?

2008-10-06 Thread Holger
On 6 Okt., 10:37, Mark Dickinson <[EMAIL PROTECTED]> wrote:
> See alsohttp://bugs.python.org/issue3439
> where there's a proposal to expose the _PyLong_NumBits method.  This
> would give an O(1) solution.
Doesn't that depend on the underlying implementation?

Anyway, here's a pretty one (I think):
def highest_bit(n, maxbits = 256):
bit = 0
while maxbits > 1:
maxbits = maxbits >> 1
mask_b = ((1<> maxbits
else:
n = b
return bit

I suspect you would call that a O(logn)) solution

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


Re: how to get the thighest bit position in big integers?

2008-10-06 Thread Mark Dickinson
On Oct 5, 11:40 pm, Terry Reedy <[EMAIL PROTECTED]> wrote:
> Your point, that taking floor(log2(x)) is redundant, is a good catch.
> However, you should have added 'untested' ;-).  When value has more
> significant bits than the fp mantissa can hold, this expression can be 1
> off (but no more, I assume).   The following correction should be
> sufficient:
>
> res = math.frexp(value)[1] - EXP_OF_ONE
> test = 1< if test > r:     res -= 1
> elif 2*test < r: res += 1
>
> For value = 2**n -1, n > 53, it is always 1 too high on my Intel
> machine, so the first correction is sometimes needed.  I do not know if
> the second is or not.

See also http://bugs.python.org/issue3439
where there's a proposal to expose the _PyLong_NumBits method.  This
would give an O(1) solution.

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


Re: Python 2.6, GUI not working on vista?

2008-10-06 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Thorsten Kampe
wrote:

> * Lawrence D'Oliveiro (Sun, 05 Oct 2008 22:13:46 +1300)
>
>> In message <[EMAIL PROTECTED]>, Michel Claveau -
>> NoSpam SVP ; merci wrote:
>> 
>> > Another way is to de-activate UAC.
>> 
>> Please don't be stupid!
> 
> He's not stupid. Disabling UAC is the recommended way to get rid of
> these problems.

Disabling UAC is NOT recommended.
--
http://mail.python.org/mailman/listinfo/python-list


Cookielib in Jython

2008-10-06 Thread Felipe De Bene
Hi There,
I'm trying to run an App I wrote in Python 2.5.2 in Jython 2.2.1 and
everything works fine except when I try to import the Standard
CPython's cookielib. I know this may sound stupid, I could use an
advice here on what's wrong. Thanks in advance,
Felipe.

Output:
Jython 2.2.1 on java1.6.0_07
Type "copyright", "credits" or "license" for more information.
>>> import cookielib
Traceback (innermost last):
  File "", line 1, in ?
ImportError: no module named cookielib
>>> from cookielib import *
Traceback (innermost last):
  File "", line 1, in ?
ImportError: no module named cookielib
>>> from CookieLib import *
Traceback (innermost last):
  File "", line 1, in ?
ImportError: no module named CookieLib
--
http://mail.python.org/mailman/listinfo/python-list


Re: how to get the thighest bit position in big integers?

2008-10-06 Thread bearophileHUGS
Mark Dickinson:
> See alsohttp://bugs.python.org/issue3439
> where there's a proposal to expose the _PyLong_NumBits method.  This
> would give an O(1) solution.

Sounds useful, I've used the gmpy.numdigits(x [,base]) few times.

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


What AugStore and AugLoad AST nodes are?

2008-10-06 Thread franck
Dear all,

I'm experimenting with new ast module.
I'd like to have pieces of code that can generate AugLoad and AugStore
AST nodes.
Indeed, I actually do not know what they correspond to.

Thanks for any help!
Franck
--
http://mail.python.org/mailman/listinfo/python-list


Re: In Python 2.6, bytes is str

2008-10-06 Thread Benjamin Kaplan
On Mon, Oct 6, 2008 at 1:30 AM, Bryan Olson <[EMAIL PROTECTED]> wrote:

>
>
> In Python 2.6, the name 'bytes' is defined, and bound to str. The 2.6
> assignment presents some pitfalls. Be aware.
>
> Consider constructing a bytes object as:
>
>b = bytes([68, 255, 0])
>
> In Python 3.x, len(b) will be 3, which feels right.
>
> In Python 2.6, len(b) will be  12, because b is the str, '[68, 255, 0]'.
>
>
> I'm thinking I should just avoid using 'bytes' in Python 2.6. If there's
>  another Python release between 2.6 and 3.gold, I'd advocate removing the
> pre-defined 'bytes', or maybe defining it as something else.


You could just use a bytearray instead of a normal list.

Python 2.6 (trunk:66714:66715M, Oct  1 2008, 18:36:04)
[GCC 4.0.1 (Apple Computer, Inc. build 5370)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> a = bytearray([65,66,67])
>>> a
bytearray(b'ABC')
>>> a[1] = 70
>>> a
bytearray(b'AFC')
>>> bytes(a)
'AFC'
--
http://mail.python.org/mailman/listinfo/python-list


Python-URL! - weekly Python news and links (Oct 6)

2008-10-06 Thread Gabriel Genellina
QOTW:  ".. as the problem grows in complexity, C++ accumulates too much of
its own bloat." -  sturlamolden, on Python as a *faster* language than C++


Python 2.6 final has been released:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/b440f6bd2a54b6a/

Why the `del` statement canNOT be used with sets (for example, in
`del a_set[element]`):

http://groups.google.com/group/comp.lang.python/browse_thread/thread/d66b7c96660b0be7/

An attempt to translate Javascript code into Python shows the
similarities and differences between the two languages:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/72ab3a4a868d15df/

Tarek Ziadé's *Expert Python Programming* is out.
http://www.packtpub.com/expert-python-programming/book

Preliminary tests combining a Python-to-Javascript compiler with
Chrome's V8 JS engine show better performance than CPython (!):

http://groups.google.com/group/comp.lang.python/browse_thread/thread/ff862fc968de50d3/

How a form of "partial inheritance" could be implemented:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/b5e297de48fa1fec/

How to "peek" inside a generic iterator (look at the next item without
consuming it)

http://groups.google.com/group/comp.lang.python/browse_thread/thread/572ad24a93077556/

How to determine whether a method is actually defined in a class or
simply inherited from (the base) object (Python 2.6/3.0):

http://groups.google.com/group/comp.lang.python/search?q=3DPython+2.6+3.0+Determining+method+inherited

Tuple parameter unpacking is gone in 3.0, and some regret it:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/24b0c30ee8b7bab6/

Sometimes what looks like "good Python code" (as seen by experienced
coders) isn't very beginners-friendly:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/f4163871f3fb7585/

Automatically decorate all methods defined in a class:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/c76eea5f716d7bda/



Everything Python-related you want is probably one or two clicks away in
these pages:

Python.org's Python Language Website is the traditional
center of Pythonia
http://www.python.org
Notice especially the master FAQ
http://www.python.org/doc/FAQ.html

PythonWare complements the digest you're reading with the
marvelous daily python url
 http://www.pythonware.com/daily

Just beginning with Python?  This page is a great place to start:
http://wiki.python.org/moin/BeginnersGuide/Programmers

The Python Papers aims to publish "the efforts of Python enthusiats":
http://pythonpapers.org/
The Python Magazine is a technical monthly devoted to Python:
http://pythonmagazine.com

Readers have recommended the "Planet" sites:
http://planetpython.org
http://planet.python.org

comp.lang.python.announce announces new Python software.  Be
sure to scan this newsgroup weekly.
http://groups.google.com/group/comp.lang.python.announce/topics

Python411 indexes "podcasts ... to help people learn Python ..."
Updates appear more-than-weekly:
http://www.awaretek.com/python/index.html

The Python Package Index catalogues packages.
http://www.python.org/pypi/

The somewhat older Vaults of Parnassus ambitiously collects references
to all sorts of Python resources.
http://www.vex.net/~x/parnassus/

Much of Python's real work takes place on Special-Interest Group
mailing lists
http://www.python.org/sigs/

Python Success Stories--from air-traffic control to on-line
match-making--can inspire you or decision-makers to whom you're
subject with a vision of what the language makes practical.
http://www.pythonology.com/success

The Python Software Foundation (PSF) has replaced the Python
Consortium as an independent nexus of activity.  It has official
responsibility for Python's development and maintenance.
http://www.python.org/psf/
Among the ways you can support PSF is with a donation.
http://www.python.org/psf/donations/

The Summary of Python Tracker Issues is an automatically generated
report summarizing new bugs, closed ones, and patch submissions. 

http://search.gmane.org/?author=status%40bugs.python.org&group=gmane.comp.python.devel&sort=date

Although unmaintained since 2002, the Cetus collection of Python
hyperlinks retains a few gems.
http://www.cetus-links.org/oo_python.html

Python FAQTS
http://python.faqts.com/

The Cookbook is a collaborative effort to capture useful and
interesting recipes

Re: python noob help

2008-10-06 Thread piloneur
On 6 oct, 09:36, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
> On Mon, 06 Oct 2008 00:08:58 -0700, toyko wrote:
> > So yeah, I have this assignment for my computer science class,
> >http://pages.cpsc.ucalgary.ca/~boyd/231/as1.pdfso far this is what I
> > have wrote, any suggestions cause I am stuck!
>
> Learn Python and actually *think* about the problem and a solution.  We
> are not going to do your homework for you.  You have to show a little
> effort.  So far you have just tried to copy the formulas from the
> assignment to Python code -- and failed because there are runtime
> errors.  So you didn't even bother to test what you have so far before
> crying for help.
>
> Ciao,
>         Marc 'BlackJack' Rintsch


small hint :
"(5)(2)" don't work, use "5*2"
same for "Qx2", use "Q*2"
--
http://mail.python.org/mailman/listinfo/python-list


Re: When Python should not be used?

2008-10-06 Thread jdd
On Oct 5, 8:08 pm, Andrea Francia <[EMAIL PROTECTED]
HERE.ohoihihoihoih.TO-HERE.gmx.it> wrote:
> The right tool depends on the current problem.
>
> While some python users prefer to talk about when Python is the right
> tool I think that it is more instructive to know when it is not.
>
> Please, could you let me know what do you think about that?
>
> Thanks
> --
> Andrea 
> Franciahttp://andreafrancia.blogspot.com/2008/07/colinux-linux-dentro-window...

In my experience, Python is not suitable for extremely resource-
intensive stuff where speed is a large priority, unless you're
comfortable with the C api. The vast majority of applications that
people are writing are nowhere near pythons limitations.
--
http://mail.python.org/mailman/listinfo/python-list


Re: I built a nice html templater!

2008-10-06 Thread Steve Holden
Tim Roberts wrote:
> Derick van Niekerk <[EMAIL PROTECTED]> wrote:
>> Ok - so it's not really an awesome achievement and only handles basic
>> templating needs (no loops and other programming constructs) but maybe
>> someone will find it useful.
> 
> 
> Sure, that's what the world needed.  We didn't have enough Python HTML
> templaters already.
> 
> 
> Did you take even 3 minutes to look for a solution before you wrote this?
> There is even a nearly identical solution in the Python cookbook.

While I agree it was a little naive to expect a huge amount of interest
I think there's educational value in building a templating system of
your own. Sarcasm id the lowest form of wit, and there's no real need
for it here. You'd have been better saving your ire for someone who
really deserves it. Sadly there are plenty around.

regards
 Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.com/

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


Re: If an OS was to be written in Python, how'w it look?

2008-10-06 Thread bieffe62
On 6 Ott, 06:16, process <[EMAIL PROTECTED]> wrote:
> If an OS was to be written in Python and the hardware optimized for
> it, what changes would be made to the hardware to accomodate Python
> strenghs and weaknesses?
>
> Some tagged architecture like in Lisp 
> machines?http://en.wikipedia.org/wiki/Tagged_architecture
>
> What else?

I would say that a python-processor should have dictionary lookup
(hash tables), garbage collection  and dynamic lists implemented by
hardware/firmware.

Maybe in another twenty years ...

Ciao

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


ANN: Albow 2.0

2008-10-06 Thread greg

ALBOW - A Little Bit of Widgetry for PyGame

Version 2.0 is now available.

This version incorporates substantial additions and improvements.
New widgets include TabPanel, TableView, CheckBox, RadioButton and
an enhanced set of TextField-based controls.

  http://www.cosc.canterbury.ac.nz/greg.ewing/python/Albow/


What is Albow?

Albow is a library for creating GUIs using PyGame that I have been
developing over the course of several PyWeek competitions. I am documenting
and releasing it as a separate package so that others may benefit from it,
and so that it will be permissible for use in future PyGame entries.

The download includes HTML documentation and an example program
demonstrating most of the library's features. You can also see some
screenshots and browse the documentation on-line.
--
http://mail.python.org/mailman/listinfo/python-list


Re: how to get the thighest bit position in big integers?

2008-10-06 Thread Holger
def highest_bit(n, maxbits = 256):
bit = 0
while maxbits > 1:
maxbits >>= 1
a = n >> maxbits
if a:
bit += maxbits
n = a
return bit

is sligtly better
--
http://mail.python.org/mailman/listinfo/python-list


Re: Problem with lower() for unicode strings in russian

2008-10-06 Thread konstantin
On Oct 6, 8:39 am, Alexey Moskvin <[EMAIL PROTECTED]> wrote:
> Martin, thanks for fast reply, now anything is ok!
> On Oct 6, 1:30 am, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote:
>
> > > I have a set of strings (all letters are capitalized) at utf-8,
>
> > That's the problem. If these are really utf-8 encoded byte strings,
> > then .lower likely won't work. It uses the C library's tolower API,
> > which works on a byte level, i.e. can't work for multi-byte encodings.
>
> > What you need to do is to operate on Unicode strings. I.e. instead
> > of
>
> >   s.lower()
>
> > do
>
> >   s.decode("utf-8").lower()
>
> > or (if you need byte strings back)
>
> >   s.decode("utf-8").lower().encode("utf-8")
>
> > If you find that you write the latter, I recommend that you redesign
> > your application. Don't use byte strings to represent text, but use
> > Unicode strings all the time, except at the system boundary (where
> > you decode/encode as appropriate).
>
> > There are some limitations with Unicode .lower also, but I don't
> > think they apply to Russian (specifically, SpecialCasing.txt is
> > not considered).
>
> > HTH,
> > Martin

Alexey,

if your strings stored in some text file you can use "codecs" package

> import codecs
> handler = codecs.open('somefile', 'r', 'utf-8')
> # ... do the job
> handler.close()

I prefer this way to deal with russian in utf-8.

Konstantin.


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


New Jersey webcam: Landie

2008-10-06 Thread fernandena
Webcam: Landie,19 year.New Jersey. Viens me voir et tu verras!
http://datesex.xhostar.com/landie1989.htm
--
http://mail.python.org/mailman/listinfo/python-list


Re: how to get the thighest bit position in big integers?

2008-10-06 Thread M.-A. Lemburg
On 2008-10-05 17:26, [EMAIL PROTECTED] wrote:
> Hi,
> 
> I'm using python to develop some proof-of-concept code for a
> cryptographic application. My code makes extended use of python's
> native bignum capabilities.
> 
> In many cryptographic applications there is the need for a function
> 'get_highest_bit_num' that returns the position number of the highest
> set bit of a given integer. For example:
> 
>get_highest_bit_num( (1 << 159)) == 159
>get_highest_bit_num( (1 << 160) - 1) == 159
>get_highest_bit_num( (1 << 160)) == 160
> 
> I implemented this the following way:
> 
> def get_highest_bit_num(r):
> i = -1
> while r > 0:
> r >>= 1
> i = i + 1
> return i
> 
> This works, but it is a very unsatisfying solution, because it is so
> slow.
> 
> My second try was using the math.log function:
> 
> import math
> r = (1 << 160) - 1
> print highest_bit_num(r)  # prints out 159
> print math.floor(math.log(r, 2))  # prints out 160.0
> 
> We see that math.log can only serve as a heuristic for the highest bit
> position. For small r, for example r = (1 << 16) - 1, the result from
> math.log(, 2) is correct, for big r it isn't any more.
> 
> My question to the group: Does anyone know of a non-hackish way to
> determine the required bit position in python? I know that my two
> ideas
> can be combined to get something working. But is there a *better* way,
> that isn't that hackish?

In Python 2.6, you can use the bin() builtin:

>>> len(bin(1<<159)) - 3
159

-- 
Marc-Andre Lemburg
eGenix.com

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


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


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


Re: do you fail at FizzBuzz? simple prog test

2008-10-06 Thread Tobiah

Or to allow the numbers 3 and 5 to be easily changed:

for i in range(1, 101):
print 'fizz' * (not i % 3) + 'buzz' * (not i % 5) or i

Tobiah



for i in range(1,100):
 print ('fizz','','')[i%3] + ('buzz','','','','')[i%5] or i


"Write a program that prints the numbers from 1 to 100. But for
multiples of three print "Fizz" instead of the number and for the
multiples of five print "Buzz". For numbers which are multiples of
both three and five print "FizzBuzz".

for i in range(1,101):
if i%3 == 0 and i%5 != 0:
print "Fizz"
elif i%5 == 0 and i%3 != 0:
print "Buzz"
elif i%5 == 0 and i%3 == 0:
print "FizzBuzz"
else:
print i


is there a better way than my solution? is mine ok?



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






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


Re: Python 2.6: Determining if a method is inherited

2008-10-06 Thread Fuzzyman
On Oct 5, 11:54 pm, Terry Reedy <[EMAIL PROTECTED]> wrote:
> Fuzzyman wrote:
> > Hello all,
>
> > I may well be being dumb (it has happened before), but I'm struggling
> > to fix some code breakage with Python 2.6.
>
> > I have some code that looks for the '__lt__' method on a class:
>
> > if hasattr(clr, '__lt__'):
>
> > However - in Python 2.6 object has grown a default implementation of
> > '__lt__', so this test always returns True.
>
>  class X(object): pass
> > ...
>  X.__lt__
> > 
>  X.__lt__ == object.__lt__
> > False
>
> In 3.0, the test returns true because function attributes only get
> wrapped when bound.  In the meanwhile, " 'object' in repr(X.__lt__)"
> should do it for you.
>


So long as its never used on a class with 'object' in the name.
Doesn't sound like a particularly *good* solution to me. :-)

Michael

> tjr

--
http://www.ironpythoninaction.com/
--
http://mail.python.org/mailman/listinfo/python-list


Dict Comprehension ?

2008-10-06 Thread Ernst-Ludwig Brust
Given 2 Number-Lists say l0 and l1,
count the various positiv differences between the 2 lists

the following part works:

dif=[abs(x-y) for x in l0 for y in l1]
da={}
for d in dif: da[d]=da.get(d,0)+1

i wonder, if there is a way, to avoid the list dif

Ernst-Ludwig Brust 


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


Re: Python 2.6: Determining if a method is inherited

2008-10-06 Thread Fuzzyman
On Oct 6, 7:16 am, Christian Heimes <[EMAIL PROTECTED]> wrote:
> Terry Reedy wrote:
> > In 3.0, the test returns true because function attributes only get
> > wrapped when bound.  In the meanwhile, " 'object' in repr(X.__lt__)"
> > should do it for you.
>
> This session should give you some hints how to archive your goal :)
> Have fun!
>
>  >>> import types
>  >>> class A(object):
> ... def __lt__(self):
> ... pass
> ...
>  >>> isinstance(A.__lt__, types.MethodType)
> True
>  >>> isinstance(A.__gt__, types.MethodType)
> False
>
>  >>> type(A.__lt__)
> 
>  >>> type(A.__gt__)
> 
>  >>> type(A.__str__)
> 
>  >>> type(A.__new__)
> 
>
>  >>> A.__lt__.im_func
> 
>  >>> A.__lt__.im_func == A.__lt__.im_func
> True
>  >>> A.__gt__.im_func
> Traceback (most recent call last):
>File "", line 1, in 
> AttributeError: 'method-wrapper' object has no attribute 'im_func'

However - I need to detect whether a method is inherited from
*object*. All those differences you have shown behave identically if
the class inherits from 'int'.

I am trying to detect explicit implementation of comparison methods -
so there is a big difference between inheriting from int and
inheriting from object (meaningful comparison methods existing on one
and not the other).

What I went for in the end:

import sys as _sys

if _sys.version_info[0] == 3:
def _has_method(cls, name):
for B in cls.__mro__:
if B is object:
continue
if name in B.__dict__:
return True
return False
else:
def _has_method(cls, name):
for B in cls.mro():
if B is object:
continue
if name in B.__dict__:
return True
return False

See this page for why I needed it:

http://www.voidspace.org.uk/python/weblog/arch_d7_2008_10_04.shtml#e1018

Michael

--
http://www.ironpythoninaction.com/
--
http://mail.python.org/mailman/listinfo/python-list


Class properties and object properties

2008-10-06 Thread SuperZE
Learning python I was rewriting some of my old programs to see the
pros and cons of python when a steped in some weird (at least for me)
behavior.

Here it is simplified

The code:

>>> class Test1:
myList = [4 for n in range(4)]
myInt = 4
>>> a = Test1()
>>> b = Test1()
>>> a.myList
[4, 4, 4, 4]
>>> a.myInt
4
>>> b.myList
[4, 4, 4, 4]
>>> b.myInt
4
>>> b.myList[2] = 3
>>> b.myInt = 3
>>> b.myList
[4, 4, 3, 4]
>>> b.myInt
3
>>> a.myList
[4, 4, 3, 4]
>>> a.myInt
4


I would not expect the second a.myList to have changed as it did
since, for me, I have only changed b.myList. And also, why only the
list changed and not the integer?

One thing i tried was:

>>> class Test2:
myList = []
myInt = 4
def __init__(self):
self.myList = [4 for n in range(4)]

>>> a = Test2()
>>> b = Test2()
>>> a.myList
[4, 4, 4, 4]
>>> b.myList
[4, 4, 4, 4]
>>> b.myList[2] = 3
>>> b.myList
[4, 4, 3, 4]
>>> a.myList
[4, 4, 4, 4]


And as you see it worked as I expected.

Now the question, why?
--
http://mail.python.org/mailman/listinfo/python-list


how to start thread by group?

2008-10-06 Thread oyster
my code is not right, can sb give me a hand? thanx

for example, I have 1000 urls to be downloaded, but only 5 thread at one time
def threadTask(ulr):
  download(url)

threadsAll=[]
for url in all_url:
 task=threading.Thread(target=threadTask, args=[url])
 threadsAll.append(task)

for every5task in groupcount(threadsAll,5):
for everytask in every5task:
everytask.start()

for everytask in every5task:
everytask.join()

for everytask in every5task:#this does not run ok
while everytask.isAlive():
pass
--
http://mail.python.org/mailman/listinfo/python-list


Re: Using python Serial module on windows

2008-10-06 Thread Holger
Turns out there's a windows package that works bautifully with
activestate python:
pyserial-2.4.win32.exe

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


Re: Class properties and object properties

2008-10-06 Thread Diez B. Roggisch
SuperZE wrote:

> Learning python I was rewriting some of my old programs to see the
> pros and cons of python when a steped in some weird (at least for me)
> behavior.
> 
> Here it is simplified
> 
> The code:
> 
 class Test1:
> myList = [4 for n in range(4)]
> myInt = 4
 a = Test1()
 b = Test1()
 a.myList
> [4, 4, 4, 4]
 a.myInt
> 4
 b.myList
> [4, 4, 4, 4]
 b.myInt
> 4
 b.myList[2] = 3
 b.myInt = 3
 b.myList
> [4, 4, 3, 4]
 b.myInt
> 3
 a.myList
> [4, 4, 3, 4]
 a.myInt
> 4
> 
> 
> I would not expect the second a.myList to have changed as it did
> since, for me, I have only changed b.myList. And also, why only the
> list changed and not the integer?
> 
> One thing i tried was:
> 
 class Test2:
> myList = []
> myInt = 4
> def __init__(self):
> self.myList = [4 for n in range(4)]
> 
 a = Test2()
 b = Test2()
 a.myList
> [4, 4, 4, 4]
 b.myList
> [4, 4, 4, 4]
 b.myList[2] = 3
 b.myList
> [4, 4, 3, 4]
 a.myList
> [4, 4, 4, 4]
> 
> 
> And as you see it worked as I expected.
> 
> Now the question, why?

Because you declare myList to be a *class*-level variable, which means *all*
instances of that class (a and b in your case) *share* it. Python does not
declare *instance* variables the way you do.

Instead, do this:

class Foo(object):
def __init__(self):
self.myList = []

And to avoid a common pitfall you are likely to hit next: default arguments
in functions (and methods) are evaluated only *once*, when defined - not
later!

So

def foo(some_arg=[]):
some_arg.append("a")
print some_arg

foo()
foo()

will result in 

['a']
['a', 'a'] 

being printed out.

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


Re: Class properties and object properties

2008-10-06 Thread SuperZE
> Because you declare myList to be a *class*-level variable, which means *all*
> instances of that class (a and b in your case) *share* it. Python does not
> declare *instance* variables the way you do.
>
> Instead, do this:
>
> class Foo(object):
>     def __init__(self):
>         self.myList = []


Interesting, but that does not explain the difference in the behavior
of myList and myInt

Both were class-level variables, as far as I can see, and therefor a
and b should also share it


And good remind on default arguments :)
--
http://mail.python.org/mailman/listinfo/python-list


Re: Class properties and object properties

2008-10-06 Thread Jerry Hill
On Mon, Oct 6, 2008 at 9:38 AM, SuperZE <[EMAIL PROTECTED]> wrote:
> Interesting, but that does not explain the difference in the behavior
> of myList and myInt
>
> Both were class-level variables, as far as I can see, and therefor a
> and b should also share it

They did share it, until you assigned an instance variable in b, which
shadowed the class variable.  Example:

>>> class Test1:
myInt = 4


>>> a = Test1()
>>> b = Test1()
>>> a.myInt
4
>>> b.myInt
4
>>> Test1.myInt
4
>>> b.myInt = 3
>>> a.myInt
4
>>> b.myInt
3
>>> Test1.myInt
4

As soon as you bound the name b.myInt to a new value, it created an
instance variable.  That hides the value of Test1.myInt.

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


Re: Class properties and object properties

2008-10-06 Thread Diez B. Roggisch
SuperZE wrote:

>> Because you declare myList to be a *class*-level variable, which means
>> *all* instances of that class (a and b in your case) *share* it. Python
>> does not declare *instance* variables the way you do.
>>
>> Instead, do this:
>>
>> class Foo(object):
>> def __init__(self):
>> self.myList = []
> 
> 
> Interesting, but that does not explain the difference in the behavior
> of myList and myInt

Sorry, I forgot that.

The reason is simple - lists are mutable. Numbers aren't. And when you
*assign* to an instance a value, it will be set on the instance, not on the
class.

The same happens (as you've already seen for yourself) when you do

a.myList = []

as this creates a new list, stored only on a.

 
> Both were class-level variables, as far as I can see, and therefor a
> and b should also share it

Nope. To change it, you need to do

Test1.myInt = 5

The thing is that the lookup triggered by getattr/dotted notation goes
roughly like this:

1) try to find the attribute (value *or* method! Python doesn't distinguish)
in the instance itself.

2) if not found there, look at the class.

3) if not found there, look at the base-classes in the method resolution
order (MRO)

There are some other things involved - descriptor protocol calls on the
class-level lookups - but that's not relevant for the problem at hand.

OTOH, when setting with setattr/dotted notation, it will always set on the
object passed.

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


Re: Dict Comprehension ?

2008-10-06 Thread bearophileHUGS
Ernst-Ludwig Brust:
> Given 2 Number-Lists say l0 and l1,
> count the various positiv differences between the 2 lists
>...
> i wonder, if there is a way, to avoid the list dif

Instead of creating the list (array) dif, you can create a lazy
iterator. Then you can fed it to a set.

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


Re: Class properties and object properties

2008-10-06 Thread SuperZE
TYVM Diez and Jerry

Now I understand how this works
--
http://mail.python.org/mailman/listinfo/python-list


type-checking support in Python?

2008-10-06 Thread Joe Strout
I'm just re-learning Python after nearly a decade away.  I've learned  
a good healthy paranoia about my code in that time, and so one thing  
I'd like to add to my Python habits is a way to both (a) make intended  
types clear to the human reader of the code, in a uniform manner; and  
(b) catch any type errors as early and automatically as possible.


I found the "typecheck" module (http://oakwinter.com/code/typecheck/),  
but I notice that it hasn't been updated since 2006, and it's not  
included with the Python distribution.  Are there other modules  
providing similar functionality that I should consider instead?


Also, I'll probably be considering a lint-like tool at some point...  
are there any that allow you to declare some extra type information,  
and have that checked at lint time?


Finally, one thing I've considered is adopting some identifier  
prefixes indicating type.  Maybe "iFoo" for integer, "fFoo" for  
floating-point numbers, "d" for dictionary, "l" for list, "t" for  
tuple, "o" for object, and "v" for variable types that may be more  
than one of the above.  I gather (from just a couple days of browsing)  
that such a naming convention isn't common in the Python community,  
but is there anyone else here who does it?  I'd rather adopt an  
existing standard (even if it's not widely used) than make one up.


Many thanks,
- Joe


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


Re: how to start thread by group?

2008-10-06 Thread bieffe62
On 6 Ott, 15:24, oyster <[EMAIL PROTECTED]> wrote:
> my code is not right, can sb give me a hand? thanx
>
> for example, I have 1000 urls to be downloaded, but only 5 thread at one time
> def threadTask(ulr):
>   download(url)
>
> threadsAll=[]
> for url in all_url:
>      task=threading.Thread(target=threadTask, args=[url])
>      threadsAll.append(task)
>
> for every5task in groupcount(threadsAll,5):
>     for everytask in every5task:
>         everytask.start()
>
>     for everytask in every5task:
>         everytask.join()
>
>     for everytask in every5task:        #this does not run ok
>         while everytask.isAlive():
>             pass

Thread.join() stops until the thread is finished. You are assuming
that the threads
terminates exactly in the order in which are started. Moreover, before
starting the
next 5 threads you are waiting that all previous 5 threads have been
completed, while I
believe your intention was to have always the full load of 5 threads
downloading.

I would restructure my code with someting like this ( WARNING: the
following code is
ABSOLUTELY UNTESTED and shall be considered only as pseudo-code to
express my idea of
the algorithm (which, also, could be wrong:-) ):


import threading, time

MAX_THREADS = 5
DELAY = 0.01 # or whatever

def task_function( url ):
download( url )

def start_thread( url):
task=threading.Thread(target=task_function, args=[url])
return task

def main():
all_urls = load_urls()
all_threads = []
while all_urls:
while len(all_threads) < MAX_THREADS:
url = all_urls.pop(0)
t = start_thread()
all_threads.append(t)
for t in all_threads
if not t.isAlive():
t.join()
all_threads.delete(t)
time.sleep( DELAY )


HTH

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


Re: Dict Comprehension ?

2008-10-06 Thread pruebauno
On Oct 6, 8:59 am, "Ernst-Ludwig Brust" <[EMAIL PROTECTED]> wrote:
> Given 2 Number-Lists say l0 and l1,
> count the various positiv differences between the 2 lists
>
> the following part works:
>
> dif=[abs(x-y) for x in l0 for y in l1]
> da={}
> for d in dif: da[d]=da.get(d,0)+1
>
> i wonder, if there is a way, to avoid the list dif
>
> Ernst-Ludwig Brust

from collections import defaultdict
da=defaultdict(int)
for x in [10]:
for y in [11]:
da[abs(x-y)]+=1
--
http://mail.python.org/mailman/listinfo/python-list


Re: Cookielib in Jython

2008-10-06 Thread bieffe62
On 6 Ott, 13:19, Felipe De Bene <[EMAIL PROTECTED]> wrote:
> Hi There,
> I'm trying to run an App I wrote in Python 2.5.2 in Jython 2.2.1 and
> everything works fine except when I try to import the Standard
> CPython's cookielib. I know this may sound stupid, I could use an
> advice here on what's wrong. Thanks in advance,
> Felipe.
>
> Output:
> Jython 2.2.1 on java1.6.0_07
> Type "copyright", "credits" or "license" for more information.>>> import 
> cookielib
>
> Traceback (innermost last):
>   File "", line 1, in ?
> ImportError: no module named cookielib>>> from cookielib import *
>
> Traceback (innermost last):
>   File "", line 1, in ?
> ImportError: no module named cookielib>>> from CookieLib import *
>
> Traceback (innermost last):
>   File "", line 1, in ?
> ImportError: no module named CookieLib

Obviously, choockielib is not in your jython installation.
If this module is a pure python module and not a wrupper of an
underlying C
module, you could try simple to get is from a CPython installation,
try and
compile it with Jython inside the code. If the module does not use any
feature
of the language introduced after Python 2.2, or other unsupported
modules,
it could work and you can use it inside your program as it was one of
your modules.

HTH

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


Re: Builing Python 2.6 on AIX 5.2

2008-10-06 Thread pruebauno
On Oct 6, 4:16 am, brasse <[EMAIL PROTECTED]> wrote:
> Hello!
>
> I am having some trouble building Python 2.6 on AIX. The steps I have
> taken are:
>
> export PATH=/usr/bin/:/usr/vacpp/bin/
> ./configure --with-gcc=xlc_r --with-cxx=xlC_r --disable-ipv6
> make
>
> This is the error message I'm seeing:
> ./Modules/ld_so_aix xlc_r -bI:Modules/python.exp build/
> temp.aix-5.2-2.6/home/mabr/Python-2.6/Modules/_multiprocessing/
> multiprocessing.o build/temp.aix-5.2-2.6/home/mabr/Python-2.6/Modules/
> _multiprocessing/socket_connection.o build/temp.aix-5.2-2.6/home/mabr/
> Python-2.6/Modules/_multiprocessing/semaphore.o -L/usr/local/lib -o
> build/lib.aix-5.2-2.6/_multiprocessing.so
> ld: 0711-317 ERROR: Undefined symbol: .sem_timedwait
> ld: 0711-317 ERROR: Undefined symbol: .CMSG_SPACE
> ld: 0711-317 ERROR: Undefined symbol: .CMSG_LEN
> ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more
> information.
> *** WARNING: renaming "_multiprocessing" since importing it failed: No
> such file or directory
> error: No such file or directory
> make: The error code from the last command is 1.
>
> Have someone on this list had similar problems? Am I missing some
> libraries? The configure script runs without errors, I would have
> expected some kind of error there if I was missing something.
>
> Regards,
> Mattias

I don't know if it has anything to do with it. But I got that error
one time on AIX and it was a library compiled to 32 bit that could not
be linked to 64 bit python. Maybe in your case it is the other way
around.

I haven't tried compiling Py2.6 yet. I compile 64 bit with:

OPT=-O2 ./configure --with-gcc="xlc_r -q64" --with-cxx="xlC_r -q64" --
disable-ipv6 AR="ar -X64"
--
http://mail.python.org/mailman/listinfo/python-list


Re: type-checking support in Python?

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

> I'm just re-learning Python after nearly a decade away.  I've learned
> a good healthy paranoia about my code in that time, and so one thing
> I'd like to add to my Python habits is a way to both (a) make intended
> types clear to the human reader of the code, in a uniform manner; and
> (b) catch any type errors as early and automatically as possible.
> 
> I found the "typecheck" module (http://oakwinter.com/code/typecheck/),
> but I notice that it hasn't been updated since 2006, and it's not
> included with the Python distribution.  Are there other modules
> providing similar functionality that I should consider instead?
> 
> Also, I'll probably be considering a lint-like tool at some point...
> are there any that allow you to declare some extra type information,
> and have that checked at lint time?
> 
> Finally, one thing I've considered is adopting some identifier
> prefixes indicating type.  Maybe "iFoo" for integer, "fFoo" for
> floating-point numbers, "d" for dictionary, "l" for list, "t" for
> tuple, "o" for object, and "v" for variable types that may be more
> than one of the above.  I gather (from just a couple days of browsing)
> that such a naming convention isn't common in the Python community,
> but is there anyone else here who does it?  I'd rather adopt an
> existing standard (even if it's not widely used) than make one up.

The short answer is:

 - don't use typechecks, or at least as few as possible - only for
polymorphy. Ducktyping is important for good python code, and shouldn't be
prevented by excessive typechecks.

 - if you don't trust your code, write tests. Actually, *always* write
tests. It really helps getting the design of your code better, saves time
when refactorings or enhancements are needed - and captures more errors
that static typechecking - and your typechecking actually isn't even static
& thus you'd need tests to get code coverage anyway.

 - don't adopt these silly microsoft perversion of hungarian notation.
clear, expressive variable names - sure. with pre- or suffixes to indicate
their kind, possible. But using iX or fX where all one cares is that X
holds a number is not helpful.

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


Python - modules and netCDF

2008-10-06 Thread Michele Thornton
Greetings,

I would like to use Python to open, edit, and write netCDF files.  I
mostly work as a GIS analyst and find myself needing to edit netCDF
files in order to meet CF Metadata conventions.  Along with Python, I
need to include, as far as I can tell, at least 2 modules, Scientific
Python (or SciPy) and Numeric Python (or NumPy) in order to have all
the correct pieces to make this work.  Does anybody have a way to
determine what version(s) of Python and  each module I need to
accomplish this task?  Should I start with Python 2.4, 2.5, or the
latest release, 2.6?

I keep finding conflicting and out-dated information especially as it
relates to Scientific Python (and/or SciPy) and Numeric Python (and/or
NumPy) and the ability to work with netCDF files.  For example,
written Jun8, 2007, "Note numpy does NOT work!"  But when I go to
sourceforge.net to download Numerical Python, I'm downloading NumPy -
1.2.0.  The Scientific Python site recomments Numerical Python release
23.8.2.  NumPy website says, "It may take months for the large code
base that uses Numeric and/or Numarray to transition to the new NumPy
system.   Links to the older packages are provided here.   New users
should start out with NumPy."


Thanks in advance,
Michele



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


Re: If an OS was to be written in Python, how'w it look?

2008-10-06 Thread Eric Wertman
>> If an OS was to be written in Python and the hardware optimized for
>> it, what changes would be made to the hardware to accomodate Python
>> strenghs and weaknesses?


I'm no expert, but this would seem like a good example of something
that python wasn't good for.  I have always wondered, though, what a
Linux kernel module would look like that had a python (or java, or
whatever) interpreter running low-level, so the higher level
components on the operating system could be implemented in an
interpreted language.  Is there any benefit to something like that?
Or is that crap too?  Again, I'm no expert.

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


Re: Builing Python 2.6 on AIX 5.2

2008-10-06 Thread Jesse Noller
Looks like AIX is missing sem_timedwait - see:
http://bugs.python.org/issue3876

Please add your error to the bug report just so I can track it.

-jesse

On Mon, Oct 6, 2008 at 4:16 AM, brasse <[EMAIL PROTECTED]> wrote:
> Hello!
>
> I am having some trouble building Python 2.6 on AIX. The steps I have
> taken are:
>
> export PATH=/usr/bin/:/usr/vacpp/bin/
> ./configure --with-gcc=xlc_r --with-cxx=xlC_r --disable-ipv6
> make
>
> This is the error message I'm seeing:
> ./Modules/ld_so_aix xlc_r -bI:Modules/python.exp build/
> temp.aix-5.2-2.6/home/mabr/Python-2.6/Modules/_multiprocessing/
> multiprocessing.o build/temp.aix-5.2-2.6/home/mabr/Python-2.6/Modules/
> _multiprocessing/socket_connection.o build/temp.aix-5.2-2.6/home/mabr/
> Python-2.6/Modules/_multiprocessing/semaphore.o -L/usr/local/lib -o
> build/lib.aix-5.2-2.6/_multiprocessing.so
> ld: 0711-317 ERROR: Undefined symbol: .sem_timedwait
> ld: 0711-317 ERROR: Undefined symbol: .CMSG_SPACE
> ld: 0711-317 ERROR: Undefined symbol: .CMSG_LEN
> ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more
> information.
> *** WARNING: renaming "_multiprocessing" since importing it failed: No
> such file or directory
> error: No such file or directory
> make: The error code from the last command is 1.
>
> Have someone on this list had similar problems? Am I missing some
> libraries? The configure script runs without errors, I would have
> expected some kind of error there if I was missing something.
>
> Regards,
> Mattias
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list


Re: If an OS was to be written in Python, how'w it look?

2008-10-06 Thread Dan Upton
On Mon, Oct 6, 2008 at 11:02 AM, Eric Wertman <[EMAIL PROTECTED]> wrote:
>>> If an OS was to be written in Python and the hardware optimized for
>>> it, what changes would be made to the hardware to accomodate Python
>>> strenghs and weaknesses?
>
>
> I'm no expert, but this would seem like a good example of something
> that python wasn't good for.  I have always wondered, though, what a
> Linux kernel module would look like that had a python (or java, or
> whatever) interpreter running low-level, so the higher level
> components on the operating system could be implemented in an
> interpreted language.  Is there any benefit to something like that?
> Or is that crap too?  Again, I'm no expert.
>

The closest I can think of to that is Singularity, Microsoft's
research OS written in .NET (well, C# specifically I guess).  I think
their intent was more to shrink the size of the trusted computing base
though and then make all of the actual OS services and such managed
code.

http://research.microsoft.com/os/Singularity/
--
http://mail.python.org/mailman/listinfo/python-list


The recent SPAM messages, and a suggested solution

2008-10-06 Thread Barak, Ron
Hi,

I think most of us are annoyed by the recent SPAM messages that crept onto our 
list.
I'd like to suggest a possible solution, and maybe start a thread that 
eventually will rid us of this unpleasantness.

My idea:

Once every few messages from the list owners, they would send a new numerical 
string that will have to be included in members' list submission.
A message being submitted without this numeric string will be re-routed to 
/dev/null.
The current string will be announced on the messages being send to new members 
upon registration.

Since SPAM is sent in bulk, this may be a rather complete solution.

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


OptionParser: options and args passed to PyQT app

2008-10-06 Thread [EMAIL PROTECTED]
Hi,

New with python, I've developped a small cmd line script parsing opts
and args with an OptionParser:

in myApp.py:

...blablabla...
parser.add_option(...)
parser.add_option(...)
(options, args) = parser.parse_args()
doCheckParams(parser, options, args)
...blablabla...

I'm trying now to integrate it into a PyQt GUI app: Then options and
args are coming from my app fields.

here's my app:

from PyQt4 import QtCore, QtGui
from gui import Ui_my_app_gui
import myApp

class MyAppDialog(QtGui.QDialog):
def __init__(self):
QtGui.QDialog.__init__(self)
self.ui = Ui_my_app_gui()
self.ui.setupUi(self)

self.connect(self.ui.launch_button, QtCore.SIGNAL("clicked()"),
self._run)

def _run(self):

options = {}
options['opt1'] = self.ui.opt1_value.text
options['opt2'] = self.ui.opt2_value.text

args = str(self.ui.arg1_value.text)

try:
myApp.doCheckParams(parser=None, options=options, 
args=args)
# code does not reach this line!
myApp.run()
except Exception, message:
self.ui.output_value.setEnabled(True)
self.ui.output_value.text = message


if __name__=="__main__":
app = QtGui.QApplication(sys.argv)
dialog = MyAppDialog()
dialog.show()
app.exec_()

When clicking on my launch_button button, I can see that some code is
executed but my code never reaches the  "# code does not reach this
line!" line

Thanks a lot for your precious help!

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


Re: Cookielib in Jython

2008-10-06 Thread Felipe De Bene
On Oct 6, 10:36 am, [EMAIL PROTECTED] wrote:
> On 6 Ott, 13:19, Felipe De Bene <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hi There,
> > I'm trying to run an App I wrote in Python 2.5.2 in Jython 2.2.1 and
> > everything works fine except when I try to import the Standard
> > CPython's cookielib. I know this may sound stupid, I could use an
> > advice here on what's wrong. Thanks in advance,
> > Felipe.
>
> > Output:
> > Jython 2.2.1 on java1.6.0_07
> > Type "copyright", "credits" or "license" for more information.>>> import 
> > cookielib
>
> > Traceback (innermost last):
> >   File "", line 1, in ?
> > ImportError: no module named cookielib>>> from cookielib import *
>
> > Traceback (innermost last):
> >   File "", line 1, in ?
> > ImportError: no module named cookielib>>> from CookieLib import *
>
> > Traceback (innermost last):
> >   File "", line 1, in ?
> > ImportError: no module named CookieLib
>
> Obviously, choockielib is not in your jython installation.
> If this module is a pure python module and not a wrupper of an
> underlying C
> module, you could try simple to get is from a CPython installation,
> try and
> compile it with Jython inside the code. If the module does not use any
> feature
> of the language introduced after Python 2.2, or other unsupported
> modules,
> it could work and you can use it inside your program as it was one of
> your modules.
>
> HTH
> 
> FB

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


gif creator

2008-10-06 Thread [EMAIL PROTECTED]
has anyone written a gif creator program purely in python that doesn't
require PIL or tons of other claptrap?

the GIF89a format is pretty straightforward and C is not required to
create these files.

i didn't want to have to upgrade to a newer release of python, install
a huge bunch of stuff or compile
anything.  and i don't care about other formats or animation or
whatever.  black and white is ok.

i just want to be able to create a gif that's 100x40 (or whatever) and
pass in an array saying
which pixels are black or white.

sounds pretty simple doesn' t it?
--
http://mail.python.org/mailman/listinfo/python-list


Re: The recent SPAM messages, and a suggested solution

2008-10-06 Thread skip

Ron> I think most of us are annoyed by the recent SPAM messages that
Ron> crept onto our list.  I'd like to suggest a possible solution, and
Ron> maybe start a thread that eventually will rid us of this
Ron> unpleasantness.

Ron> My idea:

Ron> Once every few messages from the list owners, they would send a new
Ron> numerical string that will have to be included in members' list
Ron> submission.  A message being submitted without this numeric string
Ron> will be re-routed to /dev/null.  The current string will be
Ron> announced on the messages being send to new members upon
Ron> registration.

Ron> Since SPAM is sent in bulk, this may be a rather complete solution.

Those of us who manage the the python.org mailing lists are overloaded
enough as it is.  We don't have time to add extra tasks to our daily
checklists.  In addition, ad hoc solutions frequently don't scale well.
Check http://mail.python.org/ for the full scope of the management problem.
We run a single SpamBayes instance on mail.python.org which scans for spam
in almost all those mailing lists.  A couple are unfiltered for various
reasons.

If you read python-list via Usenet (comp.lang.python in its various guises)
there's not much we can do to help you.  If someone posts crap via Usenet
you will see it before it reaches the spam filter on mail.python.org.  Some
Usenet servers may provide decent spam filtering.  Google Groups appears not
to, and their spam reporting process requires several steps on your part.
If you are reading [email protected] please feel free to mail me
([EMAIL PROTECTED]) any spam which sneaks through SpamBayes.  I will train them
as I can, generally about once a day.  It would really help if you could
attach a zip'd or gzip'd copy of the message.  Don't just paste a spam
message into any mail you send me.

If you read email you get spam.  That is an unfortunate fact of life today.
You should run some sort of spam filter on your system and not rely on
sysadmins or mailing list admins to filter your mail.  My email goes through
Gmail and I run SpamBayes on my laptop as well.  That presents its own set
of issues (I have to poke around in both filters' traps to find spams which
sneak through the mail.python.org filters for example), but I generally see
very little spam.  You can get SpamBayes (it's free and written in Python)
from .  There are a number of ways to use it,
including an Outlook plugin and several more Unix-oriented apps.  All use
the same core classifier.  There is a Thunderbird plugin available (google
for ThunderBayes) which is currently unsupported but which we would like to
incorporate into the SpamBayes code base.  Unfortunately, we are short of
round tuits.  If you'd like to help we can always use more brainpower.

-- 
Skip Montanaro - [EMAIL PROTECTED] - http://www.webfast.com/~skip/
--
http://mail.python.org/mailman/listinfo/python-list


subprocess.Popen(..., cwd=...) and Makefile $(PWD) don't play nice

2008-10-06 Thread Miki
Hello All,

Can anybody explain why Makefile $(PWD) does show the right directory
when running under subprocess.Popen(..., cwd=...)

For example:
[18:07] tmp $cat /tmp/p/Makefile
all:
@echo $(PWD)
[18:07] tmp $cat t
#!/usr/bin/env python

from subprocess import Popen
Popen(["make"], cwd="/tmp/p")

[18:07] tmp $./t
/tmp

The output of the "make" command should have been "/tmp/p" and not "/
tmp"

TIA,
--
Miki <[EMAIL PROTECTED]>
http://pythonwise.blogspot.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: type-checking support in Python?

2008-10-06 Thread Bruno Desthuilliers

Joe Strout a écrit :
I'm just re-learning Python after nearly a decade away.  I've learned a 
good healthy paranoia about my code in that time, and so one thing I'd 
like to add to my Python habits is a way to both (a) make intended types 
clear to the human reader of the code,


Good naming and documentation.

in a uniform manner; and (b) 
catch any type errors as early and automatically as possible.


For which definition of "type error" ?-)

To make a long story short, duck typing is the pythonic way to do 
things. From experience, type errors are rare, and usually very quickly 
spotted and fixed. Except when it comes to handling user inputs, don't 
bother coding in a defensive style. Just write the minimal necessary 
code, and only worry about exceptions you somehow except *and* can 
handle locally.


I found the "typecheck" module (http://oakwinter.com/code/typecheck/), 
but I notice that it hasn't been updated since 2006, and it's not 
included with the Python distribution.  Are there other modules 
providing similar functionality that I should consider instead?


yes : unittests.


Also, I'll probably be considering a lint-like tool at some point... are 
there any that allow you to declare some extra type information, and 
have that checked at lint time?


Not AFAIK. This may come with py3k using ABCs and type annotations, but 
once again, don't worry too much about this.


I know these advices may sound scary to declarative static typing 
addicts, but man/years of experience have proven that duck typing 
JustWork(tm). So don't fight the language, it would only make you suffer 
useless pain and frustration.


Finally, one thing I've considered is adopting some identifier prefixes 
indicating type.


Don't.

 Maybe "iFoo" for integer, "fFoo" for floating-point 
numbers, "d" for dictionary, "l" for list, "t" for tuple, "o" for 
object,


Then you can already prefix each and any of your identifiers (including 
classes and functions) with an 'o', since everything in Python is an 
object !-)


 I gather (from just a couple days of browsing) that such a 
naming convention isn't common in the Python community,


It's not only uncommon, but - just like useless typechecking - 
considered bad form.


but is there 
anyone else here who does it?  I'd rather adopt an existing standard 
(even if it's not widely used) than make one up.


The standard coding conventions are here:
http://www.python.org/dev/peps/pep-0008/

FWIW, Python relies quite heavily on naming conventions. Better to stick 
to pep8.

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


Re: gif creator

2008-10-06 Thread Steve Holden
[EMAIL PROTECTED] wrote:
> has anyone written a gif creator program purely in python that doesn't
> require PIL or tons of other claptrap?
> 
> the GIF89a format is pretty straightforward and C is not required to
> create these files.
> 
> i didn't want to have to upgrade to a newer release of python, install
> a huge bunch of stuff or compile
> anything.  and i don't care about other formats or animation or
> whatever.  black and white is ok.
> 
> i just want to be able to create a gif that's 100x40 (or whatever) and
> pass in an array saying
> which pixels are black or white.
> 
> sounds pretty simple doesn' t it?

It doesn't sound anywhere near as simple as downloading and installing
PIL then using that. Claptrap is in the eye of the beholder. There are
many pitfalls awaiting the programmer who decides to write something to
do such a "simple" task ...

regards
 Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.com/

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


Re: If an OS was to be written in Python, how'w it look?

2008-10-06 Thread Paul Rubin
"Eric Wertman" <[EMAIL PROTECTED]> writes:
> I'm no expert, but this would seem like a good example of something
> that python wasn't good for.  I have always wondered, though, what a
> Linux kernel module would look like that had a python (or java, or
> whatever) interpreter running low-level, so the higher level
> components on the operating system could be implemented in an
> interpreted language.  Is there any benefit to something like that?
> Or is that crap too?  Again, I'm no expert.

This was done 20 years ago with the Lisp machine.  Really, it was a
bold idea back then, but programming language and systems
understanding have comea long way since then.  Best to keep using
Python as a scripting language; it's not the right thing for an OS.
--
http://mail.python.org/mailman/listinfo/python-list


Re: If an OS was to be written in Python, how'w it look?

2008-10-06 Thread Paul Rubin
"Dan Upton" <[EMAIL PROTECTED]> writes:
> The closest I can think of to that is Singularity, Microsoft's
> research OS written in .NET (well, C# specifically I guess).  

Singularity is almost the exact opposite of this and I don't think it
uses (unmodified) C#.  It does away with use of hardware memory
protection in any form, and relies on rigorous, statically enforced
type safety in the compilers and OS to isolate processes from one
another.
--
http://mail.python.org/mailman/listinfo/python-list


Re: ABCs -> infix syntax for isinstance() ?

2008-10-06 Thread Bruno Desthuilliers

[EMAIL PROTECTED] a écrit :

Bruno Desthuilliers dixit :


Boris Borcic a écrit :


Given the ABC innovation, maybe an infix syntax for isinstance() would
be good.
Possibilities :
- stealing "is" away from object identity. As a motivation, true use
cases for testing object identity are rare;

"x is None" is a *very* common test. Using a _marker object as default
arg value when you want to accept None as a meaningfull value is pretty
common.


(a) Okay, 3to2 can take care of "x is NoneType" and/or "x == None".
The latter could also be a compiler optimization.

(b) Give me None==False


Why so ?


and in exchange I will adopt "x is None" as
sacred forever :)




(not quite BTW, how much future do you think is there in turning 2to3
into some usable 3to2 ? What about "NtoM" as a more generic Python
project ?)


Testing a class identity often happens when writing metaclasses


This kind-of-talks for Terry's proposition : adding a __contains__ to
type,


I said "type identity testing", not isinstance() or issubclass() testing.

(snip)


A intriguing wider proposition would be to transpose Ruby's notion of
"Open Classes" to Python built-in metaclasses (or just to type
itself ?).


No, thanks. Even the Ruby guys start to think making evrything open may 
not be such a good idea after all.


And anyway, I don't see how any of the above address the point that your 
premise that "true identity testing is rare" is just wrong...


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


Re: gif creator

2008-10-06 Thread Miki
> i didn't want to have to upgrade to a newer release of python, install
> a huge bunch of stuff or compile
> anything.  and i don't care about other formats or animation or
> whatever.  black and white is ok.
One option is to install ImageMagick and use subprocess.Popen to
communicate with it. This will work even when you upgrade Python.

HTH,
--
Miki <[EMAIL PROTECTED]>
http://pythonwise.blogspot.com
--
http://mail.python.org/mailman/listinfo/python-list


AIR Jordan Fusions 13 NIKE Jordan Fusion 14 AIR Jordans 15Nike Jordan

2008-10-06 Thread [EMAIL PROTECTED]
shoes on
AIR Jordan 1  (paypal payment)(www.youtetrade.com )
AIR Jordan 2
AIR Jordan 3
AIR Jordan 4
AIR Jordan 5 (paypal payment)(www.youtetrade.com )
AIR Jordan 6 Rings
AIR Jordan 6
AIR Jordan 7
AIR Jordan 8
AIR Jordan 9 (paypal payment)(www.youtetrade.com )
AIR Jordan 10
AIR Jordan 11
AIR Jordan 12
AIR Jordan 13 (paypal payment)(www.youtetrade.com )
AIR Jordan 14
AIR Jordan 15
AIR Jordan 16
AIR Jordan 17
AIR Jordan 18
AIR Jordan 19
AIR Jordan 20 (paypal payment)(www.youtetrade.com )
AIR Jordan 21
AIR Jordan 22
AIR Jordan 23 (paypal payment)(www.youtetrade.com )
AIR Jordan 3.5
AIR AIR Jordan 4.5
AIR Jordan 7.5
AIR Jordan 9.5
AIR Jordan 12.5 (paypal payment)(www.youtetrade.com )
AIR Jordan 15.5
AIR Jordan 19.5
AIR Jordan 21.5
AIR Jordan Large Size Jordan
AIR Jordan  Size 14 Jordan
AIR Jordan Size 15 shoes
AIR Jordan DMP
Nike air force one, air force 1, air force one low cut, air force one
high cut, air force one release date
Air force one, air foce one 25TH, af 1, af 1 25TH, Nike air force one
new releases, limited version
Air Force One (paypal payment)(www.youtetrade.com )
Air Force one 25TH
AF 1
AF 1 25TH (paypal payment)(www.youtetrade.com )
Dunk sb nike sb dunk nike dunk sb dunk sb high  dunk sb low  dunk sb
woman
Nike sb dunk Nike Dunk High SB nike dunk low premuim sb Nike SB Dunk
High Shimizu
Nike SB Dunk Pro Nike SB Dunk Dunk SB
Nike Dunk shoes
Dunk shoes for woman (paypal payment)(www.youtetrade.com )
Dunk low cut
Dunk high cut


AIR Jordans Fusion 1 Jordan 2 Fusion AIR Jordan 3 Nike Jordan Fusion
4
Jordan 5 shoes Nike Air Jordan 6 VI Force 1 Jordan Fusion AJF 6 AJF6
AJ6F Jordan 6 Rings Jordan 6 fusion (paypal payment)(www.honest-
shop.cn )


AIR Jordan Fusions 13 NIKE Jordan Fusion 14 AIR Jordans 15Nike Jordan
16 Fusion Jordan 17 shoes Nike Air Jordans 18 XVIII  Force 1 Jordan
Fusion AJF18 AJF18 AJ18F Jordan 18 fusions
(paypal payment)(www.youtetrade.com )


AIR Jordan Fusions 7 NIKE Jordan Fusion 8 AIR Jordans 9 Nikes Jordan
Fusion 10 Jordan 11 shoes Nike Air Jordan 12 XII  Force 1 Jordan
Fusion AJF 12 AJF12 AJ12F Jordans 12 fusions
(paypal payment)(www.youtetrade.com )


NIKE AIR JORDAN FORCE FUSION SHOES AJF 5 V JORDANs 5 FUSION NIKE
JORDAN 5 FUSION SHOES AJF5 Nike Air Jordan XXIII 23 Force 1 Jordan
Fusion AJF 23 AJF23 AJ23F
(paypal payment)(www.youtetrade.com )


Nike Jordans Fusion 23 AIR Jordan 22 Jordan Fusions 21 AIR Jordans
Fusion 20 Jordan 19 shoes Air Jordan Force Fusion VIII (8), AJF 8
Nike (paypal payment)(www.youtetrade.com )
Air Jordan 17 XVII  Force 1 Jordan Fusions AJF 17 AJF17 AJ17F Jordan
our website : www.youtetrade.com
--
http://mail.python.org/mailman/listinfo/python-list


AIR Jordan Fusions 13 NIKE Jordan Fusion 14 AIR Jordans 15Nike Jordan

2008-10-06 Thread 46768
shoes on
AIR Jordan 1  (paypal payment)(www.youtetrade.com )
AIR Jordan 2
AIR Jordan 3
AIR Jordan 4
AIR Jordan 5 (paypal payment)(www.youtetrade.com )
AIR Jordan 6 Rings
AIR Jordan 6
AIR Jordan 7
AIR Jordan 8
AIR Jordan 9 (paypal payment)(www.youtetrade.com )
AIR Jordan 10
AIR Jordan 11
AIR Jordan 12
AIR Jordan 13 (paypal payment)(www.youtetrade.com )
AIR Jordan 14
AIR Jordan 15
AIR Jordan 16
AIR Jordan 17
AIR Jordan 18
AIR Jordan 19
AIR Jordan 20 (paypal payment)(www.youtetrade.com )
AIR Jordan 21
AIR Jordan 22
AIR Jordan 23 (paypal payment)(www.youtetrade.com )
AIR Jordan 3.5
AIR AIR Jordan 4.5
AIR Jordan 7.5
AIR Jordan 9.5
AIR Jordan 12.5 (paypal payment)(www.youtetrade.com )
AIR Jordan 15.5
AIR Jordan 19.5
AIR Jordan 21.5
AIR Jordan Large Size Jordan
AIR Jordan  Size 14 Jordan
AIR Jordan Size 15 shoes
AIR Jordan DMP
Nike air force one, air force 1, air force one low cut, air force one
high cut, air force one release date
Air force one, air foce one 25TH, af 1, af 1 25TH, Nike air force one
new releases, limited version
Air Force One (paypal payment)(www.youtetrade.com )
Air Force one 25TH
AF 1
AF 1 25TH (paypal payment)(www.youtetrade.com )
Dunk sb nike sb dunk nike dunk sb dunk sb high  dunk sb low  dunk sb
woman
Nike sb dunk Nike Dunk High SB nike dunk low premuim sb Nike SB Dunk
High Shimizu
Nike SB Dunk Pro Nike SB Dunk Dunk SB
Nike Dunk shoes
Dunk shoes for woman (paypal payment)(www.youtetrade.com )
Dunk low cut
Dunk high cut


AIR Jordans Fusion 1 Jordan 2 Fusion AIR Jordan 3 Nike Jordan Fusion
4
Jordan 5 shoes Nike Air Jordan 6 VI Force 1 Jordan Fusion AJF 6 AJF6
AJ6F Jordan 6 Rings Jordan 6 fusion (paypal payment)(www.honest-
shop.cn )


AIR Jordan Fusions 13 NIKE Jordan Fusion 14 AIR Jordans 15Nike Jordan
16 Fusion Jordan 17 shoes Nike Air Jordans 18 XVIII  Force 1 Jordan
Fusion AJF18 AJF18 AJ18F Jordan 18 fusions
(paypal payment)(www.youtetrade.com )


AIR Jordan Fusions 7 NIKE Jordan Fusion 8 AIR Jordans 9 Nikes Jordan
Fusion 10 Jordan 11 shoes Nike Air Jordan 12 XII  Force 1 Jordan
Fusion AJF 12 AJF12 AJ12F Jordans 12 fusions
(paypal payment)(www.youtetrade.com )


NIKE AIR JORDAN FORCE FUSION SHOES AJF 5 V JORDANs 5 FUSION NIKE
JORDAN 5 FUSION SHOES AJF5 Nike Air Jordan XXIII 23 Force 1 Jordan
Fusion AJF 23 AJF23 AJ23F
(paypal payment)(www.youtetrade.com )


Nike Jordans Fusion 23 AIR Jordan 22 Jordan Fusions 21 AIR Jordans
Fusion 20 Jordan 19 shoes Air Jordan Force Fusion VIII (8), AJF 8
Nike (paypal payment)(www.youtetrade.com )
Air Jordan 17 XVII  Force 1 Jordan Fusions AJF 17 AJF17 AJ17F Jordan
our website : www.youtetrade.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: lint for Python?

2008-10-06 Thread Wolfgang Grafen

No need to develop another lint tool. Just give the creator of pylint an
improvement proposal. This can be at least reported as a warning.

Even in a highly dynamic language like Python it is good to follow some
style guides. I try to avoid the same names if possible for different
functionality. This makes the code much more manageable and maintainable 
and understandable for larger projects.


Pat schrieb:
I've been searching for a good multi-module lint checker for Python and 
I haven't found one yet.


Pylint does a decent job at checking for errors only within a single 
module.


Here's one of my problems.  I have two modules.

In module one, I have a function:

def foo( host, userid, password ):
pass

In module two, I call that function:

foo( userid, password)

lint doesn't find that error and it won't be caught until it's called 
while the program is running.  I don't want that error found at 3AM.


I've never used a language that didn't catch that type of error.  I'm 
quite surprised that Python is being used by a number of major 
companies.  How you catch these types of errors?


I've spoken to tech support at Wing and they weren't aware of a 
multi-module lint but they're considering putting their own lint into 
their IDE.


Thank you

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


Re: 2to3 refactoring [was Re: Tuple parameter unpacking in 3.x]

2008-10-06 Thread Harald Luessen
On Sun, 05 Oct 2008 "Aaron \"Castironpi\" Brady" wrote:

>There's the possibility that the most important words should go first in 
>this case:
>
>result_flag__t
>
>But, I'll admit that other people could have learned different orders of 
>scanning words than I, especially depending on their spoken language 
>backgrounds.  A poll of the newsgroup isn't exactly academically 
>impartial sampling, but there aren't any better ways to make decisions, 
>are there?  (I think it would be easy to make either one a habit.)
>
>Here's the other option in the same context:
>
>def function(vocab_list, result_flag__t, max_value):
> result, flag = result_flag__t
> pass
>
>To be thorough, there's also a trailing double underscore option.
>
>def function(vocab_list, result_flag__, max_value):
> result, flag = result_flag__
> pass
>
>Which I don't recognize from any other usages, but I defer.  If there 
>aren't any, conditionally, I think this is my favorite.

t__result_flag and result_flag__t have the advantage that you can 
search for t__ or __t as start or end of a name if you want to 
find and change all these places in the source. You can compare 
it with the decision to use reinterpret_cast(...) as a cast 
operator in C++. It is ugly but much easier to find than (long)...
A search for __ alone would have too many hits in Python.

Harald

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


Re: Python 2.6: Determining if a method is inherited

2008-10-06 Thread Terry Reedy

Fuzzyman wrote:

On Oct 5, 11:54 pm, Terry Reedy <[EMAIL PROTECTED]> wrote:

Fuzzyman wrote:

Hello all,
I may well be being dumb (it has happened before), but I'm struggling
to fix some code breakage with Python 2.6.
I have some code that looks for the '__lt__' method on a class:
if hasattr(clr, '__lt__'):
However - in Python 2.6 object has grown a default implementation of
'__lt__', so this test always returns True.

class X(object): pass

...

X.__lt__



X.__lt__ == object.__lt__

False

In 3.0, the test returns true because function attributes only get
wrapped when bound.  In the meanwhile, " 'object' in repr(X.__lt__)"
should do it for you.



So long as its never used on a class with 'object' in the name.
Doesn't sound like a particularly *good* solution to me. :-)


From what you posted, 'type object at' should work.

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


Re: Python 2.6 / 3.0: Determining if a method is inherited

2008-10-06 Thread Aaron "Castironpi" Brady
On Oct 6, 4:30 am, Fuzzyman <[EMAIL PROTECTED]> wrote:
> On Oct 6, 1:13 am, MRAB <[EMAIL PROTECTED]> wrote:
>
>
>
> > Fuzzyman wrote:
> > > Hello all,
>
> > > I may well be being dumb (it has happened before), but I'm struggling
> > > to fix some code breakage with Python 2.6.
>
> > > I have some code that looks for the '__lt__' method on a class:
>
> > > if hasattr(clr, '__lt__'):
>
> > > However - in Python 2.6 object has grown a default implementation of
> > > '__lt__', so this test always returns True.
>
> > > >>> class X(object): pass
> > > ...
> > > >>> X.__lt__
> > > 
> > > >>> X.__lt__ == object.__lt__
> > > False
>
> > > So how do I tell if the X.__lt__ is inherited from object? I can look
> > > in the '__dict__' of the class - but that doesn't tell me if X
> > > inherits '__lt__' from a base class other than object. (Looking inside
> > > the method wrapper repr with a regex is not an acceptable answer...)
>
> > > Some things I have tried:
>
> > > >>> X.__lt__.__self__
> > > 
> > > >>> dir(X.__lt__)
> > > ['__call__', '__class__', '__cmp__', '__delattr__', '__doc__',
> > > '__format__', '__getattribute__', '__hash__', '__init__', '__name__',
> > > '__new__', '__objclass__', '__reduce__', '__reduce_ex__', '__repr__',
> > > '__self__', '__setattr__', '__sizeof__', '__str__',
> > > '__subclasshook__']
> > > >>> X.__lt__.__func__
> > > Traceback (most recent call last):
> > >   File "", line 1, in 
> > > AttributeError: 'method-wrapper' object has no attribute '__func__'
>
> > > Hmmm... I can get this working with Python 2.6 with:
>
> > > if '__lt__' in dir(cls):
>
> > > The default implementation of '__lt__' doesn't appear in the dir of
> > > classes. However this fails with Python 3 where the default
> > > implementation *does* appear in the output of 'dir'. Any suggestions?
>
> > Methods are objects. How do you know if two references refer to the
> > same object? You use "is":
>
> > X.__lt__ is object.__lt__
>
> Didn't you see that even an equality test fails - so they are not the
> same (that being the problem)...
>
> They are unbound method objects - in Python 3 the unbound method has
> gone away, so the problem is with Python 2.6.
>
> Michael
> --http://www.ironpythoninaction.com/

Not tested extensively.

class NoLTException( Exception ): pass

class NoLT( object ):
def __lt__( self, other ):
raise NoLTException()

class A( NoLT ):
pass

class B( A ):
def __lt__( self, other ):
return self

def test_lt( obj ):
try:
obj.__lt__( None )
except NoLTException:
return False
except:
pass
return True

>>> a= A()
>>> b= B()
>>> test_lt( a )
False
>>> test_lt( b )
True
>>>

This method won't work for arbitrary classes, only ones that you
control, that inherit from 'NoLT'.  The 'test_lt' function works by
trying to call '__lt__' on its argument.  The parameter to it doesn't
matter because of what happens next.  If '__lt__' raises a
NoLTException, you know it was inherited from NoLT.  Otherwise, even
if another exception occurs, the object you know has '__lt__'.

It's a very object oriented solution.  Essentially you're inheriting
all the classes that you want to fail, from a class that does.
--
http://mail.python.org/mailman/listinfo/python-list


Re: When Python should not be used?

2008-10-06 Thread Stef Mientki

Andrea Francia wrote:

The right tool depends on the current problem.

While some python users prefer to talk about when Python is the right 
tool I think that it is more instructive to know when it is not.


Please, could you let me know what do you think about that?

Thanks

I'm programming in Python now for about a year,
so I'm definitely not an expert,
but this friendly list will correct me I'm wrong.
Here is what I can come up with
- design of GUI is difficult (despite all those well meant programs, of 
which I couldn't get one of them working)

- autoit like applications
- low level drivers
- licenses differ a lot, which makes it hard to combine different packages
- downwards compatibility is sometimes lost
- a number of libraries is quite in-mature
but for the rest, it's a beautiful language,
and I'm working on a large application,
which should be open source replacement for MatLab + LabView.

cheers,
Stef

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


do something in time interval

2008-10-06 Thread Petr Jakes
I have infinitive loop running script and I would like to check
something periodically after 5 seconds (minutes, hours...) time period
(I do not mean time.sleep(5) ). Till now, I have following script, but
I think there must be something more elegant.

eventFlag = False
while 1:
time.sleep(0.01)
seconds = time.time()
if not int(seconds % (5)):
if eventFlag:
print "5 seconds, hurray"
eventFlag = False
else:
eventFlag = True

Best regards

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


Re: how to get the thighest bit position in big integers?

2008-10-06 Thread Fredrik Johansson
On Oct 5, 5:26 pm, [EMAIL PROTECTED] wrote:
> Hi,
>
> My question to the group: Does anyone know of a non-hackish way to
> determine the required bit position in python? I know that my two
> ideas
> can be combined to get something working. But is there a *better* way,
> that isn't that hackish?

No non-hackish way.

I've myself needed a version of this function for a speed-critical
application. For my purposes, it needs to be fast both for small and
extremely large numbers; the following is the fastest version I've
come up with. The idea to use bisect with a precomputed list when
possible, and math.log (with a correction) for larger numbers. There's
a tradeoff: a longer bisect table makes it fast for larger number, but
the bisection also becomes slower for small numbers. For my
application, 300 turned out to be a reasonable compromise.

from bisect import bisect
from math import log

powers = [1<<_ for _ in range(300)]

def bitcount(n):
bc = bisect(powers, n)
if bc != 300:
return bc
bc = int(log(n, 2)) - 4
return bc + bctable[n>>bc]

bctable = map(bitcount, range(1024))

Calling this function is still slow, so when possible, I track the
approximate number of bits in a number across operations, and do (bc
+bctable[n>>bc]) inline (where bc is a low estimate of the number of
bits) to obtain the exact bit count.

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


Re: Python 2.6 / 3.0: Determining if a method is inherited

2008-10-06 Thread Fuzzyman
On Oct 6, 7:01 pm, "Aaron \"Castironpi\" Brady" <[EMAIL PROTECTED]>
wrote:
> On Oct 6, 4:30 am, Fuzzyman <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Oct 6, 1:13 am, MRAB <[EMAIL PROTECTED]> wrote:
>
> > > Fuzzyman wrote:
> > > > Hello all,
>
> > > > I may well be being dumb (it has happened before), but I'm struggling
> > > > to fix some code breakage with Python 2.6.
>
> > > > I have some code that looks for the '__lt__' method on a class:
>
> > > > if hasattr(clr, '__lt__'):
>
> > > > However - in Python 2.6 object has grown a default implementation of
> > > > '__lt__', so this test always returns True.
>
> > > > >>> class X(object): pass
> > > > ...
> > > > >>> X.__lt__
> > > > 
> > > > >>> X.__lt__ == object.__lt__
> > > > False
>
> > > > So how do I tell if the X.__lt__ is inherited from object? I can look
> > > > in the '__dict__' of the class - but that doesn't tell me if X
> > > > inherits '__lt__' from a base class other than object. (Looking inside
> > > > the method wrapper repr with a regex is not an acceptable answer...)
>
> > > > Some things I have tried:
>
> > > > >>> X.__lt__.__self__
> > > > 
> > > > >>> dir(X.__lt__)
> > > > ['__call__', '__class__', '__cmp__', '__delattr__', '__doc__',
> > > > '__format__', '__getattribute__', '__hash__', '__init__', '__name__',
> > > > '__new__', '__objclass__', '__reduce__', '__reduce_ex__', '__repr__',
> > > > '__self__', '__setattr__', '__sizeof__', '__str__',
> > > > '__subclasshook__']
> > > > >>> X.__lt__.__func__
> > > > Traceback (most recent call last):
> > > >   File "", line 1, in 
> > > > AttributeError: 'method-wrapper' object has no attribute '__func__'
>
> > > > Hmmm... I can get this working with Python 2.6 with:
>
> > > > if '__lt__' in dir(cls):
>
> > > > The default implementation of '__lt__' doesn't appear in the dir of
> > > > classes. However this fails with Python 3 where the default
> > > > implementation *does* appear in the output of 'dir'. Any suggestions?
>
> > > Methods are objects. How do you know if two references refer to the
> > > same object? You use "is":
>
> > > X.__lt__ is object.__lt__
>
> > Didn't you see that even an equality test fails - so they are not the
> > same (that being the problem)...
>
> > They are unbound method objects - in Python 3 the unbound method has
> > gone away, so the problem is with Python 2.6.
>
> > Michael
> > --http://www.ironpythoninaction.com/
>
> Not tested extensively.
>
> class NoLTException( Exception ): pass
>
> class NoLT( object ):
>     def __lt__( self, other ):
>             raise NoLTException()
>
> class A( NoLT ):
>     pass
>
> class B( A ):
>     def __lt__( self, other ):
>             return self
>
> def test_lt( obj ):
>     try:
>             obj.__lt__( None )
>     except NoLTException:
>             return False
>     except:
>             pass
>     return True
>
>
>
> >>> a= A()
> >>> b= B()
> >>> test_lt( a )
> False
> >>> test_lt( b )
> True
>
> This method won't work for arbitrary classes, only ones that you
> control, that inherit from 'NoLT'.  The 'test_lt' function works by
> trying to call '__lt__' on its argument.  The parameter to it doesn't
> matter because of what happens next.  If '__lt__' raises a
> NoLTException, you know it was inherited from NoLT.  Otherwise, even
> if another exception occurs, the object you know has '__lt__'.
>
> It's a very object oriented solution.  Essentially you're inheriting
> all the classes that you want to fail, from a class that does.

But not a very good solution to the problem...

The specific problem is to determine if an arbitrary class implements
a specified comparison method. The general problem (that gives rise to
the specific problem) is to write a class decorator that can implement
all comparison methods from a class that implements only one.

See: http://code.activestate.com/recipes/576529/

Michael
--
http://www.ironpythoninaction.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: how to get the thighest bit position in big integers?

2008-10-06 Thread Aaron "Castironpi" Brady
On Oct 6, 3:37 am, Mark Dickinson <[EMAIL PROTECTED]> wrote:
> On Oct 5, 11:40 pm, Terry Reedy <[EMAIL PROTECTED]> wrote:
>
> > Your point, that taking floor(log2(x)) is redundant, is a good catch.
> > However, you should have added 'untested' ;-).  When value has more
> > significant bits than the fp mantissa can hold, this expression can be 1
> > off (but no more, I assume).   The following correction should be
> > sufficient:
>
> > res = math.frexp(value)[1] - EXP_OF_ONE
> > test = 1< > if test > r:     res -= 1
> > elif 2*test < r: res += 1
>
> > For value = 2**n -1, n > 53, it is always 1 too high on my Intel
> > machine, so the first correction is sometimes needed.  I do not know if
> > the second is or not.
>
> See alsohttp://bugs.python.org/issue3439
> where there's a proposal to expose the _PyLong_NumBits method.  This
> would give an O(1) solution.
>
> Mark

That generates an odd error with ctypes.

>>> from ctypes import *
>>> _PyLong_NumBits= PYFUNCTYPE( c_int, py_object )( pythonapi._PyLong_NumBits )
>>> _PyLong_NumBits( 1<<50 )
Traceback (most recent call last):
  File "_ctypes/callbacks.c", line 295, in 'calling callback function'
ctypes.ArgumentError: argument 1: :
long int to
o long to convert
2227205
>>>

Seems 'ctypes' tries to call PyLong_AsUnsignedLong for you.  Anyone
know a way around it?
--
http://mail.python.org/mailman/listinfo/python-list


Re: When Python should not be used?

2008-10-06 Thread cstorey
On Oct 6, 2:07 pm, Stef Mientki <[EMAIL PROTECTED]> wrote:

> and I'm working on a large application,
> which should be open source replacement for MatLab + LabView.
>
> cheers,
> Stef

An Open Source Labview replacement would be really useful!  Any
preview of the project?

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


Re: Python 2.6 / 3.0: Determining if a method is inherited

2008-10-06 Thread Aaron "Castironpi" Brady
On Oct 6, 1:17 pm, Fuzzyman <[EMAIL PROTECTED]> wrote:
> On Oct 6, 7:01 pm, "Aaron \"Castironpi\" Brady" <[EMAIL PROTECTED]>
> wrote:
> > It's a very object oriented solution.  Essentially you're inheriting
> > all the classes that you want to fail, from a class that does.
>
> But not a very good solution to the problem...
>
> The specific problem is to determine if an arbitrary class implements
> a specified comparison method. The general problem (that gives rise to
> the specific problem) is to write a class decorator that can implement
> all comparison methods from a class that implements only one.
>
> See:http://code.activestate.com/recipes/576529/
>
> Michael
> --http://www.ironpythoninaction.com/

Nope, I'm out of ideas, I'm afraid.
--
http://mail.python.org/mailman/listinfo/python-list


python -Ms-Word

2008-10-06 Thread gita saleh
Hello Everyone,

I'd like to add header and footer to ms-word using python. Any hint would be
appreciated.

Thanks,

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


Re: do something in time interval

2008-10-06 Thread Leon Zhang
Petr,

I am not an expert, but why not to use time.sleep(5)?
If you are using wxPython, you may also try wx.Timer, in which you could set
its interval.

Good luck!
Leon

On Tue, Oct 7, 2008 at 2:07 AM, Petr Jakes <[EMAIL PROTECTED]> wrote:

> I have infinitive loop running script and I would like to check
> something periodically after 5 seconds (minutes, hours...) time period
> (I do not mean time.sleep(5) ). Till now, I have following script, but
> I think there must be something more elegant.
>
> eventFlag = False
> while 1:
>time.sleep(0.01)
>seconds = time.time()
>if not int(seconds % (5)):
>if eventFlag:
>print "5 seconds, hurray"
>eventFlag = False
>else:
>eventFlag = True
>
> Best regards
>
> Petr Jakes
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list


RE: When Python should not be used?

2008-10-06 Thread Blubaugh, David A.
Stef,

May I see your open-source version of a combined Matlab + Labview
program?  Is there a website, I may visit??  


Thanks,


David Blubaugh


 

-Original Message-
From: Stef Mientki [mailto:[EMAIL PROTECTED] 
Sent: Monday, October 06, 2008 2:07 PM
To: [email protected]
Subject: Re: When Python should not be used?

Andrea Francia wrote:
> The right tool depends on the current problem.
>
> While some python users prefer to talk about when Python is the right 
> tool I think that it is more instructive to know when it is not.
>
> Please, could you let me know what do you think about that?
>
> Thanks
I'm programming in Python now for about a year, so I'm definitely not an
expert, but this friendly list will correct me I'm wrong.
Here is what I can come up with
- design of GUI is difficult (despite all those well meant programs, of
which I couldn't get one of them working)
- autoit like applications
- low level drivers
- licenses differ a lot, which makes it hard to combine different
packages
- downwards compatibility is sometimes lost
- a number of libraries is quite in-mature but for the rest, it's a
beautiful language, and I'm working on a large application, which should
be open source replacement for MatLab + LabView.

cheers,
Stef



This e-mail transmission contains information that is confidential and may be 
privileged. It is intended only for the addressee(s) named above. If you 
receive 
this e-mail in error, please do not read, copy or disseminate it in any manner. 
If you are not the intended recipient, any disclosure, copying, distribution or 
use of the contents of this information is prohibited. Please reply to the 
message immediately by informing the sender that the message was misdirected. 
After replying, please erase it from your computer system. Your assistance in 
correcting this error is appreciated.

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


Re: do something in time interval

2008-10-06 Thread Terry Reedy

Petr Jakes wrote:

I have infinitive loop running script and I would like to check
something periodically after 5 seconds (minutes, hours...) time period
(I do not mean time.sleep(5) ). Till now, I have following script, but
I think there must be something more elegant.

eventFlag = False
while 1:
time.sleep(0.01)
seconds = time.time()
if not int(seconds % (5)):
if eventFlag:
print "5 seconds, hurray"
eventFlag = False
else:
eventFlag = True


The eventFlag is confusing.  Better:

dt = 5 # for instance
event_time = time.time()
while 1:
  #do every loop stuff
  now = time.time()
  if now >= event_time:
event_time = now + dt
event()

If you have multiple delayed events, quite possibly each with a 
different or even variable delta, store (future_time,func_to_call) pairs 
in a priority queue (heapq module).


Terry Jan Reedy

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


Re: lint for Python?

2008-10-06 Thread Bruno Desthuilliers

Pat a écrit :
I've been searching for a good multi-module lint checker for Python and 
I haven't found one yet.


Pylint does a decent job at checking for errors only within a single 
module.


Here's one of my problems.  I have two modules.

In module one, I have a function:

def foo( host, userid, password ):
pass

In module two, I call that function:

foo( userid, password)

lint doesn't find that error


Nope, but even the most simple manual test should find it pretty quick.

and it won't be caught until it's called 
while the program is running.  I don't want that error found at 3AM.


Don't you ever test your code ???


I've never used a language that didn't catch that type of error.


It does. Just try to run your code, and you'll have a nice traceback. 
Unless of course 'foo' is rebound in module two to another callable 
expecting only two parameters...


 I'm 
quite surprised that Python is being used by a number of major 
companies.


Perhaps do they rely more on testing and less on the compiler ? FWIW, 
I've seen my share of bugs in declarativly statically typed languages, 
and most of them were way nastier (and way less obvious) than the above one.



 How you catch these types of errors?


Just like any other type of errors : testing, testing, and then add some 
more tests.


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


Re: PyOpenGL double-buffered hardware surface

2008-10-06 Thread Clay Hobbs

On Sun, 2008-10-05 at 14:16 -0400, Mike C. Fletcher wrote:
> Clay Hobbs wrote:
> > How do I create a double-buffered hardware surface with PyOpenGL?  I
> > knew how to once, but forgot.
> >
> >   
> Depends on your GUI library, most of them have a flag-set that you pass 
> to the initializer of the OpenGL-holding widget.  If you're using 
> Pygame, see Pygame's display module.  If wxPython, see their GLcanvas 
> object.  If GLUT, see glutInitDisplayMode, etceteras.
> 
> Good luck,
> Mike
> 

I'm using wxPython.  My real problem is that everything flashes when it
moves.  I thought the way to fix this was to make a double-buffered
hardware surface, but I may be wrong.  Thank you for the help so far,

--Ratfink

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


Re: Python 2.6 / 3.0: Determining if a method is inherited

2008-10-06 Thread Fuzzyman
On Oct 6, 7:23 pm, "Aaron \"Castironpi\" Brady" <[EMAIL PROTECTED]>
wrote:
> On Oct 6, 1:17 pm, Fuzzyman <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Oct 6, 7:01 pm, "Aaron \"Castironpi\" Brady" <[EMAIL PROTECTED]>
> > wrote:
> > > It's a very object oriented solution.  Essentially you're inheriting
> > > all the classes that you want to fail, from a class that does.
>
> > But not a very good solution to the problem...
>
> > The specific problem is to determine if an arbitrary class implements
> > a specified comparison method. The general problem (that gives rise to
> > the specific problem) is to write a class decorator that can implement
> > all comparison methods from a class that implements only one.
>
> > See:http://code.activestate.com/recipes/576529/
>
> > Michael
> > --http://www.ironpythoninaction.com/
>
> Nope, I'm out of ideas, I'm afraid.

Thankfully that page I pointed you to has the solution I came up with
- walk the method resolution order of the class checking in the
classes' '__dict__' to see what they explicitly implement.

Given that you can get hold of X.__lt__ I was surprised by how hard it
was to tell whether that was an inherited implementation or not.

Michael
--
http://www.ironpythoninaction.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: do something in time interval

2008-10-06 Thread Jerry Hill
On Mon, Oct 6, 2008 at 2:07 PM, Petr Jakes <[EMAIL PROTECTED]> wrote:
> I have infinitive loop running script and I would like to check
> something periodically after 5 seconds (minutes, hours...) time period
> (I do not mean time.sleep(5) ). Till now, I have following script, but
> I think there must be something more elegant.

Take a look at the sched module.
http://www.python.org/doc/2.5.2/lib/module-sched.html

> eventFlag = False
> while 1:
>time.sleep(0.01)
>seconds = time.time()
>if not int(seconds % (5)):
>if eventFlag:
>print "5 seconds, hurray"
>eventFlag = False
>else:
>eventFlag = True

Using sched, I think you would re-write this as:

import sched, time
s=sched.scheduler(time.time, time.sleep)

def do_event():
print "5 seconds, hurray!"
s.enter(5, 1, do_event, ())

s.enter(5, 1, do_event, ())
s.run()

That will run do_event() after five seconds, and then do_event() puts
itself back in the queue to be executed in another 5 seconds.

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


Favorite Python System Administration Examples

2008-10-06 Thread Steve Holden
I'm giving a talk at LISA this year, and while the slides are ready I
would like to go armed with as many examples of good system
administration code as possible.

If you have a favorite administration tool that you wouldn't mind me
using I'd love to know about it. Feel free to email me personally or
submit via the list.

regards
 Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.com/

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


Re: do something in time interval

2008-10-06 Thread Petr Jakeš
>
> I am not an expert, but why not to use time.sleep(5)?
> If you are using wxPython, you may also try wx.Timer, in which you could
> set its interval.
>
>
Thanks for your reply.
During the 5s period my script has to do some stuff instead of sleeping.
Thats why it runs in the loop and once in 5s period it has to trigger some
other stuff(function, method, action) to do.
Petr Jakes
--
http://mail.python.org/mailman/listinfo/python-list


Is PyFIT dead and abandoned?

2008-10-06 Thread oakley
I was wanting to experiment with PyFIT but it seems DOA. Googling
doesn't yield any information less than two years old. When I try to
install 0.8a2 I get errors because setup.py references a non-existant
file (FitFilter.py). I find it hard to believe that in two years
nobody has stumbled over this unless there's simply no one using it.

Has PyFIT been completely abandoned? Is there a better alternative or
other resources to help me integrate fitnesse and python?

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


Re: Builing Python 2.6 on AIX 5.2

2008-10-06 Thread pruebauno
On Oct 6, 11:03 am, "Jesse Noller" <[EMAIL PROTECTED]> wrote:
> Looks like AIX is missing sem_timedwait - see:http://bugs.python.org/issue3876
>
> Please add your error to the bug report just so I can track it.
>
> -jesse
>
> On Mon, Oct 6, 2008 at 4:16 AM, brasse <[EMAIL PROTECTED]> wrote:
> > Hello!
>
> > I am having some trouble building Python 2.6 on AIX. The steps I have
> > taken are:
>
> > export PATH=/usr/bin/:/usr/vacpp/bin/
> > ./configure --with-gcc=xlc_r --with-cxx=xlC_r --disable-ipv6
> > make
>
> > This is the error message I'm seeing:
> > ./Modules/ld_so_aix xlc_r -bI:Modules/python.exp build/
> > temp.aix-5.2-2.6/home/mabr/Python-2.6/Modules/_multiprocessing/
> > multiprocessing.o build/temp.aix-5.2-2.6/home/mabr/Python-2.6/Modules/
> > _multiprocessing/socket_connection.o build/temp.aix-5.2-2.6/home/mabr/
> > Python-2.6/Modules/_multiprocessing/semaphore.o -L/usr/local/lib -o
> > build/lib.aix-5.2-2.6/_multiprocessing.so
> > ld: 0711-317 ERROR: Undefined symbol: .sem_timedwait
> > ld: 0711-317 ERROR: Undefined symbol: .CMSG_SPACE
> > ld: 0711-317 ERROR: Undefined symbol: .CMSG_LEN
> > ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more
> > information.
> > *** WARNING: renaming "_multiprocessing" since importing it failed: No
> > such file or directory
> > error: No such file or directory
> > make: The error code from the last command is 1.
>
> > Have someone on this list had similar problems? Am I missing some
> > libraries? The configure script runs without errors, I would have
> > expected some kind of error there if I was missing something.
>
> > Regards,
> > Mattias
> > --
> >http://mail.python.org/mailman/listinfo/python-list

FYI
I read that some people use:
HAVE_BROKEN_POSIX_SEMAPHORES in pyconfig.h.

for AIX, although I never do. Maybe I am not doing anything advanced
enough for problems related to semaphores to show up.
--
http://mail.python.org/mailman/listinfo/python-list


Re: do something in time interval

2008-10-06 Thread D'Arcy J.M. Cain
On Mon, 6 Oct 2008 21:13:21 +0200
"Petr Jake?" <[EMAIL PROTECTED]> wrote:
> > I am not an expert, but why not to use time.sleep(5)?
> >
> During the 5s period my script has to do some stuff instead of sleeping.
> Thats why it runs in the loop and once in 5s period it has to trigger some
> other stuff(function, method, action) to do.

Then check out http://www.python.org/doc/current/library/select.html

-- 
D'Arcy J.M. Cain <[EMAIL PROTECTED]> |  Democracy is three wolves
http://www.druid.net/darcy/|  and a sheep voting on
+1 416 425 1212 (DoD#0082)(eNTP)   |  what's for dinner.
--
http://mail.python.org/mailman/listinfo/python-list


Re: do something in time interval

2008-10-06 Thread Mathieu Prevot
2008/10/6 Petr Jakeš <[EMAIL PROTECTED]>:
>> I am not an expert, but why not to use time.sleep(5)?
>> If you are using wxPython, you may also try wx.Timer, in which you could
>> set its interval.
>>
>
> Thanks for your reply.
> During the 5s period my script has to do some stuff instead of sleeping.
> Thats why it runs in the loop and once in 5s period it has to trigger some
> other stuff(function, method, action) to do.
> Petr Jakes

You might want to use threads so you have a very simple code like this:

data data0

thread1:
while True:
  time.sleep(5)
  doSomething(data0)

thread2:
while True:
  time.sleep(0.01)
 doAnotherthing(data0)

thread1 and thread2 can run in parallel; if thread2 take more time,
thread1 won't be impaired.

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


Re: When Python should not be used?

2008-10-06 Thread Stef Mientki

David, Craig,

Thanks for your interest.
Here are a few examples, containing links to some animations
 
http://oase.uci.kun.nl/~mientki/data_www/pylab_works/pw_animations_screenshots.html

and here is a collection of my notes until july this year:
 http://pylab-works.googlecode.com/files/pw_manual.pdf
I'm now trying to make an installation,
and hope to release an alfa version in the next couple of weeks)

cheers,
Stef


Blubaugh, David A. wrote:

Stef,

May I see your open-source version of a combined Matlab + Labview
program?  Is there a website, I may visit??  



Thanks,


David Blubaugh


  


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


Re: I built a nice html templater!

2008-10-06 Thread Eric S. Johansson
Steve Holden wrote:
> Tim Roberts wrote:
>> Derick van Niekerk <[EMAIL PROTECTED]> wrote:
>>> Ok - so it's not really an awesome achievement and only handles basic
>>> templating needs (no loops and other programming constructs) but maybe
>>> someone will find it useful.
>> 
>> Sure, that's what the world needed.  We didn't have enough Python HTML
>> templaters already.
>> 
>>
>> Did you take even 3 minutes to look for a solution before you wrote this?
>> There is even a nearly identical solution in the Python cookbook.
> 
> While I agree it was a little naive to expect a huge amount of interest
> I think there's educational value in building a templating system of
> your own. Sarcasm id the lowest form of wit, and there's no real need
> for it here. You'd have been better saving your ire for someone who
> really deserves it. Sadly there are plenty around.

my replication of work was motivated by a very different need.  I built a web
framework that is friendly to speech recognition users. It uses plain English
words and very little special punctuation.  the internal CGI environment is also
very simple in case you have a memory deficit and need to refresh your memory on
the functionality between uses.  Almost every HTML template system, and web
framework I've seen look like they are designed to exclude disabled users.
Special punctuation, special spacing rules, non-English character sequences,
complex APIs, and lots of APIs say to the world "no disabled need apply".

Before you protest and say that disabled users are a special case, remember that
almost everyone becomes disabled as a result of aging or accident.  a simple
broken wrist or arm could keep you from doing your job.  arthritis and other
joint disorders will make keyboards something you cannot stand the touch.  you
will not escape needing some form of accessibility tools if you decide to keep
using computers.

Now you're faced with a choice.  Do you want to design and build things that you
will not be able to use at some point or do you want to build systems that can
be used by you now, and you in the future.  let me play from personal
experience, it's far easier to build accessible systems before you need them
than after.
--
http://mail.python.org/mailman/listinfo/python-list


Re: lint for Python?

2008-10-06 Thread Pat

Bruno Desthuilliers wrote:

Pat a écrit :
I've been searching for a good multi-module lint checker for Python 
and I haven't found one yet.


Pylint does a decent job at checking for errors only within a single 
module.


Here's one of my problems.  I have two modules.

In module one, I have a function:

def foo( host, userid, password ):
pass

In module two, I call that function:

foo( userid, password)

lint doesn't find that error


Nope, but even the most simple manual test should find it pretty quick.

and it won't be caught until it's called while the program is 
running.  I don't want that error found at 3AM.


Don't you ever test your code ???


I've never used a language that didn't catch that type of error.


It does. Just try to run your code, and you'll have a nice traceback. 
Unless of course 'foo' is rebound in module two to another callable 
expecting only two parameters...


 I'm quite surprised that Python is being used by a number of major 
companies.


Perhaps do they rely more on testing and less on the compiler ? FWIW, 
I've seen my share of bugs in declarativly statically typed languages, 
and most of them were way nastier (and way less obvious) than the above 
one.



 How you catch these types of errors?


Just like any other type of errors : testing, testing, and then add some 
more tests.




I haven't gotten into unittesting.  I've just started learning Python.

It also dawned on me why my original question is a bit lame.  Python 
supports default arguments; something that is new to me.  How could lint 
possibly know the correct number of arguments passed to it?  Unless, of 
course, lint knew which functions had default arguments or not.


I'll come back with more intelligent questions after I've actually 
learned some Python.

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


function(s) to decode a URL produced by encodeURIComponent in javascript

2008-10-06 Thread Merrick
I encoded a URL in javascript and would like to decode it in python.
The urllib.unquote does not have an optional safe argument and I
cannot find how to do urldecode.
--
http://mail.python.org/mailman/listinfo/python-list


Re: lint for Python?

2008-10-06 Thread George Sakkis
On Oct 6, 3:49 pm, Pat <[EMAIL PROTECTED]> wrote:

> I'll come back with more intelligent questions after I've actually
> learned some Python.

That's a wise self-advice ;-)
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.6: Determining if a method is inherited

2008-10-06 Thread Fuzzyman
On Oct 6, 7:02 pm, Terry Reedy <[EMAIL PROTECTED]> wrote:
> Fuzzyman wrote:
> > On Oct 5, 11:54 pm, Terry Reedy <[EMAIL PROTECTED]> wrote:
> >> Fuzzyman wrote:
> >>> Hello all,
> >>> I may well be being dumb (it has happened before), but I'm struggling
> >>> to fix some code breakage with Python 2.6.
> >>> I have some code that looks for the '__lt__' method on a class:
> >>> if hasattr(clr, '__lt__'):
> >>> However - in Python 2.6 object has grown a default implementation of
> >>> '__lt__', so this test always returns True.
> >> class X(object): pass
> >>> ...
> >> X.__lt__
> >>> 
> >> X.__lt__ == object.__lt__
> >>> False
> >> In 3.0, the test returns true because function attributes only get
> >> wrapped when bound.  In the meanwhile, " 'object' in repr(X.__lt__)"
> >> should do it for you.
> > So long as its never used on a class with 'object' in the name.
> > Doesn't sound like a particularly *good* solution to me. :-)
>
>  From what you posted, 'type object at' should work.

It's still a hack...
--
http://mail.python.org/mailman/listinfo/python-list


tcl/tk version confusion with tkinter in Python 2.6, on OS X

2008-10-06 Thread njwilson23
I'm having trouble with tkinter on a new installation of Python (2.6),
built with the framework option from source that was downloaded from
python.org. I'm running OS 10.4 on a PowerPC G4.

The problem first arose when I tried to run matplotlib - it couldn't
find tcl/tk because it was searching for 8.5, and I had 8.4. I found
and built tcl/tk 8.5, which led to a new error, reproduced below:

Traceback (most recent call last):
  File "brownian2.py", line 55, in 
main()
  File "brownian2.py", line 41, in main
root = Tk()
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/lib-tk/Tkinter.py", line 1645, in __init__
self._loadtk()
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/
python2.6/lib-tk/Tkinter.py", line 1659, in _loadtk
% (_tkinter.TK_VERSION, tk_version)
RuntimeError: tk.h version (8.4) doesn't match libtk.a version (8.5)

I'm a bit of a neophyte - can anyone tell me how to go about fixing
this? I've found some information by searching the list and Google,
but no helpful solutions.

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


Re: I built a nice html templater!

2008-10-06 Thread Carl Banks
On Oct 2, 3:18 am, Tim Roberts <[EMAIL PROTECTED]> wrote:
> Derick van Niekerk <[EMAIL PROTECTED]> wrote:
> >Ok - so it's not really an awesome achievement and only handles basic
> >templating needs (no loops and other programming constructs) but maybe
> >someone will find it useful.
>
> 
> Sure, that's what the world needed.  We didn't have enough Python HTML
> templaters already.
> 
>
> Did you take even 3 minutes to look for a solution before you wrote this?
> There is even a nearly identical solution in the Python cookbook.

He probably wrote his own faster than it would have taken him to
search for existing systems, and as an added bonus wouldn't have had
to work around all those things that are almost but not quite the way
he wanted.

Cut him some slack.


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


Re: lint for Python?

2008-10-06 Thread Bruno Desthuilliers

Pat a écrit :

Bruno Desthuilliers wrote:

Pat a écrit :


(snip)


 How you catch these types of errors?


Just like any other type of errors : testing, testing, and then add 
some more tests.




I haven't gotten into unittesting.  I've just started learning Python.

It also dawned on me why my original question is a bit lame.


I wouldn't qualify it as 'lame' - even if it could have been expressed 
on a slightly less controversial tone !-)


 Python 
supports default arguments; something that is new to me.


Then prepare for quite a lot of new things...

 How could lint 
possibly know the correct number of arguments passed to it?  Unless, of 
course, lint knew which functions had default arguments or not.


import inspect
inspect.getargspecs(func)


Python is incredibly strong at introspection - even if that doesn't 
solve the kind of "problems" one can possibly have with dynamic typing, 
and yes, dynamism (and not only applied to typing) has its own share of 
drawbacks, like the one you evoked (almost no compile time checking 
except for syntax) and quite a few others. Like any other design 
choices, it's a trade-off. You lose a bit here, and possibly (depending 
on the kind of application and how your neurons are connected) win quite 
a lot there.


From a very pragmatic POV (and Python is mostly a pragmatic language), 
Python is pretty good at getting out of the way while you get the job 
done - which is perhaps why more and more 'major companies' are using 
it. The "downside" is that you lose in (perceived ?) "security" what you 
gain in freedom and flexibility. Some like it, some just can't get used 
to it, and there's no judgement call involved - it's just a matter of 
what better fits your own brain.


wrt/ your question, it's indeed a fact that Python (like any other 
dynamic language FWIW) can't catch this class of errors at compile time. 
So the question 'how do I avoid this kind of error' is mostly sensible.


OTHO, not even Ada would catch the following :
 foo(userid, password, host)
at compile time - unless you define specific distinct types for each 
argument, which might be a bit overkill (well, IMHO at least - YMMV !-).


IOW :  you *do* have to test, whatever the language and type system.

Practically and most of the time, given Python's very quick edit/run 
cycle, you don't even have to write unit tests to catch this kind of 
silly errors - my experience at least. But having unit tests is still 
the best way to ensure you didn't break anything with your last edit. 
While unit testing is not a panacea neither (hint: there's no silver 
bullet), it's really an invaluable tool.



I'll come back with more intelligent questions after I've actually 
learned some Python.


You can even ask "not that intelligent" questions while learning - in 
the worst case, you'll have no anwer at all, but most probably you'll at 
least have a short answer with a link to the relevant documentation.


Welcome onboard !-)
--
http://mail.python.org/mailman/listinfo/python-list


Re: function(s) to decode a URL produced by encodeURIComponent in javascript

2008-10-06 Thread Merrick
On Oct 6, 12:51 pm, Merrick <[EMAIL PROTECTED]> wrote:
> I encoded a URL in javascript and would like to decode it in python.
> The urllib.unquote does not have an optional safe argument and I
> cannot find how to do urldecode.

It looks like urllib.unquote_plus does this, sorry for answering my
own question.
--
http://mail.python.org/mailman/listinfo/python-list


Re: function(s) to decode a URL produced by encodeURIComponent in javascript

2008-10-06 Thread Bruno Desthuilliers

Merrick a écrit :
(answering to itself)


sorry for answering my
own question.


Don't be sorry. You're doing a great service to everyone here by 
letting us know the problem is solved (so we don't bother answering), 
and to everyone that might have the same problem (and is able to use a 
search engine...) by providing the solution.

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


  1   2   >