"Hansika Motwani IN DENIM JEANS" "Hansika Motwani BEAUTIFUL BELLY" "Hansika Motwani as college GIRL" "Hansika Motwani in GYM in RED BRA" "Hansika Motwani in GREEN SAREE BELLY" "BOLLYWOOD GIRLS" on h

2010-05-28 Thread Naeem
"Hansika Motwani IN DENIM JEANS" "Hansika Motwani BEAUTIFUL BELLY"
"Hansika Motwani as college GIRL" "Hansika Motwani in GYM in RED BRA"
"Hansika Motwani in GREEN SAREE BELLY" "BOLLYWOOD GIRLS" on
http://hollywood-bollywood-pics.blogspot.com "Hansika Motwani IN
DENIM JEANS" "Hansika Motwani BEAUTIFUL BELLY"  "Hansika Motwani as
college GIRL" "Hansika Motwani in GYM in RED BRA" "Hansika Motwani in
GREEN SAREE BELLY" "BOLLYWOOD GIRLS" on 
http://hollywood-bollywood-pics.blogspot.com
"Hansika Motwani IN DENIM JEANS" "Hansika Motwani BEAUTIFUL BELLY"
"Hansika Motwani as college GIRL" "Hansika Motwani in GYM in RED BRA"
"Hansika Motwani in GREEN SAREE BELLY" "BOLLYWOOD GIRLS" on
http://hollywood-bollywood-pics.blogspot.com "Hansika Motwani IN
DENIM JEANS" "Hansika Motwani BEAUTIFUL BELLY"  "Hansika Motwani as
college GIRL" "Hansika Motwani in GYM in RED BRA" "Hansika Motwani in
GREEN SAREE BELLY" "BOLLYWOOD GIRLS" on 
http://hollywood-bollywood-pics.blogspot.com
"Hansika Motwani IN DENIM JEANS" "Hansika Motwani BEAUTIFUL BELLY"
"Hansika Motwani as college GIRL" "Hansika Motwani in GYM in RED BRA"
"Hansika Motwani in GREEN SAREE BELLY" "BOLLYWOOD GIRLS" on
http://hollywood-bollywood-pics.blogspot.com "Hansika Motwani IN
DENIM JEANS" "Hansika Motwani BEAUTIFUL BELLY"  "Hansika Motwani as
college GIRL" "Hansika Motwani in GYM in RED BRA" "Hansika Motwani in
GREEN SAREE BELLY" "BOLLYWOOD GIRLS" on 
http://hollywood-bollywood-pics.blogspot.com
"Hansika Motwani IN DENIM JEANS" "Hansika Motwani BEAUTIFUL BELLY"
"Hansika Motwani as college GIRL" "Hansika Motwani in GYM in RED BRA"
"Hansika Motwani in GREEN SAREE BELLY" "BOLLYWOOD GIRLS" on
http://hollywood-bollywood-pics.blogspot.com "Hansika Motwani IN
DENIM JEANS" "Hansika Motwani BEAUTIFUL BELLY"  "Hansika Motwani as
college GIRL" "Hansika Motwani in GYM in RED BRA" "Hansika Motwani in
GREEN SAREE BELLY" "BOLLYWOOD GIRLS" on 
http://hollywood-bollywood-pics.blogspot.com
"Hansika Motwani IN DENIM JEANS" "Hansika Motwani BEAUTIFUL BELLY"
"Hansika Motwani as college GIRL" "Hansika Motwani in GYM in RED BRA"
"Hansika Motwani in GREEN SAREE BELLY" "BOLLYWOOD GIRLS" on
http://hollywood-bollywood-pics.blogspot.com "Hansika Motwani IN
DENIM JEANS" "Hansika Motwani BEAUTIFUL BELLY"  "Hansika Motwani as
college GIRL" "Hansika Motwani in GYM in RED BRA" "Hansika Motwani in
GREEN SAREE BELLY" "BOLLYWOOD GIRLS" on 
http://hollywood-bollywood-pics.blogspot.com
"Hansika Motwani IN DENIM JEANS" "Hansika Motwani BEAUTIFUL BELLY"
"Hansika Motwani as college GIRL" "Hansika Motwani in GYM in RED BRA"
"Hansika Motwani in GREEN SAREE BELLY" "BOLLYWOOD GIRLS" on
http://hollywood-bollywood-pics.blogspot.com "Hansika Motwani IN
DENIM JEANS" "Hansika Motwani BEAUTIFUL BELLY"  "Hansika Motwani as
college GIRL" "Hansika Motwani in GYM in RED BRA" "Hansika Motwani in
GREEN SAREE BELLY" "BOLLYWOOD GIRLS" on 
http://hollywood-bollywood-pics.blogspot.com
"Hansika Motwani IN DENIM JEANS" "Hansika Motwani BEAUTIFUL BELLY"
"Hansika Motwani as college GIRL" "Hansika Motwani in GYM in RED BRA"
"Hansika Motwani in GREEN SAREE BELLY" "BOLLYWOOD GIRLS" on
http://hollywood-bollywood-pics.blogspot.com "Hansika Motwani IN
DENIM JEANS" "Hansika Motwani BEAUTIFUL BELLY"  "Hansika Motwani as
college GIRL" "Hansika Motwani in GYM in RED BRA" "Hansika Motwani in
GREEN SAREE BELLY" "BOLLYWOOD GIRLS" on 
http://hollywood-bollywood-pics.blogspot.com
"Hansika Motwani IN DENIM JEANS" "Hansika Motwani BEAUTIFUL BELLY"
"Hansika Motwani as college GIRL" "Hansika Motwani in GYM in RED BRA"
"Hansika Motwani in GREEN SAREE BELLY" "BOLLYWOOD GIRLS" on
http://hollywood-bollywood-pics.blogspot.com "Hansika Motwani IN
DENIM JEANS" "Hansika Motwani BEAUTIFUL BELLY"  "Hansika Motwani as
college GIRL" "Hansika Motwani in GYM in RED BRA" "Hansika Motwani in
GREEN SAREE BELLY" "BOLLYWOOD GIRLS" on 
http://hollywood-bollywood-pics.blogspot.com
"Hansika Motwani IN DENIM JEANS" "Hansika Motwani BEAUTIFUL BELLY"
"Hansika Motwani as college GIRL" "Hansika Motwani in GYM in RED BRA"
"Hansika Motwani in GREEN SAREE BELLY" "BOLLYWOOD GIRLS" on
http://hollywood-bollywood-pics.blogspot.com "Hansika Motwani IN
DENIM JEANS" "Hansika Motwani BEAUTIFUL BELLY"  "Hansika Motwani as
college GIRL" "Hansika Motwani in GYM in RED BRA" "Hansika Motwani in
GREEN SAREE BELLY" "BOLLYWOOD GIRLS" on 
http://hollywood-bollywood-pics.blogspot.com
"Hansika Motwani IN DENIM JEANS" "Hansika Motwani BEAUTIFUL BELLY"
"Hansika Motwani as college GIRL" "Hansika Motwani in GYM in RED BRA"
"Hansika Motwani in GREEN SAREE BELLY" "BOLLYWOOD GIRLS" on
http://hollywood-bollywood-pics.blogspot.com "Hansika Motwani IN
DENIM JEANS" "Hansika Motwani BEAUTIFUL BELLY"  "Hansika Motwani as
college GIRL" "Hansika Motwani in GYM in RED BRA" "Hansika Motwani in
GREEN SAREE BELLY" "BOLLYWOOD GIRLS" on 
http://hollywood-bollywood-pics.blogspot.com
"Hansika Motwani IN DENIM JEANS" "Hansika Motwani BEAUTIFUL BELLY"
"Hansika Motwani as college GIRL

Re: Minor annoyances with properties

2010-05-28 Thread eb303
On May 27, 3:24 pm, Christian Heimes  wrote:
> >  Do I miss something?
> > Is this the way to do it, or is there a better one?
>
> A better way was introduced in Python 2.6. 
> Seehttp://docs.python.org/library/functions.html?highlight=property#prop...
> I have a Python only version around if you are still using Python 2.5.
>
> Christian

Mmmm, I might still miss something. OK, I can replace my initial
property using @property and @p.setter, but it doesn't seem to work in
subclasses:

class A(object):
  @property
  def p(self):
return self._p
  @p.setter
  def _set_p(self, p):
self._p = p
class B(A):
  @p.setter
  def _set_p(self, p):
…

results in:

Traceback (most recent call last):
  File "toto.py", line 8, in 
class B(A):
  File "toto.py", line 9, in B
@p.setter
NameError: name 'p' is not defined
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Minor annoyances with properties

2010-05-28 Thread eb303
On May 27, 8:56 pm, Francesco Bochicchio  wrote:
> On 27 Mag, 14:37, eb303  wrote:
>
>
>
> > Hello all,
>
> > I've been using Python properties quite a lot lately and I've found a
> > few things that are a bit annoying about them in some cases. I
> > wondered if I missed something or if anybody else has this kind of
> > problems too, and if there are better solutions than the ones I'm
> > using ATM.
>
> > The first annoyance is when I want to specialize a property in a
> > subclass. This happens quite often actually, and it is even sometimes
> > the reason why a plain attribute is turned into a property: a subclass
> > needs to do more things than the superclass when the property is
> > updated for example. So, of course, my first try was:
>
> > class A(object):
> >   def __init__(self):
> >     self._p = None
> >   def _get_p(self):
> >     return self._p
> >   def _set_p(self, p):
> >     self._p = p
> >   p = property(_get_p, _set_p)
> > class B(A):
> >   def _set_p(self, p):
> >     ## Additional things here…
> >     super(B, self)._set_p(p)
>
> > And of course, it doesn't work: the property has been bound to
> > A._set_p in A, so any new definition of _set_p in any subclass does
> > not replace the set method for the property. So I always have to add a
> > line:
> > p = property(A._get_p, _set_p)
> > in the subclass too. This is a bit awkward to me, since I have to
> > specify the superclass's name (super(…) can't be used, since it should
> > take B as an argument, and B isn't defined yet…). Do I miss something?
> > Is this the way to do it, or is there a better one?
>
> Don't know if is better, but you could add a level of indirection to
> solve it
>
>  class A(object):
>    def __init__(self):
>      self._p = None
>    def _get_p(self):
>      return self._p
>    def _set_p(self, p):
>      self._p = p
>    def _virtual_get_p (self): _get_p(self)
>    def _virtual_set_p (self,v): _set_p(self, v)
>    p = property(_virtual_get_p, _virtual_set_p)
>
> At this point, the subclasses of A can reimplement _get_p and _set_p
> as they like (I think)
>
> Ciao
> -
> FB

Well, I've thought about that too and it should work, but that makes 2
function calls instead of one for every property access… I'd really
like to avoid that.

By the way, I think your 'virtual' methods should be written as:
def _virtual_get_p (self): return self._get_p()
def _virtual_set_p (self,v): self._set_p(v)

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


Re: Minor annoyances with properties

2010-05-28 Thread eb303
On May 27, 3:14 pm, Neil Cerutti  wrote:
> On 2010-05-27, eb303  wrote:
>
> > I've been using Python properties quite a lot lately and I've
> > found a few things that are a bit annoying about them in some
> > cases. I wondered if I missed something or if anybody else has
> > this kind of problems too, and if there are better solutions
> > than the ones I'm using ATM.
> > The first annoyance is when I want to specialize a property in a
> > subclass.
>
> See:
>
> URI:http://infinitesque.net/articles/2005/enhancing%20Python%27s%20proper...
>
> --
> Neil Cerutti
> *** You found a dead moose-rat. You sell the hide for $200. ***

Thanks for the suggestion, but it looks a bit heavy… Performing the
name lookup on the specialized object each time the property is
accessed seems a bit overkill. I'd really just like a simple way to
tell in the subclass: now, the setter methof for property p is this
one, only that…

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


Re: Minor annoyances with properties

2010-05-28 Thread Christian Heimes
Am 28.05.2010 11:31, schrieb eb303:
> On May 27, 3:24 pm, Christian Heimes  wrote:
>>>  Do I miss something?
>>> Is this the way to do it, or is there a better one?
>>
>> A better way was introduced in Python 2.6. 
>> Seehttp://docs.python.org/library/functions.html?highlight=property#prop...
>> I have a Python only version around if you are still using Python 2.5.
>>
>> Christian
> 
> Mmmm, I might still miss something. OK, I can replace my initial
> property using @property and @p.setter, but it doesn't seem to work in
> subclasses:
> 
> class A(object):
>   @property
>   def p(self):
> return self._p
>   @p.setter
>   def _set_p(self, p):
> self._p = p
> class B(A):
>   @p.setter
>   def _set_p(self, p):
> …
> 
> results in:
> 
> Traceback (most recent call last):
>   File "toto.py", line 8, in 
> class B(A):
>   File "toto.py", line 9, in B
> @p.setter
> NameError: name 'p' is not defined

It doesn't work because "p" is not in the scope of B's body while B is
created. You have to write

class B(A):
# access the "p" property from class A
@A.p.setter
def p(self, p):
pass

# once p is in the class body scope, you must not use A.p again
@p.deleter
def p(self):
pass

Christian

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


Re: if, continuation and indentation

2010-05-28 Thread Jonathan Hartley
On May 27, 1:57 pm, Jean-Michel Pichavant 
wrote:
> HH wrote:
> > I have a question about best practices when it comes to line wrapping/
> > continuation and indentation, specifically in the case of an if
> > statement.
>
> > When I write an if statement with many conditions, I prefer to use a
> > parenthesis around the whole block and get the implicit continuation,
> > rather than ending each line with an escape character.  Thus, using
> > the example from the style guide (http://www.python.org/dev/peps/
> > pep-0008/) I would write:
>
> >     if (width == 0 and
> >         height == 0 and
> >         color == 'red' and
> >         emphasis == 'strong' or
> >         highlight > 100):
> >         raise ValueError("sorry, you lose")
>
> > The problem should be obvious -- it's not easy to see where the
> > conditional ends and the statement begins since they have the same
> > indentation.  Part of the problem, I suppose, is that Emacs indents
> > 'height' and the other lines in the conditional to 4 spaces (because
> > of the parenthesis).  How do people deal with this situation?
>
> > Thanks,
> > Henrik
>
> One possible solution
>
>     if (
>             width == 0 and
>             height == 0 and
>             color == 'red' and
>             emphasis == 'strong' or
>             highlight > 100
>        ):
>         raise ValueError("sorry, you lose")
>
> JM  

I've always liked this, or even:

  if (
  width == 0 and
  height == 0 and
  color == 'red' and
  emphasis == 'strong' or
  highlight > 100
  ):
  raise ValueError("sorry, you lose")


but my co-workers have uniformly gone bananas whenever I try it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: if, continuation and indentation

2010-05-28 Thread Jean-Michel Pichavant

Jonathan Hartley wrote:

On May 27, 1:57 pm, Jean-Michel Pichavant 
wrote:
  

HH wrote:


I have a question about best practices when it comes to line wrapping/
continuation and indentation, specifically in the case of an if
statement.
  
When I write an if statement with many conditions, I prefer to use a

parenthesis around the whole block and get the implicit continuation,
rather than ending each line with an escape character.  Thus, using
the example from the style guide (http://www.python.org/dev/peps/
pep-0008/) I would write:
  
if (width == 0 and

height == 0 and
color == 'red' and
emphasis == 'strong' or
highlight > 100):
raise ValueError("sorry, you lose")
  
The problem should be obvious -- it's not easy to see where the

conditional ends and the statement begins since they have the same
indentation.  Part of the problem, I suppose, is that Emacs indents
'height' and the other lines in the conditional to 4 spaces (because
of the parenthesis).  How do people deal with this situation?
  
Thanks,

Henrik
  

One possible solution

if (
width == 0 and
height == 0 and
color == 'red' and
emphasis == 'strong' or
highlight > 100
   ):
raise ValueError("sorry, you lose")

JM  



I've always liked this, or even:

  if (
  width == 0 and
  height == 0 and
  color == 'red' and
  emphasis == 'strong' or
  highlight > 100
  ):
  raise ValueError("sorry, you lose")


but my co-workers have uniformly gone bananas whenever I try it.
  
I tried to give a layout that fits the OP way of doing, but I would not 
use what I described above, so I can understand why your co workers go 
bananas :)


when it comes to extended conditions in if statement I prefer to write 
something like


if self.haveLost():
   raise ValueError("sorry, you lose")

It drastically improves the reading because it splits the notion of what 
to do in which case, and how do you identify the cases (i.e. what should 
I do when I've lost, and how do I know that I've lost). If you don't 
want to pollute your upper namespace you can embed the function that way:


def foo():
   width = 0
   height = 0
   color = 'red'
   emphasis = 'strong'

   def haveLost():
   return not width and not height and color == 'red' and emphasis 
=='strong'


   if haveLost():
   raise ValueError("sorry you lose")

It has the cool side effect to name your condition as well, that helps 
debugging the condition *a lot*.


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


Re: if, continuation and indentation

2010-05-28 Thread Jonathan Hartley

On 28/05/2010 11:34, Jean-Michel Pichavant wrote:

Jonathan Hartley wrote:

On May 27, 1:57 pm, Jean-Michel Pichavant 
wrote:

HH wrote:

I have a question about best practices when it comes to line wrapping/
continuation and indentation, specifically in the case of an if
statement.
  When I write an if statement with many conditions, I prefer 
to use a

parenthesis around the whole block and get the implicit continuation,
rather than ending each line with an escape character.  Thus, using
the example from the style guide (http://www.python.org/dev/peps/
pep-0008/) I would write:
  if (width == 0 and
height == 0 and
color == 'red' and
emphasis == 'strong' or
highlight > 100):
raise ValueError("sorry, you lose")
  The problem should be obvious -- it's not easy to see where the
conditional ends and the statement begins since they have the same
indentation.  Part of the problem, I suppose, is that Emacs indents
'height' and the other lines in the conditional to 4 spaces (because
of the parenthesis).  How do people deal with this situation?
  Thanks,
Henrik

One possible solution

if (
width == 0 and
height == 0 and
color == 'red' and
emphasis == 'strong' or
highlight > 100
   ):
raise ValueError("sorry, you lose")

JM 


I've always liked this, or even:

  if (
  width == 0 and
  height == 0 and
  color == 'red' and
  emphasis == 'strong' or
  highlight > 100
  ):
  raise ValueError("sorry, you lose")


but my co-workers have uniformly gone bananas whenever I try it.
I tried to give a layout that fits the OP way of doing, but I would 
not use what I described above, so I can understand why your co 
workers go bananas :)


when it comes to extended conditions in if statement I prefer to write 
something like


if self.haveLost():
   raise ValueError("sorry, you lose")

It drastically improves the reading


Good point.

+1 for naming the condition, hooray for self-documenting code.

Sometime last year at my workplace, we started referring to comments as 
'lies', we now always try to use techniques like this instead of comments.


--
Jonathan Hartley  Made of meat.  http://tartley.com
tart...@tartley.com   +44 7737 062 225   twitter/skype: tartley

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


Sockets and xml problem

2010-05-28 Thread kak...@gmail.com
Hi in the following code

class MyClientHandler(SocketServer.BaseRequestHandler):
def handle(self):
print self.client_address, now( )
time.sleep(5)
while True:
xmltxt = self.request.recv(1024)<--is this ok -
enough?
if not xmltxt: break

doc = minidom.parseString(data)
 <--- it also fails for parse(data)
rootNode = doc.documentElement

level = 0

walk(rootNode, outFile, level)
  <---just a function to print the xml
self.request.send('Echo=>%s at %s' % (data, now( )))
rootNode = doc.documentElement
level = 0
walk(rootNode, outFile, level)
self.request.send('Echo=>%s at %s' % (data, now( )))
self.request.close( )

# make a threaded server, listen/handle clients forever
myaddr = (myHost, myPort)
server = SocketServer.ThreadingTCPServer(myaddr, MyClientHandler)
server.serve_forever( )


I want to send XML messages from my client. The server sends back the
XML it receives but
the parser exits with error codes.
What am i doing wrong.

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


Re: Yet Another MySQL Problem

2010-05-28 Thread Victor Subervi
On Thu, May 27, 2010 at 5:47 PM, Tim Chase wrote:

> On 05/27/2010 03:32 PM, Victor Subervi wrote:
>
>  On Thu, May 27, 2010 at 1:15 PM, Tim Chase wrote:
>>
>>> That should be:

 ', '.join(['%s'] * len(values)))

>>>
>>> Or as I've done in the past:
>>>
>>>  ', '.join('%s' for _ in values)
>>>
>>
>> Huh? Can you describe that underscore to me? Fascinating!
>>
>
> The underscore is a valid variable-name, idiomatically used for "I don't
> care about this", often seen in places like tuple assignment:
>
>  a,_,_,d = some_4_element_tuple
>
> So in my above case, it could also have been written as
>
>  ', '.join('%s' for value in values)
>  ', '.join('%s' for dont_care_about_the_value in values)
>
> but the "_" idiom means "I'm iterating over 'values' but I'm not actually
> using the values I get from it"
>

I should have known. Thanks!
beno
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Some More MySQL

2010-05-28 Thread Victor Subervi
On Fri, May 28, 2010 at 2:17 AM, Dennis Lee Bieber wrote:

> On Thu, 27 May 2010 23:22:24 +0100, MRAB 
> declaimed the following in gmane.comp.python.general:
>
> >
> > Placeholders which are handled by .execute shouldn't be wrapped in
> > quotes, even is the value is a string, because .execute will handle that
> > (and any other details) itself.
>
> Even more internal details -- the MySQLdb placeholder is %s because
> the adapter, internally, converts ALL parameters to strings, applies
> escapes to them, and THEN wraps them with quotes before using Python
> string interpolation to make the query that gets submitted to the
> server.
>
>This is why you can not use, say %d as a placeholder for a numeric
> parameter... MySQLdb will convert that numeric to a string, and then
> Python will choke when it tries to use a %d formatter and is given a
> string value.
>
>
> All of your and MRAB's comments were very helpful. However, I don't see how
these two problems are addressed:

  sql = 'select * from options%s where ID=%%s', (opTable[0].upper() +
opTable[1:])
#  cursor.execute(sql, id)
  cursor.execute('select * from options%s where ID=%s' %
(opTable[0].upper() + opTable[1:], id))

The last one works, but if I comment it out and uncomment the middle line,
it doesn't. Same here:

sql = "update options%s set PriceDiff='%%s' where Field='%%s' and
ID=%%s and Store='%%s'" % (opTable[0].upper() + opTable[1:])
#cursor.execute(sql, (value, opName, id, store))
cursor.execute('update options%s set PriceDiff="%s" where Field="%s"
and ID=%s and Store="%s"' % (opTable[0].upper() + opTable[1:], value,
opName, id, store))

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


Re: multiprocessing and accessing server's stdout

2010-05-28 Thread Adam Tauno Williams
On Thu, 2010-05-27 at 08:36 -0700, Tim Arnold wrote:
> On May 26, 4:52 pm, Adam Tauno Williams 
> wrote:
> > On Wed, 2010-05-26 at 11:47 -0700, Tim Arnold wrote:
> > > Hi,
> > > I'm using multiprocessing's BaseManager to create a server on one
> > > machine and a client on another. The client fires a request and the
> > > server does some work, the result of which ends up on a shared file
> > > system that both the client and server can see.
> > > However, I need the client machine to see the stdout of the process
> > > running on the server. Not sure this is doable--I've been unable to
> > > google anything useful on this one.
> >
> > Nope, it isn't.  Don't use stdout, use an IPC mechanism to communicate
> > between the client and the server if you need feedback.
> Thanks for that info, it saves me some time. This is a new area for me
> though: do you redirect stdout on the server to a socket and have the
> client listen and somehow pipe the sockets contents to the client
> stdout?

No, I close stdin, stderr, and stdout on the server processes and attach
them to /dev/null.  Just don't use stdout.

> Interestingly, the RPYc package manages it--that is, the client gets
> the stdout of the server process, so I'll dig into that code to get an
> idea. In the meantime, are there any recipes or other docs that would
> be helpful? I've been googling but without much luck.

Closing stdout and attaching it to any other file descriptor is pretty
simple.

sys.stdout = open('/dev/null', 'w')

You should be able to point it any any file-like object.  But, again,
why?

If you have the data in the process why send it to stdout and redirect
it.  Why not just send the data to the client directly?
-- 
Adam Tauno Williams  LPIC-1, Novell CLA

OpenGroupware, Cyrus IMAPd, Postfix, OpenLDAP, Samba

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


Re: Sockets and xml problem

2010-05-28 Thread Stefan Behnel

kak...@gmail.com, 28.05.2010 13:50:

Hi in the following code

class MyClientHandler(SocketServer.BaseRequestHandler):
 def handle(self):
 print self.client_address, now( )
 time.sleep(5)
 while True:
 xmltxt = self.request.recv(1024)<--is this ok -
enough?


Depends. If your messages are never larger than 1K, this is enough. 
Otherwise, you have to collect the data, instead of parsing each chunk 
separately.


I suggest using the incremental parser in xml.etree.ElementTree, which 
allows you to push more data into the parser as it comes in. When done, 
call it's .close() method to retrieve the result.


http://docs.python.org/library/xml.etree.elementtree.html#xmltreebuilder-objects



I want to send XML messages from my client. The server sends back the
XML it receives but the parser exits with error codes.


You should also rethink your approach one more time. Are you sure that a 
raw socket is a good protocol for sending your messages? In many cases, a 
proper higher-level transport protocol like HTTP is much better suited. If 
you provide more details about what you are trying to do, others may be 
able to help you further.


Stefan

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


Re: Sockets and xml problem

2010-05-28 Thread kak...@gmail.com
On May 28, 3:23 pm, Stefan Behnel  wrote:
> kak...@gmail.com, 28.05.2010 13:50:
>
> > Hi in the following code
>
> > class MyClientHandler(SocketServer.BaseRequestHandler):
> >      def handle(self):
> >          print self.client_address, now( )
> >          time.sleep(5)
> >          while True:
> >              xmltxt = self.request.recv(1024)<--is this ok -
> > enough?
>
> Depends. If your messages are never larger than 1K, this is enough.
> Otherwise, you have to collect the data, instead of parsing each chunk
> separately.
>
> I suggest using the incremental parser in xml.etree.ElementTree, which
> allows you to push more data into the parser as it comes in. When done,
> call it's .close() method to retrieve the result.
>
> http://docs.python.org/library/xml.etree.elementtree.html#xmltreebuil...
>
> > I want to send XML messages from my client. The server sends back the
> > XML it receives but the parser exits with error codes.
>
> You should also rethink your approach one more time. Are you sure that a
> raw socket is a good protocol for sending your messages? In many cases, a
> proper higher-level transport protocol like HTTP is much better suited. If
> you provide more details about what you are trying to do, others may be
> able to help you further.
>
> Stefan

Stefan first of all thank you for your response.
I don't want anything fancy. Just a simple server that accepts xml
messages from multple clients in xml,
parses the XML and show it in a console.
Antonis
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Some More MySQL

2010-05-28 Thread Kushal Kumaran
On Fri, May 28, 2010 at 5:46 PM, Victor Subervi  wrote:
> On Fri, May 28, 2010 at 2:17 AM, Dennis Lee Bieber 
> wrote:
>>
>> On Thu, 27 May 2010 23:22:24 +0100, MRAB 
>> declaimed the following in gmane.comp.python.general:
>>
>> >
>> > Placeholders which are handled by .execute shouldn't be wrapped in
>> > quotes, even is the value is a string, because .execute will handle that
>> > (and any other details) itself.
>>
>>        Even more internal details -- the MySQLdb placeholder is %s because
>> the adapter, internally, converts ALL parameters to strings, applies
>> escapes to them, and THEN wraps them with quotes before using Python
>> string interpolation to make the query that gets submitted to the
>> server.
>>
>>        This is why you can not use, say %d as a placeholder for a numeric
>> parameter... MySQLdb will convert that numeric to a string, and then
>> Python will choke when it tries to use a %d formatter and is given a
>> string value.
>>
>>
> All of your and MRAB's comments were very helpful. However, I don't see how
> these two problems are addressed:
>
>   sql = 'select * from options%s where ID=%%s', (opTable[0].upper() +
> opTable[1:])
> #  cursor.execute(sql, id)
>   cursor.execute('select * from options%s where ID=%s' %
> (opTable[0].upper() + opTable[1:], id))
>

The second argument to cursor.execute needs to be a tuple.  Change the
call to this:

cursor.execute(sql, (id,))

> The last one works, but if I comment it out and uncomment the middle line,
> it doesn't. Same here:
>
>     sql = "update options%s set PriceDiff='%%s' where Field='%%s' and
> ID=%%s and Store='%%s'" % (opTable[0].upper() + opTable[1:])
> #    cursor.execute(sql, (value, opName, id, store))
>     cursor.execute('update options%s set PriceDiff="%s" where Field="%s"
> and ID=%s and Store="%s"' % (opTable[0].upper() + opTable[1:], value,
> opName, id, store))
>

Lose the quotes around the %s.  You are replying to a post that
describes why this is important.

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


Re: Free chapter about Python and databases (MySQL and SQLite)

2010-05-28 Thread Tino Wildenhain

Hi,

Am 28.05.2010 04:45, schrieb Sebastian Bassi:

Hello, I want to announce that the publisher of "Python for
Bioinformatis" (CRC Press) allowed me to publish a chapter from my
book.
I decided to publish the chapter about "Python and databases". I think
it may be useful for somebody.
The official announcement and download link is here:
http://py4bio.com/2010/05/28/python_databases_mysql_sqlite/
For more information about the book: www.tinyurl.com/biopython
Best,
SB.


This is nice! Congrats!
Did you consider adding a part dealing with postgresql too?
(Especially interesting in the way you can write stored functions
in python there)

Regards
Tino



smime.p7s
Description: S/MIME Cryptographic Signature
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: multiprocessing and accessing server's stdout

2010-05-28 Thread Martin P. Hellwig

On 05/28/10 13:17, Adam Tauno Williams wrote:



You should be able to point it any any file-like object.  But, again,
why?

If you have the data in the process why send it to stdout and redirect
it.  Why not just send the data to the client directly?


Well you might want to multiplex it to more then one client, not saying 
that this is the case here, just something I imagine possible.


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


Re: Minor annoyances with properties

2010-05-28 Thread eb303
On May 28, 11:50 am, Christian Heimes  wrote:
> Am 28.05.2010 11:31, schrieb eb303:
>
>
>
> > On May 27, 3:24 pm, Christian Heimes  wrote:
> >>>  Do I miss something?
> >>> Is this the way to do it, or is there a better one?
>
> >> A better way was introduced in Python 2.6. 
> >> Seehttp://docs.python.org/library/functions.html?highlight=property#prop...
> >> I have a Python only version around if you are still using Python 2.5.
>
> >> Christian
>
> > Mmmm, I might still miss something. OK, I can replace my initial
> > property using @property and @p.setter, but it doesn't seem to work in
> > subclasses:
>
> > class A(object):
> >   @property
> >   def p(self):
> >     return self._p
> >   @p.setter
> >   def _set_p(self, p):
> >     self._p = p
> > class B(A):
> >   @p.setter
> >   def _set_p(self, p):
> >     …
>
> > results in:
>
> > Traceback (most recent call last):
> >   File "toto.py", line 8, in 
> >     class B(A):
> >   File "toto.py", line 9, in B
> >     @p.setter
> > NameError: name 'p' is not defined
>
> It doesn't work because "p" is not in the scope of B's body while B is
> created. You have to write
>
> class B(A):
>     # access the "p" property from class A
>     @A.p.setter
>     def p(self, p):
>         pass
>
>     # once p is in the class body scope, you must not use A.p again
>     @p.deleter
>     def p(self):
>         pass
>
> Christian

Well, I still have to explicitely specify the superclass's name then,
so IMHO it's not a big improvement over repeating:
p = property(A._get_p, _set_p)

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


Re: Free chapter about Python and databases (MySQL and SQLite)

2010-05-28 Thread Sebastian Bassi
On Fri, May 28, 2010 at 9:41 AM, Tino Wildenhain  wrote:
> Did you consider adding a part dealing with postgresql too?
> (Especially interesting in the way you can write stored functions
> in python there)

That is a good idea for the next version/edition. But meanwhile I
could write something in my blog at www.py4bio.com
Best,
SB
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: http post

2010-05-28 Thread christian schulze
On 28 Mai, 16:47, yqyq22  wrote:
> Hy, i would like to create a little script to reproduce this one
> below:
> Do you have suggestion?
>
> POST /folder/path/upload.exe?/dir HTTP/1.1
> Host: 192.168.100.1:8080
> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:
> 1.9.2.3) Gecko/20100401 Firefox/3.6.3 (.NET CLR 3.5.30729)
> Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/
> *;q=0.8
> Accept-Language: en-us,en;q=0.5
> Accept-Encoding: gzip,deflate
> Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
> Keep-Alive: 115
> Proxy-Connection: keep-alive
> Referer:http://192.168.1.100:8080/dir1
> Content-Type: multipart/form-data;
> boundary=---7075104567331
> Content-Length: 539
> Connection: close
>
> -7075104567331
> Content-Disposition: form-data; name="F1"; filename="file.txt"
> Content-Type: application/octet-stream
>
> -7075104567331
> Content-Disposition: form-data; name="p4"
>
> -7075104567331--
>
> THANKS A LOT

Just send it via a socket? Or use urllib, afair you can send custom
HTTP headers.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: http post

2010-05-28 Thread yqyq22
On May 28, 5:17 pm, christian schulze  wrote:
> On 28 Mai, 16:47, yqyq22  wrote:
>
>
>
>
>
> > Hy, i would like to create a little script to reproduce this one
> > below:
> > Do you have suggestion?
>
> > POST /folder/path/upload.exe?/dir HTTP/1.1
> > Host: 192.168.100.1:8080
> > User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:
> > 1.9.2.3) Gecko/20100401 Firefox/3.6.3 (.NET CLR 3.5.30729)
> > Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/
> > *;q=0.8
> > Accept-Language: en-us,en;q=0.5
> > Accept-Encoding: gzip,deflate
> > Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
> > Keep-Alive: 115
> > Proxy-Connection: keep-alive
> > Referer:http://192.168.1.100:8080/dir1
> > Content-Type: multipart/form-data;
> > boundary=---7075104567331
> > Content-Length: 539
> > Connection: close
>
> > -7075104567331
> > Content-Disposition: form-data; name="F1"; filename="file.txt"
> > Content-Type: application/octet-stream
>
> > -7075104567331
> > Content-Disposition: form-data; name="p4"
>
> > -7075104567331--
>
> > THANKS A LOT
>
> Just send it via a socket? Or use urllib, afair you can send custom
> HTTP headers.- Hide quoted text -
>
> - Show quoted text -

If i understood right i would use only socket.. is it possible?
thanks
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Free chapter about Python and databases (MySQL and SQLite)

2010-05-28 Thread christian schulze
On 28 Mai, 17:12, Sebastian Bassi  wrote:
> On Fri, May 28, 2010 at 9:41 AM, Tino Wildenhain  wrote:
> > Did you consider adding a part dealing with postgresql too?
> > (Especially interesting in the way you can write stored functions
> > in python there)
>
> That is a good idea for the next version/edition. But meanwhile I
> could write something in my blog atwww.py4bio.com
> Best,
> SB

Indeed a style like
> user="root"
is not that nice.

I had no look at the chapter but recommend you to read the PEP 8 -
Python style guides (code conventions for python).

Imo a book have to be kinda exemplary. And bad style sucks anyway ...

PS:
> user = 'root' or user = "root"
... would be much more beautyful.
-- 
http://mail.python.org/mailman/listinfo/python-list


Omit the headers from XML message

2010-05-28 Thread kak...@gmail.com
Hi i have the following xml message i want to omit the headers, any
hints?

POST /test/pcp/Listener HTTP/1.1
User-Agent: Jakarta Commons-HttpClient/3.1
Host: 127.0.0.1:50002
Content-Length: 547

http://demo.com/demo";>
  

  
scvdcvsdv
sdfv
Antonis Kaklis
away
testing the new client
jlkdjf
android
  

  

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


Re: http post

2010-05-28 Thread christian schulze
On 28 Mai, 17:20, yqyq22  wrote:
> On May 28, 5:17 pm, christian schulze  wrote:
>
>
>
> > On 28 Mai, 16:47, yqyq22  wrote:
>
> > > Hy, i would like to create a little script to reproduce this one
> > > below:
> > > Do you have suggestion?
>
> > > POST /folder/path/upload.exe?/dir HTTP/1.1
> > > Host: 192.168.100.1:8080
> > > User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:
> > > 1.9.2.3) Gecko/20100401 Firefox/3.6.3 (.NET CLR 3.5.30729)
> > > Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/
> > > *;q=0.8
> > > Accept-Language: en-us,en;q=0.5
> > > Accept-Encoding: gzip,deflate
> > > Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
> > > Keep-Alive: 115
> > > Proxy-Connection: keep-alive
> > > Referer:http://192.168.1.100:8080/dir1
> > > Content-Type: multipart/form-data;
> > > boundary=---7075104567331
> > > Content-Length: 539
> > > Connection: close
>
> > > -7075104567331
> > > Content-Disposition: form-data; name="F1"; filename="file.txt"
> > > Content-Type: application/octet-stream
>
> > > -7075104567331
> > > Content-Disposition: form-data; name="p4"
>
> > > -7075104567331--
>
> > > THANKS A LOT
>
> > Just send it via a socket? Or use urllib, afair you can send custom
> > HTTP headers.- Hide quoted text -
>
> > - Show quoted text -
>
> If i understood right i would use only socket.. is it possible?
> thanks

Yeah i think so, but i am not quite sure. Just test it :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: http post

2010-05-28 Thread yqyq22
On May 28, 5:24 pm, christian schulze  wrote:
> On 28 Mai, 17:20, yqyq22  wrote:
>
>
>
>
>
> > On May 28, 5:17 pm, christian schulze  wrote:
>
> > > On 28 Mai, 16:47, yqyq22  wrote:
>
> > > > Hy, i would like to create a little script to reproduce this one
> > > > below:
> > > > Do you have suggestion?
>
> > > > POST /folder/path/upload.exe?/dir HTTP/1.1
> > > > Host: 192.168.100.1:8080
> > > > User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:
> > > > 1.9.2.3) Gecko/20100401 Firefox/3.6.3 (.NET CLR 3.5.30729)
> > > > Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/
> > > > *;q=0.8
> > > > Accept-Language: en-us,en;q=0.5
> > > > Accept-Encoding: gzip,deflate
> > > > Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
> > > > Keep-Alive: 115
> > > > Proxy-Connection: keep-alive
> > > > Referer:http://192.168.1.100:8080/dir1
> > > > Content-Type: multipart/form-data;
> > > > boundary=---7075104567331
> > > > Content-Length: 539
> > > > Connection: close
>
> > > > -7075104567331
> > > > Content-Disposition: form-data; name="F1"; filename="file.txt"
> > > > Content-Type: application/octet-stream
>
> > > > -7075104567331
> > > > Content-Disposition: form-data; name="p4"
>
> > > > -7075104567331--
>
> > > > THANKS A LOT
>
> > > Just send it via a socket? Or use urllib, afair you can send custom
> > > HTTP headers.- Hide quoted text -
>
> > > - Show quoted text -
>
> > If i understood right i would use only socket.. is it possible?
> > thanks
>
> Yeah i think so, but i am not quite sure. Just test it :)- Hide quoted text -
>
> - Show quoted text -

Do u have an example/link "closed" to my need? thanks
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Some More MySQL

2010-05-28 Thread Victor Subervi
I still have this code:

  sql = 'select * from options%s where ID=%%s', (opTable[0].upper() +
opTable[1:])
  cursor.execute(sql, (id,))

which throws this error:

 /var/www/html/angrynates.com/cart/enterOptionsPrices2.py
   70 print 'All options prices have been successfully updated.'
   71 print '\n'
   72
   73 enterOptionsPrices2()
   74
enterOptionsPrices2 = 
 /var/www/html/angrynates.com/cart/enterOptionsPrices2.py in
enterOptionsPrices2()
   58   id = form.getfirst('%sID' % option)
   59   sql = 'select * from options%s where ID=%%s',
(opTable[0].upper() + opTable[1:])
   60   cursor.execute(sql, (id,))
   61 #  cursor.execute('select * from options%s where ID=%s' %
(opTable[0].upper() + opTable[1:], id))
   62   if cursor.fetchone() is not None:
cursor = , cursor.execute = >, sql = ('select * from
options%s where ID=%%s', 'Sizes'), id = '0.00'
 /usr/lib64/python2.4/site-packages/MySQLdb/cursors.py in
execute(self=, query=('select * from
options%s where ID=%%s', 'Sizes'), args=('0.00',))
  144 db = self._get_db()
  145 charset = db.character_set_name()
  146 query = query.encode(charset)
  147 if args is not None:
  148 query = query % db.literal(args)
query = ('select * from options%s where ID=%%s', 'Sizes'), query.encode
undefined, charset = 'latin1'

AttributeError: 'tuple' object has no attribute 'encode'
  args = ("'tuple' object has no attribute 'encode'",)


Please advise.
TIA
beno
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Yet Another MySQL Problem

2010-05-28 Thread Malcolm Greene
Tim,

> The underscore is a valid variable-name, idiomatically used for "I don't care 
> about this", often seen in places like tuple assignment:

The underscore is also used as an alias for gettext.gettext or
gettext.ugettext so you may want to use another variable-name.

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


Re: Omit the headers from XML message

2010-05-28 Thread Jon Clements
On 28 May, 16:24, "kak...@gmail.com"  wrote:
> Hi i have the following xml message i want to omit the headers, any
> hints?
>
> POST /test/pcp/Listener HTTP/1.1
> User-Agent: Jakarta Commons-HttpClient/3.1
> Host: 127.0.0.1:50002
> Content-Length: 547
>
> http://demo.com/demo";>
>   
>     
>       
>         scvdcvsdv
>         sdfv
>         Antonis Kaklis
>         away
>         testing the new client
>         jlkdjf
>         android
>       
>     
>   
> 

Assuming the header is separated by a blank line, something like:

list(islice(dropwhile(bool, s.split('\n')), 1, None))
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Free chapter about Python and databases (MySQL and SQLite)

2010-05-28 Thread Peter Otten
christian schulze wrote:

> On 28 Mai, 17:12, Sebastian Bassi  wrote:
>> On Fri, May 28, 2010 at 9:41 AM, Tino Wildenhain 
>> wrote:
>> > Did you consider adding a part dealing with postgresql too?
>> > (Especially interesting in the way you can write stored functions
>> > in python there)
>>
>> That is a good idea for the next version/edition. But meanwhile I
>> could write something in my blog atwww.py4bio.com
>> Best,
>> SB
> 
> Indeed a style like
>> user="root"
> is not that nice.
> 
> I had no look at the chapter but recommend you to read the PEP 8 -
> Python style guides (code conventions for python).
> 
> Imo a book have to be kinda exemplary. And bad style sucks anyway ...
> 
> PS:
>> user = 'root' or user = "root"
> ... would be much more beautyful.

My crystal ball says that the post you are not quoting is concerned about 
the security implications of accessing a database as the superuser rather 
than about spaces surrounding the assignment operator.

My crystal ball then starts nitpicking and adds that in the sample chapter 
user="root" occurs within an argument list where its format is actually 
required by the PEP:

"""
- Don't use spaces around the '=' sign when used to indicate a
  keyword argument or a default parameter value.

  Yes:

  def complex(real, imag=0.0):
  return magic(r=real, i=imag)
"""

Cheers,
Peter

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


Re: Some More MySQL

2010-05-28 Thread MRAB

Victor Subervi wrote:

I still have this code:

  sql = 'select * from options%s where ID=%%s', (opTable[0].upper() 
+ opTable[1:])

  cursor.execute(sql, (id,))

which throws this error:

 /var/www/html/angrynates.com/cart/enterOptionsPrices2.py 


   70 print 'All options prices have been successfully updated.'
   71 print '\n'
   72
   73 enterOptionsPrices2()
   74
enterOptionsPrices2 = 
 /var/www/html/angrynates.com/cart/enterOptionsPrices2.py 
 in enterOptionsPrices2()

   58   id = form.getfirst('%sID' % option)
   59   sql = 'select * from options%s where ID=%%s', 
(opTable[0].upper() + opTable[1:])

   60   cursor.execute(sql, (id,))
   61 #  cursor.execute('select * from options%s where ID=%s' % 
(opTable[0].upper() + opTable[1:], id))

   62   if cursor.fetchone() is not None:
cursor = , cursor.execute = Cursor.execute of >, sql = ('select * 
from options%s where ID=%%s', 'Sizes'), id = '0.00'
 /usr/lib64/python2.4/site-packages/MySQLdb/cursors.py in 
execute(self=, query=('select * from 
options%s where ID=%%s', 'Sizes'), args=('0.00',))

  144 db = self._get_db()
  145 charset = db.character_set_name()
  146 query = query.encode(charset)
  147 if args is not None:
  148 query = query % db.literal(args)
query = ('select * from options%s where ID=%%s', 'Sizes'), query.encode 
undefined, charset = 'latin1'


AttributeError: 'tuple' object has no attribute 'encode'
  args = ("'tuple' object has no attribute 'encode'",)


Please advise.


On line 59 you're making a tuple.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Omit the headers from XML message

2010-05-28 Thread kak...@gmail.com
On 28 Μάϊος, 18:45, Jon Clements  wrote:
> On 28 May, 16:24, "kak...@gmail.com"  wrote:
>
>
>
>
>
> > Hi i have the following xml message i want to omit the headers, any
> > hints?
>
> > POST /test/pcp/Listener HTTP/1.1
> > User-Agent: Jakarta Commons-HttpClient/3.1
> > Host: 127.0.0.1:50002
> > Content-Length: 547
>
> > http://demo.com/demo";>
> >   
> >     
> >       
> >         scvdcvsdv
> >         sdfv
> >         Antonis Kaklis
> >         away
> >         testing the new client
> >         jlkdjf
> >         android
> >       
> >     
> >   
> > 
>
> Assuming the header is separated by a blank line, something like:
>
> list(islice(dropwhile(bool, s.split('\n')), 1, None))

Thank you!!!

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


Re: Omit the headers from XML message

2010-05-28 Thread Stefan Behnel

kak...@gmail.com, 28.05.2010 17:24:

Hi i have the following xml message i want to omit the headers, any
hints?

POST /test/pcp/Listener HTTP/1.1
User-Agent: Jakarta Commons-HttpClient/3.1
Host: 127.0.0.1:50002
Content-Length: 547

http://demo.com/demo";>
   
 
   
 scvdcvsdv
 sdfv
 Antonis Kaklis
 away
 testing the new client
 jlkdjf
 android
   
 
   



Use the HTTP server that comes with Python, instead of the plain socket server.

Stefan

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


Re: Omit the headers from XML message

2010-05-28 Thread Peter Otten
Jon Clements wrote:

> On 28 May, 16:24, "kak...@gmail.com"  wrote:
>> Hi i have the following xml message i want to omit the headers, any
>> hints?

> Assuming the header is separated by a blank line, something like:
> 
> list(islice(dropwhile(bool, s.split('\n')), 1, None))

Making the same assumptions, but giving a single string instead of a list of 
lines:

s.partition("\n\n")[-1]

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


Re: ElementTree write creates large one line XML file ....

2010-05-28 Thread robert somerville
Thanks Robert Kern :

"prettyprint" ; indent()  does the trick ;-)


>ElementTree writes exactly what you tell it to. In XML, whitespace is
>significant. If you want newlines and/or indentation to make it pretty-looking,
>then you need to add those to your elements.
>
>Fredrik provides an example function for doing this:
>
>   http://effbot.org/zone/element-lib.htm#prettyprint
-- 
http://mail.python.org/mailman/listinfo/python-list


Like __getattr__ but with args and kwargs as well

2010-05-28 Thread Giampaolo Rodolà
I know, the title doesn't say much, but I had no better ideas. =)
I have a class within a serie of redundant methods, which looks like this:

class MixedAuthorizer:

def __init__(self, *args):
# expected a list of class instances
self.authorizers = args

def get_home(self, user):
for auth in self.authorizers:
if not auth.has_user(user):
continue
return auth.get_home(user)
return ""

def get_password(self, user):
for auth in self.authorizers:
if not auth.has_user(user):
continue
return auth.get_password(user)
return ""

 # follows a long list of get_* methods as above
 ...


Considering that I always do the same thing (iterate over a list of
objects -> call obj.has_user() -> call obj.get_*()) I would like to
know if there's a more compact way to do that.
What I basically need is something like __getattr__ but which provides
the arguments and eventually the keyword arguments a method has been
called with, other than just its name.
Actually I'm not even sure whether Python can reach such a level of
dynamism but I wanted to give it a try anyway.
Is there a way to do such a thing?


--- Giampaolo
http://code.google.com/p/pyftpdlib
http://code.google.com/p/psutil
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Like __getattr__ but with args and kwargs as well

2010-05-28 Thread Miki
class MixedAuthorizer:
def __init__(self, *args):
# expected a list of class instances
self.authorizers = args
self._set_methods()

def _set_methods(self):
for attr in ("home", "password"):
def fn(user):
return self._get_attr(user, attr)
setattr(self, "get_%s" % attr, fn)

def _get_attr(self, user, attr):
auths = [auth for auth in self.authorizers if
auth.has_user(user)]
if not auths:
return ""

method_name = "get_%s" % attr
method = getattr(auths[0], method_name, None)
if not fn:
raise ValueError("Unknown attribute - %s" % method_name)

return fn(user)

HTH,
--
Miki
http://pythonwise.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Like __getattr__ but with args and kwargs as well

2010-05-28 Thread Chris Rebert
On Fri, May 28, 2010 at 10:08 AM, Giampaolo Rodolà  wrote:
> I know, the title doesn't say much, but I had no better ideas. =)
> I have a class within a serie of redundant methods, which looks like this:
>
> class MixedAuthorizer:
>
>    def __init__(self, *args):
>        # expected a list of class instances
>        self.authorizers = args
>
>    def get_home(self, user):
>        for auth in self.authorizers:
>            if not auth.has_user(user):
>                continue
>            return auth.get_home(user)
>        return ""
>
>    def get_password(self, user):
>        for auth in self.authorizers:
>            if not auth.has_user(user):
>                continue
>            return auth.get_password(user)
>        return ""
>
>     # follows a long list of get_* methods as above
>     ...
>
>
> Considering that I always do the same thing (iterate over a list of
> objects -> call obj.has_user() -> call obj.get_*()) I would like to
> know if there's a more compact way to do that.
> What I basically need is something like __getattr__ but which provides
> the arguments and eventually the keyword arguments a method has been
> called with, other than just its name.
> Actually I'm not even sure whether Python can reach such a level of
> dynamism but I wanted to give it a try anyway.
> Is there a way to do such a thing?

There's no such "über-__getattr__", but with some indirection we can
achieve much the same effect:

#Note: Completely untested
from functools import partial

class Whatever(object):
def _getter(self, _name, user, *args, **kwds):
# I assume your actual code will use the *args and **kwds
for auth in self.authorizers:
if not auth.has_user(user):
continue
return getattr(auth, _name)(user)
return ""

def __getattr__(self, name):
if name.startswith("get_"):
return partial(self._getter, _name=name)
else:
raise AttributeError

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Like __getattr__ but with args and kwargs as well

2010-05-28 Thread Miki
>         method = getattr(auths[0], method_name, None)
Should be
fn = getattr(auths[0], method_name, None)

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


Re: Like __getattr__ but with args and kwargs as well

2010-05-28 Thread Peter Otten
Giampaolo Rodolà wrote:

> I know, the title doesn't say much, but I had no better ideas. =)
> I have a class within a serie of redundant methods, which looks like this:
> 
> class MixedAuthorizer:
> 
> def __init__(self, *args):
> # expected a list of class instances
> self.authorizers = args
> 
> def get_home(self, user):
> for auth in self.authorizers:
> if not auth.has_user(user):
> continue
> return auth.get_home(user)
> return ""
> 
> def get_password(self, user):
> for auth in self.authorizers:
> if not auth.has_user(user):
> continue
> return auth.get_password(user)
> return ""
> 
>  # follows a long list of get_* methods as above
>  ...
> 
> 
> Considering that I always do the same thing (iterate over a list of
> objects -> call obj.has_user() -> call obj.get_*()) I would like to
> know if there's a more compact way to do that.
> What I basically need is something like __getattr__ but which provides
> the arguments and eventually the keyword arguments a method has been
> called with, other than just its name.
> Actually I'm not even sure whether Python can reach such a level of
> dynamism but I wanted to give it a try anyway.
> Is there a way to do such a thing?

Yes, and for the above example it is easier to implement than you think:

class MA(object):
def __init__(self, authorizers):
self.authorizers = authorizers
def __getattr__(self, name):
def get(self, user):
for auth in self.authorizers:
if auth.has_user(user):
return getattr(auth, name)(user)
return get.__get__(self)

You can modify it to pass along arbitrary keyword arguments:

class MA(object):
def __init__(self, authorizers):
self.authorizers = authorizers
def __getattr__(self, name):
def get(self, **kw):
for auth in self.authorizers:
if auth.has_user(kw["user"]):
return getattr(auth, name)(**kw)
return get.__get__(self)

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


Re: if, continuation and indentation

2010-05-28 Thread Colin J. Williams

On 28-May-10 05:54 AM, Jonathan Hartley wrote:

On May 27, 1:57 pm, Jean-Michel Pichavant
wrote:

HH wrote:

I have a question about best practices when it comes to line wrapping/
continuation and indentation, specifically in the case of an if
statement.



When I write an if statement with many conditions, I prefer to use a
parenthesis around the whole block and get the implicit continuation,
rather than ending each line with an escape character.  Thus, using
the example from the style guide (http://www.python.org/dev/peps/
pep-0008/) I would write:



 if (width == 0 and
 height == 0 and
 color == 'red' and
 emphasis == 'strong' or
 highlight>  100):
 raise ValueError("sorry, you lose")



The problem should be obvious -- it's not easy to see where the
conditional ends and the statement begins since they have the same
indentation.  Part of the problem, I suppose, is that Emacs indents
'height' and the other lines in the conditional to 4 spaces (because
of the parenthesis).  How do people deal with this situation?



Thanks,
Henrik


One possible solution

 if (
 width == 0 and
 height == 0 and
 color == 'red' and
 emphasis == 'strong' or
 highlight>  100
):
 raise ValueError("sorry, you lose")

JM


I've always liked this, or even:

   if (
   width == 0 and
   height == 0 and
   color == 'red' and
   emphasis == 'strong' or
   highlight>  100
   ):
   raise ValueError("sorry, you lose")


but my co-workers have uniformly gone bananas whenever I try it.

I liked:

On 27-May-10 08:48 AM, Xavier Ho wrote:
> On 27 May 2010 22:22, HH  > wrote:
>
> if (width == 0 and
> height == 0 and
> color == 'red' and
> emphasis == 'strong' or
> highlight > 100):
> raise ValueError("sorry, you lose")
>
>
> I've gotta say - I've bumped into this problem before, and I'm sure many
> other have - this is a valid question. It just hasn't bothered me enough
> to ask...
>
> Correct me if I'm wrong, but I think the following is equivalent, and
> looks better. Although this won't fix all ugly cases in that problem..
>
> if (width, height, color, emphasis) == (0, 0, 'red', 'strong') or
> highlight > 100:
>  raise ValueError("sorry, you lose")
>
> Cheers,
> Xav

but nobody commented.

Colin W.

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


Re: Like __getattr__ but with args and kwargs as well

2010-05-28 Thread Giampaolo Rodolà
2010/5/28 Peter Otten <__pete...@web.de>:
> Giampaolo Rodolà wrote:
>
>> I know, the title doesn't say much, but I had no better ideas. =)
>> I have a class within a serie of redundant methods, which looks like this:
>>
>> class MixedAuthorizer:
>>
>>     def __init__(self, *args):
>>         # expected a list of class instances
>>         self.authorizers = args
>>
>>     def get_home(self, user):
>>         for auth in self.authorizers:
>>             if not auth.has_user(user):
>>                 continue
>>             return auth.get_home(user)
>>         return ""
>>
>>     def get_password(self, user):
>>         for auth in self.authorizers:
>>             if not auth.has_user(user):
>>                 continue
>>             return auth.get_password(user)
>>         return ""
>>
>>      # follows a long list of get_* methods as above
>>      ...
>>
>>
>> Considering that I always do the same thing (iterate over a list of
>> objects -> call obj.has_user() -> call obj.get_*()) I would like to
>> know if there's a more compact way to do that.
>> What I basically need is something like __getattr__ but which provides
>> the arguments and eventually the keyword arguments a method has been
>> called with, other than just its name.
>> Actually I'm not even sure whether Python can reach such a level of
>> dynamism but I wanted to give it a try anyway.
>> Is there a way to do such a thing?
>
> Yes, and for the above example it is easier to implement than you think:
>
> class MA(object):
>    def __init__(self, authorizers):
>        self.authorizers = authorizers
>    def __getattr__(self, name):
>        def get(self, user):
>            for auth in self.authorizers:
>                if auth.has_user(user):
>                    return getattr(auth, name)(user)
>        return get.__get__(self)
>
> You can modify it to pass along arbitrary keyword arguments:
>
> class MA(object):
>    def __init__(self, authorizers):
>        self.authorizers = authorizers
>    def __getattr__(self, name):
>        def get(self, **kw):
>            for auth in self.authorizers:
>                if auth.has_user(kw["user"]):
>                    return getattr(auth, name)(**kw)
>        return get.__get__(self)
>
> Peter
> --
> http://mail.python.org/mailman/listinfo/python-list
>



Thanks, this has been helpful.
I managed to write this monster: =)


class MixedAuthorizer(object):

def __init__(self, *authorizers):
self.authorizers = authorizers

def __getattr__(self, name):

def get(self, user, *args, **kwargs):
for auth in self.authorizers:
if auth.has_user(user):
method = getattr(auth, name)
return method(user, *args, **kwargs)

# if we reached this point no user was found
if name == "validate_authentication":
return False
if name.startswith("get"):
return ""
if name.startswith("has"):
return False

return get.__get__(self)


--- Giampaolo
http://code.google.com/p/pyftpdlib
http://code.google.com/p/psutil
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Like __getattr__ but with args and kwargs as well

2010-05-28 Thread MRAB

Giampaolo Rodolà wrote:

I know, the title doesn't say much, but I had no better ideas. =)
I have a class within a serie of redundant methods, which looks like this:

class MixedAuthorizer:

def __init__(self, *args):
# expected a list of class instances
self.authorizers = args

def get_home(self, user):
for auth in self.authorizers:
if not auth.has_user(user):
continue
return auth.get_home(user)
return ""

def get_password(self, user):
for auth in self.authorizers:
if not auth.has_user(user):
continue
return auth.get_password(user)
return ""

 # follows a long list of get_* methods as above
 ...


Considering that I always do the same thing (iterate over a list of
objects -> call obj.has_user() -> call obj.get_*()) I would like to
know if there's a more compact way to do that.
What I basically need is something like __getattr__ but which provides
the arguments and eventually the keyword arguments a method has been
called with, other than just its name.
Actually I'm not even sure whether Python can reach such a level of
dynamism but I wanted to give it a try anyway.
Is there a way to do such a thing?


Here's a way (mis)using a decorator (written in Python 3):

def locate(func):
def lookup(self, user):
for auth in self.authorizers:
if auth.has_user(user):
return getattr(auth, func.__name__)()
return ""
return lookup

class Authorizer:
def __init__(self, user):
self.user = user
def has_user(self, user):
return self.user == user
def get_home(self):
return "{}-HOME".format(self.user)
def get_password(self):
return "{}-PASSWORD".format(self.user)

class MixedAuthorizer:
def __init__(self, *authorizers):
self.authorizers = authorizers
# The following methods are used only as placeholders.
@locate
def get_home(self): pass
@locate
def get_password(self): pass

a1 = Authorizer("USER1")
a2 = Authorizer("USER2")
m = MixedAuthorizer(a1, a2)
print(m.get_home("USER1"))
print(m.get_password("USER2"))

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


Re: Omit the headers from XML message

2010-05-28 Thread kak...@gmail.com
On May 28, 7:48 pm, Peter Otten <__pete...@web.de> wrote:
> Jon Clements wrote:
> > On 28 May, 16:24, "kak...@gmail.com"  wrote:
> >> Hi i have the following xml message i want to omit the headers, any
> >> hints?
> > Assuming the header is separated by a blank line, something like:
>
> > list(islice(dropwhile(bool, s.split('\n')), 1, None))
>
> Making the same assumptions, but giving a single string instead of a list of
> lines:
>
> s.partition("\n\n")[-1]
>
> Peter

Thank you all for your responses!

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


Re: multiprocessing and accessing server's stdout

2010-05-28 Thread Adam Tauno Williams
On Fri, 2010-05-28 at 15:41 +0100, Martin P. Hellwig wrote:
> On 05/28/10 13:17, Adam Tauno Williams wrote:
> 
> > You should be able to point it any any file-like object.  But, again,
> > why?
> > If you have the data in the process why send it to stdout and redirect
> > it.  Why not just send the data to the client directly?
> Well you might want to multiplex it to more then one client, not saying 
> that this is the case here, just something I imagine possible.

That still doesn't make sense.  Why 'multiplex stdout'?  Why not just
multiplex the data into proper IPC channels in the first place?
-- 
Adam Tauno Williams  LPIC-1, Novell CLA

OpenGroupware, Cyrus IMAPd, Postfix, OpenLDAP, Samba

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


A Friday Python Programming Pearl: random sampling

2010-05-28 Thread Mark Dickinson
For a lazy Friday evening, here's a Python algorithm that seemed so
cute that I just had to share it with everyone.  I'm sure it's well
known to many here, but it was new to me.  Skip directly to the
'sample2' function to see the algorithm and avoid the commentary...

Suppose that you want to select a number of elements, k, say, from a
population, without replacement.  E.g., selecting 3 elements from
range(30) might give you:

[13, 3, 27]

Order matters, so the above is considered distinct from [3, 13, 27].
And you want to be sure that each possible selection has equal
probability of occurring (to within the limits of the underlying
PRNG).

One solution is to select elements from the population one-by-one,
keep track of the indices of already-selected elements in a set, and
if you end up selecting something that's already in your set, simply
try again.  Something like this (code stolen and adapted from
Random.sample in Python's standard library 'random' module):

from random import randrange

def sample1(population, k):
n = len(population)
result = [None] * k
selected = set()
for i in range(k):
j = randrange(n)
# retry until we get something that's not already selected
while j in selected:
j = randrange(n)
selected.add(j)
result[i] = population[j]
return result


N.B.  The above is Python 3 code; for Python 2, replace range with
xrange.

All that's required of 'population' here is that it implements __len__
and __getitem__.  The method works well for k significantly smaller
than n, but as k approaches n the number of reselections required
increases.  So for larger k, Random.sample uses a different method:
roughly, make a copy of 'population', do a partial in-place shuffle of
that copy that randomizes the first k elements, and return those.
This second method isn't so great when k is small and n is huge, since
it ends up being O(n) from the list copy, but it works out that the
two methods complement each other nicely.

Looking at the above code, I was idly wondering whether there was a
way to alter 'sample1' to avoid the need for resampling, thus giving a
single algorithm that works reasonably efficiently regardless of the
population size and requested sample size.  And it turns out that
there is.  The code below is similar to 'sample1' above, except that
instead of using a set to keep track of indices of already-selected
members of the population, it uses a dict; for an index i
(corresponding to a member of the population), d[i] gives the position
that population[i] will occupy in the resulting sample.


from random import randrange

def sample2(population, k):
n = len(population)

d = {}
for i in reversed(range(k)):
j = randrange(i, n)
if j in d:
d[i] = d[j]
d[j] = i

result = [None] * k
for j, i in d.items():
result[i] = population[j]
return result


Note that no resampling is required, and that there's no copying of
the population list.  The really clever bit is the 'if j in d: ...'
block.  If you stare at the algorithm for long enough (and it does
take some staring), you can convince yourself that after the first
'for' loop, d can be any of the n*(n-1)*...*(n-k+1)
mappings-with-no-repeated-elements from some set of k elements of
range(n) to range(k), and that each one of these mappings is equally
likely to occur.  In a sense, this d is the inverse of the desired
sample, which would be a map with no repetitions from range(k) to
range(n).  So inverting d, and replacing d's keys by the corresponding
population elements, gives the random sample.

N.B.  I don't claim any originality for the algorithm; only for the
implementation: the algorithm is based on an algorithm attributed to
Robert Floyd, and appearing in Jon Bentley's 'Programming Pearls' book
(though that algorithm produces a set, so doesn't worry about the
ordering of the sample).  But I was struck by its beauty and
simplicity, and thought it deserved to be better known.

Happy Friday!

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


Re: TypeError: _new_() takes exactly 3 arguments (2 given) - what does it mean?

2010-05-28 Thread Jesse McDonnell
On Wed, 26 May 2010 14:30:21 -0400
Terry Reedy  wrote:

> On 5/24/2010 2:52 PM, Jesse McDonnell wrote:
> > I'm attempting to install Powerline http://code.google.com/p/powerline/,
> > a computer reservation software based on CherryPy/Python using a MYSql
> > database, at my local library and I've run up against an error that I
> > 
> 
> Honestly, unless you find a Python+Powerline expert who will help, I 
> suggest that you delete Powerline and look for something else. The most 
> recent release is an alpha release over 2 years old. Except for the Feb 
> 2010 wiki updates, the project appears to be dead. Even if someone 
> helped you past this, there is no evidence that the fix would applied 
> back to the codebase. And what about the next bug or problem?

> Terry Jan Reedy
> 
and

On Wed, 26 May 2010 12:04:53 -0700 (PDT)
Carl Banks  wrote:

> [Again, can't see the original, sorry]
> 
> On May 26, 11:30 am, Terry Reedy  wrote:
> > On 5/24/2010 2:52 PM, Jesse McDonnell wrote:

> 
> The most common reason for this message is trying to subclass a
> module.  (Very easy mistake when a module has the same name as a
> class, which is part of why I don't like the practice, though the
> modern PEP 8 reduces the issue.)
> 
> IOW, someone did something like this:
> 
> import foo
> class bar(foo): pass
> 
> when they should have done this:
> 
> from foo import foo
> class bar(foo): pass
> 

Terry and Carl,

Thanks for your replies. I got a response from the guy who coded Powerline 
through the google group for the app and upgrading dbwrap resolved this 
particular error. He also helped me work through some python-genshi issues and 
I now have  a working web interface.

Thanks again for your help.

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


Re: multiprocessing and accessing server's stdout

2010-05-28 Thread Martin P. Hellwig

On 05/28/10 21:44, Adam Tauno Williams wrote:

On Fri, 2010-05-28 at 15:41 +0100, Martin P. Hellwig wrote:

On 05/28/10 13:17, Adam Tauno Williams wrote:


You should be able to point it any any file-like object.  But, again,
why?
If you have the data in the process why send it to stdout and redirect
it.  Why not just send the data to the client directly?

Well you might want to multiplex it to more then one client, not saying
that this is the case here, just something I imagine possible.


That still doesn't make sense.  Why 'multiplex stdout'?  Why not just
multiplex the data into proper IPC channels in the first place?


I am going on a stretch here, I mostly agree with you, just trying to 
illustrate that there could be corner cases where this is sensible.
The current situation could be that there is a client/server program 
(binary only perhaps) which is not multi-user safe.


Python can be used as a wrapper around the server to make it 
multi-client, by emulating the exact behavior towards the client, the 
client program does not have to be changed.


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


Re: function that counts...

2010-05-28 Thread Lie Ryan
On 05/26/10 11:04, Bryan wrote:
> Jean-Michel Pichavant wrote:
>> I still don't see "how many positive integers less than n have digits
>> that sum up to m" makes it a "partition" though if that what prttn
>> means. Surely because I miss the context.
> 
> A partition of a positive integer m is an unordered collection of
> positive integers that sum to m. [1, 1, 2, 5] is a partition of 9. The
> problem at issue here is not that of counting partitions.
> 
> My algorithm for our prttn separated out the 'ndsums' sub-problem:
> Count d-digit ints with digits summing to m. I found a generalization
> of that problem stated in the /CRC Handbook of Discrete and
> Combinatorial Mathematics/ (2000 edition, section 2.1) among "counting
> problems" as:
> 
>Solutions to x_1 + ... x_n = k
>0 <= x_i <= a_i for one or more i
> 
> Alas, the handbook does not provide a formula or algorithm. It refers
> to the inclusion/exclusion principle, which I did not see how to turn
> into an efficient algorithm.

superpollo posted this question in comp.programming
(http://groups.google.com/group/comp.programming/browse_thread/thread/e3b10346db8ebd0a/579ca67f8b9b5a8c;
http://groups.google.com/group/comp.programming/msg/f7323d6e6942e883;
http://groups.google.com/group/comp.programming/browse_thread/thread/e3b10346db8ebd0a/dc4cd1e2feb89500
)

I went through the mathematical foundation of using
partition/distribution and inclusion-exclusion, and have written some
code that solves a subset of the problem, feel free if you or superpollo
are interested in continuing my answer (I won't be able to continue it
until next week, have been a little bit busy here)


copying the code here for convenience:

# memoization would be very useful here
def fact(n):
""" factorial function (i.e. n! = n * (n-1) * ... * 2 * 1) """
return n * fact(n - 1) if n != 0 else 1

def C(n, r):
""" regular Combination (nCr) """
return fact(n) / (fact(n - r) * fact(r))

def D(M, N):
""" Distribution aka Partitioning """
return C(M + N - 1, M)

def partition10(M, i):
""" Count how many integer < N sums to M where N = 10**int(i) """
s = 0
sign = 1
for j in range(i + 1):
s += sign * D(M, i) * C(i, j)

# flip the sign for inclusion-exclusion
sign *= -1

# if M = 32, then 32, 22, 12, 2, -8
M -= 10
return s

# still need to write:
# def partitionN10(...): -- applies a "restriction"/"boundary" to
#   the most significant digit
# then make it recurse.

# assuming factorials calculation is constant time (hint: memoization)
# the resulting code should work in O(n**2)
# an improvement over the naive method which is O(10**n)
# where n is the number of digits in N
# DISCLAIMER: the big-O is a quick guess, not really calculated
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Free chapter about Python and databases (MySQL and SQLite)

2010-05-28 Thread John Bokma
Sebastian Bassi  writes:

> On Fri, May 28, 2010 at 12:37 AM, John Bokma  wrote:
>> I feel more than uncomfortable with example code that uses: user="root"
>
> What's wrong with this? It is just an example of connection string.
> The reader will use his/her user/pass/dbname according to their own
> settings.

A bit down you're contradicting yourself: your audience is not familiar
with databases, yet you assume that they will use their own settings?

>> (e.g. p291). I never get why people write a short (IMO) /bad/ intro to
>> databases while there are books out there that do a way better
>
> The intended audience of this book are biologist who may be not
> familiarized with relational databases. Most of my colleagues (at
> least from the bio camp) don't even know that behind most dynamic web
> pages there are databases and I think that most of them will find the
> intro section useful. You can always skip what you know and go to the
> point you want.

My point is that the intro I (speed) read is weak at best. You say
you're doing your audience a favor, but I don't agree.

> I am not sure that price in this kind of book are tied to the number
> of pages. There must be some relation, but this is not the main factor
> affecting price.

Even if it's just a few bucks, it's still money saved [0]. On top of
that I think it's way better to point your audience to good books on the
topic and skip the intro instead of doing a (half hearted IMO) attempt
at it yourself.

>> I would love to see more technical books that start at page 1 with the
>> topic, not with an introduction to the language (170+ pages) and some
> ...
>
> I see where you go, it seems you are not the target audience for this
> book. Anyway I appreciate your feedback.

You're welcome. And to be honest, if the book didn't have those filler
chapters (which they are IMO) I would certainly have been interested in
it. Note that I am not trying to convince you to rewrite your book, but
my bookcase could have 20% more room if technical writers stopped to
write books that tried to introduce their audience to everything but the
kitchen sink [1]. My favourite books are the ones that /don't/ do the
everything but the kitchensink gig, but direct me to other high quality
books.


[0] I've been a technical editor for a book, and got paid by the page.
[1] I mean the books that seem to handle a single specific topic. If I
buy "Ubuntu up and running" I expect everything, including the
kitchensink.

-- 
John Bokma   j3b

Hacking & Hiking in Mexico -  http://johnbokma.com/
http://castleamber.com/ - Perl & Python Development
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Free chapter about Python and databases (MySQL and SQLite)

2010-05-28 Thread Robinow



 wrote:


Sebastian Bassi  writes:

On Fri, May 28, 2010 at 12:37 AM, John Bokma   
wrote:


Even if it's just a few bucks, it's still money saved [0]. On top of
that I think it's way better to point your audience to good books on  
the

topic and skip the intro instead of doing a (half hearted IMO) attempt
at it yourself.





OK, John. What book do you recommend?

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


"Neha Dhupia IN WATER" "Neha Dhupia" IN BIKINI " "SEXY "Neha Dhupia SEXY BELLY" "Neha Dhupia IN YELLOW BIKINI" "Neha Dhupia IN WHITE BIKINI" "Neha Dhupia" AS MISS WORLD" "BOLLYWOOD BIKINI" on http://

2010-05-28 Thread Naeem
"Neha Dhupia IN WATER" "Neha Dhupia"  IN BIKINI " "SEXY "Neha Dhupia
SEXY BELLY" "Neha Dhupia IN YELLOW BIKINI" "Neha Dhupia IN WHITE
BIKINI" "Neha Dhupia"  AS MISS WORLD" "BOLLYWOOD BIKINI" on
http://hollywood-bollywood-pics.blogspot.com/   "Neha Dhupia IN WATER"
"Neha Dhupia"  IN BIKINI " "SEXY "Neha Dhupia SEXY BELLY" "Neha Dhupia
IN YELLOW BIKINI" "Neha Dhupia IN WHITE BIKINI" "Neha Dhupia"  AS MISS
WORLD" "BOLLYWOOD BIKINI" on  http://hollywood-bollywood-pics.blogspot.com/
"Neha Dhupia IN WATER" "Neha Dhupia"  IN BIKINI " "SEXY "Neha Dhupia
SEXY BELLY" "Neha Dhupia IN YELLOW BIKINI" "Neha Dhupia IN WHITE
BIKINI" "Neha Dhupia"  AS MISS WORLD" "BOLLYWOOD BIKINI" on
http://hollywood-bollywood-pics.blogspot.com/   "Neha Dhupia IN WATER"
"Neha Dhupia"  IN BIKINI " "SEXY "Neha Dhupia SEXY BELLY" "Neha Dhupia
IN YELLOW BIKINI" "Neha Dhupia IN WHITE BIKINI" "Neha Dhupia"  AS MISS
WORLD" "BOLLYWOOD BIKINI" on  http://hollywood-bollywood-pics.blogspot.com/
"Neha Dhupia IN WATER" "Neha Dhupia"  IN BIKINI " "SEXY "Neha Dhupia
SEXY BELLY" "Neha Dhupia IN YELLOW BIKINI" "Neha Dhupia IN WHITE
BIKINI" "Neha Dhupia"  AS MISS WORLD" "BOLLYWOOD BIKINI" on
http://hollywood-bollywood-pics.blogspot.com/   "Neha Dhupia IN WATER"
"Neha Dhupia"  IN BIKINI " "SEXY "Neha Dhupia SEXY BELLY" "Neha Dhupia
IN YELLOW BIKINI" "Neha Dhupia IN WHITE BIKINI" "Neha Dhupia"  AS MISS
WORLD" "BOLLYWOOD BIKINI" on  http://hollywood-bollywood-pics.blogspot.com/
"Neha Dhupia IN WATER" "Neha Dhupia"  IN BIKINI " "SEXY "Neha Dhupia
SEXY BELLY" "Neha Dhupia IN YELLOW BIKINI" "Neha Dhupia IN WHITE
BIKINI" "Neha Dhupia"  AS MISS WORLD" "BOLLYWOOD BIKINI" on
http://hollywood-bollywood-pics.blogspot.com/   "Neha Dhupia IN WATER"
"Neha Dhupia"  IN BIKINI " "SEXY "Neha Dhupia SEXY BELLY" "Neha Dhupia
IN YELLOW BIKINI" "Neha Dhupia IN WHITE BIKINI" "Neha Dhupia"  AS MISS
WORLD" "BOLLYWOOD BIKINI" on  http://hollywood-bollywood-pics.blogspot.com/
"Neha Dhupia IN WATER" "Neha Dhupia"  IN BIKINI " "SEXY "Neha Dhupia
SEXY BELLY" "Neha Dhupia IN YELLOW BIKINI" "Neha Dhupia IN WHITE
BIKINI" "Neha Dhupia"  AS MISS WORLD" "BOLLYWOOD BIKINI" on
http://hollywood-bollywood-pics.blogspot.com/   "Neha Dhupia IN WATER"
"Neha Dhupia"  IN BIKINI " "SEXY "Neha Dhupia SEXY BELLY" "Neha Dhupia
IN YELLOW BIKINI" "Neha Dhupia IN WHITE BIKINI" "Neha Dhupia"  AS MISS
WORLD" "BOLLYWOOD BIKINI" on  http://hollywood-bollywood-pics.blogspot.com/
"Neha Dhupia IN WATER" "Neha Dhupia"  IN BIKINI " "SEXY "Neha Dhupia
SEXY BELLY" "Neha Dhupia IN YELLOW BIKINI" "Neha Dhupia IN WHITE
BIKINI" "Neha Dhupia"  AS MISS WORLD" "BOLLYWOOD BIKINI" on
http://hollywood-bollywood-pics.blogspot.com/   "Neha Dhupia IN WATER"
"Neha Dhupia"  IN BIKINI " "SEXY "Neha Dhupia SEXY BELLY" "Neha Dhupia
IN YELLOW BIKINI" "Neha Dhupia IN WHITE BIKINI" "Neha Dhupia"  AS MISS
WORLD" "BOLLYWOOD BIKINI" on  http://hollywood-bollywood-pics.blogspot.com/
"Neha Dhupia IN WATER" "Neha Dhupia"  IN BIKINI " "SEXY "Neha Dhupia
SEXY BELLY" "Neha Dhupia IN YELLOW BIKINI" "Neha Dhupia IN WHITE
BIKINI" "Neha Dhupia"  AS MISS WORLD" "BOLLYWOOD BIKINI" on
http://hollywood-bollywood-pics.blogspot.com/   "Neha Dhupia IN WATER"
"Neha Dhupia"  IN BIKINI " "SEXY "Neha Dhupia SEXY BELLY" "Neha Dhupia
IN YELLOW BIKINI" "Neha Dhupia IN WHITE BIKINI" "Neha Dhupia"  AS MISS
WORLD" "BOLLYWOOD BIKINI" on  http://hollywood-bollywood-pics.blogspot.com/
"Neha Dhupia IN WATER" "Neha Dhupia"  IN BIKINI " "SEXY "Neha Dhupia
SEXY BELLY" "Neha Dhupia IN YELLOW BIKINI" "Neha Dhupia IN WHITE
BIKINI" "Neha Dhupia"  AS MISS WORLD" "BOLLYWOOD BIKINI" on
http://hollywood-bollywood-pics.blogspot.com/   "Neha Dhupia IN WATER"
"Neha Dhupia"  IN BIKINI " "SEXY "Neha Dhupia SEXY BELLY" "Neha Dhupia
IN YELLOW BIKINI" "Neha Dhupia IN WHITE BIKINI" "Neha Dhupia"  AS MISS
WORLD" "BOLLYWOOD BIKINI" on  http://hollywood-bollywood-pics.blogspot.com/
"Neha Dhupia IN WATER" "Neha Dhupia"  IN BIKINI " "SEXY "Neha Dhupia
SEXY BELLY" "Neha Dhupia IN YELLOW BIKINI" "Neha Dhupia IN WHITE
BIKINI" "Neha Dhupia"  AS MISS WORLD" "BOLLYWOOD BIKINI" on
http://hollywood-bollywood-pics.blogspot.com/   "Neha Dhupia IN WATER"
"Neha Dhupia"  IN BIKINI " "SEXY "Neha Dhupia SEXY BELLY" "Neha Dhupia
IN YELLOW BIKINI" "Neha Dhupia IN WHITE BIKINI" "Neha Dhupia"  AS MISS
WORLD" "BOLLYWOOD BIKINI" on  http://hollywood-bollywood-pics.blogspot.com/
"Neha Dhupia IN WATER" "Neha Dhupia"  IN BIKINI " "SEXY "Neha Dhupia
SEXY BELLY" "Neha Dhupia IN YELLOW BIKINI" "Neha Dhupia IN WHITE
BIKINI" "Neha Dhupia"  AS MISS WORLD" "BOLLYWOOD BIKINI" on
http://hollywood-bollywood-pics.blogspot.com/   "Neha Dhupia IN WATER"
"Neha Dhupia"  IN BIKINI " "SEXY "Neha Dhupia SEXY BELLY" "Neha Dhupia
IN YELLOW BIKINI" "Neha Dhupia IN WHITE BIKINI" "Neha Dhupia"  AS MISS
WORLD" "BOLLYWOOD BIKINI" on  http://hollywood-bollywood-pics.blogspot.com/
"Neha Dhupia IN WATER" "Neha Dhupia"  IN BIKINI " "SEXY "Neha Dhupia
SEXY BELLY" "Neha Dh