Re: Concepts RE: Python evolution: Unease

2005-01-05 Thread corey

Roman Suzi wrote:
> On Wed, 5 Jan 2005, EP wrote:
>

>
> I can try to write a PEP "Generic Programming Concepts".
>

That would be great.  It's so hard to get your head around an abstract
concept (a thought, not a programming concept) without a concrete
example in some form of syntax.  I think that's what's throwing off
most people from the idea.
And if you really do want to get it incorporated into whatever Guido is
thinking, it would probably be best to hurry.  ;)

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


python cvs interface?

2005-03-09 Thread corey
Hi everyone, this should be a quick question.  I'm writing some scripts
to take some file and move them into a CVS repository, but it's pretty
slow, because it uses system calls to execute the CVS commands.  Has
anyone ever made a python to CVS interface library that I could use?
I've been trying to google around for something, but predictably I get
a zillion sourceforge repository hits, and it isn't really helping.  So
anyway, if anyone knows of a useful module, I'd love to hear about it.
Thanks!

- Corey

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


Re: python cvs interface?

2005-03-09 Thread corey
Thanks, that looks promising, I'll take a look!

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


Re: python cvs interface?

2005-03-09 Thread corey
Ah, unfortunately it looks like this program uses something called
gcvs, a gtk cvs interface written in C++, for interfacing to low level
cvs routines.  So it probably won't work for me.  Oh well.  Anyone else
have any suggestions?

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


Re: python cvs interface?

2005-03-10 Thread corey
Well, the problem is that there are a lot of files to deal with, and
I'm already running in parallel, but it still takes a while.  Also, cvs
uses some sort of locking scheme to stop parallel updates, so it's hard
to parallelize effectively.

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


Re: Sending a broadcast message using raw sockets

2013-01-22 Thread Corey LeBleu
If you don't *have* to use the actual socket library, you might want to
have a look at scapy.  It's a packet manipulation program/library. It might
make things a little easier.

http://www.secdev.org/projects/scapy/

 On Jan 22, 2013 9:17 AM, "Peter Steele"  wrote:

> I just tried running you code, and the "sendto" call fails with "Network
> is unreachable". That's what I expected, based on other tests I've done.
> That's why I was asking about how to do raw sockets, since tools like
> dhclient use raw sockets to do what they do. It can clearly be duplicated
> in Python, I just need to find some code samples on how to construct a raw
> packet.
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: While stack:

2012-06-01 Thread Corey Richardson
On Fri, 1 Jun 2012 18:59:57 +0100 (BST)
David Shi   wrote:

> Can any one clarify what "while stack:" mean?
> 
> Regards,
> 
> David
> 

Formal explanation:
http://docs.python.org/reference/compound_stmts.html#while

Informal introduction:
http://learnpythonthehardway.org/book/ex33.html

Simplistic summary: it executes the indented code under the "while"
until stack evaluates to non-True.

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


Re: get latest from svn

2012-06-01 Thread Corey Richardson
On Fri, 1 Jun 2012 15:38:58 +0530
prakash jp   wrote:

> Hi All,
> 
> Can some one suggest me a module to access SVN repository so that i
> could download any given branch.
> 
> Thanks

Doing some basic googling, I found:

http://pysvn.tigris.org/

I imagine you could also shell out.
-- 
Corey Richardson
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: why i can't read sda1 with python?

2012-06-04 Thread Corey Richardson
On Sat, 2 Jun 2012 10:14:36 +0800
"水静流深" <1248283...@qq.com> <1248283...@qq.com> wrote:

> [snip]
> i want to read  sda1  with python:
> >>> file=open('/dev/sda1','rb')
> Traceback (most recent call last):
>   File "", line 1, in 
> IOError: [Errno 13] Permission denied: '/dev/sda1'
> 
> how can i own the access to read sda1?
>

You need read privileges. Either change the permissions of /dev/sda1,
or run python as root.

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


Re: Python libraries portable?

2012-06-07 Thread Corey Richardson
On Thu, 07 Jun 2012 20:20:47 GMT
jkells   wrote:

> We are new to developing applications with Python.  A question came
> up concerning Python libraries being portable between
> Architectures.More specifically, can we take a python library
> that runs on a X86 architecture and run it on a SPARC architecture or
> do we need to get the native libraries for SPARC?
> 

Pure-python libraries should run wherever Python does, if it doesn't,
that's a bug. C extensions to CPython shouldn't have any platform
incompatibilities, but of course you'll need to recompile.

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


Re: Python libraries portable?

2012-06-07 Thread Corey Richardson
On Thu, 7 Jun 2012 15:09:36 -0800
Tim Johnson   wrote:

>   Does this mean that I could copy my MySQLdb module directly from
>   my workstation via ftp to a server, and have it work, given that
>   sys.path contained the path?
> 

No, absolutely not. MySQLdb is a C extension. Assuming same
architecture and shared libraries, it will *probably* work, but no
guarantees. If any of those are different, even slightly, it will break.

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


Re: Python libraries portable?

2012-06-07 Thread Corey Richardson
On Thu, 7 Jun 2012 16:43:26 -0800
Tim Johnson   wrote:

>   So what to do if I can't install from the command line?
>   I could use python's external command tools like
>   subprocess.call(), but am not sure what the implications would be
>   since privileges might be limited.
> 

https://github.com/petehunt/PyMySQL/ is your best option, when it comes
to using mysql without C extensions. I don't even know if it works, but
it's the only one I could fine.

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


Re: Installing MySQLdb via FTP?

2012-06-08 Thread Corey Richardson
On Fri, 8 Jun 2012 09:55:23 -0800
Tim Johnson   wrote:

>   See the thread titled "Python libraries portable?" you will note
>   that Corey Richardson makes the statement that MySQLdb is a C
>   extension. I accepted that statement, but upon looking at the
>   directories (I am on Mac Lion, but believe it may be the same for
>   Linux) I see no binaries, just straight .py and .pyc files.
> 

http://mysql-python.hg.sourceforge.net/hgweb/mysql-python/MySQLdb-2.0/file/566baac88764/src

It definitely is. The C extension part is the '_mysql' module, here it
is /usr/lib64/python2.7/site-packages/_mysql.so. MySQLdb (of which
_mysql is a part) uses that to provide a DB-API 2.0 compliant API.

>   *However* as it often turns out, I was barking up the wrong tree.
>

(I haven't followed this thread at all besides noticing this message)

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


Re: which one do you prefer? python with C# or java?

2012-06-10 Thread Corey Richardson
On Sun, 10 Jun 2012 21:46:50 -0700 (PDT)
Broad Liyn   wrote:

> of course java is the best option in my opinion.There is no need to
> provide many evidences that java is better than c# because its
> advantages are really obvious.
>

Not as obvious as you'd imagine... I can't think of many.

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


Re: announcing: dmangame: an ai game. maybe.

2011-06-06 Thread Corey Richardson
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 06/06/2011 01:50 AM, okay zed wrote:
> the link: http://okayzed.github.com/dmangame/introduction.html
> 
> dmangame is a game about writing AI for a simple strategy game.

Looks fun! I play a bit of Core War, so this should pose a similar but
new challenge to my brain. Thank you for your work and for sharing.

- -- 
Corey Richardson
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.17 (GNU/Linux)

iQEcBAEBAgAGBQJN7ILhAAoJEAFAbo/KNFvpFjYH/A+5l58MURNwSkNkRvejcS83
GDCVkq7I9ojqkGdEMi4get4oz0z+TQnZ5PTjHNMpgZvbI+AM6esQ2NPKIUGQd4l5
bk9ZeiA+YJbg3xs7w2mMjW4FEJdr2NNberWTPSn24TyTqFxHPxihK6ul6vv+Nbj6
6VEhGxSGtlHyYeQHDW2RX/EYij7GLX185YVmi9jZXG2OAAypvgLOIBOmtz2b2/xD
ht7bcqeie0Qx4B3fopGlSN7aPPKG1OCzIkjzSdm/LbHzpnRwVZTty8OPp/MdJpcY
MBwsqBgulUcOWZVyUuLes2/AqfAtLhq4VLF5BfM3r3x+ZKru1tiWQGnkY8uf0cs=
=Yglm
-END PGP SIGNATURE-
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.6 OR 3.2

2011-06-09 Thread Corey Richardson
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 06/09/2011 01:18 PM, hisan wrote:
> Hi All,
> 
> Please let me know which one is GOOD whether Python 2.6 OR 3.2.
> Please let me know the difference between them.
> Please give some refernce site or books to know the difference

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

Pick one and learn it well. It'll be easy to switch to the other when/if
you need to. Right now lots of nice libraries only support 2.x, like
Twisted and lots of web frameworks (all? I think there's one or two that
use 3).

- -- 
Corey Richardson
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.17 (GNU/Linux)

iQEcBAEBAgAGBQJN8SDNAAoJEAFAbo/KNFvpbewH/3IclMl/K5d35qsVesoYuICB
pFt0W6gxyMSRMU2TcoYbpsSVlqjc+KCwUQ7wxv/yIw8ldXs09IV3ITbajKDR2Gnh
TX5DdgRaC8vAoQHLuvjUvJST0/1INnK/sYGnzS1xuNv5uuohqZ026jx4HEXTfjUi
haI/bFLELM9iKrBjuSRKYVy4RYRHAE0ziKblbXtfNTltU0Y2C56xRKkMplsEk/pV
ka+6R5OkHvMap+g++TRaXqN347m60GnWKWYwTklcTSyfJmmEtaokE4gJwPodv7N4
ozQrkcNdL3tHxTLFbMfO5zrSrW+yWEpsGRYbUSJIx8zOUOhbyjZJtHBuYu+xsqI=
=4AvK
-END PGP SIGNATURE-
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: // compile python core //

2011-06-25 Thread Corey Richardson
Excerpts from victor lucio's message of Sun Jun 26 02:01:27 -0400 2011:
> Hi
> 
> I would like to know how to compile the python core.
> I am going to remove some modules of it to have a thin python.
> 
> Where could I find further information about it?
> 

I'm guessing you're going to want to go through and edit Makefile.pre.in
and take out stuff you dont' want. Just make sure you know what you're
doing. That said, this was an educated guess, I don't actually know.

http://hg.python.org/cpython/file/c5b0585624ef/Makefile.pre.in

Best of luck!
-- 
Corey Richardson
  "Those who deny freedom to others, deserve it not for themselves"
 -- Abraham Lincoln


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


Re: Default value for optional parameters unexpected behaviour?

2011-06-26 Thread Corey Richardson
Excerpts from Marc Aymerich's message of Sun Jun 26 14:28:30 -0400 2011:
> Hi,
> I'm trying to define a function that has an optional parameter which
> should be an empty list whenever it isn't given. However, it takes as
> value the same value as the last time the function was executed. What
> is the reason of this behaviour? How does python deal with default
> values (i.e. when are they assigned/created)?
> 
> Thanks :)
> 

Really common mistake, I made it myself too. When Python evaluates the 
function, it sees the default parameter of `foo' as the new object you
create with []. It keeps that object around. The proper idiom instead of

> >>> def a(foo=[]):
> ...  foo.append(1)
> ...  print foo
> ...

is

def a(foo=None):
if foo is None:
    foo = []
foo.append(1)
print foo
-- 
Corey Richardson
  "Those who deny freedom to others, deserve it not for themselves"
 -- Abraham Lincoln


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


Re: Default value for optional parameters unexpected behaviour?

2011-06-26 Thread Corey Richardson
Excerpts from Thomas L. Shinnick's message of Sun Jun 26 14:53:21 -0400 2011:
> See reference manual section 7.6  "Function definitions" under the 
> discussion subtitle "Default parameter values are evaluated when the 
> function definition is executed. "
>  
> http://docs.python.org/reference/compound_stmts.html#function-definitions
> 
> Yes, this is discussed in many places and many times, but why isn't 
> it in the Python FAQ?  Amazing, yes?
> 

Well, to be fair, I don't think most people actually read the FAQ.
The FAQ does say:

"Default arguments can be used to determine values once, at compile
time instead of at run time. This can only be done for functions or
objects which will not be changed during program execution..."

And he did modify the list during program execution. However this
isn't exactly forthright if you aren't looking for it / know what
you're reading.  I don't think it should be spilled out in detail but
maybe a "there are some tricks involved with mutable default
arguments (for example a list).  Refer to the language reference
(LINK) for more details" would be useful.

But I'm not really certain that would make much of a difference.
I'll Cc this to d...@python.org.
-- 
Corey Richardson
  "Those who deny freedom to others, deserve it not for themselves"
 -- Abraham Lincoln


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


Re: Nested/Sub Extensions in Python

2011-07-01 Thread Corey Richardson
Excerpts from H Linux's message of Fri Jul 01 16:02:15 -0400 2011:
> Dear all,
> 
> I am currently fighting with a problem writing a set of Python
> extensions in C.

If you haven't seen it yet, Cython is a *very* nice tool for writing
C extensions. http://cython.org/
-- 
Corey Richardson
  "Those who deny freedom to others, deserve it not for themselves"
 -- Abraham Lincoln
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The end to all language wars and the great unity API to come!

2011-07-05 Thread Corey Richardson
Excerpts from rantingrick's message of Tue Jul 05 07:42:39 -0400 2011:
>
> I was thinking more about this comment and it occurred to me that
> Python does have user controlled data structures. Just because there
> is no "top level syntax" like ruby does not mean these do not exists.
> You only have to look below the surface. Take the sort methods of
> lists for example...
> 
> >>> lst = [
> (100, 0),
> (25, 2),
> (10,1),
> ]
> >>> lst
> [(100, 0), (25, 2), (10, 1)]
> >>> lst.sort()
> >>> lst
> [(10, 1), (25, 2), (100, 0)]
> >>> lst.sort(lambda x,y: cmp(x[1], y[1]))
> >>> lst
> [(100, 0), (10, 1), (25, 2)]
> 
> ...that looks like a "user defined control" structure to me. So how
> can an anti-feature become part of the language proper? (devils
> advocate here) :)
> 

How is giving the sort method a function by which to determine the relative
value of objects a control structure? Do you know what a control structure is?
It's something that you use to modify control flow:

if foo <= bar:
foo += 1
else:
bar += 1

That's a control structurem the "if-else". I don't know what Ruby calls a 
control structure, but that's what it is. for and while are in there too.
When you run lst.sort(lambda x, y: cmp(x[1], y[1])), what happens?

We'll call that argument srt, here's a sample (naive) implementation:

def sort(key):
lst = self.internal_list
for n in range(len(self.internal_list) - 1):
for i in range(len(self.internal_list) - 1):
if srt(lst[i], lst[i+1]) < 0:
lst[i], lst[i+1] = lst[i+1], lst[i]

Untested, probably doesn't work either. See what's in there? An if. Nothing
"user-defined" at all. Sure, WHAT the if does is user-controlled with the
key, but that doesn't make that particular if a new control structure, and
it certainly doesn't make the key a control structure. You can pass a key
to a sort even in C and that certainly doesn't have user defined control
structures.
-- 
Corey Richardson
  "Those who deny freedom to others, deserve it not for themselves"
 -- Abraham Lincoln


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


Re: meaning of numpy.fft coefficients

2011-07-08 Thread Corey Richardson
Excerpts from Joey's message of Fri Jul 08 20:14:29 -0400 2011:
> the list generated by numpy is of form [ a+bi, c+di, ...]
> 
> could anybody tell me the meaning of the coefficients a and b? I am
> very confused about fourier transform!
> 

a+bi is a typical complex number. a is the real part, b is the imaginary.
Python uses j,

>>> 4+5j
(4+5j)

http://en.wikipedia.org/wiki/Complex_number
http://docs.python.org/library/stdtypes.html#typesnumeric
-- 
Corey Richardson
  "Those who deny freedom to others, deserve it not for themselves"
 -- Abraham Lincoln


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


Re: Function docstring as a local variable

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

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

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

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

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

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


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


Re: Function docstring as a local variable

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

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


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


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


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

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

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


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


Re: Function docstring as a local variable

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

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


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


Re: list(), tuple() should not place at "Built-in functions" in documentation

2011-07-14 Thread Corey Richardson
Excerpts from rantingrick's message of Thu Jul 14 21:36:15 -0400 2011:
> On Jul 14, 8:21pm, Inside  wrote:
> > As telling in the subject,because "list" and "tuple" aren't functions,they 
> > are types.Is that right?
> 
> You wanna see some warts in the docs. Okay, try to use the search box
> to find list, dict, or tuple and see what happens...
> 
> http://docs.python.org/
> 
> Search: [ list ]
> 
> PyMethod_ClearFreeList (cfunction, in Method Objects)
> 
> [ snip: mile long list with no LIST info to be found! ]
> 
> Hey don't get me wrong, the python docs are great; as long as you know
> where to find what you're looking for.
> 

I agree, having the stuff from the C API docs appear in the search isn't
very useful. Perhaps the search should be redesigned with stuff like that
in mind? (Or maybe the search is more advanced than I use it). They aren't
exactly warts, it's useful information, but in the common case they probably
aren't desired (I always use Google to search around the python docs).

Not to mention that the search is slooowwww. It's plenty fast on my local
download, but I haven't actually looked at the search to see what it does
and how.
-- 
Corey Richardson
  "Those who deny freedom to others, deserve it not for themselves"
 -- Abraham Lincoln


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


Re: list(), tuple() should not place at "Built-in functions" in documentation

2011-07-16 Thread Corey Richardson
Excerpts from Inside's message of Sat Jul 16 01:40:21 -0400 2011:
> Supplement:
> The assertion will not be handled anyway.
> I want AssertionError raise as early as possible.(mentinoed before)

An AssertionError is pretty useless, there are much better exceptions
that you could (and should!) use, depending on the context. If you
need a sequence, just use it like it is. If it's not a sequence a 
TypeError will be raised anyway:

>>> class Foo(object): pass
... 
>>> f = Foo()
>>> for i in f: pass
... 
Traceback (most recent call last):
  File "", line 1, in 
TypeError: 'Foo' object is not iterable
>>> 

Which is tons more useful than

>>> assert isinstance(f, (list, tuple))
Traceback (most recent call last):
  File "", line 1, in 
AssertionError
>>> 
-- 
Corey Richardson
  "Those who deny freedom to others, deserve it not for themselves"
 -- Abraham Lincoln


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


Re: Tabs -vs- Spaces: Tabs should have won.

2011-07-17 Thread Corey Richardson
Excerpts from Thorsten Kampe's message of Sun Jul 17 11:10:57 -0400 2011:
> The "perfect programming font" is just the one that looks so good that 
> you would also use it for writing email. Dejavu Sans Mono is pretty 
> good. Consolas looks also looks good but it is Windows only.
> 

I use inconsolata, but I  hate the look of it un-bold at small sizes, so
I keep it bold all the time. I've started using DejaVu very recently because
of that, it looks better on screen at small sizes (pixelsize=9 in my 
~/.Xdefaults, as opposed to the 12 and bold with inconsolata). Inconsolata
looks great on paper, though. DejaVu Sans Mono isn't the prettiest thing
but it certainly gets the job done.
-- 
Corey Richardson
  "Those who deny freedom to others, deserve it not for themselves"
 -- Abraham Lincoln


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


Re: I am fed up with Python GUI toolkits...

2011-07-20 Thread Corey Richardson
Excerpts from Phlip's message of Wed Jul 20 16:58:08 -0400 2011:
> On Jul 20, 10:32am, rantingrick  wrote:
> 
> > Steven, you have no buisness offering advice on Tkinter since you
> > yourself have proclaimed that YOU NEVER used the module and never
> > will. Stick to what you know please.
> 
> Allow me.
> 
> Tkinter sucks because it looks like an enfeebled Motif 1980s dawn-of-
> GUIs scratchy window with grooves and lines everywhere.
> 

Themed Tk (TTK) has come a far way. I'll leave the research for you, however,
as I can not give this post the time it deserves.

-- 
Corey Richardson
  "Those who deny freedom to others, deserve it not for themselves"
 -- Abraham Lincoln


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


Re: [PyWart 1001] Inconsistencies between zipfile and tarfile APIs

2011-07-21 Thread Corey Richardson
Excerpts from rantingrick's message of Thu Jul 21 23:46:05 -0400 2011:
> 
> I may have found the mother of all inconsitency warts when comparing
> the zipfile and tarfile modules. Not only are the API's different, but
> the entry and exits are differnet AND zipfile/tarfile do not behave
> like proper file objects should.
> 

I agree, actually.
-- 
Corey Richardson
  "Those who deny freedom to others, deserve it not for themselves"
 -- Abraham Lincoln


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


Re: Inconsistencies between zipfile and tarfile APIs

2011-07-21 Thread Corey Richardson
Excerpts from rantingrick's message of Fri Jul 22 00:48:37 -0400 2011:
> On Jul 21, 11:13pm, Corey Richardson  wrote:
> > I agree, actually.
> 
> 
> Maybe i can offer a solution. A NEW module called "archive.py" (could
> even be a package!) which exports both the zip and tar file classes.
> However, unlike the current situation this archive module will be
> consistent with it's API.
> 
> >>> from archive import ZipFile, TarFile
> >>> zf = ZipFile(path, *args)
> >>> tf = TarFile(path, *args)

I have nothing to do this weekend, I might as well either write my own or
twist around the existing implementations in the hg repo.
-- 
Corey Richardson
  "Those who deny freedom to others, deserve it not for themselves"
 -- Abraham Lincoln


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


Re: Inconsistencies between zipfile and tarfile APIs

2011-07-22 Thread Corey Richardson
Excerpts from rantingrick's message of Fri Jul 22 02:40:51 -0400 2011:
> On Jul 22, 12:45am, Terry Reedy  wrote:
> > On 7/22/2011 12:48 AM, rantingrick wrote:
> > > On Jul 21, 11:13 pm, Corey Richardson wrote:
> 
> > Hmm. Archives are more like directories than files. Windows, at least,
> > seems to partly treat zipfiles as more or less as such.
> 
> Yes but a zipfile is just a file not a directory. This is not the
> first time Microsoft has "mislead" people you know. ;-)
> 

Ehh...yes and no. Physically, it is a file and nothing more. But its actual
use and contents could reflect that of a directory. Are files and directories
that different, after all? I don't believe so. They are both an expression
of the same thing. Both contain data, one just contains others of itself.
Of course, treating a zipfile as a directory will certainly have a performance
cost. But here in Linux-land (and elsewhere I'm sure) I can mount, for example,
a disk image to a mountpoint anywhere. It's a useful thing to do!

> > Certainly, 7zip
> > present a directory interface. So opening a zipfile/tarfile would be
> > like opening a directory, which we normally do not do. On the other
> > hand, I am not sure I like python's interface to directories that much.
> 
> I don't think we should make comparisons between applications and
> API's.
> 

Ehh...yes and no again. Maybe the applications are on to something? Whether
the filesystem is physically on disk or is just a representation of a
filesystem on a file in a filesystem on disk, treating them both as a
filesystem is a useful abstraction (NOT the only one available?)

> > It would be more sensible to open files within the archives. Certainly,
> > it would be nice to have the result act like file objects as much as
> > possible.
> 
> Well you still need to start at the treetop (which is the zip/tar
> file) because lots of important information is exposed at that level:
> 
>  * compressed file listing
>  * created, modified times
>  * adding / deleting
>  * etc.
> 
> I'll admit you could think of it as a directory but i would not want
> to do that. People need to realize that tar and zip files are FILES
> and NOT folders.
> 

I think it's a useful abstraction to think if an archive as a directory.
They ARE files, yes. But must their physical representation impact their
semantics? I think not! It doesn't matter if Python's list object is a
linked-list down under or if it isn't. Or any sequence, for that matter!
It's a useful abstraction to treat them all as sequences, uniform interface
etc, even though one sequence might be a linked list in a C module, or
a row from a database, or whatever!

> > Seaching open issues for 'tarfile' or 'zipfile' returns about 40 issues
> > each. So I think some people would care more about fixing bugs than
> > adjusting the interfaces. Of course, some of the issues may be about the
> > interface and increasing consistency where it can be done without
> > compatibility issues.
> 
> Yes i agree! If we can at least do something as meager as this it
> would be a step forward. However i still believe the current API is
> broken beyond repair so we must introduce a new "archive" module.
> That's my opinion anyway.
> 

Checking if such a thing exists already may be more useful. I saw someone
mention a project similar?

> > However, I do not think there are any active
> > developers focued on those two modules.
> 
> We need some fresh blood infused into Python-dev. I have been trying
> to get involved for a long time. We as a community need to realize
> that this community is NOT a homogeneous block. We need to be a little
> more accepting of new folks and new ideas. I know this language would
> evolve much quicker if we did.
> 

> > > Rick: But what about Python 3000?
> > > PTB: " Oh, well, umm, lets see. Well that was then and this is now!
> >
> > The changes made for 3.0 were more than enough for some people to
> > discourage migration to Py3. And we *have* made additional changes
> > since. So the resistance to incompatible feature changes has increased.
> 
> Yes i do understand these changes have been very painful for some
> folks (me included). However there is only but one constant in this
> universe and that constant is change. I believe we can improve many of
> these API's starting with zip/tar modules. By the time Python 4000
> gets here (and it will be much sooner than you guys realize!) we need
> to have this stdlib in pristine condition. That means:
> 
>  * Removing style guide violations.
>  * Removing inconsistencies in existing API's.
> 

Re: PEP 8 and extraneous whitespace

2011-07-22 Thread Corey Richardson
Excerpts from Chris Rebert's message of Fri Jul 22 16:56:15 -0400 2011:
> On Fri, Jul 22, 2011 at 12:13 PM, John Gordon  wrote:
> > In <98u00kfnf...@mid.individual.net> Neil Cerutti  
> > writes:
> >
> >> You can fit much more code per unit of horizontal space with a
> >> proportionally spaced font. As a result, that issue, while valid,
> >> is significantly reduced.
> >
> > Is it? I assume one major reason for the 80-character limit is to help
> > the poor sod who will eventually get stuck working with your code on an
> > 80-column fixed width terminal window.
> 
> What environments with that limitation are still in common use?
> It's not the '70s anymore; I think we can safely increase the max
> column width a bit.
> 

I agree. I have my tiling WM setup with two columns, giving each terminal 110
characters of breathing space. I still limit my lines to 78 chars though, if
not for any reason besides text is nice and easy to read at that width, and
everyone else is doing it. I have no reason to change. I've never desired more
characters than that.
-- 
Corey Richardson
  "Those who deny freedom to others, deserve it not for themselves"
 -- Abraham Lincoln
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PyWart: os.path needs immediate attention!

2011-07-29 Thread Corey Richardson
ts own, it's uninformative, but considering
the whole name is "os.path.split", it's fairly intuitive.

>  * splitext --> Wow, informative!

split extension...seems straightforward to me.

> ~
>  4. Duplicated functionality.
> ~
> 
> >>> os.path.lexists.__doc__
> 'Test whether a path exists.  Returns False for broken symbolic links'
> >>> os.path.exists.__doc__
> 'Test whether a path exists.  Returns False for broken symbolic links'
> 
> Should have been one method:
> >>> os.path.exists(path, ignoreSymLnks=False)

It is.

/usr/lib64/python2.7/ntpath.py says..

> # alias exists to lexists 
>   
> lexists   = exists

But over here in Not-NT where we actually *have* symlinks to be broken, it's

>>> os.path.lexists.__doc__
'Test whether a path exists.  Returns True for broken symbolic links'
>>> os.path.exists.__doc__
'Test whether a path exists.  Returns False for broken symbolic links

I agree that it should be an argument to os.path.exists, though.
-- 
Corey Richardson
  "Those who deny freedom to others, deserve it not for themselves"
 -- Abraham Lincoln


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


Re: Struggling to convert a mysql datetime object to a python string of a different format

2011-02-24 Thread Corey Richardson
On 02/24/2011 04:34 AM, rahul mishra wrote:
> try this 
> 
> test = time.time(2011, 2, 1, 2, 4, 10)
> # this is your datetime object from mysql
> 
> print time.mktime(test.timetuple())
> 
> hope this would help you
> 
> 

You do realize that email was sent over four months ago, correct?
See:

>> On Wednesday, August 04, 2010 7:40 PM ? wrote:

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


Re: Newbie...

2011-02-25 Thread Corey Richardson
On 02/25/2011 03:18 AM, wisecrac...@tesco.net wrote:
> True, but it is inside a Python file too. So therefore the idea is in a 
> working state.

Then copyright the code.

>>> # >>> import afg[RETURN/ENTER]
> 
>> I thought you said you use only "STANDARD Python"? What's afg? It doesn't
>> seem very standard to me:
> 
>>>>> import afg
>> Traceback (most recent call last):
>>   File "", line 1, in 
>> ImportError: No module named afg
> 
> I made the mistake of making an assumption that intelligent guys like you
> would know to save the first file as afg.py and the second as arp.py from the
> import statements given... Oh well, can`t win `em all.

Should have specified that with header comment, for example:

###
## Copyright 2009, B.Walker, G0LCU.
## arp.py
##
## Something about this module
###

Or even better, a docstring.


>>> # The program proper...
>>> def main():
>>> # Make all variables global, a quirk of mine... :)
> 
>> It's not 1970 any more. People will avoid like the plague code that 
>> over-uses globals.
> 
> Maybe not but I code for 10 year olds to understand and be able to modify 
> easily, I build
> HW for 10 year olds to make, modify and understand, I marry the two for 10 
> year olds to
> modify and understand.

Teaching good practice to the young is better than teaching them easy
bad practice. It's taken me a too long to break out of my bad habits I
learned when I was 13 first learning Python.

> Mine is easy to understand even by programmer of limited knowledge.
> Most of the Python code I`ve seen would be just visual 'noise' to a 10 year 
> old.
> 
>>  sine=chr(15)+chr(45)+chr(63)+chr(45)+chr(15)+chr(3)+chr(0)+chr(3)
> 
>> This is much more easily and efficiently written as:
> 
>> sine = ''.join([chr(n) for n in (15, 45, 63, 45, 15, 3, 0, 3)])
> 
>> or even shorter, as a string constant:
> 
>> sine = '\x0f-?-\x0f\x03\x00\x03'
> 
> Now show your code to a 10 year old and see if he understands it...

When I was 10 all I knew was Logo (and very little of it)!

Also, if one understands how a unicode byte looks like in a string, it's
pretty easy to understand, and looks a hell of a lot clearer than a
bunch of chr()'s without any space between. That's just my two cents.

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


Re: Newbie...

2011-02-25 Thread Corey Richardson
On 02/25/2011 03:39 AM, Corey Richardson wrote:
> Also, if one understands how a unicode byte looks like in a string, it's
> pretty easy to understand, and looks a hell of a lot clearer than a
> bunch of chr()'s without any space between. That's just my two cents.

Err..not a unicode byte, but it's some sort of escape sequence that
represents a byte. Not sure what it's called, to be honest.

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


Re: Parsing numeric ranges

2011-02-25 Thread Corey Richardson
On 02/25/2011 04:27 AM, Seldon wrote:
> Hi all,
> I have to convert integer ranges expressed in a popular "compact" 
> notation (e.g. 2, 5-7, 20-22, 41) to a the actual set of numbers (i.e. 
> 2,5,7,20,21,22,41).
> 
> Is there any library for doing such kind of things or I have to write it 
> from scratch ?
> 
> Thanks in advance for any answers.
> 
> Seldon
> 

I don't know of any library, but range() in Python 2 or list(range()) in
python 3 should provide the brunt force of what you're trying to do.

for example,

final_nums = [2]
compact_range = "5-7".split('-')
final_nums += range(int(compact_range[0]), int(compact_range[1]) + 1)

And then looping through your compact notation deciding when it's a
range notation and when it's a literal is all you have to do.

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


Re: Python getting stuck

2011-02-26 Thread Corey Richardson
On 02/26/2011 06:55 PM, Shanush Premathasarathan wrote:
> Hi All,
> 
> When I use cut, copy, paste, and any keyboard shortcuts, Python freezes and I 
> am unable to use Python. Please Help as quick as possible!!!

What OS? Are you using the standard interpreter? Are you using IDLE,
bpython, etc? What key combination are you using?

My instinctive guess is that you are trying to Ctrl-C to copy something
in the interpreter, which actually just raises a KeyboardInterrupt
exception. However your additional symptoms seem to indicate otherwise.

A more verbose description is needed.
-- 
Corey Richardson
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: jQuery-like sliding container animations for Tkinter?

2011-02-26 Thread Corey Richardson
On 02/26/2011 07:24 PM, pyt...@bdurham.com wrote:
> Any thoughts on the ability to implement jQuery-like sliding
> container animations in Tkinter? By jQuery animations I mean the
> smooth sliding effects one sees on many websites where containers
> slide in and out of visible view or smoothly shrink or grow?
> 
> My working knowledge of Tkinter tells me that Tkinter's pack and
> grid layout techniques will not be optimal for the above type of
> animations.

The place geometry manager might suit your needs, but that can be a bit
PITA to work with. By can, I mean is.
-- 
Corey Richardson
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: WxPython versus Tkinter.

2011-03-02 Thread Corey Richardson
On 03/02/2011 07:40 PM, Gregory Ewing wrote:
> Octavian Rasnita wrote:
> 
>> How complete is this GUI lib compared with others that can be used in 
>> Python apps?
> 
> It has most of the basic things you would want. There are one
> or two gaps, and I'm working on filling them.

What are those gaps?
-- 
Corey Richardson
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A Short Question on list

2011-03-03 Thread Corey Richardson
On 03/03/2011 08:08 AM, joy99 wrote:
> Dear Group,
> If I have a list of elements, like,
> list=[1,2,3,4,5,..]
> now, if I want to multiply an increment of subset of the list each
> time,
> like,
> 
> elem1_list=list[0]
> elem2_list=list[1]
> elem3_list=list[2]
> elem4_list=list[3]

Why do you assign those to variables?

> As I was figuring out doing a for kind of iteration may not help
> exactly
> Can any one give some idea?

Are you looking for something like this?
>
# UNTESTED (Poor styling of variable names is noted)

def recursiveMultiply(l, r, product): # list, range (no shadowing)
if r <= 0:
return sum
product *= l[r]
recursiveMultiply(l, r - 1, product) # r must be decremented

subsetrange = 15
multiplysubset, elemlist = [], list(range(15)) # Works with Py2 and Py3

assert subset_range <= len(elemlist)

for i in range(subsetrange):
multiplysubset.append(recursiveMultiply(elemlist, i, 0))

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


Re: Communicating from Flash to Python

2011-03-03 Thread Corey Richardson
On 03/03/2011 05:01 PM, Victor Subervi wrote:
> Hi;
> I have an AS3 script that is supposed to communicate with a python script
> and I don't think it is. The python script is to email.

How does Flash communicate with Python? Only thing I found at all was
Flash interfacing with a PHP script via a webpage, so are you trying to
use Python with the CGI to do this? If so, check out the actionscript
thing at [1] and just implement the server page with Python CGI instead
of PHP.

[1]
http://www.actionscript.org/resources/articles/82/1/Send-Email-via-Flash-and-PHP/Page1.html
-- 
Corey Richardson
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What do I need to know in order to write a web application in python?

2011-03-04 Thread Corey Richardson
On 03/04/2011 03:08 PM, ErichCart ErichCart wrote:
> I am currently a Computer Science student, I can write in pascal, C,
> and Java, and recently I learned about Python and fell in love with
> it. I watched some python programming tutorials on youtube, and now I
> can write some programs.
> But what I really want to do is to make a website where people can
> play real-time RISK game online with other players.
> 
> Can this be done in Python 3.2?
> What do I need to know in order to make such a website? Which Python
> modules will I need to use?

Real-time? As in viewing the same board like people would in real-life?
I would say that's a job for Java or Flash. You could pull off something
with Javascript and XMPP (bad choice? I don't know), in which case
Python would be on the server directing the game logic and sending the
proper messages to the players.

So look into XMPP (xmpppy or Twisted Words are your choices, I guess)
and learn up on Javascript.

That's my take on it, at least. I'm sure someone with more experience
could direct you more specifically.

Turn-based would be much easier.

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


Re: What do I need to know in order to write a web application in python?

2011-03-04 Thread Corey Richardson
On 03/04/2011 03:34 PM, ErichCart ErichCart wrote:
> It is just that I want to better my python skills by doing this.
> 
> I have heard about Django, can't this be done with Django?

As you described it? Absolutely not [1]. When thinking of Django, think
more of Ruby on Rails or something vaguely along the lines of PHP. If
you want to improve your Python skills, this is a poor project unless
you already have plenty of experience designing fairly complex systems
with many interoperating parts.

Take all the things you did in school for C etc. and implement them in
Python. That's a good start, so you're more familiar with the language
compared to the ones you currently know. And then you can try a web app
with Django, but I suggest Pyramid instead.

-- 
Corey Richardson

[1] - Well, kinda. You could have Django driving the back-end and maybe
use AJAX and have the client poll the server every second or so for a
change in the game state, but that'd be needlessly complex and
resource-consuming compared to other systems.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What do I need to know in order to write a web application in python?

2011-03-04 Thread Corey Richardson
On 03/04/2011 04:48 PM, ErichCart ErichCart wrote:
> In fact this doesn't necessary need to be web application. For example
> I have a friend who uses Delphi, and he can create all sorts of
> windows applications easily, like he can see the window on the screen
> and he can place buttons, text fields, radio buttons etc. wherever he
> wants and then program the actions of each element. I was able to do
> the same with visual basic in one of my university classes.
> 
> What do I need to know in order to be able to do the same with python?
> Which python modules/python development environments do I need to use?

As far as I know, no tools exist to make developing desktop apps in
Python like there do VB. However I can recommend a few desktop toolkits.
Qt (pyqt or pyside) and Gtk (pygtk) seem to be popular, and I think
Pygui will be becoming popular as it becomes more complete / more
examples/tutorials using it become available. Tkinter is easy to use and
comes right in the standard library.

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


Re: What do I need to know in order to write a web application in python?

2011-03-05 Thread Corey Richardson
On 03/05/2011 06:49 AM, ErichCart ErichCart wrote:
> So, "Glade", is this what everybody uses? I mean programmers don't
> just use text editors to make GUI applications, do they?

I usually see people using Qt and QtDesigner over Gtk and Glade. And
actually, yes, I'm sure lots of people besides me actually make their
GUI apps in a text editor. Then again, I usually don't do anything big.
If you want to learn your GUI toolkit well, do it by hand and not by
tool. As someone said to me once, "QtDesigner is meant for people who
already know how to use Qt". I'm sure the same applies for Glade.

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


Re: having both dynamic and static variables

2011-03-05 Thread Corey Richardson
On 03/05/2011 10:23 PM, MRAB wrote:
> Having a fixed binding could be useful elsewhere, for example, with
> function definitions:
> [..]
>  fixed PI = 3.1415926535897932384626433832795028841971693993751
> 
>  fixed def squared(x):
>  return x * x

This question spawns from my ignorance: When would a functions
definition change? What is the difference between a dynamic function and
a fixed function?

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


Re: Tk MouseWheel Support

2011-03-10 Thread Corey Richardson
On 03/10/2011 03:28 PM, Richard Holmes wrote:
> I am trying to use the mouse wheel to scroll a list box, but I'm not
> getting the event. When I bind "" to the listbox I get the
> event and I'm able to scroll using yview_scroll. I've tried binding
> "MouseWheel" and "", and I've also tried "" and
> "" even though I'm using Windows (XP, if that makes a
> difference). None of these works (I'm using print to see if I got to
> an event handler, and there's no printout).
> 
> TIA for any help!
> 
> Dick

Middle button is Button-3 IIRC, and I think it'd be MouseUp and
MouseDown. I'm really not sure though.


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


Re: Tk MouseWheel Support

2011-03-10 Thread Corey Richardson
On 03/10/2011 03:35 PM, Corey Richardson wrote:
> Middle button is Button-3 IIRC, and I think it'd be MouseUp and
> MouseDown. I'm really not sure though.

It's Button-2 rather.

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


Re: Good literature about python twisted

2011-03-15 Thread Corey Richardson
On 03/15/2011 03:18 PM, gelonida wrote:
> o it seems another book or some other documentation would be great.
> 
> Does anyone have recommendations?
> 

http://krondo.com/?page_id=1327

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


Re: best python games?

2011-03-25 Thread Corey Richardson
On 03/25/2011 10:39 PM, sogeking99 wrote:
> hey guys, what are some of the best games made in python? free games
> really. like pygames stuff. i want to see what python is capable of.
> 
> cant see any good one on pygames site really, though they have nothing
> like sort by rating or most downloaded as far as i can tell

Unknown Horizons is pretty OK, and the upcoming PARPG looks promising
(both use the FIFE engine).

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


Re: popular programs made in python?

2011-03-29 Thread Corey Richardson
On 03/29/2011 10:32 AM, Neil Alt wrote:
> i mean made with python only, not just a small part of python.

Civilisation 4 (the game) used Python for all of its scripting. As far
as I know almost all the game logic was in Python, and you could access
most parts of the game.

Blender also has a rather extensive Python API that allows you to make
scripts that can access any part of the software, or almost any part of it.

Just look at http://en.wikipedia.org/wiki/List_of_Python_software
It's not a complete list either.
-- 
Corey Richardson
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python-related Animation Packages?

2011-03-29 Thread Corey Richardson
On 03/29/2011 01:17 PM, Benjamin J. Racine wrote:
> Hello all,
> 
> Does anyone know of software that might be of use in an attempt to animate an 
> object undergoing 6-DOF rigid body motions: surge, sway, heave, roll, pitch 
> and yaw?
> 
> Thanks so much,
> Ben Racine
> 

Blender.

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


The Magick of __call__ (Or, Digging Deeper Than I Ought To)

2011-04-01 Thread Corey Richardson
All callables (things you can foo(bar)) are really just objects that
implement the __call__ method, as far as I understand. Well then, that
would appear to make methods themselves callable, so let's do a little
playing around...

lavos@lavos ~ $ python
Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> class Foo(object):
... def __call__(self, foo):
... self.name(foo)
... def name(self, bar):
... print "Name: {0}".format(bar)
...
>>> foo = Foo()
>>> foo("Me!")
Name: Me!

Ok, nothing out of the ordinary. But what happens if

>>> foo.name.__call__("Corey")
Name: Corey
>>> eval("foo.name" + (".__call__" * 9001) + "('Corey')")
Name: Corey
>>> foo.name.__call__.__call__.__call__.__call__.__call__("Corey")
Name: Corey
>>> eval("foo.name" + (".__call__" * 1) + "('Corey')")
^C^Z
[1]+  Stopped python

(Which was then followed by a ps aux and a kill -9...it ate all my
memory and then moved on to my swap.)

I've been told that much magick lies in the CALL_FUNCTION bytecode, and
that if I really cared I could look at ceval.c. I don't speak enough C
or know enough of Python's C API for it to be of any use (yes I
looked!). Would looking at something such as PyPy's version of it be
good for me / does anyone else have insights?

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


Re: proposal to allow to set the delimiter in str.format to something other than curly bracket

2011-04-03 Thread Corey Richardson
On 04/03/2011 06:07 AM, Alia Khouri wrote:
> Hi folks,
> 
> I've been using ironpython2.7 in a project, and I was generating some
> csharp code when i discovered that I couldn't use use str.format
> because the interference with the brackets-aplenty situation in
> csharp.
> 

Roll your own http://docs.python.org/library/string.html#string.Formatter

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


Re: using python to post data to a form

2011-04-04 Thread Corey Richardson
On 04/04/2011 01:36 AM, Littlefield, Tyler wrote:
> Hello:
> I have some data that needs to be fed through a html form to get 
> validated and processed and the like. How can I use python to send data 
> through that form, given a specific url? the form says it uses post, but 
> I"m not really sure what the difference is. would it just be:
> http://mysite.com/bla.php?foo=bar&bar=foo?
> If so, how do I do that with python?
> 

import urllib
import urllib2

url = "http://www.foo.com/";
data = {"name": "Guido", "status": "BDFL"}

data = urllib.urlencode(data)
request = urllib2.Request(url, data)
response = urllib2.urlopen(request)

page = response.read()

So yeah, passing in a Request object to urlopen that has some
urlencode'ed data in it.
-- 
Corey Richardson
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Proper way to handle errors in a module

2011-05-12 Thread Corey Richardson
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 05/12/2011 04:12 PM, Andrew Berg wrote:
> On 2011.05.12 02:25 PM, MRAB wrote:
>> You can raise an exception wherever you like! :-)
> If I raise an exception that isn't a built-in exception, I get something
> like "NameError: name 'HelloError' is not defined". I don't know how to
> define the exception.

class HelloError(Exception):
pass

Of course, there are all sorts of other things you could do with your
exception.

http://docs.python.org/tutorial/errors.html#user-defined-exceptions
- -- 
Corey Richardson
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.17 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJNzED9AAoJEAFAbo/KNFvp1uQIAKFaKyD1Q3RL7LGFSmnyRFTK
9XWRH3CSM9mOALccfQ8bUkrquol1fAqhrm4jyOW0scWmsJpRlcb6Rj4HtrmMQOuG
DpsUzEZCTnT9Xk80OeTFbpWWBIVBkxdhCxCl75XAP22o5EjhHpgLyqoqMD+81BKH
5/JWAGRJx/9E4BvNWsxIUhb1jlz+XT4H1XykTE1UUOP0uZneWRJMs7P12WNiL2Ii
HT0hEUhQc1eP1fJ5BqPB/6/B9q/KxTbN55hCq1VwwfRhgbaM4kR7Bekri7QUHGAK
1MKxRa1v+Co59y+ywAIH92L3wky3xNyFrUlFzK4AwYOnwRkVvUWw7vPG1iShE+k=
=2+y6
-END PGP SIGNATURE-
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 3.x and bytes

2011-05-17 Thread Corey Richardson
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 05/17/2011 02:47 PM, Ethan Furman wrote:
> In Python 3 one can say
> 
> --> huh = bytes(5)
> 
> Since the bytes type is actually a list of integers, I would have 
> expected this to have huh being a bytestring with one element -- the 
> integer 5.  Actually, what you get is:
> 
> --> huh
> b'\x00\x00\x00\x00\x00'
> 
> or five null bytes.  Note that this is an immutable type, so you cannot 
> go in later and say

For the bytes to actually be a 'list of integers', you need to pass it
an iterable, ex:
>>> bytes([5, 6, 1, 3])
b'\x05\x06\x01\x03'

- From help(bytes):
 |  bytes(iterable_of_ints) -> bytes
 |  bytes(string, encoding[, errors]) -> bytes
 |  bytes(bytes_or_buffer) -> immutable copy of bytes_or_buffer
 |  bytes(memory_view) -> bytes

Looks like you're using the fourth when you want the first, possibly?

- -- 
Corey Richardson
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.17 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJN0tF1AAoJEAFAbo/KNFvp41AH/1l2zR6XVOJ0xM7s2P+PDYZX
OAhmi19hFEP0zQoWiW3TiMEVPlaqgtipPCp1t+jTeNNN3F+H4NG2DHJJZ3dPDr2J
CpABQKyS4MJQTUxhCIlXqAaA2I1pejzAv6fwsF66/zPFmyaTAJLDP+3WMQvCUUoZ
5A3qHgHNp6vBHXd13RNdQStLeprfQptA+z6XdiJPos348ecRj/u9id7v28dwxxsm
d9WA6oYwJ+Y/NcG2OP0Flyp3Zc3hymVsv5vhmhG2+EiIrxMn95k8ImsKLEhvUW3a
72CxlE6EaOMD4MuWyeGMS33c0vHwtAvEIE7M56R2FAl8EsUFwP2swaij0tEiemg=
=8MRV
-END PGP SIGNATURE-
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 3.x and bytes

2011-05-17 Thread Corey Richardson
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 05/17/2011 04:55 PM, Ethan Furman wrote:
> Apparently, it's not well documented.  If you check PEP 358 
> you'll find it.
> 
> ~Ethan~

Agreed, it looks like it should be mentioned in bytes.__doc__ about the
single-integer argument.

- -- 
Corey Richardson
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.17 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJN0ugoAAoJEAFAbo/KNFvphIsH/3LOzN8+D98D0+nm6m8sfCUC
f+KfgTLITAmecYOuOBym1snl6qj2JnZkGYRW6M2O5NV8arNJ1dHty3dPbwMeKdfH
67m2a0UgHcwqv5M5VGNQQYTQ03Mzqy+A84MMvBKWUQ0nxZRCkPMtdxm2T4/UEVLx
uelDPOdOWB1PDmc3sNUDPovXeOFlTKmcQ5yfolyrdLFU/KmbamgRSltpBFEbyInO
4KI3hoGka4PVaaBLf9QPjFC6tBu4QdQ4UTnWD3sy78LA3KPsa5MEpXFXctwJkJ+O
q2Y7SWOPJDz19V+MT87Aeu69YpzxWwkp4fBflNxYaQUoJqNlzIfRkavUzZ0zfMQ=
=E2qm
-END PGP SIGNATURE-
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python in CS1

2011-05-21 Thread Corey Richardson
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 05/21/2011 04:30 AM, Franck Ditter wrote:
> Except at MIT, who knows some good CS1 references for teaching Python ?
> Thanks,
> 
>franck

Check out http://www.python.org/community/sigs/current/edu-sig/, and if
nothing there satisfies you jump over onto the edu-sig list.

- -- 
Corey Richardson
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.17 (GNU/Linux)

iQEcBAEBAgAGBQJN18oPAAoJEAFAbo/KNFvp9MwH/0zXSTTaxAwYPLSxhyirqr3X
DUxyulE5HRn+NIarWyomlDfoayip3boyUBG1GQDDKh+sIIzPT9ETfL7+ep9rwkL4
VA7XSDMLu+4DtUlnFjGlfxCz1REYKVvS4m/9w68F0kRflh5XZzDRBbTz0nXMiMM8
/UPBV8cX1XDq+RYis1baIlMSaro6sK3mHW5avBd9RxO4+IzH0TtKw510EWfRvZ8e
ssdEUXZwxHmI0eRwYovynJ7VdLWwY/FLKuuoKl1IOpRwbAH8LtLtAAudHDZKOo9X
ctwYfwGPCg39gz+fuJFFUGI6oYw8dkqiDi2su/QwN8JsaMXv4xeOc2ZXkZVYMiM=
=7xLM
-END PGP SIGNATURE-
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Should I use "if" or "try" (as a matter of speed)?

2005-07-11 Thread corey . coughlin
It really does depend.  For instance, some other programmers where I
work came up with a way to represent a hierarchical, somewhat random
data set by creating each object and then adding attributes to those
for each subobject, and so on down the tree.  However, you could never
really be sure that the object you wanted was really there, so for
every access call they just wrapped it in a try ...except loop.  Now
that may seem like a good way to go, but when I rewrote some code to
use hasattr() instead, it ran a lot faster.  So yeah, exceptions can be
handy, but if you code requires exception handling for everything, you
may want to rethink things.

Steve Juranich wrote:
> I know that this topic has the potential for blowing up in my face,
> but I can't help asking.  I've been using Python since 1.5.1, so I'm
> not what you'd call a "n00b".  I dutifully evangelize on the goodness
> of Python whenever I talk with fellow developers, but I always hit a
> snag when it comes to discussing the finer points of the execution
> model (specifically, exceptions).
>
> Without fail, when I start talking with some of the "old-timers"
> (people who have written code in ADA or Fortran), I hear the same
> arguments that using "if" is "better" than using "try".  I think that
> the argument goes something like, "When you set up a 'try' block, you
> have to set up a lot of extra machinery than is necessary just
> executing a simple conditional."
>
> I was wondering how true this holds for Python, where exceptions are
> such an integral part of the execution model.  It seems to me, that if
> I'm executing a loop over a bunch of items, and I expect some
> condition to hold for a majority of the cases, then a "try" block
> would be in order, since I could eliminate a bunch of potentially
> costly comparisons for each item.  But in cases where I'm only trying
> a single getattr (for example), using "if" might be a cheaper way to
> go.
>
> What do I mean by "cheaper"?  I'm basically talking about the number
> of instructions that are necessary to set up and execute a try block
> as opposed to an if block.
>
> Could you please tell me if I'm even remotely close to understanding
> this correctly?
> -- 
> Steve Juranich
> Tucson, AZ
> USA

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


Re: OO design

2005-07-19 Thread corey . coughlin
I also have a little trouble with creating megaclasses.  Usually I just
try to think about what things are a little bit, and how I'm going to
be using them.  I think somebody else suggested a top down approach,
and that makes a certain amount of sense.

But at this point, you're probably getting tired of all the vague
advice.  It sounds like you don't have a very complicated set of
concepts to deal with, so you probably won't wind up with too many
classes, but having a single giant one is probably inconvenient.
Here's how I would do things (although keep in mind, I only have a
vague understanding of what you really need to do..)

First off, you have your (x,y) datasets.  It sounds like you perform
most of your operations on those, so they'd probably be a good idea for
a class.

You may also want a class for the (x,y) points themselves, especially
if you have any operations that collapse a point set to a single value
or values (like your means and peaks and stuff.)

So the methods on your (x,y) dataset probably want to be restricted to
your mathematical operations.  Although you'll also definitely want to
look at the representation that gets passed onto your other classes.

Thinking beyond those basic classes, you probably want to now think
about your input and output operations.  A general way of doing OOP for
things like this is to try to abstract your input and output operations
into objects based on what kinds of inputs or outputs they are.  In
this case it sounds like you have files, which are both input and
output, and plots, which are just output.  Both seem to take either
single x,y sets or a number of sets.  So each I/O object would appear
to be some sort of object container for your x,y sets.

Take the plot object.  It will probably be fairly simple, just
something you pass sets of x,y lists to and it plots them.  You may
want some more capabilities, like naming the sets, or giving the axes
units, or whatever, but you can probably add that stuff later.

Now for the file object.  Luckily, python already includes a file
object, so you already have something to base yours on.  For the files,
you have two basic operations, the read and the write.  For the read,
you'll need to pass in a filename, and have a way to return the
datasets (like iterating over a data file produces a dataset, hm...).
For output, you'll again need a filename, and a set of datasets to
write.  For both operations, you may also want to provide formatting
options, unless you can figure it out from the filename or something.
So the ultimate hierarchy might look something like this:

class point:
self.x
self.y

class dataset:
self.data = [ #list of points ]
self.units = '' #?? maybe
def sum
def mean
# and so on

class datafile:
self.filename
self.filetype
self.datasets = [ #list of data sets? ]
def read
def write
## and so on

class plot:
self.datasets = { #dictionary of data sets, each named?}
self.xaxis = ''
self.yaxis = ''
def makeplot
## and so on

Looking at it like that, it might make some sense to come up with
something like a dataset collection class that you can pass to plot or
datafile, but if you can use something like a list (if the data is
fairly arbitrary) or a dictionary (if the datasets have names or some
other way of signifying what they're about), that will probably be
enough.   Anyway, that's just a rough sketch, hopefully it will give
you some ideas if it doesn't seem like the best solution.

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


pyUI?

2005-07-28 Thread corey . coughlin
I think someone built a gui on top of pygame a while back, I think it
was called pyUI or something, let's see what google gives me here, ah,
here we go

http://pyui.sourceforge.net/

Hope that helps.  Looks like neat stuff anyway...

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


Re: Rich Graphics?

2005-07-28 Thread corey . coughlin
for widgets, try pyUI

http://pyui.sourceforge.net/

hope that helps, looks cool and all..

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


build flow? SCons? AAP? process creation?

2005-04-13 Thread corey . coughlin
Hey guys, here's a little question.  I'm looking for something like a
build system, where I can set up a bunch of jobs with dependencies, and
have them run in parallel.  Ideally, I'd like a system where jobs can
be run in parallel, all the stdout and stderr for each job is kept in a
database of some kind, jobs can be anything that can be run at a
command line, and a failing job won't cause the whole run to fail.
I've been looking into some of the standard stuff (GNU make) and some
of the more pythonic stuff like SCons and AAP.  SCons seems to do
parallel execution, which is nice, but I can't figure out from the docs
if it's possible to keep stdout and stderr somewhere.  AAP seems to
have a nice interface, but it doesn't do parallel.

So if I do wind up having to write this thing myself, I've been
checking the docs on process creation, and have a couple questions if
anyone can fill me in.  It looks like the os.spawn* commands can start
nonblocking sub-processes, but there doesn't seem to be a way to get
stdout and stderr.  On the other hand, the popen commands make it easy
to trap stdout and stderr, but I guess I'd have to do the thread setup
and spawning myself.  Is there another alternative that I'm missing
here?  

Thanks!

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


Re: build flow? SCons? AAP? process creation?

2005-04-13 Thread corey . coughlin
good point, I hadn't checked the docs too closely.  Shame it's only in
2.4 though, we're still running 2.2 around here, but it would be nice
to have a reason to upgrade, anyway.  Thanks for the pointer!

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


python concurrency proposal

2006-01-02 Thread corey . coughlin
Alright, so I've been following some of the arguments about enhancing
parallelism in python, and I've kind of been struck by how hard things
still are.  It seems like what we really need is a more pythonic
approach.  One thing I've been seeing suggested a lot lately is that
running jobs in separate processes, to make it easy to use the latest
multiprocessor machines.  Makes a lot of sense to me, those processors
are going to be more and more popular as time goes on. But it would
also be nice if it could also turn into a way to make standard
threading a little easier and trouble free.  But I'm not seeing an easy
way to make it possible with the current constraints of the language,
so it seems like we're going to need some kind of language improvement.
Thinking of it from that perspective, I started thinking about how it
would be easy to deal with in a more idealized sense.  It would be nice
to abstract out the concept of running something in parallel to
something that can be easily customized, is flexible enough to use in a
variety of concepts, and is resonably hard to screw up and fairly easy
to use.  Perhaps a new built-in type might be just the trick.  Consider
a new suite:

pardef (self, , arguments...):
self.send(, , arguments)
self.receive(, arguments)
return arguments
yield arguments

so the object would then be something you can create an instance of,
and set up like a normal object, and it would have other interface
functions as well.  Consider your basic vector add operation:

import concurrent
import array

pardef vecadd(self, concurrent.subprocess, veca, vecb, arrtype):
import array
output = array.array(arrtype)
for a,b in zip(veca, vecb):
output.append( a + b)
return output

a = array.array('d')
b = array.array('d')
for i in range(1000):
a.append(float(i))
b.append(float(i))

h1 = vecadd(a[:500], b[:500], 'd')
h2 = vecadd()
h2.veca = a[500:]
h2.vecb = b[500:]
h2.arrtype = 'd'

h1.run()
h2.run()
c = h1.result + h2.result

You can see a few things in this example.  First off, you'll notice
that vecadd has the import for array inside it.  One of the most
important things about the pardef is that it must not inherit anything
from the global scope, all variable passing must occur through either
the arguments or .receive statements.  You'll also notice that it's
possible to set the arguments like instance values.  This isn't as
important in this case, but it could be very useful for setting
arguments for other pardefs.  Take this example of your basic SIMD-ish
diffusion simulation:

import concurrent

pardef vecadd(self, concurrent.subprocess, right, left, up, down,
initval):
current = initval
maxruns = 100
updef = not (isinstance(up, int) or isintance(up, float))
downdef = not (isinstance(down, int) or isintance(down, float))
rightdef = not (isinstance(right, int) or isintance(right, float))
leftdef = not (isinstance(left, int) or isintance(left, float))
for i in range(maxruns):
if updef:
upval = self.receive(up, 'up')
else:
upval = up
if downdef:
downval = self.receive(down, 'down')
else:
downval = down
if rightdef:
rightval = self.receive(right, 'right')
else:
rightval = right
if leftdef:
leftval = self.receive(left, 'left')
else:
leftval = left
current = (upval + downval + leftval + rightval) / 4
if updef:
up.send('down', current)
if downdef:
down.send('up', current)
if rightdef:
right.send('left', current)
if leftdef:
left.send('right', current)
return current

diffgrid = {}
for x, y in zip(range(10), range(10)):
diffgrid[(x, y)] = vecadd()
for x, y in zip(range(10), range(10)):
gridpt = diffgrid[(x, y)]
gridpt.initval = 50.0
if x == 0:
gridpt.left = 75.0
else:
gridpt.left = diffgrid[(x-1, y)]
if x == 10:
gridpt.right = 50.0
else:
gridpt.right = diffgrid[(x+1, y)]
if y == 0:
gridpt.down = 0.0
else:
gridpt.down = diffgrid[(x, y-1)]
if y == 10:
gridpt.up = 100.0
else:
gridpt.up = diffgrid[(x, y+1)]
for coord in diffgrid:
diffgrid[coord].run()
for x, y in zip(range(10), range(10)):
print '(%i, %i) = %f' % (x, y, diffgrid[(x,y)].return())

Now sure, this example is a little contrived, but it shows the utility
of allowing

Re: python concurrency proposal

2006-01-03 Thread Corey Coughlin
Hey, some responses, let's see...

Peter Tillotson wrote:
> I'd really like to see a concurrency system come into python based on 
> theories such as Communicating Sequential Processes (CSP) or its 
> derivatives lambda or pi calculus. These provide an analytic framework 
> for developing multi thread / process apps. CSP like concurrency is one 
> of the hidden gems in the Java Tiger release (java.util.concurrency). 
> The advantages of the analytic framework is that they minimise livelock, 
> deadlock and facilitate debugging.

Yes, a CSP-like system would be kind of nice.  Of course, to really pull 
it off, you'd probably need some kind of primitive to represent a simple 
process.  Which is kind of what I'm proposing.  It's kind of a primitive 
version, but an object to easily represent processes and communication 
channels would be a big help, I'd imagine.  Once a primitive is in 
place, I believe it would be fairly easy to build up a full set of 
CSP-ish primitives to help assemble full systems.

> I'm no expert on the theory but i've developed under these frameworks 
> and found them a more reliable way of developing distributed agent systems.
> 
> You may also be interested in looking at 
> http://sourceforge.net/projects/pympi

Ah yes, pympi, that's good stuff.  It does suggest that I might need to 
add blocking and non-blocking version of send and receive, there might 
be a need for that.  Especially the non-blocking receive, that looks 
very handy.  And maybe a .status for polling the status of running jobs. 
It does go a lot further than I do with this proposal, it adds all 
that stuff for collecting the jobs, running them as a group, gathering 
results, and so on.  This proposal could probably use an extra library 
to provide a bunch of those type of operations, but I wanted to start a 
little bit small here with just the proposal of a process primitive. 
That seems like it would be a good first step.  Of course, what I'm 
really hoping for is that at some point you could do something like this:

import mpi

pardef vecadd(self, mpi.mpiproc, ...)

and so on.  I'm not really all that concerned about the communication 
channels and process distributions work, I suspect that many people will 
want to try different methods like MPI, or the standard pthread wrapper 
with some kind of standard queue communications channel, or pyro, maybe 
even Kamaelia.  I'm just proposing the primitive for it.  So, if there's 
anything else you'd like to see it work like, be sure to let me know. 
Thanks for the input!

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


Re: python concurrency proposal

2006-01-03 Thread Corey Coughlin

> Yes.  Parallelism certainly deserves attention, and I believe
> "amateurs" are likely to help in the breakthroughs to come.  I
> further suspect, though, that they'll be amateurs who benefit
> from knowledge of existing research into the range of documented
> concurrency concepts, including CSPs, tasks, guarded methods, 
> microthreads, weightless threads, chords, co-routines, and so on.

Yes, there are lots of different concepts, even in python, there's pympi 
(as was mentioned), the standard python thread library, the subprocess 
library, generators, microthreads and stackless, not to mention 
Candygram, PyLinda, ATOM, Kamaelia (get to that in a minute), and other 
things you can search for on the web.  My motivation here is just to see 
if I can find some lowest common denominator, to try to simplify this 
stuff to the point where the whole concept is a little easier to use, 
and the plumbing can be hidden away somewhere so "amateurs" don't have 
to worry about it (too much) if they don't want to.
Now to be more specific, there does seem to be a lot of work with 
generators to set up concurrency, and that's fine, but it does seem like 
it takes a bunch of scaffolding and a different way of looking at 
things, and it's not really obvious to me how it can scale up on 
multiple processor systems with the GIL still in place.  Now I'm not 
sure that this will be the answer to all the problems, but breaking the 
global address space and making it easy to break up jobs into small 
communicating chunks seems like it would be a good way to go.  Or maybe 
I'm missing something?  Is there anything you'd care to elaborate on?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python concurrency proposal

2006-01-03 Thread Corey Coughlin
  downdef = not (isinstance(down, int) or isintance(down, float))
> rightdef = not (isinstance(right, int) or isintance(right, float))
> leftdef = not (isinstance(left, int) or isintance(left, float))
> 
> In these lines you have passed over global scope data - specifically
> int and float.

Well, the old preferred method was to import types and compare to those, 
but I thought that comparing to the builtins was the shiny new way to do 
things.  I don't do this stuff very often, so I may have gotten this 
wrong, though.  But I do assume that a pardef does get a clean set of 
built in functions, as you would get in any module without imports.

> Unlike your approach (syntax first), we've created a large (growing) number
> of components (like your pardefs) which have been put together for various
> systems which have varying levels of concurrency which are probably a useful
> testbed for testing your ideas:
> 
> * http://kamaelia.sourceforge.net/Components.html
> 
> Example systems created using this vary from a "everything broadcast" PVR
> for radio [*], a networked audio mixer matrix, simple games, a presentation
> tool (probably including soon a live video mixer to go with the video
> playback), topology viewing tools, a simple "paint" program, etc)
> 
>* Actually a box for creating a record of transmission, which
>  is slightly different, but the former description is more
>  accessible if slightly inaccurate.)
> 
> If you're interested in prototyping your ideas in python, you can simulate
> some of your ideas using decorators. Something that might help you with
> prototyping your ideas is our tutorial for Kamaelia, which is a "build your
> own core" system type tutorial. It might also help show that your pardefs
> are very similar to python's generators. It can be found here:
> * http://kamaelia.sourceforge.net/MiniAxon/

Yes, you have been busy.  It is a very interesting system.

> In many respects, I feel that the API we have still isn't "100% pythonic" as
> many would call it, but it does try to be unsurprising and consistent. You
> could say we're aiming for pythonic - though personally I favour easy and
> unsurprising as more concrete, less abstract goals - even if it's not there
> yet. (portability of ideas to other languages is important to me, which
> again is another reason for an API based view rather than syntax).
> 
> If you're willing to take a look at it, and make suggestions as to how your
> ideas might fit, (or what you think is dumb :-) I'd welcome it.

I'm not sure, really, I'm still kind of confused as to the depth of your 
system.  It does look strongly generator based, so it should be possible 
  to port most of the algorithms you're using to this proposed system 
(if I ever implement it) (and I really should mention that a .restart 
method would really be useful for yield-ing pardefs, I keep forgetting 
to mention that) but I'm not sure how much further Kamaelia goes.  It 
sounds like you have networking 'pipes' going that allow you distribute 
jobs across a network, but it's not completely clear to me.  If that's 
the case, then it should be possible to encapsulate that into a Kamaelia 
base class for this proposal so you could keep that functionality as 
well.  That might require some extra base-class specific methods, but I 
have no problem with that.  Like I said, I imagine this as a fairly 
minimal interface, no problem supplementing it if you like.
But anyway, I'm beginning to ramble, but thanks for all the great 
feedback, and a happy new year to you as well!  :)


- Corey

> *Especially* if it simplifies the system (*or* the way it's used).
> 
> Finally though, as I say above,I'm not trying to discourage you, I like
> the ideas, and would like to see you expand them more since they interest
> me, and like you I think this is an area that needs work. I would suggest
> playing with the ideas though and testing them against systems before
> writing a PEP though. (real/useful systems rather than contrived ones! -)
> 
> Best Regards & Happy New Year,
> 
> 
> Michael.
> --
> [EMAIL PROTECTED], http://kamaelia.sourceforge.net/ 
> British Broadcasting Corporation, Research and Development 
> Kingswood Warren, Surrey KT20 6NP 
>  
> This message (and any attachments) may contain personal views
> which are not the views of the BBC unless specifically stated.
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python concurrency proposal

2006-01-04 Thread Corey Coughlin
Mike Meyer wrote:

> [Rest elided]
> 
> This really has a lot in common with SCOOP. SCOOP makes concurrent
> stuff easier, but i'm not sure it fits well with Python. I'll describe
> it, on the off chance you may get some ideas from it. See  http://archive.eiffel.com/doc/manuals/technology/concurrency/ > for
> full details.

Eiffel!  I should have thought of that.  I may have to dig all my old 
Meyer books out of storage..

> 
> Like pardef, you use SCOOP by creating objects that are going to run
> concurrently. Unlike pardef, the objects are - well, objects, not just
> restricted to functions. This has deep implications. For instance, one
> of the things that sets SCOOP apart from other concurrency systems
> that I know if is that the program doesn't have code to create
> "processors" (threads, process, whatever - places for the code to
> run).  From my reading of your description, this isn't the case for
> pardef. Invoking a pardef causes a new processor to be created, and
> when the pardef returns, the processor is finished.

Well, not quite, the pardef is actually an object, and you can certainly 
put all kinds of objects inside it if you want to.  The pardef object is 
really more of an interface specification, where the actual 
implementation of most of the methods is really defined in the base 
class.  The body of the pardef really just defines what happens during a 
.run() call.  The whole 'def' in pardef and the use of returns (and 
yields) may be kind of misleading, the return (and yield) are really 
just ways to send info back to the calling scope without having to come 
up with some wierd way of referencing it.  What I'm envisioning can 
return a single value, or stay resident and return multiple values 
(through yield or .send calls) or whatever.

> 
> Like pardef, SCOOP separates the specification of the kind of
> processor from the rest of the code. It carries things further than
> pardef though. You specify a set of processors at build time, and the
> support system takes care of getting objects on the right processor.
> 
> Synchronization and protection is all handled via method
> invocation. There are no new primitives for locking objects, explicit
> synchronization, or communications.

Yeah, I've been trying to think of some way to setup channels in a 
better way.  Tagged channels can certainly be used, but method (or 
method-like) invocations would be more elegant in more than a few 
situations.  On the other hand, I've also been trying to avoid locking 
people into a fully OO style in order to use concurrency, it would be 
nice to allow people who don't want to define everything as an object to 
use parallelism.  But it can get ugly that way.  Maybe something like a 
"property" declaration to optionally simplify things, hmm

> 
> Calls to methods of a separate object are non-blocking. The calls are
> queued, and executed later. Reading an attribute from a separate
> object is a blocking action.  Calling a method with a separate object
> as an argument causes the call to block until the separate arguments
> are all locked. There are rules - enforceable by the compiler - about
> what you can do with separate objects that prevent a lot of the things
> that cause headaches when doing concurrent programming.

Undoubtedly enforced by contracts, Eiffel is nice that way.  Some things 
I do miss from stricter languages.  But then again, having to define 
everything as an object does drive me nuts.

> 
> So instead of "run", you instantiate a separate object. Instead of
> ".send", you just invoke a method on the seperate object, and the
> arguments get sent to it. Instead of ".receive", you read an attribute
> from a separate object. Instead of ."kill", you let the object be
> garbage collected (or maybe those aren't the same thing).  Return is
> missing, because it's an object, not a function. On the other hand,
> you could define an attribute that's the "return value", and reading
> it fetches that value.
> 
> The problems with Python is that "separate" is really a property of a
> variable, not an object. To see the difference, if I declare an object
> separate, and it creates an attribute, and I read that attribute, then
> that object is separate for me. But in the object that created it, it
> isn't. This is one major clash with Python. The other is the
> critical distinction that SCOOP places on reading vs. calling a
> feature. What does:
> 
>  a = Seperate_Object()
>  x = a.thing
>  x()
> 
> do with SCOOP semantics?
> 
> Oh well. I think SCOOP does the job you want of "making things
> easier", and fits well in an OO language. Maybe you can find good
> ideas in it.
> 
>   http://mail.python.org/mailman/listinfo/python-list


subprocess returncode always None

2006-07-09 Thread Corey Wallis
Dear All,

I'm currently working on a project that needs to collect the output of
the JHOVE application. More information about the application is
available at this website:

http://hul.harvard.edu/jhove/

The application is written in Java and is executed by a shell script.
There are occasions where this application may get stuck in an
infinite loop. For this reason I've been trying to implement a simple
class that I can use to execute the JHOVE application and if it
doesn't complete in the required period of time to raise an exception
and kill the process.

The class is as follows, apologies for the odd line wrapping.


class niceSubprocess(object):
"""
A class that implements a call to the subprocess method with a timeout
- command, the command to execute
- params, the parameters to pass to the application
- timeout, the amount of time in seconds to wait
"""
def executeCommand(self, command, params, timeout):
try:
timeElapsed = 0

process = subprocess.Popen((command, params), stdin =
subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE,
close_fds = True)

while process.poll() == None and timeElapsed < timeout:
print process.poll()
#print process.stdout.read()
timeElapsed = timeElapsed + 1
time.sleep(1)

if process.poll() == None:
# kill off the process, and don't be terribly nice about it
os.kill(process.pid, signal.SIGKILL)
raise timeoutError, timeout
else:
if process.stdout.read() == "":
raise executeError, process.stderr.read()
else:
return process.stdout.read()

except Exception, errorInfo:
# pass the exception to the calling code
raise errorInfo



I'm running this on Linux and through the use of top can see the JAVA
process start and complete. The problem I have is that process.poll()
always returns None, even though the application has successfully ran
and returned output.

Can anyone shed some light on why the call to the shell script always
returns None as a return code?

With thanks.

-Corey

-- 
Corey Wallis
RUBRIC Technical Officer
University of Southern Queensland
http://www.rubric.edu.au
http://techxplorer.wordpress.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Python 3000 vs Perl 6

2008-06-23 Thread Corey G.
If Perl 6 ever does get on its feet and get released, how does it  
compare to Python 3000?  Is Perl 6 more like Java now with Parrot?  I  
just want to make sure that Python is staying competitive.


If this is the wrong mailing list, just let me know.  Thanks!


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


Re: Python 3000 vs Perl 6

2008-06-24 Thread Corey G.
What I meant, in terms of dealing with accurate or non-accurate rumors  
is with speed, yes.  There are plenty of comparisons where Perl is  
4-15x faster then Python for 'some' operations regarding regular  
expressions, etc.


For me personally, this means absolutely nothing because if I spend  
50x more time comprehending spaghetti, obfuscated Perl code it's  
irrelevant.  The main concern (my concern) is whether or not Perl 6 is  
more like Java with pre-compiled byte code (did I say that right) and  
whether or not individuals without the ability to see past the surface  
will begin to migrate towards Perl 6 for its seemingly faster  
capabilities.


With Perl 6 taking 10+ years, if/when it actually gets released, will  
it be technically ahead of Python 3000?  Is Parrot worth the extra  
wait the Perl 6 project is enduring?  My own answer would be a  
resounding no, but I am curious as to what others think. :)


-Thanks!





On Jun 24, 2008, at 2:52 AM, [EMAIL PROTECTED] wrote:


On Jun 24, 8:20 am, "Corey G." <[EMAIL PROTECTED]> wrote:

If Perl 6 ever does get on its feet and get released, how does it
compare to Python 3000?  Is Perl 6 more like Java now with Parrot?  I
just want to make sure that Python is staying competitive.

If this is the wrong mailing list, just let me know.  Thanks!


Do you mean in terms of speed (parrot is a JIT?). I believe Python 3k
will (when out of beta) will have a speed similar to what it has
currently in 2.5, possibly with speed ups in some locations. But
competitive-wise I think the point is Python 3k tries to remove warts
from the Python Language to make it even more friendly to readers and
writers alike. In that way it should/will stay competitive.

However towards overall usage, the general advice is to stay with the
2.x series for now, trying to ensure your code style is moving towards
the Py3k style, and then make the jump to the 3.x series when it is
finialised.

Another point, is Perl 6 ever going to get released :P
--
http://mail.python.org/mailman/listinfo/python-list



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


Re: PExpect Cross-Platform Alternative

2010-02-12 Thread corey goldberg
> > I was just tasked to get
> > these scripts running in a windows environment and to my dismay very
> > quickly realized that pexpect is not cross platform compatible.
> > Am I stuck, or are there solutions out there?


I haven't tried it, but here is another Python implementation of
Expect that claims to run on Windows also:

http://code.google.com/p/python-expect/

-Corey

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


Re: Just Starting in on programming

2011-01-04 Thread Corey Richardson
On 01/05/2011 12:22 AM, Thai wrote:
> I was told this was good and some of the easier way to start 
>programming. I'm just wondering if this statement is true and if 
>so what is it I should do to really start getting in there and go 
>ahead and start using some other languages.
> 
>Thank you those who reply and help in advance
>   Tyler Ryan Carrollhttp://docs.python.org/tutorial/

You were told what was good? Get started in where? If you're just
learning to program, I found http://www.alan-g.me.uk/ was a very good
resource, and I learned a lot. #python recommends
http://www.greenteapress.com/thinkpython/html/index.html in the topic,
and the Python tutorial at http://docs.python.org/tutorial/ is quality,
you may learn quite a bit from it. If you have questions, I suggest you
look into the tutor mailing list, tu...@python.org

~Corey Richardson
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Google Chart API, HTTP POST request format.

2011-01-05 Thread Corey Richardson
On 01/06/2011 12:16 AM, Garland Fulton wrote:
> I tried to use "pygooglechart.py" and I have been trying to get it set
> up all day actually along with several other graphing API's.
> 
> I just found out that there is a problem with numpy and python 3.1 that
> is why I moved from the API's. Should I change version just for
> these library's?
> 
> Should I be learning Python on 3.1?
> 
> Awesome!
> 
> [snip]

I swapped from 3 to 2.6 a while back, better support for modules, and
not really losing much in the way of features.

~Corey Richardson

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


Re: student question

2011-01-07 Thread Corey Richardson
On 01/07/2011 09:42 PM, John wrote:
>>>> q_file = open(questions_location) #opens the document successfully
>>>> for line in q_file:
>   print line
> 
> # prints document successfully
>>>> line
> # prints last line of document
>>>> for line in q_file:
>   print line # prints nothing
> 
> ...why does it print nothing?

IIRC, iterating through the lines in a file moves the cursor (is that
the correct term?) to the end of the file. After the first one, use
q_file.seek(0) to go back to the start. I think.

~Corey Richardson
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: compute the double square...... :(

2011-01-08 Thread Corey Richardson
On 01/09/2011 01:10 AM, aregee wrote:
> 
> Double Squares
> A double-square number is an integer X which can be expressed as the
> sum of two perfect squares. For example, 10 is a double-square because
> 10 = 32 + 12. Your task in this problem is, given X, determine the
> number of ways in which it can be written as the sum of two squares.
> For example, 10 can only be written as 32 + 12 (we don't count 12 + 32
> as being different). On the other hand, 25 can be written as 52 + 02
> or as 42 + 32.
> 
> Input
> You should first read an integer N, the number of test cases. The next
> N lines will contain N values of X.
> Constraints
> 0 ≤ X ≤ 2147483647
> 1 ≤ N ≤ 100
> Output
> For each value of X, you should output the number of ways to write X
> as the sum of two square
> 
> Is the code mention below solution to this question  what is the
> fault...
> Error :
> are...@aregee-laptop:~/Desktop$ python pie.py
> enter a number::10
> pie.py:3: Deprecation Warning: integer argument expected, got float
>   for b in range(0,(x**0.5)/2):
That says it all. You can't use a float in range(), use int(x ** 0.5) if
that's what you need, but the behavior won't be the same. My suggestion
would be to try to find a different way to do it.
> 
> #Double square
> 
> x = input("enter a number::")
> for b in range(0,(x**0.5)/2):
>   a = (x-(b**2))**0.5
> try:
>   a = int(a)
> except:
>   print("not an integer")
>   exit(1)
> 
Here it would be better to use:
if type(a) != int
print("Not an integer")
exit(1)
>   count = 0;
>   count = count + 1;
> if (x == a**2 + b**2):
> 
>   print "double square"

~Corey Richardson
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What INI config file module allows lists of duplicate same-named options?

2011-01-09 Thread Corey Richardson
On 01/09/2011 03:43 PM, Thomas L. Shinnick wrote:
> Having (possibly) surveyed all the available pypi config file modules, I
> still haven't seen one that allows an obvious and familiar extension of
> the strict Windows INI format. 
> 
> Each INI-style config module seems to enforce the strict rule: each
> option in a section must have a different name - no duplicates.  Thus it
> is impossible to have a simple list, e.g.
> 
> [pathset  uk]
> pathpair: /bath/* to/london/*
> pathpair: /bath/upload/** to/london/*
> pathpair: /firth/*to/forth/*
> pathpair: /firth/upload/**to/forth/*
> 
> Rather you must give each line a separate name, e.g.
> 
> [pathset  uk]
> pathpair001: /bath/*  to/london/*
> pathpair002: /bath/upload/**  to/london/*
> pathpair003: /firth/* to/forth/*
> pathpair004: /firth/upload/** to/forth/*
>   |   |  |   |  |   |
> pathpair068: /glasgow/*   to/edinburgh/*
> pathpair069: /glasgow/upload/**   to/edinburgh/*
>   |   |  |   |  |   |
> 
> This is not ideal for a number of reasons.  Do you know of a library
> module that has the (optional?) ability to handle duplicate-named
> options, returning them as a list?
> 
> If instead someone can point me to a reasonable Apache-style config
> module, that might also serve.  I've looked for such and the few found
> seemed to be either bare bones or clumsily stripped out of something
> much larger.
> 
> 
> -- 
> I'm a pessimist about probabilities; I'm an optimist about possibilities.
> Lewis Mumford  (1895-1990)
> 

Seems to me to be a standard enforced by Windows itself, not any an
issue with the modules. What exactly are you doing?
~Corey Richardson
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python use growing fast

2011-01-10 Thread Corey Richardson
On 01/10/2011 10:24 PM, Dan Stromberg wrote:
> On Mon, Jan 10, 2011 at 5:22 PM, Krzysztof Bieniasz
>  wrote:
>>> Also depends on how one defines "popularity" in the context of
>>> programming languages.
>>
>> Tiobe quite clearly states what they mean by the name "popularity".
>> Namely the number of Google search results of expressions like
>> "programming X" for X in languages. If no one in the Web writes about
>> programming JavaScript then obviously it's not popular... sort of.
>> --
>> http://mail.python.org/mailman/listinfo/python-list
>>
> 
> About JavaScript's popularity:
> 1) I've been getting the impression that JavaScript is popular in a
> manner similar to how x86 machine language is popular: That is, it's
> used all over, but few people hand code it (though admittedly, there
> are probably more people hand coding JavaScript than people hand
> coding x86 assembler today)
> 2) JavaScript seems widely considered a bit of a mess, and yet, many
> tools make use of it because it's in almost all web browsers
> 3) It seems that when JavaScript does get used directly, it tends to
> be done in small snippets, like inline assembler in C or C++
> 4) It appears that there is quite a few different tools (one of them,
> our own Pyjamas, and to a lesser extent, Django - and of course GWT
> though that's only tenuously related to Python through Pyjamas) that
> attempt to take the pain out of writing JavaScript
> 
> IOW, I'm not convinced that Tiobe's ranking of JavaScript is
> inaccurate, or even weakly correlated with reality.

The biggest use of JavaScript I've seen is browser-based games using
them for some display magic, windows popping up etc. Their back-end is
still VB.NET (or x framework), and none of the lifting is done by
JavaScript.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: cipher encoding

2011-01-12 Thread Corey Richardson
On 01/12/2011 07:35 PM, Cathy James wrote:
> Dear all,
>  
> I hope someone out there can help me.
>  
>  The output string of my code is close to what i need, but i need it
> 1)printed on one line and
> 2) reversed
>  
> #mycode:
> s= input("Enter message: ")
> key=1
> for letter in s:
> num=(chr(ord(letter)+1))
> print(num)
> #or is there a better way to rewrite it with elementary level Python,
> which happens 2b my current ranking.
> #Your insight is always appreciated:)
> 

s = input("Enter message: ")
key = int(input("Enter offset: ")) # I think that's what you wanted
for letter in s:
print(chr(ord(letter) + key), end = "")

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


Re: cipher encoding

2011-01-12 Thread Corey Richardson
On 01/12/2011 07:39 PM, Corey Richardson wrote:
> On 01/12/2011 07:35 PM, Cathy James wrote:
>> Dear all,
>>  
>> I hope someone out there can help me.
>>  
>>  The output string of my code is close to what i need, but i need it
>> 1)printed on one line and
>> 2) reversed
>>  
>> #mycode:
>> s= input("Enter message: ")
>> key=1
>> for letter in s:
>> num=(chr(ord(letter)+1))
>> print(num)
>> #or is there a better way to rewrite it with elementary level Python,
>> which happens 2b my current ranking.
>> #Your insight is always appreciated:)
>>
> 
> s = input("Enter message: ")
> key = int(input("Enter offset: ")) # I think that's what you wanted
> for letter in s:
> print(chr(ord(letter) + key), end = "")
> 
Oh, and you wanted it reversed. That's not hard.

message = input("Enter message: ")
key = int(input("Enter offset: "))
new_message = ""
for char in message:
new_message += chr(ord(letter) + key)
print(new_message[::-1])
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Regex url

2011-01-15 Thread Corey Richardson
On 01/15/2011 08:48 PM, Jean-Francois wrote:
> Hi,
> 
> I try to match the following url with one regex
> 
> /hello
> /hello/
> /hello/world
> /hello/world/
> 
> 
> world is a variable, I can put toto instead
> 
> Thanks !

What was the regex you tried, and where did it fail? I'm no re guru, but
here's my go at it:

"(/hello/?(%s)?/?)" % var

Interpreter session:
Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> var = "toto"
>>> pat = re.compile("(/hello/?(%s)?/?)" % var)
>>> pat.match("/hello/toto")
<_sre.SRE_Match object at 0x7f53baf25938>
>>> pat.match("/hello")
<_sre.SRE_Match object at 0x7f53baf25c68>
>>> pat.match("/hello/")
<_sre.SRE_Match object at 0x7f53baf25938>
>>> pat.match("/hello/toto/")
<_sre.SRE_Match object at 0x7f53baf25c68>

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


Re: Tkinter: The good, the bad, and the ugly!

2011-01-18 Thread Corey Richardson
On 01/18/2011 07:53 PM, rantingrick wrote:
> On Jan 18, 6:23 pm, Adam Skutt  wrote:
> 
> [snip]
> 
> Adam, it is now evident that your view of the world is, at best, a
> superficial one. You are shallow and incapable of any coherent
> abstract reasoning abilities. I genuinely hope this is due to some
> emotional distress you are suffering and not a chronic condition,
> because if not, you need to give some deep mediative thoughts to how
> you are perceiving the world around you to heal your mind of this
> improper processing. Being argumentative just for the sake of being
> argumentative is a never ending cycle of foolishness. Now, at some
> point earlier you had begin to display some coherency and insights. I
> sure hope that behavior will return soon..?

Because insulting others is completely how things get done. As to the
button/hyperlink, they may both share some common functionality and even
a common ancestor, they are different beings, otherwise they wouldn't be
two separate things. It may even be that a hyperlink is a type of
button, but that doesn't make a button a hyperlink. (Plant/tree,
rectangle/square type deal).

I for one am quite pleased with Tkinter up to this point. It allowed me
to come in with extremely minimal GUI experience, and make something
that worked with minimal effort. It was simple to understand, no
concepts of slots and signals to learn. A project I'm working on
requires PyQt, so I use PyQt. Is the fact that it's not in the stdlib a
detriment? No. I think Tkinter _should_ be in the stdlib because it's
simple. If something else were to take it's place I would hope that it
is as easy to learn/use as Tkinter is.

But I think this whole thread has gotten off topic. Why should Tkinter
be replaced? Why was it added there in the first place? What should
replace it, and why? Instead of arguing about little piddly details like
the difference between a button and a hyperlink, just stick to the task
at hand that you yourself presented.

My two cents,
~Corey
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tkinter: The good, the bad, and the ugly!

2011-01-18 Thread Corey Richardson
On 01/18/2011 08:41 PM, rantingrick wrote:
> On Jan 18, 7:19 pm, Corey Richardson  wrote:
> 
>> I for one am quite pleased with Tkinter up to this point. It allowed me
>> to come in with extremely minimal GUI experience, and make something
>> that worked with minimal effort. It was simple to understand, no
>> concepts of slots and signals to learn.
> 
> I agree. I have written tons of code with Tkinter and i love both the
> simplistic API and the geometry managers to name a few pros.
> 
> 
>> If something else were to take it's place (Tkinter) I would hope that it
>> is as easy to learn/use as Tkinter is.
> 
> I completely agree! And we should expect it to be even better!

What out there is there that meets those requirements?
> 
> 
>> But I think this whole thread has gotten off topic. Why should Tkinter
>> be replaced?
> 
> Well there are many good reasons and most are not apparent to those
> with minimal to average Tkinter experience. My main beef with Tkinter
> is that it is limited --both widget wise and extensible wise-- and
> that we must recognize that web and mobile platforms are getting
> bigger every day. We cannot ignore this fact. The GUI landscape is
> changing fast and whilst desktop support will be needed for many years
> to come, mobile and web must be addressed and addressed quickly!

Mobile and web certainly have their place, but it Python the place for
it? Sure, Python can be used as the back-end of web sites, but not up
front like Java or Flash (aside from Jython). Especially mobile. Python
was not intended for a mobile platform not should it be made to fit that
niche. Python has its place, but your cell phone is not it.
> 
>  [snip]
>> What should
>> replace it, and why?
> 
> Well that seems to be the burning question. Now, after considering all
> the options i can't see anything that truly moves us forward to were
> we "should" be. I do think wx would be a move "forward" however only a
> very *small* move in the larger scope of things. We need to think
> bigger, we need to think of mobile and web interfaces if we want
> Python to compete in the next 10 years. So when considering anything
> we must consider all three.
> 

>From that, it appears we need to:
1. Replace Tkinter with something more modern and feature-complete, but
just as easy to use.
2. Add a web framework/web-GUI

As a web interface are you thinking something like Java's Swing or
something like Django?

Given the above, what do you guys (python-list, not just rantingrick)
think fills the spot the best?

Would these items inclusion in the stdlib entail unnecessary cruft added
on to the size of the stdlib, are they completely cross-platform (as far
as Python itself is)?

Let's try not to get off track like this thing has been since it was
started. Either get things done or shut up ;-). I think this is almost
ready to split into a "real" thread, not just a giant cyclic argument
that this thread has been.

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


Re: Tkinter: The good, the bad, and the ugly!

2011-01-18 Thread Corey Richardson
On 01/18/2011 09:16 PM, rantingrick wrote:
> On Jan 18, 7:59 pm, Corey Richardson  wrote:
>> On 01/18/2011 08:41 PM, rantingrick wrote:
> 
>> >From that, it appears we need to:
>>
>> 1. Replace Tkinter with something more modern and feature-complete, but
>> just as easy to use.
>> 2. Add a web framework/web-GUI
> 
> That would be a HUGE step in the correct direction. It would not solve
> all our problems however its a start. Like i mentioned earlier with
> Tkinter it is fact that sooner or later you will come up against the
> glass ceiling. At that point your only alternative is to toss away
> everything you have learned/written and re-learn another GUI library
> like wxPython. This is what bothers me most about Tkinter. It just
> sums to wasted time and energy. If we had a simplistic wxGUI in the
> stdlib, when you hit the ceiling and need to go further you could then
> scale nicely to the feature richness of wxPython as a 3rd party
> download -- WITHOUT relearning/rewriting everything!
> 

You mentioned having a segment of wxPython in the stdlib earlier. If
this actually feasible from a legal standpoint, and would the
maintainers of wxPython be willing to put it in the stdlib? Not to
mention the wonderful people over at python-dev.

Why would you add in only a part of wxPython, instead of all of it? Is
the work to cut it down really an advantage over the size of the full
toolkit? From what I just checked, the source tarball is 40MB. Can that
much really be added to the Python stdlib? What other alternatives are
there, besides wxPython, that are perhaps a bit smaller.

> 
>> Given the above, what do you guys (python-list, not just rantingrick)
>> think fills the spot the best?
> 
> Well i hope some heavy weights weigh in however i must tell you that
> it don't happen very often.
> 
> 

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


Re: Tkinter: The good, the bad, and the ugly!

2011-01-18 Thread Corey Richardson
On 01/18/2011 09:46 PM, rantingrick wrote:
> On Jan 18, 8:27 pm, Corey Richardson  wrote:
> 
>> You mentioned having a segment of wxPython in the stdlib earlier. If
>> this actually feasible from a legal standpoint, and would the
>> maintainers of wxPython be willing to put it in the stdlib? Not to
>> mention the wonderful people over at python-dev.
> 
> This might come as a shock to you, but it really doesn't matter what
> the wxPython folks think about the inclusion of wxPython into the
> stdlib. If they are against it (or simply don't care) then they can
> continue to focus their efforts on the full version. No harm done,
> really. As far as python-dev is concerned -- it does matter! However
> if the community wants change, and makes enough noise, they will have
> no choice either. ;)
> 
>> Why would you add in only a part of wxPython, instead of all of it?
> 
> see my next answer for detail...
> 
>> Is
>> the work to cut it down really an advantage over the size of the full
>> toolkit? From what I just checked, the source tarball is 40MB. Can that
>> much really be added to the Python stdlib?
> 
> 40MB is far too big. Much of wxPython is thousands of widgets that
> have no buisness in the stdlib. We only want a very limited set (much
> like what Tkinter is composed of now) and then for the people who want
> to create professional GUI's they can download the full 40MB. The
> great advantage here is scalability. Tkinter cannot do this. And
> anybody who alludes to this is a liar.
> 
>>  What other alternatives are
>> there, besides wxPython, that are perhaps a bit smaller.
> 
> Well i am open to any and all alternatives. However no many have been
> brought forward. My dream would be to have something completely python
> based, although i realize that the work involved is far too enormous.
> So we must build from something that already exists. Nothing is really
> perfect. WxPython IS NOT perfect however it is a step forward.
> 
> As far as alternative here is a list...
> 
> http://docs.python.org/faq/gui

If that's what you believe, I don't think many (if any) here have an
issue with replacing Tkinter with something that has more features and
is just as easy to use. Write up a full-on proposal, including technical
feasibility of splitting up wxPython, and send it to python-ideas. After
they give some feedback, modify and send to python-dev. If it's well
written and makes sense, I'm sure they'll lend an ear. Just don't keep
getting off topic and I'm sure people will take you more seriously next
time. The insulting doesn't help either side.


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


Re: Tkinter: The good, the bad, and the ugly!

2011-01-18 Thread Corey Richardson
On 01/18/2011 10:24 PM, rantingrick wrote:
> On Jan 18, 9:02 pm, Corey Richardson  wrote:
> 
>> If that's what you believe, I don't think many (if any) here have an
>> issue with replacing Tkinter with something that has more features and
>> is just as easy to use.
> 
> Yea, and you're basing that on facts from where? If you haven't
> noticed by now NEWSFLASH! nobody from Python-dev has weighed in. Where
> is Steve Holden on the issue... who knows? Where is his subordinate on
> this?
> 
>> Write up a full-on proposal, including technical
>> feasibility of splitting up wxPython, and send it to python-ideas. After
>> they give some feedback, modify and send to python-dev. If it's well
>> written and makes sense, I'm sure they'll lend an ear.
> 
> Obviously you've never dealt with these folks before have you?
> 
>> Just don't keep
>> getting off topic and I'm sure people will take you more seriously next
>> time. The insulting doesn't help either side.
> 
> Yea, thats all it takes Corey.  Obviously you have not been around
> here long and know that because your spirit is not broken yet. But
> don't worry Corey, because if you hang around long enough these
> monsters will crucify you. Then you will understand why i have to rant
> so much, and why we find ourselves a full decade behind in GUI
> libraries with no good solution in sight. They can find a thousand
> reasons not to remove Tkinter and not one of them have an once of
> vision or thought applied. These people live on emotion, one hand
> washes the other, and back door politics. That is the current state of
> Python-dev as it relates to the "peasents". We are nothing to them.
> 
> Python has lost all vision as a community. This is no doubt the
> beginning of the end. Better check out GO...
> 
> 

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


Re: Tkinter: The good, the bad, and the ugly!

2011-01-18 Thread Corey Richardson
On 01/18/2011 10:54 PM, Adam Skutt wrote:
> On Jan 18, 9:27 pm, Corey Richardson  wrote:
>>
>> Why would you add in only a part of wxPython, instead of all of it? Is
>> the work to cut it down really an advantage over the size of the full
>> toolkit? From what I just checked, the source tarball is 40MB. Can that
>> much really be added to the Python stdlib? What other alternatives are
>> there, besides wxPython, that are perhaps a bit smaller.
>>
> The source tarball from the wxPython.org website contains a full
> version of wxWidgets in addition to the actual wxPython
> functionality.  A python distribution would  certainly contain solely
> the latter and require the end user to already have wxWidgets
> installed in a suitable fashion.  The actual full wxPython binding is
> ~100 MiB uncompressed, ~15 MiB compressed BZIP2, but it also includes
> a lot of stuff that could possibly be removed and/or reduced, like
> full documentation, examples, etc.  It can be shrunk even further by
> taking a dependency on swig and regenerating the bindings at compile
> time (they're shipped prebuilt).  At which point, it's pretty damn
> small.  Not as small as all of the Tk functionality, I think, but well
> under 10MiB compressed.
> 
> The problem to me isn't the size (though some might find it
> objectionable), but the system dependencies you have to take:
> wxWidgets requires GTK+ on UNIX, which requires a whole mess of crap
> in term, plus swig, plus whatever else I may or may not be missing.
> I'm also not 100% certain as to whether it's as portable as Tk is
> today.
> 
> At any rate, if the size is an issue, culling widgets is a lot of an
> effort for not much of a gain, especially when you look at the bigger
> picture of, "Every file I have to download to build python from
> scratch"  Minimizing what's in the Python distribution does not change
> the size of the dependency set one bit, and that dwarfs the python
> code in any case.  That is what you want to avoid in my opinion.
> 
> Adam

That is a pretty large dependency to rely on, and it is rather
undesirable IMO.

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


Re: Tkinter: The good, the bad, and the ugly!

2011-01-18 Thread Corey Richardson
On 01/18/2011 11:15 PM, rantingrick wrote:
> On Jan 18, 10:10 pm, Corey Richardson  wrote:
> 
>> That is a pretty large dependency to rely on, and it is rather
>> undesirable IMO.
> 
> And what exactly is undesirable? Unless you actually back up your
> statements with fact they just ring hallow. Can you offer any specific
> reasons why wx is a bad choice. And more importantly can you offer any
> viable alternatives?

Go ahead and read Adam's fine post about the dependencies of wxwidgets.
As for alternatives? I think Tkinter is fine for most of my purposes.
When I need something else, I use PyQt. I can install python-minimal on
Windows/Linux/What-have-you and know that Tkinter will run without
needing GTK+ and SWIG, as Adam mentioned. If you want to get something
done, here's an idea - do it yourself. That's what OS is all about.
Don't just write something, implement it. If the folks over in
python-dev want nothing to do with it, that's fine - make a package
using your minimal wxpython version, I'm sure people will use it,
especially if you make it as easy to use as Tkinter.

I'm done with this thread. I inserted my 12 cents. Have a nice day, and
good luck with your ventures.

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


Re: Need GUI pop-up to edit a (unicode ?) string

2011-01-22 Thread Corey Richardson

On 01/22/2011 03:22 PM, Rikishi42 wrote:


I'm in need for a graphical pop-up that will display a (unicode ?) string in
a field, allow the user to change it and return the modified string.

Maybe also keep the original one displayed above it.


Something like this:
+-+
|   Please confirm or edit the following string   |
| |
| Original_example_string |
| |
|  +---+  |
|  |  Original_about_to_be_changed |  |
|  +---+  |
| |
| OK  |
| |
+-+


I've never used any kind of graphical interface programing before, so I
don't have a clue where to start.
This would, however, be the *only* GUI part in the app at this point.


From what I can see the solution lays with PyQT, but the docs I find are

courses that aim to teach the whole GUI tool. I only need a little pop-up to
alow a user to edit part of a filename, for instance.


I'm using Python 2.6.x on various Linux platforms (mainly openSUSE and Mint)
and on Windows. Windows support is not important, in this case.





If that is all you need, I suggest Tkinter. Nice and easy, comes built 
into Python. Looks like you need two labels, an entry, and a button. 
When I was learning Tkinter I used http://effbot.org/tkinterbook/.


Hope it helped,
~Corey
--
http://mail.python.org/mailman/listinfo/python-list


Re: WxPython versus Tkinter.

2011-01-23 Thread Corey Richardson

On 01/23/2011 05:18 AM, rusi wrote:


Tried the code with debian sid and default python (2.6)

I get (after some loading... statements)

Segmentation fault

[Actually this is the first time in my 10 years of python that Ive
seen a pure python module segfault :-) ]


I also have a segfault. You should fix that, rantingrick :)
--
http://mail.python.org/mailman/listinfo/python-list


Re: A and B but not C in list

2011-01-23 Thread Corey Richardson

On 01/23/2011 04:05 PM, CM wrote:

In Python, is there a recommended way to write conditionals of the
form:

"if A and B but not C or D in my list, do something."  ?

I may also have variations on this, like "if A but not B, C, or D".

Do I have to just write out all the if and elifs with all possible
conditions, or is there a handier and more code-maintainable way to
deal with this?

Thanks.






if (A in list and B in list) and (C not in list or D not in list):
pass

I'm sure the gurus on this list can come up with something better.
--
http://mail.python.org/mailman/listinfo/python-list


Re: WxPython versus Tkinter.

2011-01-23 Thread Corey Richardson

On 01/23/2011 05:08 PM, rantingrick wrote:

On Jan 23, 3:11 pm, "Littlefield, Tyler"  wrote:


if you can't manage to provide cross-platform bug-free code.


No one has posted even one traceback Tyler (including yourself!). And
until they do i will assume that my code is bug free. I know it to be
bug free on windows. If and when someone *actually* provides proof
(supported by a traceback) then i will take them seriously.





There are more types of bugs than syntax errors, which are one of the 
only types of bug that raise exceptions in Python. Try looking at [1] or 
[2].


Here is the output on my system (Linux Mint 64bit):

/home/corey/Downloads/Wx_Tk_Challenge/Bitmaps
Loading Images:
 -- /home/corey/Downloads/Wx_Tk_Challenge/Bitmaps/file.bmp file.bmp
 -- /home/corey/Downloads/Wx_Tk_Challenge/Bitmaps/folder.bmp folder.bmp
 -- /home/corey/Downloads/Wx_Tk_Challenge/Bitmaps/link.bmp link.bmp
['folder', 'link', 'file']
Segmentation fault



[1] http://en.wikipedia.org/wiki/Software_bug#Common_types_of_computer_bugs
[2] http://msdn.microsoft.com/en-us/library/s9ek7a19%28v=vs.80%29.aspx
--
http://mail.python.org/mailman/listinfo/python-list


Re: WxPython versus Tkinter.

2011-01-23 Thread Corey Richardson

On 01/23/2011 07:07 PM, rantingrick wrote:

On Jan 22, 6:07 pm, rantingrick  wrote:


I await any challengers...



WxPython Challenge 1 code updated...

  * Fixed tab traveral
  * Removed hand-holding code
  * Removed some cruft

   https://sites.google.com/site/thefutureofpython/home/code-challenges

Good luck!


Still doesn't fix the problem of the code not working on Linux boxes. 
Maybe wxPython isn't the best option, it doesn't appear very cross-platform.

Still getting:

Loading Images:
 -- /home/corey/Downloads/Wx_Tk_Challenge/Bitmaps/file.bmp, file.bmp
 -- /home/corey/Downloads/Wx_Tk_Challenge/Bitmaps/folder.bmp, folder.bmp
 -- /home/corey/Downloads/Wx_Tk_Challenge/Bitmaps/link.bmp, link.bmp
imageMap.keys -> ['folder', 'link', 'file']
Segmentation fault

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


Re: WxPython versus Tkinter.

2011-01-23 Thread Corey Richardson

On 01/23/2011 08:25 PM, rantingrick wrote:

On Jan 23, 5:44 pm, "Martin v. Loewis"  wrote:

For something as common as displaying a file browser, it should be as
simple as this:



import gui_toolkit  # whichever
path = gui_toolkit.select_file()



Something like zenity:



[steve@sylar ~]$ zenity --file-selection
/home/steve/python/findsingle.py


And indeed, it is that simple:

python -c "import tkFileDialog as tkfd;print tkfd.askopenfilename()"



Martin the tkFileDialog.ask* uses the platform specific Open, Save
dialogs which DO contain a ListCtrl. Obviously this ListCtrl is not
available to Tkinter uses. You just exposed your weak knowledge of
Tkinter and sadly you are very high on the community totem pole. Very
sad :(



Actually, the people on the top of the totem pole were of less social 
status. 
http://podcasts.howstuffworks.com/hsw/podcasts/sysk/2009-11-17-sysk-totem-poles.mp3?_kip_ipx=1723793795-1295833113


(Finally, useful knowledge from listening to podcasts in my off-time!)

You have also ignored that I gave the same information as him (minus the 
traceback), saying that I am on Linux Mint 64bit.


Why can't we use a TreeCtrl? If we can't use all our widgets, why can 
you use all yours?


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


Re: WxPython versus Tkinter.

2011-01-23 Thread Corey Richardson

On 01/23/2011 08:50 PM, rantingrick wrote:

On Jan 23, 7:40 pm, Corey Richardson  wrote:


Why can't we use a TreeCtrl? If we can't use all our widgets, why can
you use all yours?

~Corey


Columns Corey, the key word here is "columns". One more
time...COOLUUUMMMNNN. Is this starting to sink in yet
Corey?


I sent that email before you sent your email explaining why (responded 
to Kevin), sorry that I can't see the future.

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


  1   2   >