Re: python xauth

2011-07-11 Thread Ian Kelly
On Sun, Jul 10, 2011 at 11:23 PM, 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.

First, by "xauth" do you mean the X11 authorization scheme, or the
"extended authentication" (xauth.org) scheme?  The name is
unfortunately overloaded.

Second, have you tried googling for "python xauth"?

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


Re: A beginning programmer

2011-07-11 Thread Chris Angelico
On Mon, Jul 11, 2011 at 8:06 AM, Eric  wrote:
> But I just don't know what
> to do with it, I don't have any problems that need to be solved...

There are always more problems to be solved than people willing to
solve them! It's just a matter of finding ones you're interested in.

Several people have recommended looking at bugtrackers and such.
Another good source of programming tasks is automation - look for any
task that you or someone else does repeatedly, and write a script that
does it. That can range from a half-dozen lines of shell script up to
full-on commercial-grade packages (if you think about it, an
accounting system is nothing more than reports automation).

Learn as many languages as you can. Develop the skill of picking up a
new language and mastering it; obscure languages have just as
interesting problems as do mainstream ones, and being able to learn
Pike might suddenly come in handy when you find yourself invited to
code on somebody's MUD some day!

Chris Angelico
Currently striving to be the Mr Melas of programming languages
-- 
http://mail.python.org/mailman/listinfo/python-list


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

2011-07-11 Thread Adam Tauno Williams
On Mon, 2011-07-11 at 03:44 +, John Gordon wrote:
> 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?

field.get_text()
field.set_text(value)



> 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.

-1 -1 -1  Do not "google" [search the Internet] for solutions to pyGtk
problems.  That is just a confusing waste of time.  Use the *excellent*
and well-linked documentation:




The FAQ is extensive and really does cover a lot of the common
questions.  Also there is a list specifically for pygtk questions:



Google, or Bing, or even DuckDuckGo, are *not* your friends.  They are
enormous and inefficient time-sinks.  They are a *BAD* way to solve
problems.  Use the documentation.

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


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

2011-07-11 Thread sturlamolden
On 11 Jul, 02:43, Adam Tauno Williams  wrote:
> >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.

The type speciemens for "RAD tools" were Borland Delphi and Microsoft
Visual Basic.

They were not a combination of GUI designer and SQL/ORM backend.

They were a combination of GUI designer, code editor, compiler, and
debugger.


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


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

2011-07-11 Thread sturlamolden
On 11 Jul, 00:50, 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?

If you by "RAD tool" mean "GUI builder", I'd recommend wxFormBuilder
for wxPython, QtCreator for PyQt or PySide, and GLADE for PyGTK.

Personally I prefer wxFormBuilder and wxPython, but it's a matter of
taste.

Sturla




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


Re: parsing packets

2011-07-11 Thread Thomas Rachel

Am 10.07.2011 22:59 schrieb 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.


Are these packets sent as separate UDP packets or embedded in a TCP 
stream? In the first case, you already have packets and only have to 
parse them. In a stream, you first have to split them up.


In the following, I will talk about UDP datagrams. For TCP, further work 
is needed.




The setup is something like this: the first two bytes is the type of the
packet.


Then you have

type = struct.unpack(">H", packet),
payload1 = packet[2:]


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.


if type == CONNECT:
subtype = struct.unpack("B", payload1)
payload2 = payload1[1:]
if subtype == CONNECT:
upx = payload2.split("\0")
assert len(upx) == 3 and upx[-1] == ''
username, password = upx[:2]
else:
assert len(payload2) == 4
version = struct.unpack(">L", payload2)



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),


I. e., you already have your packets distinct? That's fine.

> and how I get the length of the packet with multiple NULL values.

With len(), how else?


> 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?


The same: with struct.pack().


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


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

2011-07-11 Thread bruno.desthuilli...@gmail.com
On Jul 11, 2:42 am, Adam Tauno Williams 
wrote:
>
> 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.

Why "too many" ? Natural selection is a GoodThing.

Python is known as "the language with more web frameworks than
keywords", and this doesn't prevent some of these frameworks to be 1/
pretty good and 2/ becoming de facto standards.

> 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.

This is slightly arrogant. Did you occur to you that quite a few OSS
developers may have at least as much experience as you do with these
kind of tools and just happen to actually prefer the unix way of doing
things ?


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


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

2011-07-11 Thread Ben Finney
"bruno.desthuilli...@gmail.com"  writes:

> On Jul 11, 2:42 am, Adam Tauno Williams 
> wrote:
> >
> > 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].
>
> Why "too many" ? Natural selection is a GoodThing.

Natural selection is not a good thing. It is blind and unthinking and
cruel and wasteful and haphazard and purposeless. Those aren't traits to
recommend it, IMO.

(It's also not a bad thing. Natural selection just is.)

Natural selection is not what's happening here. Rather, *artifical*
selection, with people as the agents of selection, have purposes and
wants that guide their selections.

It would be better to say: Competition can be (not an unalloyed “is”) a
Good Thing.

> Python is known as "the language with more web frameworks than
> keywords", and this doesn't prevent some of these frameworks to be 1/
> pretty good and 2/ becoming de facto standards.

Right. People are selecting web frameworks for their fitness to
purposes, but their purposes are many and change over time. So there can
be many such frameworks, of varying popularity, and that's a good thing.

> > 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.
>
> This is slightly arrogant. Did you occur to you that quite a few OSS
> developers may have at least as much experience as you do with these
> kind of tools and just happen to actually prefer the unix way of doing
> things ?

Yes. As someone who has used some of those all-in-one one-size-fits-most
tools, I can testify that their usefulness is severely limited when
compared with the Unix model.

The Unix model is: a collection of general-purpose, customisable tools,
with clear standard interfaces that work together well, and are easily
replaceable without losing the benefit of all the others.

-- 
 \   “Are you pondering what I'm pondering?” “Umm, I think so, |
  `\Brain, but what if the chicken won't wear the nylons?” —_Pinky |
_o__)   and The Brain_ |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Freeze statically

2011-07-11 Thread Sebastien Dudek
Hi everyone!

Let me explain you my big adventure. So I trying to make a static
python executable using the native Python freeze. I've modified the
file Modules/Setup.dist using this perl cli : perl -pi -e 's!(^#
\*shared\*)!*static*\n$1!' Modules/Setup.dist

Then ./configure, make && make install

If I'm using my python interpreter to build with freeze a simple
project that we can call "hello world". It works perfectly but it is
still : "dynamically linked (uses shared libs)". So modifying the
Makefile using '-static' for linking, I hopped I could make it static.

But... it fail :
+--
+
...
/home/fluxius/Python-2.7.2/./Modules/pwdmodule.c:156: warning: Using
'setpwent' in statically linked applications requires at runtime the
shared libraries from the glibc version used for linking
/home/fluxius/Python-2.7.2/./Modules/pwdmodule.c:168: warning: Using
'endpwent' in statically linked applications requires at runtime the
shared libraries from the glibc version used for linking
/usr/bin/ld: dynamic STT_GNU_IFUNC symbol `strcmp' with pointer
equality in `/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/
4.5.2/../../../libc.a(strcmp.o)' can not be used when making an
executable; recompile with -fPIE and relink with -pie
collect2: ld returned 1 exit status
make: *** [hello] Erreur 1
+--
+

Help me please!! =)
-- 
http://mail.python.org/mailman/listinfo/python-list


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

2011-07-11 Thread sturlamolden
On 11 Jul, 14:39, Ben Finney  wrote:

> The Unix model is: a collection of general-purpose, customisable tools,
> with clear standard interfaces that work together well, and are easily
> replaceable without losing the benefit of all the others.

This is opposed to the "Windows model" of a one-click installer for a
monolithic application. Many Windows users get extremely frustrated
when they have to use more than one tool.

There is also a deep anxiety of using the keyboard. This means that
command line tools are out of the question (everything needs a GUI).

In the Windows world, even programming should be drag-and-drop with
the mouse. Windows programmers will go to extreme measures to avoid
typing code on their own, as tke keyboard is so scary. The most
extreme case is not Visual Basic but LabView, where even business
logic is drag-and-drop.

A side-effect is that many Windows developers are too dumb to write
code on their own, and rely on pre-coded "components" that can be
dropped on a "form". A common fail-case is multiuser applications,
where the developers do not understand anything about what is going
on, and scalability is non-existent.

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


Re: Virtual functions are virtually invisible!

2011-07-11 Thread rantingrick
On Jul 10, 11:45 pm, Michael Hrivnak  wrote:
> I can't believe you're saying that you will create a sub-class without
> taking the time to understand the base class.

I'm NOT saying that so stop putting words in my mouth!

> Seriously?  That right
> there is why you are seeing method overrides that aren't documented.

You being a bit bombastic now with this *rolls-eyes*

> 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?

You took my simple statement of... " It is not ALWAYS necessary to
have an intimate knowledge of the base class when creating derived
classes"... and extrapolated THAT nonsense?

Okay let me show you a simple example of not needing to know the base
class intimatly. I'll use the tkSimpleDialog...

class MyDialog(tkSimpleDialog.Dialog):
def body(self, master):
#imagine i created widgets here.

NOW. Would it really be nessesary at this point to have an intimate
knowledge of the base class? Hmm?

> Suggesting that no developers document their methods?  Incredible.

Very, very few document clobbered virtual methods. yes.

> Clobbered methods have "magic"?  Multi-layered "magic"?

Of course! That is, in the perverted case of Clarke's third law[1]...
"Any sufficiently advanced technology is indistinguishable from
magic"... And since class inheritance can be multi-layered, um, you
get the idea.

>  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.

You're preaching to the choir reverend!

> 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.

It's not me that needs to change kind sir, it is the community in
general. I document my code. I follow the python style guide. I always
create unit tests. Unfortunately no matter how well i write code i
cannot force others to do so. Heck i have posted many fixes for the
abomination called tkSimpleDialog and not only do they refuse to
upgrade the code, they refuse to even post comments!

This mandate must be handed down from the gods who reside on "Mount
REFUSE-E-OUS to RECOGNIZE-E-OUS a major PROBLEM-O-MOUS"

[1] http://en.wikipedia.org/wiki/Clarke's_three_laws
-- 
http://mail.python.org/mailman/listinfo/python-list


An interesting beginner question: why we need colon at all in the python language?

2011-07-11 Thread Anthony Kong
Hi, all,

Lately I am giving some presentations to my colleagues about the python
language. A new internal project is coming up which will require the use of
python.

One of my colleague asked an interesting:

*If Python use indentation to denote scope, why it still needs semi-colon at
the end of function declaration and for/while/if loop?*

My immediate response is: it allows us to fit statements into one line. e.g.
if a == 1: print a

However I do not find it to be a particularly strong argument. I think PEP8
does not recommend this kind of coding style anyway, so one-liner should not
be used in the first place!

Is there any other reasons for use of semi-colon in python?


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


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

2011-07-11 Thread Kevin Walzer

On 7/10/11 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?


http://pyobjc.sourceforge.net/

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


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

2011-07-11 Thread Thorsten Kampe
* sturlamolden (Mon, 11 Jul 2011 06:44:22 -0700 (PDT))
> On 11 Jul, 14:39, Ben Finney  wrote:
> > The Unix model is: a collection of general-purpose, customisable
> > tools, with clear standard interfaces that work together well, and
> > are easily replaceable without losing the benefit of all the others.
> 
> This is opposed to the "Windows model" of a one-click installer for a
> monolithic application. Many Windows users get extremely frustrated
> when they have to use more than one tool.

*sigh* There is no Windows nor Unix "model". There is only you-get-what-
you-pay-for.

On Windows, you're a customer and the developer wants to make using his 
application as convenient as possible for you, the customer.

On Unix you don't pay and the developer couldn't care less if his 
application works together with application b or how much it takes you 
to actually get this damn thing running.

And as soon as developers start developing for Unix customers (say 
Komodo, for instance), they start following the "Windows model" - as you 
call it.

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


Re: An interesting beginner question: why we need colon at all in the python language?

2011-07-11 Thread Thomas Jollans
On 07/11/2011 03:51 PM, Anthony Kong wrote:
> Hi, all,
> 
> Lately I am giving some presentations to my colleagues about the python
> language. A new internal project is coming up which will require the use
> of python.
> 
> One of my colleague asked an interesting:
> 
> /If Python use indentation to denote scope, why it still needs
> semi-colon at the end of function declaration and for/while/if loop?/
> 
> My immediate response is: it allows us to fit statements into one line.
> e.g. if a == 1: print a
> 
> However I do not find it to be a particularly strong argument. I think
> PEP8 does not recommend this kind of coding style anyway, so one-liner
> should not be used in the first place!

Basically, it looks better, and is more readable. A colon, in English
like in Python, means that something follows that is related to what was
before the colon. So the colon makes it abundantly clear to the human
reader that a block follows, and that that block is to be considered in
relation to what was just said, before the colon.

Coincidentally, Guido wrote this blog post just last week, without which
I'd be just as much at a loss as you:

http://python-history.blogspot.com/2011/07/karin-dewar-indentation-and-colon.html

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


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

2011-07-11 Thread sturlamolden
On 11 Jul, 16:10, Thorsten Kampe  wrote:

> And as soon as developers start developing for Unix customers (say
> Komodo, for instance), they start following the "Windows model" - as you
> call it.

You are probably aware that Unix and Unix customers have been around
since the 1970s. I would expect the paradigm to be changed by now.


S.M.



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


Saving emails

2011-07-11 Thread Fulvio
Hello,

my curiosity these day lay around the problem given by Kmail2.
I'd like to keep my old emails and a backup would satisfy my needs. The only 
conditions should be that the mails will come back in a quick way.
I found this page
http://www.ducea.com/2006/11/25/cleanup-maildir-folders-archive-delete-old-
mails/

Which gives me some point, but the program is too old and I'd like to use 
Python 3. Another chance it would be to implement an IMAP server which move 
old emails in and out of an archive. Then it will be simple to recall old 
emails.

Some docs about email deciphering. Kmail uses a maildir and several 
subfolders. I'd like to export the emails in mbox file and perhaps to 
separate by a period of time, say July2010, September2010 end so forth.

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


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

2011-07-11 Thread John Gordon
In  Adam Tauno Williams 
 writes:

> Google, or Bing, or even DuckDuckGo, are *not* your friends.  They are
> enormous and inefficient time-sinks.  They are a *BAD* way to solve
> problems.  Use the documentation.

One would hope that a Google search might lead to the documentation.

-- 
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: An interesting beginner question: why we need colon at all in the python language?

2011-07-11 Thread Anthony Kong
Awesome! Thanks for blog post link

Cheers

On Tue, Jul 12, 2011 at 12:16 AM, Thomas Jollans  wrote:

> On 07/11/2011 03:51 PM, Anthony Kong wrote:
> > Hi, all,
> >
> > Lately I am giving some presentations to my colleagues about the python
> > language. A new internal project is coming up which will require the use
> > of python.
> >
> > One of my colleague asked an interesting:
> >
> > /If Python use indentation to denote scope, why it still needs
> > semi-colon at the end of function declaration and for/while/if loop?/
> >
> > My immediate response is: it allows us to fit statements into one line.
> > e.g. if a == 1: print a
> >
> > However I do not find it to be a particularly strong argument. I think
> > PEP8 does not recommend this kind of coding style anyway, so one-liner
> > should not be used in the first place!
>
> Basically, it looks better, and is more readable. A colon, in English
> like in Python, means that something follows that is related to what was
> before the colon. So the colon makes it abundantly clear to the human
> reader that a block follows, and that that block is to be considered in
> relation to what was just said, before the colon.
>
> Coincidentally, Guido wrote this blog post just last week, without which
> I'd be just as much at a loss as you:
>
>
> http://python-history.blogspot.com/2011/07/karin-dewar-indentation-and-colon.html
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
/*--*/
Don’t EVER make the mistake that you can design something better than what
you get from ruthless massively parallel trial-and-error with a feedback
cycle. That’s giving your intelligence _much_ too much credit.

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


Re: An interesting beginner question: why we need colon at all in the python language?

2011-07-11 Thread Dave Angel

On 01/-10/-28163 02:59 PM, Anthony Kong wrote:

Hi, all,

Lately I am giving some presentations to my colleagues about the python
language. A new internal project is coming up which will require the use of
python.

One of my colleague asked an interesting:

*If Python use indentation to denote scope, why it still needs semi-colon at
the end of function declaration and for/while/if loop?*

My immediate response is: it allows us to fit statements into one line. e.g.
if a == 1: print a

However I do not find it to be a particularly strong argument. I think PEP8
does not recommend this kind of coding style anyway, so one-liner should not
be used in the first place!

Is there any other reasons for use of semi-colon in python?


Cheers

You're confusing the colon with the semi-colon.  If you want two 
statements on the same line, you use a semi-colon.


The character you're asking about is the colon.  It goes at the end of 
an if, else, for, with, while statement.  I doubt it's absolutely 
essential, but it helps readability, since a conditional expression 
might span multiple lines.

if someexpression ==
  someotherexpression:
body_of_the_conditional

DaveA

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


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

2011-07-11 Thread Chris Angelico
On Tue, Jul 12, 2011 at 12:21 AM, sturlamolden  wrote:
> You are probably aware that Unix and Unix customers have been around
> since the 1970s. I would expect the paradigm to be changed by now.
>

The paradigm of small tools that do exactly what they're supposed to,
and can be combined? Nope. There's still a philosophy of services that
fit together like a jigsaw puzzle, rather than expecting each
application to do everything you want it to. A standard Unix command
line might consist of three or more tools, piping from one into
another - grep the Apache log for lines containing the name of a PHP
script, pipe that into awk to pick up just the user name, IP address,
and date (without time), then pipe into uniq (deliberately without
first going through sort) to show who's been using the script lately.
And then piped it through sed to clean up the format a bit. Yep,
that's something I did recently.

Point to note: This is the Unix *philosophy* versus the Windows
*philosophy*, not Unix *programs* versus Windows *programs*. There are
Windows programs that follow the Unix philosophy.

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


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

2011-07-11 Thread Thorsten Kampe
* sturlamolden (Mon, 11 Jul 2011 07:21:37 -0700 (PDT))
> On 11 Jul, 16:10, Thorsten Kampe  wrote:
> > And as soon as developers start developing for Unix customers (say
> > Komodo, for instance), they start following the "Windows model" - as
> > you call it.
> 
> You are probably aware that Unix and Unix customers have been around
> since the 1970s. I would expect the paradigm to be changed by now.

For the /customers/ on Unix it never was a paradigm. They would have 
laughed in their vendor's face if they had gotten the "here are the 
tools, just make them work together as you like" attitude[1].

Thorsten
[1] at least starting from the beginning of the nineties when commercial 
alternatives to Unix began to emerge
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Virtual functions are virtually invisible!

2011-07-11 Thread Chris Angelico
On Mon, Jul 11, 2011 at 11:42 PM, rantingrick  wrote:
> This mandate must be handed down from the gods who reside on "Mount
> REFUSE-E-OUS to RECOGNIZE-E-OUS a major PROBLEM-O-MOUS"
>

I assume you're trying to reference Mount Olympus where the Greek gods
live, but I'm left thinking more of Mount Vesuvius... possibly not the
best reference for what you're saying.

But once again, Ranting Rick posts something saying that he is perfect
and everyone else needs to change. I can see why you keep landing in
killfiles [1].

ChrisA

[1] http://bofh.ch/bofh/bsmh2.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Finding duplicated photo

2011-07-11 Thread Fulvio
Thomas Jollans wrote:

> If Gwenview simply moves/renames the images, is it not enough to compare
> the actual files, byte by byte?

For the work at the spot I found Geeqie, doing right. In the other hand 
learning some PIL function is one of my interest.


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


Re: An interesting beginner question: why we need colon at all in the python language?

2011-07-11 Thread Grant Edwards
On 2011-07-11, Thomas Jollans  wrote:
> On 07/11/2011 03:51 PM, Anthony Kong wrote:
>> Hi, all,
>> 
>> Lately I am giving some presentations to my colleagues about the python
>> language. A new internal project is coming up which will require the use
>> of python.
>> 
>> One of my colleague asked an interesting:
>> 
>> /If Python use indentation to denote scope, why it still needs
>> semi-colon at the end of function declaration and for/while/if loop?/
>> 
>> My immediate response is: it allows us to fit statements into one line.
>> e.g. if a == 1: print a
>> 
>> However I do not find it to be a particularly strong argument. I think
>> PEP8 does not recommend this kind of coding style anyway, so one-liner
>> should not be used in the first place!
>
> Basically, it looks better, and is more readable.

And it makes adding a "python mode" to a programming editor almost
trivial.

-- 
Grant Edwards   grant.b.edwardsYow! I am a jelly donut.
  at   I am a jelly donut.
  gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: An interesting beginner question: why we need colon at all in the python language?

2011-07-11 Thread Sébastien Volle
Could it have been made optional, like the trailing comma in list
declaration?

--
Seb

2011/7/11 Anthony Kong 

> Awesome! Thanks for blog post link
>
> Cheers
>
>
> On Tue, Jul 12, 2011 at 12:16 AM, Thomas Jollans  wrote:
>
>> On 07/11/2011 03:51 PM, Anthony Kong wrote:
>> > Hi, all,
>> >
>> > Lately I am giving some presentations to my colleagues about the python
>> > language. A new internal project is coming up which will require the use
>> > of python.
>> >
>> > One of my colleague asked an interesting:
>> >
>> > /If Python use indentation to denote scope, why it still needs
>> > semi-colon at the end of function declaration and for/while/if loop?/
>> >
>> > My immediate response is: it allows us to fit statements into one line.
>> > e.g. if a == 1: print a
>> >
>> > However I do not find it to be a particularly strong argument. I think
>> > PEP8 does not recommend this kind of coding style anyway, so one-liner
>> > should not be used in the first place!
>>
>> Basically, it looks better, and is more readable. A colon, in English
>> like in Python, means that something follows that is related to what was
>> before the colon. So the colon makes it abundantly clear to the human
>> reader that a block follows, and that that block is to be considered in
>> relation to what was just said, before the colon.
>>
>> Coincidentally, Guido wrote this blog post just last week, without which
>> I'd be just as much at a loss as you:
>>
>>
>> http://python-history.blogspot.com/2011/07/karin-dewar-indentation-and-colon.html
>>
>> --
>> http://mail.python.org/mailman/listinfo/python-list
>>
>
>
>
> --
> /*--*/
> Don’t EVER make the mistake that you can design something better than what
> you get from ruthless massively parallel trial-and-error with a feedback
> cycle. That’s giving your intelligence _much_ too much credit.
>
> - Linus Torvalds
>
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Finding duplicated photo

2011-07-11 Thread Fulvio
Kevin Zhang wrote:

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

I found that isn't python 3 code :(

Then the code should go into some other program to allow actions on those 
pictures which are matching each other. Am I right?

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


Re: Finding duplicated photo

2011-07-11 Thread Fulvio
Dave Angel wrote:

> If your real problem is identifying a renamed file amongst thousands of
> others, why not just compare the metadata?  it'll be much faster.
> 
This was the primer situation, then to get into the dirt I tought something 
more sophisticated.
There was a program some year's back which was brilliant an fast to find 
similar pictures on several thousand of them.
Now I can't recall what was the program name and very interesting to do some 
of mine experiments.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: An interesting beginner question: why we need colon at all in the python language?

2011-07-11 Thread Thomas Jollans
On 07/11/2011 04:36 PM, Dave Angel wrote:
> The character you're asking about is the colon.  It goes at the end of
> an if, else, for, with, while statement.  I doubt it's absolutely
> essential, but it helps readability, since a conditional expression
> might span multiple lines.
> if someexpression ==
>   someotherexpression:
> body_of_the_conditional

That, of course, is not legal Python. Your point stands when you add
brackets or a backslash to hold the condition together.
-- 
http://mail.python.org/mailman/listinfo/python-list


My take on 'Python Productivity tip for Java Programmer'. Could you give me more feedback?

2011-07-11 Thread Anthony Kong
Hi, all,

Lately I am giving some presentations to my colleagues about the python
language. A new internal project is coming up which will require the use of
python.

One of the goals of the presentations, as told by the 'sponsor' of the
presentation, is to help the existing Java/Excel VBA programming team to
become productive in python asap.

I have a feeling that they are asking it based on their Java/Eclipse
experience. By productive they are actually looking for some GUI tools that
are as helpful as Eclipse.

Having done Java programming before, I am thinking of answering the question
this way:

1) For many of us, vi/emacs are sufficient for python development. (I used
vim + ctags as my primary IDE for a very long time)

2) For a feature-rich GUI environment, we can consider pyCharm. (I was
totally 'wowed' by it, and has convinced my last employer to purchased a
few enterprise licenses)

3) The Python language itself is actually small and concise. The need for a
full-blown IDE is less. The language itself could be counted as a part of
the productive tool.

4) The functional aspect of the language (e.g. map, reduce, partial) helps
to make program shorter and easier to understand

5) The 'battery included' standard library helps to avoid the need of
complicated build tool.

6) The interactive shell helps to test out solutions in smaller units.

It is probably not the team is expecting. Do you have more to add? What do
you think about this 'answer'?

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


Re: An interesting beginner question: why we need colon at all in the python language?

2011-07-11 Thread Anthony Kong
Sorry, typo in my original question. I do mean 'colon'. It should have read

*If Python use indentation to denote scope, why it still needs colon at the
end of function declaration and for/while/if loop?*

Thanks


On Tue, Jul 12, 2011 at 12:36 AM, Dave Angel  wrote:

> On 01/-10/-28163 02:59 PM, Anthony Kong wrote:
>
>> Hi, all,
>>
>> Lately I am giving some presentations to my colleagues about the python
>> language. A new internal project is coming up which will require the use
>> of
>> python.
>>
>> One of my colleague asked an interesting:
>>
>> *If Python use indentation to denote scope, why it still needs semi-colon
>> at
>> the end of function declaration and for/while/if loop?*
>>
>> My immediate response is: it allows us to fit statements into one line.
>> e.g.
>> if a == 1: print a
>>
>> However I do not find it to be a particularly strong argument. I think
>> PEP8
>> does not recommend this kind of coding style anyway, so one-liner should
>> not
>> be used in the first place!
>>
>> Is there any other reasons for use of semi-colon in python?
>>
>>
>> Cheers
>>
>>  You're confusing the colon with the semi-colon.  If you want two
> statements on the same line, you use a semi-colon.
>
> The character you're asking about is the colon.  It goes at the end of an
> if, else, for, with, while statement.  I doubt it's absolutely essential,
> but it helps readability, since a conditional expression might span multiple
> lines.
>if someexpression ==
>  someotherexpression:
>body_of_the_conditional
>
> DaveA
>
>


-- 
/*--*/
Don’t EVER make the mistake that you can design something better than what
you get from ruthless massively parallel trial-and-error with a feedback
cycle. That’s giving your intelligence _much_ too much credit.

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


Re: An interesting beginner question: why we need colon at all in the python language?

2011-07-11 Thread Ian Kelly
On Mon, Jul 11, 2011 at 8:50 AM, Sébastien Volle
 wrote:
> Could it have been made optional, like the trailing comma in list
> declaration?

Cobra makes the colons optional, so probably yes.
-- 
http://mail.python.org/mailman/listinfo/python-list


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

2011-07-11 Thread Chris Hulan
The callback is a method so you need to specify the owner

builder.connect_signals({"on_window_destroy" : gtk.main_quit,
"on_btnExit_clicked" : self.btnExit_clicked})

Got this info from 
http://www.pygtk.org/articles/pygtk-glade-gui/Creating_a_GUI_using_PyGTK_and_Glade.htm

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


Property setter and lambda question

2011-07-11 Thread Anthony Kong
Hi, all,

This question is in the same context of my two earlier questions. This
question was raised by some python beginners, and I would like to check with
the list to ensure I provide a correct answer.

Here is a code snippet I used to demonstrate the keyword *property*:


class A(object):

def __init__(self):
self.__not_here = 1

def __get_not_here(self):
return self.__not_here

def __set_not_here(self, v):
print "I am called"
self.__not_here = v

not_here = property(lambda self: self.__get_not_here(), lambda self, v:
self.__set_not_here(v))
# not_here = property(lambda self: self.__not_here, lambda self, v:
self.__not_here = v)

So the question: is it possible to use lambda expression at all for the
setter? (As in the last, commented-out line)

Python interpreter will throw an exception right there if I use the last
line ('SyntaxError: lambda cannot contain assignment'). I'd use pass a
setter method anyway.

What is your preferred solution?

-- 

Tony Kong
*blog:* www.ahwkong.com

/*--*/
Don’t EVER make the mistake that you can design something better than what
you get from ruthless massively parallel trial-and-error with a feedback
cycle. That’s giving your intelligence _much_ too much credit.

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


Re: My take on 'Python Productivity tip for Java Programmer'. Could you give me more feedback?

2011-07-11 Thread Thomas Jollans
On 07/11/2011 05:07 PM, Anthony Kong wrote:
> Hi, all,
> 
> Lately I am giving some presentations to my colleagues about the python
> language. A new internal project is coming up which will require the use
> of python.
> 
> One of the goals of the presentations, as told by the 'sponsor' of the
> presentation, is to help the existing Java/Excel VBA programming team to
> become productive in python asap.
> 
> I have a feeling that they are asking it based on their Java/Eclipse
> experience. By productive they are actually looking for some GUI tools
> that are as helpful as Eclipse.
> 
> Having done Java programming before, I am thinking of answering the
> question this way:
> 
> 1) For many of us, vi/emacs are sufficient for python development. (I
> used vim + ctags as my primary IDE for a very long time)
> 
> 2) For a feature-rich GUI environment, we can consider pyCharm. (I was
> totally 'wowed' by it, and has convinced my last employer to purchased a
> few enterprise licenses) 
> 
> 3) The Python language itself is actually small and concise. The need
> for a full-blown IDE is less. The language itself could be counted as a
> part of the productive tool.

If your colleagues are used to Eclipse, it's almost certainly best to
continue using Eclipse, with PyDev. Don't make a big deal of the tools,
just say that many Pythonista don't use a heavy IDE, mention PyDev, and,
if you want to, recommend pyCharm.

> 4) The functional aspect of the language (e.g. map, reduce, partial)
> helps to make program shorter and easier to understand

Don't overemphasize this. Those functions can be very useful, and using
them can lead to very concise and simple code, but (big BUT) more often
than not, they're overly cryptic when compared to list comprehension and
generator expressions.

Do make a huge case for generator expressions/list comprehension, and
generators.

> 5) The 'battery included' standard library helps to avoid the need of
> complicated build tool.
> 
> 6) The interactive shell helps to test out solutions in smaller units. 

Speaking of testing: introduce them to the doctest module.

> It is probably not the team is expecting. Do you have more to add? What
> do you think about this 'answer'?

If using Jython is an option, present it! Jython will allow Java
programmers to use their existing knowledge of the Java standard library.

Explain, and make the case for, duck typing.

While actual functional programming is, as I said, a bit "out there"
from a Java/VBA standpoint, do show off function objects.

If you know what they're going to do with Python, you should point them
to relevant libraries/modules.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ctypes: point to buffer in structure

2011-07-11 Thread Wanderer
On Jul 11, 1:12 am, Tim Roberts  wrote:
> 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.

if UNICODE_STRING is a structure you will want a structure for it

class UNICODE_STRING(ctypes.Structure):
_fields_ = [("Length", ctypes.c_ushort),
("MaximumLength" ,ctypes.c_ushort),
("Buffer", ctypes.c_wchar_p)]

class SYSTEM_PROCESS_ID_INFORMATION(ctypes.Structure):
_fields_ = [("pid", ctypes.c_ulong),
("imageName", UNICODE_STRING)]


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


Re: Property setter and lambda question

2011-07-11 Thread Thomas Jollans
On 07/11/2011 05:54 PM, Anthony Kong wrote:
> Hi, all,
> 
> This question is in the same context of my two earlier questions. This
> question was raised by some python beginners, and I would like to check
> with the list to ensure I provide a correct answer.
> 
> Here is a code snippet I used to demonstrate the keyword *property*:
> 
> 
> class A(object):
> 
> def __init__(self):
> self.__not_here = 1
> 
> def __get_not_here(self):
> return self.__not_here
> 
> def __set_not_here(self, v):
> print "I am called"
> self.__not_here = v
> 
> not_here = property(lambda self: self.__get_not_here(), lambda self,
> v: self.__set_not_here(v))
> # not_here = property(lambda self: self.__not_here, lambda self, v:
> self.__not_here = v)
> 
> So the question: is it possible to use lambda expression at all for the
> setter? (As in the last, commented-out line)
> 
> Python interpreter will throw an exception right there if I use the last
> line ('SyntaxError: lambda cannot contain assignment'). I'd use pass a
> setter method anyway.  
> 
> What is your preferred solution?

No, a lambda can only contain an expression, not a statement. This is
not C, assignments are not expressions.

As to what I would do:
There's really no need to use lambdas at all here:

class A(object):
def __init__(self):
self.not_here = 1
def __get_not_here(self):
return self.__not_here
def __set_not_here(self, val):
self.__not_here = val
not_here = property(__get_not_here, __set_not_here)

My favourite way to create properties is of course with decorators:

class A(object):
def __init__(self):
self.not_here = 1

@property
def not_here(self):
return self.__not_here

@not_here.setter
def not_here(self, val):
self.__not_here = val
-- 
http://mail.python.org/mailman/listinfo/python-list


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

2011-07-11 Thread rusi
On Jul 11, 7:39 pm, Chris Angelico  wrote:
> On Tue, Jul 12, 2011 at 12:21 AM, sturlamolden  wrote:
> > You are probably aware that Unix and Unix customers have been around
> > since the 1970s. I would expect the paradigm to be changed by now.
>
> The paradigm of small tools that do exactly what they're supposed to,
> and can be combined? Nope. There's still a philosophy of services that
> fit together like a jigsaw puzzle, rather than expecting each
> application to do everything you want it to. A standard Unix command
> line might consist of three or more tools, piping from one into
> another - grep the Apache log for lines containing the name of a PHP
> script, pipe that into awk to pick up just the user name, IP address,
> and date (without time), then pipe into uniq (deliberately without
> first going through sort) to show who's been using the script lately.
> And then piped it through sed to clean up the format a bit. Yep,
> that's something I did recently.
>
> Point to note: This is the Unix *philosophy* versus the Windows
> *philosophy*, not Unix *programs* versus Windows *programs*. There are
> Windows programs that follow the Unix philosophy.
>
> ChrisA


The intention of programming is to close the semantic gap.

-
It is a fundamental task of software engineering to close the gap
between application specific knowledge and technically doable
formalization. For this purpose domain specific (high-level) knowledge
must be transferred into an algorithm and its parameters (low-level).

(from http://en.wikipedia.org/wiki/Semantic_gap
-

A gui-builder reduces the semantic gap by showing a widget when the
programmer things 'widget.'
Banging out hundreds of lines in vi/emacs for the same purpose does a
measurably poorer job.

Note it can reduce but not close.  By choosing fidelity to the gui we
have corresponding less fidelity to the algos and data-structures [And
one may assume that someone even using a gui toolkit wants to do
something with the gui and not just paint the screen]

Still it seems a bit naive to suggest that building a gui by a few
point&clicks is 'windows-model' and banging out hundreds of lines in
vi/emacs is 'unix-model.'  It does disservice to python and to unix.

If a student of mine came and said: Is Python better or Unix? he would
receive a dressing down.
And yet more than one person here seems to think such type-wrong
comparisons are ok.

I find this disturbing...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: My take on 'Python Productivity tip for Java Programmer'. Could you give me more feedback?

2011-07-11 Thread Anthony Kong
Thomas,

Thanks for the excellent suggestions.

Generator is certainly an interesting subject.

>From what i understand, the advantage of generator is mainly about saving
memory, right? (i.e. no need to create a list in memory before iterate thru
it)

Duck typing... Although it can be easily demonstrated, I find it hard to
explain its advantages to Java developers who are so used to Interfaces. (Is
it about the certainty of type info... I am not sure about their concern
actually)

Jython is not a possibility, but I will show them an example anyway. We can
use it to write some support script, I suppose.

(Off topic) Monkey patching - It is a term used by Ruby developer a lot. If
it means to change a function's implementation in run-time, i think python
can achieve the same, right? Is it equivalent to Mixin?

Cheers



On Tue, Jul 12, 2011 at 2:00 AM, Thomas Jollans  wrote:

> On 07/11/2011 05:07 PM, Anthony Kong wrote:
> > Hi, all,
> >
> > Lately I am giving some presentations to my colleagues about the python
> > language. A new internal project is coming up which will require the use
> > of python.
> >
> > One of the goals of the presentations, as told by the 'sponsor' of the
> > presentation, is to help the existing Java/Excel VBA programming team to
> > become productive in python asap.
> >
> > I have a feeling that they are asking it based on their Java/Eclipse
> > experience. By productive they are actually looking for some GUI tools
> > that are as helpful as Eclipse.
> >
> > Having done Java programming before, I am thinking of answering the
> > question this way:
> >
> > 1) For many of us, vi/emacs are sufficient for python development. (I
> > used vim + ctags as my primary IDE for a very long time)
> >
> > 2) For a feature-rich GUI environment, we can consider pyCharm. (I was
> > totally 'wowed' by it, and has convinced my last employer to purchased a
> > few enterprise licenses)
> >
> > 3) The Python language itself is actually small and concise. The need
> > for a full-blown IDE is less. The language itself could be counted as a
> > part of the productive tool.
>
> If your colleagues are used to Eclipse, it's almost certainly best to
> continue using Eclipse, with PyDev. Don't make a big deal of the tools,
> just say that many Pythonista don't use a heavy IDE, mention PyDev, and,
> if you want to, recommend pyCharm.
>
> > 4) The functional aspect of the language (e.g. map, reduce, partial)
> > helps to make program shorter and easier to understand
>
> Don't overemphasize this. Those functions can be very useful, and using
> them can lead to very concise and simple code, but (big BUT) more often
> than not, they're overly cryptic when compared to list comprehension and
> generator expressions.
>
> Do make a huge case for generator expressions/list comprehension, and
> generators.
>
> > 5) The 'battery included' standard library helps to avoid the need of
> > complicated build tool.
> >
> > 6) The interactive shell helps to test out solutions in smaller units.
>
> Speaking of testing: introduce them to the doctest module.
>
> > It is probably not the team is expecting. Do you have more to add? What
> > do you think about this 'answer'?
>
> If using Jython is an option, present it! Jython will allow Java
> programmers to use their existing knowledge of the Java standard library.
>
> Explain, and make the case for, duck typing.
>
> While actual functional programming is, as I said, a bit "out there"
> from a Java/VBA standpoint, do show off function objects.
>
> If you know what they're going to do with Python, you should point them
> to relevant libraries/modules.
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 

Tony Kong
*blog:* www.ahwkong.com

Don’t EVER make the mistake that you can design something better than what
> you get from ruthless massively parallel trial-and-error with a feedback
> cycle. That’s giving your intelligence *much* too much credit.


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


Re: Property setter and lambda question

2011-07-11 Thread Ian Kelly
On Mon, Jul 11, 2011 at 9:54 AM, Anthony Kong  wrote:
> Hi, all,
> This question is in the same context of my two earlier questions. This
> question was raised by some python beginners, and I would like to check with
> the list to ensure I provide a correct answer.
> Here is a code snippet I used to demonstrate the keyword property:

What Thomas said.  But also, please note that "property" is a builtin,
not a keyword.



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


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

2011-07-11 Thread Speedbird
> On Windows, you're a customer and the developer wants to make using his
> application as convenient as possible for you, the customer.
>

So the well-behavioured, good-intentioned windows devs are making sure
the
customer feels pampered and cozy, how nice and dandy.

> On Unix you don't pay and the developer couldn't care less if his
> application works together with application b or how much it takes you
> to actually get this damn thing running.
>

Now, on the other hand, the bad, bearded, grumpy and ugly unix devs
want to make the customer's life miserable, bad boys..

What a load of bull, I am a unix developer and do _care_ for my
customers, being them sysadmins, end users or even windows heads,
and I am sure I am not the only one thinking this way.

The windows "way of doing things" ("user friendly experience", "point
and click", "plug and play") etc is not a bad one at all, it consists
of tools to allow developers who have lesser understanding about
computers
to create applications that will be used by users with also little
understanding
about computers in general, on the other hand, unix/linus/posix devs
develop
applications that can potentially be used more efficiently by people
with great understanding about computers in general.

Both have their user base, and this is IMO the primary reason why
windows
is the dominant OS currently, those with little understanding about
computers and technology in general far outnumber those who do.

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


Re: Property setter and lambda question

2011-07-11 Thread Anthony Kong
Thanks again for your input, Thomas.

I normally prefer

not_here = property(lambda self: self.__get_not_here(), lambda self, v:
self.__set_not_here(v))

than

not_here = property(__get_not_here, __set_not_here)

Because it allows me to have a pair getter/setter (when there is a need for
it). Use of lambda there is ensure derived class of A can provide their
custom version of getter/setter.


But decorator! Of course! Thanks for reminding me this.

In your example, where does '@not_here' come from? (Sorry, this syntax is
new to me)

Cheers

On Tue, Jul 12, 2011 at 2:23 AM, Thomas Jollans  wrote:

> On 07/11/2011 05:54 PM, Anthony Kong wrote:
> > Hi, all,
> >
> > This question is in the same context of my two earlier questions. This
> > question was raised by some python beginners, and I would like to check
> > with the list to ensure I provide a correct answer.
> >
> > Here is a code snippet I used to demonstrate the keyword *property*:
> >
> >
> > class A(object):
> >
> > def __init__(self):
> > self.__not_here = 1
> >
> > def __get_not_here(self):
> > return self.__not_here
> >
> > def __set_not_here(self, v):
> > print "I am called"
> > self.__not_here = v
> >
> > not_here = property(lambda self: self.__get_not_here(), lambda self,
> > v: self.__set_not_here(v))
> > # not_here = property(lambda self: self.__not_here, lambda self, v:
> > self.__not_here = v)
> >
> > So the question: is it possible to use lambda expression at all for the
> > setter? (As in the last, commented-out line)
> >
> > Python interpreter will throw an exception right there if I use the last
> > line ('SyntaxError: lambda cannot contain assignment'). I'd use pass a
> > setter method anyway.
> >
> > What is your preferred solution?
>
> No, a lambda can only contain an expression, not a statement. This is
> not C, assignments are not expressions.
>
> As to what I would do:
> There's really no need to use lambdas at all here:
>
> class A(object):
>def __init__(self):
>self.not_here = 1
>def __get_not_here(self):
>return self.__not_here
> def __set_not_here(self, val):
>self.__not_here = val
>not_here = property(__get_not_here, __set_not_here)
>
> My favourite way to create properties is of course with decorators:
>
> class A(object):
>def __init__(self):
>self.not_here = 1
>
> @property
>def not_here(self):
>return self.__not_here
>
>@not_here.setter
>def not_here(self, val):
>self.__not_here = val
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 

Tony Kong
*blog:* www.ahwkong.com

Don’t EVER make the mistake that you can design something better than what
> you get from ruthless massively parallel trial-and-error with a feedback
> cycle. That’s giving your intelligence *much* too much credit.


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


Re: Property setter and lambda question

2011-07-11 Thread Anthony Kong
Good point! Need to get my terminology right. Thanks

On Tue, Jul 12, 2011 at 2:43 AM, Ian Kelly  wrote:

> On Mon, Jul 11, 2011 at 9:54 AM, Anthony Kong 
> wrote:
> > Hi, all,
> > This question is in the same context of my two earlier questions. This
> > question was raised by some python beginners, and I would like to check
> with
> > the list to ensure I provide a correct answer.
> > Here is a code snippet I used to demonstrate the keyword property:
>
> What Thomas said.  But also, please note that "property" is a builtin,
> not a keyword.
>
> 
>
> Cheers,
> Ian
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 

Tony Kong
*blog:* www.ahwkong.com

Don’t EVER make the mistake that you can design something better than what
> you get from ruthless massively parallel trial-and-error with a feedback
> cycle. That’s giving your intelligence *much* too much credit.


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


Re: My take on 'Python Productivity tip for Java Programmer'. Could you give me more feedback?

2011-07-11 Thread Thomas Jollans
On 07/11/2011 06:42 PM, Anthony Kong wrote:
> Thomas, 
> 
> Thanks for the excellent suggestions.
> 
> Generator is certainly an interesting subject.
> 
> From what i understand, the advantage of generator is mainly about
> saving memory, right? (i.e. no need to create a list in memory before
> iterate thru it)

When it comes to generator expression vs. list comprehension, yes. It
also has the benefit that, if you're reading, say, from the network, you
can do things with the content elegantly as it arrives: you can process
the first bit when the last bit doesn't yet exist.

"Classic" Python-2.3 (?) generators themselves are brilliant invention
that makes it easy to create custom iterators. Java has iterators too,
but nothing akin to this:

def foo():
   # do stuff:
   yield x

> Duck typing... Although it can be easily demonstrated, I find it hard to
> explain its advantages to Java developers who are so used to Interfaces.
> (Is it about the certainty of type info... I am not sure about their
> concern actually)

They're used to interfaces, yes. Duck typing is little more than
implicit interfaces. Python does support Java-style interfaces via ABC,
but all the metaclasses and isinstance calls are needless complexity.

> Jython is not a possibility, but I will show them an example anyway. We
> can use it to write some support script, I suppose.
> 
> (Off topic) Monkey patching - It is a term used by Ruby developer a lot.
> If it means to change a function's implementation in run-time, i think
> python can achieve the same, right? Is it equivalent to Mixin?

Python doesn't have Ruby mixins as such. It's possible to replace
functions and methods on any object, but it is almost always better (as
in easier to understand and maintain) to modify the class/module you're
using, or to subclass it. The only case when it's useful IMHO is when
there's a bug or shortcoming in an external library you use, cannot
modify, and if subclassing can't achieve the desired results.

Don't show your Java programmers this. Being used to static typing,
they'll be terrified, and rightly so.

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


Re: Property setter and lambda question

2011-07-11 Thread Thomas Jollans
# On 07/11/2011 06:53 PM, Anthony Kong wrote:
# But decorator! Of course! Thanks for reminding me this.
#
# In your example, where does '@not_here' come from? (Sorry, this syntax
# is new to me)

class A(object):
def __init__(self):
self.not_here = 1

 @property
 def not_here(self):
 return self.__not_here

 @not_here.setter
 def not_here(self, val):
 self.__not_here = val

"""
Let's translate that to non-decorator Python:
"""

class A(object):
def __init__(self):
self.not_here = 1

def _(self):
return self.__not_here
not_here = property(_)
del _

def _(self, val):
self.__not_here = val
not_here = not_here.setter(_)
del _


"""
@not_here.setter exists because not_here.setter exists. not_here exists
since we set it (when the getter/property was set).


Cheers
Thomas


PS: are you sure the lambda self: self.__foo() trick works, with
subclasses or otherwise? I haven't tested it, and I'm not saying it
doesn't, but I have a feeling double-underscore name mangling might be a
problem somewhere down the line?

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


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

2011-07-11 Thread Stefan Behnel

Ivan Kljaic, 11.07.2011 00:50:

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.


Just a quick suggestion regarding the way you posed your question. It's 
usually better to ask if anyone knows a good tool to do a specific job 
(which you would describe in your post), instead of complaining about there 
being none. Even if you googled for it, you may have missed something 
because it's known under a different name or because it works differently 
than you expected. Also, as the answers show, your usage of the term "RAD" 
is ambiguous - not everyone seems to know what you mean with it.


Stefan

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


Re: Property setter and lambda question

2011-07-11 Thread Anthony Kong
>
> PS: are you sure the lambda self: self.__foo() trick works, with
> subclasses or otherwise? I haven't tested it, and I'm not saying it
> doesn't, but I have a feeling double-underscore name mangling might be a
> problem somewhere down the line?
>
>
Awesome, Thomas. The trick only works if there is only *one* leading
underscore in the *method* names.

The following example works as I expected for the derived class B.

class A(object):

def __init__(self):
self.__not_here = 1

def _get_not_here(self):
return self.__not_here

def _set_not_here(self, v):
print "I am called"
self.__not_here = v

not_here = property(lambda self: self._get_not_here(), lambda self, v:
self._set_not_here(v))

class B(A):
def _set_not_here(self, v):
print "version B"
self.__not_here = v


a = A()
# print a.__not_here
print a.not_here
# a.set_not_here(10)
a.not_here = 10
print a.not_here


b = B()
print b.not_here
b.not_here = 70  # print version B
print b.not_here




-- 

Tony Kong
*blog:* www.ahwkong.com

Don’t EVER make the mistake that you can design something better than what
> you get from ruthless massively parallel trial-and-error with a feedback
> cycle. That’s giving your intelligence *much* too much credit.


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


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

2011-07-11 Thread rantingrick
On Jul 11, 11:33 am, rusi  wrote:

> A gui-builder reduces the semantic gap by showing a widget when the
> programmer things 'widget.'
> Banging out hundreds of lines in vi/emacs for the same purpose does a
> measurably poorer job.

It is very rare to need to "bang out" hundreds of lines of code to
replace a mouse click interface. If properly designed a good API can
compete with a GUI. In far less time than it takes me to scroll down a
list of widgets, pick the appropriate one, drag it across the screen,
tinker with it's absolute position, and set some attributes,  i could
have typed Widget(parent, **kw).geometry(blah, blah) and been done.

> Note it can reduce but not close.  By choosing fidelity to the gui we
> have corresponding less fidelity to the algos and data-structures [And
> one may assume that someone even using a gui toolkit wants to do
> something with the gui and not just paint the screen]

Exactly. For this very reason i have always refused to used any "point-
and-click" GUI builders. I prefer to get up-close and personal with my
code bases. Of course i use high levels of API abstraction for most of
the work, however i already know what is happening in the lower levels
if i need to dive down one tier.

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


Re: Property setter and lambda question

2011-07-11 Thread John Posner
On 2:59 PM, Anthony Kong wrote:


> So the question: is it possible to use lambda expression at all for
> the setter? (As in the last, commented-out line)
>
> Python interpreter will throw an exception right there if I use the
> last line ('SyntaxError: lambda cannot contain assignment'). I'd use
> pass a setter method anyway.  
>
> What is your preferred solution?

Anthony, you might take a look at this alternative writeup for
"property", which I placed on the Python Wiki:

http://wiki.python.org/moin/AlternativeDescriptionOfProperty

HTH,
John



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


Re: Property setter and lambda question

2011-07-11 Thread Ian Kelly
On Mon, Jul 11, 2011 at 10:53 AM, Anthony Kong
 wrote:
> Thanks again for your input, Thomas.
> I normally prefer
> not_here = property(lambda self: self.__get_not_here(), lambda self, v:
> self.__set_not_here(v))
> than
> not_here = property(__get_not_here, __set_not_here)
> Because it allows me to have a pair getter/setter (when there is a need for
> it). Use of lambda there is ensure derived class of A can provide their
> custom version of getter/setter.

The .setter convenience method also makes it a bit easier for derived
classes to modify getters and setters:

class Base(object):

def get_my_property(self):
return self._my_property

def set_my_property(self, value):
self._my_property = value

my_property = property(get_my_property, set_my_property)


class Derived(Base):

def set_my_property(self, value):
super(Derived, self).set_my_property(convert(value))

my_property = Base.my_property.setter(set_my_property)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Property setter and lambda question

2011-07-11 Thread Ian Kelly
On Mon, Jul 11, 2011 at 11:21 AM, Anthony Kong
 wrote:
> Awesome, Thomas. The trick only works if there is only one leading
> underscore in the method names.
> The following example works as I expected for the derived class B.
> class A(object):
>     def __init__(self):
>         self.__not_here = 1
>     def _get_not_here(self):
>         return self.__not_here
>     def _set_not_here(self, v):
>         print "I am called"
>         self.__not_here = v
>     not_here = property(lambda self: self._get_not_here(), lambda self, v:
> self._set_not_here(v))
> class B(A):
>     def _set_not_here(self, v):
>         print "version B"
>         self.__not_here = v

It shouldn't.  You've still got the name __not_here used in both A and
B, so that the B version is setting a different attribute than the A
version (_B__not_here vs. _A__not_here).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Property setter and lambda question

2011-07-11 Thread Anthony Kong
So subclass B has no access to __not_here in A after all...

OK, in one of legacy Python I supported there are a lot of code floating
around like this. It works OK (in term of business logic and unit test).
That's probably due to luck :-)

It also uses a lot of __slot__ = ['attr_a', 'attr_b'...] in class
definitions to prevent accidental creation of new variables (due to typo for
example).

Needless to say it was first written up by programmers of static lang
background who want to enforce the java/.net behavior... (private variables,
variable declaration)


Cheers


On Tue, Jul 12, 2011 at 3:41 AM, Ian Kelly  wrote:

> On Mon, Jul 11, 2011 at 11:21 AM, Anthony Kong
>  wrote:
> > Awesome, Thomas. The trick only works if there is only one leading
> > underscore in the method names.
> > The following example works as I expected for the derived class B.
> > class A(object):
> > def __init__(self):
> > self.__not_here = 1
> > def _get_not_here(self):
> > return self.__not_here
> > def _set_not_here(self, v):
> > print "I am called"
> > self.__not_here = v
> > not_here = property(lambda self: self._get_not_here(), lambda self,
> v:
> > self._set_not_here(v))
> > class B(A):
> > def _set_not_here(self, v):
> > print "version B"
> > self.__not_here = v
>
> It shouldn't.  You've still got the name __not_here used in both A and
> B, so that the B version is setting a different attribute than the A
> version (_B__not_here vs. _A__not_here).
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 

Tony Kong
*blog:* www.ahwkong.com

Don’t EVER make the mistake that you can design something better than what
> you get from ruthless massively parallel trial-and-error with a feedback
> cycle. That’s giving your intelligence *much* too much credit.


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


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

2011-07-11 Thread Chris Angelico
On Tue, Jul 12, 2011 at 2:56 AM, rantingrick  wrote:
> It is very rare to need to "bang out" hundreds of lines of code to
> replace a mouse click interface. If properly designed a good API can
> compete with a GUI. In far less time than it takes me to scroll down a
> list of widgets, pick the appropriate one, drag it across the screen,
> tinker with it's absolute position, and set some attributes,  i could
> have typed Widget(parent, **kw).geometry(blah, blah) and been done.
>

Point to ponder: Human beings tend to memorize names better than
images from long lists. Most widgets have names as well as appearances
(although it's arguable that the appearance is more what the widget
_is_, and the name is somewhat arbitrary), although in some cases
there's odd pairings - some toolkits merge Radio Button and Check
Box/Button into a single object, others call them two different
things.

To find the widget you need, you must either scroll a long list and
pick the one you want, or key in - possibly with autocompletion
assistance - the name. Which is easier to memorize? Which is easier to
explain? I'd always rather work with the name. And even with the most
point-and-clicky of interface designers, it's normal to be able to see
the names of the objects you're working with.

The one time where point and click is majorly superior to scripted
design is with pixel positioning of widgets. You can drag things
around until you're artistically happy with them, rather than have to
fiddle with the numbers in code. That's how I learned to code GUIs,
but when I started doing cross-platform work and discovered rule-based
layouts (where you put objects in boxes and lay out the boxes in
order, etc), suddenly life got a LOT easier.

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


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

2011-07-11 Thread Ivan Kljaic
Ok. I asked about this questio because I am working with python for
the last 5 years and I am always in touch about signifigact things in
Python. I am pissed of that I make my living by developing
applications at work in Java an C#. My comPany would switch to python
but they complained that there is not even one single gui builder or
framework that can allow it to make a living from it. If you are going
to say that there are also other libraries with every single one there
is a significant problem that make the development painfull.

About the natural selection... I'll say it with the words of
penn&teller:bullshit
For how many years are this vui library wars going on. How many. Look.
I am a open source supporter but Windows will always kick the ass of
open source because the open source comunity can not make a decision.
Just imagine what we would have today if the effort of development
would have been used to develop one really good library. We would have
kicked the ass of MS and steve balmer. The average user wants
something simple and not something to program to do something. It
looks that the firs linux os to realize that is successfull. I am
talking about android.

And the python development team is doing nothing to improve the
situatio to solve this dispute that lasts for the last years by
including the worthless Tk library and now upgrading it with Tix.

To summarize it. It would be very helpfull for python to spread if
there qould be one single good rad gui builder similar to vs or
netbeAns but for python. So right now if i need to make a gui app i
need to work with an applicatio that is dicontinued for the last 5
years is pretty buggy but is ok. If it would only be maintained and
the libraby updated it would be great. When it comes to other
application, sorry but they are just bad. Their userfriendlyness is
simmilar to most of Ms products, they are "user friendly" but the
problem is that they very wisely chose their friends.

The ony worthly ones mentioning as an gui builder are boa constructor
fo wx, qtDesigner with the famous licence problems why companies do
not want to work with it, sharpdevelop for ironpython and netbeans for
jython.
Did you notice that 2 of these 4 are not for python? One is out of dTe
and one has a fucked up licence. Sorry guys but there is not even one
single rad gui tool for python as long as there is no serious
guibuilder.
-- 
http://mail.python.org/mailman/listinfo/python-list


perceptron feed forward neural networks in python

2011-07-11 Thread Igor Begić
Hi,

I,m new to Python and i want to study and write programs about perceptron
feed forward neural networks in python. Does anyone have a good book or link
for this?

Thx,

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


Re: perceptron feed forward neural networks in python

2011-07-11 Thread Ken Watford
On Mon, Jul 11, 2011 at 2:31 PM, Igor Begić  wrote:
> Hi,
> I,m new to Python and i want to study and write programs about perceptron
> feed forward neural networks in python. Does anyone have a good book or link
> for this?

Try Stephen Marsland's "Machine Learning: An Algorithmic Perspective".
All example code is done in Python, and there's a chapter on
multilayer perceptrons.

The code for the book is available online here:
http://www-ist.massey.ac.nz/smarsland/MLbook.html
-- 
http://mail.python.org/mailman/listinfo/python-list


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

2011-07-11 Thread rantingrick
On Jul 11, 1:03 pm, Chris Angelico  wrote:
>
> The one time where point and click is majorly superior to scripted
> design is with pixel positioning of widgets. You can drag things
> around until you're artistically happy with them, rather than have to
> fiddle with the numbers in code.

This is true mostly for the new user of a GUI library or anyone
unlucky enough to use a poorly designed API(which leads into my next
response)

> That's how I learned to code GUIs,
> but when I started doing cross-platform work and discovered rule-based
> layouts (where you put objects in boxes and lay out the boxes in
> order, etc), suddenly life got a LOT easier.

A bit tangential however still relevant... i had always considered
Tkinter's three geometry managers (pack, place, and grid) to be
perfect. However lately i have been musing on the idea of rewriting
the pack API into something more intuitive like a "linear-box-style"
which then manifests itself in two forms; horizontal and vertical.

Of course you can create horizontal and vertical layouts ALREADY by
passing the side=LEFT or side=RIGHT to the pack geometry manager of
Tkinter widgets (TOP being the default BTW) but that fact isn't always
apparent to the new user as the full set of options are side={TOP|
BOTTOM|LEFT|RIGHT}.

And besides, the current API allows you to pack in all sorts of
ridiculous manners; BOTTOM, then TOP, then LEFT, then TOP, then RIGHT,
then TOP, then LEFT, then RIGHT, THEN GHEE WHIZ! Are you trying to win
the obfuscation award of the year here lad?

As we all know you only need three types of geometry management:
 * Linear (horizontal&vertical)
 * Grid
 * Absolute

Anything else is just multiplicity run a muck, again! And by
propagating such API's we also induce ignorance into our ranks. Before
we EVER consider a Python4000 we really need to clean up this
atrocious stdlib! It's like i tell people: when you keep screwing your
customers over then very soon you'll be out of buisness. Sure you can
make a decent living for a short time but the whole house of cards
comes crumbling down without the core base of repeat customers.



PS: I noticed that Python.org has a suggestion box now for which
modules we should be concentrating our community efforts. Well like
they say... "imitation is the greatest form of flattery". And i am
quite flattered.

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


Re: A beginning programmer

2011-07-11 Thread Eric Griffith
Shell scripts are ones that I do all the time, sometimes in BASH
sometimes in python + system calls. A lot of the mainly for
post-install setups of Ubuntu / Fedora / Arch trying to take some of
the load off of my hands in a way that I actually know what is going
on behind the scenes. But I'll definitely go and check out
bugtrackers, I posted this same email to the kde mailing list and one
of the developers told me to check out their Junior Jobs, which are
things such as comment clean up, spelling errors and things like that
so its an introduction to the code itself and I can ease my way in.

Thanks or the quick responses guys!
-- 
http://mail.python.org/mailman/listinfo/python-list


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

2011-07-11 Thread Elias Fotinis

On Mon, 11 Jul 2011 20:11:56 +0300, Stefan Behnel  wrote:


Just a quick suggestion regarding the way you posed your question. It's
usually better to ask if anyone knows a good tool to do a specific job
(which you would describe in your post), instead of complaining about there
being none.


Opinion is divided on this… 

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


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

2011-07-11 Thread Chris Angelico
On Tue, Jul 12, 2011 at 4:28 AM, Ivan Kljaic  wrote:
> For how many years are this vui library wars going on. How many. Look.
> I am a open source supporter but Windows will always kick the ass of
> open source because the open source comunity can not make a decision.

You think Microsoft makes decisions and sticks with them? Look at
Office's last few versions. They can't decide on a file format, an
interface, a featureset... everything keeps changing. The difference
is that in the open-source world, everything survives and can be seen
as a set of alternatives, whereas in the closed-source world, it's
either different versions of one program (like MS Office), or
competing products (which usually means one of them dies for lack of
money - or is bought out by the other).

What we have is not indecision, it is options. Imagine if you went to
a hardware shop and were offered only one tool: a magnet. Would you
laud them for making a decision and sticking with it? No, you'd wonder
what they have against hammers and screwdrivers. I like to have tools
available to my use, not someone else making my decisions for me.

There's competition in the open source world, too; primarily
competition for developer time, a quite scarce resource. If a toolkit
is not of value to people, it won't get as many dev hours,  so you can
often gauge popularity and usefulness by the VCS checkins.

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


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

2011-07-11 Thread rantingrick
On Jul 11, 1:28 pm, Ivan Kljaic  wrote:

> To summarize it. It would be very helpfull for python to spread if
> there qould be one single good rad gui builder similar to vs or
> netbeAns but for python.

Well don't hold your breath friend because i have been ranting for
years about the sad state of GUI libraries (not just in Python but
everywhere). However if somehow "we" (the Python community) could grow
a collective brain and build the three tiered system (that i proposed
on THIS very list!) then we would have something that no one has! Yes,
we would have a future!

 * Layer1: A 3rd party low level GUI library (owned by the python
community) that will be the base from which to build the cake.  A Gui
library that carries the torch of true 21st century GUI's look and
feel, and widgets! (aka: lots of C code here).

 * Layer2: An abstraction of Layer1 (written in 100% python) for the
python std library. (think "PythonGUI")

 * Layer3: A Graphical GUI builder front end for this expansive and
beautiful library (so the kids can play along too).

Yes, i DID mention a Graphical Builder. Even though i'd never use one,
i DO realize the importance of such tools to this community.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why isn't there a good RAD Gui tool for python

2011-07-11 Thread Billy Mays

On 07/11/2011 02:59 PM, Elias Fotinis wrote:

On Mon, 11 Jul 2011 20:11:56 +0300, Stefan Behnel 
wrote:


Just a quick suggestion regarding the way you posed your question. It's
usually better to ask if anyone knows a good tool to do a specific job
(which you would describe in your post), instead of complaining about
there
being none.


Opinion is divided on this… 



There is another way: http://bash.org/?684045
--
http://mail.python.org/mailman/listinfo/python-list


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

2011-07-11 Thread Chris Angelico
On Tue, Jul 12, 2011 at 4:52 AM, rantingrick  wrote:
> As we all know you only need three types of geometry management:
>  * Linear (horizontal&vertical)
>  * Grid
>  * Absolute
>

I contend that Absolute is unnecessary and potentially dangerous. Grid
and Box (linear) are the most flexible, but there are others that come
in handy too. GTK has quite a few [1] including a scrollable, a
notebook, hor/vert panes (where the user can adjust the size between
the two panes), and so on.

Once again, Ranting Rick is asking for all tools to be destroyed
except his preferred minimal set. I think this strongly suggests that
Rick is, in point of fact, either brain something'd (keeping this
G-rated) or an orangutan, because the ultimate end of his logic is
coding in either Brain-*[2] or Ook [3].

ChrisA

[1] http://developer.gnome.org/gtk3/stable/LayoutContainers.html
[2] http://www.muppetlabs.com/~breadbox/bf/
[3] http://www.dangermouse.net/esoteric/ook.html
-- 
http://mail.python.org/mailman/listinfo/python-list


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

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

On 2011.07.11 02:16 PM, Chris Angelico wrote:
> You think Microsoft makes decisions and sticks with them? Look at 
> Office's last few versions. They can't decide on a file format, an 
> interface, a featureset... everything keeps changing.
Of course they do. They've decided to change things in each major
version to give people a reason to pay for the new version when there's
nothing wrong with the old one (at least nothing that's been fixed in
the new version :P ). Of course, MS is not the only software company
that employs such a strategy...

- -- 
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/

iQEcBAEBAwAGBQJOG1ORAAoJEPiOA0Bgp4/LF7oH/Al6RTGIQ2hAKztEiob/oXnz
+eV8HZ0K+OBpd/FtRBkiMTJaQm5LU1jKPdwsf/RhF7UU69FfCQNfhzW5LsdMMQYE
+lh4YwbJ8cXVEkCgdkf2zh7BElJ9/95nYedd64Ev4sG+QECvLFYoeql5mjcO45S9
V+iElE9y4FsPr1E0tC2BhFPQuiRMRIIOjQQ7UKP28dnIOKf6u9QM4UdN4WYKOy+n
jgXRaFtstA3YtbzqmKfVoj9Go8SstF71XnGjSzAQeq4j96IfbvW/PTaPhkvyfB7y
tHG861oW19orvZ1ESJue/lvd/KQ7rRDRn7IjH+fKvKuYlgjM3+Q7hR7hcXi97Wg=
=a5A/
-END PGP SIGNATURE-
-- 
http://mail.python.org/mailman/listinfo/python-list


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

2011-07-11 Thread sturlamolden
On 11 Jul, 20:28, Ivan Kljaic  wrote:

> To summarize it. It would be very helpfull for python to spread if
> there qould be one single good rad gui builder similar to vs or
> netbeAns but for python. So right now if i need to make a gui app i
> need to work with an applicatio that is dicontinued for the last 5
> years is pretty buggy but is ok.

http://wxformbuilder.org/

Shut up.


> The ony worthly ones mentioning as an gui builder are boa constructor
> fo wx, qtDesigner with the famous licence problems why companies do
> not want to work with it, sharpdevelop for ironpython and netbeans for
> jython.
> Did you notice that 2 of these 4 are not for python? One is out of dTe
> and one has a fucked up licence.


Qt and PySide have LGPL license. QtCreator can be used with Python
(there is a Python uic).

SharpDevelop has an IronPython GUI builder.

Boa Constructor is abandonware, yes.


Is it just me, or did I count to three?

And yes, you forgot:

Visual Studio for IronPython
wxGLADE for wxPython
GLADE for PyGTK
BlackAdder for Python and Qt
SpecTcl for Tkinter

That's eight.




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


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

2011-07-11 Thread sturlamolden
On 11 Jul, 21:58, sturlamolden  wrote:

> That's eight.

Sorry, nine ;)
-- 
http://mail.python.org/mailman/listinfo/python-list


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

2011-07-11 Thread sturlamolden
On 11 Jul, 20:28, Ivan Kljaic  wrote:

> The ony worthly ones mentioning as an gui builder are boa constructor
> fo wx, qtDesigner with the famous licence problems why companies do
> not want to work with it, sharpdevelop for ironpython and netbeans for
> jython.

There is wxFormBuilder for wxPython, I suppose you've missed it. Of
three GUI builders for wxPython (wxFormBuilder, wxGLADE, Boa
Constructor), you managed to pick the lesser.

The license for Qt is LGPL, the same as for wxWidgets. Both have LGPL
Python bindings (PySide and wxPython), so why is Qt's license more
scary than wxWidgets?

I have an idea why you think QtCreator cannot be used with Python. If
you had actually used it, you would have noticed that the XML output
file can be compiled by PyQt and PySide.

SharpDevelop for IronPython means you've missed Microsoft Visual
Studio. Bummer.

And I am not going to mention IBM's alternative to NetBeans, as I am
sure you can Google it.

And did you forget abpout GLADE, or do you disregard GTK (PyGTK) as a
toolkit completely?


Regards,
Sturla



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


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

2011-07-11 Thread cjrh
On Monday, 11 July 2011 00:50:31 UTC+2, Ivan Kljaic  wrote:
> But seriously. Why is the not even one single RAD tool
> for Python. I simply do not see any reasons why there isn't anything.
> Please help me understand it. Any insights?

The set of reasons that nobody else has made one is *exactly* the same set of 
reasons that you're not going to make one.  Note that if you prove me wrong, 
and make one, I still win ;)

I am in the somewhat interesting position of having worked continuously with 
both Python and Delphi (yes, formerly by Borland) for the last decade.  I like 
to think I use both languages/tools idiomatically.   I used to lament not 
having a GUI builder like the Delphi IDE for Python, but I don't any more.  Use 
the right tool for the job, and all that old-timer stuff is starting to make 
sense.
-- 
http://mail.python.org/mailman/listinfo/python-list


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

2011-07-11 Thread sturlamolden
On 11 Jul, 21:58, sturlamolden  wrote:

> http://wxformbuilder.org/


This Demo is using C++, it works the same with Python (wxPython code
is generated similarly).

http://zamestnanci.fai.utb.cz/~bliznak/screencast/wxfbtut1/wxFBTut1_controller.swf



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


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

2011-07-11 Thread Kevin Walzer

On 7/11/11 2:28 PM, Ivan Kljaic wrote:

Did you notice that 2 of these 4 are not for python? One is out of dTe
and one has a fucked up licence. Sorry guys but there is not even one
single rad gui tool for python as long as there is no serious
guibuilder.


One reason there hasn't been much demand for a GUI builder is that, in 
many cases, it's just as simpler or simpler to code a GUI by hand. 
Certainly with the Tkinter library this is trivial. The only GUI builder 
I've ever used that was arguably superior to hand-coding is Interface 
Builder, on Mac OS X, and it's truly needed there. (The Cocoa frameworks 
don't really lend themselves to hand-coding.) Otherwise I find GUI 
builders inflexible, and more trouble than they are worth.


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


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

2011-07-11 Thread sturlamolden
On 11 Jul, 22:35, Kevin Walzer  wrote:

> One reason there hasn't been much demand for a GUI builder is that, in
> many cases, it's just as simpler or simpler to code a GUI by hand.

Often a GUI builder is used as a bad replacement for sketch-pad and
pencil.

With layout managers (cf. wxWidgets, Qt, Swing, SWT, Tkinter) it is
easier to "sketch and code" than with common MS Windows toolkits (eg.
MFC, .NET Forms, Visual Basic, Delphi) which use absolute positioning
and anchors. Using a GUI builder with layout managers might actually
feel awkward. But with absolute positioning and anchors, there is no
way to avoid a GUI builder. That said, we have good GUI builders for
all the common Python GUI toolkits.

Sometimes a mock-up GUI designer like DesignerVista might help.

Yes, and actually hiring a graphical designer helps too.


Sturla

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


Re: perceptron feed forward neural networks in python

2011-07-11 Thread sturlamolden
On 11 Jul, 20:47, Ken Watford  wrote:
> On Mon, Jul 11, 2011 at 2:31 PM, Igor Begić  wrote:
> > Hi,
> > I,m new to Python and i want to study and write programs about perceptron
> > feed forward neural networks in python. Does anyone have a good book or link
> > for this?
>
> Try Stephen Marsland's "Machine Learning: An Algorithmic Perspective".
> All example code is done in Python, and there's a chapter on
> multilayer perceptrons.
>
> The code for the book is available online 
> here:http://www-ist.massey.ac.nz/smarsland/MLbook.html


This is quite simple with tools like NumPy and SciPy. E.g. use
numpy.dot (level-3 BLAS matrix multiply) for the forward pass, and
scipy.optimize.leastsq (MINPACK Levenberg-Marquardt) for the training.

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


Re: Virtual functions are virtually invisible!

2011-07-11 Thread rantingrick
On Jul 11, 9:41 am, Chris Angelico  wrote:
> On Mon, Jul 11, 2011 at 11:42 PM, rantingrick  wrote:
> > This mandate must be handed down from the gods who reside on "Mount
> > REFUSE-E-OUS to RECOGNIZE-E-OUS a major PROBLEM-O-MOUS"
>
> I assume you're trying to reference Mount Olympus where the Greek gods
> live, but I'm left thinking more of Mount Vesuvius... possibly not the
> best reference for what you're saying.


Actually no i was purposely implying Mt. Vesuvius. You know, the
VOLCANO that erupted and left poor Pompeii in ruins? Here is some text
from the wiki verbatim:

"""Mount Vesuvius is best known for its eruption in AD 79 that led to
the burying and destruction of the Roman cities of Pompeii and
Herculaneum. They were never rebuilt, although surviving townspeople
and probably looters did undertake extensive salvage work after the
destructions."""


I modified the text "slightly" to reflect our current conundrum:

"""Guido and Pydev are best known for their absence around 2000, which
led to the burying and destruction of comp.lang.Python (and the
community as a whole) in ash clowns. They were never rebuilt, although
a few surviving "good" townspeople did undertake extensive attacks
from trolls after the destruction."""
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Function docstring as a local variable

2011-07-11 Thread Carl Banks
On Sunday, July 10, 2011 4:06:27 PM UTC-7, 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?

It prints the module docstring, same as your example does.  You did realize 
that was the question I was answering, right?


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


Re: How to compile on OS X PPC? was: Re: [RELEASED] Python 3.2

2011-07-11 Thread Ned Deily
In article ,
 Ned Deily  wrote:
> In article <4d640175$0$81482$e4fe5...@news.xs4all.nl>,
>  Irmen de Jong  wrote:
> > However, I'm having trouble compiling a framework build from source on 
> > Mac OS 10.5.8 on PowerPC.  No matter what I try (gcc 4.0, gcc 4.2, 
> > different compiler options), the compilation aborts with the following 
> > error:
> > 
> > Undefined symbols:
> >"___fixdfdi", referenced from:
> >_rlock_acquire in libpython3.2m.a(_threadmodule.o)
> >_lock_PyThread_acquire_lock in libpython3.2m.a(_threadmodule.o)
> >"___moddi3", referenced from:
> >_PyThread_acquire_lock_timed in libpython3.2m.a(thread.o)
> >_acquire_timed in libpython3.2m.a(_threadmodule.o)
> >"___divdi3", referenced from:
> >_PyThread_acquire_lock_timed in libpython3.2m.a(thread.o)
> >_acquire_timed in libpython3.2m.a(_threadmodule.o)
> > ld: symbol(s) not found
> > /usr/bin/libtool: internal link edit command failed
> 
> Unfortunately, this is a variation of an old issue that hasn't yet been 
> fixed (http://bugs.python.org/issue1099).

UPDATE:  this problem has been fixed in the newly-release Python 3.2.1.  
On a 10.4 or 10.5 PPC machine, you should now be able to successfully 
build a PPC-only 3.2 framework with just:

./configure --enable-framework ; make

On 10.5, you may want to use:
 
./configure --enable-framework  MACOSX_DEPLOYMENT_TARGET=10.5 ; make

-- 
 Ned Deily,
 n...@acm.org

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


Read SAS files with Python?

2011-07-11 Thread Jones, Rebecca
Apologies in advance if this is already a time-worn question!

 

We are essentially a "SAS shop" and use Base SAS, Enterprise Guide and
E-Miner for statistical and predictive modeling purposes, often working
on big datasets (30M rows of 100+ columns).  There are some applications
for which we have had to craft Python solutions, such as interfacing
with ArcView to automate the generation of map overelays from
shapefiles, but the vast majority of our work is well-handled by our SAS
suite.

 

However, in the interest of expanding our skillset (and hedging our
bets), we are investigating whether anyone has yet developed a Python
module that can read SAS datasets directly?

 

Thank you!

 

RJones 

 

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


Re: Problem compiling Python 3.2 in 32bit on Snow Leopard

2011-07-11 Thread Ned Deily
In article ,
 Ned Deily  wrote:
> In article <8t5vunfca...@mid.individual.net>,
>  Gregory Ewing  wrote:
> > Attempting to compile Python 3.2 in 32-bit mode
> > on MacOSX 10.6.4 I get:
> > 
> > Undefined symbols:
> >"___moddi3", referenced from:
> >_PyThread_acquire_lock_timed in libpython3.2m.a(thread.o)
> >_acquire_timed in libpython3.2m.a(_threadmodule.o)
> >"___divdi3", referenced from:
> >_PyThread_acquire_lock_timed in libpython3.2m.a(thread.o)
> >_acquire_timed in libpython3.2m.a(_threadmodule.o)
> > ld: symbol(s) not found
> > /usr/bin/libtool: internal link edit command failed
> > 
> > Any suggestions?
> 
> http://article.gmane.org/gmane.comp.python.general/685151

UPDATE:  this problem has been fixed in the newly-released Python 3.2.1.   
On OX X 10.6, you should be able to build a 10.6 32-bit-only framework 
with:

./configure --enable-framework CFLAGS="-arch i386"  \
LDFLAGS="-arch i386" MACOSX_DEPLOYMENT_TARGET=10.6

-- 
 Ned Deily,
 n...@acm.org

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


Re: Newbie help - Programming the Semantic Web with Python

2011-07-11 Thread Bruce Whealton
This didn't seem to work either.  I was getting errors the number of 
arguments expected being two, when I changed to

def add (self, args):
I seem to remember that if I removed the parentheses around sub, pred, obj, 
it worked.  I thought that was how it worked.  What is strange is that this 
is not reported as an error on the books page.  So, it should have worked as 
is with either Python 2.7, which I have installed or Python 3.0 which I also 
have installed.  So, it seems like it would have worked as is for one of the 
versions of Python, but it doesn't seem to work that way.
I'll paste a link to where the code exists.  Could someone help me figure it 
out please.  The code is here on the site:

http://semprog.com/content/the-book/

I wonder if I can also try it out from the IDLE interactive session.
Thanks,
Bruce

On Sun, Jul 10, 2011 at 11:32 AM, Bruce Whealton  
wrote:

problem with is this line:

def add(self, (sub, pred, obj)):
I think the problem is with the parentheses before the sub.  I removed 
those and that seemed to fix that error or make it go away.  I don’t 
remember how I figured that out,   It should be on the Errata page for 
sure.

Then it has a problem with this line:
print list(g.triples((None, None, None)))
If I was using python 3, it would require () around the thing that is 
going to be printed, right?  Maybe python 2.7 doesn’t like this line for 
the same reason.




The issue there is with tuple unpacking. To match the older syntax,
don't touch the call, but change the definition thus:
def add(self, args):
 (sub, pred, obj)=args

Or, of course, simply list the arguments directly, rather than in a
tuple; but that requires changing every call (if it's a small program
that may not be a problem).

You're right about needing parentheses around the print() call; in
Python 2 it's a statement, but in Python 3, print is a function like
any other.

Regarding the module search path, this may help:
http://docs.python.org/dev/tutorial/modules.html#the-module-search-path

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


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


Re: perceptron feed forward neural networks in python

2011-07-11 Thread Igor Begić
thx,
bye

On Mon, Jul 11, 2011 at 8:47 PM, Ken Watford wrote:

> On Mon, Jul 11, 2011 at 2:31 PM, Igor Begić  wrote:
> > Hi,
> > I,m new to Python and i want to study and write programs about perceptron
> > feed forward neural networks in python. Does anyone have a good book or
> link
> > for this?
>
> Try Stephen Marsland's "Machine Learning: An Algorithmic Perspective".
> All example code is done in Python, and there's a chapter on
> multilayer perceptrons.
>
> The code for the book is available online here:
> http://www-ist.massey.ac.nz/smarsland/MLbook.html
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: parsing packets

2011-07-11 Thread Dan Stromberg
On Mon, Jul 11, 2011 at 5:05 AM, Thomas Rachel <
nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa...@spamschutz.glglgl.de> wrote:

> Am 10.07.2011 22:59 schrieb 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.
>>
>
> Are these packets sent as separate UDP packets or embedded in a TCP stream?
> In the first case, you already have packets and only have to parse them. In
> a stream, you first have to split them up.
>

Aren't UDP packets subject to fragmentation and aggregation?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: parsing packets

2011-07-11 Thread Dan Stromberg
On Sun, Jul 10, 2011 at 1: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.
>

I like to use this module (I wrote while in the employ of UCI, so it's under
a UCI - BSDesque - license, but they've given redistribution permission so
long as the module is under their license) to extract pieces from a data
source with varied field lengths:

http://stromberg.dnsalias.org/~dstromberg/bufsock.html


I use it often with TCP.  For UDP, I'd probably catentate the blocks
recieved and then pull data back out of the aggregate using bufsock - to
deal with the possibility of fragmentation or aggregation in transit.
-- 
http://mail.python.org/mailman/listinfo/python-list


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

2011-07-11 Thread Dave Cook
On 2011-07-10, Ivan Kljaic  wrote:
> 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.

I prefer spec-generators (almost all generate XML these days) like
QtDesigner to code-generators like Boa. I've only seen one good
argument for code generation, and that's to generate code for a layout
to "see how it's done".  But code could always be generated
automatically from a spec.

I already have an editor I like, I don't see the need to tie GUI
layout to a code editor.  If you want something with more
sophisticated Python specific features, there's PyDev.

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


Re: An interesting beginner question: why we need colon at all in the python language?

2011-07-11 Thread Dan Stromberg
On Mon, Jul 11, 2011 at 8:28 AM, Ian Kelly  wrote:

> On Mon, Jul 11, 2011 at 8:50 AM, Sébastien Volle
>  wrote:
> > Could it have been made optional, like the trailing comma in list
> > declaration?
>
> Cobra makes the colons optional, so probably yes.
> --
> http://mail.python.org/mailman/listinfo/python-list
>

A little redundancy in a computer language facilitates error checking - much
like the bits of redundancy in one's English make written and voice
communication less error prone.

But strictly speaking, the colon could've been left out.
-- 
http://mail.python.org/mailman/listinfo/python-list


Please Help with vertical histogram

2011-07-11 Thread Cathy James
Please kindly help- i have a project where I need to plot dict results
as a histogram. I just can't get the y- axis to print right.  May
someone please help?  I have pulled my hair for the past two weeks, I
am a few steps ahead, but stuck for now.


def histo(his_dict = {1:16, 2:267, 3:267, 4:169, 5:140, 6:112, 7:99,
8:68, 9:61, 10:56, 11:35, 12:13, 13:9, 14: 7, 15:2}):

x_max = 17 #get maximum value of x
y_max = 400 #get minimum value of y
# print each line
print ('^')
for j in range(y_max, 0, -100):# draw

s = '|'
for i in range(1, x_max):
if i in his_dict.keys() and his_dict[i] >= j:
s += '***'
else:
s += '   '
print (s)
print (j)
# print x axis
s = '+'
for i in range(1, x_max):
s += '-+-'
s += '>'
print (s)

# print indexes
s = ' '
for i in range(1, x_max):
s += ' %d ' % i
print (s)

histo()

# I need it to look like this:
400 -|
   |
   |
   |
   |
300 -|
   |
   |   **
   |   **
   |   **
200 -|   **
   |   **
   |   *
   |   
   |   
100 -|   ***
   |   **
   |   
   |   ***
   |*
0 -+-+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+-
   | 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16
-- 
http://mail.python.org/mailman/listinfo/python-list


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

2011-07-11 Thread Gregory Ewing

Chris Angelico wrote:

either brain something'd (keeping this
G-rated) or an orangutan,


There's a certain librarian who might take issue with your
lumping orangutans in with the brain-something'd...

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


Re: Please Help with vertical histogram

2011-07-11 Thread Dan Stromberg
I have a histogram script in Python at
http://stromberg.dnsalias.org/svn/histogram/trunk/  It's under a UCI
(BSD-like) license.  Feel free to use it or borrow ideas from it.

On Mon, Jul 11, 2011 at 5:42 PM, Cathy James  wrote:

> Please kindly help- i have a project where I need to plot dict results
> as a histogram. I just can't get the y- axis to print right.  May
> someone please help?  I have pulled my hair for the past two weeks, I
> am a few steps ahead, but stuck for now.
>
>
> def histo(his_dict = {1:16, 2:267, 3:267, 4:169, 5:140, 6:112, 7:99,
> 8:68, 9:61, 10:56, 11:35, 12:13, 13:9, 14: 7, 15:2}):
>
>x_max = 17 #get maximum value of x
>y_max = 400 #get minimum value of y
># print each line
>print ('^')
>for j in range(y_max, 0, -100):# draw
>
>s = '|'
>for i in range(1, x_max):
>if i in his_dict.keys() and his_dict[i] >= j:
>s += '***'
>else:
>s += '   '
>print (s)
>print (j)
># print x axis
>s = '+'
>for i in range(1, x_max):
>s += '-+-'
>s += '>'
>print (s)
>
># print indexes
>s = ' '
>for i in range(1, x_max):
>s += ' %d ' % i
>print (s)
>
> histo()
>
> # I need it to look like this:
> 400 -|
>   |
>   |
>   |
>   |
> 300 -|
>   |
>   |   **
>   |   **
>   |   **
> 200 -|   **
>   |   **
>   |   *
>   |   
>   |   
> 100 -|   ***
>   |   **
>   |   
>   |   ***
>   |*
>0 -+-+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+-
>   | 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16
> --
> 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-11 Thread Ben Finney
Ivan Kljaic  writes:

> My comPany would switch to python but they complained that there is
> not even one single gui builder or framework that can allow it to make
> a living from it.

That response from your company is a non sequitur. What does “one single
gui builder or framework” have to do with “allow it to make a living
from it”?

Evidently many organisations are making a living with Python, so that
statement is just false.

> For how many years are this vui library wars going on. How many.

Why see it as a war that must have one clear winner? You have options.

> I am a open source supporter but Windows will always kick the ass of
> open source because the open source comunity can not make a decision.

Different people make different decisions. If you want a monolithic
organisation that makes a single decision for everyone, you don't want
software freedom.

> To summarize it. It would be very helpfull for python to spread

Please find a different language to “fix”; Python is spreading quite
successfully.

-- 
 \  “I don't like country music, but I don't mean to denigrate |
  `\  those who do. And for the people who like country music, |
_o__)denigrate means ‘put down’.” —Bob Newhart |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Finding duplicated photo

2011-07-11 Thread Kevin Zhang
On Mon, Jul 11, 2011 at 10:50 PM, Fulvio  wrote:
>
>
> I found that isn't python 3 code :(
>
> It's written in python 2.6.


> Then the code should go into some other program to allow actions on those
> pictures which are matching each other. Am I right?
>
> The leverages PIL to get the job done.

The performance from PIL's quite poor, though not precisely measured, most
of the time was
spent on resizing pictures with PIL.
-- 
http://mail.python.org/mailman/listinfo/python-list


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

2011-07-11 Thread sturlamolden
On 12 Jul, 01:33, Dave Cook  wrote:

> I prefer spec-generators (almost all generate XML these days) like
> QtDesigner to code-generators like Boa. I've only seen one good
> argument for code generation, and that's to generate code for a layout
> to "see how it's done".  But code could always be generated
> automatically from a spec.

wxFormBuilder will produce C++, Python and XML. Pick the one you like!

The advantage of using XML in tools like GLADE, QtCreator, and more
recently Visual C#, is separation of layout and program logic. The
problem with code generators like Visual C++ or Delphi was the mixing
of generated and hand-written code.

However, there is no real advantage over using XML instead of C++ or
Python: C++ and Python code are also structured text. One structured
text is as good as another: "There once was a man who had a problem.
He said: 'I know, I will use XML.' Now he had two problems."

When using wxFormBuilder, the generated .cpp, .h, .py or .xrc files
are not to be edited.

To write event handlers, we inherit from the generated classes. Thus,
program view (generated code) and program control (hand-written code)
are kept in separate source files.

Because C++ and Python have multiple inheritance, we can even separate
the program control into multiple classes. What we instantate is a
class that inherit the designed dialog class (generated) and event
handler classes (hand-written).

Therefore, XML has no advantage over Python in the case of
wxFormBuilder. XML just adds a second layer of complexity we don't
need: I.e. not only must we write the same program logic, we must also
write code to manage the XML resources. Hence, we are left with two
problems instead of one.

This is not special for wxFormBuilder: In many cases when working with
Python (and to somewhat lesser extent C++), one is left to conclude
that XML serves no real purpose.

Sturla




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


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

2011-07-11 Thread sturlamolden
On 12 Jul, 01:33, Dave Cook  wrote:

> I prefer spec-generators (almost all generate XML these days) like
> QtDesigner to code-generators like Boa. I've only seen one good
> argument for code generation, and that's to generate code for a layout
> to "see how it's done".  But code could always be generated
> automatically from a spec.

wxFormBuilder will produce C++, Python and XML. Pick the one you like!

The advantage of using XML in tools like GLADE, QtCreator, and more
recently Visual C#, is separation of layout and program logic. The
problem with code generators like Visual C++ or Delphi was the mixing
of generated and hand-written code.

However, there is no real advantage over using XML instead of C++ or
Python: C++ and Python code are also structured text. One structured
text is as good as another: "There once was a man who had a problem.
He said: 'I know, I will use XML.' Now he had two problems."

When using wxFormBuilder, the generated .cpp, .h, .py or .xrc files
are not to be edited.

To write event handlers, we inherit from the generated classes. Thus,
program view (generated code) and program control (hand-written code)
are kept in separate source files.

Because C++ and Python have multiple inheritance, we can even separate
the program control into multiple classes. What we instantate is a
class that inherit the designed dialog class (generated) and event
handler classes (hand-written).

Therefore, XML has no advantage over Python in the case of
wxFormBuilder. XML just adds a second layer of complexity we don't
need: I.e. not only must we write the same program logic, we must also
write code to manage the XML resources. Hence, we are left with two
problems instead of one.

This is not special for wxFormBuilder: In many cases when working with
Python (and to somewhat lesser extent C++), one is left to conclude
that XML serves no real purpose.

Sturla




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


Re: Lisp refactoring puzzle

2011-07-11 Thread Xah Lee

2011-07-11

On Jul 11, 6:51 am, jvt  wrote:
> I might as well toss my two cents in here.  Xah, I don't believe that
> the functional programming idiom demands that we construct our entire
> program out of compositions and other combinators without ever naming
> anything.  That is much more the province of so-called "function-
> level" programming languages like APL/J and to a more limited extent
> concatenative languages where data (but not code) is mostly left
> without names.
>
> Functional programming, in my mind, is about identifying reproducibly
> useful abstractions, _naming them_, and constructing other
> abstractions from them.  Your piece of code above probably needs to be
> factored out into named pieces so that the composition is more
> sensible.  If a piece of code isn't comprehensible, it might be
> because it isn't using the right abstractions in the right way, not
> because the notion of functional programming is itself problematic.
>
> One might instead provide a nightmare nest of procedural code and
> claim that procedural programming has problems. Of course, this
> particular kind of problem might be less common in procedural code,
> since it depends heavily on naming and side effecting values, but it
> isn't hard to find procedural code with a long list of operations and
> namings wherein the chose names are random or otherwise unrelated to
> the problem domain.  My adviser in grad school used to name variables
> after pieces of furniture in dutch, but that didn't cause me to
> impeach the _notion_ of procedural code.

hi jvt,

of course, you are right. But i wasn't criticising functional
programing in anyway.

was just putting out my tale as a caution, to those of us — e.g.
academic scheme lispers and haskell types — who are perpetually
mangling their code for the ultimate elegant constructs.

but speaking on this now... as you guys may know, i was a naive master
of Mathematica while being absolute illiterate in computer science or
any other lang. (see 〈Xah Lee's Computing Experience (Impression Of
Lisp from Mathematica)〉 @ 
http://xahlee.org/PageTwo_dir/Personal_dir/xah_comp_exp.html
) When i didn't know anything about lisp, i thought lisp would be
similar, or even better, as a highlevel lang in comparison to
Mathematica. In retrospect now, i was totally wrong.

lisp, or scheme lisp, is a magnitude more highlevel in comparison to C
or C derivatives such as C++, Java. However, in comparison to
Mathematica, it's one magnitude low level. (it pains me to see lisp
experts here talking about cons and macros all day, even bigshot names
such as one Paul Graham and in lisp books praising lisp macros. Quite
ridiculous.)

over the years, i had curiosity whether perhaps ML/OCaml, Haskell,
would be equivalent high-level as Mathematica as i thought.
Unfortunately, my study of them didn't went far. (best result is my
incomplete 〈OCaml Tutorial〉 @ http://xahlee.org/ocaml/ocaml.html ) Am
not qualified to comment on this, but i think that even Haskell,
OCaml, are still quite low in comparison to Mathematica.

it's funny, in all these supposedly modern high-level langs, they
don't provide even simple list manipulation functions such as union,
intersection, and the like. Not in perl, not in python, not in lisps.
(sure, lib exists, but it's a ride in the wild) It's really
exceedingly curious to me. And it seems that lang authors or its
users, have all sorts of execuse or debate about whether those should
be builtin if you force them to answer. (i.e. they don't get it)
While, we see here regularly questions about implementing union etc
with follow up of wild answers and re-invention the thousandth time.
Of course, Mathematica has Union, Intersection, and a host of others
some 20 years ago, and today it has a complete set of combinatorics
functions as *builtin* functions (as opposed to add-on libs of second-
rate quality). (this is not a question. No need to suggest some
possible reasons why lang might not want to have a whole set of list
manipulation builtin. You (the lisper/python/perl regulars and other
lang fans) are a complete idiot, that's what i'm saying. COMPLETE
IDIOT. (actually, this is not surprising, since genius and true
thinkers are rare and few. (such as myself. As they say, beyond the
times)))

i also wondered, if Mathematica is truely a magnitude higher level
than lisp, why we don't see any computer scientists talk about it? (of
course there are, but almost non-existant in comparison to, say,
academic publications on Scheme, Haskell, even Java) I think the
reason is social, again. Proprietary langs isn't a revue of
academicians, together with the fact that Stephen Wolfram goes about
as if the entire science of computer science comprises of himself.

Want Mathematica? Pay $2k+.

recently i spent several days studying and watching a talk by Douglas
Crockford.  it is incredible. He went thru history, and explained, how
it is the very people in computing community who laughed and stifled
all th

Questions about os.waitpid(pid, options) on windows

2011-07-11 Thread Fan
It seems that waitpid take process handle instead of process id as the
first parameter on Windows.  On Unices platform, the first parameter
is process id.

This interface is a little bit confusing. What's the purpose for such
a design?

Thanks a lot,
Fan
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why isn't there a good RAD Gui tool for python

2011-07-11 Thread Hansmeet Singh
lol isnt billy mays dead

On 7/11/11, Billy Mays  wrote:
> On 07/11/2011 02:59 PM, Elias Fotinis wrote:
>> On Mon, 11 Jul 2011 20:11:56 +0300, Stefan Behnel 
>> wrote:
>>
>>> Just a quick suggestion regarding the way you posed your question. It's
>>> usually better to ask if anyone knows a good tool to do a specific job
>>> (which you would describe in your post), instead of complaining about
>>> there
>>> being none.
>>
>> Opinion is divided on this… 
>>
>
> There is another way: http://bash.org/?684045
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Python bug? Indexing to matrices

2011-07-11 Thread David
Should the following line work for defining a matrix with zeros?

c= [[0]*col]*row

where "col" is the number of columns in the matrix and "row" is of
course the number of rows.

If this a valid way of initializing a matrix in Python 3.2.1, then it
appears to me that a bug surfaces in Python when performing this line:

c[i][j] = c[i][j] + a[i][k] * b[k][j]

It writes to the jth column rather than just the i,j cell.

I'm new at Python and am not sure if I'm just doing something wrong if
there is really a bug in Python.  The script works fine if I
initialize the matrix with numpy instead:

c = np.zeros((row,col))

So, I know my matrix multiply algorithm is correct (I know I could use
numpy for matrix multiplication, this was just to learn Python).

I've attached my source code below.

TIA,

David

-

#!python
#   dot.py - Matrix multiply in matricies: [c] = [a] * [b]

import numpy as np

a = [[3, 7], [-2, 1], [2, 4]]
b = [[2, 1, -3, 1], [4, 3, -2, 3]]

print("a = {0}, b = {1}".format(a,b))


row = len(a)
col = len(b[0])

#c = np.zeros((row,col))# <- Correct results when using this
line
c= [[0]*col]*row# <- Incorrect results when using
this line
print(c)

for i in range(row):# Index into rows of [a]
for j in range(col):# Index into columns of [b]
c[i][j] = 0

for k in range(len(b)): # Index into columns of [a] and 
rows of [b]
print("c[{0}][{1}] + a[{2}][{3}] * b[{4}][{5}] = {6} + 
{7} *
{8}".format(i,j,i,k,k,j,c[i][j],a[i][k],b[k][j]))
c[i][j] = c[i][j] + a[i][k] * b[k][j]

print(c)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python bug? Indexing to matrices

2011-07-11 Thread Chris Rebert
On Mon, Jul 11, 2011 at 10:39 PM, David  wrote:
> Should the following line work for defining a matrix with zeros?
>
> c= [[0]*col]*row
>
> where "col" is the number of columns in the matrix and "row" is of
> course the number of rows.

Nope. See the FAQ:
http://docs.python.org/faq/programming.html#how-do-i-create-a-multidimensional-list

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


Re: Please Help with vertical histogram

2011-07-11 Thread Thorsten Kampe
* Cathy James (Mon, 11 Jul 2011 19:42:10 -0500)
> Please kindly help- i have a project where I need to plot dict results
> as a histogram. I just can't get the y- axis to print right. May
> someone please help? I have pulled my hair for the past two weeks, I
> am a few steps ahead, but stuck for now.

This sounds like homework. There's the Python Tutor mailing list where 
you will receive help.

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


Re: Python bug? Indexing to matrices

2011-07-11 Thread Ben Finney
David  writes:

> Should the following line work for defining a matrix with zeros?
>
> c= [[0]*col]*row

No. Python lists are not matrixes and are not arrays.

If you want good implementations of arrays and matrices, use NumPy
http://numpy.scipy.org/>.

-- 
 \  “Properly read, the Bible is the most potent force for atheism |
  `\ever conceived.” —Isaac Asimov |
_o__)  |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list