Re: Python C API String Memory Consumption

2009-04-10 Thread Hrvoje Niksic
a...@pythoncraft.com (Aahz) writes:

> BTW, note that if you're using Python 2.x, range(100) will cause
> a "leak" because ints are never freed.  Instead, use xrange().

Note that using xrange() won't help with that particular problem.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Jython on Google AppEngine.

2009-04-10 Thread Aurélien Campéas

Le 9/04/09 23:51, Tino Wildenhain a écrit :

Jason Scheirer wrote:

On Apr 9, 9:12 am, Alan Kennedy  wrote:

Hi all,

You may be interested to know that you can now run jython 2.2 out of
the box on Google AppEngine, thanks to their new java support.

...


Finally! A way to run Python on App Engine!


?

Is that some kind of weird humor? :-)

T.


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


Re: numpy.where

2009-04-10 Thread Robert Kern

On 2009-04-09 22:40, Peter Pearson wrote:

On Thu, 09 Apr 2009 09:09:18 -0400, Lou Pecora wrote:

Thanks, Neil.  Always something to learn.  I've used Numpy for several
years, but still have not plumbed the depths.  Just tried this script
and, yep, it works.

   arr=array([-1,1.0,2.2,-10.0,1.1, 0.9,-0.9])
   cond= arr<  1.0
   print cond
   brr=arr[cond]
   print brr

Output:

[ True False False  True False  True  True]
[ -1.  -10.0.9  -0.9]

Really,  I've gotta RTFM. :-)


Hey, if you find TFM, please tell me where it is.  I haven't
found anything Fine.  I even bought Travis Oliphant's book,
which helps a little, but . . .


http://docs.scipy.org/doc/numpy/reference/arrays.indexing.html

--
Robert Kern

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

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


Re: Scrap Posts

2009-04-10 Thread Aaron Brady
On Apr 9, 1:28 pm, Grant Edwards  wrote:
> On 2009-04-09, Avi  wrote:
>   2. Filter out everything posted from google groups.
>
>   3. Read the group via the mailing list (which has much better
>      filtering). The mailing list is gatewayed by gmane.org if
>      you prefer web or NNTP access instead of seeing stuff in
>      your inbox.  
>
> I rely mostly on option 2.  You loose some non-spam posts, but
> anybody posting from Google Groups ought not be surprised to be
> lost among the spam.
>
> > Can we clean it up?
>
> Not really, no.  Google could, but they refuse.

What, and part with such a source of revenue?


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


Re: Running an interactive subprocess with Popen

2009-04-10 Thread Diez B. Roggisch

David Liang schrieb:

Hello,
Sorry for the newbie question. How do I run a program that could
block, waiting for user input, using subprocess.Popen? For example,

from subprocess import *

def foo():
a = Popen(['python'] ...)

I want to be able to get input from the user and send input to the
subprocess, printing stdout and stderr as data becomes available, then
return once the subprocess exits. Is it possible to send to the
subprocess keyboard interrupts, EOF, and such?

I tried doing stdout=PIPE, stderr=PIPE, stdin=PIPE. I tried using
communicate(), but could only call it once; subsequent calls raised
"ValueError: I/O operation on closed file."
And both a.stdout.read() and a.stderr.read() blocked the program. Any
help would be much appreciated.



Use pexpect, which emulates a pseudo-terminal speaking with the subprocess.

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


communication between objects - help

2009-04-10 Thread Murali kumar
hi all..
I'm posted in a word doc becoz to add a image to explain my problem..
also I think gmail automatically scans for attachments..

anyway.. here's my problem...( see the image)

http://www.2shared.com/file/5299759/45e4c614/load.html

Using : Python 2.6 , wxPython 2.8.9

 *Scenario:
*In my application , a menu invoking a frame class.

It’s having a wx.notebook control like above. Each notebook page is also a
class. In loadprofile class i'm tried to load a configuration file already
created by application.
 (when pressing load button, current selected config filename in a listbox
must be loaded for application.)

config file data must to be applied to my application object.


 mainApp object  --->  Frame object ( wx.notebook )

  |

  Load profile class

  |

(return config file or data to mainApp object in load button Event handler
function..)


 * I don’t know how to return config file or data to mainApp object when
pressing load button. *


 * Is it easy to return filename only and load the file’s data into mainApp
object in menu handler itself? *


 Please suggest me right direction.. and tell me how to do it?

Usually where I can get these informations.. (suggest links and books..)




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


XMLRPC - persistent object state on server

2009-04-10 Thread Demidov Andrey
Hi, all

I need a XMLRPC server, which works with database and returns data to
the clients.
But I can not find any possibility to keep the object state on server
between the clients calls.

Here is my code:

  1. Server:

from SimpleXMLRPCServer import SimpleXMLRPCServer
from SimpleXMLRPCServer import SimpleXMLRPCRequestHandler

# Restrict to a particular path.
class RequestHandler(SimpleXMLRPCRequestHandler):
rpc_paths = ('/RPC2',)

# Create server
server = SimpleXMLRPCServer(("localhost", 8000),
requestHandler=RequestHandler)
server.register_introspection_functions()

class MyClass:
def __init__(self, a):
self.a = a
# and some heavy works which I would like to do once
def say(self):
return a

cl = MyClass(100)

def return_my_value():
return cl.say()

server.register_function(return_my_value, 'r_v')

# Run the server's main loop
server.serve_forever()

   2. Client:

import xmlrpclib

s = xmlrpclib.ServerProxy('http://localhost:8000')
print s.r_v()

When I'm running client I get this error message:

de...@myhost ~/sources/study/python $ python rpc_client.py
Traceback (most recent call last):
  File "rpc_client.py", line 4, in 
print s.r_v()
  File "/usr/lib/python2.6/xmlrpclib.py", line 1199, in __call__
return self.__send(self.__name, args)
  File "/usr/lib/python2.6/xmlrpclib.py", line 1489, in __request
verbose=self.__verbose
  File "/usr/lib/python2.6/xmlrpclib.py", line 1253, in request
return self._parse_response(h.getfile(), sock)
  File "/usr/lib/python2.6/xmlrpclib.py", line 1392, in _parse_response
return u.close()
  File "/usr/lib/python2.6/xmlrpclib.py", line 838, in close
raise Fault(**self._stack[0])
xmlrpclib.Fault: :global name 'a' is
not defined">


How can I fix it?  Is there any possibility to keep the object state between
the clients calls?

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


Re: XMLRPC - persistent object state on server

2009-04-10 Thread Demidov Andrey
Thank you.
Of course, it is my stupid mistake.

Change:
>  def say(self):
>  return a
>
> to:
>  def say(self):
>  return self.a
>
> Cheers,
> Brian
>
--
http://mail.python.org/mailman/listinfo/python-list


Re: XMLRPC - persistent object state on server

2009-04-10 Thread Brian Quinlan

Demidov Andrey wrote:

class MyClass:
def __init__(self, a):
self.a = a
# and some heavy works which I would like to do once
def say(self):
return a



Change:
  def say(self):
  return a

to:
  def say(self):
  return self.a

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


Multiprocessing module

2009-04-10 Thread Deepak Rokade
Hi All,

I have decided to use multiprocessing module in my application. In brief, my
application fetches files from multiple remote directories and distributes
the received files to one or more remote directories using SFTP.



Since this application is going to be commercial one I want to know at this
stage if there are any known serious bugs (not limitations) in the
multiprocessing module?

Also are there any examples where this module has been used for commercial
applications? Where can I get this information about companies / products
using this particular module?

-- 
Thanx & Regards,
Deepak Rokade
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python C API String Memory Consumption

2009-04-10 Thread Carl Banks
On Apr 9, 11:23 pm, Hrvoje Niksic  wrote:
> a...@pythoncraft.com (Aahz) writes:
> > BTW, note that if you're using Python 2.x, range(100) will cause
> > a "leak" because ints are never freed.  Instead, use xrange().
>
> Note that using xrange() won't help with that particular problem.

I think it will because with xrange the integers will not all have to
exist at one time, so Python doesn't have to increase the size of the
integer pool to a million.


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


Re: calculate field in ARCGIS

2009-04-10 Thread Duncan Booth
MRAB  wrote:

> You might also want to try a triple-quoted string, which makes it
> clearer:
> 
> codeblock = """def codefun(code):
>  if code == 0:
>  return "B"
>  else:
>  return ""
> """
> 

Possibly the clearest way to do something like that is to use a single 
backslash escape and then all the vertical alignment is exactly as you see 
it:

codeblock = """\
def codefun(code):
 if code == 0:
 return "B"
 else:
 return ""
"""
--
http://mail.python.org/mailman/listinfo/python-list


Generating User Search Queries

2009-04-10 Thread Lawrence D'Oliveiro
I implemented a form in a Web-based database-management application that
lets the user search on a whole lot of different fields. I hate writing
repetitive code. But here's part of the sequence I came up with
for translating entered field values into MySQL query phrases:

   condition = \
(
list
( # free-text fields
"%(name)s like %(value)s"
%
{
"name" : field[0],
"value" :
SQLString("%" + 
EscapeSQLWild(Params.getvalue(field[1])) + "%"
),
}
for field in
(
("make", "search_make"),
("model", "search_model"),
...
)
if Params.getvalue(field[1]) != ""
)
+
list
( # exact-match fields
"%(name)s = %(value)s"
%
{
"name" : field[0],
"value" : SQLString(Params.getvalue(field[1])),
}
for field in
(
("class_name", "search_class"),
...

)
if Params.getvalue(field[1]) != ""
)
+
list
( # date fields
"("
+
" or ".join
(
"%(name)s %(op)s %(value)s"
%
{
"name" : field[0],
"op" : op[0],
"value" : SQLString(Params.getvalue(field[1])),
}
for op in
(
("<", "lt"),
("=", "eq"),
(">", "gt"),
)
if GetCheckbox("%(name)s[%(op)s]" % {"name" : field[1], 
"op" : op[1]})
)
+
")"
for field in
(
("when_purchased", "search_when_purchased"),
...
  )
if reduce
(
operator.__or__,
(
GetCheckbox("%(name)s[%(op)s]" % {"name" : 
field[1], "op" : op})
for op in ("lt", "eq", "gt")
)
)
)
)

And then you can build the whole thing into a where-clause just with

" and ".join(condition)


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


Re: communication between objects - help

2009-04-10 Thread Dave Angel



Murali kumar wrote:

hi all..
I'm posted in a word doc becoz to add a image to explain my problem..
also I think gmail automatically scans for attachments..

anyway.. here's my problem...( see the image)

http://www.2shared.com/file/5299759/45e4c614/load.html

Using : Python 2.6 , wxPython 2.8.9


 * I don’t know how to return config file or data to mainApp object when
pressing load button. *


 * Is it easy to return filename only and load the file’s data into mainApp
object in menu handler itself? *


 Please suggest me right direction.. and tell me how to do it?

Usually where I can get these informations.. (suggest links and books..)


Thanks for any advice

  


Most of the widget classes in your code should be derived classes, so 
they can hold extra instance data & event handlers and such.  So that 
means you can have extra parameters on the constructor, besides the ones 
the base class requires.  Use one or more of those extra parameters to 
store your own information about the hierarchy.


Simplest example is to add the app instance to each constructor.  Then 
each widget object would know how to call back into the app to do some 
work, or to load data into a common place.


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


Adding a Badge to an Icon in Mac OS X

2009-04-10 Thread bingo
Hi all,
I have been, now for daysm trying to figure out how to add a badge to
an Icon in Mac OS X. Carbon Icon Services is not documented and I new
to Mac programming. Any help would be greatly appreciated!

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


Re: Python C API String Memory Consumption

2009-04-10 Thread Hrvoje Niksic
Carl Banks  writes:

> On Apr 9, 11:23 pm, Hrvoje Niksic  wrote:
>> a...@pythoncraft.com (Aahz) writes:
>> > BTW, note that if you're using Python 2.x, range(100) will cause
>> > a "leak" because ints are never freed.  Instead, use xrange().
>>
>> Note that using xrange() won't help with that particular problem.
>
> I think it will because with xrange the integers will not all have
> to exist at one time, so Python doesn't have to increase the size of
> the integer pool to a million.

Good catch!  I stand corrected.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Request For Comment

2009-04-10 Thread Esmail

Aahz wrote:

How RFC1 got created:

http://www.nytimes.com/2009/04/07/opinion/07crocker.html


That was great, thanks for posting the link.

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


Can't create list of dictionaries

2009-04-10 Thread sophie_newbie
Hi there,

I've got a function that returns a dictionary, I need to loop and
return 1000 dictionaries and append them to a list, but the thing is
that when I do the list.append(funtThatReturnsDict()) the resulting
only ever has 1 dictionary attached to it, even after running the
append function 1000 times!

I've tried using dict.copy() on the dictionary that was returned from
the function but this didn't work either.

And the function is definately returning different dictionaries each
time as I can see that when I print them.

I know this is something to do with the dictionries being stored as
references but I've no idea how to fix it seeing as the copy()
function didn't work.

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


Re: Can't create list of dictionaries

2009-04-10 Thread sophie_newbie
Scratch everything I said, copy() does work. Made a wee mistake
somewhere else.

Apologies if I've wasted anyones time!


On Apr 10, 12:36 pm, sophie_newbie  wrote:
> Hi there,
>
> I've got a function that returns a dictionary, I need to loop and
> return 1000 dictionaries and append them to a list, but the thing is
> that when I do the list.append(funtThatReturnsDict()) the resulting
> only ever has 1 dictionary attached to it, even after running the
> append function 1000 times!
>
> I've tried using dict.copy() on the dictionary that was returned from
> the function but this didn't work either.
>
> And the function is definately returning different dictionaries each
> time as I can see that when I print them.
>
> I know this is something to do with the dictionries being stored as
> references but I've no idea how to fix it seeing as the copy()
> function didn't work.
>
> Thanks!

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


weird try/finally behaviour

2009-04-10 Thread Sylvain Thénault
Hi there,

I've encountered the following behaviour which I found surprising:

>>> def test():
... for x in ('test', 'tests'):
...  try:
... if True:
...   print 'return'
...   return 1
...  finally:
... print 'break'
... break
... print 'end'
... 
>>> 
>>> test()
return
break
end

As you can see, the 'break' in the finally block makes the 'return 1' beeing 
ignored.
Is this a known caveat or should it be considered as a bug?
-- 
Sylvain Thénault   LOGILAB, Paris (France)
Formations Python, Debian, Méth. Agiles: http://www.logilab.fr/formations
Développement logiciel sur mesure:   http://www.logilab.fr/services
CubicWeb, the semantic web framework:http://www.cubicweb.org

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


Re: Can't create list of dictionaries

2009-04-10 Thread John Machin
On Apr 10, 9:49 pm, sophie_newbie  wrote:
> Scratch everything I said, copy() does work. Made a wee mistake
> somewhere else.
>
> Apologies if I've wasted anyones time!

U ... if think you need a dict.copy() *after* the function has
returned, then you are likely to be doing it in a way that perhaps you
shouldn't make a habit of :-)
--
http://mail.python.org/mailman/listinfo/python-list


Re: weird try/finally behaviour

2009-04-10 Thread Tim Hoffman
Hi Sylvain

You should have a read of the python docs, specifically on try:
finally:

excerpt from docs. --

When a return, break or continue statement is executed in the try
suite of a try...finally statement, the finally clause is also
executed `on the way out.' A continue statement is illegal in the
finally clause. (The reason is a problem with the current
implementation -- this restriction may be lifted in the future).

See ya

Tim


On Apr 10, 7:49 pm, Sylvain Thénault 
wrote:
> Hi there,
>
> I've encountered the following behaviour which I found surprising:
>
> >>> def test():
>
> ...     for x in ('test', 'tests'):
> ...          try:
> ...             if True:
> ...                   print 'return'
> ...                   return 1
> ...          finally:
> ...             print 'break'
> ...             break
> ...     print 'end'
> ...
>
> >>> test()
>
> return
> break
> end
>
> As you can see, the 'break' in the finally block makes the 'return 1' beeing 
> ignored.
> Is this a known caveat or should it be considered as a bug?
> --
> Sylvain Thénault                               LOGILAB, Paris (France)
> Formations Python, Debian, Méth. Agiles:http://www.logilab.fr/formations
> Développement logiciel sur mesure:      http://www.logilab.fr/services
> CubicWeb, the semantic web framework:    http://www.cubicweb.org

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


Re: Can't create list of dictionaries

2009-04-10 Thread Peter Otten
sophie_newbie wrote:

> Hi there,
> 
> I've got a function that returns a dictionary, I need to loop and
> return 1000 dictionaries and append them to a list, but the thing is
> that when I do the list.append(funtThatReturnsDict()) the resulting
> only ever has 1 dictionary attached to it, even after running the
> append function 1000 times!
> 
> I've tried using dict.copy() on the dictionary that was returned from
> the function but this didn't work either.
> 
> And the function is definately returning different dictionaries each
> time as I can see that when I print them.
> 
> I know this is something to do with the dictionries being stored as
> references but I've no idea how to fix it seeing as the copy()
> function didn't work.
> 
> Thanks!

Let's see. First, a function that returns a new dictionary on every run:

>>> def new_dict(): return {}
...
>>> dicts = [new_dict() for _ in range(3)]
>>> dicts
[{}, {}, {}]
>>> dicts[1]["x"] = 42
>>> dicts
[{}, {'x': 42}, {}]

Works. Now a function that always returns the same dictionary:

>>> def same_dict(d={}): return d
...
>>> dicts = [same_dict() for _ in range(3)]
>>> dicts
[{}, {}, {}]
>>> dicts[1]["x"] = 42
>>> dicts
[{'x': 42}, {'x': 42}, {'x': 42}]

That's not what we want. Can it be fixed with dict.copy()?

>>> dicts = [same_dict().copy() for _ in range(3)]
>>> dicts
[{'x': 42}, {'x': 42}, {'x': 42}]

Hm, it wasn't a good idea to reuse same_dict() from the previous example
because the default value was changed by the 

dicts[1]["x"] = 42

statement. Second try:

>>> def same_dict(d={}): return d
...
>>> dicts = [same_dict().copy() for _ in range(3)]
>>> dicts
[{}, {}, {}]
>>> dicts[1]["x"] = 42
>>> dicts
[{}, {'x': 42}, {}]

So the approach using dict.copy() works, too. 

Note however, that you ust make a deep copy if you have mutable values

>>> d = dict(a=[])
>>> e = d.copy()
>>> d["a"].append(42)
>>> d
{'a': [42]}
>>> e
{'a': [42]}

>>> import copy
>>> d = dict(a=[])
>>> e = copy.deepcopy(d)
>>> d["a"].append(42)
>>> d
{'a': [42]}
>>> e
{'a': []}

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


Re: is this possible (getting info off web page)

2009-04-10 Thread Esmail

bruce wrote:

Hi Esmail.

I've not looked at the site. however, i can give you some general pointers
that might help you in solving your issue.


Excellent advice, thanks for pointing me in those directions. I am not
familiar with curl but will take this as an opportunty to learn about it.
I think looking at the user-agent parameter may also help.

Cheers,
Esmail


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


Re: Can't create list of dictionaries

2009-04-10 Thread John Machin
On Apr 10, 9:36 pm, sophie_newbie  wrote:
> Hi there,
>
> I've got a function that returns a dictionary, I need to loop and
> return 1000 dictionaries and append them to a list, but the thing is
> that when I do the list.append(funtThatReturnsDict()) the resulting
> only ever has 1 dictionary attached to it, even after running the
> append function 1000 times!

Do you mean that the length of the list is 1, or do you mean that the
same dictionary has been appended 1000 times?
>
> I've tried using dict.copy() on the dictionary that was returned from
> the function but this didn't work either.
>
> And the function is definately returning different dictionaries each
> time as I can see that when I print them.
>
> I know this is something to do with the dictionries being stored as
> references but I've no idea how to fix it seeing as the copy()
> function didn't work.

I think you had better show us your code, and the output from (say) 3
iterations (not 1000!!). If you are really doing "list.append
(functThatReturnsDict())" all in one line, break it up into multiple
lines so that some print statements can be used for debugging:

adict = functThatReturnsDict()
print "A", id(adict), len(adict), adict
alist.append(adict)
print "B", len(alist), id(alist[-1])

Clean it up a bit ... the dict.copy() is extremely unlikely to be part
of a principled solution, so remove any trace of that.

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


Re: Running an interactive subprocess with Popen

2009-04-10 Thread edexter
On Apr 10, 2:56 am, "Diez B. Roggisch"  wrote:
> David Liang schrieb:
>
>
>
>
>
> > Hello,
> > Sorry for the newbie question. How do I run a program that could
> > block, waiting for user input, using subprocess.Popen? For example,
>
> > from subprocess import *
>
> > def foo():
> >     a = Popen(['python'] ...)
>
> > I want to be able to get input from the user and send input to the
> > subprocess, printing stdout and stderr as data becomes available, then
> > return once the subprocess exits. Is it possible to send to the
> > subprocess keyboard interrupts, EOF, and such?
>
> > I tried doing stdout=PIPE, stderr=PIPE, stdin=PIPE. I tried using
> > communicate(), but could only call it once; subsequent calls raised
> > "ValueError: I/O operation on closed file."
> > And both a.stdout.read() and a.stderr.read() blocked the program. Any
> > help would be much appreciated.
>
> Use pexpect, which emulates a pseudo-terminal speaking with the subprocess.
>
> Diez- Hide quoted text -
>
> - Show quoted text -

I am not sure about that particular issue put I did manage to get it
working with windows in the dex tracker project..  you would have to
search the files or something to figure out where..  when you are
looking at examples it does matter wich operating system you are using
at least for python 2.5
--
http://mail.python.org/mailman/listinfo/python-list


ANN: python-ldap-2.3.7

2009-04-10 Thread Michael Ströder
Find a new release of python-ldap:

  http://python-ldap.sourceforge.net/

python-ldap provides an object-oriented API to access LDAP directory
servers from Python programs. It mainly wraps the OpenLDAP 2.x libs for
that purpose. Additionally it contains modules for other LDAP-related
stuff (e.g. processing LDIF, LDAPURLs and LDAPv3 schema).

Note that the download page has changed recently. You can now find the
source distribution at PyPI:

  http://pypi.python.org/pypi/python-ldap/

Ciao, Michael.

-- 
Michael Ströder
E-Mail: mich...@stroeder.com
http://www.stroeder.com


Released 2.3.7 2009-04-09

Changes since 2.3.6:

Lib/
* urllib.quote() is now used in LDAPUrlExtension.unparse() to quote
  all special URL characters in extension values

Modules/
* Fixed ldapcontrol.c not to raise ldap.ENCODING_ERROR in
  function encode_rfc2696() on 64-bit systems
* Fixed seg fault if error code in a LDAP response was outside
  the known error codes and could not be mapped to a specific
  exception class (thanks to Sean)
* errors.c: LDAP_ERROR_MAX set to LDAP_PROXIED_AUTHORIZATION_DENIED
  if available in OpenLDAP header
* new exception class ldap.PROXIED_AUTHORIZATION_DENIED
  if available in OpenLDAP header
* Fixed functions.c not to raise ldap.ENCODING_ERROR in
  function l_ldap_str2dn() on 64-bit systems (see SF#2725356)


Released 2.3.6 2009-02-22

Changes since 2.3.5:

Lib/
* Importing ldap.str2dn() which directly imported _ldap.str2dn()
  is prohibited now (see SF#2181141)

Modules/
* get_option(): Added support for reading more SASL options.
  (OPT_X_SASL_MECH, OPT_X_SASL_REALM, OPT_X_SASL_AUTHCID and
  OPT_X_SASL_AUTHZID)
* Added some explicit type casts to fix issues while building
  with SunStudio
* Fixed compiling issue with GCC 4.4
  (see SF#2555793, thanks to Matej and Martin)

Doc/
* Clarified not to use ldap_get_dn() directly
* Fixed description of ldap.SASL_AVAIL and ldap.TLS_AVAIL
  (see SF#2555804, thanks to Matej and Martin)


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


loop? maybe?

2009-04-10 Thread heidi taynton


Hey guys,

Sorry for being such a noob with this stuff and the language is hard for me to 
read through with the online manuals...  i can do math speak, and science 
speak... not so much programming/code speak... so when you say pickle... i 
think food


Anyways,

I have an array and I want to turn it into a new array.   where


nlines = 188
new_array=n.array(nlines)

for i in arange(nlines):

#   and here i want to tell it to read old_array and take  n  data points  
where new_n=1.1**old_n ... take the mean of those data points and put them in 
the first spot in the arraythen loop through with until the array is 
full?  If it doesn't make sense, i can try to clarify some more... 


Thanks, you guys are life savers,
hi
--
http://mail.python.org/mailman/listinfo/python-list


save error with embedded python 2.5

2009-04-10 Thread eric_dex...@msn.com
I seem to be getting one extra value when I create my values with

for yy in range(1, maxy):
  for xx in range(1, maxx):
count = count + 1
#squaret.append[count]
squaret.append( square(xx * 20, yy * 20))

and saving boxes with

if squaresave.state == '1':
  outfile = open('grid.dat','w')
  count = 0
  for s in squaret:
count = count + 1
outfile.write(s.state)
outfile.write(' ')
if count == maxy:
  outfile.write('\n')
  count = 0

thanks for any help in advance

I am using python 2.5 embeded into pycap..  the rest of the source is
available at
http://dexrowem.blogspot.com/2009/04/pycap-drum-machine-or-piano-roll-beta.html
if needed..
--
http://mail.python.org/mailman/listinfo/python-list


Re: Can't create list of dictionaries

2009-04-10 Thread Piet van Oostrum
> sophie_newbie  (sn) wrote:

>sn> Hi there,
>sn> I've got a function that returns a dictionary, I need to loop and
>sn> return 1000 dictionaries and append them to a list, but the thing is
>sn> that when I do the list.append(funtThatReturnsDict()) the resulting
>sn> only ever has 1 dictionary attached to it, even after running the
>sn> append function 1000 times!

>sn> I've tried using dict.copy() on the dictionary that was returned from
>sn> the function but this didn't work either.

>sn> And the function is definately returning different dictionaries each
>sn> time as I can see that when I print them.

>sn> I know this is something to do with the dictionries being stored as
>sn> references but I've no idea how to fix it seeing as the copy()
>sn> function didn't work.

You better post some real code. 
-- 
Piet van Oostrum 
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: p...@vanoostrum.org
--
http://mail.python.org/mailman/listinfo/python-list


I can't get RLock to work (warning, the following code is pretty long)

2009-04-10 Thread grocery_stocker
When I run the following...

#!/usr/bin/python

import time
import thread
import threading

def get_first_part(string, lock, sleeptime, *args):
global counter
lock.acquire()
try:
counter = counter + 1
data = counter
print "%s value is %d" % (string, counter)
time.sleep(sleeptime)
finally:
lock.release()
return data

def get_second_part(string, lock, sleeptime, *args):
global counter
lock.acquire()
try:
counter = counter + 1
data = counter
print "%s value is %d" % (string, counter)
time.sleep(sleeptime)
finally:
lock.release()
return data

def get_both_parts(string, lock, sleeptime, *args):
global first, second
lock.acquire()
try:
first = get_first_part()
second = get_second_part()
print "%s values are %d and %d" % (string, first,
second)
time.sleep(sleeptime)
finally:
lock.release()
return first, second

if __name__ == "__main__":
#lock = thread.allocate_lock()
lock = threading.RLock()

counter = 0
first = 0
second = 0

thread.start_new_thread(get_first_part, ("Thread1", lock, 2))
thread.start_new_thread(get_second_part, ("Thread2", lock, 2))
thread.start_new_thread(get_both_parts, ("Thread3", lock, 2))

#Yes I was told this was bad, but I'm still doing until I can make
it beyond
#the basics.
while 1: pass

The code will jsut hang

[cdal...@localhost oakland]$ ./rlock.py
Thread1 value is 1
Thread2 value is 2
Traceback (most recent call last):
  File "./rlock.py", line 57, in ?
while 1: pass
KeyboardInterrupt

How come RLock isn't working in this example?
--
http://mail.python.org/mailman/listinfo/python-list


Re: writing array

2009-04-10 Thread Piet van Oostrum
> heidi taynton  (ht) wrote:

>ht> Hey guys,


>ht> I'm trying to write a new array from the one i already have  


>ht> but here is the catch:

>ht> I want an array where  n=# of data points used in previous point (rounded 
>down)
>ht> in every spot, I want to take 1.1**n  data points and then take the mean 
>of the data points. (i know there is a numpy function mean() ).. put that is 
>spot 0  and so on... any suggestions? 

>ht> for clarification:
>ht> so the first spot takes 1 data point, b/c 1.1^0 =1   and the average of 
>that is just the data point
>ht> the second spot takes 2 data points b/c 1.1^1=1.1  which rounds up to 
>2  then the average of those two 
>ht> the third spot takes 4 data points b/c 1.1^2 = 1.21    and then that 
>will repeat   

>ht> make sense?

Not much. As 1.1^2=1.21, I would think this would then take 2
datapoints, not 4. If you take at each step n = 1.1^n (rounded up) n
will stay at 2 forever.
And first you talk about rounding down, later about rounding up. So what
is it.

Maybe you should give a better specification?
-- 
Piet van Oostrum 
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: p...@vanoostrum.org
--
http://mail.python.org/mailman/listinfo/python-list


Re: I can't get RLock to work (warning, the following code is pretty long)

2009-04-10 Thread Peter Otten
grocery_stocker wrote:

> When I run the following...
> 
> #!/usr/bin/python
> 
> import time
> import thread
> import threading
> 
> def get_first_part(string, lock, sleeptime, *args):
> global counter
> lock.acquire()
> try:
> counter = counter + 1
> data = counter
> print "%s value is %d" % (string, counter)
> time.sleep(sleeptime)
> finally:
> lock.release()
> return data

> def get_both_parts(string, lock, sleeptime, *args):
> global first, second
> lock.acquire()
> try:
> first = get_first_part()
> second = get_second_part()
> print "%s values are %d and %d" % (string, first,
> second)
> time.sleep(sleeptime)
> finally:
> lock.release()
> return first, second

> How come RLock isn't working in this example?

When get_both_parts() acquires the lock it invokes get_first_part() which
tries to acquire the lock. This fails because get_both_parts() does not
release the lock until after get_first_part() has finished...

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


RE: Open source web crawler with mysql integration

2009-04-10 Thread Support Desk
Sounds Interesting. When its done would you care to share it?

Sincerely,
Michael H.
 
-Original Message-
From: Philip Semanchuk [mailto:phi...@semanchuk.com] 
Sent: Thursday, April 09, 2009 9:46 PM
To: Python
Subject: Re: Open source web crawler with mysql integration


On Apr 9, 2009, at 7:37 PM, Daniel Fetchinson wrote:

>> I'm looking for a crawler that can spider my site and toss the  
>> results
>> into mysql so, in turn, that database can be indexed by Sphinx  
>> Search.
>>
>> Since I don't want to reinvent the wheel, is anyone aware of any open
>> source projects or code snippets that can already handle this?
>
> Have a look at http://nikitathespider.com/python/


As the author of Nikita, I can say that (a) she used Postgres and (b)  
the code wasn't open sourced except for a couple of small parts. The  
service is now defunct. It wasn't making money. Ideally I'd like to  
open source the code one day, but it would take a lot of documentation  
work to make it installable by others, and I won't have the time to do  
that for the foreseeable future.

At the URL provided there's a nice module for parsing robots.txt files  
(better than the one in the standard library IMHO) but that's about it.

FYI, I wrote my spider in Python because I couldn't find a decent one  
written in Python. There's Nutch, but that's not Python (Java I think).

Good luck
Philip



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


email in separate thread

2009-04-10 Thread joeygartin
Greetings,

Disclosure:  I am a total newbie!

I am building an application Django and come to a dilemna when sending
off emails.  I have an application that sends off an email after a
customer has filled out a form, actually it sends off 7 emails.

The problem is the page hangs while the emails are sent.  My current
hosting situation does not give me direct access to an email queue.
So I have two options (that I can think of):

1) Write the email information to a file and then run a cron job in
the background that routinely checks the file and sends the necessary
emails off

OR

2) Spin-off a thread (which I have no background with at all!) for the
emails and be able to redirect the user to the next page.

I have posted this problem on the Django users group, but did not
really get a usable response.  If any of you have dealt with this or
know of an actual solution, please help.

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


how to use logging.config.fileConfig ?

2009-04-10 Thread Alexandru Moșoi
Hello,

I have a problem using logging the library. I copied and modified the
example from PEP 282 [0], [1], [2], [3].
If I use logging.basicConfig() everything works fine. If I use
logging.config.fileConfig() my loggers get disabled. I checked logging/
config.py and I found a big comment saying that old loggers are
disabled! Why? What am I doing wrong? How do I use
logging.config.fileConfig() to avoid this problem ?


with logging.config.fileconfig()

2009-04-10 17:49:19,955:MyApp:INFO - Starting my app
2009-04-10 17:49:19,955:MyApp:ERROR - There was a problem.
Traceback (most recent call last):
  File "myapp.py", line 10, in 
mymodule.doIt()
  File "/home/voodoo/src/mymodule.py", line 7, in doIt
raise TypeError, "Bogus type error for testing"
TypeError: Bogus type error for testing
2009-04-10 17:49:19,956:MyApp:INFO - Ending my app
--

with logging.basicConfig()
--
INFO:MyApp:Starting my app
DEBUG:MyModule:Doin' stuff...
ERROR:MyApp:There was a problem.
Traceback (most recent call last):
  File "myapp.py", line 10, in 
mymodule.doIt()
  File "/home/voodoo/src/mymodule.py", line 7, in doIt
raise TypeError, "Bogus type error for testing"
TypeError: Bogus type error for testing
INFO:MyApp:Ending my app
--



[0] http://rafb.net/p/nl7b7m19.html
[1] http://rafb.net/p/n6KNdU44.html
[2] http://rafb.net/p/OxyTga98.html
[3] http://www.python.org/dev/peps/pep-0282/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Adding a Badge to an Icon in Mac OS X

2009-04-10 Thread Kevin Walzer

bingo wrote:

Hi all,
I have been, now for daysm trying to figure out how to add a badge to
an Icon in Mac OS X. Carbon Icon Services is not documented and I new
to Mac programming. Any help would be greatly appreciated!

Cheers,


Look at PyObjC--there should be methods in there to do it.

--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: a simple keypress sensor

2009-04-10 Thread cassiope
On Apr 9, 6:55 pm, Soumen banerjee  wrote:
> Hello,
> I am writing a little program where i have an array the elements of
> which i want to display upon keypresses by the user. The only way on
> linux seems like using getch() from the curses library. I wanted a
> simpler solution than having to use curses for such a simple thing.
> any ideas?
> Regards
> Soumen

A more "natural" solution - within Linux - would be to use the termios
library functions.  Simple, no curses necessary.

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


Re: I can't get RLock to work (warning, the following code is pretty long)

2009-04-10 Thread grocery_stocker
On Apr 10, 6:48 am, Peter Otten <__pete...@web.de> wrote:
> grocery_stocker wrote:
> > When I run the following...
>
> > #!/usr/bin/python
>
> > import time
> > import thread
> > import threading
>
> > def get_first_part(string, lock, sleeptime, *args):
> > global counter
> > lock.acquire()
> > try:
> > counter = counter + 1
> > data = counter
> > print "%s value is %d" % (string, counter)
> > time.sleep(sleeptime)
> > finally:
> > lock.release()
> > return data
> > def get_both_parts(string, lock, sleeptime, *args):
> > global first, second
> > lock.acquire()
> > try:
> > first = get_first_part()
> > second = get_second_part()
> > print "%s values are %d and %d" % (string, first,
> > second)
> > time.sleep(sleeptime)
> > finally:
> > lock.release()
> > return first, second
> > How come RLock isn't working in this example?
>
> When get_both_parts() acquires the lock it invokes get_first_part() which
> tries to acquire the lock. This fails because get_both_parts() does not
> release the lock until after get_first_part() has finished...
>
> Peter


i thought a Rlock() (vs a Lock()) was suspposed to get around this
kind of a problem.
--
http://mail.python.org/mailman/listinfo/python-list


Re: loop? maybe?

2009-04-10 Thread Mike Driscoll
On Apr 10, 7:42 am, heidi taynton  wrote:
> Hey guys,
>
> Sorry for being such a noob with this stuff and the language is hard for me 
> to read through with the online manuals...  i can do math speak, and science 
> speak... not so much programming/code speak... so when you say pickle... i 
> think food
>
> Anyways,
>
> I have an array and I want to turn it into a new array.   where
>
> nlines = 188
> new_array=n.array(nlines)
>
> for i in arange(nlines):
>
> #   and here i want to tell it to read old_array and take  n  data points 
>  where new_n=1.1**old_n ... take the mean of those data points and put them 
> in the first spot in the array    then loop through with until the array 
> is full?      If it doesn't make sense, i can try to clarify some more...
>
> Thanks, you guys are life savers,
> hi

I'm probably missing something, but is this sort of what you are
looking for?



nlines = 188
new_array = [] # this creates a list
for i in range(nlines):
new_n = 1.1 ** i
mean = (new_n + i) / 2
new_array.append(mean)



If you wanted a cumulative mean of the values, then you'll have to
change it slightly of course, probably by using a nested loop.

Hopefully this isn't a homework question, but even if it is, it's an
interesting exercise.

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


Re: I can't get RLock to work (warning, the following code is pretty long)

2009-04-10 Thread Peter Otten
grocery_stocker wrote:

> On Apr 10, 6:48 am, Peter Otten <__pete...@web.de> wrote:
>> grocery_stocker wrote:
>> > When I run the following...
>>
>> > #!/usr/bin/python
>>
>> > import time
>> > import thread
>> > import threading
>>
>> > def get_first_part(string, lock, sleeptime, *args):
>> > global counter
>> > lock.acquire()
>> > try:
>> > counter = counter + 1
>> > data = counter
>> > print "%s value is %d" % (string, counter)
>> > time.sleep(sleeptime)
>> > finally:
>> > lock.release()
>> > return data
>> > def get_both_parts(string, lock, sleeptime, *args):
>> > global first, second
>> > lock.acquire()
>> > try:
>> > first = get_first_part()
>> > second = get_second_part()
>> > print "%s values are %d and %d" % (string, first,
>> > second)
>> > time.sleep(sleeptime)
>> > finally:
>> > lock.release()
>> > return first, second
>> > How come RLock isn't working in this example?
>>
>> When get_both_parts() acquires the lock it invokes get_first_part() which
>> tries to acquire the lock. This fails because get_both_parts() does not
>> release the lock until after get_first_part() has finished...
>>
>> Peter
> 
> 
> i thought a Rlock() (vs a Lock()) was suspposed to get around this
> kind of a problem.

Oops, yes. In get_both_parts() try calling get_first_part/get_second_part()
with the three necessary arguments...

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


Re: I can't get RLock to work (warning, the following code is pretty long)

2009-04-10 Thread grocery_stocker
On Apr 10, 8:39 am, Peter Otten <__pete...@web.de> wrote:
> grocery_stocker wrote:
> > On Apr 10, 6:48 am, Peter Otten <__pete...@web.de> wrote:
> >> grocery_stocker wrote:
> >> > When I run the following...
>
> >> > #!/usr/bin/python
>
> >> > import time
> >> > import thread
> >> > import threading
>
> >> > def get_first_part(string, lock, sleeptime, *args):
> >> > global counter
> >> > lock.acquire()
> >> > try:
> >> > counter = counter + 1
> >> > data = counter
> >> > print "%s value is %d" % (string, counter)
> >> > time.sleep(sleeptime)
> >> > finally:
> >> > lock.release()
> >> > return data
> >> > def get_both_parts(string, lock, sleeptime, *args):
> >> > global first, second
> >> > lock.acquire()
> >> > try:
> >> > first = get_first_part()
> >> > second = get_second_part()
> >> > print "%s values are %d and %d" % (string, first,
> >> > second)
> >> > time.sleep(sleeptime)
> >> > finally:
> >> > lock.release()
> >> > return first, second
> >> > How come RLock isn't working in this example?
>
> >> When get_both_parts() acquires the lock it invokes get_first_part() which
> >> tries to acquire the lock. This fails because get_both_parts() does not
> >> release the lock until after get_first_part() has finished...
>
> >> Peter
>
> > i thought a Rlock() (vs a Lock()) was suspposed to get around this
> > kind of a problem.
>
> Oops, yes. In get_both_parts() try calling get_first_part/get_second_part()
> with the three necessary arguments...
>

Doh. I knew that. I really did.

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


Re: numpy.where

2009-04-10 Thread Peter Pearson
On Fri, 10 Apr 2009 02:39:46 -0500, Robert Kern  wrote:
> On 2009-04-09 22:40, Peter Pearson wrote:
>>
>> Hey, if you find TFM, please tell me where it is.  I haven't
>> found anything Fine.  I even bought Travis Oliphant's book,
>> which helps a little, but . . .
>
> http://docs.scipy.org/doc/numpy/reference/arrays.indexing.html

Thanks.  I'll make that my front-line reference for my next foray.

-- 
To email me, substitute nowhere->spamcop, invalid->net.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Open source web crawler with mysql integration

2009-04-10 Thread Philip Semanchuk


On Apr 10, 2009, at 10:28 AM, Support Desk wrote:


Sounds Interesting. When its done would you care to share it?


Hi Michael,
The coding has been done (as much as software is ever "done") for a  
couple of years now. It's mothballed now, sitting on my hard drive.  
The problem with open sourcing it isn't that the code is incomplete,  
the problem is that it's insufficiently documented, features a  
byzantine install procedure and contains a lot of code & assumptions  
that were relevant to my business but would not be of interest to most  
people looking to download a general-purpose spider. I'd love to open  
source it and if someone wants to pay me to make it open source-able,  
let's talk! But if I have to do it on my own time for free it will be  
a while (maybe never, although I hope not) before I can make the time.


Regards
Philip





-Original Message-
From: Philip Semanchuk [mailto:phi...@semanchuk.com]
Sent: Thursday, April 09, 2009 9:46 PM
To: Python
Subject: Re: Open source web crawler with mysql integration


On Apr 9, 2009, at 7:37 PM, Daniel Fetchinson wrote:


I'm looking for a crawler that can spider my site and toss the
results
into mysql so, in turn, that database can be indexed by Sphinx
Search.

Since I don't want to reinvent the wheel, is anyone aware of any  
open

source projects or code snippets that can already handle this?


Have a look at http://nikitathespider.com/python/



As the author of Nikita, I can say that (a) she used Postgres and (b)
the code wasn't open sourced except for a couple of small parts. The
service is now defunct. It wasn't making money. Ideally I'd like to
open source the code one day, but it would take a lot of documentation
work to make it installable by others, and I won't have the time to do
that for the foreseeable future.

At the URL provided there's a nice module for parsing robots.txt files
(better than the one in the standard library IMHO) but that's about  
it.


FYI, I wrote my spider in Python because I couldn't find a decent one
written in Python. There's Nutch, but that's not Python (Java I  
think).


Good luck
Philip





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


RE: Open source web crawler with mysql integration

2009-04-10 Thread bruce
phillip...

lots of code is opened source "as is"!!!

when you get right down to it, a good deal of "open source" code from
sourceforge/hotscritps/freshmeat/etc.. is pretty poor, but it is open
sourced.

you could simply toss your code out into the open source pool, and not be
worried about supporting it, or even touching it again...

peace


-Original Message-
From: python-list-bounces+bedouglas=earthlink@python.org
[mailto:python-list-bounces+bedouglas=earthlink@python.org]on Behalf
Of Philip Semanchuk
Sent: Friday, April 10, 2009 8:10 AM
To: Python (General)
Subject: Re: Open source web crawler with mysql integration



On Apr 10, 2009, at 10:28 AM, Support Desk wrote:

> Sounds Interesting. When its done would you care to share it?

Hi Michael,
The coding has been done (as much as software is ever "done") for a
couple of years now. It's mothballed now, sitting on my hard drive.
The problem with open sourcing it isn't that the code is incomplete,
the problem is that it's insufficiently documented, features a
byzantine install procedure and contains a lot of code & assumptions
that were relevant to my business but would not be of interest to most
people looking to download a general-purpose spider. I'd love to open
source it and if someone wants to pay me to make it open source-able,
let's talk! But if I have to do it on my own time for free it will be
a while (maybe never, although I hope not) before I can make the time.

Regards
Philip




> -Original Message-
> From: Philip Semanchuk [mailto:phi...@semanchuk.com]
> Sent: Thursday, April 09, 2009 9:46 PM
> To: Python
> Subject: Re: Open source web crawler with mysql integration
>
>
> On Apr 9, 2009, at 7:37 PM, Daniel Fetchinson wrote:
>
>>> I'm looking for a crawler that can spider my site and toss the
>>> results
>>> into mysql so, in turn, that database can be indexed by Sphinx
>>> Search.
>>>
>>> Since I don't want to reinvent the wheel, is anyone aware of any
>>> open
>>> source projects or code snippets that can already handle this?
>>
>> Have a look at http://nikitathespider.com/python/
>
>
> As the author of Nikita, I can say that (a) she used Postgres and (b)
> the code wasn't open sourced except for a couple of small parts. The
> service is now defunct. It wasn't making money. Ideally I'd like to
> open source the code one day, but it would take a lot of documentation
> work to make it installable by others, and I won't have the time to do
> that for the foreseeable future.
>
> At the URL provided there's a nice module for parsing robots.txt files
> (better than the one in the standard library IMHO) but that's about
> it.
>
> FYI, I wrote my spider in Python because I couldn't find a decent one
> written in Python. There's Nutch, but that's not Python (Java I
> think).
>
> Good luck
> Philip
>
>
>

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

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


Bug tracker off-line?

2009-04-10 Thread MRAB

Is it just me or is the bug tracker site having problems? I'm not having
a problem with other sites.
--
http://mail.python.org/mailman/listinfo/python-list


python crash

2009-04-10 Thread John Reid
Python crashes in glibc with the following stack trace. I'm using an 
interface to R (rpy2), ipython, matplotlib, numpy, and scipy with a wx 
backend. I'm not sure if the stack trace shows which is the culprit. 
I've probably misconfigured one of their installs but knowing which one 
to recompile is a bit of a problem. They all took some time to install 
so I don't really want to start from scratch again and there's no 
knowing if that would fix it anyhow.


I'm on 64 bit Ubuntu:
Linux john-dell 2.6.27-11-generic #1 SMP Wed Apr 1 20:53:41 UTC 2009 
x86_64 GNU/Linux


Python 2.5.2
Numpy: 1.2.1
Scipy: 0.7.0rc2
IPython: 0.9.1
matplotlib: 0.98.5.2
wx: 2.8.8.0 (gtk2-unicode)

I suspect it is something to do with matplotlib as I think it happens 
when I'm plotting stuff but its not completely reproducible.


Also, I'm using the Ubuntu python package but I've built numpy, scipy 
and matplotlib myself. I didn't think this would be a problem though.


Any help appreciated.

Thanks,
John.



*** glibc detected *** /usr/bin/python2.5: free(): invalid pointer: 
0x7f6e499967a0 ***

=== Backtrace: =
/lib/libc.so.6[0x7f6e6dcf1a58]
/lib/libc.so.6(cfree+0x76)[0x7f6e6dcf40a6]
/usr/lib/python2.5/lib-dynload/readline.so[0x7f6e6aa7fcd0]
/usr/bin/python2.5(PyEval_EvalFrameEx+0x57e2)[0x491052]
/usr/bin/python2.5(PyEval_EvalCodeEx+0x6ad)[0x4927cd]
/usr/bin/python2.5[0x4dd4c2]
/usr/bin/python2.5(PyObject_Call+0x13)[0x418c33]
/usr/bin/python2.5[0x41fb08]
/usr/bin/python2.5(PyObject_Call+0x13)[0x418c33]
/usr/bin/python2.5(PyEval_CallObjectWithKeywords+0x72)[0x48a852]
/usr/bin/python2.5(PyInstance_New+0x86)[0x422956]
/usr/bin/python2.5(PyObject_Call+0x13)[0x418c33]
/usr/bin/python2.5(PyEval_EvalFrameEx+0x3d12)[0x48f582]
/usr/bin/python2.5(PyEval_EvalFrameEx+0x6872)[0x4920e2]
/usr/bin/python2.5(PyEval_EvalFrameEx+0x6872)[0x4920e2]
/usr/bin/python2.5(PyEval_EvalCodeEx+0x6ad)[0x4927cd]
/usr/bin/python2.5(PyEval_EvalFrameEx+0x5483)[0x490cf3]
/usr/bin/python2.5(PyEval_EvalCodeEx+0x6ad)[0x4927cd]
/usr/bin/python2.5[0x4dd4c2]
/usr/bin/python2.5(PyObject_Call+0x13)[0x418c33]
/usr/bin/python2.5[0x41fb08]
/usr/bin/python2.5(PyObject_Call+0x13)[0x418c33]
/usr/bin/python2.5(PyEval_CallObjectWithKeywords+0x72)[0x48a852]
/usr/bin/python2.5(PyInstance_New+0x86)[0x422956]
/usr/bin/python2.5(PyObject_Call+0x13)[0x418c33]
/usr/bin/python2.5(PyEval_EvalFrameEx+0x3d12)[0x48f582]
/usr/bin/python2.5(PyEval_EvalFrameEx+0x6872)[0x4920e2]
/usr/bin/python2.5(PyEval_EvalCodeEx+0x6ad)[0x4927cd]
/usr/bin/python2.5(PyEval_EvalCode+0x32)[0x4929c2]
/usr/bin/python2.5(PyRun_FileExFlags+0x108)[0x4b2678]
/usr/bin/python2.5[0x489948]
/usr/bin/python2.5(PyEval_EvalFrameEx+0x57e2)[0x491052]
/usr/bin/python2.5(PyEval_EvalCodeEx+0x6ad)[0x4927cd]
/usr/bin/python2.5(PyEval_EvalFrameEx+0x4cf8)[0x490568]
/usr/bin/python2.5(PyEval_EvalCodeEx+0x6ad)[0x4927cd]
/usr/bin/python2.5[0x4dd4c2]
/usr/bin/python2.5(PyObject_Call+0x13)[0x418c33]
/usr/bin/python2.5[0x41fb08]
/usr/bin/python2.5(PyObject_Call+0x13)[0x418c33]
/usr/bin/python2.5(PyEval_EvalFrameEx+0x3d12)[0x48f582]
/usr/bin/python2.5(PyEval_EvalFrameEx+0x6872)[0x4920e2]
/usr/bin/python2.5(PyEval_EvalCodeEx+0x6ad)[0x4927cd]
/usr/bin/python2.5[0x4dd4c2]
/usr/bin/python2.5(PyObject_Call+0x13)[0x418c33]
/usr/bin/python2.5[0x41fb08]
/usr/bin/python2.5(PyObject_Call+0x13)[0x418c33]
/usr/bin/python2.5(PyEval_CallObjectWithKeywords+0x72)[0x48a852]
/usr/lib/python2.5/site-packages/wx-2.8-gtk2-unicode/wx/_core_.so(_ZN12wxPyCallback12EventThunkerER7wxEvent+0x107)[0x7f6e662099d7]
/usr/lib/libwx_baseu-2.8.so.0(_ZN12wxEvtHandler21ProcessEventIfMatchesERK21wxEventTableEntryBasePS_R7wxEvent+0x89)[0x7f6e64556ca9]
/usr/lib/libwx_baseu-2.8.so.0(_ZN12wxEvtHandler23SearchDynamicEventTableER7wxEvent+0x54)[0x7f6e64556e54]
/usr/lib/libwx_baseu-2.8.so.0(_ZN12wxEvtHandler12ProcessEventER7wxEvent+0x92)[0x7f6e64557f42]
/usr/lib/libwx_gtk2u_core-2.8.so.0(_ZN11wxTimerBase6NotifyEv+0x66)[0x7f6e64ee51d6]
/usr/lib/libwx_gtk2u_core-2.8.so.0[0x7f6e64dec3cb]
/usr/lib/libglib-2.0.so.0[0x7f6e623a551b]
/usr/lib/libglib-2.0.so.0(g_main_context_dispatch+0x23b)[0x7f6e623a4d5b]
/usr/lib/libglib-2.0.so.0[0x7f6e623a852d]
/usr/lib/libglib-2.0.so.0(g_main_loop_run+0x1cd)[0x7f6e623a8a5d]
/usr/lib/libgtk-x11-2.0.so.0(gtk_main+0xa7)[0x7f6e63fb17a7]
/usr/lib/libwx_gtk2u_core-2.8.so.0(_ZN11wxEventLoop3RunEv+0x48)[0x7f6e64de3d18]
/usr/lib/libwx_gtk2u_core-2.8.so.0(_ZN9wxAppBase8MainLoopEv+0x4b)[0x7f6e64e6cf4b]
/usr/lib/python2.5/site-packages/wx-2.8-gtk2-unicode/wx/_core_.so(_ZN7wxPyApp8MainLoopEv+0x37)[0x7f6e66208cd7]
/usr/lib/python2.5/site-packages/wx-2.8-gtk2-unicode/wx/_core_.so[0x7f6e6626707e]
/usr/bin/python2.5(PyEval_EvalFrameEx+0x562b)[0x490e9b]
=== Memory map: 
0040-00525000 r-xp  08:05 4825998 
 /usr/bin/python2.5
00724000-00725000 r--p 00124000 08:05 4825998 
 /usr/bin/python2.5
00725000-00757000 rw-p 00125000 08:05 4825998 
 /usr/bin/python2.5

00757000-0075f000 rw-p 00757000 00:00 0
018e9000-0d5d6000 rw-p 018e9000 00:00 0 
 [

Crash on msvcrt mismatch?

2009-04-10 Thread Lagarde, Jean
I don't have much experience writing extension modules, and am looking for 
pointers to resolve python crashes on Windows.

I've isolated the problem to a python file with the following two lines:


import PyQt4.Qwt5
import C13


That causes Python to crash. If I comment out either one of the two lines, it 
doesn't. C13 is an extension module wrapping the API for an instrumentation 
card. I've written test code that uses that C13 module without problems, but 
that code doesn't use PyQt.

My Python and  PyQt come from the Python(x,y) binary distribution (version 
2.1.11). C13 was compiled using mingw and used msvcr71 by default. I noticed 
that although Python depends on msvcr71 as well, the PyQt modules depend on 
msvcrt (QtCore4.dll and Qtw.pyd for example). I tried to use msvcrt for C13 as 
well, but got the same result.

I'm looking for ideas as to what to try next. I'd like to avoid having to build 
PyQt from source, but if that's the recommendation I'll give it a go.

Cheers,

Jean

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


Re: numpy.where

2009-04-10 Thread Lou Pecora
In article ,
 Robert Kern  wrote:

> http://docs.scipy.org/doc/numpy/reference/arrays.indexing.html

That helps, thanks.  So I can RTFWP, too.  :-)

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


Re: Bug tracker off-line?

2009-04-10 Thread Aahz
In article ,
MRAB   wrote:
>
>Is it just me or is the bug tracker site having problems? I'm not having
>a problem with other sites.

Someone else reported this on python-dev
-- 
Aahz (a...@pythoncraft.com)   <*> http://www.pythoncraft.com/

Why is this newsgroup different from all other newsgroups?
--
http://mail.python.org/mailman/listinfo/python-list


RE: Crash on msvcrt mismatch?

2009-04-10 Thread Lagarde, Jean
I'm curious to understand why that matters, but I found out that if I load the 
modules in the inverse order, everything works fine.

-- Jean


From: Lagarde, Jean
Sent: Friday, April 10, 2009 10:08 AM
To: python-list@python.org
Subject: Crash on msvcrt mismatch?

I don't have much experience writing extension modules, and am looking for 
pointers to resolve python crashes on Windows.

I've isolated the problem to a python file with the following two lines:


import PyQt4.Qwt5
import C13


That causes Python to crash. If I comment out either one of the two lines, it 
doesn't. C13 is an extension module wrapping the API for an instrumentation 
card. I've written test code that uses that C13 module without problems, but 
that code doesn't use PyQt.

My Python and  PyQt come from the Python(x,y) binary distribution (version 
2.1.11). C13 was compiled using mingw and used msvcr71 by default. I noticed 
that although Python depends on msvcr71 as well, the PyQt modules depend on 
msvcrt (QtCore4.dll and Qtw.pyd for example). I tried to use msvcrt for C13 as 
well, but got the same result.

I'm looking for ideas as to what to try next. I'd like to avoid having to build 
PyQt from source, but if that's the recommendation I'll give it a go.

Cheers,

Jean

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


Re: Running an interactive subprocess with Popen

2009-04-10 Thread norseman

David Liang wrote:

Hello,
Sorry for the newbie question. How do I run a program that could
block, waiting for user input, using subprocess.Popen? For example,

from subprocess import *

def foo():
a = Popen(['python'] ...)

I want to be able to get input from the user and send input to the
subprocess, printing stdout and stderr as data becomes available, then
return once the subprocess exits. Is it possible to send to the
subprocess keyboard interrupts, EOF, and such?

I tried doing stdout=PIPE, stderr=PIPE, stdin=PIPE. I tried using
communicate(), but could only call it once; subsequent calls raised
"ValueError: I/O operation on closed file."
And both a.stdout.read() and a.stderr.read() blocked the program. Any
help would be much appreciated.

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



David;
	Take a look at Section 14.1.2 of the Python Library pdf reference.  The 
popen3 should interest you.  It allows 2 way communication with a 
'child' process.
	I was going to include some samples, but it seems I took them off when 
that project terminated.  (So they are buried somewhere in storage - sorry.)


I'm running Ver. 2.5.2 for mass compatibility.

Note:
  I never tried redirection of the mouse. Just the keyboard, which
  worked very well for me. In my case "Parent" controlled conversation.
  In essence, treating 'child' as a subroutine. 'Child' included Unix
  scripts, Unix programs, and some third party programs.  Try to have
  your "parent" program NOT talk to the screen while in this mode. :)


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


zProblem

2009-04-10 Thread norseman

Moderator:  I apologize for attaching anything.

However, in order to explain my problem, I need to control the font
since text graphics only work for a given font. It's as small as I can
get it.


Steve
norse...@hughes.net




zProblem.pdf
Description: Adobe PDF document
--
http://mail.python.org/mailman/listinfo/python-list


Re: Crash on msvcrt mismatch?

2009-04-10 Thread Aahz
In article ,
Lagarde, Jean  wrote:
>
>I'm curious to understand why that matters, but I found out that if I load =
>the modules in the inverse order, everything works fine.

There's probably a refcount bug hiding in your code.
-- 
Aahz (a...@pythoncraft.com)   <*> http://www.pythoncraft.com/

Why is this newsgroup different from all other newsgroups?
--
http://mail.python.org/mailman/listinfo/python-list


knowing mobile ip

2009-04-10 Thread seham salem

how can i know  my mobile ip by bython code or something else 
i found a code but it does not work with my mobile.
Nokia N73,E56>>>
thanks




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


How to create a virtual serial port?

2009-04-10 Thread Stuart Davenport
Hi,

I am trying to work out if its possible, to create a virtual serial
port with Python? Would anyone know how to go about this in code? Any
help would be greatly appreciated! :)

I have a had a google and the topics returned only seem to reflect
"reading" serial port data, particularly pySerial results...

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


Re: How to create a virtual serial port?

2009-04-10 Thread Scott David Daniels

Stuart Davenport wrote:

Hi,

I am trying to work out if its possible, to create a virtual serial
port with Python? Would anyone know how to go about this in code? Any
help would be greatly appreciated! :)

I have a had a google and the topics returned only seem to reflect
"reading" serial port data, particularly pySerial results...

Cheers
Stu

Well, search for Smart Questions.  I have no idea what your OS is, nor
what level of "virtual serial port" you want/need.  All anyone could
do with your current request is guess what you need and try to steer you
towards it.

--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list


Re: How to create a virtual serial port?

2009-04-10 Thread Grant Edwards
On 2009-04-10, Stuart Davenport  wrote:

> I am trying to work out if its possible, to create a virtual serial
> port with Python?

On Linux: no.

On other OSes, I don't know.

-- 
Grant Edwards   grante Yow! I'm encased in the
  at   lining of a pure pork
   visi.comsausage!!
--
http://mail.python.org/mailman/listinfo/python-list


Python 2.6/3.0 packages for Ubuntu?

2009-04-10 Thread skip
Does Ubuntu really not have Python 2.6 or 3.0 packages or do I just have my
package list misconfigured?  I'm setting up a fresh machine and am not too
Ubuntu-aware.  Is there a list of package repositories around somewhere?

Thx,

-- 
Skip Montanaro - s...@pobox.com - http://www.smontanaro.net/
"XML sucks, dictionaries rock" - Dave Beazley
--
http://mail.python.org/mailman/listinfo/python-list


ValueError: I/O operation on closed file

2009-04-10 Thread dj
I have a handler which I use with a set of log levels for the python
logging module.

--- myhandler.py

import logging.handlers

# create my handler class
class MyHandler(logging.handlers.RotatingFileHandler):
def __init__(self, fn):
logging.handlers.RotatingFileHandler.__init__(self, fn,
 
maxBytes=10485760, backupCount=5)

# Register handler in the "logging.handlers" namespace
logging.handlers.MyHandler = MyHandler


Using it, repeatedly generates this error:

Traceback (most recent call last):
  File "C:\python26\lib\logging\handlers.py", line 74, in emit
if self.shouldRollover(record):
  File "C:\python26\lib\logging\handlers.py", line 146, in
shouldRollover
self.stream.seek(0, 2)  #due to non-posix-compliant Windows
feature
ValueError: I/O operation on closed file


I am completely stumped  has to what could be the issue.
Any help would be greatly appreciated.
--
http://mail.python.org/mailman/listinfo/python-list


Re: How to create a virtual serial port?

2009-04-10 Thread Banibrata Dutta
As others have already stated, "Virtual Serial Port" isn't descriptive
enough. There are various forms of "Virtual Serial Ports" and different
people use the term to mean different things. For example, emulating RS232
communication over Bluetooth, or USB, is also something done using "Virtual
Serial Port". I'd expect however, this to be a driver, not typically not a
user-land application.

On Sat, Apr 11, 2009 at 12:29 AM, Stuart Davenport <
stuart.davenp...@gmail.com> wrote:

> Hi,
>
> I am trying to work out if its possible, to create a virtual serial
> port with Python? Would anyone know how to go about this in code? Any
> help would be greatly appreciated! :)
>
> I have a had a google and the topics returned only seem to reflect
> "reading" serial port data, particularly pySerial results...
>
> Cheers
> Stu
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
regards,
Banibrata
http://www.linkedin.com/in/bdutta
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.6/3.0 packages for Ubuntu?

2009-04-10 Thread Benjamin Kaplan
On Fri, Apr 10, 2009 at 4:27 PM,  wrote:

> Does Ubuntu really not have Python 2.6 or 3.0 packages or do I just have my
> package list misconfigured?  I'm setting up a fresh machine and am not too
> Ubuntu-aware.  Is there a list of package repositories around somewhere?
>
> Thx,
>

Which version of Ubuntu are you using?

Hardy: 2.5.2
Intrepid: 2.5.2 and 3.0rc1
Jaunty (beta) : 2.6.2rc1 and 3.0.1


> --
> Skip Montanaro - s...@pobox.com - http://www.smontanaro.net/
>"XML sucks, dictionaries rock" - Dave Beazley
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list


Unsupported operand types in if/else list comprehension

2009-04-10 Thread Mike H
Hello all, I have a question about the if/else aspect of list comprehension:

I would like to go through a list and place quotes around an item if
it is a string, and keep the item the same if it's anything else:

e.g.['a',9,'8b'] --> ['"a"', 9, '"8b"']

I understand that if/else list comprehension should be generally:

b=[(F,T)[boolean test] for val in X]

so, I tried the following code:

a=['test',1,'two']
b=[(inst, '"'+inst+'"')[isinstance(inst, str)] for inst in a]

I end up getting the error: unsupported operand type(s) for +: 'int' and 'str'

>From playing around with other examples, I get the feeling that Python
is calculating both values (inst and '"'+inst+'"') before selecting
which one to pass to the new list. Am I right? Is there any way I can
do this using list comprehension?

Thanks in advance,

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


Re: Unsupported operand types in if/else list comprehension

2009-04-10 Thread Gary Herron

Mike H wrote:

Hello all, I have a question about the if/else aspect of list comprehension:

I would like to go through a list and place quotes around an item if
it is a string, and keep the item the same if it's anything else:

e.g.['a',9,'8b'] --> ['"a"', 9, '"8b"']

I understand that if/else list comprehension should be generally:

b=[(F,T)[boolean test] for val in X]

so, I tried the following code:

a=['test',1,'two']
b=[(inst, '"'+inst+'"')[isinstance(inst, str)] for inst in a]

I end up getting the error: unsupported operand type(s) for +: 'int' and 'str'

>From playing around with other examples, I get the feeling that Python
is calculating both values (inst and '"'+inst+'"') before selecting
which one to pass to the new list. Am I right? Is there any way I can
do this using list comprehension?

Thanks in advance,

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

While I think your goal is of questionable value, this will do it:

   b = [('"'+inst+'"' if isinstance(inst, str) else inst)   for inst in a]

The parentheses around the conditional are unnecessary, but help with 
readability I think.


Better yet:
 def  QuoteIfString(inst):
 ...

 b = [QuoteIfString(inst)   for inst in a]

would be much more readable, and you could document
*why* you are doing this in the def of QuoteIfString


Gary Herron







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


Re: Unsupported operand types in if/else list comprehension

2009-04-10 Thread John Yeung
On Apr 10, 5:07 pm, Mike H  wrote:
> From playing around with other examples, I get the feeling
> that Python is calculating both values (inst and '"'+inst+'"')
> before selecting which one to pass to the new list. Am I right?

I believe so.  (I'm sure the experts here will tell you more
definitively.)

> Is there any way I can do this using list comprehension?

Yes.  If you are using 2.5 or later, you can do this:

Python 2.6.1 (r261:67517, Dec  4 2008, 16:51:00) [MSC v.1500 32 bit
(Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> a=['test',1,'two']
>>> b=[(x if not isinstance(x, str) else '"'+x+'"') for x in a]
>>> b
['"test"', 1, '"two"']
>>>

If you are trying to make a CSV file, then even better may be to use
the csv module.

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


Re: Unsupported operand types in if/else list comprehension

2009-04-10 Thread MRAB

Mike H wrote:

Hello all, I have a question about the if/else aspect of list comprehension:

I would like to go through a list and place quotes around an item if
it is a string, and keep the item the same if it's anything else:

e.g.['a',9,'8b'] --> ['"a"', 9, '"8b"']

I understand that if/else list comprehension should be generally:

b=[(F,T)[boolean test] for val in X]

so, I tried the following code:

a=['test',1,'two']
b=[(inst, '"'+inst+'"')[isinstance(inst, str)] for inst in a]

I end up getting the error: unsupported operand type(s) for +: 'int' and 'str'


From playing around with other examples, I get the feeling that Python

is calculating both values (inst and '"'+inst+'"') before selecting
which one to pass to the new list. Am I right? Is there any way I can
do this using list comprehension?


Yes, and yes:

b=[(inst, '"%s"' % inst)[isinstance(inst, str)] for inst in a]
--
http://mail.python.org/mailman/listinfo/python-list


Re: Adding a Badge to an Icon in Mac OS X

2009-04-10 Thread bingo
Kevin,

PyObjc seems to offer the option to add badges to icons in the doc. I
need to add badges to any icon... kinda like SCPlugin and dropbox do.
I think that SCPlugin is doing it through carbon Icon Services. But I
am still trying to figure out how it is done!

Thanks,

Madi

On Apr 10, 4:57 am, Kevin Walzer  wrote:
> bingo wrote:
> > Hi all,
> > I have been, now for daysm trying to figure out how to add a badge to
> > an Icon in Mac OS X. Carbon Icon Services is not documented and I new
> > to Mac programming. Any help would be greatly appreciated!
>
> > Cheers,
>
> Look at PyObjC--there should be methods in there to do it.
>
> --
> Kevin Walzer
> Code by Kevinhttp://www.codebykevin.com

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


Re: Unsupported operand types in if/else list comprehension

2009-04-10 Thread Mike H
Thanks to all of you.

FYI, I'm doing this because I'm working on creating some insert
statements in SQL, where string values need to be quoted, and integer
values need to be unquoted.

I wanted to be sure that I could pass these values to the list in a
normal way e.g. ['test', 1, 'two'] and have a function correct the
list for me, rather than calling the function with a strangely quoted
list e.g. ['"'test'"', 1, '"'two'"'].

Again, thanks.

On Fri, Apr 10, 2009 at 5:18 PM, John Yeung  wrote:
> On Apr 10, 5:07 pm, Mike H  wrote:
>> From playing around with other examples, I get the feeling
>> that Python is calculating both values (inst and '"'+inst+'"')
>> before selecting which one to pass to the new list. Am I right?
>
> I believe so.  (I'm sure the experts here will tell you more
> definitively.)
>
>> Is there any way I can do this using list comprehension?
>
> Yes.  If you are using 2.5 or later, you can do this:
>
> Python 2.6.1 (r261:67517, Dec  4 2008, 16:51:00) [MSC v.1500 32 bit
> (Intel)] on
> win32
> Type "help", "copyright", "credits" or "license" for more information.
 a=['test',1,'two']
 b=[(x if not isinstance(x, str) else '"'+x+'"') for x in a]
 b
> ['"test"', 1, '"two"']

>
> If you are trying to make a CSV file, then even better may be to use
> the csv module.
>
> John
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list


Re: zProblem

2009-04-10 Thread Gabriel Genellina
En Fri, 10 Apr 2009 14:50:57 -0300, norseman   
escribió:



However, in order to explain my problem, I need to control the font
since text graphics only work for a given font. It's as small as I can
get it.


I didn't understand what your problem is actually.

--
Gabriel Genellina

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


Re: Python 2.6/3.0 packages for Ubuntu?

2009-04-10 Thread Benjamin Kaplan
On Fri, Apr 10, 2009 at 5:15 PM,  wrote:

>
>>> Does Ubuntu really not have Python 2.6 or 3.0 packages
>
>Benjamin> Which version of Ubuntu are you using?
>
>Benjamin> Hardy: 2.5.2
>Benjamin> Intrepid: 2.5.2 and 3.0rc1
>Benjamin> Jaunty (beta) : 2.6.2rc1 and 3.0.1
>
> I'm using Intrepid.  Is there a simple way within Synaptic or by editing
> config files to jump up to Jaunty?
>

You can either wait 13 days for the final release, or run "sudo
update-manager -d" if you don't mind using the beta. You'll get a
notificaiton in the update manager that a new distribution is available. The
dist upgrades are pretty big (about 1GB) so make sure you have a good
internet connection and/or plenty of time before you do it.



> Thanks,
>
> --
> Skip Montanaro - s...@pobox.com - http://www.smontanaro.net/
>"XML sucks, dictionaries rock" - Dave Beazley
>
--
http://mail.python.org/mailman/listinfo/python-list


Re: How to create a virtual serial port?

2009-04-10 Thread Stuart Davenport
On 10 Apr, 20:45, Scott David Daniels  wrote:
> Stuart Davenport wrote:
> > Hi,
>
> > I am trying to work out if its possible, to create a virtual serial
> > port with Python? Would anyone know how to go about this in code? Any
> > help would be greatly appreciated! :)
>
> > I have a had a google and the topics returned only seem to reflect
> > "reading" serial port data, particularly pySerial results...
>
> > Cheers
> > Stu
>
> Well, search for Smart Questions.  I have no idea what your OS is, nor
> what level of "virtual serial port" you want/need.  All anyone could
> do with your current request is guess what you need and try to steer you
> towards it.
>
> --Scott David Daniels
> scott.dani...@acm.org

Scott, totally fair point - a little candid, but fair...

I'm on a OS X, python 2.5. Basically I will have a remote application
pushing data (GPS) over the network to a python application I have
running on my Mac, I want this python application to again push the
data on to a "virtual serial port". Then the GPS program I have
running on my MAC, RouteBuddy, can read the data from that serial port
as standard.

The only part I am concerned about here though, is if I can create a
serial port virtually and push data out of it?

Hope that defines a little more clarity for yourself.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Open source web crawler with mysql integration

2009-04-10 Thread Philip Semanchuk


On Apr 10, 2009, at 12:33 PM, bruce wrote:


phillip...

lots of code is opened source "as is"!!!

when you get right down to it, a good deal of "open source" code from
sourceforge/hotscritps/freshmeat/etc.. is pretty poor, but it is open
sourced.

you could simply toss your code out into the open source pool, and  
not be

worried about supporting it, or even touching it again...


You're right, and I like your enthusiasm. But I don't want to invite  
people to use my code if it's just going to be frustrating to 90% of  
them. It's bad for my reputation. And for the reputation of open  
source in general, but I'm more concerned about me. ;)






-Original Message-
From: python-list-bounces+bedouglas=earthlink@python.org
[mailto:python-list-bounces+bedouglas=earthlink@python.org]on  
Behalf

Of Philip Semanchuk
Sent: Friday, April 10, 2009 8:10 AM
To: Python (General)
Subject: Re: Open source web crawler with mysql integration



On Apr 10, 2009, at 10:28 AM, Support Desk wrote:


Sounds Interesting. When its done would you care to share it?


Hi Michael,
The coding has been done (as much as software is ever "done") for a
couple of years now. It's mothballed now, sitting on my hard drive.
The problem with open sourcing it isn't that the code is incomplete,
the problem is that it's insufficiently documented, features a
byzantine install procedure and contains a lot of code & assumptions
that were relevant to my business but would not be of interest to most
people looking to download a general-purpose spider. I'd love to open
source it and if someone wants to pay me to make it open source-able,
let's talk! But if I have to do it on my own time for free it will be
a while (maybe never, although I hope not) before I can make the time.

Regards
Philip





-Original Message-
From: Philip Semanchuk [mailto:phi...@semanchuk.com]
Sent: Thursday, April 09, 2009 9:46 PM
To: Python
Subject: Re: Open source web crawler with mysql integration


On Apr 9, 2009, at 7:37 PM, Daniel Fetchinson wrote:


I'm looking for a crawler that can spider my site and toss the
results
into mysql so, in turn, that database can be indexed by Sphinx
Search.

Since I don't want to reinvent the wheel, is anyone aware of any
open
source projects or code snippets that can already handle this?


Have a look at http://nikitathespider.com/python/



As the author of Nikita, I can say that (a) she used Postgres and (b)
the code wasn't open sourced except for a couple of small parts. The
service is now defunct. It wasn't making money. Ideally I'd like to
open source the code one day, but it would take a lot of  
documentation
work to make it installable by others, and I won't have the time to  
do

that for the foreseeable future.

At the URL provided there's a nice module for parsing robots.txt  
files

(better than the one in the standard library IMHO) but that's about
it.

FYI, I wrote my spider in Python because I couldn't find a decent one
written in Python. There's Nutch, but that's not Python (Java I
think).

Good luck
Philip





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



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


Re: zProblem

2009-04-10 Thread norseman

Gabriel Genellina wrote:
En Fri, 10 Apr 2009 14:50:57 -0300, norseman  
escribió:



However, in order to explain my problem, I need to control the font
since text graphics only work for a given font. It's as small as I can
get it.


I didn't understand what your problem is actually.




UUHHDid you read the pdf?
--
http://mail.python.org/mailman/listinfo/python-list


Re: Unsupported operand types in if/else list comprehension

2009-04-10 Thread Miles
On Fri, Apr 10, 2009 at 5:26 PM, Mike H wrote:
> Thanks to all of you.
>
> FYI, I'm doing this because I'm working on creating some insert
> statements in SQL, where string values need to be quoted, and integer
> values need to be unquoted.

This is what you should have posted in the first place.  Your solution
is entirely the wrong one, because it will break if your input strings
contain the quote character (and suffers from other issues as
well)--this is where SQL injection vulnerabilities come from.  The
safe and correct way is to allow your database driver to insert the
parameters into the SQL query for you; it will look something like
this (though the exact details will vary depending on what module
you're using):

cursor.execute('INSERT INTO my_table VALUES (?, ?, ?)', ['test',1,'two'])

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


Re: Adding a Badge to an Icon in Mac OS X

2009-04-10 Thread Miles
On Fri, Apr 10, 2009 at 5:22 PM, bingo wrote:
> PyObjc seems to offer the option to add badges to icons in the doc. I
> need to add badges to any icon... kinda like SCPlugin and dropbox do.
> I think that SCPlugin is doing it through carbon Icon Services. But I
> am still trying to figure out how it is done!

I believe those programs are able to do so because they are Finder
plugins--it's not something that a separate program could do.  This
isn't really a Python question, though; you'd probably have better
luck finding answers on a OS X-related list.

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


Re: how to use logging.config.fileConfig ?

2009-04-10 Thread Vinay Sajip
On Apr 10, 3:51 pm, Alexandru  Moșoi  wrote:
> config.py and I found a big comment saying that old loggers are
> disabled! Why? What am I doing wrong?

This is by design, because fileConfig is not meant for incremental
configuration - it is for complete configuration of the logging
system. The old loggers which are not mentioned in the config file are
disabled (rather than removed from memory) as there might be threads
running which reference them. So if your logging configuration is
static for an application run you can use fileConfig. If it is
dyanmic, you are better off using programmatic configuration.

Regards,

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


Re: ValueError: I/O operation on closed file

2009-04-10 Thread Vinay Sajip
On Apr 10, 9:25 pm, dj  wrote:
> I have a handler which I use with a set of log levels for the 
> pythonloggingmodule.
>
> --- myhandler.py
> 
> importlogging.handlers
>
> # create my handler class
> class MyHandler(logging.handlers.RotatingFileHandler):
> def __init__(self, fn):
>logging.handlers.RotatingFileHandler.__init__(self, fn,
>
> maxBytes=10485760, backupCount=5)
>
> # Register handler in the "logging.handlers" 
> namespacelogging.handlers.MyHandler = MyHandler
> 
>
> Using it, repeatedly generates this error:
>
> Traceback (most recent call last):
>   File "C:\python26\lib\logging\handlers.py", line 74, in emit
> if self.shouldRollover(record):
>   File "C:\python26\lib\logging\handlers.py", line 146, in
> shouldRollover
> self.stream.seek(0, 2)  #due to non-posix-compliant Windows
> feature
> ValueError: I/O operation on closed file
>
> I am completely stumped  has to what could be the issue.
> Any help would be greatly appreciated.

Not sure - you may need to post a small script which demonstrates the
error repeatably. Otherwise, it may be caused by e.g. other handles
being open to the same file (say, if you open a FileHandler and a
RotatingFileHandler with the same path, or have one of the log files
open in an editor which locks the file.

Regards,

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


Re: zProblem

2009-04-10 Thread norseman

norseman wrote:

Gabriel Genellina wrote:
En Fri, 10 Apr 2009 14:50:57 -0300, norseman  
escribió:



However, in order to explain my problem, I need to control the font
since text graphics only work for a given font. It's as small as I can
get it.


I didn't understand what your problem is actually.




UUHHDid you read the pdf?
--
http://mail.python.org/mailman/listinfo/python-list


==

Let me recant a bit on my reply to Gabriel:
	To Wit:  I re-read the contents of the pdf and I think I can see where 
I wasn't completely clear on the differences between grid and parcel.  I 
need to place differently sized "pieces of paper" on a mockup. The docs 
to Tkinter mention using inches or other units of measure but Tkinter 
does not actually allow that. At least I cannot get it to do so. Another 
tidbit I had found stated that the "grid" would be the bounding 
dimensions of the first "piece of paper" placed on the background and 
could not be confined to itself only.  Which seem to be true. 
Publishing companies have long used gridded backdrops to provide 
placement of non-same sized things to help minimize wasted space. (Good 
layout people eyeball it just fine.)  I need some way to get things of 
different sizes onto the backdrop - where I want them,  regardless. 
Something like, backdrop is 10 inches wide and 5 inches tall. First 
piece of paper is 2x2 inches and second is 6x3 (goes under first) and 
third is 4 x 2 and goes next to first and on top of second. And so on.

Tkinter (actually Tk) isn't liking me very much.


Is that better?
I'm a little too close to the problem.

Steve


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


Re: weird try/finally behaviour

2009-04-10 Thread Terry Reedy

Sylvain Thénault wrote:

Hi there,

I've encountered the following behaviour which I found surprising:


def test():

... for x in ('test', 'tests'):
...  try:
... if True:
...   print 'return'
...   return 1
...  finally:
... print 'break'
... break
... print 'end'
... 

test()

return
break
end



If you say 'print test()', you shoud see None printed after 'end' (at 
least with 3.0) from the function falling off the end.


The 'if True:' line make no difference.


As you can see, the 'break' in the finally block makes the 'return 1' beeing 
ignored.
Is this a known caveat or should it be considered as a bug?


Neither, but it s a bit subtle.  If you replace 'break' with 'return 2', 
what would you expect?  What does happen is that 2, not 1, is returned. 
 Similarly, the break sends control to "print 'end'" and thence to the 
implicit 'return None'.


The try doc on finally says "If the finally clause raises another 
exception or executes a return or break statement, the saved exception 
is lost."  The same is true for saved returns, for the same reason: the 
implicit END-FINALLY (an actual byte code) that completes the pending 
return/exception is never reached.


When bugs.python.org works again, I will try to remember to suggest a 
doc improvement.


Terry Jan Reedy

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


Re: Bug tracker off-line?

2009-04-10 Thread Terry Reedy

Aahz wrote:

In article ,
MRAB   wrote:

Is it just me or is the bug tracker site having problems? I'm not having
a problem with other sites.


Someone else reported this on python-dev


Still down 7 hours later.

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


Re: Python 2.6/3.0 packages for Ubuntu?

2009-04-10 Thread Terry Reedy

Benjamin Kaplan wrote:



On Fri, Apr 10, 2009 at 5:15 PM, > wrote:



   >> Does Ubuntu really not have Python 2.6 or 3.0 packages

   Benjamin> Which version of Ubuntu are you using?

   Benjamin> Hardy: 2.5.2
   Benjamin> Intrepid: 2.5.2 and 3.0rc1
   Benjamin> Jaunty (beta) : 2.6.2rc1 and 3.0.1

I'm using Intrepid.  Is there a simple way within Synaptic or by editing
config files to jump up to Jaunty?


You can either wait 13 days for the final release, 


I am thinking of getting Ubuntu.  Cannot one also download the sources 
and compile?  (Without replacing the system version!)


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


Re: Unsupported operand types in if/else list comprehension

2009-04-10 Thread Terry Reedy

Mike H wrote:

Hello all, I have a question about the if/else aspect of list comprehension:

I would like to go through a list and place quotes around an item if
it is a string, and keep the item the same if it's anything else:

e.g.['a',9,'8b'] --> ['"a"', 9, '"8b"']

I understand that if/else list comprehension should be generally:

b=[(F,T)[boolean test] for val in X]

so, I tried the following code:

a=['test',1,'two']
b=[(inst, '"'+inst+'"')[isinstance(inst, str)] for inst in a]

I end up getting the error: unsupported operand type(s) for +: 'int' and 'str'


From playing around with other examples, I get the feeling that Python

is calculating both values (inst and '"'+inst+'"') before selecting
which one to pass to the new list. Am I right? Is there any way I can
do this using list comprehension?


I would just use an old-fashioned for loop, especially if it were ok to 
quote the strings 'in-place'.


for i, item in enumerate(X):
  if isinstance(item,str):
X[i] = '"'+item+'"'

tjr

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


Re: safe eval of moderately simple math expressions

2009-04-10 Thread Steven D'Aprano
On Thu, 09 Apr 2009 13:13:50 -0400, Terry Reedy wrote:

> Joel Hedlund wrote:
>> Hi all!
>> 
>> I'm writing a program that presents a lot of numbers to the user, and I
>> want to let the user apply moderately simple arithmentics to these
>> numbers. One possibility that comes to mind is to use the eval
>> function, but since that sends up all kinds of warning flags in my
>> head,
> 
> Where does the program execute?  If on the user's own machine, no
> problem.

Until the user naively executes a code sample he downloaded from the 
Internet, and discovers to his horror that his *calculator* is able to 
upload his banking details to an IRC server hosted in Bulgaria.

How quickly we forget... for twenty or thirty years all malware 
infections was via programs executed on the user's own machine.


> Eval is no more dangerous than Python itself.

But users know Python is a Turing-complete programming language that can 
do anything their computer can do. It would come to an unpleasant 
surprise to discover that (say) your icon editor was also a Turing-
complete programming language capable of doing anything your C-compiler 
could do. The same holds for applications written in Python.



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


Re: Python 2.6/3.0 packages for Ubuntu?

2009-04-10 Thread Benjamin Kaplan
On Fri, Apr 10, 2009 at 8:29 PM, Terry Reedy  wrote:

> Benjamin Kaplan wrote:
>
>>
>>
>> On Fri, Apr 10, 2009 at 5:15 PM, mailto:s...@pobox.com>>
>> wrote:
>>
>>
>>   >> Does Ubuntu really not have Python 2.6 or 3.0 packages
>>
>>   Benjamin> Which version of Ubuntu are you using?
>>
>>   Benjamin> Hardy: 2.5.2
>>   Benjamin> Intrepid: 2.5.2 and 3.0rc1
>>   Benjamin> Jaunty (beta) : 2.6.2rc1 and 3.0.1
>>
>>I'm using Intrepid.  Is there a simple way within Synaptic or by
>> editing
>>config files to jump up to Jaunty?
>>
>>
>> You can either wait 13 days for the final release,
>>
>
> I am thinking of getting Ubuntu.  Cannot one also download the sources and
> compile?  (Without replacing the system version!)
>

By default, user-compiled programs are installed in /usr/local, while the
system programs are installed in /usr, so you won't replace anything unless
you specify the prefix (though you will have to use the full path to get the
system version).

If you want to build a package from a later version of Ubuntu (they add a
bunch of distro-specific patches to their packages), you can download that
source tarball and Ubuntu's patches from packages.ubuntu.com. The binary
.debs are there too but those will replace the system versions (and you'll
probably need to upgrade a lot of the dependencies).

FYI, the normal binary packages in the repositories don't include the header
files so you'll need to install the dev versions of all the packages as well
(i.e. you need both libsqlite3.0 and libsqlite3-dev to build python's sqlite
module).
--
http://mail.python.org/mailman/listinfo/python-list


Re: zProblem

2009-04-10 Thread Steven D'Aprano
On Fri, 10 Apr 2009 10:50:57 -0700, norseman wrote:

> Moderator:  I apologize for attaching anything.

This newsgroup has no moderator.



> However, in order to explain my problem, I need to control the font
> since text graphics only work for a given font.

Use the least common denominator available, so-called "ASCII graphics", 
and put a note that the diagrams are best viewed in a non-proportional 
font like Courier or equivalent. E.g.:

+---+
| Input |
+---+
|  +--+
|--|  Special |
|  +--+
*   ++
*  Box  *---| Output |
*   ++

Even if the lines don't quite line up, it's decipherable.

This is a newsgroup for a programming language. Nearly everyone will be 
using a monospaced font already, or at least nearly all the *serious* 
contributors, so that code blocks will line up correctly.

More importantly, you should describe the nature of your problem in the 
body of the post, as concisely as possible, and use attachments for as 
little content as possible. For many people, it is inconvenient and 
difficult to deal with attachments in their newsreader, and people won't 
bother unless they know the topic is of interest to them.

You should also read this:

http://www.catb.org/~esr/faqs/smart-questions.html


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


Re: Get the ipv6 address from a interface

2009-04-10 Thread Дамјан Георгиевски
> In Linux, you can only have one IPv4 address per interface (and you
> have to use alias interfaces, such as eth0:0, to assign multiple
> addresses to a physical link).

that's actually not correct, use the "ip" tool (iproute2 package) to see 
how easily you can have several addresses to a single interface.
  ip addr add 1.1.1.1/24 dev eth0
  ip addr add 2.2.2.1/24 dev eth0

the need for alias interfaces has been removed, a long time ago (AFAIK 
even before the 2.4 kernel).

-- 
дамјан ( http://softver.org.mk/damjan/ )

In theory, there is no difference between theory and practice.
 But, in practice, there is.

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


Re: Unsupported operand types in if/else list comprehension

2009-04-10 Thread Steven D'Aprano
On Fri, 10 Apr 2009 17:07:38 -0400, Mike H wrote:

> Hello all, I have a question about the if/else aspect of list
> comprehension:
> 
> I would like to go through a list and place quotes around an item if it
> is a string, and keep the item the same if it's anything else:
> 
> e.g.['a',9,'8b'] --> ['"a"', 9, '"8b"']
> 
> I understand that if/else list comprehension should be generally:
> 
> b=[(F,T)[boolean test] for val in X]

That's *one* specific form of a list comprehension. A more general form 
is:

alist = [ some-expression for val in sequence if condition ]

In your case, (F, T)[boolean test] counts as one such possible 
expression. It's not a "magic" list comprehension syntax, you can use it 
anywhere:

>>> t = ("not true", "correct")
>>> t[45 > 15]
'correct'
>>> ("incorrect", "true")[15 > 99]
'incorrect'

The disadvantage of the (F, T)[bool] expression is that both F and T are 
evaluated *before* the boolean test. Think about it: you have to create 
the tuple (F, T) before you can index into it! 


In your case, there are three obvious solutions (untested). In no 
particular order:

(1) Use a helper function.

def quote_obj(obj):
"""Return strings quoted, and all other objects unchanged."""
if isinstance(obj, basestring):
return '"%s"' % obj
else:
return obj

b = [quote_obj(x) for x in alist]


(2) Use the ternary if expression:

b = ['"%s"' % obj if isinstance(obj, basestring) else obj for obj in 
alist]


(3) Use a regular for loop with an accumulator:

b = []
for obj in alist:
if isinstance(obj, basestring):
obj = '"%s"' % obj
b.append(obj)



The less obvious solution is to rethink your program design. Having 
multiple types of object in the one list is often (but not always) a sign 
that your design is too complicated and is trying to do to much in too 
little code. It is a mild code-smell:

http://www.joelonsoftware.com/articles/Wrong.html



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


[rfc] An object that creates (nested) attributes automatically on assignment

2009-04-10 Thread Edd
Hi folks,

I'd like to use Python itself as the configuration language for my
Python application. I'd like the user to be able to write something
like this in their config file(s):

   cfg.laser.on = True
   cfg.laser.colour = 'blue'
   cfg.discombobulated.vegetables = ['carrots', 'broccoli']
   # ...

To this end, I've created a class that appears to allow instance
variables to be created on the fly. In other words, I can to the
following to read a config file:

cfg = Config()
execfile(filename, {'cfg', cfg}, {})

However, I think my implementation of the Config class is a little
crappy. I'd really appreciate the critical eye of a pro. Here's the
sauce:

class Config(object):
def __init__(self, sealed=False):
def seal():
for v in self._attribs.values():
if isinstance(v, self.__class__): v.seal()
del self.__dict__['seal']

d =  {'_attribs': {}, '_a2p': None}
if not sealed: d['seal'] = seal

self.__dict__.update(d)

def __getattr__(self, key):
if not key in self._attribs:
d = Config(sealed='seal' not in self.__dict__)
def add2parent():
self._attribs[key] = d
if self._a2p:
self._a2p()
self._a2p = None

# if anything is assigned to an attribute of d,
# make sure that d is recorded as an attribute of this
Config
d._a2p = add2parent
return d
else:
return self._attribs[key]

def __setattr__(self, key, value):
if key in self.__dict__:
self.__dict__[key] = value
else:
if not 'seal' in self.__dict__:
clsname = self.__class__.__name__
raise AttributeError("'%s' object attribute '%s'
is read-only (object is sealed)" % (clsname, key))
self.__dict__['_attribs'][key] = value
if self._a2p:
self._a2p()
self._a2p = None

def __delattr__(self, key):
if key in self.__dict__:
clsname = self.__class__.__name__
raise AttributeError("can't delete '%s' object
attribute '%s' as it is used for book-keeping!" % (clsname, key))
else:
if key in self._attribs:
del self._attribs[key]

def __bool__(self):
return bool(self._attribs)

def __nonzero__(self):
return bool(self._attribs)

if __name__ == '__main__':
cfg = Config()
cfg.a = 1
cfg.b.c = 2
cfg.d.e.f.g.h = [1, 2, 3]
print cfg.a
print cfg.b.c
print cfg.d.e.f.g.h

del cfg.b.c
print cfg.b.c

try:
del cfg.d.e._attribs
except AttributeError, ex:
print ex

cfg.seal()
try:
cfg.k.l.z = []
except AttributeError, ex:
print ex

Once the config is loaded, it will be passed down to other user-
written scripts and it's important that these scripts don't
accidentally change the config. So the idea is that I'll call cfg.seal
() to prevent any further changes before passing it on to these other
scripts. Beyond the general fiddliness of the code, I think the way
seal() currently works is particularly pants.

I considered using a simpler approach:

def mkdd(): return defaultdict(mkdd)
cfg = mkdd()
execfile(filename, {'cfg': cfg}, {})

But I quite like the way the '.' separators quite naturally (IMO)
indicate a hierarchy of settings.

Comments and suggestions welcome!

Kind regards,

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


Re: regexp strangeness

2009-04-10 Thread Steven D'Aprano
On Thu, 09 Apr 2009 20:48:11 +0100, Dale Amon wrote:

> This finds nothing:
...
> DEC029 = re.compile("[^&0-9A-Z/ $*,.\-:#@'=\"[<(+\^!);\\\]%_>?]")
 
> This works correctly:
...
> DEC029 = re.compile("[^&0-9A-Z/ $*,.\-:#@'=\"[<(+\^!)\\;\]%_>?]")


> They differ only in the positioning of the quoted backslash.

So you're telling us that two different regexs do different things? Gosh. 
Thanks for the heads up!

BTW, when creating regexes, you may find it much easier if you use raw 
strings to avoid needing to escape backslashes:

'\n' in a string is a newline escape. To get a literal backslash followed 
by an n, you can write '\\n' or r'\n'.



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


Re: Open source web crawler with mysql integration

2009-04-10 Thread Lawrence D'Oliveiro
In message , Philip 
Semanchuk wrote:

> I'd love to open source it and if someone wants to pay me to make it open
> source-able, let's talk!

Nobody's going to pay you for something of doubtful value--it's up to you to 
prove the value of the code first. You must go to the community, the 
community will not come to you.

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


Re: Python 2.6/3.0 packages for Ubuntu?

2009-04-10 Thread Lawrence D'Oliveiro
In message , Terry 
Reedy wrote:

> I am thinking of getting Ubuntu.  Cannot one also download the sources
> and compile?  (Without replacing the system version!)

Debian Unstable offers about 3 different versions of Python that you can 
install side-by-side.

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


Re: Python 2.6/3.0 packages for Ubuntu?

2009-04-10 Thread skip

Terry> I am thinking of getting Ubuntu.  Cannot one also download the
Terry> sources and compile?  (Without replacing the system version!)

Sure.  I compile it all the time on my Mac.  This is just a little bupkis
virtual server where I run my personal website.  I'd like to just install
vendor-provided packages, at least as much as I can.

-- 
Skip Montanaro - s...@pobox.com - http://www.smontanaro.net/
"XML sucks, dictionaries rock" - Dave Beazley
--
http://mail.python.org/mailman/listinfo/python-list


Re: email in separate thread

2009-04-10 Thread Aahz
In article <66f23ffc-345e-4603-9519-cd122a116...@j12g2000vbl.googlegroups.com>,
joeygartin   wrote:
>
>The problem is the page hangs while the emails are sent.  My current
>hosting situation does not give me direct access to an email queue.
>So I have two options (that I can think of):
>
>1) Write the email information to a file and then run a cron job in
>the background that routinely checks the file and sends the necessary
>emails off
>
>OR
>
>2) Spin-off a thread (which I have no background with at all!) for the
>emails and be able to redirect the user to the next page.

2a) Fork off a separate process

How frequently do you need to send e-mail?
-- 
Aahz (a...@pythoncraft.com)   <*> http://www.pythoncraft.com/

Why is this newsgroup different from all other newsgroups?
--
http://mail.python.org/mailman/listinfo/python-list


Re: How to create a virtual serial port?

2009-04-10 Thread Banibrata Dutta
On Sat, Apr 11, 2009 at 3:17 AM, Stuart Davenport <
stuart.davenp...@gmail.com> wrote:

> I'm on a OS X, python 2.5. Basically I will have a remote application
> pushing data (GPS) over the network to a python application I have
> running on my Mac, I want this python application to again push the
> data on to a "virtual serial port". Then the GPS program I have
> running on my MAC, RouteBuddy, can read the data from that serial port
> as standard.


Python app reads data "off" the network (s.a. TCP/IP maybe), and then pushes
the data onto a serial-port ? And since you don't have the real device
(using the serial-port), you want to create a virtual serial-port ? Is that
the intent ? Or, is it something like this that you are trying to do --
http://www.anzio.com/products/virtport.htm ? Or something like this --
http://www.softizer.com/show_product/software_development/components_libraries/virtual_serial_ports_driver_xp/


> The only part I am concerned about here though, is if I can create a
> serial port virtually and push data out of it?
>

I'd guess this capability to require creating a "kext" (kernel extension /
driver) on OS/X, and feel that this is not possible in user-land, and thus
not a Python domain problem.

-- 
regards,
Banibrata
http://www.linkedin.com/in/bdutta
--
http://mail.python.org/mailman/listinfo/python-list


Re: How to create a virtual serial port?

2009-04-10 Thread Banibrata Dutta
This might help: http://en.wikipedia.org/wiki/COM_port_redirector

On Sat, Apr 11, 2009 at 8:34 AM, Banibrata Dutta
wrote:

> On Sat, Apr 11, 2009 at 3:17 AM, Stuart Davenport <
> stuart.davenp...@gmail.com> wrote:
>
>> I'm on a OS X, python 2.5. Basically I will have a remote application
>> pushing data (GPS) over the network to a python application I have
>> running on my Mac, I want this python application to again push the
>> data on to a "virtual serial port". Then the GPS program I have
>> running on my MAC, RouteBuddy, can read the data from that serial port
>> as standard.
>
>
--
http://mail.python.org/mailman/listinfo/python-list


Re: Open source web crawler with mysql integration

2009-04-10 Thread Philip Semanchuk


On Apr 10, 2009, at 10:37 PM, Lawrence D'Oliveiro wrote:

In message ,  
Philip

Semanchuk wrote:

I'd love to open source it and if someone wants to pay me to make  
it open

source-able, let's talk!


Nobody's going to pay you for something of doubtful value--it's up  
to you to

prove the value of the code first. You must go to the community, the
community will not come to you.


Not true, people pay for things of doubtful value all the time! I just  
need a better sales team. =)


Seriously, if I had expectations of talking someone into fronting  
money, do you think I'd use words like "insufficiently documented" and  
"byzantine"? I was just trying to emphasize what I thought was an  
obvious point: I can't afford the time to open source my code right  
now, but if someone were to make it worth my while, that'd be a  
different story. I may as well have said "if I win the lottery". It  
*could* happen, but I'm not holding my breath (or buying lottery  
tickets).


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


Re: [rfc] An object that creates (nested) attributes automatically on assignment

2009-04-10 Thread Steven D'Aprano
On Fri, 10 Apr 2009 19:04:38 -0700, Edd wrote:

> Hi folks,
> 
> I'd like to use Python itself as the configuration language for my
> Python application. I'd like the user to be able to write something like
> this in their config file(s):
> 
>cfg.laser.on = True
>cfg.laser.colour = 'blue'
>cfg.discombobulated.vegetables = ['carrots', 'broccoli'] # ...
> 
> To this end, I've created a class that appears to allow instance
> variables to be created on the fly.

Um, don't all classes allow that?

>>> class MyClass(): pass
...
>>> instance = MyClass()
>>>

Or do you mean instance *attributes*? Again, apart from built-in types 
and classes that use __slots__, all classes allow that.

>>> instance.parrot = 'Norwegian Blue'
>>>

> In other words, I can to the
> following to read a config file:
> 
> cfg = Config()
> execfile(filename, {'cfg', cfg}, {})


That's okay so long as you trust the user not to put malicious, or buggy, 
code in your config file. Personally, I think config files should be more 
tolerant of errors than a programming language.


> However, I think my implementation of the Config class is a little
> crappy. I'd really appreciate the critical eye of a pro. Here's the
> sauce:

For starters, where is your documentation? No doc strings, not even any 
comments! No, I tell a lie... *one* obscure comment that doesn't really 
explain much.

 
> class Config(object):
> def __init__(self, sealed=False):
> def seal():
> for v in self._attribs.values():
> if isinstance(v, self.__class__): v.seal()
> del self.__dict__['seal']
> 
> d =  {'_attribs': {}, '_a2p': None}
> if not sealed: d['seal'] = seal
> 
> self.__dict__.update(d)

I'm going to try to guess what the above does. When you initialise an 
instance, you can tell the instance to be "sealed" or unsealed. I'm not 
sure what the difference is, or why you would choose one over the other. 
Sealed instances seem to be exactly the same as unsealed instances, 
except they have a seal() method (actually a closure). The seal method, 
when called, recursively seals any embedded Config instances inside the 
current instance, then deletes itself.

Arghhh!!! Self-modifying code!!! Unclean, unclean!!!

I'm not sure why seal() is necessary -- it seems to me that if present, 
all it does is delete itself. So why not just leave it out altogether?

You also have a rather complicated way of adding instance attributes. 
Instead of 

d =  {'_attribs': {}, '_a2p': None}
self.__dict__.update(d)

why not just do the more obvious:

self._attribs = {}
self._a2p = None

?

 

> def __getattr__(self, key):
> if not key in self._attribs:
> d = Config(sealed='seal' not in self.__dict__) def
> add2parent():
> self._attribs[key] = d
> if self._a2p:
> self._a2p()
> self._a2p = None


It looks like you are just re-inventing the normal attribute mechanism of 
Python. I'm not sure why you feel this is necessary. And it contains MORE 
self-modifying code! Yuck! Frankly I don't care enough to dig into your 
code to understand how it works in detail.



> # if anything is assigned to an attribute of d, # make
> sure that d is recorded as an attribute of this
> Config
> d._a2p = add2parent
> return d
> else:
> return self._attribs[key]
> 
> def __setattr__(self, key, value):
> if key in self.__dict__:
> self.__dict__[key] = value
> else:
> if not 'seal' in self.__dict__:
> clsname = self.__class__.__name__
> raise AttributeError("'%s' object attribute '%s'
> is read-only (object is sealed)" % (clsname, key))
> self.__dict__['_attribs'][key] = value if self._a2p:
> self._a2p()
> self._a2p = None

Does "sealed" mean that the instance is read-only? If so, and if I'm 
reading this correctly, I think it is buggy. You allow modifications to 
attributes inside __dict__ *without* checking to see if the instance is 
read-only. Then you get the test backwards: surely the existence, not the 
absence, of a 'seal' attribute should mean it is sealed?



> def __delattr__(self, key):
> if key in self.__dict__:
> clsname = self.__class__.__name__
> raise AttributeError("can't delete '%s' object
> attribute '%s' as it is used for book-keeping!" % (clsname, key))
> else:
> if key in self._attribs:
> del self._attribs[key]

Nothing much to say here, except that you're doing more work re-inventing 
the wheel, storing attributes inside _attribs instead of using the 
general attribute mechanism. Se

sharing/swapping items between lists

2009-04-10 Thread Ross
I'm trying to design an iterator that produces two lists. The first
list will be a list of unique pairings and the second will be a list
of items that weren't used in the first list. After each round, the
items that weren't used in the round before will get put back in and
the second list will be populated with unique items. To clarify,
here's an example of what my output would be if I had 8 items:

First Iteration

LIST 1LEFTOVERS LIST

[(1,2),(3,4),(5,6)]   [7,8]

Second Iteration

[(1,3), (2,7),(4,8)] [5,6]

Third Iteration

[(1,5), (2,6), (7,8)][3,4]

etc

Additionally, I want the items in the "leftovers" list to be used the
same amount.

Can you guys suggest an approach to this problem...I'm trying to teach
myself python so an outline of how to approach this would probably be
more helpful to me than an explicit solution. I'll cry mercy if I
can't figure it out after your hints.
--
http://mail.python.org/mailman/listinfo/python-list


Re: sharing/swapping items between lists

2009-04-10 Thread Paul Rubin
Ross  writes:
> Can you guys suggest an approach to this problem...I'm trying to teach
> myself python so an outline of how to approach this would probably be
> more helpful to me than an explicit solution. I'll cry mercy if I
> can't figure it out after your hints.

Look at the "set" datatype.  Think of making some sets of integers
and finding their unions and intersections as appropriate.
--
http://mail.python.org/mailman/listinfo/python-list


Re: zProblem

2009-04-10 Thread Gabriel Genellina
En Fri, 10 Apr 2009 21:14:01 -0300, norseman   
escribió:

norseman wrote:

Gabriel Genellina wrote:
En Fri, 10 Apr 2009 14:50:57 -0300, norseman   
escribió:



However, in order to explain my problem, I need to control the font
since text graphics only work for a given font. It's as small as I can
get it.

I didn't understand what your problem is actually.

 UUHHDid you read the pdf?


Yes (and I guess not many people would do). It wasn't clear *what* you  
were asking until this post.


	To Wit:  I re-read the contents of the pdf and I think I can see where  
I wasn't completely clear on the differences between grid and parcel.


(are you sure the grammatical issues are relevant at all...?)

I need some way to get things of different sizes onto the backdrop -  
where I want them,  regardless. Something like, backdrop is 10 inches  
wide and 5 inches tall. First piece of paper is 2x2 inches and second is  
6x3 (goes under first) and third is 4 x 2 and goes next to first and on  
top of second. And so on.

Tkinter (actually Tk) isn't liking me very much.


Now, if the above paragraph really summarizes your problem, I think you  
should use the "place" geometry manager, not grid (nor pack).
The Tkinter documentation [1] is rather short but the Tcl docs [2] have  
more info.


[1] http://effbot.org/tkinterbook/place.htm
[2] http://www.tcl.tk/man/tcl8.4/TkCmd/place.htm

--
Gabriel Genellina

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


  1   2   >