Re: What makes functions special?

2011-07-10 Thread Terry Reedy

On 7/9/2011 6:34 PM, Steven D'Aprano wrote:


Suppose instead an implementation of Python did not pre-compile the
function. Each time you called spam(n), the implementatio n would have to
locate the source code and interpret it on the spot. Would that be
allowed?"

If that's your question, then I would call that a Python interpreter using
c.1960 technology (as opposed to a byte-code compiler, which all the main
implementations currently are).

If that were the *only* difference, then I see no reason why it wouldn't be
allowed as an implementation of Python. A horribly slow implementation, but
still an implementation.


while and for loops would also be terribly slow if their bodies were not 
compiled but were reinterpreted at the source code level for each loop. 
Having to reinterpred the compiled byte code for each loop does make 
them slower than compiled to native code C. Same as for functions.


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


Re: String concatenation vs. string formatting

2011-07-10 Thread Vinay Sajip
Andrew Berg  gmail.com> writes:

> How would I do that with the newer formatting? I've tried:

There are examples in the blog post I linked to earlier:

http://plumberjack.blogspot.com/2010/10/supporting-alternative-formatting.html

Regards,

Vinay Sajip


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


Re: String concatenation vs. string formatting

2011-07-10 Thread Andrew Berg
-BEGIN PGP SIGNED MESSAGE-
Hash: RIPEMD160

On 2011.07.10 02:23 AM, Vinay Sajip wrote:
> There are examples in the blog post I linked to earlier:
It seems that would require logutils. I'm trying to keep dependencies to
a minimum in my project, but I'll take a look at logutils and see if
there's anything else I could use. Thanks.

- -- 
CPython 3.2 | Windows NT 6.1.7601.17592 | Thunderbird 5.0
PGP/GPG Public Key ID: 0xF88E034060A78FCB
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAwAGBQJOGVnZAAoJEPiOA0Bgp4/LvLoH/3DL2mf7UcI/JVrrYfRmh2gb
oofQzskbFrIp74U9w+8Qdxu2dmgctIk7q0S+y6jKVbc1tk1SfqQS+wAIP058ckak
SDq0AoVrTSYEee+cuAvMiGHZCom2Y49mzdbXEHOOLDYZi8y3KojOJEAm0PWMdpN6
1dIpojozNOZU3V4j91E5UXV4APe8ixXrjlWNwhxqiTITrMenCG6O0LfxVvnHedTl
gKvpC2Sfr2ql1+Xo7Nl6Z5jbMjFb0m8DmYaPXpS7QU6KXHOD7L6wt9+iG4H2F146
aYXukjkTXu9nwtn2s6EVn2QUyImlfzxtpd+UrpfAb0mMwItdInTKOrCwAAHSHl0=
=/VOv
-END PGP SIGNATURE-
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How can I make a program automatically run once per day?

2011-07-10 Thread Rafael Durán Castañeda

On 10/07/11 04:01, John Salerno wrote:

Thanks everyone! I probably should have said something like "Python,
if possible and efficient, otherwise any other method" ! :)

I'll look into the Task Scheduler. Thanks again!
You may use Celery 
http://docs.celeryproject.org/en/latest/userguide/periodic-tasks.html

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


Re: String concatenation vs. string formatting

2011-07-10 Thread Vinay Sajip
Andrew Berg  gmail.com> writes:

> On 2011.07.10 02:23 AM, Vinay Sajip wrote:
> > There are examples in the blog post I linked to earlier:
> It seems that would require logutils. I'm trying to keep dependencies to
> a minimum in my project, but I'll take a look at logutils and see if
> there's anything else I could use. Thanks.

You don't need logutils, just the BraceMessage class - which is shown in the
blog post (around 10 lines). Feel free to use it with copy and paste :-)

Regards,

Vinay Sajip




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


Re: String concatenation vs. string formatting

2011-07-10 Thread Andrew Berg
-BEGIN PGP SIGNED MESSAGE-
Hash: RIPEMD160

On 2011.07.10 04:47 AM, Vinay Sajip wrote:
> You don't need logutils, just the BraceMessage class - which is
> shown in the blog post (around 10 lines). Feel free to use it with
> copy and paste :-)
I didn't realize that was the actual class when I first read it. Thanks.

- -- 
CPython 3.2 | Windows NT 6.1.7601.17592 | Thunderbird 5.0
PGP/GPG Public Key ID: 0xF88E034060A78FCB
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAwAGBQJOGXp6AAoJEPiOA0Bgp4/LHhgH/2lLFrRPep9rBsmSVSc794YM
w2A/e8KMTuChITTSa90WOsjqfIAkS1cvP7JWEJZ1QUqtZJMAWLhlZBaG8QuZRR2b
OGBia15fzMEfHcWkNfLZ9fbZvSVZNH71YSA7bEbz5MYy+iBUcbmHI8KmQiJN1kI3
Be4uXH+l09iJBqgQKsfARzNcVxtauKylfla4/0aIWoumX6ioP+l6C+M/2iq+mYG5
w+NX1AWH2f85UT5Wlt3FcyNMP6PZHFZg+hojS4p+NVZChl7KMlJihWPSRxZNWhGp
0qf/qh9y4d1M2Kfo1C3DTDdpdL+tWWanlJ3ghXSF096/ylmytxivZ17utl3U5vA=
=RQGa
-END PGP SIGNATURE-
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How can I make a program automatically run once per day?

2011-07-10 Thread Paul Rudin
John Salerno  writes:

> I have a script that does some stuff that I want to run every day for
> maybe a week, or a month. So far I've been good about running it every
> night, but is there some way (using Python, of course) that I can make
> it automatically run at a set time each night?

Well - you can make a long lived python process that puts itself to
sleep for 24 hours and then wakes up and does stuff, but the normal
approach to this kind of thing is to use cron. On windows there's also
some kind of scheduler.

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


Re: Finding duplicated photo

2011-07-10 Thread Kevin Zhang
On Fri, Jul 8, 2011 at 8:37 PM, Billy Mays  wrote:
>
>
> I recently wrote a program after reading an article (
> http://www.hackerfactor.com/**blog/index.php?/archives/432-**
> Looks-Like-It.html)
>  using the DCT method he proposes.  It worked surprisingly well even with
> just the 64bit hash it produces.
>
>
The link you provided was so great.
It mentioned an implementation of the hash algorithm in Python though
invalid, so I spent some time writing my own version.
It works really fine and kind of solved the problem of finding duplicated
pictures to delete I recently came across.

Thanks Billy!

ps.
If anyone's interested, pleas checkout the source code in the attachment and
welcome any advise.


pic_seeker.py
Description: Binary data
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: String concatenation vs. string formatting

2011-07-10 Thread Steven D'Aprano
Andrew Berg wrote:

> How should I go about switching from concatenation to string formatting
> for this?
> 
> avs.write(demux_filter + field_filter + fpsin_filter + i2pfilter +
> dn_filter + fpsout_filter + trim_filter + info_filter)
> 
> I can think of a few ways, but none of them are pretty.

fields = (demux_filter, field_filter, fpsin_filter, i2pfilter, 
  dn_filter, fpsout_filter, trim_filter, info_filter)
avs.write("%s"*len(fields) % fields)

works for me.




-- 
Steven

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


anonymous function with multiple statements

2011-07-10 Thread Yingjie Lan
Hi all, 

I wonder if Python provides a way to define anonymous functions containing 
multiple statements? With lambda form, we can only define a function of a 
single 
expression. In Javascript, it is possible to define 
a full-fledged anonymous functions, which suggests it is useful to have it. In 
Python, it might be like this:


#==

def test( fn, K ): 
return sum(fn(i) for i in range(K))/K

test( def (i): #indent from start of this line, not from 'def'
from math import sin
#the last statement ends with a ',' or ')'.
return sin(i)+i*i;, 100) #';' to mark end of statement 

#another way:
test( def (i): #indent from start of this line, not from 'def'
from math import sin
return sin(i)+i*i
  , 100) #freely place ',' anywhere

#===

Any thoughts?

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


Re: String concatenation vs. string formatting

2011-07-10 Thread Roy Smith
In article ,
 Andrew Berg  wrote:

> How should I go about switching from concatenation to string formatting
> for this?
> 
> avs.write(demux_filter + field_filter + fpsin_filter + i2pfilter +
> dn_filter + fpsout_filter + trim_filter + info_filter)
> 
> I can think of a few ways, but none of them are pretty.

The canonical way to do that would be something like

fields = [demux_filter,
  field_filter,
  fpsin_filter,
  i2pfilter,
  dn_filter,
  fpsout_filter,
  trim_filter,
  info_filter]
avs.write(''.join(fields))
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: why the following python program does not face any concurrency problems without synchronize mechanism?

2011-07-10 Thread TheSaint
smith jack wrote:

>  have run this program for many times,and the result is always 5050
You might not need to make it in a multiprocess environment

Try it in the python (3) shell

>>> tot= 0
>>> for k in range(1,100):
...   tot += k
...   print(tot)
... 

And watch the risults.

-- 
goto /dev/null
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Morelia for BDD in Python

2011-07-10 Thread Phlip
> I think it would add great value, since without it I'm unlikely to
> bother using Morelia in any project. The maintenance burden is too high
> to keep adding dependencies that come from a distinct dependency system
> outside my OS.

pip freeze! Specifically, we already added pip freeze and virtualenv
support to our project's fab file...

> There's no "pip uninstall", though.

I can see that would matter to projects you would want to uninstall,
but not Morelia...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: anonymous function with multiple statements

2011-07-10 Thread Terry Reedy

On 7/10/2011 7:21 AM, Yingjie Lan wrote:


I wonder if Python provides a way to define anonymous functions containing
multiple statements?


No, intentionally not. Forget this idea. Multiple functions named 
'' are inferior for representation purposes, like in error 
tracebacks, to those with individual names. Just use def statements.


Terry J. Reedy


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


Re: Morelia for BDD in Python

2011-07-10 Thread Phlip
Two of my feature requests for Morelia:

 - integrate with the test runner (nose etc.) to provide one
dot . per passing step

 - insert a long multi-line abstract string (typically
XML) with inside [[CDATA-style escaping tags

 - the ability to stub a step as 

 - the ability to pass a | delimited | table into a step
as an argument containing an array, instead of unrolling
the table into multiple calls to one step

 - a rapid conversion to an HTML report, with folding blocks,
 as an instant project documentation.

Lack of the second option is why we _didn't_ use M for the BDD test
runner on our latest project. (The onsite customer is an XML-freak,
AND the lead architect until I can manage to retire him upstairs!;)

But if I could put those four in, then write a disposable script that
converted our XML "project definition" file back into Morelia-Cucumber-
Gherkin notation, I'd have Morelia back in our project!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Virtual functions are virtually invisible!

2011-07-10 Thread rantingrick
On Jul 4, 3:43 am, Gregory Ewing  wrote:
> rantingrick wrote:
> > what concerns me is the fact that virtual methods in derived
> > classes just blend in to the crowd.
> > I think we really need some
> > sort of visual cue in the form of forced syntactical notation (just
> > like the special method underscores).
>
> If you're suggesting that it should be impossible to override
> a method unless it is specially marked somehow in the base
> class, I think that would be a bad idea.

Sorry i did explain properly... No NOT marked in the BASE class but
marked in the DERIVED class! My concerns are from a readability
standpoint. Here's a naive example...

class Top(object):
def __init__(self):
pass
def m1(self):
"""overide"""
return True
def m2(self):
print 'm2'


def Derived(Top):
def __init__(self):
Top.__init__(self)
def m1(self):
return False

My argument is this...

   """If class "Derived" exists in another module the reader has no
idea which methods where clobbered and which were not WITHOUT being
intimate with the entire code base."""

 I suggest we solve this dilemma by forcing a syntax "tag" when
declaring clobbering virtual functions. And if someone forgets to
include the tag python would throw an exception. This has the effect
of making the code MUCH easier to follow by the human readers. And it
put NO constraints on the API. Also it has the added effect of warning
unsuspecting programmers of name clashes that would otherwise not
produce an error.

> One of the principles behind the design of Eiffel is that
> classes should *always* be open to modification in any way
> by a subclass. The reason is that the author of a class
> library can't anticipate all the ways people might want to
> use it. Consequently Eiffel has no equivalent of C++'s
> "private" declaration -- everything is at most "protected".
> It also has no equivalent of Java's "final".

Exactly! We should never put limits on what methods CAN be virtual.
However, we CAN enforce a syntax that removes ambiguity from the
equation.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Virtual functions are virtually invisible!

2011-07-10 Thread Chris Angelico
On Mon, Jul 11, 2011 at 3:15 AM, rantingrick  wrote:
>  I suggest we solve this dilemma by forcing a syntax "tag" when
> declaring clobbering virtual functions.

Python has other dilemmas, too. I suggest we adopt the same solution.
For instance, every statement should begin with a marker, so that we
know it isn't a comment; every variable name should be adorned, so
that we know it's not a keyword like 'if'; and every decimal integer
should begin with "0d" so that we know it isn't hex. Plus, we should
get rid of binary operators with their messy precedence tables;
everything should become function calls.

 $assign($x,$add(0d5,0d7))  # assigns 12 (decimal) to x

This would make Python far less ambiguous. We should proceed with this
right away.

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


Function docstring as a local variable

2011-07-10 Thread Tim Johnson
Consider the following:
## code
def test():
"""This is my docstring"""
print(??)  ## can I print the docstring above?
## /code
It possible for a function to print it's own docstring?

thanks
(pointers to docs could be sufficient)
-- 
Tim 
tim at johnsons-web dot com or akwebsoft dot com
http://www.akwebsoft.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Function docstring as a local variable

2011-07-10 Thread rantingrick
On Jul 10, 12:41 pm, Tim Johnson  wrote:
> It possible for a function to print it's own docstring?

def f():
   """docstring"""
   print "docstring"

any questions?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Function docstring as a local variable

2011-07-10 Thread Andrew Berg
-BEGIN PGP SIGNED MESSAGE-
Hash: RIPEMD160

On 2011.07.10 12:41 PM, Tim Johnson wrote:
> It possible for a function to print it's own docstring?
>>> def test():
... """Hi there."""
... print(test.__doc__)
...
>>> test()
Hi there.

- -- 
CPython 3.2 | Windows NT 6.1.7601.17592 | Thunderbird 5.0
PGP/GPG Public Key ID: 0xF88E034060A78FCB
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAwAGBQJOGeWlAAoJEPiOA0Bgp4/LT1EIAM32NS/RdZ9y6IlAkpEYkYeP
qGf2A/+8eZHrSYtCWYWwpfusa9guYaQsDvq31sFHnI3VPria7mUeB6HoyqP1sO3B
5D0lpBK0/u3rWNL9FHeWeb+Cc6CLXBB7531VAR1pzfUVb1mw3LPww16klNMkr5Gd
9Qob710lKIW+om8rEF+L5o/DOFSTN7oodTsNpdj8zhHVnPVpV/gtL7iQR82C0KPq
UuukVkCuhvYyWoJMz1qDZjKU1bI2T064TC8IeOQLdOVMnQLhTJdgsHD4nNVszixN
EU9eemscW0cABF2MgUPnuJLytUJHcxtEC4aj3Cue0oLhMyVN57yNIBaf1Pm6M7E=
=tCFP
-END PGP SIGNATURE-
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Morelia for BDD in Python

2011-07-10 Thread rusi
On Jul 10, 10:21 am, Ben Finney  wrote:
> Phlip  writes:
> > 'sudo pip install morelia' just worked for me, on Ubuntu.
>
> The problem with ‘pip’ is that it's a parallel package installation that
> ignores the available package management system on the OS.
>
> That's not a fault of ‘pip’ or Setuptools or PyPI or the rest; but it's
> a higher maintenance burden for the user than getting a package from the
> same system that provides all the rest of their packages on the
> computer.
>
> On operating systems with poor package management, Python's distutils
> and PyPI etc. are better than nothing. But on an OS like Debian with
> good package management already for free software, it's a step backward
> to rely on external dependencies from a disjoint package system.

Just curious: Do you manage to stay within debian packages and have
all the python packages you want/need at the versions that are most
convenient?

For myself, until recently my debian testing did not even give
python2.7.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Function docstring as a local variable

2011-07-10 Thread Chris Angelico
On Mon, Jul 11, 2011 at 3:47 AM, Andrew Berg  wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: RIPEMD160
>
> On 2011.07.10 12:41 PM, Tim Johnson wrote:
>> It possible for a function to print it's own docstring?
 def test():
> ...     """Hi there."""
> ...     print(test.__doc__)

That's assuming that it knows its own name, and that that name hasn't
been rebound. Is there a way for a function to find its own self?

>>> def findself():
"""Find myself. Ooh look, there I am!"""
import sys
try:
1/0
except:
traceback=sys.exc_info()[2]
# Now I'm not sure what to do with traceback.
# traceback.tb_frame.f_code.co_name is the function name ("findself").
# Is there a way to get the function object?

I'm kinda half-way there, but I've never worked with traceback
objects. Someone will know, I'm sure!

ChrisA


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


Re: Newbie help - Programming the Semantic Web with Python

2011-07-10 Thread Bruce Whealton
Thanks for the tips.  I actually had done some studies with Python, mainly 
Python 3, back about 6 months ago and over a period of a few months.
I didn't write a great deal of programs though, at the time.  I got away 
from it in a while and I didn't want to go back to step one of being like a 
total beginner.  There are so many things I try to keep up with as a Web 
Developer and coder and trying to expand my skills.  Unfortunately, I don't 
do well with picking  a focus.  I remember reading through this long 
reference manual, called "Learning Python," while I was on a flight and over 
a trip.  That was without a computer, so I was just reading, which is not 
the way to learn programming, obviously.  I feel the many concepts will come 
back to me fast.  I have another text, called "Beginning Python: From Novice 
to Professional" which covers Python 3.  This is a bit more practical in 
orientation.  I'm debating whether to jump to the chapters dealing with the 
web and see what I can do or starting from the beginning.  I did look into 
some online training, tutorials, or the like.


The Programming the Semantic Web book uses Python but all the code is 
included.  So, while it won't be a way to learn python, I hope I can get the 
code to run correctly.  In that text, they must be using Python 2.7 because 
I see print statements and not the print function call.
If you know of any good resources for finding python applications on the 
web, this might be a good way to learn.  I don't know if  I should look for 
Python applications, or if I'll have more luck looking for Python Libraries.

Thanks,
Bruce

-Original Message- 
From: Andrew Berg

Sent: Saturday, July 09, 2011 10:44 PM
To: comp.lang.python
Subject: Re: Newbie help - Programming the Semantic Web with Python

On 2011.07.09 08:32 PM, Bruce Whealton wrote:

Hello,
So, I got this book on Programming the Semantic Web about
the same time I started learning Python.  The code seems to be
developed for python 2.7 and not 3, I believe.

If you're going to learn Python 3, I suggest learning from a book that
deals with Python 3 (if there's not an updated text for the area you're
dealing with, go with something that teaches the basics). Once you have
the basics down and you know the common differences, then it will be
much easier to learn from a text that's based on Python 2 (you'll
stumble a whole lot less when trying to learn from such texts). You'll
also find some things in Python 3 that have been added to recent
versions of Python 2 that the text may not cover (e.g., the old % string
formatting syntax vs. the new format() string method).

If I was using python 3, it would require () around the thing that is
going to be printed, right?

That's not really the right way to think of the print() function. The
print statement has some very arbitrary syntax that could cause
unexpected behavior if simply put in the print() function. The print
function has parameters for optional behavior rather than odd syntax. In
the simplest cases, print and print() are extremely similar, but print()
has a bunch of functionality that is either difficult/annoying to
decipher (for humans, not the interpreter) or simply doesn't exist in print.
--
http://mail.python.org/mailman/listinfo/python-list 


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


Re: Function docstring as a local variable

2011-07-10 Thread Tim Johnson
* Andrew Berg  [110710 09:59]:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: RIPEMD160
> 
> On 2011.07.10 12:41 PM, Tim Johnson wrote:
> > It possible for a function to print it's own docstring?
> >>> def test():
> ... """Hi there."""
> ... print(test.__doc__)
  Holy Moly. Of course!
  thanks
-- 
Tim 
tim at johnsons-web dot com or akwebsoft dot com
http://www.akwebsoft.com
-- 
http://mail.python.org/mailman/listinfo/python-list


parsing packets

2011-07-10 Thread Littlefield, Tyler

Hello all:
I'm working on a server that will need to parse packets sent from a 
client, and construct it's own packets.
The setup is something like this: the first two bytes is the type of the 
packet.
So, lets say we have a packet set to connect. There are two types of 
connect packet: a auth packet and a connect packet.
The connect packet then has two bytes with the type, another byte that 
notes that it is a connect packet, and 4 bytes that contains the version 
of the client.
The auth packet has the two bytes that tells what packet it is, one byte 
denoting that it is an auth packet, then the username, a NULL character, 
and a password and a NULL character.


With all of this said, I'm kind of curious how I would 1) parse out 
something like this (I am using twisted, so it'll just be passed to my 
Receive function), and how I get the length of the packet with multiple 
NULL values. I'm also looking to build a packet and send it back out, is 
there something that will allow me to designate two bytes, set 
individual bits, then put it altogether in a packet to be sent out?


--

Take care,
Ty
my website:
http://tds-solutions.net
my blog:
http://tds-solutions.net/blog
skype: st8amnd127
My programs don't have bugs; they're randomly added features!

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


Re: Function docstring as a local variable

2011-07-10 Thread Richard Thomas
> >>> def findself():
>
>         """Find myself. Ooh look, there I am!"""
>         import sys
>         try:
>                 1/0
>         except:
>                 traceback=sys.exc_info()[2]
>         # Now I'm not sure what to do with traceback.
>         # traceback.tb_frame.f_code.co_name is the function name ("findself").
>         # Is there a way to get the function object?

I'm pretty sure there isn't. I've tried a number of times before to
find it but failed. Fundamentally frame objects don't need to know
about functions. Functions are just one way of wrapping code objects
but sometimes code objects come in modules.

You can use sys._getframe() to get the current frame instead of the
traceback.

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


Re: parsing packets

2011-07-10 Thread geremy condra
On Sun, Jul 10, 2011 at 4:59 PM, Littlefield, Tyler  wrote:
> Hello all:
> I'm working on a server that will need to parse packets sent from a client,
> and construct it's own packets.
> The setup is something like this: the first two bytes is the type of the
> packet.
> So, lets say we have a packet set to connect. There are two types of connect
> packet: a auth packet and a connect packet.
> The connect packet then has two bytes with the type, another byte that notes
> that it is a connect packet, and 4 bytes that contains the version of the
> client.
> The auth packet has the two bytes that tells what packet it is, one byte
> denoting that it is an auth packet, then the username, a NULL character, and
> a password and a NULL character.
>
> With all of this said, I'm kind of curious how I would 1) parse out
> something like this (I am using twisted, so it'll just be passed to my
> Receive function), and how I get the length of the packet with multiple NULL
> values. I'm also looking to build a packet and send it back out, is there
> something that will allow me to designate two bytes, set individual bits,
> then put it altogether in a packet to be sent out?

Just use the struct module[0] to do your packing for you.  There's not
enough info in your description to write it out for you, but it sounds
like it should do everything you need.

Geremy Condra

[0]: http://docs.python.org/library/struct.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie help - Programming the Semantic Web with Python

2011-07-10 Thread Andrew Berg
-BEGIN PGP SIGNED MESSAGE-
Hash: RIPEMD160

On 2011.07.10 02:28 PM, Bruce Whealton wrote:
> If you know of any good resources for finding python applications on
> the web, this might be a good way to learn.  I don't know if  I
> should look for Python applications, or if I'll have more luck
> looking for Python Libraries.
Tutorials and simple code examples are the best way to learn (walk
before you run). If you tried to study the standard libraries (or any
but the simplest libraries on PyPI), you'd get lost. Studying the
standard libraries would probably be a good way to learn good design
once you have a great command of the language. Of course, actually doing
a project to solve a real problem is probably the best way to learn once
you have the basics down (I'm learning a lot doing my first Python project).

- -- 
CPython 3.2 | Windows NT 6.1.7601.17592 | Thunderbird 5.0
PGP/GPG Public Key ID: 0xF88E034060A78FCB
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAwAGBQJOGh2VAAoJEPiOA0Bgp4/LIjoIAOaAnLWpPwRvwZm2VxhnA5CY
dNEJvEU4DyCvqKBOQ5Eh0NKgK7M81+sibgqsIqKLzIdUdK9io7zVQ+mYfS0h40TO
WzYOTX54Tx1d9w9K2/UWNAz+csWJ06TSsHDDVmhQ1JdHAhWz9EM4RzSt96RtdHsc
1dh/UtWTpn6Fm+9o2nIJ/471ZwtxAjOENprrC8SGchRT9mxlNvOyWe9+N3xr/g6l
qqGHHqSfazQU1wqbEbyvQxB0CsJ5kVVm764c0a1tkiVcGT6o+e93zB1tm0Di4KNe
gbDXVHtfo5jQIKCs8utt0a+m4IMzuU182MLz05ngWIQxIbhHW/zBNfw2pMxRxBA=
=RFgH
-END PGP SIGNATURE-
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Morelia for BDD in Python

2011-07-10 Thread Ben Finney
rusi  writes:

> Just curious: Do you manage to stay within debian packages and have
> all the python packages you want/need at the versions that are most
> convenient?

When that's not the case, I consider it not a status quo to live with,
but a problem to be addressed.

-- 
 \ “I cannot conceive that anybody will require multiplications at |
  `\   the rate of 40,000 or even 4,000 per hour …” —F. H. Wales, 1936 |
_o__)  |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


A beginning programmer

2011-07-10 Thread Eric
Greetings everyone;

Fresh High School graduate here with a passion for problem solving. My
last 2 years of HS I took programming courses (actually fairly good
ones; yay for good tech departments) that showed me

QuickBasic
VisualBasic
C++
Java

(in that order)

A friend of mine often talked about how nice Python was and being an
xkcd fan, i saw Python come up alot in the jokes. Python's awesome; I
see limitless possibilities in a very easy to understand and use
language that as xkcd put it "Programmings fun again!"

My problem is this though... I don't know what to do with this new
found knowledge of these languages. I'm a linux user so availability
of development tools is haaardly a problem. But I just don't know
what to do with it, I don't have any problems that need to be solved
and unfortunately I'm not familar enough with the languages (except
maybe c++) to help out the big projects like KDE / Gnome.

I realize this is the python mailing list and that I brought up some
non-python languages but I'm sure my situation is hardly new for those
looking to get into programming but having no idea of where to begin.

Any feedback is much appreciated!

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


Re: Function docstring as a local variable

2011-07-10 Thread python
I'm not sure how a function can get a generic handle to itself, but if
you're willing to hardcode the function name, then this technique works:

def test():
"""This is my doc string"""
print test.__doc__

test()

Outputs:

This is my doc string

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


Re: A beginning programmer

2011-07-10 Thread Thomas Jollans
On 07/11/2011 12:06 AM, Eric wrote:
> My problem is this though... I don't know what to do with this new
> found knowledge of these languages. I'm a linux user so availability
> of development tools is haaardly a problem. But I just don't know
> what to do with it, I don't have any problems that need to be solved
> and unfortunately I'm not familar enough with the languages (except
> maybe c++) to help out the big projects like KDE / Gnome.

Open source bug trackers are a great source of problems. Take an open
source program you like, ideally one with a sizeable and active user
base, written in a programming language you're comfortable with, check
out an open bug, and try solving it. This will
 * Get you reading other people's code. You can learn a lot from this
 * Provide a challenge
 * Do good

CPython itself is a great project to have a go at. I don't know how
familiar you are with C (as opposed to C++), but a large part of the
code is written in Python, there's loads of activity on the bug tracker,
and, in my experience, the community is very happy to help along new
people contributing their first patch.

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


Re: A beginning programmer

2011-07-10 Thread Andrew Berg
-BEGIN PGP SIGNED MESSAGE-
Hash: RIPEMD160

On 2011.07.10 05:06 PM, Eric wrote:
> But I just don't know what to do with it
You and I are quite different. I don't enjoy programming much, but
Python is a great tool to accomplish a few goals that I have.

> I don't have any problems that need to be solved and unfortunately
> I'm not familar enough with the languages (except maybe c++) to help
> out the big projects like KDE / Gnome.
The KDE for Windows project is really struggling. You could help there
with your C++ skills.

> I realize this is the python mailing list and that I brought up some 
> non-python languages but I'm sure my situation is hardly new for
> those looking to get into programming but having no idea of where to
> begin.
I could use some help on my project, but two inexperienced coders are
going to be slower than one.

- -- 
CPython 3.2 | Windows NT 6.1.7601.17592 | Thunderbird 5.0
PGP/GPG Public Key ID: 0xF88E034060A78FCB
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAwAGBQJOGiatAAoJEPiOA0Bgp4/LqxkH/1fbq+m0uyQDAV38mJq861HC
a4r3XZAka5BbGqIF753LRMzPdd31RpTiv+AUWtF7/AUVE+b0UsHaBDvyVvSBRcw9
XGwXUOy9WWtpeGS5CaKyJumMJStzzhCGetKeX+86F7RB6XgiBOCAFuaH4NRCpkYb
4y+Kg+0FqzYJk/lW9J/ZsoqyIbloet7zDC1EkrmwsfsodoTqL/NqRW4MY0u9PzU3
HTg2hBshj8EGe1wLG1DHxR7q/T88GuQZq7f6dYjwLmyljzs21cIj+Dn2d7nhbPpi
KwszNCpENbn4fssUh+xca71kd4S2zWEkxz0gLkVPdsuVffWKkLgrY8flnqVuXQk=
=NFjK
-END PGP SIGNATURE-
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Function docstring as a local variable

2011-07-10 Thread Colin J. Williams

On 10-Jul-11 13:44 PM, rantingrick wrote:

On Jul 10, 12:41 pm, Tim Johnson  wrote:

It possible for a function to print it's own docstring?


def f():
"""docstring"""
print "docstring"

any questions?


Try:

def f():
 ds= """docstring"""
 print ds
>

Colin W.

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


Re: A beginning programmer

2011-07-10 Thread Thomas Jollans
On 07/11/2011 12:22 AM, Thomas Jollans wrote:
> On 07/11/2011 12:06 AM, Eric wrote:
>> My problem is this though... I don't know what to do with this new
>> found knowledge of these languages. I'm a linux user so availability
>> of development tools is haaardly a problem. But I just don't know
>> what to do with it, I don't have any problems that need to be solved
>> and unfortunately I'm not familar enough with the languages (except
>> maybe c++) to help out the big projects like KDE / Gnome.
> 
> Open source bug trackers are a great source of problems. Take an open
> source program you like, ideally one with a sizeable and active user
> base, written in a programming language you're comfortable with, check
> out an open bug, and try solving it. This will
>  * Get you reading other people's code. You can learn a lot from this
>  * Provide a challenge
>  * Do good

Do note: Maybe you won't be able to create quality patches at first. But
you'll familiarize yourself with the language (and project) in time, and
if you follow a bug on a bug tracker, you can, when somebody else has
fixed it, study their patch as well. It's like a puzzle ;-)

As Andrew pointed out, KDE is written in C++. So you might want to check
that out.

> 
> CPython itself is a great project to have a go at. I don't know how
> familiar you are with C (as opposed to C++), but a large part of the
> code is written in Python, there's loads of activity on the bug tracker,
> and, in my experience, the community is very happy to help along new
> people contributing their first patch.
> 
> Cheers,
> Thomas

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


Re: Function docstring as a local variable

2011-07-10 Thread Roy Smith
In article ,
 pyt...@bdurham.com wrote:

> I'm not sure how a function can get a generic handle to itself, but if
> you're willing to hardcode the function name, then this technique works:
> 
> def test():
> """This is my doc string"""
> print test.__doc__
> 
> test()
> 
> Outputs:
> 
> This is my doc string
> 
> Malcolm

I'm sure there has to be a cleaner way that this, but one possible way 
for a function to find its name is to catch an exception and look at the 
traceback:

---
#!/usr/bin/env python   


import sys
import traceback

def foo():
"The Larch"
try:
raise Exception
except Exception, ex:
_, _, tb = sys.exc_info()
stacks = traceback.extract_tb(tb)
file_name, line_number, function_name, text = stacks[0]
print "I am %s", function_name
print "My docstring is", eval(function_name).__doc__

foo()
--

This works, but yuck.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: String concatenation vs. string formatting

2011-07-10 Thread Steven D'Aprano
Roy Smith wrote:

> The canonical way to do that would be something like
> 
> fields = [demux_filter,
>   field_filter,
>   fpsin_filter,
>   i2pfilter,
>   dn_filter,
>   fpsout_filter,
>   trim_filter,
>   info_filter]
> avs.write(''.join(fields))

I can't believe I didn't think of that. I must be getting sick. (The sore
throat, stuffy nose and puffy eyes may also be a sign.)

Yes, ''.join() is far to be preferred over my solution using "%s".



-- 
Steven

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


Re: Function docstring as a local variable

2011-07-10 Thread Tim Johnson
* pyt...@bdurham.com  [110710 14:17]:
> I'm not sure how a function can get a generic handle to itself, but if
> you're willing to hardcode the function name, then this technique works:
> 
> def test():
> """This is my doc string"""
> print test.__doc__
> 
> test()
  Works for me. Works for the application I'm after. thanks
  Here's a related question:
  I can get the docstring for an imported module:
  >>> import tmpl as foo
  >>> print(foo.__doc__)
  Python templating features

   Author - tim at akwebsoft dot com

 ## Is it possible to get the module docstring
 ## from the module itself?

 Thanks again
-- 
Tim 
tim at johnsons-web dot com or akwebsoft dot com
http://www.akwebsoft.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Wgy isn't there a good RAD Gui tool fo python

2011-07-10 Thread Ivan Kljaic
Ok Guys. I know that most of us have been expiriencing the need for a
nice Gui builder tool for RAD and most of us have been googling for it
a lot of times. But seriously. Why is the not even one single RAD tool
for Python. I mean what happened to boa constructor that it stopped
developing. I simply do not see any reasons why there isn't anything.
Please help me understand it. Any insights?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Function docstring as a local variable

2011-07-10 Thread Carl Banks
On Sunday, July 10, 2011 3:50:18 PM UTC-7, Tim Johnson wrote:
>   Here's a related question:
>   I can get the docstring for an imported module:
>   >>> import tmpl as foo
>   >>> print(foo.__doc__)
>   Python templating features
> 
>Author - tim at akwebsoft dot com
> 
>  ## Is it possible to get the module docstring
>  ## from the module itself?


print __doc__


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


Re: Function docstring as a local variable

2011-07-10 Thread Corey Richardson
Excerpts from Colin J. Williams's message of Sun Jul 10 18:28:15 -0400 2011:
> Try:
> 
> def f():
>   ds= """docstring"""
>   print ds

That doesn't actually make a docstring, though. It makes a string object and
points the name ds at it. Do you know what a docstring is?

def foo():
"""I am a docstring"""
pass

def bar():
ds = "I am not a docstring!"

def baz():
"I am a docstring too!"
pass

def qux():
'And even me! Quote type don't matter (besides style)'
 pass
-- 
Corey Richardson
  "Those who deny freedom to others, deserve it not for themselves"
 -- Abraham Lincoln


signature.asc
Description: PGP signature
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Function docstring as a local variable

2011-07-10 Thread Corey Richardson
Excerpts from Carl Banks's message of Sun Jul 10 18:59:02 -0400 2011:
> print __doc__
> 

Python 2.7.1 (r271:86832, Jul  8 2011, 22:48:46) 
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> def foo():
... "Docstring"
... print __doc__
... 
>>> foo()
None
>>> 


What does yours do?
-- 
Corey Richardson
  "Those who deny freedom to others, deserve it not for themselves"
 -- Abraham Lincoln


signature.asc
Description: PGP signature
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Wgy isn't there a good RAD Gui tool fo python

2011-07-10 Thread Corey Richardson
Excerpts from Ivan Kljaic's message of Sun Jul 10 18:50:31 -0400 2011:
> Ok Guys. I know that most of us have been expiriencing the need for a
> nice Gui builder tool for RAD and most of us have been googling for it
> a lot of times. But seriously. Why is the not even one single RAD tool
> for Python. I mean what happened to boa constructor that it stopped
> developing. I simply do not see any reasons why there isn't anything.
> Please help me understand it. Any insights?

What is RAD? If you're just looking for a GUI builder there's Glade for
gtk, wxGlade for wxWidgets, QtCreator (And something new for their newer
system, don't remember the name), etc.
-- 
Corey Richardson
  "Those who deny freedom to others, deserve it not for themselves"
 -- Abraham Lincoln


signature.asc
Description: PGP signature
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Function docstring as a local variable

2011-07-10 Thread Tim Chase

On 07/10/2011 05:50 PM, Tim Johnson wrote:

* pyt...@bdurham.com  [110710 14:17]:

def test():
 """This is my doc string"""
 print test.__doc__
test()


   Works for me. Works for the application I'm after. thanks
   Here's a related question:
  ## Is it possible to get the module docstring
  ## from the module itself?


You're gonna kick yourself :)

  print __doc__

-tkc



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


Re: String concatenation vs. string formatting

2011-07-10 Thread Andrew Berg
-BEGIN PGP SIGNED MESSAGE-
Hash: RIPEMD160

On 2011.07.10 09:33 AM, Roy Smith wrote:
> The canonical way to do that would be something like
> 
> fields = [demux_filter, field_filter, fpsin_filter, i2pfilter, 
> dn_filter, fpsout_filter, trim_filter, info_filter] 
> avs.write(''.join(fields))
That would look really awful (IMO) if the strings weren't intended to be
on separate lines (I use embedded newlines instead of joining them with
newlines in order to prevent blank lines whenever a certain filter isn't
used). In this particular case, they are, so even though it uses a lot
of whitespace, it does match the layout of its output.

- -- 
CPython 3.2 | Windows NT 6.1.7601.17592 | Thunderbird 5.0
PGP/GPG Public Key ID: 0xF88E034060A78FCB
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAwAGBQJOGjSxAAoJEPiOA0Bgp4/LHzcH+gKeSCkbdEh8jg2UV0vICJdS
Fea95/vqCbZkjQxSuW8L73CpoACiv4XQ6hoxyIUq7maf+W89rGMVmLsPWYXtmif9
FV6WM3kSpg4hoC1cbqGW5g1bnpMnSPlznm74mKtdGhF+3zEtlm9+j8m53362YQHc
0Y9D+4KAeee5QUT/NII5QBRvSG2rAuv5+sayMNayix0pCJLEGrRLp/7LJOyhvJLN
eDdywE+svfcQAi4iGAylrmvDfgf6pBgysyY/pv2YD9IpdpYL5mkVqLi+ADZdZBOb
M4uxBReowgC/RaWxB+qEvfg5AxWmfg4uCtAl48Z/Jv/uYR9d9jeHAlbuV2xPfnk=
=wRB5
-END PGP SIGNATURE-
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Function docstring as a local variable

2011-07-10 Thread Andrew Berg
-BEGIN PGP SIGNED MESSAGE-
Hash: RIPEMD160

On 2011.07.10 06:06 PM, Corey Richardson wrote:
> Python 2.7.1 (r271:86832, Jul  8 2011, 22:48:46) [GCC 4.4.5] on
> linux2 Type "help", "copyright", "credits" or "license" for more
> information.
 def foo():
> ... "Docstring" ... print __doc__ ...
 foo()
> None
I get the same result with Python 3.2.

- -- 
CPython 3.2 | Windows NT 6.1.7601.17592 | Thunderbird 5.0
PGP/GPG Public Key ID: 0xF88E034060A78FCB
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAwAGBQJOGjV5AAoJEPiOA0Bgp4/LF2YH/jaEjS6sFuwekVG0cKyjnx/z
8j28OHB9mklXg6oEMSsypU5dVPst2a6fmEHm+sXPYgQHZ9tk0oun+xxmdldNyV8h
knfFVgMC5ww1Q7gLkPWzY8me3k4YcokYGhsuwXEGBvPby4M4ZC5uyetKTzVWp+uH
sO11DPBaaXzGj7E7wu+HbfWsvPxw9h9jfJ7ihjhHNSUiL3MkGEqlxK8Pw2o3cw1e
sCY7XWm1x8qClJLrwwxnB7pfuOfNJ6aS3xLd8FFs4hRp1J9W+z4on91XZooa5kT+
UEfkrzppOjw1UNA1etxIGmJQ+/qrKSGg5Nmc4jHXNfwIZCECHuWxEqaL5e0WdHU=
=5gdS
-END PGP SIGNATURE-
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: parsing packets

2011-07-10 Thread Michael Hrivnak
In order to find the end of the packet, include a field that is the
packet length.  This is what IP packets do to find the end of their
header.

http://en.wikipedia.org/wiki/IPv4#Header

And the TCP header (see "data offset") does the same:

http://en.wikipedia.org/wiki/Transmission_Control_Protocol#TCP_segment_structure

Of course in both cases they are specifying the header length, not
including a data payload.  However, it sounds like you might not have
a payload, so your entire packet might consist of header-like data.

Michael


On Sun, Jul 10, 2011 at 4:59 PM, Littlefield, Tyler  wrote:
> Hello all:
> I'm working on a server that will need to parse packets sent from a client,
> and construct it's own packets.
> The setup is something like this: the first two bytes is the type of the
> packet.
> So, lets say we have a packet set to connect. There are two types of connect
> packet: a auth packet and a connect packet.
> The connect packet then has two bytes with the type, another byte that notes
> that it is a connect packet, and 4 bytes that contains the version of the
> client.
> The auth packet has the two bytes that tells what packet it is, one byte
> denoting that it is an auth packet, then the username, a NULL character, and
> a password and a NULL character.
>
> With all of this said, I'm kind of curious how I would 1) parse out
> something like this (I am using twisted, so it'll just be passed to my
> Receive function), and how I get the length of the packet with multiple NULL
> values. I'm also looking to build a packet and send it back out, is there
> something that will allow me to designate two bytes, set individual bits,
> then put it altogether in a packet to be sent out?
>
> --
>
> Take care,
> Ty
> my website:
> http://tds-solutions.net
> my blog:
> http://tds-solutions.net/blog
> skype: st8amnd127
> My programs don't have bugs; they're randomly added features!
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Wgy isn't there a good RAD Gui tool fo python

2011-07-10 Thread CM
On Jul 10, 6:50 pm, Ivan Kljaic  wrote:
> Ok Guys. I know that most of us have been expiriencing the need for a
> nice Gui builder tool for RAD and most of us have been googling for it
> a lot of times. But seriously. Why is the not even one single RAD tool
> for Python. I mean what happened to boa constructor that it stopped
> developing. I simply do not see any reasons why there isn't anything.
> Please help me understand it. Any insights?

Just because Boa Constructor stopped (or lengthily paused?)
development
doesn't mean it doesn't exist.  It does, and (at least on Windows), it
is, IMO, really good.  So why don't you use it?

Che

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


Re: Function docstring as a local variable

2011-07-10 Thread Ben Finney
"Colin J. Williams"  writes:

> On 10-Jul-11 13:44 PM, rantingrick wrote:
> > On Jul 10, 12:41 pm, Tim Johnson  wrote:
> >> It possible for a function to print it's own docstring?
> >
> > def f():
> > """docstring"""
> > print "docstring"
>
> Try:
>
> def f():
>  ds= """docstring"""
>  print ds

The OP wants the function to print its own docstring, which your example
does not do. You've defined a function with an empty docstring.

>>> def foo():
... ds = "The Larch"
... print ds
... 
>>> foo.__doc__
>>>

-- 
 \   “Firmness in decision is often merely a form of stupidity. It |
  `\indicates an inability to think the same thing out twice.” |
_o__)—Henry L. Mencken |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Function docstring as a local variable

2011-07-10 Thread Tim Johnson
* Carl Banks  [110710 15:18]:
> On Sunday, July 10, 2011 3:50:18 PM UTC-7, Tim Johnson wrote:
> >   Here's a related question:
> >   I can get the docstring for an imported module:
> >   >>> import tmpl as foo
> >   >>> print(foo.__doc__)
> >   Python templating features
> > 
> >Author - tim at akwebsoft dot com
> > 
> >  ## Is it possible to get the module docstring
> >  ## from the module itself?
> 
> 
> print __doc__
  Thanks Carl. 
  
  Where is general documentation on the subject of variables
  beginning with 2 underscores? 
  
  I'm presuming the key phrase is 'builtin variables'. I'm searching
  too ...

-- 
Tim 
tim at johnsons-web dot com or akwebsoft dot com
http://www.akwebsoft.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Function docstring as a local variable

2011-07-10 Thread Chris Rebert
On Sun, Jul 10, 2011 at 5:00 PM, Tim Johnson  wrote:
> * Carl Banks  [110710 15:18]:
>> On Sunday, July 10, 2011 3:50:18 PM UTC-7, Tim Johnson wrote:

>> >  ## Is it possible to get the module docstring
>> >  ## from the module itself?
>>
>> print __doc__
>  Thanks Carl.
>
>  Where is general documentation on the subject of variables
>  beginning with 2 underscores?
>
>  I'm presuming the key phrase is 'builtin variables'. I'm searching
>  too ...

I've never heard that phrase used to describe __doc__ or its friends.

Look in the "underscore" section of the documentation index:
http://docs.python.org/genindex-_.html

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


Re: Function docstring as a local variable

2011-07-10 Thread Chris Rebert
On Sun, Jul 10, 2011 at 4:06 PM, Corey Richardson  wrote:
> Excerpts from Carl Banks's message of Sun Jul 10 18:59:02 -0400 2011:
>> print __doc__
>>
>
> Python 2.7.1 (r271:86832, Jul  8 2011, 22:48:46)
> [GCC 4.4.5] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
 def foo():
> ...     "Docstring"
> ...     print __doc__
> ...
 foo()
> None

>
>
> What does yours do?

The question Carl's code was in answer to was, slightly paraphrased:
"Is it possible to get a *module*'s docstring from within the module
itself?"
The question had nothing to do with *function* docstrings.

The interactive interpreter environment also isn't quite a true
module, so you can't give it a docstring or really test the relevant
feature there. Try this instead:
$ cat test.py
"""I am the docstring of the `test` module!"""

print("This module's docstring is:", __doc__)
$ python test.py
This module's docstring is: I am the docstring of the `test` module!
$

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


Re: Function docstring as a local variable

2011-07-10 Thread Tim Johnson
* Chris Rebert  [110710 16:14]:
> >
> >  Where is general documentation on the subject of variables
> >  beginning with 2 underscores?
> 
> I've never heard that phrase used to describe __doc__ or its friends.
 :) That why I wasn't satified with my search results. 
> Look in the "underscore" section of the documentation index:
> http://docs.python.org/genindex-_.html
  And that is what I was looking for.
  thanks
-- 
Tim 
tim at johnsons-web dot com or akwebsoft dot com
http://www.akwebsoft.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Function docstring as a local variable

2011-07-10 Thread Corey Richardson
Excerpts from Chris Rebert's message of Sun Jul 10 20:16:23 -0400 2011:
> The question Carl's code was in answer to was, slightly paraphrased:
> "Is it possible to get a *module*'s docstring from within the module
> itself?"
> The question had nothing to do with *function* docstrings.
> 

Ah. My bad, thank you for clarifying.
-- 
Corey Richardson
  "Those who deny freedom to others, deserve it not for themselves"
 -- Abraham Lincoln


signature.asc
Description: PGP signature
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Virtual functions are virtually invisible!

2011-07-10 Thread Michael Hrivnak
It sounds to me like you need a better IDE, better documentation,
and/or better code to work on and use.  I don't understand why it's
difficult to look at a derived class as see what methods are
overridden.  If you are working on the code, it is quite obvious what
methods exist in the base class.  If you're not willing to get an
intimate understanding of how the base class works, you probably
shouldn't be working on the subclass.  If the base class is difficult
to understand, it's probably poorly written and/or poorly documented.
Neither of these problems should be solved by adding complexity to the
language.  Referencing the Zen of Python: "If the implementation is
hard to explain, it's a bad idea."

If you are just using a library but not developing it, why does it
matter what methods are overridden?  As long as class "Derived"
behaves the way it is documented, who cares how it got that way or
what is going on behind the scenes?  If you need to read the code to
figure out how it works, then it's just poorly documented.

Django is a great example, because it is very well documented.  Most
users have little idea of what base classes are involved and what
features are overridden, because it doesn't matter when you are just
using the library.  When you need to write your own subclass of a
django class, then it might matter, and you should see my first
paragraph.

And in terms of "non-starters", any "Pythonista" who isn't willing to
adhere to the style guide and document their code wouldn't work on my
team for very long, if at all.  There is just no excuse for that.

Michael

On Sun, Jul 10, 2011 at 1:15 PM, rantingrick  wrote:
> On Jul 4, 3:43 am, Gregory Ewing  wrote:
>> rantingrick wrote:
>> > what concerns me is the fact that virtual methods in derived
>> > classes just blend in to the crowd.
>> > I think we really need some
>> > sort of visual cue in the form of forced syntactical notation (just
>> > like the special method underscores).
>>
>> If you're suggesting that it should be impossible to override
>> a method unless it is specially marked somehow in the base
>> class, I think that would be a bad idea.
>
> Sorry i did explain properly... No NOT marked in the BASE class but
> marked in the DERIVED class! My concerns are from a readability
> standpoint. Here's a naive example...
>
> class Top(object):
>    def __init__(self):
>        pass
>    def m1(self):
>        """overide"""
>        return True
>    def m2(self):
>        print 'm2'
>
>
> def Derived(Top):
>    def __init__(self):
>        Top.__init__(self)
>    def m1(self):
>        return False
>
> My argument is this...
>
>   """If class "Derived" exists in another module the reader has no
> idea which methods where clobbered and which were not WITHOUT being
> intimate with the entire code base."""
>
>  I suggest we solve this dilemma by forcing a syntax "tag" when
> declaring clobbering virtual functions. And if someone forgets to
> include the tag python would throw an exception. This has the effect
> of making the code MUCH easier to follow by the human readers. And it
> put NO constraints on the API. Also it has the added effect of warning
> unsuspecting programmers of name clashes that would otherwise not
> produce an error.
>
>> One of the principles behind the design of Eiffel is that
>> classes should *always* be open to modification in any way
>> by a subclass. The reason is that the author of a class
>> library can't anticipate all the ways people might want to
>> use it. Consequently Eiffel has no equivalent of C++'s
>> "private" declaration -- everything is at most "protected".
>> It also has no equivalent of Java's "final".
>
> Exactly! We should never put limits on what methods CAN be virtual.
> However, we CAN enforce a syntax that removes ambiguity from the
> equation.
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Wgy isn't there a good RAD Gui tool fo python

2011-07-10 Thread Benjamin Kaplan
On Sun, Jul 10, 2011 at 3:50 PM, Ivan Kljaic  wrote:

> Ok Guys. I know that most of us have been expiriencing the need for a
> nice Gui builder tool for RAD and most of us have been googling for it
> a lot of times. But seriously. Why is the not even one single RAD tool
> for Python. I mean what happened to boa constructor that it stopped
> developing. I simply do not see any reasons why there isn't anything.
> Please help me understand it. Any insights?
> --
>

Because RAD tools are for GUI toolkits, not for languages. If you're using
GTK, Glade works fine. Same with QT and QTDesigner. If you're using WPF with
IronPython, there's plenty of tools out there for you to use. And Boa
Constructor isn't the only RAD tool for wx- you can also use wxGlade, which
can output code in several languages in addition to XRC files (an XML file
you can load into wx from any language)


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


Re: Wgy isn't there a good RAD Gui tool fo python

2011-07-10 Thread Adam Tauno Williams
On Sun, 2011-07-10 at 15:50 -0700, Ivan Kljaic wrote:
> Ok Guys. I know that most of us have been expiriencing the need for a
> nice Gui builder tool for RAD and most of us have been googling for it
> a lot of times. But seriously. Why is the not even one single RAD tool
> for Python. I mean what happened to boa constructor that it stopped
> developing. I simply do not see any reasons why there isn't anything.
> Please help me understand it. Any insights?

I've pondered this myself, for a long time - since I could use RAD to
build very nice applications using Borland's OWL on Windows For
Workgroups it is sad.

But Open Source land is simply too fragmented.  There are too many
database bindings [and RAD requires something like an ORM (think
SQLalchemy)] and far too many GUI toolkits [Qt, Gtk, wx, and the list
goes on and on].

Nothing can muster the gravity required to bring a quality RAD tool into
existence.

I also suspect - seeing some of the articles that float across the
FLOSS-o-sphere mentioning "RAD" - that many Open Source developers have
never had the pleasure [yes, it is a pleasure] of using a professional
RAD tool.

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


Re: Wgy isn't there a good RAD Gui tool fo python

2011-07-10 Thread Adam Tauno Williams

>Because RAD tools are for GUI toolkits, not for languages. If you're
>using GTK, Glade works fine. Same with QT and QTDesigner. If you're
>using WPF with IronPython, t

These [Glade, etc...] are *NOT* RAD tools.  They are GUI designers.  A
RAD tool provides a GUI designer that can be bound to a backend
[typically an SQL database].  RAD = GUI + ORM.


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


Re: Wgy isn't there a good RAD Gui tool fo python

2011-07-10 Thread Anthony Papillion
As someone who was a Visual Studio user for many years, I felt much
the same way you do when I made the jump to Python on Linux last year.
But then I discovered Glade and am quite satisfied.

Glades UI design paradigm is a little different than that of VS but
it's not so hard that you couldn't learn it in a week. It's very
usable, pretty easy to learn, and doesn't cost you a penny.

If you've not already, I recommend you check out Glade. I think it's
probably what you're looking for.

Anthony

On 7/10/11, Ivan Kljaic  wrote:
> Ok Guys. I know that most of us have been expiriencing the need for a
> nice Gui builder tool for RAD and most of us have been googling for it
> a lot of times. But seriously. Why is the not even one single RAD tool
> for Python. I mean what happened to boa constructor that it stopped
> developing. I simply do not see any reasons why there isn't anything.
> Please help me understand it. Any insights?
> --
> http://mail.python.org/mailman/listinfo/python-list
>


-- 
Anthony Papillion
Advanced Data Concepts
Get real about your software/web development and IT Services
Phone: (918) 919-4624

Does your business need to reduce its phone bill? I can help!
Email me and ask me how!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Function docstring as a local variable

2011-07-10 Thread Steven D'Aprano
On Mon, 11 Jul 2011 09:00 am Corey Richardson wrote:

> Excerpts from Colin J. Williams's message of Sun Jul 10 18:28:15 -0400
> 2011:
>> Try:
>> 
>> def f():
>>   ds= """docstring"""
>>   print ds
> 
> That doesn't actually make a docstring, though. It makes a string object
> and points the name ds at it. Do you know what a docstring is?


Colin might not be aware of why docstrings are useful, and arbitrary local
variables ds="""docstring""" are not.


def f1():
"""This is my documentation string.

Imagine this has actual useful information.
"""

def f2():
dc = """This is my documentation string.

Imagine this has actual useful information.
"""


Now, at the interactive interpreter, call:

help(f1)
help(f2)



-- 
Steven

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


Backshift mailing list create - opensource, deduplicating, compressing backups in Python

2011-07-10 Thread Dan Stromberg
I've created a google mailing list for the discussion of the backup program
I've been working on, "backshift".

You can find it at:

backsh...@googlegroups.com

And I'd be pleased if you were to choose to join, if you're interested in
the subject of Python and Backups.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: parsing packets

2011-07-10 Thread Aman Nijhawan
Are you sending binary data if so you can use the  struct module to pack,
unpack and interpret binary data http://docs.python.org/library/struct.html
,

You will have to design the header scheme yourself you can
either embed length in the packets or try to use a carefully selected
delimiter character .

Thanks
Aman


On Sun, Jul 10, 2011 at 5:31 PM,  wrote:

> Send Python-list mailing list submissions to
>python-list@python.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>http://mail.python.org/mailman/listinfo/python-list
> or, via email, send a message with subject or body 'help' to
>python-list-requ...@python.org
>
> You can reach the person managing the list at
>python-list-ow...@python.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Python-list digest..."
>
> Today's Topics:
>
>   1. Re: parsing packets (Michael Hrivnak)
>   2. Re: Wgy isn't there a good RAD Gui tool fo python (CM)
>   3. Re: Function docstring as a local variable (Ben Finney)
>   4. Re: Function docstring as a local variable (Tim Johnson)
>   5. Re: Function docstring as a local variable (Chris Rebert)
>   6. Re: Function docstring as a local variable (Chris Rebert)
>   7. Re: Function docstring as a local variable (Tim Johnson)
>   8. Re: Function docstring as a local variable (Corey Richardson)
>   9. Re: Virtual functions are virtually invisible! (Michael Hrivnak)
>
>
> -- Forwarded message --
> From: Michael Hrivnak 
> To: ty...@tysdomain.com
> Date: Sun, 10 Jul 2011 19:33:38 -0400
> Subject: Re: parsing packets
> In order to find the end of the packet, include a field that is the
> packet length.  This is what IP packets do to find the end of their
> header.
>
> http://en.wikipedia.org/wiki/IPv4#Header
>
> And the TCP header (see "data offset") does the same:
>
>
> http://en.wikipedia.org/wiki/Transmission_Control_Protocol#TCP_segment_structure
>
> Of course in both cases they are specifying the header length, not
> including a data payload.  However, it sounds like you might not have
> a payload, so your entire packet might consist of header-like data.
>
> Michael
>
>
> On Sun, Jul 10, 2011 at 4:59 PM, Littlefield, Tyler 
> wrote:
> > Hello all:
> > I'm working on a server that will need to parse packets sent from a
> client,
> > and construct it's own packets.
> > The setup is something like this: the first two bytes is the type of the
> > packet.
> > So, lets say we have a packet set to connect. There are two types of
> connect
> > packet: a auth packet and a connect packet.
> > The connect packet then has two bytes with the type, another byte that
> notes
> > that it is a connect packet, and 4 bytes that contains the version of the
> > client.
> > The auth packet has the two bytes that tells what packet it is, one byte
> > denoting that it is an auth packet, then the username, a NULL character,
> and
> > a password and a NULL character.
> >
> > With all of this said, I'm kind of curious how I would 1) parse out
> > something like this (I am using twisted, so it'll just be passed to my
> > Receive function), and how I get the length of the packet with multiple
> NULL
> > values. I'm also looking to build a packet and send it back out, is there
> > something that will allow me to designate two bytes, set individual bits,
> > then put it altogether in a packet to be sent out?
> >
> > --
> >
> > Take care,
> > Ty
> > my website:
> > http://tds-solutions.net
> > my blog:
> > http://tds-solutions.net/blog
> > skype: st8amnd127
> > My programs don't have bugs; they're randomly added features!
> >
> > --
> > http://mail.python.org/mailman/listinfo/python-list
> >
>
>
>
> -- Forwarded message --
> From: CM 
> To: python-list@python.org
> Date: Sun, 10 Jul 2011 16:49:51 -0700 (PDT)
> Subject: Re: Wgy isn't there a good RAD Gui tool fo python
> On Jul 10, 6:50 pm, Ivan Kljaic  wrote:
> > Ok Guys. I know that most of us have been expiriencing the need for a
> > nice Gui builder tool for RAD and most of us have been googling for it
> > a lot of times. But seriously. Why is the not even one single RAD tool
> > for Python. I mean what happened to boa constructor that it stopped
> > developing. I simply do not see any reasons why there isn't anything.
> > Please help me understand it. Any insights?
>
> Just because Boa Constructor stopped (or lengthily paused?)
> development
> doesn't mean it doesn't exist.  It does, and (at least on Windows), it
> is, IMO, really good.  So why don't you use it?
>
> Che
>
>
>
>
> -- Forwarded message --
> From: Ben Finney 
> To: python-list@python.org
> Date: Mon, 11 Jul 2011 09:48:46 +1000
> Subject: Re: Function docstring as a local variable
> "Colin J. Williams"  writes:
>
> > On 10-Jul-11 13:44 PM, rantingrick wrote:
> > > On Jul 10, 12:41 pm, Tim Johnson  wrote:
> > >> It possible for a function to print it's own docstring?
> > >
> > > def f():
> > > 

How to get or set the text of a textfield?

2011-07-10 Thread Anthony Papillion
Hi Everyone,

So I've built a UI with Glade and have loaded it using the standard
Python code. In my UI, I have a textfield called txtUsername. How do I
get and set the text in this field from my Python code?

Thanks!
Anthony

-- 
Anthony Papillion
Advanced Data Concepts
Get real about your software/web development and IT Services
Phone: (918) 919-4624

Does your business need to reduce its phone bill? I can help!
Email me and ask me how!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: TypeError: unbound method DefaultTracer() must be called with MyClass instance as first argument (got str instance instead)

2011-07-10 Thread Kannan Varadhan
Thanks folks,

Tried all of these, and went with staticmethod().  Was cleanest
solution,

> After skimming over Steven's post: use staticmethod.
> No idea why I didn't think of that myself.


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


Re: Virtual functions are virtually invisible!

2011-07-10 Thread rantingrick
On Jul 10, 7:31 pm, Michael Hrivnak  wrote:
> It sounds to me like you need a better IDE, better documentation,
> and/or better code to work on and use.

Yes the last two points are relevant here. However whilst IDE choice
belongs to the user, documentation and code are in the hands of the
developer; who's own selfish needs often outweigh that of the user AND
community as a whole.

> I don't understand why it's
> difficult to look at a derived class as see what methods are
> overridden.

Well in my simple example it is VERY easy, WHY? Here are a few reasons
why the clobbered methods are easy to spot (in both the base and
derived classes)...

 * Both exists within the same view frame. No need to flip back and
forth between two windows.
 * Both have only one method. The complexity increases exponentially
by the number of methods AND the length of their respective code
blocks!
 * "Derived.m1" has a syntactical mark. You can clearly see which
method has been clobbered WITHOUT even bothering to look at the base
class.

The only time you SHOULD have to look at the base class is to see what
mandates the virtual method may impose. Does it require a Boolean
return? An Integer? A Float? A List? Does it modify an object? Etc,
etc?

>  If you are working on the code, it is quite obvious what
> methods exist in the base class.

Let me correct your statement... IF you have an intimate understanding
of the base. Heck what if the base is derived also? These things are
NOT strictly single level you know.

>  If you're not willing to get an
> intimate understanding of how the base class works, you probably
> shouldn't be working on the subclass.  

Not true, many times you don't need an intimate understanding of the
base to wield a derived class. That's when the syntactical markers
come in handy.

> If the base class is difficult
> to understand, it's probably poorly written and/or poorly documented.
> Neither of these problems should be solved by adding complexity to the
> language.

How is adding syntactical markers to an otherwise obfuscation of
virtual method clobbering going to confuse anyone? I would say the
opposite is true. Python has used the forced convention "double-
leading-and-trailing-underscores" to mark special methods since it's
beginning. One reason for this convention is prevent name clashes
HOWEVER the most important reason (i would argue) is for readability
of source code. When Guido implemented this convention it was one of
his greatest gifts to Python and the world (only to be outdone by
forced indention!).

> Referencing the Zen of Python: "If the implementation is
> hard to explain, it's a bad idea."

What if the code is "difficult" to read? Does "readability count" ring
a bell?

> If you are just using a library but not developing it, why does it
> matter what methods are overridden?  As long as class "Derived"
> behaves the way it is documented, who cares how it got that way or
> what is going on behind the scenes?  If you need to read the code to
> figure out how it works, then it's just poorly documented.

Yes. It is obviously poorly documented. And all the writer would have
to do is put a little doc string there saying "clobbered virtual
method here". HOWEVER, do you know how many folks bother to ACTUALLY
do that? Huh? Do ya? None! Exactly.

> Django is a great example, because it is very well documented.  Most
> users have little idea of what base classes are involved and what
> features are overridden, because it doesn't matter when you are just
> using the library.  When you need to write your own subclass of a
> django class, then it might matter, and you should see my first
> paragraph.

When a method has been clobbered any reader of such code NEEDS to know
about it. WHY, well because usually clobbered methods have "magic"
going on being the scenes. Sometimes many layers of "magic".

> And in terms of "non-starters", any "Pythonista" who isn't willing to
> adhere to the style guide and document their code wouldn't work on my
> team for very long, if at all.  There is just no excuse for that.

I agree. However as we are all aware many "great Pythonistas" refuse
to follow the style guide (*cough* freg! :). The only way to correct
this problem is via a forced syntactical marker placed by the derived
class's writer. Just like with "__IDENTIFIER__"

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


paypal wholesale all brand(UGGBOOTS, SHOES, CLOTHES, HANDBAG, WATCH, JEANS, JERSEY, T-SHIRT, SHIRTS, HOODY, EYEGLASS, CAP, SHAWL, WALLT) and so on.

2011-07-10 Thread amy
paypal payment wholesale all brand
shoes(NIKE,ADIDAS,LV,GUCCI,CHANEL,PRADA,POLO,UGG BOOTS,D&G,DIOR )and
so on.
paypal payment wholesale all brand clothing(T-
SHIRT,JEANS,JERSEY,HOODIES,JACKETS,HARDY,SWEATER,SHIRTS )and so on .
http://www.24hour-buy.com
paypal payment all brand
watch(ROLEX,OMEGA,CHANEL,LV,CARTIER,IWC,GUCCI,RADO )and so on.
http://www.24hour-buy.com
paypal payment all brand
handbag(LV,GUCCI,CHANEL,PRADA,POLO,COACH,FENDI,CHLOE,BUBERRY,JUICY)
and so on.
paypal payment brand CAP,SHAWL,BELT,WALLET,UNDER WEAR)and so on.

More detail land,address:  http://www.24hour-buy.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to get or set the text of a textfield?

2011-07-10 Thread John Gordon
In  Anthony Papillion 
 writes:

> So I've built a UI with Glade and have loaded it using the standard
> Python code. In my UI, I have a textfield called txtUsername. How do I
> get and set the text in this field from my Python code?

I don't know anything about Glade, so I can't answer your question
definitively.  However, as a general rule, you can use the dir() builtin
function to see what methods are defined by an object.

So, assuming you have access to an interactive shell within your Glade
environment, you can do this:

  dir(txtUsername)

and it will print a list of methods that are defined by that object.
Hopefully one of them will be called something helpful like set_text()
or set_property().  Once you know the method name, you might try a Google
search to determine the exact usage and arguments.

-- 
John Gordon   A is for Amy, who fell down the stairs
gor...@panix.com  B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"

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


Re: How to get or set the text of a textfield? - SOLVED

2011-07-10 Thread Anthony Papillion
> I don't know anything about Glade, so I can't answer your question
> definitively.  However, as a general rule, you can use the dir() builtin
> function to see what methods are defined by an object.

Hi John,

Thanks for the input and it looks like it's pretty simple. Basically, I
can access the properties of objects like:

self.objectname.property_or_method()

So, to solve my question, I'd just use:

self.txtUsername.set_text('Whatever I want')

or

enteredText = self.txtUsername.get_text()

Pretty simple and this actually solves ALL of my Glade problems. I'm
excited.

Thanks for the direction!

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


Re: Function docstring as a local variable

2011-07-10 Thread alex23
On Jul 11, 9:00 am, Corey Richardson  wrote:
> def qux():
>     'And even me! Quote type don't matter (besides style)'

Well, style and the presence of the string literal notation in the
quoted text :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Function docstring as a local variable

2011-07-10 Thread alex23
On Jul 11, 9:06 am, Corey Richardson  wrote:
> Excerpts from Carl Banks's message of Sun Jul 10 18:59:02 -0400 2011:
>
> > print __doc__
>
> Python 2.7.1 (r271:86832, Jul  8 2011, 22:48:46)
> [GCC 4.4.5] on linux2
> Type "help", "copyright", "credits" or "license" for more information.>>> def 
> foo():
>
> ...     "Docstring"
> ...     print __doc__
> ...
>
> >>> foo()
> None
>
> What does yours do?

Is foo() declared in a module with a docstring? Because that's what
Carl was talking about.

test_module.py:
'''module docstring'''

def foo():
print __doc__


Works for me.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Virtual functions are virtually invisible!

2011-07-10 Thread Michael Hrivnak
I can't believe you're saying that you will create a sub-class without
taking the time to understand the base class.  Seriously?  That right
there is why you are seeing method overrides that aren't documented.
How can you document something you don't understand?  Furthermore, how
can you have any confidence in your subclass if you don't understand
what its base class is doing?  Do you write unit tests?  How do you
know what to test if you don't understand the code you are
subclassing?

Suggesting that no developers document their methods?  Incredible.

Clobbered methods have "magic"?  Multi-layered "magic"?  Perhaps when
you take the time to 1) document the base class and 2) understand that
base class before subclassing it, that "magic" will start to look like
reasonable and logical processes.

Professional developers document their code.  They take the time to
understand the code they are working on.  If you don't want to do
those things, that's your business, and I'm sure you can find other
people who also don't do those things.  But I really don't think
you'll have much success changing the language to accommodate your
refusal to follow the most basic best practices.

Best of luck,
Michael

On Sun, Jul 10, 2011 at 10:35 PM, rantingrick  wrote:
> On Jul 10, 7:31 pm, Michael Hrivnak  wrote:
>> It sounds to me like you need a better IDE, better documentation,
>> and/or better code to work on and use.
>
> Yes the last two points are relevant here. However whilst IDE choice
> belongs to the user, documentation and code are in the hands of the
> developer; who's own selfish needs often outweigh that of the user AND
> community as a whole.
>
>> I don't understand why it's
>> difficult to look at a derived class as see what methods are
>> overridden.
>
> Well in my simple example it is VERY easy, WHY? Here are a few reasons
> why the clobbered methods are easy to spot (in both the base and
> derived classes)...
>
>  * Both exists within the same view frame. No need to flip back and
> forth between two windows.
>  * Both have only one method. The complexity increases exponentially
> by the number of methods AND the length of their respective code
> blocks!
>  * "Derived.m1" has a syntactical mark. You can clearly see which
> method has been clobbered WITHOUT even bothering to look at the base
> class.
>
> The only time you SHOULD have to look at the base class is to see what
> mandates the virtual method may impose. Does it require a Boolean
> return? An Integer? A Float? A List? Does it modify an object? Etc,
> etc?
>
>>  If you are working on the code, it is quite obvious what
>> methods exist in the base class.
>
> Let me correct your statement... IF you have an intimate understanding
> of the base. Heck what if the base is derived also? These things are
> NOT strictly single level you know.
>
>>  If you're not willing to get an
>> intimate understanding of how the base class works, you probably
>> shouldn't be working on the subclass.
>
> Not true, many times you don't need an intimate understanding of the
> base to wield a derived class. That's when the syntactical markers
> come in handy.
>
>> If the base class is difficult
>> to understand, it's probably poorly written and/or poorly documented.
>> Neither of these problems should be solved by adding complexity to the
>> language.
>
> How is adding syntactical markers to an otherwise obfuscation of
> virtual method clobbering going to confuse anyone? I would say the
> opposite is true. Python has used the forced convention "double-
> leading-and-trailing-underscores" to mark special methods since it's
> beginning. One reason for this convention is prevent name clashes
> HOWEVER the most important reason (i would argue) is for readability
> of source code. When Guido implemented this convention it was one of
> his greatest gifts to Python and the world (only to be outdone by
> forced indention!).
>
>> Referencing the Zen of Python: "If the implementation is
>> hard to explain, it's a bad idea."
>
> What if the code is "difficult" to read? Does "readability count" ring
> a bell?
>
>> If you are just using a library but not developing it, why does it
>> matter what methods are overridden?  As long as class "Derived"
>> behaves the way it is documented, who cares how it got that way or
>> what is going on behind the scenes?  If you need to read the code to
>> figure out how it works, then it's just poorly documented.
>
> Yes. It is obviously poorly documented. And all the writer would have
> to do is put a little doc string there saying "clobbered virtual
> method here". HOWEVER, do you know how many folks bother to ACTUALLY
> do that? Huh? Do ya? None! Exactly.
>
>> Django is a great example, because it is very well documented.  Most
>> users have little idea of what base classes are involved and what
>> features are overridden, because it doesn't matter when you are just
>> using the library.  When you need to write your own subclass of a
>> django class, th

Re: How to get or set the text of a textfield?

2011-07-10 Thread Waldek M.
Dnia Sun, 10 Jul 2011 21:14:10 -0500, Anthony Papillion napisał(a):
> 
> So I've built a UI with Glade and have loaded it using the standard
> Python code. In my UI, I have a textfield called txtUsername. How do I
> get and set the text in this field from my Python code?

http://developer.gnome.org/pygtk/stable/
http://www.learningpython.com/2006/05/07/creating-a-gui-using-pygtk-and-glade/

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


Re: ctypes: point to buffer in structure

2011-07-10 Thread Tim Roberts
Jesse R  wrote:
>
>Hey I've been trying to convert this to run through ctypes and i'm
>having a hard time
>
>typedef struct _SYSTEM_PROCESS_ID_INFORMATION
>{
>HANDLE ProcessId;
>UNICODE_STRING ImageName;
>} SYSTEM_PROCESS_IMAGE_NAME_INFORMATION,
>*PSYSTEM_PROCESS_IMAGE_NAME_INFORMATION;
>
>to
>
>class SYSTEM_PROCESS_ID_INFORMATION(ctypes.Structure):
>_fields_ = [('pid', ctypes.c_ulong),
>('imageName', ctypes.c_wchar_p)]
>...
>does anyone know how to get this working?

UNICODE_STRING is not just a pointer to wide characters.  It is itself a
structure:

typedef struct _UNICODE_STRING {
USHORT Length;
USHORT MaximumLength;
PWSTR  Buffer;
} UNICODE_STRING;

So, I think you want fields of ctypes.c_ulong, ctypes.c_ushort,
ctypes.c_ushort, and ctypes.c_wchar_p.  MaximumLength gives the allocated
size of the buffer.  Length gives the length of the string currently held
in the buffer.  It can be less than the maximum length, and the buffer does
NOT necessarily contain a zero-terminator.

UNICODE_STRING and ANSI_STRING are used in kernel programming to avoid the
potential ambiguities of counted strings.
-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list


south actress hot photos and videos

2011-07-10 Thread SHILPA
v

FOR GOOD JOBS SITES TO YOU
 http://goodjobssites.blogspot.com/

FOR HOT PHOTO&VIDEOS
TAMANNA HOT SEXY PHOTOS & VIDEOS
http://southactresstou.blogspot.com/2011/07/tamanna-wallpapers.html
   KAJAL AGARWAL HOT SEXY PHOTOS
http://southactresstou.blogspot.com/2011/05/kajal-agarwal.html
 KATRINA KAIF IN BEAUTIFUL RED DRESS
http://southactresstou.blogspot.com/2011/05/katrina-kaif_22.html
GOOD LOOKING DEEPIKA PADUKONE
http://southactresstou.blogspot.com/2011/05/deepika-padukone_22.html
  AISHWARYA RAI UNBELIVABLE PHOTO
http://southactresstou.blogspot.com/2011/05/aishwarya-rai.html
TAPSEE RARE PHOTOS
http://southactresstou.blogspot.com/2011/06/tapsee-rare-photos.html



FOR FAST UPDATES IN TELUGU FILM INDUSTRY
http://allyouwants.blogspot.com



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


[RELEASED] Python 3.2.1

2011-07-10 Thread Georg Brandl
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On behalf of the Python development team, I am pleased to announce the
final release of Python 3.2.1.

Python 3.2.1 is the first bugfix release for Python 3.2, fixing over 120
bugs and regressions in Python 3.2.

For an extensive list of changes and features in the 3.2 line, see

http://docs.python.org/3.2/whatsnew/3.2.html

To download Python 3.2.1 visit:

http://www.python.org/download/releases/3.2.1/

This is a final release: Please report any bugs you may notice to:

http://bugs.python.org/


Enjoy!

- -- 
Georg Brandl, Release Manager
georg at python.org
(on behalf of the entire python-dev team and 3.2's contributors)
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.17 (GNU/Linux)

iEYEARECAAYFAk4aiNMACgkQN9GcIYhpnLDofwCglfgDQ1/B/TxxwfqtDxK13ksz
micAn0CVWmNNaYE2a6z0N7+Dz+hCZSj1
=7Mia
-END PGP SIGNATURE-
-- 
http://mail.python.org/mailman/listinfo/python-list


python xauth

2011-07-10 Thread kracekumar ramaraju
I am looking to use xauth in python?It is for my command line process,I would 
like to have few examples and resources.
-- 
http://mail.python.org/mailman/listinfo/python-list


OK, I lied, I do have another question...

2011-07-10 Thread Anthony Papillion
Hi Everyone,

So I've used Glade to build a simple UI and I'm loading it with
gtkBuilder. The UI loads fine but, for some reason, none of my signals
are being connected. For example, in Glade, I said when the button
called btnExit was clicked, execute the btnExit_clicked method. Then, in
my App() class definition, I defined btnExit_clicked(self, widget) and
simply added the gtk.main_quit() statement (to exit). But when I start
my app, I am told that the btnExit_clicked() method isn't defined. This
happens for every single signal I define.

I'm assuming I'm simply putting something in the wrong place so can
anyone have a look at this and tell me what that might be? It looks
almost identical to examples I've seen on the net.  Thanks!

CODE:

class App:
def __init__(self):
builder = gtk.Builder()
builder.add_from_file('bcbackup.ui')
builder.connect_signals({"on_window_destroy" : gtk.main_quit,
"on_btnExit_clicked" : btnExit_clicked})
self.window = builder.get_object("winMain")
self.window.show()

def btnSaveInformation_clicked(self, widget):
pass

def btnExit_clicked(self, widget):
gtk.main_quit()

if __name__ == "__main__":
myApp = App()
gtk.main()

END CODE

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


Re: python xauth

2011-07-10 Thread Cousin Stanley

kracekumar ramaraju wrote:

> I am looking to use xauth in python ?
>
> It is for my command line process,
> I would like to have few examples 
> and resources.

A simple example 

>>> import subprocess as SP
>>> 
>>> proc = [ 'xauth' , 'list' , ':0' ]
>>> 
>>> pipe = SP.Popen( proc , stdout = SP.PIPE )
>>> 
>>> data = pipe.stdout.readline()
>>> 
>>> print '\n' , data

em1dsq/unix:0  MIT-MAGIC-COOKIE-1  10a533afab15a57c8704a16d1dc5bb12


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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