Re: I strongly dislike Python 3

2010-06-27 Thread Lawrence D'Oliveiro
In message , Stefan 
Reich wrote:

> My complaint is about changing the syntax of "print".

I never use print, so I don’t appreciate the problem. It seems to be useful 
only for noddy I/O.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why Is Escaping Data Considered So Magical?

2010-06-27 Thread Ian Kelly
On Sat, Jun 26, 2010 at 8:31 PM, Lawrence D'Oliveiro
 wrote:
> Except I only needed two calls to SQLString, while you need two dozen
> instances of that repetitive items.c boilerplate.
>
> As a human, being repetitive is not my job. That’s what the computer is for.

Then why do you have every parameter prefixed with "modify_"? 8-)

But seriously, if that bothers you, then fold the "items.c." portion
into the generator expression with a getattr call.  Or just change
them back to the same strings you had originally, and sqlalchemy will
be just as happy to accept them as-is.

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


Re: I strongly dislike Python 3

2010-06-27 Thread Martin v. Loewis
> I didn't notice this level of angst when Python made equally significant 
> changes going from 1.5 to 2.0...

I think the *level* was about the same (IIRC). People would say that
they ignore 2.x for years, and that it is important to continue
supporting 1.5.2 for a long time (about until 2.4 was released).

What's different now is the *amount* of angst. That's not surprising:
there is a much larger user community now with investment into Python
2.x, and they are concerned, and worried about the work that they have
to perform.

In addition to your observations: what the 3.x haters fail to recognize
is that the porting effort is actually much smaller than they think it
is. Would they try it out, they'd notice that it didn't take so long,
after all. Of course, porting from 2.x to 3.x is a skill to acquire,
so it gets easier the more you memorize the differences and pitfalls.

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


Re: Why Is Escaping Data Considered So Magical?

2010-06-27 Thread Kushal Kumaran
On Sun, Jun 27, 2010 at 9:47 AM, Lawrence D'Oliveiro
 wrote:
> In message , Roy Smith wrote:
>
>> I recently fixed a bug in some production code.  The programmer was
>> careful to use snprintf() to avoid buffer overflows.  The only problem
>> is, he wrote something along the lines of:
>>
>> snprintf(buf, strlen(foo), foo);
>
> A long while ago I came up with this macro:
>
>    #define Descr(v) &v, sizeof v
>
> making the correct version of the above become
>
>    snprintf(Descr(buf), foo);
>

Not quite right.  If buf is a char array, as suggested by the use of
sizeof, then you're not passing a char* to snprintf.  You need to lose
the & in your macro.

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


2. Re: Python interface problem with Windows (Benjamin Kaplan)

2010-06-27 Thread Kermit Rose

On 6/26/2010 9:30 PM, python-list-requ...@python.org wrote:



Today's Topics:




2. Re: Python interface problem with Windows (Benjamin Kaplan)





> Message: 2
> Date: Sat, 26 Jun 2010 16:26:47 -0700
> From: Benjamin Kaplan 
> To: python-list@python.org
> Subject: Re: Python interface problem with Windows
> Message-ID:
>
> Content-Type: text/plain; charset=ISO-8859-1

> You don't need to save scripts in C:\Python26. In fact, doing so is a
> very bad idea. You should keep the libraries in one place (that would
> be C:\Python26 ) and all of your individual programs somewhere else
> (like your Documents folder) where you don't have to worry if two
> different projects have files of the same name. For security reasons,
> you don't have permission to write to the whole hard drive, just your
> home directory.




I do not know how to import code from any other directory than the 
default, C:\Python26.


And how do I save the code in a different directory than the default, 
c:\Python26?



Kermit Rose





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


Re: 2. Re: Python interface problem with Windows (Benjamin Kaplan)

2010-06-27 Thread rantingrick
On Jun 27, 5:52 am, Kermit Rose  wrote:
> On 6/26/2010 9:30 PM, python-list-requ...@python.org wrote:

> I do not know how to import code from any other directory than the
> default, C:\Python26.

Kermit,

There are a couple of ways to import python modules from various
places. But first create a folder somewhere (like was mentioned
earlier) to keep all your personal modules and scripts in. Now create
a file named "myconfig.pth" and throw it in your main PythonXX folder.
Any paths in this file will be added to the search path of Python
modules. Now you can import from these folders

Also so you will be aware. You can add folders to the python search
path by appending or inserting to the sys.path array.

>>> import sys
>>> print sys.path
[...list of paths here...]
>>> sys.path.append('path\to\some\directory\containing\script.py')
>>> import script.py

There are other ways...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: value of: None is None is None

2010-06-27 Thread Lawrence D'Oliveiro
In message , Alan G Isaac wrote:

> Surprising for a moment, if you don't
> immediatelyrecognize it as a chained comparison.

Bugger. So much for a Python version of this 
, then 
...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why Is Escaping Data Considered So Magical?

2010-06-27 Thread Lawrence D'Oliveiro
In message , Kushal 
Kumaran wrote:

> On Sun, Jun 27, 2010 at 9:47 AM, Lawrence D'Oliveiro
>  wrote:
>
>> In message , Roy Smith wrote:
>>
>>> I recently fixed a bug in some production code.  The programmer was
>>> careful to use snprintf() to avoid buffer overflows.  The only problem
>>> is, he wrote something along the lines of:
>>>
>>> snprintf(buf, strlen(foo), foo);
>>
>> A long while ago I came up with this macro:
>>
>> #define Descr(v) &v, sizeof v
>>
>> making the correct version of the above become
>>
>> snprintf(Descr(buf), foo);
> 
> Not quite right.  If buf is a char array, as suggested by the use of
> sizeof, then you're not passing a char* to snprintf.

What am I passing, then?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I strongly dislike Python 3

2010-06-27 Thread rantingrick

> > P.S. Am I the only one who has never, ever, even *seen* a 'print'
> > statement in non-toy or non-bash-script-style code in any application
> > or even third-party library I looked at? Except, on occasion, for
> > quick and dirty debugging. Perhaps because I'm more used to
> > cross-platform to windows development, where a stray print can
> > actually break the entire application (depending on contexts, if one
> > is run under a service or sometimes even pythonw)

Oh i dunno, these "toys" include print...

C:\Python26\Lib\abc.py
C:\Python26\Lib\aifc.py
C:\Python26\Lib\asyncore.py
C:\Python26\Lib\atexit.py
C:\Python26\Lib\audiodev.py
C:\Python26\Lib\base64.py
C:\Python26\Lib\BaseHTTPServer.py
C:\Python26\Lib\Bastion.py
C:\Python26\Lib\bdb.py
C:\Python26\Lib\calendar.py
C:\Python26\Lib\cgi.py
C:\Python26\Lib\cmd.py
C:\Python26\Lib\code.py
C:\Python26\Lib\collections.py
C:\Python26\Lib\compileall.py
C:\Python26\Lib\Cookie.py
C:\Python26\Lib\cookielib.py
C:\Python26\Lib\copy.py
C:\Python26\Lib\cProfile.py
C:\Python26\Lib\decimal.py
C:\Python26\Lib\difflib.py
C:\Python26\Lib\dis.py
C:\Python26\Lib\doctest.py
C:\Python26\Lib\DocXMLRPCServer.py
C:\Python26\Lib\dummy_thread.py
C:\Python26\Lib\filecmp.py
C:\Python26\Lib\fileinput.py
C:\Python26\Lib\formatter.py
C:\Python26\Lib\fpformat.py
C:\Python26\Lib\ftplib.py
C:\Python26\Lib\getopt.py
C:\Python26\Lib\getpass.py
C:\Python26\Lib\gettext.py
C:\Python26\Lib\gzip.py
C:\Python26\Lib\heapq.py
C:\Python26\Lib\htmllib.py
C:\Python26\Lib\httplib.py
C:\Python26\Lib\ihooks.py
C:\Python26\Lib\imaplib.py
C:\Python26\Lib\imghdr.py
C:\Python26\Lib\imputil.py
C:\Python26\Lib\io.py
C:\Python26\Lib\keyword.py
C:\Python26\Lib\linecache.py
C:\Python26\Lib\locale.py
C:\Python26\Lib\macurl2path.py
C:\Python26\Lib\mailcap.py
C:\Python26\Lib\mhlib.py
C:\Python26\Lib\mimetools.py
C:\Python26\Lib\mimetypes.py
C:\Python26\Lib\mimify.py
C:\Python26\Lib\modulefinder.py
C:\Python26\Lib\netrc.py
C:\Python26\Lib\nntplib.py
C:\Python26\Lib\opcode.py
C:\Python26\Lib\optparse.py
C:\Python26\Lib\os.py
C:\Python26\Lib\pdb.py
C:\Python26\Lib\pickletools.py
C:\Python26\Lib\pipes.py
C:\Python26\Lib\platform.py
C:\Python26\Lib\plistlib.py
C:\Python26\Lib\poplib.py
C:\Python26\Lib\pprint.py
C:\Python26\Lib\profile.py
C:\Python26\Lib\pstats.py
C:\Python26\Lib\pyclbr.py
C:\Python26\Lib\pydoc.py
C:\Python26\Lib\pydoc_topics.py
C:\Python26\Lib\py_compile.py
C:\Python26\Lib\quopri.py
C:\Python26\Lib\random.py
C:\Python26\Lib\rexec.py
C:\Python26\Lib\rfc822.py
C:\Python26\Lib\rlcompleter.py
C:\Python26\Lib\runpy.py
C:\Python26\Lib\sgmllib.py
C:\Python26\Lib\shlex.py
C:\Python26\Lib\SimpleXMLRPCServer.py
C:\Python26\Lib\site.py
C:\Python26\Lib\smtpd.py
C:\Python26\Lib\smtplib.py
C:\Python26\Lib\sndhdr.py
C:\Python26\Lib\SocketServer.py
C:\Python26\Lib\sre_compile.py
C:\Python26\Lib\sre_constants.py
C:\Python26\Lib\sre_parse.py
C:\Python26\Lib\ssl.py
C:\Python26\Lib\string.py
C:\Python26\Lib\StringIO.py
C:\Python26\Lib\stringold.py
C:\Python26\Lib\subprocess.py
C:\Python26\Lib\sunaudio.py
C:\Python26\Lib\symbol.py
C:\Python26\Lib\symtable.py
C:\Python26\Lib\tabnanny.py
C:\Python26\Lib\tarfile.py
C:\Python26\Lib\telnetlib.py
C:\Python26\Lib\textwrap.py
C:\Python26\Lib\this.py
C:\Python26\Lib\threading.py
C:\Python26\Lib\timeit.py
C:\Python26\Lib\tokenize.py
C:\Python26\Lib\trace.py
C:\Python26\Lib\traceback.py
C:\Python26\Lib\unittest.py
C:\Python26\Lib\urllib.py
C:\Python26\Lib\urlparse.py
C:\Python26\Lib\uu.py
C:\Python26\Lib\warnings.py
C:\Python26\Lib\webbrowser.py
C:\Python26\Lib\whichdb.py
C:\Python26\Lib\xmllib.py
C:\Python26\Lib\xmlrpclib.py
C:\Python26\Lib\zipfile.py
C:\Python26\Lib\__future__.py


... just children's toy's i guess ;-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why Is Escaping Data Considered So Magical?

2010-06-27 Thread Lawrence D'Oliveiro
In message , Ian Kelly 
wrote:

> On Sat, Jun 26, 2010 at 8:31 PM, Lawrence D'Oliveiro
>  wrote:
>
>> Except I only needed two calls to SQLString, while you need two dozen
>> instances of that repetitive items.c boilerplate.
>>
>> As a human, being repetitive is not my job. That’s what the computer is
>> for.
> 
> Then why do you have every parameter prefixed with "modify_"? 8-)

Touché :). Actually it’s because the same form can be used to add a new 
record to the table, so there’s a separate set of input fields for that.

> But seriously, if that bothers you, then fold the "items.c." portion
> into the generator expression with a getattr call.  Or just change
> them back to the same strings you had originally, and sqlalchemy will
> be just as happy to accept them as-is.

All this trouble, and it only gets rid of 2 of the 3 instances of data-
escaping in the example.
-- 
http://mail.python.org/mailman/listinfo/python-list


live chat mic +cam freeeeeeeeeeee no dawenlod

2010-06-27 Thread lost2030
http://niceyapchat.blogspot.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


live chat mic +cam freeeeeeeeeeee no dawenlod

2010-06-27 Thread lost2030
http://niceyapchat.blogspot.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: value of: None is None is None

2010-06-27 Thread Thomas Jollans
On 06/27/2010 01:45 PM, Lawrence D'Oliveiro wrote:
> In message , Alan G Isaac wrote:
> 
>> Surprising for a moment, if you don't
>> immediatelyrecognize it as a chained comparison.
> 
> Bugger. So much for a Python version of this 
> , then 
> ...

You mean like
(a <= b < c) if (a <= c) else (b >= a or b < c)
?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I strongly dislike Python 3

2010-06-27 Thread Thomas Jollans
On 06/27/2010 01:46 PM, rantingrick wrote:
> 
>>> P.S. Am I the only one who has never, ever, even *seen* a 'print'
>>> statement in non-toy or non-bash-script-style code in any application
>>> or even third-party library I looked at? Except, on occasion, for
>>> quick and dirty debugging. Perhaps because I'm more used to
>>> cross-platform to windows development, where a stray print can
>>> actually break the entire application (depending on contexts, if one
>>> is run under a service or sometimes even pythonw)
> 
> Oh i dunno, these "toys" include print...

Do your homework properly. I randomly checked a few of these. base64
includes a "Small main program", which is certainly "bash-script-style".
Quite a few of the other files don't use print-the-statement/function at
all, but use "print" as part of an identifier. Your grepping is sloppy,
my friend!

Granted, some use print to emit warnings (aifc for example). This isn't
perfectly clean, of course, but it's not used a whole lot either. Mostly
rather old code too, I think.
And some (abc for example) use print in what looks like internal
diagnostics methods.

That being said, Stephen's statement was very broad, but I think it's
true: print is primarily used in small scripts, or script-like testing
functions/methods.

Thomas

> 
> C:\Python26\Lib\abc.py
> C:\Python26\Lib\aifc.py
>  [ ... ]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python dynamic attribute creation

2010-06-27 Thread Bruno Desthuilliers
WANG Cong a écrit :
> On 06/25/10 15:34, Bruno Desthuilliers 
>  wrote:
> 
>> WANG Cong a écrit :
>>> Hi, list!
>>>
>>> I have a doubt about the design of dynamic attribute creation by
>>> assignments in Python.
>>>
>>> As we know, in Python, we are able to create a new attribute of
>>> a class dynamically by an assignment:
>>>
>> class test: pass
>>> ... 
>> test.a = "hello"
>> test.a
>>> 'hello'
>>>
>>> However, I still don't get the points why Python designs it like this.
>>>
>>> My points are:
>>>
>> (snip)
>>
>> Python's classes are plain objects, and like any other object are
>> created at runtime. Having to special-case them would break the
>> simplicity and uniformity of Python for no good reason. Just like
>> there's no good reason to make setattr() working differently for class
>> and non-class objects.
>>
> 
> For implementaiton, perhaps, but not for the language design, how could
> a language design be perfect if we can use setattr() like assignments
> while use other things, e.g. delattr(), not? Is there any way to express
> delattr() as simple as expressing setattr() with assignments? I doubt...

cf Ethan's answer on this.

> Using assignments to create an attribute hides metaprogramming
> while using delattr() exposes it.

Once again : in Python, none of this is "metaprogramming" - just plain
ordinary programming. So called "metaprogramming" is just an artefact of
static languages where datastructures are created at compile time.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I strongly dislike Python 3

2010-06-27 Thread David Cournapeau
On Sun, Jun 27, 2010 at 4:54 PM, Martin v. Loewis  wrote:
>> I didn't notice this level of angst when Python made equally significant
>> changes going from 1.5 to 2.0...
>
> I think the *level* was about the same (IIRC). People would say that
> they ignore 2.x for years, and that it is important to continue
> supporting 1.5.2 for a long time (about until 2.4 was released).
>
> What's different now is the *amount* of angst. That's not surprising:
> there is a much larger user community now with investment into Python
> 2.x, and they are concerned, and worried about the work that they have
> to perform.
>
> In addition to your observations: what the 3.x haters fail to recognize
> is that the porting effort is actually much smaller than they think it
> is.

I think one point which needs to be emphasized more is what does
python 3 bring to people. The" what's new in python 3 page" gives the
impression that python 3 is about removing cruft. That's a very poor
argument to push people to switch.

I doubt "porting is easier than you think" will convince many people
if they don't know what the gain will be. For example, porting numpy
and scipy to py3k has been easier than I thought, but besides making
it easier for other people to switch, I can't see *any* benefit.
That's bound to frustrate people.


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


Re: Python dynamic attribute creation

2010-06-27 Thread Bruno Desthuilliers
WANG Cong a écrit :
(snip)
> 
> The point is why making metaprogramming easy is wonderful?

Because it makes life easier ?-)

> AND, even if
> it were wonderful, why only this one, i.e. creating attributes by
> assignments, not other things?

Like :

class Test(object):
a = 1

del Test.a

?-)

>>> 2) Metaprogramming should be distinguished with non-meta programming,
>>> like templates in C++, it is obvious to see if you are using template
>>> metaprogramming in C++.
>> Why should it be?
> 
> 
> It is, if you consider other things of metaprogramming in Python. For
> example, deleting an attribute.

cf above.

>>
>>> 3) Thus, allowing dynamic attribute creation by assignment _by default_
>>> is not a good design for me. It is not obvious at all to see if I am
>>> doing metaprogramming at a first glance.
>> Why do you care if you are doing metaprogramming? Perhaps other languages 
>> make it seem difficult and scary, but in Python it is not. It is simple 
>> and easy.
>>
> 
> 
> I do care, programming for a class is quite different from programming
> for a non-class,

Not when a class is just another ordinary object.

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


Re: Python dynamic attribute creation

2010-06-27 Thread Bruno Desthuilliers
WANG Cong a écrit :
> On 06/25/10 17:25, Steven D'Aprano  
> wrote:
> 
>> On Fri, 25 Jun 2010 14:15:12 +0100, WANG Cong wrote:
>>
(snip)
>>> 4) Also, this will _somewhat_ violate the OOP princples, in OOP, this is
>>> and should be implemented by inherence.
>> Perhaps, and perhaps not. But Python has never pretended to slavishly 
>> follow OOP "principles". Python does what works, not necessarily what is 
>> a "pure" design. Python has functional programming, procedural 
>> programming, and OO programming, and happily mixes them all together.
>>
> 
> "Happily mixes them all together" doesn't mean it is elegant. :)

Python has no pretention at "elegance". It's a _very_ practical
language. It's designed to help you get the job done, period.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python dynamic attribute creation

2010-06-27 Thread Bruno Desthuilliers
WANG Cong a écrit :
> On 06/26/10 00:11, Neil Hodgson  wrote:
> 
>> WANG Cong:
>>
>>> 4) Also, this will _somewhat_ violate the OOP princples, in OOP,
>>> this is and should be implemented by inherence.
>>Most object oriented programming languages starting with Smalltalk
>> have allowed adding attributes (addInstVarName) to classes at runtime.
> 
> 
> Thanks, I have to admit that I know nothing about Smalltalk.
> 

Then you really don't know much about OO.

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


Re: I strongly dislike Python 3

2010-06-27 Thread Malte Dik
quote:
> 
> I didn't notice this level of angst when Python made equally significant
> changes going from 1.5 to 2.0... admittedly Python 1.5 code would work
> unchanged in 2.0, but the 2.x series introduced MUCH bigger additions to
> Python than anything 3.0 and 3.1 have added, and anyone taking advantage
> of those changes is implicitly writing code which is not backwards
> compatible.

Maybe the print statement is like the wart of Python. It maybe ugly, but it 
adds character. Could you imagine Lemmy lasered his?

Of course people are angsty that *their* Python might not be the same!


But I can relieve those who are: The interactive command line shell IPython 
delivers an autocompletion where parenthesis for _any_ function may be left 
out. Now, how does that sound? Ruby anyone? ;)


Sincerely,

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


Re: CONTROLLED DEMOLITION INC explosive-charge placement technician Tom ?Sullivan 911 TESTIMONIAL Video

2010-06-27 Thread Juha Nieminen
In comp.lang.c++ nanothermite911fbibustards 
 wrote:
> http://www.ae911truth.org/newsletter/2010/06/index.php#cdi
> 
> Explosive Evidence at WTC Cited by Former CDI Employee
> News - News Releases By AE911Truth
> Written by Darcy Wearing and Richard Gage, AIA
> Thursday, 24 June 2010 18:55

  Could you please take your religion elsewhere and stop spamming newsgroups
that have nothing to do with it? Thanks.
-- 
http://mail.python.org/mailman/listinfo/python-list


latex output

2010-06-27 Thread ilovesss2004
Hi,
The latex print function in sympy only can make latex code for math
expression which includes at least a variable. If we input an
expression without any variable like latex('2**2/3'), we will get
'$1$' instead of '$\\frac{1}{3} 2^{2}$'.

Is there a python package I can use to output latex code for math
expression without variables?

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


Re: Why Is Escaping Data Considered So Magical?

2010-06-27 Thread Nobody
On Sun, 27 Jun 2010 14:36:10 +1200, Lawrence D'Oliveiro wrote:

>> In any case, you're still trying to make arguments about whether it's easy
>> or hard to get it right, which completely misses the point. Eliminating
>> the escaping entirely makes it impossible to get it wrong.
> 
> Except nobody has yet shown an alternative which is easier to get right.

For SQL, use stored procedures or prepared statements. For HTML/XML, use a
DOM (or similar) interface.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I strongly dislike Python 3

2010-06-27 Thread Peter Kleiweg
David Cournapeau schreef op de 27e dag van de zomermaand van het jaar 2010:

> I doubt "porting is easier than you think" will convince many people
> if they don't know what the gain will be. For example, porting numpy
> and scipy to py3k has been easier than I thought, but besides making
> it easier for other people to switch, I can't see *any* benefit.
> That's bound to frustrate people.

The latest NumPy is 1.4.1, and it does not install with Python 3.1.1

-- 
Peter Kleiweg  L:NL,af,da,de,en,ia,nds,no,sv,(fr,it)  S:NL,de,en,(da,ia)
info: http://www.let.rug.nl/kleiweg/ls.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I strongly dislike Python 3

2010-06-27 Thread David Cournapeau
On Sun, Jun 27, 2010 at 11:46 PM, Peter Kleiweg  wrote:
> David Cournapeau schreef op de 27e dag van de zomermaand van het jaar 2010:
>
>> I doubt "porting is easier than you think" will convince many people
>> if they don't know what the gain will be. For example, porting numpy
>> and scipy to py3k has been easier than I thought, but besides making
>> it easier for other people to switch, I can't see *any* benefit.
>> That's bound to frustrate people.
>
> The latest NumPy is 1.4.1, and it does not install with Python 3.1.1

The 3.x support for numpy is in the trunk

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


Re: CONTROLLED DEMOLITION INC explosive-charge placement technician Tom ?Sullivan 911 TESTIMONIAL Video

2010-06-27 Thread small Pox
On Jun 27, 6:45 am, Juha Nieminen  wrote:
> In comp.lang.c++ nanothermite911fbibustards 
>  wrote:
>
> >http://www.ae911truth.org/newsletter/2010/06/index.php#cdi
>
> > Explosive Evidence at WTC Cited by Former CDI Employee
> > News - News Releases By AE911Truth
> > Written by Darcy Wearing and Richard Gage, AIA
> > Thursday, 24 June 2010 18:55
>
>   Could you please take your religion elsewhere and stop spamming newsgroups
> that have nothing to do with it? Thanks.

You PARASITE , who benefits from TAX PAYER money in terms of FEDERAL
and Research GRANTS !!!

Now is the time to pay back by defending the CONSTITUTION and first
step is spreading the INCONTROVERTIBLE EVIDENCE of the CRIME and the
CRIMINALS.

This is FORENSICs

http://911blogger.com

Academia and Scientific and Arts community is the BIGGEST RECIPIENT of
Federal Grants from TAX PAYER  MONEY 

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


Re: Continuously running scripts question

2010-06-27 Thread Peter H. Coffin
On Sun, 27 Jun 2010 16:21:25 +1200, Lawrence D'Oliveiro wrote:
> In message , Ian Kelly 
> wrote:
>
>> I use cron.
>> 
>> Con:  Most cron implementations have a maximum frequency of once per
>> minute.
>
> Another con is: what happens if a run takes longer than the invocation 
> frequency?

Not cron's problem. Whatever mechanism you use to prevent
fumble-fingered keyboard actuators from running your thing more than
once simulaneously will suffice for cron as well.

-- 
Don't use this code for realtime control, for weapons systems, or for
anything else that may put life or limb at hazard.  It isn't man-rated,
it isn't really thing-rated, and we don't claim that it's worth a good
G*dDamn for anything at all, at all.  -- Mike Andrews, on Java compilers
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I strongly dislike Python 3

2010-06-27 Thread Stephen Hansen

On 6/27/10 5:16 AM, Thomas Jollans wrote:

On 06/27/2010 01:46 PM, rantingrick wrote:



P.S. Am I the only one who has never, ever, even *seen* a 'print'
statement in non-toy or non-bash-script-style code in any application
or even third-party library I looked at? Except, on occasion, for
quick and dirty debugging. Perhaps because I'm more used to
cross-platform to windows development, where a stray print can
actually break the entire application (depending on contexts, if one
is run under a service or sometimes even pythonw)


Oh i dunno, these "toys" include print...


[replying to Rick here, just cuz! -- I can get two replies into one that 
way]


You did see "or non-bash-script-style code" right? Or? Or, meaning it 
can be toy, or bash-script-style-code. Now you may have no idea what the 
latter means, but no: I rather explicitly included a whole category of 
uses which aren't toy code.


[Now, back to Thomas!]


Do your homework properly. I randomly checked a few of these. base64
includes a "Small main program", which is certainly "bash-script-style".
Quite a few of the other files don't use print-the-statement/function at
all, but use "print" as part of an identifier. Your grepping is sloppy,
my friend!


Apparently he was confused between "a 'print' statement" and "the word 
print appearing somewhere in a file" :)



Granted, some use print to emit warnings (aifc for example). This isn't
perfectly clean, of course, but it's not used a whole lot either. Mostly
rather old code too, I think.


I'd actually, personally, consider it a bug if any stdlib module used 
'print' in the normal course of operations (i.e., not during some 
test/debug mode, and not when the lib is run as a script and the print 
is just part of example/testing stuff in the __name__ == "__main__" 
guard) -- unless it was one of those platform-specific modules. I don't 
know if python-dev would agree with that assessment, but if I ever 
encountered one I'd write up a patch and submit a bug report.


I haven't yet, so I'm pretty sure your analysis is correct.


That being said, Stephen's statement was very broad, but I think it's
true: print is primarily used in small scripts, or script-like testing
functions/methods.


I was going a little bit down the hyperbole road with my wording of the 
statement, but yeah. I did a random checking of the list myself, and the 
only ones I found with actual print statements would qualify under what 
I *meant* in 'non-toy or non-bash-script-style code'.


Its entirely possible that definition is not perfectly clear. But I'm 
really too tired to find a better way to describe it. You know. Quick 
glue-type and drive-other-things and test-this-out and one-off sort of 
activities.


There's nothing *wrong* with that kind of code or the people who use it. 
Doing those kinds of activities in Python makes way more sense then 
doing it in say, bash or perl :) (I'm biased on the latter in that perl 
makes my eyes cross and despite many attempts, learning even rudimentary 
perl has defied me)


But its also the kind of code which, in my personal experience, tends to 
-not- use advanced new features of the language, and which tends to 
-not- be the kind of stuff which gets run on a platform whose Python 
version evolves very fast if at all.


Then again, I have seen one instance where a heavily "scripted" 
environment made up of basically a bunch of interlocking Python scripts, 
sort of spontaneously evolved into a MCP, and advanced features started 
spreading around. It wouldn't at all have surprised me if the MCP put 
various scripts into laser bike races to see which were the best for its 
purposes.


--

   ... Stephen Hansen
   ... Also: Ixokai
   ... Mail: me+list/python (AT) ixokai (DOT) io
   ... Blog: http://meh.ixokai.io/

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


Re: I strongly dislike Python 3

2010-06-27 Thread rantingrick
On Jun 27, 7:16 am, Thomas Jollans  wrote:

> Granted, some use print to emit warnings (aifc for example). This isn't
> perfectly clean, of course, but it's not used a whole lot either. Mostly
> rather old code too, I think.
> And some (abc for example) use print in what looks like internal
> diagnostics methods.

You sure are going to great lengths to protect Stephens assertion ;)

> That being said, Stephen's statement was very broad, but I think it's
> true: print is primarily used in small scripts, or script-like testing
> functions/methods.

No, Stephen's comments were NOT general in any way and they where in
fact very specific... "If you use the print statement/function you're
are a noob and your code is a toy". And i think there's and air of
"also you're beneath me" in the tone of it too.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 2. Re: Python interface problem with Windows (Benjamin Kaplan)

2010-06-27 Thread Terry Reedy

On 6/27/2010 6:52 AM, Kermit Rose wrote:


I do not know how to import code from any other directory than the
default, C:\Python26.


I personally took the easy way. I put my package of modules in
pthonxy/Lib/site-packages, which is already on the search path

from package import mymod
from package.mymod import myfunc


And how do I save the code in a different directory than the default,
c:\Python26?


For miscellaneous scripts, I use a directory I added? pythonxy/misc.

I edit with IDLE. When it starts up, the current directory is pythonxy/. 
When I start a new file, I immediately select save-as, change to ./misc, 
and save something.py. Note that one needs to type the .py even if the 
type is selected.


Also, I keep a ./misc/tem file. That is easy to select from 'recent 
files' on the menu. If I decide I want to keep the file, I save under a 
new name, leaving misc/tem to be erased and reused for another throwaway 
script.


The python uninstaller does not delete user-made directories.
When I install a new version, it is easy to move or copy to the new tree.

--
Terry Jan Reedy

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


hiiiiiiiiiiiiiiiiiiiiiiiiiiiiii

2010-06-27 Thread eslam
:
Islam is an Arabic word, it means that you totally surrender to God,
and worship Him only.
Here also I must explain what does worship means? It doesn't mean that
you only pray, its meaning is much much wider, to worship God is that
you look at Him as your ONLY master, no other master controlling you,
so He is the ONLY one you are loyal to , He is the ONLY One you rely
on, He is the ONLY one you fear, He is the ONLY one who judges you and
puts rules for you, He is the axis your life rotates on, why? because
He is our Creator, He is the Creator of the Universe and Creator of
everything, He is the One who manages the Universe, He is the strong,
the compassionate the merciful, He knows everything, He can do
everything. He is the One who controls the Universe.
How did we know that? God sent prophets to us to teach us this and to
tell us the laws He gave for us to go along our life, we will be
accounted on this in the Hereafter.
Don't think that the beginning of Islam was only since Muhammad (Peace
be upon him), no that's wrong, Islam began from the beginning of
creation, God created Adam (Peace be upon him) and Adam was a Muslim,
because he really worshipped God only, and began to have a family, all
the family were Muslims,and the life went on, then people began to
deviate from this meaning and forgot God, began to worship idols, God
sent the prophets: Noah, Hud, Saleh, Abraham,Moses, David, Solomon,
Jesus,Muhammad and many other prophets (Peace be upon them all), the
mission of all these prophets was to restore people back to the right
way of God, and to remind them of their reality.
But at the end all these prophets are not gods, they don't have any
divine nature,because Allah is the ONLY God,so when Jews put very
wrong concepts of God that made Him like a child they are deviating
from concept of worshipping God, because they are insulting Him, and
when Christians say that Jesus is God or God's son, or that God is one
in Trinity, they are really deviating from the concept , and when they
make their priests invent rules for them with no evidence from what
God said or what His prophets said, they also are deviating from the
concept of worshipping God.
We in Islam refuse all these forms, if someone said that Muhammad
(Peace be upon him) is our God, he is a disbeliever, God is the ONLY
God, If an Immam said a Fatwa, he must give his evidence on this
Fatwa, he is not obeyed blindly, our standard is what Allah and His
prophet told us (because the Prophet is the one whom God sent not
because he has a divine nature because he hasn't).
This is generally the Islamic belief.
2. Islamic morals:
God ordered us to be merciful, treat people well, help people, He
recommended us to treat our parents well, and to keep always on
helping them.
23. Thy Lord has commanded that ye worship none but HIM, and that ye
show kindness to parents. If one or both of them attain old age with
thee, never say to them as much as ugh nor reproach them, but always
address them with kindly speech.
24. And lower them the wing of humility out of tenderness. And say,
`My Lord, have mercy on them even as they nourished me when I was a
little child.' (Holy Quran 17:23-24)
even if they were not Muslims we must treat them well but we don't
obey them if they ordered us to disobey God.
15. And if they contend with thee to make thee set up equals with ME
concerning which thou hast no knowledge, obey them not, but be a kind
companion to them in worldly affairs, (Holy Quran 31:15)
God ordered us to keep always in contact with our relatives God said:
36. And worship ALLAH and associate naught with HIM, and show kindness
to parents, and to kindred (Holy Quran 4:36)
Also the Prophet (Peace be upon him) said: “ He/She who believes in
Allah , the Almighty and Day of Judgment , must communicate , be good,
courteous and kind to his kith and kin or relatives.” (Narrated by
Bukhari and Muslim)
Also we are also recommended to treat the neighbors well, even if they
were not Muslims and even if they treated us badly as God said:
and to the neighbour who is a kinsman and the neighbour who is a
stranger (Holy Quran 4:36)
Prophet (Peace be upon him) said: “(Arch Angel) Gbriel , PBUH, pressed
on reminding me with the right of the neighbor until I thought he is
going to consider him an heir ( of mine) .” (Narrated by Bukhari and
Muslim)
He also says: “ The best of neighbor s in the sight of Allah, the
Almighty, is the one who is best to his neighbor”.(Narrated by
Tirmithee)

God also told us to take care of orphans as in the same verse and
orphans
There was a very severe punishment to those who take money of orphans
as God said:
10. Surely they who devour the property of the orphans unjustly, only
swallow fire into their bellies, and they shall burn in a blazing
fire. (Quran 4:10)

God ordered us to be completely fair with people even if I saw two
people having a problem, one of them is Muslim, the other is non
Muslim, and I found the right with the non-Muslim, I must judge

Re: I strongly dislike Python 3

2010-06-27 Thread Andreas Waldenburger
On Sun, 27 Jun 2010 02:45:37 +0100 Nobody  wrote:

> On Sat, 26 Jun 2010 21:08:48 +0200, Martin v. Loewis wrote:
> 
> >> I think that's not true. If enough people want to support Python 2
> >> it might be possible to advance Python 2.
> > 
> > That won't be sufficient: enough people wanting support won't have
> > any effect. People also need to want it enough to actually fork from
> > python.org.
> 
> This will happen.
> 
> > They would then have to convince Linux packagers to include
> > it in the distribution even though it's not available from
> > python.org,
> 
> So will this.
> 
> [snip]
> 
So your crystal ball is working, eh?

Good for you, mine was a scam.

;)
/W


-- 
INVALID? DE!

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


Re: I strongly dislike Python 3

2010-06-27 Thread Stephen Hansen

On 6/27/10 9:26 AM, rantingrick wrote:

That being said, Stephen's statement was very broad, but I think it's
true: print is primarily used in small scripts, or script-like testing
functions/methods.


No, Stephen's comments were NOT general in any way and they where in
fact very specific... "If you use the print statement/function you're
are a noob and your code is a toy". And i think there's and air of
"also you're beneath me" in the tone of it too.


Excuse me?

You do not speak for me. Do not put words into my mouth: especially 
words which are not at *all* what I said.


I said, "P.S. Am I the only one who has never, ever, even *seen* a 
'print' statement in non-toy or non-bash-script-style code in any 
application or even third-party library I looked at? Except, on 
occasion, for quick and dirty debugging. Perhaps because I'm more used 
to cross-platform to windows development, where a stray print can 
actually break the entire application (depending on contexts, if one is 
run under a service or sometimes even pythonw".


If you actually practice your reading comprehension-- I know this is 
difficult for you-- then you would see there's three categories of 
places I have seen print statements:


 - Toys (do you even know what I mean by that?)
 - Bash-script-style code (this is /very/ broad, and I do it all the time)
 - Debugging (qualified as 'quick and dirty', as opposed to debugging 
using say, the logging module or some other framework)


I then further qualified that its possible my own personal experience is 
the way it is, because I may be using applications and libraries which 
focus more on windows support then others who may be doing a great deal 
more in a pure-Unix environment where things are more sensible (i.e., a 
program always has a stdout, even if its /dev/null, as opposed to on 
windows, where you sometimes just have none at all, and writing to it 
kills your program).


For you to mischaracterize that all into, "you're a noob and your code 
is a toy" goes far beyond simple misunderstanding and into malicious 
false attribution.


Usually our disagreements have at least the vaguest *semblance* of an 
actual argument, notwithstanding your long wanderings in sophistry and 
substance-less rants. Now if you've decided to go down the path of 
rewriting what I say into something it completely isn't, instead of 
actually responding to it: then I have no time for you.


You're *this* close to getting killfiled after all. Your usual nonsense 
is one thing, you usually have the barest sense of decency to actually 
quote me when you respond. If you're going to paraphrase me, do so 
accurately at least-- or do so after quoting what I actually said, if 
you wish to reinterpret my words.


--

   ... Stephen Hansen
   ... Also: Ixokai
   ... Mail: me+list/python (AT) ixokai (DOT) io
   ... Blog: http://meh.ixokai.io/

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


Where is StackPanel in IronPython / .Net 4?

2010-06-27 Thread Ian Hobson

Hi All,

According to this page

http://msdn.microsoft.com/en-us/library/system.windows.controls.stackpanel.aspx

StackPanel is in the System.Windows.Controls Namespace

When I try and set up a reference to that Namespace I get a "Could not 
add reference to assembly

System.Windows.Controls" error on the line that reads

clr.AddReference('System.Windows.Controls')

Can anyone shed light on what is going wrong?

Many thanks

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


Re: Where is StackPanel in IronPython / .Net 4?

2010-06-27 Thread Benjamin Kaplan
On Sun, Jun 27, 2010 at 10:36 AM, Ian Hobson  wrote:
> Hi All,
>
> According to this page
>
> http://msdn.microsoft.com/en-us/library/system.windows.controls.stackpanel.aspx
>
> StackPanel is in the System.Windows.Controls Namespace
>
> When I try and set up a reference to that Namespace I get a "Could not add
> reference to assembly
> System.Windows.Controls" error on the line that reads
>
> clr.AddReference('System.Windows.Controls')
>
> Can anyone shed light on what is going wrong?
>
> Many thanks
>
> Ian
> --

You don't add references to namespaces. You add references to
assemblies and you then you import the namespace.

>From the documentation:
'''
Namespace:  System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)
'''

So you would do
clr.AddReference("PresentationFramework")
import System.Windows.Controls

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


Re: Why Is Escaping Data Considered So Magical?

2010-06-27 Thread Jorgen Grahn
On Sat, 2010-06-26, Lawrence D'Oliveiro wrote:
> In message , Jorgen Grahn 
> wrote:
>
>> I thought it was well-known that the solution is *not* to try to
>> sanitize the input -- it's to switch to an interface which doesn't
>> involve generating an intermediate executable.  In the Python example,
>> that would be something like os.popen2(['zcat', '-f', '--', untrusted]).
>
> That???s what I mean. Why do people consider input sanitization so hard?

I'm not sure you understood me correctly, because I advocate
*not* doing input sanitization. Hard or not -- I don't want to know,
because I don't want to do it.

/Jorgen

-- 
  // Jorgen GrahnO  o   .
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I strongly dislike Python 3

2010-06-27 Thread Terry Reedy

On 6/27/2010 8:41 AM, David Cournapeau wrote:


I think one point which needs to be emphasized more is what does
python 3 bring to people. The" what's new in python 3 page" gives the
impression that python 3 is about removing cruft. That's a very poor
argument to push people to switch.


Python3 is about finishing transitions. The last stage in a transition 
that replaces something old with something new is to remove the old, 
after showing that the new works. I am working on a separate post for 
this.) I presume most readers here who are not packrats have at some 
time discarded a working machine (perhaps reluctantly) after installing 
and testing a new one.


For new learners, not having to also learn the old is a real benefit. 
People who already know the old typically do not see that.


> I doubt "porting is easier than you think" will convince many people
> if they don't know what the gain will be. For example, porting numpy
> and scipy to py3k has been easier than I thought, but besides making
> it easier for other people to switch, I can't see *any* benefit.

I thank you and your group for porting numpy and scipy for the benefit 
of those who switch and for new Pythonistas that start with Python3. I 
hope and expect that they will eventually outnumber Python2 programmers.


I agree that there may be not much reason to port custom proprietary 
apps that are working fine and which would hardly benefit from, let 
alone need, and new Py3 features.

--
Terry Jan Reedy

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


Re: Roman Polansky RAPED Semantha Geimer Orally, Analy and Vaginally - TRAUMA for victim is so much that she wants it to be out of sight from her

2010-06-27 Thread nanothermite911fbibustards
On Jun 26, 10:02 pm, small Pox  wrote:
> Roman Polansky RAPED Semantha Geimer Orally, Analy and Vaginally -
> TRAUMA for victim is so much that she wants it to be out of sight from
> her
>
> Full Court Declaration of ROMAN POLANSKY
>
> http://www.netlexfrance.net/29/09/2009/roman-polanski-a-respected-fug...
>
> http://www.thesmokinggun.com/archive/polanskib12.html
>
> On Jun 26, 9:41 pm, small Pox  wrote:
>
> > How Non-Torah Zionist Rabbi Sholom Rubashkin, a former vice president
> > of Agriprocessors Inc became so rich and EARNED 27 years in JAIL ?
> > Most Jew Lawyers are LIARS !!!
>
> > Former slaughterhouse exec gets 27 years for fraud
> > By MICHAEL J. CRUMB (AP) – 4 days ago
>
> > CEDAR RAPIDS, Iowa — A former Iowa kosher slaughterhouse executive was
> > sentenced Tuesday to 27 years in prison for financial fraud, a
> > sentence legal experts called severe but not necessarily surprising as
> > judges take tough stances on white-collar crime.
>
> > Sholom Rubashkin, a former vice president of Agriprocessors Inc., also
> > was ordered to pay $27 million in restitution by Chief U.S. District
> > Court Judge Linda R. Reade, who had released a memorandum outlining
> > the sentence a day earlier.
>
> > A jury convicted Rubashkin last fall of 86 federal financial fraud
> > charges. Defense attorney Guy Cook said he plans to appeal. About 100
> > supporters gathered outside the courthouse Tuesday, some holding signs
> > reading "We want fair & equal justice."
>
> > Prosecutors had sought a 25-year sentence, but called the slightly
> > longer punishment "entirely appropriate."
>
> > "It is a lengthy sentence, but he earned it by everything he did," U.S
> > attorney spokesman Bob Teig said.
>
> > Rubashkin oversaw the plant in Postville, Iowa, that gained attention
> > in 2008 after a large-scale immigration raid in which authorities
> > detained 389 illegal immigrants. The plant eventually filed for
> > bankruptcy and was later sold.
>
> > After an investigation by a court-appointed trustee, prosecutors
> > alleged Rubashkin intentionally deceived the company's lender and
> > directed employees to create fake invoices in order to show St. Louis-
> > based First Bank the plant had more money flowing in than it did. Cook
> > tried to portray Rubashkin as a bumbling businessman who never even
> > read the loan agreement with First Bank.
>
> > Rubashkin also faced 72 charges for allegedly allowing illegal
> > immigrants to work at the plant but Reade dismissed those charges and
> > a jury acquitted Rubashkin of state child labor charges earlier this
> > month.
>
> > Stanford University law professor Robert Weisberg called Rubashkin's
> > 27-year sentence "dubious" even though severe sentences are
> > increasingly common in the wake of major fraud cases, such as that
> > against Enron. The energy company's 2001 collapse cost thousands of
> > jobs and billions of dollars.
>
> > Weisberg contended Rubashkin's case does not rise to such a level.
>
> > "I don't understand why it was a longer sentence than what the
> > prosecution asked for, especially when the prosecution asked for a
> > sentence that was already pretty severe," Weisberg said.
>
> > But Robert Rigg, a law professor at Drake University in Des Moines,
> > said the slaughterhouse case is by no means small, "especially for
> > Iowa."
>
> > He said the raid's economic impact and disruption the case caused in
> > Postville likely factored into Reade's sentencing.
>
> > "There is a lot of collateral damage here and you can understand why a
> > judge would take the facts and the circumstances of the case as an
> > aggravating factor," Rigg said.
>
> > Defense attorneys argue Reade improperly considered other factors,
> > such as the raid and immigration case, in sentencing for the fraud
> > conviction. The judge did not specifically address her reasoning for
> > the lengthy sentence, but her 52-page memorandum handed down Monday
> > leaned heavily on documents submitted by prosecutors.
>
> > "Here, the record establishes Defendant committed an unprecedented
> > amount of criminal conduct which has not entered into the
> > determination of the advisory (sentencing) guidelines," Reade said.
>
> > Teig agreed that information about illegal immigrants working at the
> > slaughterhouse was an integral part of the fraud investigation.
>
> > "The jury found the defendant knew illegal immigrants were being
> > harbored at the plant and lied to the bank about that, so clearly it
> > was part of the fraud charges that the defendant was involved in the
> > hiring of illegal immigrants," Teig said.
>
> > Rigg, the Drake professor, said he had tried cases before Reade when
> > she was a state court judge and called her a "stickler." He said she
> > is a "harsher sentencer than most," but not the most harsh he's seen.
>
> > "Does she take a bite out of your client? Yes," Rigg said. "You better
> > be prepared if you go in asking Judge Reade for leniency. I would not
> > en

Wrong reference

2010-06-27 Thread Jimmy
Add references to:
"PresentationCore"
and "PresentationFramework"
for the System.Windows and System.Windows.Controls etc namespace.



Ian Hobson wrote:

Where is StackPanel in  IronPython / .Net 4?
27-Jun-10

Hi All,

According to this page

http://msdn.microsoft.com/en-us/library/system.windows.controls.stackpanel.aspx

StackPanel is in the System.Windows.Controls Namespace

When I try and set up a reference to that Namespace I get a "Could not
add reference to assembly
System.Windows.Controls" error on the line that reads

clr.AddReference('System.Windows.Controls')

Can anyone shed light on what is going wrong?

Many thanks

Ian

Previous Posts In This Thread:


Submitted via EggHeadCafe - Software Developer Portal of Choice 
XAML Organizer
http://www.eggheadcafe.com/tutorials/aspnet/ac373a5d-e497-4e07-9186-12166e83a024/xaml-organizer.aspx
-- 
http://mail.python.org/mailman/listinfo/python-list


Correction

2010-06-27 Thread Jimmy
It should be
"PresentationCore"
and "PresentationFramework."

For some reason, that first part got deleted in my reply.



Jimmy Cao wrote:

Wrong reference
27-Jun-10

Add references to:
"PresentationCore"
and "PresentationFramework"
for the System.Windows and System.Windows.Controls etc namespace.

Previous Posts In This Thread:


Submitted via EggHeadCafe - Software Developer Portal of Choice 
Store ASP.NET Site Visitor Stats in MongoDb
http://www.eggheadcafe.com/tutorials/aspnet/3a73c6de-82a1-4690-a7aa-d0eda58203f7/store-aspnet-site-visitor-stats-in-mongodb.aspx
-- 
http://mail.python.org/mailman/listinfo/python-list


PresentationCore got deleted again

2010-06-27 Thread Jimmy
For some reason, "PresentationCore" doesn't show up...
PresentationCore
PresentationCore
PresentationCore
PresentationCore
PresentationCore



Jimmy Cao wrote:

Wrong reference
27-Jun-10

Add references to:
"PresentationCore"
and "PresentationFramework"
for the System.Windows and System.Windows.Controls etc namespace.

Previous Posts In This Thread:


Submitted via EggHeadCafe - Software Developer Portal of Choice 
Store ASP.NET Site Visitor Stats in MongoDb
http://www.eggheadcafe.com/tutorials/aspnet/3a73c6de-82a1-4690-a7aa-d0eda58203f7/store-aspnet-site-visitor-stats-in-mongodb.aspx
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: os.system: string encoding

2010-06-27 Thread Martin v. Loewis
Am 25.06.2010 17:13, schrieb Peter Kleiweg:
> How do I set the string encoding for os.system to anything other then UTF-8?

You shouldn't have to set it, as it should use your locale's encoding.
In 3.1.2, it will.

For the moment, you can encode the string explicitly, and pass a byte
string.

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


Re: I strongly dislike Python 3

2010-06-27 Thread Martin v. Loewis
> I agree that there may be not much reason to port custom proprietary
> apps that are working fine and which would hardly benefit from, let
> alone need, and new Py3 features.

In the long run, there will be a benefit: at some point in the future
(surely years from now), /usr/bin/python will be Python 3. So scripts
that use /usr/bin/python (or "/usr/bin/env python") will stop working.
As a quick fix, it might then be possible to have them run with
/usr/bin/python2. Some time more into the future, this will also stop
working, as Python 2.x won't be available anymore in the OS
distributions. If the custom proprietary app is then still used, it
better be ported.

The same happened with other kinds of deprecations and removals through
the life of 2.x. Some applications where tied to a specific Python
release, or to a specific feature that had been deprecated. These either
needed to be ported, or dropped.

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


Re: Why Is Escaping Data Considered So Magical?

2010-06-27 Thread Jorgen Grahn
On Fri, 2010-06-25, Nobody wrote:
> On Fri, 25 Jun 2010 12:15:08 +, Jorgen Grahn wrote:
>
>> I don't do SQL and I don't even understand the terminology properly
>> ... but the discussion around it bothers me.
>> 
>> Do those people really do this?
>
> Yes. And then some.
>
> Among web developers, the median level of programming knowledge amounts to
> the first 3 chapters of "Learn PHP in 7 Days".
>
> It doesn't help the the guy who wrote PHP itself wasn't much better.
>
>> - accept untrusted user data
>> - try to sanitize the data (escaping certain characters etc)
>> - turn this data into executable code (SQL)
>> - executing it
>> 
>> Like the example in the article
>> 
>>   SELECT * FROM hotels WHERE city = '';
>
> Yep. Search the BugTraq archives for "SQL injection". And most of those
> are for widely-deployed middleware; the zillions of bespoke site-specific
> scripts are likely to be worse.
>
> Also: http://xkcd.com/327/

Priceless!

As is often the case with xkcd, I learned something, too: there's a
widely used web application/portal/database thingy which silently
strips some characters from my input.  I thought it had to do with
HTML, but it's in fact exactly the sequences "'", ')', ';' and '--'
from the comic, and a few more like '>' and undoubtedly some I haven't
noticed yet.

That is surely "input sanitization" gone horribly wrong: I enter "6--8
slices of bread", but the system stores "68 slices of bread".

>> I thought it was well-known that the solution is *not* to try to
>> sanitize the input
>
> Well known by anyone with a reasonable understanding of the principles of
> programming, but somewhat less well known by the other 98% of web
> developers.
>
>> Am I missing something?
>
> There's a world of difference between a skilled chef and the people
> flipping burgers for a minimum wage. And between a chartered civil
> engineer and the people laying the asphalt. And between what you
> probably consider a programmer and the people doing most web development.

I don't know them, so I wouldn't know ... What I would *expect* is
that safe tools are provided for them, not just workarounds so they
can keep using the unsafe tools. That's what Python did, with its
multitude of alternatives to os.system and os.popen.

Anyway, thanks. It's always nice to be able to map foreign terminology
like "SQL injection" to something you already know.

/Jorgen

-- 
  // Jorgen GrahnO  o   .
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: os.system: string encoding

2010-06-27 Thread Peter Kleiweg
Martin v. Loewis schreef op de 27e dag van de zomermaand van het jaar 2010:

> Am 25.06.2010 17:13, schrieb Peter Kleiweg:
> > How do I set the string encoding for os.system to anything other then UTF-8?
> 
> You shouldn't have to set it, as it should use your locale's encoding.
> In 3.1.2, it will.
> 
> For the moment, you can encode the string explicitly, and pass a byte
> string.

That doesn't work

Python 3.1.1 (r311:74480, Oct  2 2009, 11:50:52) 
>>> import os
>>> os.system('echo \N{EURO SIGN}'.encode('iso-8859-15'))
Traceback (most recent call last):
  File "", line 1, in 
TypeError: must be string, not bytes


-- 
Peter Kleiweg  L:NL,af,da,de,en,ia,nds,no,sv,(fr,it)  S:NL,de,en,(da,ia)
info: http://www.let.rug.nl/kleiweg/ls.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Where is StackPanel in IronPython / .Net 4?

2010-06-27 Thread Ian

Hi Benjamin - and thanks for your reply.

I'm now really confused.

On 27/06/2010 20:05, Benjamin Kaplan wrote:

You don't add references to namespaces. You add references to
assemblies and you then you import the namespace.

> From the documentation:
'''
Namespace:  System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)
'''

So you would do
clr.AddReference("PresentationFramework")
import System.Windows.Controls

   

I tried
from System.Windows.Controls import StackPanel
and it worked fine.

Now I need  VerticalAlignment.Top

From 
http://msdn.microsoft.com/en-us/library/system.windows.verticalalignment%28v=VS.95%29.aspx 
I learn that

this is in the VerticalAlignment Enumeration

Quote
*Namespace:* System.Windows 


*Assembly:* System.Windows (in System.Windows.dll)
  ^^^
End quote

So I write

clr.AddReference('System.Windows')

and it errors - Could not add reference to System.Windows

So clearly I still don't understand something rather basic.

More help please.

Thanks

Ian

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


Re: Why Is Escaping Data Considered So Magical?

2010-06-27 Thread Jorgen Grahn
On Sun, 2010-06-27, Lawrence D'Oliveiro wrote:
> In message , Roy Smith wrote:
>
>> I recently fixed a bug in some production code.  The programmer was
>> careful to use snprintf() to avoid buffer overflows.  The only problem
>> is, he wrote something along the lines of:
>> 
>> snprintf(buf, strlen(foo), foo);
>
> A long while ago I came up with this macro:
>
> #define Descr(v) &v, sizeof v
>
> making the correct version of the above become
>
> snprintf(Descr(buf), foo);

This is off-topic, but I believe snprintf() in C can *never* safely be
the only thing you do to the buffer: you also have to NUL-terminate it
manually in some corner cases. See the documentation.

/Jorgen

-- 
  // Jorgen GrahnO  o   .
-- 
http://mail.python.org/mailman/listinfo/python-list


Scan until random delimiter.

2010-06-27 Thread Laurent Verweijen

In contrast to java or c python seems not be able to use a random
delimiter.

In java, you can do:


Code:

import java.util.Scanner

Scanner sc = new Scanner(System.in).useSeperator(" ")
int a = sc.nextInt()


But in python there seems to be no other option then waiting until you
see a newline.
I wrote a script which should allow more freedom.


Code:

#!/usr/bin/python

def readtoken(source=None, delim=" \n\t\r"):
if source is None:
from sys import stdin
source = stdin

r = []
c = delim + " "

while c not in delim:
c = source.read(1)
r.append(c)

return "".join(r)

if __name__ == "__main__":
for _ in range(5):
print(readtoken())


It works a bit but still requires the user to press enter.
Is there some way around it, which is platform independant? 

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


Re: os.system: string encoding

2010-06-27 Thread Martin v. Loewis
>> For the moment, you can encode the string explicitly, and pass a byte
>> string.
> 
> That doesn't work

I only have 3.1.2 to test at the moment. I suggest trying to use the
subprocess module instead.

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


Re: Scan until random delimiter.

2010-06-27 Thread Albert Hopkins
On Sun, 2010-06-27 at 22:41 +0200, Laurent Verweijen wrote:
> In contrast to java or c python seems not be able to use a random
> delimiter.
> 
> In java, you can do:
> 
> 
> Code:
> 
> import java.util.Scanner
> 
> Scanner sc = new Scanner(System.in).useSeperator(" ")
> int a = sc.nextInt()
> 
> 
> But in python there seems to be no other option then waiting until you
> see a newline.
> I wrote a script which should allow more freedom.
> 
> 
> Code:
> 
> #!/usr/bin/python
> 
> def readtoken(source=None, delim=" \n\t\r"):
> if source is None:
> from sys import stdin
> source = stdin
> 
> r = []
> c = delim + " "
> 
> while c not in delim:
> c = source.read(1)
> r.append(c)
> 
> return "".join(r)
> 
> if __name__ == "__main__":
> for _ in range(5):
> print(readtoken())
> 

I found this recipe (though not tried it):

http://code.activestate.com/recipes/134892/




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


Re: A link to a collection of tutorials on LISP.

2010-06-27 Thread Öö Tiib
On 28 juuni, 00:12, nanothermite911fbibustards
 wrote:
> On Jun 27, 1:33 pm, Peter Keller   wrote:
>
> > nanothermite911fbibustards  wrote:
> > > A single bound pdf document of all the tutorial slides in one SINGLE
> > > pdf with bookmarks and plain white background would be of some worth
> > > but this is TOTAL SHaT.
> > Curious. You emit the worst kind of vitriolic hate that literally drives
> > genocides and then you edit yourself when writing the word 'SHIT'?
> > That's kinda of awesome.
>
> That guys intention is not to spread tutorial, but its a commercial. I
> clarified its true nature.
>
> On the genocide, the thing that drives it is the lies and deception -
> of people like the FBI bustards - as well as the events that took
> place on the Turkish FLOTILLA.

By you definition you are one of these "bustards". OK, lets assume
they did drop these 3 scyscrapers and so on did other crimes too. Then
some of it started to become evident. So you have given a task to
pretend to be a lamer lunatic. Now you rave out of topic in several
newsgroups, make everything you say to sound like hallucinations of a
madman. What you gain (job task of yours) is that everyone does put
major keywords that are connected to the issues into their killfiles.
-- 
http://mail.python.org/mailman/listinfo/python-list


refactoring a group of import statements

2010-06-27 Thread GrayShark
I have a large list of package files to import. I'm using a try/except 
test to verify the import. Looks like:

try:
import abc
except ImportError:
print( "Error importing abc" )

I've got many of those segments. I want to try and refactor this part 
of the code. 

Trying:
for mod in ['ab', 'cd', 'ef' ]:
try:
mod = __import__( mod )
except ImportError:
print( "Error importing %" % mod )

This of course doesn't work. The module ab get's assign in the application
as mod. 

Tried:
for mod in ['ab', 'cd', 'ef' ]:
('%s' % mod ) = __import__( mod )

Still no joy.

I need a way to deference the the string in mod to be just a variable.

Any suggestions?

GrayShark

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


Why are String Formatted Queries Considered So Magical?

2010-06-27 Thread Carl Banks
On Jun 24, 6:02 pm, Roy Smith  wrote:
> In article ,
>  Lawrence D'Oliveiro  wrote:
>
> > I construct ad-hoc queries all the time. It really isn’t that hard to do
> > safely. All you have to do is read the documentation
>
> I get worried when people talk about how easy it is to do something
> safely.  Let me suggest a couple of things you might not have considered:
>
> 1) Somebody is running your application (or the database server) with
> the locale set to something unexpected.  This might change how numbers,
> dates, currency, etc, get formatted, which could change the meaning of
> your constructed SQL statement.
>
> 2) Somebody runs your application with a different PYTHONPATH, which
> causes a different (i.e. malicious) urllib module to get loaded, which
> makes urllib.quote() do something you didn't expect.

Seriously, almost every other kind of library uses a binary API. What
makes databases so special that they need a string-command based API?
How about this instead (where this a direct binary interface to the
library):

results = rdb_query(table = model,
columns = [model.name, model.number])

results = rdb_inner_join(tables = [records,tags],
 joins = [(records.id,tags.record_id)]),
 columns = [record.name, tag.name])

Well, we know the real reason is that C, Java, and friends lack
expressiveness and so constructing a binary query is an ASCII
nightmare.  Still, it hasn't stopped binary APIs in other kinds of
libraries.


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


Re: refactoring a group of import statements

2010-06-27 Thread Thomas Jollans
On 06/28/2010 12:06 AM, GrayShark wrote:
> I have a large list of package files to import. I'm using a try/except 
> test to verify the import. Looks like:
> 
> try:
>   import abc
> except ImportError:
>   print( "Error importing abc" )
> 
> I've got many of those segments. I want to try and refactor this part 
> of the code. 
> 
> Trying:
>   for mod in ['ab', 'cd', 'ef' ]:
>   try:
>   mod = __import__( mod )
>   except ImportError:
>   print( "Error importing %" % mod )
> 
> This of course doesn't work. The module ab get's assign in the application
> as mod. 
> 
> Tried:
>   for mod in ['ab', 'cd', 'ef' ]:
>   ('%s' % mod ) = __import__( mod )
> 
> Still no joy.
> 
> I need a way to deference the the string in mod to be just a variable.
> 
> Any suggestions?

(1) Don't. If you need the module, there's no reason to check for
exceptions. Just let the ImportError propagate. Okay, maybe you don't
actually need the module - then why do you have to import it in the
first place?

(2) globals()[mod] = __import__(mod)

(3) Why not

try:
import x
import y
import z
except ImportError as exc:
display_error_properly(exc)
raise exc


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


Re: Why are String Formatted Queries Considered So Magical?

2010-06-27 Thread Roy Smith
In article 
<14e44c9c-04d9-452d-b544-498adfaf7...@d8g2000yqf.googlegroups.com>,
 Carl Banks  wrote:

> Seriously, almost every other kind of library uses a binary API. What
> makes databases so special that they need a string-command based API?
> How about this instead (where this a direct binary interface to the
> library):
> 
> results = rdb_query(table = model,
> columns = [model.name, model.number])
> 
> results = rdb_inner_join(tables = [records,tags],
>  joins = [(records.id,tags.record_id)]),
>  columns = [record.name, tag.name])
> 
> Well, we know the real reason is that C, Java, and friends lack
> expressiveness and so constructing a binary query is an ASCII
> nightmare.  Still, it hasn't stopped binary APIs in other kinds of
> libraries.

Well, the answer to that one is simple.  SQL, in the hands of somebody 
like me, can be used to express a few pathetic joins and what I do with 
it could probably be handled with the kind of API you're describing.  
But, the language has far more expressivity than that, and a 
domain-specific language is really a good fit for what it can do.

The problem is not so much that SQL queries are described as text 
strings, but that the distinction between program and data gets lost if 
you build the query as one big string.  What you need (and which the 
Python API supplies) is the ability to clearly distinguish between "this 
text is my program" and "this text is a value which my program uses".

Python has the same problem.  If I had a text string, s, which I read 
from some external source, and wanted to interpret that string as an 
integer, I could do (at least) two different things.

# Thing 1
myInteger = int(s)

# Thing 2
myInteger = eval(s)

for properly formed input, either one works, but thing 2 loses the 
distinction between program and data and is thus dangerous.  Exactly 
like building a SQL query by smashing a bunch of strings together.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: refactoring a group of import statements

2010-06-27 Thread rantingrick
On Jun 27, 5:18 pm, Thomas Jollans  wrote:
> On 06/28/2010 12:06 AM, GrayShark wrote:
> > I have a large list of package files to import. I'm using a try/except
> > test to verify the import. Looks like:



> (1) Don't. If you need the module, there's no reason to check for
> exceptions. Just let the ImportError propagate. Okay, maybe you don't
> actually need the module - then why do you have to import it in the
> first place?

Actually thats not always the case Thomas. There *is* a need to check
for import exceptions *if* you don't want the script to blow chunks.
Take for example using the Tkinter module and it's mediocre image
support. I find that i do this sometimes...


import Tkinter as tk
try:
import Image #from PIL
print 'Using high quality images :)'
except ImportError:
print 'Using low quality images :('


Here is an example (there are other ways too) of how one might test
multiple imports in a loop -- i'll probably get thrown to the sharks
for this one ;-)


>>> code
Traceback (most recent call last):
  File "", line 1, in 
code
NameError: name 'code' is not defined
>>> for x in 'spam', 'eggs', 'code':
try:
exec('import %s' %x)
except ImportError:
print 'no %s for you!' %x

no spam for you!
no eggs for you!
>>> code

>>>

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


Re: I strongly dislike Python 3

2010-06-27 Thread eric_dex...@msn.com
On Jun 27, 2:09 pm, "Martin v. Loewis"  wrote:
> > I agree that there may be not much reason to port custom proprietary
> > apps that are working fine and which would hardly benefit from, let
> > alone need, and new Py3 features.
>
> In the long run, there will be a benefit: at some point in the future
> (surely years from now), /usr/bin/python will be Python 3. So scripts
> that use /usr/bin/python (or "/usr/bin/env python") will stop working.
> As a quick fix, it might then be possible to have them run with
> /usr/bin/python2. Some time more into the future, this will also stop
> working, as Python 2.x won't be available anymore in the OS
> distributions. If the custom proprietary app is then still used, it
> better be ported.
>
> The same happened with other kinds of deprecations and removals through
> the life of 2.x. Some applications where tied to a specific Python
> release, or to a specific feature that had been deprecated. These either
> needed to be ported, or dropped.
>
> Regards,
> Martin

It should be easier to have a large number of python versions on one
machine...  I am realy fond of 2.5 so I am probily going to start
compiling them or just include the python2.5 exe if I port stuff and
settle it that way..
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: refactoring a group of import statements

2010-06-27 Thread Thomas Jollans
On 06/28/2010 12:48 AM, rantingrick wrote:
> On Jun 27, 5:18 pm, Thomas Jollans  wrote:
>> On 06/28/2010 12:06 AM, GrayShark wrote:
>>> I have a large list of package files to import. I'm using a try/except
>>> test to verify the import. Looks like:
> 
> 
> 
>> (1) Don't. If you need the module, there's no reason to check for
>> exceptions. Just let the ImportError propagate. Okay, maybe you don't
>> actually need the module - then why do you have to import it in the
>> first place?
> 
> Actually thats not always the case Thomas. There *is* a need to check
> for import exceptions *if* you don't want the script to blow chunks.
> Take for example using the Tkinter module and it's mediocre image
> support. I find that i do this sometimes...
> 
> 
> import Tkinter as tk
> try:
> import Image #from PIL
> print 'Using high quality images :)'
> except ImportError:
> print 'Using low quality images :('

As such, that still appears rather useless - the following code doesn't
know how to behave ;-) Take this example from my own code: ;-)

HAVE_IMAGING = True
try:
from PIL import Image
except ImportError:
HAVE_IMAGING = False
sys.stderr.write("Python Imaging Library PIL not found. Cover art
disabled.\n")

Yes, sometimes these checks are needed, because a module can enhance
your code if it's present. But that tends to be the exception rather
than the rule, and would usually require some extra code to make the
check useful in the first place, which makes a generalized for loop over
a bunch of modules appear to be of little utility

> 
> 
> Here is an example (there are other ways too) of how one might test
> multiple imports in a loop -- i'll probably get thrown to the sharks
> for this one ;-)
> 
> 
 code
> Traceback (most recent call last):
>   File "", line 1, in 
> code
> NameError: name 'code' is not defined
 for x in 'spam', 'eggs', 'code':
>   try:
>   exec('import %s' %x)

Ah yes, exec. I've never liked exec - I find
globals()[x] = __import__(x)
clearer. But that might be just me.

>   except ImportError:
>   print 'no %s for you!' %x
> 
> no spam for you!
> no eggs for you!
 code
> 

> 


Just to add to the head of contrived "solutions":


def _import(module, flag=None, as=None):
try:
if as is None: as = module
globals()[as] = __import__(module)
if flag is not None: globals()[flag] = True
except ImportError:
sys.stderr.write("%s module missing.\n" % module)
if flag is not None: globals()[flag] = False
else: raise

_import('x', 'HAVE_X')
_import('y', 'HAVE_Y')
_import('ZZ9PluralZAlpha', as='zz') #required

del _import # prevents me from stupidly doing this in a function
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I strongly dislike Python 3

2010-06-27 Thread Benjamin Kaplan
On Sun, Jun 27, 2010 at 4:03 PM, eric_dex...@msn.com
 wrote:
> On Jun 27, 2:09 pm, "Martin v. Loewis"  wrote:
>> > I agree that there may be not much reason to port custom proprietary
>> > apps that are working fine and which would hardly benefit from, let
>> > alone need, and new Py3 features.
>>
>> In the long run, there will be a benefit: at some point in the future
>> (surely years from now), /usr/bin/python will be Python 3. So scripts
>> that use /usr/bin/python (or "/usr/bin/env python") will stop working.
>> As a quick fix, it might then be possible to have them run with
>> /usr/bin/python2. Some time more into the future, this will also stop
>> working, as Python 2.x won't be available anymore in the OS
>> distributions. If the custom proprietary app is then still used, it
>> better be ported.
>>
>> The same happened with other kinds of deprecations and removals through
>> the life of 2.x. Some applications where tied to a specific Python
>> release, or to a specific feature that had been deprecated. These either
>> needed to be ported, or dropped.
>>
>> Regards,
>> Martin
>
> It should be easier to have a large number of python versions on one
> machine...  I am realy fond of 2.5 so I am probily going to start
> compiling them or just include the python2.5 exe if I port stuff and
> settle it that way..
> --

You're on the only platform where it isn't that easy. All us *nix
users have to do is compile it with the altinstall flag, and then use
#!/usr/bin/env python25
Windows uses the file extension instead of the shebang line to execute
stuff, so it's harder for you to have multiple versions.
-- 
http://mail.python.org/mailman/listinfo/python-list


problems getting os.system and wxmenu to read options from a file and then execute

2010-06-27 Thread eric_dex...@msn.com
I managed to get the program running and the menu options are
appearing on the list but the programs are not running.  I suspect it
is my onexecutemethod

# Get the GUI stuff
import wx

# We're going to be handling files and directories
import os
menufile = open('menufile.txt','r')

# Set up some button numbers for the menu

ID_ABOUT=101
ID_OPEN=102
ID_SAVE=103
ID_BUTTON1=300
ID_EXIT=200
#ID_TOOL = 400

class MainWindow(wx.Frame):
def __init__(self,parent,title):
# based on a frame, so set up the frame
wx.Frame.__init__(self,parent,wx.ID_ANY, title)

# Add a text editor and a status bar
# Each of these is within the current instance
# so that we can refer to them later.
self.control = wx.TextCtrl(self, 1, style=wx.TE_MULTILINE)
self.CreateStatusBar() # A Statusbar in the bottom of the
window

# Setting up the menu. filemenu is a local variable at this
stage.
filemenu= wx.Menu()
# use ID_ for future easy reference - much better that "48",
"404" etc
# The & character indicates the short cut key
filemenu.Append(ID_OPEN, "&Open"," Open a file to edit")
filemenu.AppendSeparator()
filemenu.Append(ID_SAVE, "&Save"," Save file")
filemenu.AppendSeparator()
filemenu.Append(ID_ABOUT, "&About"," Information about this
program")
filemenu.AppendSeparator()
filemenu.Append(ID_EXIT,"E&xit"," Terminate the program")
#add options from a text file
idtool = 400
menuoptions = []
for line in menufile:
  t = line.split(' ')
  filemenu.Append(idtool, t[0], t[1])
  menuoptions.append(t[1])
  idtool += 1

# Creating the menubar.
menuBar = wx.MenuBar()
menuBar.Append(filemenu,"&File") # Adding the "filemenu" to
the MenuBar
self.SetMenuBar(menuBar)  # Adding the MenuBar to the Frame
content.
# Note - previous line stores the whole of the menu into the
current object

# Define the code to be run when a menu option is selected
wx.EVT_MENU(self, ID_ABOUT, self.OnAbout)
wx.EVT_MENU(self, ID_EXIT, self.OnExit)
wx.EVT_MENU(self, ID_OPEN, self.OnOpen)
wx.EVT_MENU(self, ID_SAVE, self.OnSave) # just "pass" in our
demo
#add execute files from the text file list
idtool = 400
for e in menuoptions:
wx.EVT_MENU(self, idtool, self.OnExecute(idtool, e))
idtool += 1
##print e

# Set up a series of buttons arranged horizontally
self.sizer2 = wx.BoxSizer(wx.HORIZONTAL)
self.buttons=[]
# Note - give the buttons numbers 1 to 6, generating events
301 to 306
# because IB_BUTTON1 is 300
for i in range(6):
# describe a button
bid = i+1
self.buttons.append(wx.Button(self, ID_BUTTON1+i, "Button
&"+str(bid)))
# add that button to the sizer2 geometry
self.sizer2.Add(self.buttons[i],1,wx.EXPAND)

# Set up the overall frame verically - text edit window above
buttons
# We want to arrange the buttons vertically below the text
edit window
self.sizer=wx.BoxSizer(wx.VERTICAL)
self.sizer.Add(self.control,1,wx.EXPAND)
self.sizer.Add(self.sizer2,0,wx.EXPAND)

# Tell it which sizer is to be used for main frame
# It may lay out automatically and be altered to fit window
self.SetSizer(self.sizer)
self.SetAutoLayout(1)
self.sizer.Fit(self)

# Show it !!!
self.Show(1)

# Define widgets early even if they're not going to be seen
# so that they can come up FAST when someone clicks for them!
self.aboutme = wx.MessageDialog( self, " A sample editor \n"
" in wxPython","About Sample Editor",
wx.OK)
self.doiexit = wx.MessageDialog( self, " Exit - R U Sure? \n",
"GOING away ...", wx.YES_NO)

# dirname is an APPLICATION variable that we're choosing to
store
# in with the frame - it's the parent directory for any file
we
# choose to edit in this frame
self.dirname = ''

def OnAbout(self,e):
# A modal show will lock out the other windows until it has
# been dealt with. Very useful in some programming tasks to
# ensure that things happen in an order that  the programmer
# expects, but can be very frustrating to the user if it is
# used to excess!
self.aboutme.ShowModal() # Shows it
# widget / frame defined earlier so it can come up fast when
needed

def OnExit(self,e):
# A modal with an "are you sure" check - we don't want to exit
# unless the user confirms the selection in this case ;-)
igot = self.doiexit.ShowModal() # Shows it
if igot == wx.ID_YES:
self.Close(True)  # Closes out this simple application

def OnOpen(se

Re: I strongly dislike Python 3

2010-06-27 Thread Stephen Hansen

On 6/27/10 4:03 PM, eric_dex...@msn.com wrote:

On Jun 27, 2:09 pm, "Martin v. Loewis"  wrote:

The same happened with other kinds of deprecations and removals through
the life of 2.x. Some applications where tied to a specific Python
release, or to a specific feature that had been deprecated. These either
needed to be ported, or dropped.

Regards,
Martin


It should be easier to have a large number of python versions on one
machine...  I am realy fond of 2.5 so I am probily going to start
compiling them or just include the python2.5 exe if I port stuff and
settle it that way..


Why do you think you'll need to compile anything?

I can't speak for the the people who run python.org, but considering you 
can still get 1.5.2 in binary form for windows, I don't see why they'd 
ever stop offering Python 2.5.


Just because new development for the 2.x series is coming to a halt, 
doesn't mean anyone's forcing everyone to start using 2.6, 2.7, or 3.x, 
or that suddenly Python.org is going to stop offering downloads for it. 
There's just no reason for them to bother as long as there's any sort of 
interest. I mean, ten years from now maybe if no one ever downloads 2.5 
-- but as it is, its 11 years since 1.5.2 was released and no one seems 
inclined to remove it. :)


--

   ... Stephen Hansen
   ... Also: Ixokai
   ... Mail: me+list/python (AT) ixokai (DOT) io
   ... Blog: http://meh.ixokai.io/

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


Re: A link to a collection of tutorials on LISP.

2010-06-27 Thread nanothermite911fbibustards
On Jun 27, 2:33 pm, Peter Keller  wrote:
> nanothermite911fbibustards  wrote:
> > That guys intention is not to spread tutorial, but its a commercial. I
> > clarified its true nature.
>
> Fair enough.
>
> > Your ilk has special skill in turning white into black and vice-versa.
>
> Assuming much there, aren't you?
>

Not really. Your last name KELLER, reminds me very well of a Jew by
the same last name who was delegated a task to interview me many years
ago before 911 for a job in a corporation . I still remember his
face . The chinese manager was interested but I saw a knowing smile on
this keller's face , I never got the job. I had published excellent
and lucid expository/tutorial paper(s) in the general field and
especially strong background.

> I think you'll find there are plenty of lies, deception, murder, torture,
> economic warfare, etc, etc, etc in plain old humanity no matter the color,
> race, or religion. Affixing a certain group as the point of origin of such
> behavior completely sidesteps the problem of why it exists in the first place.

This is typical hogwash that there has been so much so ignore our
crimes so ignore ours. jews have the largest per capita share.

I have not broached the history of AFRICA and Benjamin Disraeli ,
Cecil Rhodes and NATHAN Rothschild. The israeli UZIs have created a
wave of murder in africa and some parts of south america.

> It mostly comes down to resources: when people aren't hungry, they get along,
> when they are hungry, they ingeniously find a way to make less of themselves
> until there is enough food left so noone is hungry anymore. Add to this an
> unfortunate tendency for xenophobic behavior when different religions/cultures
> meet and humans can end up in a bad way.

The jews are hungry EVEN when they have PLENTY. Look at Bernard
Madoff. His Billions in FRAUD represent the BILLIONS in hatred by jews
who invested with him and became BLIND. The ZIONIST hatred of them
blinded them to his FRAUDs.

What about ROMAN POLANSKY ?

Your KHAZAR Race crimes are in CONTINUING mode, and no end in sight.

> Now, if you just blow up at me and denounce me as part of the
> group/conspiracy/cabal/whatever X, I'll simply ignore you forever since you
> have nothing to offer but misdirected frustration and hate. And, this being 
> the
> internet, there is plenty of that if I want it laying about in plain view.

The whole media is controlled by JEWS. NY TIMES, WASHINGTON POST, LA
TIMES ... and so on. I know you want me to shutup and you continue
with the past mode. Why dont you write to those who post porn ads, or
others ? you can certainly kill file me. We cannot stop the task of
general education of the public.

> I happened to have grown up in a hate filled environment. In the end, I
> understood why it was like that and I was sad since it was so unnecesary and
> all it did was destroy years out of the people's lives I knew and loved and 
> for
> nothing. When I went out into the world and looked, really wondering if it was
> like that, I simply found the world just isn't that way and doesn't want to be
> that way. It can be forced upon people--and is in more than a few places in 
> the
> world, but ultimately, people just want to go to work, eat their bread,
> contribute to society to make it better, and have meaning in their short
> existence.

Your ILK, after staging 911 deception, killed millions.

And as I told you, jews denied me job at many places. The FBI bustards
will never investigate. They are SO INCOMPETENT. The police ... many
of them have white spanish jews. The top man is often a jew.

> It's all academic anyway. This is a lisp group, and by my perception, you are 
> a
> troll of the worst kind. But, you are also human, so at least I would give you
> the decency of a meaningful response.

This term TROLL was also created by your ILK and popularized by them.
I have heard that it is very popular among RUSSIAN JEWS who have
migrated to US/UK/Canada . I assume, all the wealth belongs to your
group and everyone else is a TROLL. TROLL is that mythical creature
who is looking for gold ?

> Later,
> -pete

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


Re: A link to a collection of tutorials on LISP.

2010-06-27 Thread nanothermite911fbibustards
On Jun 27, 4:20 pm, nanothermite911fbibustards
 wrote:
> On Jun 27, 2:33 pm, Peter Keller  wrote:
>
> > nanothermite911fbibustards  wrote:
> > > That guys intention is not to spread tutorial, but its a commercial. I
> > > clarified its true nature.
>
> > Fair enough.
>
> > > Your ilk has special skill in turning white into black and vice-versa.
>
> > Assuming much there, aren't you?
>
> Not really. Your last name KELLER, reminds me very well of a Jew by
> the same last name who was delegated a task to interview me many years
> ago before 911 for a job in a corporation . I still remember his
> face . The chinese manager was interested but I saw a knowing smile on
> this keller's face , I never got the job. I had published excellent
> and lucid expository/tutorial paper(s) in the general field and
> especially strong background.
>
> > I think you'll find there are plenty of lies, deception, murder, torture,
> > economic warfare, etc, etc, etc in plain old humanity no matter the color,
> > race, or religion. Affixing a certain group as the point of origin of such
> > behavior completely sidesteps the problem of why it exists in the first 
> > place.
>
> This is typical hogwash that there has been so much so ignore our
> crimes so ignore ours. jews have the largest per capita share.
>
> I have not broached the history of AFRICA and Benjamin Disraeli ,
> Cecil Rhodes and NATHAN Rothschild. The israeli UZIs have created a
> wave of murder in africa and some parts of south america.
>
> > It mostly comes down to resources: when people aren't hungry, they get 
> > along,
> > when they are hungry, they ingeniously find a way to make less of themselves
> > until there is enough food left so noone is hungry anymore. Add to this an
> > unfortunate tendency for xenophobic behavior when different 
> > religions/cultures
> > meet and humans can end up in a bad way.
>
> The jews are hungry EVEN when they have PLENTY. Look at Bernard
> Madoff. His Billions in FRAUD represent the BILLIONS in hatred by jews
> who invested with him and became BLIND. The ZIONIST hatred of them
> blinded them to his FRAUDs.
>
> What about ROMAN POLANSKY ?
>
> Your KHAZAR Race crimes are in CONTINUING mode, and no end in sight.
>
> > Now, if you just blow up at me and denounce me as part of the
> > group/conspiracy/cabal/whatever X, I'll simply ignore you forever since you
> > have nothing to offer but misdirected frustration and hate. And, this being 
> > the
> > internet, there is plenty of that if I want it laying about in plain view.
>
> The whole media is controlled by JEWS. NY TIMES, WASHINGTON POST, LA
> TIMES ... and so on. I know you want me to shutup and you continue
> with the past mode. Why dont you write to those who post porn ads, or
> others ? you can certainly kill file me. We cannot stop the task of
> general education of the public.
>
> > I happened to have grown up in a hate filled environment. In the end, I
> > understood why it was like that and I was sad since it was so unnecesary and
> > all it did was destroy years out of the people's lives I knew and loved and 
> > for
> > nothing. When I went out into the world and looked, really wondering if it 
> > was
> > like that, I simply found the world just isn't that way and doesn't want to 
> > be
> > that way. It can be forced upon people--and is in more than a few places in 
> > the
> > world, but ultimately, people just want to go to work, eat their bread,
> > contribute to society to make it better, and have meaning in their short
> > existence.
>
> Your ILK, after staging 911 deception, killed millions.
>
> And as I told you, jews denied me job at many places. The FBI bustards
> will never investigate. They are SO INCOMPETENT. The police ... many
> of them have white spanish jews. The top man is often a jew.
>
> > It's all academic anyway. This is a lisp group, and by my perception, you 
> > are a
> > troll of the worst kind. But, you are also human, so at least I would give 
> > you
> > the decency of a meaningful response.
>
> This term TROLL was also created by your ILK and popularized by them.
> I have heard that it is very popular among RUSSIAN JEWS who have
> migrated to US/UK/Canada . I assume, all the wealth belongs to your
> group and everyone else is a TROLL. TROLL is that mythical creature
> who is looking for gold ?
>
> > Later,
> > -pete
>
>

I urge you to watch this excellent video on youtube by Rabbi Moshe
Domb, called

THE TRANSFORMATION

I urge you to watch this excellent video on youtube by Rabbi Moshe
Domb, called

THE TRANSFORMATION

I urge you to watch this excellent video on youtube by Rabbi Moshe
Domb, called

THE TRANSFORMATION

I urge you to watch this excellent video on youtube by Rabbi Moshe
Domb, called

THE TRANSFORMATION

I urge you to watch this excellent video on youtube by Rabbi Moshe
Domb, called

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


dynamically modify help text

2010-06-27 Thread Brian Blais

Hello,

I know that the help text for an object will give a description of  
every method based on the doc string.  Is there a way to add  
something to this text, specific to an object, but generated at run- 
time?  I have an object that reads a file, and I would like part of  
that file to be shown if one does:  help(myobject)



thanks,

Brian Blais

--
Brian Blais
bbl...@bryant.edu
http://web.bryant.edu/~bblais
http://bblais.blogspot.com/



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


Re: A link to a collection of tutorials on LISP.

2010-06-27 Thread Peter Keller
In comp.lang.lisp nanothermite911fbibustards 
 wrote:
> TROLL is that mythical creature who is looking for gold ?

Nope, they are the ones that jump out from under bridges and scare little
children cause they feel bad about themselves and need someone else to feel
powerful over. 

I hope you get better.

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


Re: Why are String Formatted Queries Considered So Magical?

2010-06-27 Thread Ben Finney
Carl Banks  writes:

> Seriously, almost every other kind of library uses a binary API.

Except for the huge number that deal with text protocols or languages.

> What makes databases so special that they need a string-command based
> API?

Because SQL is a text language.

-- 
 \  “In the long run, the utility of all non-Free software |
  `\  approaches zero. All non-Free software is a dead end.” —Mark |
_o__)Pilgrim, 2006 |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I strongly dislike Python 3

2010-06-27 Thread Tim Roberts
Stefan Reich  wrote:
>
>Consider Java as a better example: JDK 1.6 still runs and compiles 
>everything written for JDK 1.0. That is proper management.

And Python has the same management.  Python 2.6 still runs and compiles
everything written for Python 2.0.  If there is ever a JDK 2.0, I'll wager
it will have the same incompatibility issues as Python 3.0.  That "major
number" change is telling you something.  PHP 5 will not handle a lot of
PHP 4 code.

>Python 3 is, I'm sorry to say, an example of unfathomably bad management.

Are you arguing that language developers do not have the right to make
incompatible changes, ever?
-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: problems getting os.system and wxmenu to read options from a file and then execute

2010-06-27 Thread MRAB

eric_dex...@msn.com wrote:

I managed to get the program running and the menu options are
appearing on the list but the programs are not running.  I suspect it
is my onexecutemethod


[snip]


#add execute files from the text file list
idtool = 400
for e in menuoptions:
wx.EVT_MENU(self, idtool, self.OnExecute(idtool, e))


This calls the OnExecute method and then passes its result to
wx.EVT_MENU. If, for example, OnExecute is returning None, then that's
what is being passed into wx.EVT_MENU.

What you should actually be doing is passing a function which can be
called when the menu item is clicked, something like this:

wx.EVT_MENU(self, idtool, lambda idtool=idtool, e=e: 
self.OnExecute(idtool, e))



idtool += 1
##print e


[snip]

def OnExecute(self,tool,e):
print tool
os.system(e)
#print tool
# Get rid of the dialog to keep things tidy


[snip]

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


Re: refactoring a group of import statements

2010-06-27 Thread rantingrick
On Jun 27, 6:09 pm, Thomas Jollans  wrote:

> > import Tkinter as tk
> > try:
> >     import Image #from PIL
> >     print 'Using high quality images :)'
> > except ImportError:
> >     print 'Using low quality images :('
>
> As such, that still appears rather useless - the following code doesn't
> know how to behave ;-) Take this example from my own code: ;-)

Ah yes that was me trying to save a little server space by not posting
my whole script. So Yes I did leave a little "mystery" for the
advanced reader to dissect. *wink*

> Yes, sometimes these checks are needed, because a module can enhance
> your code if it's present. But that tends to be the exception rather
> than the rule, and would usually require some extra code to make the
> check useful in the first place, which makes a generalized for loop over
> a bunch of modules appear to be of little utility

agreed! However i was going to let the OP find this out though his own
realization and in the meantime show him the power of eval/exec even
if it could blow a pinky toe off ;-).

> Ah yes, exec. I've never liked exec - I find
> globals()[x] = __import__(x)
> clearer. But that might be just me.

What's the irrational fear/hatred some have of eval and exec? You *do*
know that harnessing these facilities simply invokes an underlying
process that the interpretor itself uses every time you import or run
a script. So if you fear eval/exec you *really* should fear the Python
interpretor *gasp*! Does that seem logical? Really don't fear eval/
exec! No, fear the while loop as it's much more apt to breaking loose
and running amuck!


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


Re: A link to a collection of tutorials on LISP.

2010-06-27 Thread nanothermite911fbibustards
On Jun 27, 4:26 pm, Peter Keller  wrote:
> In comp.lang.lisp nanothermite911fbibustards 
>  wrote:
>
> > TROLL is that mythical creature who is looking for gold ?
>
> Nope, they are the ones that jump out from under bridges and scare little
> children cause they feel bad about themselves and need someone else to feel
> powerful over.
>
> I hope you get better.
>
> Later,
> -pete

Well, then that definition applies to the zionist jews.

the ones who attacked the flottila at 3-4 AM in the morning and killed
9 people.
injured upto hundreds

Then the TROLLS destroyed and STOLE all live footage to HIDE the
EVIDENCE

 HIDE the EVIDENCE
 HIDE the EVIDENCE
 HIDE the EVIDENCE
 HIDE the EVIDENCE
 HIDE the EVIDENCE

jews do it ...

Here is the video, enjoy with your family.

http://www.youtube.com/watch?v=z3bb4vMhuq8
http://www.youtube.com/watch?v=z3bb4vMhuq8
http://www.youtube.com/watch?v=z3bb4vMhuq8

http://www.youtube.com/results?search_query=osama+qashoo&aq=f
http://www.youtube.com/results?search_query=osama+qashoo&aq=f
http://www.youtube.com/results?search_query=osama+qashoo&aq=f


UNDERSTAND CLEARLY, that as a result of many jews including that
KELLER, I lost VALUABLE CAREER opportunities !
UNDERSTAND CLEARLY, that as a result of many jews including that
KELLER, I lost VALUABLE CAREER opportunities !

It cant be : Heads you win and Tails I lose.
It cant be : Heads you win and Tails I lose.
It cant be : Heads you win and Tails I lose.

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


Why Python3

2010-06-27 Thread Terry Reedy
Some people appear to not understand the purpose of Python3 or more 
specifically, of the changes that break Python2 code. I attempt here to 
give a relatively full explanation.


SUMMARY: Python3 completes (or makes progress in) several transitions 
begun in Python2.


In particular, Python3 bunches together several feature removals (which 
always break someone's code) and a few feature changes (which also break 
code). The alternative would have been to make the same changes, a few 
at a time, over several releases, starting with about 2.5.


Another alternative would have been to declare 2.0 or 2.1 complete at 
far as it went and forbid adding new features that duplicate and 
supersede existing features.


Another would have been to add but never remove anthing, with the 
consequence that Python would become increasingly difficult to learn and 
the interpreter increasingly difficult to maintain with volunteers. I 
think 2.7 is far enough in that direction.


SPECIFIC REPLACEMENTS:

1. Integer division

In Python1, arithmetic expressions are mostly generic (polymophic) in 
that they have the same meaning for all builtin number types. The 
glaring exception is division, which has a special meaning for pairs of 
integers. Newbies were constantly surprised that 1/2 equals 0.


Guido proposed to fix the situation with a second division operator 
'//', with a standard warning/deprecation/removal process for the old 
behavior over three releases, perhaps ending with 2.5. In response to 
complaints about having to find and examine every use of '/', Guido 
promised that there would be a helper program. I proposed that the 
version that had only the new behavior, without 'from __future__ import 
division', be named 3.0 to signal the change.


Guido obviously decide to make a lot more changes in a 3.0 release. And 
the helper program was expanded to the current 2to3. In any case, 
Python3 finished the integer division transition.


2. User classes

In Python1, user classes, defined with a class statement, are instances 
of a class type and are otherwise separate from and cannot inherit from 
builtin types. Instances of user classes are actually instances of an 
instance type, not of the user class.


Python2.2 introduced a unified class-type system. Instead of 'from 
__future__ import newclass', the new system was invoked by defining 
__metaclass__ or inheriting from a future class. Python3 finished this 
transition by dropping ClassType and InstanceType and making the 
built-in class 'object' the default baseclass for all user classes.


3. User-defined exceptions

In Python1, user usually defined exceptions by using strings as 
exceptions, with the caveat that it was the identity and not the value 
of the string that defined the exception. The ability to subclass 
built-in exceptions made this obsolete. String exceptions were 
discouraged in 2.5 and removed in 3.0, completing another transition. 
Now all exceptions are instances of subclasses of BaseException.


4. Function application

Suppose one has a function f, object sequence args, and name-object 
mapping kwds, and one wants to call f with the *contents* of args and 
kwds as arguments. Calling f(args,kwds) does not do that as it would 
pass the collections themselves as a pair of arguments. In Python1, one 
called apply(f, args, kwds). Python2 introduced the synonym syntac 
f(*args,**kwds) and deprecated 'apply' by 2.5. Python3 removed apply, 
completing the transition.


5. Date interchange

In Python1, lists are the primary data interchange type used by built-in 
functions such as filter, map, and range. Python2.2 introduced a new 
iterator/iterable protocal, the iterator class 'generator', and 
generator functions. One advantage is that iterables and iterators can 
compactly represent virtual sequences of indefinite length. Another is 
that non-sequence collections, like sets and dicts, used be made 
iterable. Python2.3 introduced iterator versions of filter map, and zip 
in the itertools module. It also defined the new built-in function 
enumerate as returning an iterator rather than a list, as would have 
been the case if introduced much earlier. 2.4 introduce 'reversed' as 
returning an iterator. (The new in 2.4 'sorted' returns a list because 
it has to contruct one anyway.)


Pyhon3 moved much closer to replacing lists with iterators as the 
primary data interchange format. Ifilter, imap, and izip replaced 
filter, map, and zip. Xrange, which preceded 2.2, replaced range. 
Getting lists, as previously, is easy with 'list()'. The transition is 
not complete (and may never be), as slicing still returns a subsequence 
rather than an iterator, so itertools still has islice.


6. Integers

Python1 had two separate integer types, int and long. I believe that 
integer operations overflowed if the answer was too large. At some 
point, the two types were partially unified in that ints were converted 
to long when necessary to avoid overflow. At this point,

Re: I strongly dislike Python 3

2010-06-27 Thread Grant Edwards
On 2010-06-27, Benjamin Kaplan  wrote:

>> It should be easier to have a large number of python versions on one
>> machine... ?I am realy fond of 2.5 so I am probily going to start
>> compiling them or just include the python2.5 exe if I port stuff and
>> settle it that way..
>
> You're on the only platform where it isn't that easy. All us *nix
> users have to do is compile it with the altinstall flag, and then use
> #!/usr/bin/env python25
> Windows uses the file extension instead of the shebang line to execute
> stuff, so it's harder for you to have multiple versions.

If you install a real shell on Windows, then the hash-bang line works
fine. :)

-- 
Grant


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


Re: Why Python3

2010-06-27 Thread MRAB

Terry Reedy wrote:
Some people appear to not understand the purpose of Python3 or more 
specifically, of the changes that break Python2 code. I attempt here to 
give a relatively full explanation.


SUMMARY: Python3 completes (or makes progress in) several transitions 
begun in Python2.


In particular, Python3 bunches together several feature removals (which 
always break someone's code) and a few feature changes (which also break 
code). The alternative would have been to make the same changes, a few 
at a time, over several releases, starting with about 2.5.


Another alternative would have been to declare 2.0 or 2.1 complete at 
far as it went and forbid adding new features that duplicate and 
supersede existing features.


Another would have been to add but never remove anthing, with the 
consequence that Python would become increasingly difficult to learn and 
the interpreter increasingly difficult to maintain with volunteers. I 
think 2.7 is far enough in that direction.



[snip]
It's clear that Guido's time machine is limited in how far it can travel
in time, because if it wasn't then Python 1 would've been more like
Python 3 and the changes would not have been necessary! :-)
--
http://mail.python.org/mailman/listinfo/python-list


Re: I strongly dislike Python 3

2010-06-27 Thread geremy condra
On Sun, Jun 27, 2010 at 8:50 PM, Grant Edwards  wrote:
> On 2010-06-27, Benjamin Kaplan  wrote:
>
>>> It should be easier to have a large number of python versions on one
>>> machine... ?I am realy fond of 2.5 so I am probily going to start
>>> compiling them or just include the python2.5 exe if I port stuff and
>>> settle it that way..
>>
>> You're on the only platform where it isn't that easy. All us *nix
>> users have to do is compile it with the altinstall flag, and then use
>> #!/usr/bin/env python25
>> Windows uses the file extension instead of the shebang line to execute
>> stuff, so it's harder for you to have multiple versions.
>
> If you install a real shell on Windows, then the hash-bang line works
> fine. :)

Might as well spare yourself the trouble and install linux or *bsd. It's
probably easier.

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


Re: python source code -> win/dos executable (on linux)

2010-06-27 Thread Lawrence D'Oliveiro
In message <4c24c152$0$31381$4fafb...@reader1.news.tin.it>, superpollo 
wrote:

> suppose i work in a linux environment, but i would like to ship a
> win/dos executable file from time to time, just for test purposes (my
> "testers" are windows users and don't want to go through the hassle of
> installing python on their win boxes).

Is it really such a hassle to install things on Windows?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why Python3

2010-06-27 Thread Stephen Hansen

On 6/27/10 6:09 PM, MRAB wrote:

Terry Reedy wrote:

Another would have been to add but never remove anthing, with the
consequence that Python would become increasingly difficult to learn
and the interpreter increasingly difficult to maintain with
volunteers. I think 2.7 is far enough in that direction.


[snip]
It's clear that Guido's time machine is limited in how far it can travel
in time, because if it wasn't then Python 1 would've been more like
Python 3 and the changes would not have been necessary! :-)


I'm pretty sure he wrote the Time Machine in Python 1.4, or maybe 1.3? 
Either way, its well established that a time machine can't go back in 
time any farther then the moment its created.


I don't at all remember why, don't even vaguely understand the physics 
behind it, but Morgan Freeman said it on TV, so its true.


So he couldn't go back and fix 1.0, physics won't allow him. So we're 
stuck with the Py3k break. :)


--

   ... Stephen Hansen
   ... Also: Ixokai
   ... Mail: me+list/python (AT) ixokai (DOT) io
   ... Blog: http://meh.ixokai.io/

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


Re: I strongly dislike Python 3

2010-06-27 Thread Stephen Hansen

On 6/27/10 6:11 PM, geremy condra wrote:

On Sun, Jun 27, 2010 at 8:50 PM, Grant Edwards  wrote:

If you install a real shell on Windows, then the hash-bang line works
fine. :)


Might as well spare yourself the trouble and install linux or *bsd. It's
probably easier.


Not at all, bash via msys is trivial to install and use.

--

   ... Stephen Hansen
   ... Also: Ixokai
   ... Mail: me+list/python (AT) ixokai (DOT) io
   ... Blog: http://meh.ixokai.io/

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


Re: I strongly dislike Python 3

2010-06-27 Thread John Bokma
geremy condra  writes:

> On Sun, Jun 27, 2010 at 8:50 PM, Grant Edwards  
> wrote:
>> On 2010-06-27, Benjamin Kaplan  wrote:
>>
 It should be easier to have a large number of python versions on one
 machine... ?I am realy fond of 2.5 so I am probily going to start
 compiling them or just include the python2.5 exe if I port stuff and
 settle it that way..
>>>
>>> You're on the only platform where it isn't that easy. All us *nix
>>> users have to do is compile it with the altinstall flag, and then use
>>> #!/usr/bin/env python25
>>> Windows uses the file extension instead of the shebang line to execute
>>> stuff, so it's harder for you to have multiple versions.
>>
>> If you install a real shell on Windows, then the hash-bang line works
>> fine. :)
>
> Might as well spare yourself the trouble and install linux or *bsd. It's
> probably easier.

Ah, yeah, and then run all those Windows applications one requires on
Wine...

-- 
John Bokma   j3b

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


Re: I strongly dislike Python 3

2010-06-27 Thread Grant Edwards
On 2010-06-28, geremy condra  wrote:
> On Sun, Jun 27, 2010 at 8:50 PM, Grant Edwards  
> wrote:
>> On 2010-06-27, Benjamin Kaplan  wrote:
>>
 It should be easier to have a large number of python versions on one
 machine... ?I am realy fond of 2.5 so I am probily going to start
 compiling them or just include the python2.5 exe if I port stuff and
 settle it that way..
>>>
>>> You're on the only platform where it isn't that easy. All us *nix
>>> users have to do is compile it with the altinstall flag, and then use
>>> #!/usr/bin/env python25
>>> Windows uses the file extension instead of the shebang line to execute
>>> stuff, so it's harder for you to have multiple versions.
>>
>> If you install a real shell on Windows, then the hash-bang line works
>> fine. :)
>
> Might as well spare yourself the trouble and install linux or *bsd. It's
> probably easier.

In some cases it's definitely easier to install Linux than Cygwin.

-- 
Grant


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


Re: python source code -> win/dos executable (on linux)

2010-06-27 Thread Grant Edwards
On 2010-06-28, Lawrence D'Oliveiro  wrote:
> In message <4c24c152$0$31381$4fafb...@reader1.news.tin.it>, superpollo 
> wrote:
>
>> suppose i work in a linux environment, but i would like to ship a
>> win/dos executable file from time to time, just for test purposes (my
>> "testers" are windows users and don't want to go through the hassle of
>> installing python on their win boxes).
>
> Is it really such a hassle to install things on Windows?

Sometimes.  But, no matter how easy it is, if you rely on your
customers to install some third party SW that's required for your
program to work, they'll figure out a way to screw it up.

If you're shipping a Windows program, you can barely count on the
target machine having a working base Windows install.  Expecting
something else to be there is pure fantasy.

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


Re: problems getting os.system and wxmenu to read options from a file and then execute

2010-06-27 Thread eric dexter
On Jun 27, 5:56 pm, MRAB  wrote:
> eric_dex...@msn.com wrote:
> > I managed to get the program running and the menu options are
> > appearing on the list but the programs are not running.  I suspect it
> > is my onexecutemethod
>
> [snip]
>
> >         #add execute files from the text file list
> >         idtool = 400
> >         for e in menuoptions:
> >             wx.EVT_MENU(self, idtool, self.OnExecute(idtool, e))
>
> This calls the OnExecute method and then passes its result to
> wx.EVT_MENU. If, for example, OnExecute is returning None, then that's
> what is being passed into wx.EVT_MENU.
>
> What you should actually be doing is passing a function which can be
> called when the menu item is clicked, something like this:
>
>              wx.EVT_MENU(self, idtool, lambda idtool=idtool, e=e:
> self.OnExecute(idtool, e))
>
> >             idtool += 1
> >             ##print e
>
> [snip]
> >     def OnExecute(self,tool,e):
> >         print tool
> >         os.system(e)
> >         #print tool
> >         # Get rid of the dialog to keep things tidy
>
> [snip]

wx.EVT_MENU(self, idtool, self.OnExecute(idtool, e))

I changed it to this and it seems to be calling self.OnExecute befour
the editor comes up and then after the editor is up it doesn't respond
to anything.  I got rid off all the spaces but one in the text file (I
supose I need to use the strip method in real like though)..  I was
able to get an infinite loop by calling the editor as one of the
options and then it keeps calling itself.  It may be another problem
or perhaps I didn't grasp the answer.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why Python3

2010-06-27 Thread MRAB

Stephen Hansen wrote:

On 6/27/10 6:09 PM, MRAB wrote:

Terry Reedy wrote:

Another would have been to add but never remove anthing, with the
consequence that Python would become increasingly difficult to learn
and the interpreter increasingly difficult to maintain with
volunteers. I think 2.7 is far enough in that direction.


[snip]
It's clear that Guido's time machine is limited in how far it can travel
in time, because if it wasn't then Python 1 would've been more like
Python 3 and the changes would not have been necessary! :-)


I'm pretty sure he wrote the Time Machine in Python 1.4, or maybe 1.3? 
Either way, its well established that a time machine can't go back in 
time any farther then the moment its created.


I don't at all remember why, don't even vaguely understand the physics 
behind it, but Morgan Freeman said it on TV, so its true.



That's if the time machines uses a wormhole:

>>> import wormhole

Unfortunately it's not part of the standard library. :-(

So he couldn't go back and fix 1.0, physics won't allow him. So we're 
stuck with the Py3k break. :)




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


Re: Why Is Escaping Data Considered So Magical?

2010-06-27 Thread Owen Jacobson

On 2010-06-26 22:33:57 -0400, Lawrence D'Oliveiro said:


In message <2010062522560231540-angrybald...@gmailcom>, Owen Jacobson wrote:


It's not hard. It's just begging for a visit from the fuckup fairy.


That’s the same fallacious argument I pointed out earlier.


In the sense that "using correct manual escaping leads to SQL injection 
vulnerabilities", yes, that's a fallacious argument on its own. 
However, as sites like BUGTRAQ amply demonstrate, generating SQL 
through string manipulation is a risky development practice[0]. You can 
continue to justify your choice to do so however you want, and you may 
even be the One True Developer capable of getting it absolutely right 
under all circumstances, but I'd still reject patches that introduced a 
SQLString-like function and ask that you resubmit them using the 
database API's parameterization tools instead.


Assuming for the sake of discussion that your SQLString function 
perfectly captures the transformation required to turn an arbitrary str 
into a MySQL string literal. How do you address the following issues?


1. Other (possibly inexperienced) developers reading your source who 
may not have the skills to correctly implement the same transform 
correctly learn from your programs that writing your own query munger 
is okay.
1a. Other (possibly inexperienced) developers decide to copy and paste 
your function without fully understanding how it works, in tandem with 
any of the other issues below. (If you think this is rare, I invite you 
to visit stackoverflow or roseindia some time.)


2. MySQL changes the quoting and escaping rules to address a 
bug/feature request/developer whim, introducing a new set of corner 
cases into your function and forcing you to re-learn the escaping and 
quoting rules. (For people using DB API parameters, this is a matter of 
upgrading the DB adapter module to a version that supports the modified 
rules.)


3. You decide to switch from MySQL to a more fully-featured RDBMS, 
which may have different quoting and escaping rules around string 
literals.
3a. *Someone else* decides to port your program to a different RDBMS, 
and may not understand that SQLString implements MySQL's quoting and 
escaping rules only.


4. MySQL AB finally get off their collective duffs and adds real 
parameter separation to the MySQL wire protocol, and implements real 
prepared statements to massive speed gains in scenarios that are 
relevant to your interests; string-based query construction gets left 
out in the cold.
4a. As with case 3, except that instead of the rules changing when you 
move to a new RDBMS, it's the relative performance of submitting new 
queries versus reusing a parameterized query that changes.


On top of the obvious issue of completely avoiding quoting bugs, using 
query parameters rather than escaping and string manipulation neatly 
saves you from having to address any of these problems (and a multitude 
of others) -- the DB API implementation will handle things for you, and 
you are propagating good practice in an easy-to-understand form.


I am honestly at a loss trying to understand your position. There is a 
huge body of documentation out there about the weaknesses of 
string-manipulation-based approaches to query construction, and the use 
of query parameters is so compellingly the Right Thing that I have a 
very hard time comprehending why anyone would opt not to use it except 
out of pure ignorance of their existence. Generating executable code -- 
including SQL -- from untrusted user input introduces an large 
vulnerability surface for very little benefit.


You don't handle function parameters by building up python-language 
strs containing the values as literals and eval'ing them, do you?


-o

[0] If you want to be *really* pedantic, string-manipulation-based 
query construction is strongly correlated with the occurrence of SQL 
injection vulnerabilities and bugs, which is in turn not strongly 
correlated with very many other practices. Happy?


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


Re: Why Python3

2010-06-27 Thread eric dexter
On Jun 27, 7:46 pm, MRAB  wrote:
> Stephen Hansen wrote:
> > On 6/27/10 6:09 PM, MRAB wrote:
> >> Terry Reedy wrote:
> >>> Another would have been to add but never remove anthing, with the
> >>> consequence that Python would become increasingly difficult to learn
> >>> and the interpreter increasingly difficult to maintain with
> >>> volunteers. I think 2.7 is far enough in that direction.
>
> >> [snip]
> >> It's clear that Guido's time machine is limited in how far it can travel
> >> in time, because if it wasn't then Python 1 would've been more like
> >> Python 3 and the changes would not have been necessary! :-)
>
> > I'm pretty sure he wrote the Time Machine in Python 1.4, or maybe 1.3?
> > Either way, its well established that a time machine can't go back in
> > time any farther then the moment its created.
>
> > I don't at all remember why, don't even vaguely understand the physics
> > behind it, but Morgan Freeman said it on TV, so its true.
>
> That's if the time machines uses a wormhole:
>
>  >>> import wormhole
>
> Unfortunately it's not part of the standard library. :-(
>
> > So he couldn't go back and fix 1.0, physics won't allow him. So we're
> > stuck with the Py3k break. :)
>
>

planned obselence..  It would be nice if a pause was taken at 3.5 and
a huge number of libraries were made available for 3.5..
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python source code -> win/dos executable (on linux)

2010-06-27 Thread David Robinow
On Sun, Jun 27, 2010 at 9:16 PM, Lawrence D'Oliveiro
 wrote:
> In message <4c24c152$0$31381$4fafb...@reader1.news.tin.it>, superpollo
> wrote:
>
>> suppose i work in a linux environment, but i would like to ship a
>> win/dos executable file from time to time, just for test purposes (my
>> "testers" are windows users and don't want to go through the hassle of
>> installing python on their win boxes).
>
> Is it really such a hassle to install things on Windows?
 I find it somewhat easier than on Ubuntu, but I think you've missed the point.
-- 
http://mail.python.org/mailman/listinfo/python-list


Need instruction on how to use isinstance

2010-06-27 Thread Steven W. Orr
I need to test an argument for a few different types.

I'm calling my function like this

arf = MyFunc(list)

What I want to do is to test for whether something is a string, tuple, list or
function. It's that last one that's causing me a problem.

if isinstance(arg, (str, tuple, list)):

No problem, but there are a lot of types that the type function returns. If I
have a simple function

def foo():
pass
type(foo)
prints out


So, my question is, what value can I use as the 2nd arg to isinstance to see if
foo is a function? And while I'm on the subject, what types does isinstance not
support?

And last, what is the correct way to do it if this is not the right way?

TIA (and hoping I'm clear)

-- 
Time flies like the wind. Fruit flies like a banana. Stranger things have  .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I strongly dislike Python 3

2010-06-27 Thread Ben Finney
Terry Reedy  writes:

> On 6/27/2010 8:41 AM, David Cournapeau wrote:
> > I think one point which needs to be emphasized more is what does
> > python 3 bring to people.
[…]

> Python3 is about finishing transitions. The last stage in a transition
> that replaces something old with something new is to remove the old,
> after showing that the new works. […]

+1 QOTW

-- 
 \“Perchance you who pronounce my sentence are in greater fear |
  `\   than I who receive it.” —Giordano Bruno, burned at the stake by |
_o__)  the Catholic church for the heresy of heliocentrism, 1600-02-16 |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why Python3

2010-06-27 Thread Benjamin Kaplan
On Sun, Jun 27, 2010 at 6:51 PM, eric dexter  wrote:
> On Jun 27, 7:46 pm, MRAB  wrote:
>> Stephen Hansen wrote:
>> > On 6/27/10 6:09 PM, MRAB wrote:
>> >> Terry Reedy wrote:
>> >>> Another would have been to add but never remove anthing, with the
>> >>> consequence that Python would become increasingly difficult to learn
>> >>> and the interpreter increasingly difficult to maintain with
>> >>> volunteers. I think 2.7 is far enough in that direction.
>>
>> >> [snip]
>> >> It's clear that Guido's time machine is limited in how far it can travel
>> >> in time, because if it wasn't then Python 1 would've been more like
>> >> Python 3 and the changes would not have been necessary! :-)
>>
>> > I'm pretty sure he wrote the Time Machine in Python 1.4, or maybe 1.3?
>> > Either way, its well established that a time machine can't go back in
>> > time any farther then the moment its created.
>>
>> > I don't at all remember why, don't even vaguely understand the physics
>> > behind it, but Morgan Freeman said it on TV, so its true.
>>
>> That's if the time machines uses a wormhole:
>>
>>  >>> import wormhole
>>
>> Unfortunately it's not part of the standard library. :-(
>>
>> > So he couldn't go back and fix 1.0, physics won't allow him. So we're
>> > stuck with the Py3k break. :)
>>
>>
>
> planned obselence..  It would be nice if a pause was taken at 3.5 and
> a huge number of libraries were made available for 3.5..
> --

You mean as opposed to a 2-year pause at 3.1 so that a huge number of
libraries and alternate Python implementations could catch up?
http://www.python.org/dev/peps/pep-3003/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: I strongly dislike Python 3

2010-06-27 Thread geremy condra
On Sun, Jun 27, 2010 at 9:25 PM, John Bokma  wrote:
> geremy condra  writes:
>
>> On Sun, Jun 27, 2010 at 8:50 PM, Grant Edwards  
>> wrote:
>>> On 2010-06-27, Benjamin Kaplan  wrote:
>>>
> It should be easier to have a large number of python versions on one
> machine... ?I am realy fond of 2.5 so I am probily going to start
> compiling them or just include the python2.5 exe if I port stuff and
> settle it that way..

 You're on the only platform where it isn't that easy. All us *nix
 users have to do is compile it with the altinstall flag, and then use
 #!/usr/bin/env python25
 Windows uses the file extension instead of the shebang line to execute
 stuff, so it's harder for you to have multiple versions.
>>>
>>> If you install a real shell on Windows, then the hash-bang line works
>>> fine. :)
>>
>> Might as well spare yourself the trouble and install linux or *bsd. It's
>> probably easier.
>
> Ah, yeah, and then run all those Windows applications one requires on
> Wine...

If you're bound to a platform, use it. My advice is just to get bound to
a platform that does what you need it to do, and in my experience it's
quite a bit easier to teach linux to do what you wanted windows to do
than the other way around.

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


Re: problems getting os.system and wxmenu to read options from a file and then execute

2010-06-27 Thread MRAB

eric dexter wrote:

On Jun 27, 5:56 pm, MRAB  wrote:

eric_dex...@msn.com wrote:

I managed to get the program running and the menu options are
appearing on the list but the programs are not running.  I suspect it
is my onexecutemethod

[snip]


#add execute files from the text file list
idtool = 400
for e in menuoptions:
wx.EVT_MENU(self, idtool, self.OnExecute(idtool, e))

This calls the OnExecute method and then passes its result to
wx.EVT_MENU. If, for example, OnExecute is returning None, then that's
what is being passed into wx.EVT_MENU.

What you should actually be doing is passing a function which can be
called when the menu item is clicked, something like this:

 wx.EVT_MENU(self, idtool, lambda idtool=idtool, e=e:
self.OnExecute(idtool, e))


idtool += 1
##print e

[snip]

def OnExecute(self,tool,e):
print tool
os.system(e)
#print tool
# Get rid of the dialog to keep things tidy

[snip]


wx.EVT_MENU(self, idtool, self.OnExecute(idtool, e))

I changed it to this and it seems to be calling self.OnExecute befour
the editor comes up and then after the editor is up it doesn't respond
to anything.

>
That is what the line was in your original post, and I explained the
change you needed to do.

> I got rid off all the spaces but one in the text file (I

supose I need to use the strip method in real like though)..  I was
able to get an infinite loop by calling the editor as one of the
options and then it keeps calling itself.  It may be another problem
or perhaps I didn't grasp the answer.

>
I've noticed that you're opening the menu file before the class
statement but reading from it in the __init__ method. It would be better
if you opened the file in the __init__ method itself. You can split a
line on whitespace with:

t = line.split()

It won't then matter how many spaces or tabs are between the fields.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Why Python3

2010-06-27 Thread geremy condra
On Sun, Jun 27, 2010 at 9:46 PM, MRAB  wrote:
> Stephen Hansen wrote:
>>
>> On 6/27/10 6:09 PM, MRAB wrote:
>>>
>>> Terry Reedy wrote:

 Another would have been to add but never remove anthing, with the
 consequence that Python would become increasingly difficult to learn
 and the interpreter increasingly difficult to maintain with
 volunteers. I think 2.7 is far enough in that direction.

>>> [snip]
>>> It's clear that Guido's time machine is limited in how far it can travel
>>> in time, because if it wasn't then Python 1 would've been more like
>>> Python 3 and the changes would not have been necessary! :-)
>>
>> I'm pretty sure he wrote the Time Machine in Python 1.4, or maybe 1.3?
>> Either way, its well established that a time machine can't go back in time
>> any farther then the moment its created.
>>
>> I don't at all remember why, don't even vaguely understand the physics
>> behind it, but Morgan Freeman said it on TV, so its true.
>>
> That's if the time machines uses a wormhole:
>
 import wormhole
>
> Unfortunately it's not part of the standard library. :-(

Batteries- but not flux capacitors- included.

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


Re: Need instruction on how to use isinstance

2010-06-27 Thread Stephen Hansen

On 6/27/10 7:09 PM, Steven W. Orr wrote:

So, my question is, what value can I use as the 2nd arg to isinstance to see if
foo is a function? And while I'm on the subject, what types does isinstance not
support?


Does it have to be a function? -- There's quite a few things which are 
function-y enough that you really should accept them even if they may 
not be technically a /function/. Like a class instance with the __call__ 
method defined wrapping a function as a decorator. Or a bound method, 
really.


In Python 2.x, you can use callable(fun) -- that goes away in Py3 
though. But personally, I think this is the wrong approach.


I'm assuming you need to do some different sort of behavior based on if 
its a str, tuple or list-- okay.


But, personally-- at that point, I would just *assume* the argument is a 
function. And call it.


If it can't be called, its not a functiony-thing. You can either let 
that traceback propagate, or just raise a TypeError "expected arg to be 
a string, tuple, list or callable".


Then again, similarly I almost never want to test for if somethings a 
tuple or list. I'd rather use it as a sequence type and see if it works: 
while there's not as many 'sequency-like-things' out there as there are 
function-like-things, there's still quite a few.


So personally, I'd check if its a string (can it be unicode or regular? 
If so isinstance(x,basestring)).


Then I'd try to use it as a sequence, doing whatever I woulda done with 
it sequence-like. If that works, great. If not, I'd try to call it.


Etc.

Then again it does depend on just what you're *doing* with the arg being 
passed in.


--

   ... Stephen Hansen
   ... Also: Ixokai
   ... Mail: me+list/python (AT) ixokai (DOT) io
   ... Blog: http://meh.ixokai.io/

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


Re: Need instruction on how to use isinstance

2010-06-27 Thread MRAB

Steven W. Orr wrote:

I need to test an argument for a few different types.

I'm calling my function like this

arf = MyFunc(list)

What I want to do is to test for whether something is a string, tuple, list or
function. It's that last one that's causing me a problem.

if isinstance(arg, (str, tuple, list)):

No problem, but there are a lot of types that the type function returns. If I
have a simple function

def foo():
pass
type(foo)
prints out


So, my question is, what value can I use as the 2nd arg to isinstance to see if
foo is a function? And while I'm on the subject, what types does isinstance not
support?



>>> def foo():
... pass
...
>>> import types
>>> dir(types)
['BooleanType', 'BufferType', 'BuiltinFunctionType', 
'BuiltinMethodType', 'ClassType', 'CodeType', 'ComplexType', 
'DictProxyType', 'DictType', 'DictionaryType', 'EllipsisType', 
'FileType', 'FloatType', 'FrameType', 'FunctionType', 'GeneratorType', 
'GetSetDescriptorType', 'InstanceType', 'IntType', 'LambdaType', 
'ListType', 'LongType', 'MemberDescriptorType', 'MethodType', 
'ModuleType', 'NoneType', 'NotImplementedType', 'ObjectType', 
'SliceType', 'StringType', 'StringTypes', 'TracebackType', 'TupleType', 
'TypeType', 'UnboundMethodType', 'UnicodeType', 'XRangeType', 
'__builtins__', '__doc__', '__file__', '__name__', '__package__']

>>> isinstance(f, types.FunctionType)
True
>>>


And last, what is the correct way to do it if this is not the right way?


Why do you want to know what type it is? Do you want to do different
things depending on the type? If the same function can return instances
of any number of unrelated types/classes, then there's something wrong
in your design! (You should also learn what "duck typing" is!) :-)
--
http://mail.python.org/mailman/listinfo/python-list


Re: I strongly dislike Python 3

2010-06-27 Thread John Bokma
geremy condra  writes:

> On Sun, Jun 27, 2010 at 9:25 PM, John Bokma  wrote:
>> geremy condra  writes:
>>
>>> On Sun, Jun 27, 2010 at 8:50 PM, Grant Edwards  
>>> wrote:
 On 2010-06-27, Benjamin Kaplan  wrote:

>> It should be easier to have a large number of python versions on one
>> machine... ?I am realy fond of 2.5 so I am probily going to start
>> compiling them or just include the python2.5 exe if I port stuff and
>> settle it that way..
>
> You're on the only platform where it isn't that easy. All us *nix
> users have to do is compile it with the altinstall flag, and then use
> #!/usr/bin/env python25
> Windows uses the file extension instead of the shebang line to execute
> stuff, so it's harder for you to have multiple versions.

 If you install a real shell on Windows, then the hash-bang line works
 fine. :)
>>>
>>> Might as well spare yourself the trouble and install linux or *bsd. It's
>>> probably easier.
>>
>> Ah, yeah, and then run all those Windows applications one requires on
>> Wine...
>
> If you're bound to a platform, use it. My advice is just to get bound to
> a platform that does what you need it to do, and in my experience it's
> quite a bit easier to teach linux to do what you wanted windows to do
> than the other way around.

I've used several operating systems over many years and each OS has its
own issues. I am currently using mostly Linux and it's far from the
flawless OS some people seem to think it is. While it's true that some
things are easier on OS A than on OS B changing your operating system
because one (minor) thing "doesn't work" is often not an option.

On top of that, I don't think it's that hard to make a small program
that one associates with .py files which checks the first line and feeds
the .py to the correct version of Python based on the information in the
aformentioned first line.

Another option (instead of installing a better shell) might be to make
several VMs, each with their own Python version. Run subversion (or any
other version control system) on your host, and you can test whatever
you want.

There are plenty of people who are very happy with coding under an MS
OS. I now and then miss those days :-).

-- 
John Bokma   j3b

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


Re: dynamically modify help text

2010-06-27 Thread Red Forks
Read you doc file and set the __doc__ attr of the object you want to change.

On Monday, June 28, 2010, Brian Blais  wrote:
> Hello,
>
> I know that the help text for an object will give a description of every 
> method based on the doc string.  Is there a way to add something to this 
> text, specific to an object, but generated at run-time?  I have an object 
> that reads a file, and I would like part of that file to be shown if one 
> does:  help(myobject)
>
>
>                         thanks,
>
>                                 Brian Blais
>
> --
> Brian Blais
> bbl...@bryant.edu
> http://web.bryant.edu/~bblais
> http://bblais.blogspot.com/
>
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why are String Formatted Queries Considered So Magical?

2010-06-27 Thread Carl Banks
On Jun 27, 4:35 pm, Ben Finney  wrote:
> Carl Banks  writes:
> > Seriously, almost every other kind of library uses a binary API.
>
> Except for the huge number that deal with text protocols or languages.

No, not really.  Almost all types of libraries have binary APIs,
including those that deal with text protocols or language.  Any
control with string commands is something that's built on top of the
binary API.  And culturally, programmers interfacing those libraries
expect to and are expected to use the binary API for low-level
programming.

RDBs, as a whole, either don't have binary APIs or they have them but
no one really uses them.


> > What makes databases so special that they need a string-command based
> > API?
>
> Because SQL is a text language.

Circular logic.  I'm disappointed, usually when you sit on your
reinforced soapbox and pretense the air of infinite expertise you at
least use reasonable logic.

Also, I was asking about databases.  "SQL is a text language" is not
the answer to the question "Why do RDBs use string commands instead of
binary APIs"?


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


Re: I strongly dislike Python 3

2010-06-27 Thread Stephen Hansen

On 6/27/10 7:35 PM, John Bokma wrote:

On top of that, I don't think it's that hard to make a small program
that one associates with .py files which checks the first line and feeds
the .py to the correct version of Python based on the information in the
aformentioned first line.


http://effbot.org/zone/exemaker.htm does approximately that and has been 
very useful for me.


--

   ... Stephen Hansen
   ... Also: Ixokai
   ... Mail: me+list/python (AT) ixokai (DOT) io
   ... Blog: http://meh.ixokai.io/

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


Re: Why are String Formatted Queries Considered So Magical?

2010-06-27 Thread Carl Banks
On Jun 27, 3:20 pm, Roy Smith  wrote:
> In article
> <14e44c9c-04d9-452d-b544-498adfaf7...@d8g2000yqf.googlegroups.com>,
>  Carl Banks  wrote:
>
>
>
> > Seriously, almost every other kind of library uses a binary API. What
> > makes databases so special that they need a string-command based API?
> > How about this instead (where this a direct binary interface to the
> > library):
>
> > results = rdb_query(table = model,
> >                     columns = [model.name, model.number])
>
> > results = rdb_inner_join(tables = [records,tags],
> >                          joins = [(records.id,tags.record_id)]),
> >                          columns = [record.name, tag.name])
>
> > Well, we know the real reason is that C, Java, and friends lack
> > expressiveness and so constructing a binary query is an ASCII
> > nightmare.  Still, it hasn't stopped binary APIs in other kinds of
> > libraries.
>
> Well, the answer to that one is simple.  SQL, in the hands of somebody
> like me, can be used to express a few pathetic joins and what I do with
> it could probably be handled with the kind of API you're describing.  
> But, the language has far more expressivity than that, and a
> domain-specific language is really a good fit for what it can do.

I'm not the biggest expert on SQL ever, but the only thing I can think
of is expressions.  Statements don't express anything very complex,
and could straightforwardly be represented by function calls.  But
it's a fair point.


> The problem is not so much that SQL queries are described as text
> strings,

No, it is the problem, or part of it.  String commands are inherently
prone to injection attacks, that's the main problem with them.


> but that the distinction between program and data gets lost if
> you build the query as one big string.

That too.


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


Re: I strongly dislike Python 3

2010-06-27 Thread Paul Rubin
Terry Reedy  writes:
> Python3 is about finishing transitions. The last stage in a transition
> that replaces something old with something new is to remove the old,..

Main problem is that by the time Python3 has stopped being disruptive,
Python4 will be underway.  Python3 is incompatible enough with Python2
to cause hassle and headaches, but not incompatible enough for the
benefits to be more than slight.  So making more radical changes will
require undergong the transition and disruption twice.  I think it would
have been better to just do it once.  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Need instruction on how to use isinstance

2010-06-27 Thread Steven W. Orr
On 6/27/2010 10:25 PM, Stephen Hansen wrote:
> On 6/27/10 7:09 PM, Steven W. Orr wrote:
>> So, my question is, what value can I use as the 2nd arg to isinstance
>> to see if
>> foo is a function? And while I'm on the subject, what types does
>> isinstance not
>> support?
> 
> Does it have to be a function? -- There's quite a few things which are
> function-y enough that you really should accept them even if they may
> not be technically a /function/. Like a class instance with the __call__
> method defined wrapping a function as a decorator. Or a bound method,
> really.
> 
> In Python 2.x, you can use callable(fun) -- that goes away in Py3
> though. But personally, I think this is the wrong approach.

Ok, you just asked great questions, and your questions were based on what I
didn't tell you.

I'm trying to teach myself about how __metaclass__ can be used as a substitute
for LSD. ;-)

So, instead of writing a class that does typechecking on its arguments at
instantiation time, I'm writing a metaclass that allows the class to announce
what sort of values it specifically will be expecting after instantiation.

The model I'm using is something I've found that

http://cleverdevil.org/computing/78/

So, the basic idea is

>>> class Person(Enforcer):
...name = Field(str)
...age = Field(int)
...ff = Field(function)

but there's no factory function called function.

Does this help?

> 
> I'm assuming you need to do some different sort of behavior based on if
> its a str, tuple or list-- okay.
> 
> But, personally-- at that point, I would just *assume* the argument is a
> function. And call it.
> 
> If it can't be called, its not a functiony-thing. You can either let
> that traceback propagate, or just raise a TypeError "expected arg to be
> a string, tuple, list or callable".
> 
> Then again, similarly I almost never want to test for if somethings a
> tuple or list. I'd rather use it as a sequence type and see if it works:
> while there's not as many 'sequency-like-things' out there as there are
> function-like-things, there's still quite a few.
> 
> So personally, I'd check if its a string (can it be unicode or regular?
> If so isinstance(x,basestring)).
> 
> Then I'd try to use it as a sequence, doing whatever I woulda done with
> it sequence-like. If that works, great. If not, I'd try to call it.
> 
> Etc.
> 
> Then again it does depend on just what you're *doing* with the arg being
> passed in.
> 


-- 
Time flies like the wind. Fruit flies like a banana. Stranger things have  .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net
-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   >