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: 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: 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: 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: 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, 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: 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: 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: 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: 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: 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: 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: 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: [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: 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: 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: 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: 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: 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: 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 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: 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: 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: 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: 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: 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: 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: // 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: 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: 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 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: 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 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: 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: 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: 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


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


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: 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: 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: 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: 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: 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: 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: 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-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 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: Writing binary files in windows

2011-02-11 Thread Corey Richardson
On 02/11/2011 10:20 PM, Abhishek Gulyani wrote:
> When I write binary files in windows:
> 
> file  = open(r'D:\Data.bin','wb')
> file.write('Random text')
> file.close()
> 
> and then open the file it just shows up as normal text. There is nothing
> binary about it. Why is that?
> 
> Sorry if this is too much of a noobie question. I tried googling around but
> couldn't find an answer.
> 

It is binary! What are you expecting? You wrote text to a file, so when
you open the file with whatever, it displays like text. Even when you
don't open a file as binary, it is still a binary file. Otherwise it
wouldn't exist.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OO Python

2011-02-09 Thread Corey Richardson
On 02/09/2011 04:50 PM, Paul Symonds wrote:
> Are there any good resources to learn OO Python from?
> 

To my knowledge, all Python is OO. What specifically about OOP do you
want to know?

http://www.alan-g.me.uk/tutor/tutclass.htm

I've always liked Alan's site. Come over to the Tutor list if you need
basic help, tu...@python.org.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PIL Open Problem

2011-02-07 Thread Corey Richardson
On 02/07/2011 05:27 PM, Richard Holmes wrote:
> I'm trying to create an image for use in Tkinter. If I understand the
> PIL documentation correctly, I first need to import Image, then
> create an instance of the Image class and call 'open'

Don't do that. This is wrong:

import Image
im = Image.Image()
im = im.open(foo)

This is good:

import Image
im = Image.open(foo)
-- 
http://mail.python.org/mailman/listinfo/python-list


P2PU Python Challenges

2011-02-05 Thread Corey Richardson
In my journeys across the face of the Internet, I found this:
http://p2pu.org/general/python-challenges

Not sure what it's really going to be, but any new programmers/people
looking for something to do might be interested. I'm not quite sure how
a class can be organised around a web riddle, but it's there so someone
must have figured it out.

Just thought I'd share.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: psd estimation no matplotlib

2011-02-05 Thread Corey Richardson
On 02/05/2011 05:19 AM, Jack Yu wrote:
> Hi all,
> Is there a function psd() for estimating power spectral density that is not
> dependent on the importing of matplotlib or pylab [snip]
> 

There is not built into Python, but you could rip the function right out
of pylab's or matplotlib's source and put it in your own code, or even
just write it yourself.

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


Re: parse GET/POST data on simple http server

2011-02-03 Thread Corey Richardson
On 02/03/2011 03:15 AM, Markus wrote:
> Hi,
> 
> As a beginner in python, I am looking for example code that would help
> me understand how to
> code following idea:
> 1. Start minimal http server
> 2. Send GET or POST data (url encoded, or from form) - example
> Name="Foo"
> 3. Analyze the GET/POST variable value on server and match to
> different value
> example 'if Name = "Foo" then retval = "Bar" '
> 4. serve the content of retval back to user as plain html
> 
> If some code snipped that does implement all or part of the algorithm
> is known to you, please point me to it. I would be thankful for any
> push to the right direction.
> 
> Thank you!

[1] http://docs.python.org/library/cgihttpserver.html#module-CGIHTTPServer

...Sorry about that. I shouldn't post late at night!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: parse GET/POST data on simple http server

2011-02-03 Thread Corey Richardson
On 02/03/2011 03:15 AM, Markus wrote:
> Hi,
> 
> As a beginner in python, I am looking for example code that would help
> me understand how to
> code following idea:
> 1. Start minimal http server
> 2. Send GET or POST data (url encoded, or from form) - example
> Name="Foo"
> 3. Analyze the GET/POST variable value on server and match to
> different value
> example 'if Name = "Foo" then retval = "Bar" '
> 4. serve the content of retval back to user as plain html
> 
> If some code snipped that does implement all or part of the algorithm
> is known to you, please point me to it. I would be thankful for any
> push to the right direction.
> 
> Thank you!

If you really can't use a 'real' webserver like Apache, I found [1]. Not
sure how to use it, never had the need to. The documentation will show
you the way, however. Using that and the cgi module, your requirements
should be fulfilled.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-02-02 Thread Corey Richardson



On 2/2/2011 2:44 PM, rantingrick wrote:

[snip]
py>  flamer_group.append(troll_group.pop("Corey Richardson"))

Your moving up Corey. Keep up the good work!


I don't recall ever doing anything but injecting my honest opinion. If 
my opinion may be flawed (or appears to be flawed, I usually don't 
elaborate on my ideas enough), so be it.


Will you be forking IDLE and setting up some sort of tracker for 
improvements?

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


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-02-01 Thread Corey Richardson
On 02/01/2011 07:42 PM, Robert wrote:
> On 2011-02-01 10:54:26 -0500, Terry Reedy said:
> 
>> On 2/1/2011 12:13 AM, rantingrick wrote:
>>> On Jan 31, 4:17 pm, Kevin Walzer  wrote:
 Rick,
>>
>>> Yes. IDLE is first and foremost a tool to get work done. However we
>>> should not ignore the fact that IDLE could also be a great learning
>>> resource for Tkinter GUI's and other subjects. Why not clean up the
>>> code base? We could start small. First, move the custom widgets like
>>> textView, Tabbedpages, FindDialog, ReplaceDialog, and TreeWidget into
>>> the lib-tk for others to use more freely. Then we can modify the
>>> "event robbers" CallTips, ParenMatch, and ColorDelegator.
>>
>> Perhaps, after the repository moves from svn to hg, some 'we' will.
>> Maybe by then, you will have had your fun and be ready to work. Maybe
>> Kevin would help a bit.
> 
> If he does not, I think I might. Is there a timeline for the move?
> 

I would help with such a project as well, given the opportunity.

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


Re: how to get and search a html file from a website

2011-02-01 Thread Corey Richardson
On 02/01/2011 04:20 PM, Tracubik wrote:
> Hi all!
> i'm writing a notification program and i'm quite new to python.
> The program have to check every 5 minutes a particular website and alert 
> me when a particular sentence ("user online") is in the html.
> i've thinked to use a text browser (lynx) to retrieve the html and parse 
> the output in python as a normal text file.
> Do you have any better idea?
> 
> thanks
> Medeo

urllib2

http://docs.python.org/howto/urllib2.html

If you need fancy-shmancy parsing, look into:

 http://docs.python.org/library/htmlparser.html

Or you can treat the returned site as a string and just search for that
sentence.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-02-01 Thread Corey Richardson
On 02/01/2011 03:05 PM, rantingrick wrote:
> On Feb 1, 1:35 pm, John Nagle  wrote:
>> On 1/31/2011 2:17 PM, Kevin Walzer wrote:
>>
>>> It certainly would be interesting to see a fresh approach to IDLE...
>>
>> The future of "playing with Python" is probably Python in a browser
>> window, of which there are several implementations.
> 
> Hello John,
> 
> I found skulpt which looks rather interesting.
> 
>   http://www.skulpt.org/
> 
> Why do we not have a version of this at python.org so people can get a
> feel for python right away. Ruby has that "Learn Ruby in 20 Minutes"
> thing and so should we.
> 
> Do you have any links to projects such as this one that you like to
> share, John?
> 

http://people.csail.mit.edu/pgbovine/python/

Not quite an interpreter, and certainly has its limits, for example, it
will only let you run so many steps before not letting you go on. I
think it's a decent learning tool, but the visualisation is what makes
it shine, IMO. That version uses python 2.5, there is also a version
that uses python 3.1:

http://netserv.ict.ru.ac.za/python3_viz/


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


Re: WxPython versus Tkinter.

2011-01-27 Thread Corey Richardson
On 01/27/2011 09:53 PM, alex23 wrote:
> rantingrick  wrote:
>> You'll need to read that snippet in context to understand what i was
>> talking about. Again, see my "tip of the day" in my last post to you.
> 
> Pass. I'd have to see value in what you say inside of the endless
> masturbatory self-aggrandizement that you pass off as "visionary"
> posts. Instead it's all blah blah blah RUBY ASSHOLES blah blah
> INCOHERENT IDEA blah LAZY BASTARDS WHO DON'T APPRECIATE ME etc etc

Because insults and flaming totally get anyone anywhere.
If you don't have anything civil to say, don't say it at all (Because
sometimes un-nice things need to be said).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: WxPython versus Tkinter.

2011-01-27 Thread Corey Richardson
On 01/27/2011 05:08 PM, rantingrick wrote:
>> wxPython is the best and most mature cross-platform GUI toolkit, given a
>> number of constraints. The only reason wxPython isn't the standard
>> Python GUI toolkit is that Tkinter was there first.
>> -- Guido van Rossum
> 
> You forgot to put a date on that statement.

I didn't forget - there was no date provided.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: WxPython versus Tkinter.

2011-01-27 Thread Corey Richardson
On 01/27/2011 04:10 PM, rantingrick wrote:
> On Jan 27, 2:00 pm, Terry Reedy  wrote:
>> On 1/27/2011 12:54 PM, Octavian Rasnita wrote:
>>
>>> Everything that's not accessible is not recommended.
>>
>> By you. We get that.
>>
>>  >Tkinter should be at most accepted because there is no better solution,
>>
>> As I said at the beginning of this thread, tkinter is currently the only
>> option. What would have happened if there had been a real competitor
>> when 3.0 was being developed? What would happen in the future if one
>> were developed? I do not think anyone really knows.
>>
>>> at least for Python 3, not because it is the recommended solution.
>>
>> AS far as I know, Guido has never recommended any particular gui and I
>> believe he has avoided doing so when asked.
> 
> Yes but his silence speaks louder than words. He is saying " While i
> won't defend Tkinter publicly, i won't promote any others as well".
> This is a standard response you'd expect from a politician. These
> types of questions avoid dealing with the elephant in the room.
> 
> We can't just assume that Tkinter is best for Python just because
> "Guido" does not want to "ruffle" some features. Actually if you look
> back over the very few post where Guido did offer an argument for
> Tkinter you'll the find the argument to be very weak. And to make
> matters worse no one has the balls to question or argue Guido. Now
> whilst i greatly respect Guido i will not hesitate for one second to
> call him on weak arguments.
> 
> Case in point: Just recently i posted one of Guido's such arguments in
> another thread and responded to the argument. The original thread was
> from roughly eight years ago. Yes this is how long it has been since
> Guido offered argument for Tkinter. Does he honestly think that the
> world has not changed significantly in eight years as to render
> Tkinter into legacy? Does he also want us to believe that the world
> has not changed dramatically in the last twenty years since Tkinter
> was introduced? I have yet to get a response for his weak argument
> eight years ago and i can expect we will hear nothing now.
> 

wxPython is the best and most mature cross-platform GUI toolkit, given a
number of constraints. The only reason wxPython isn't the standard
Python GUI toolkit is that Tkinter was there first.
-- Guido van Rossum

(from http://www.wxpython.org/quotes.php)

A weak argument - yes. But the thought is there, and it's the thought
that counts, right? ;-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: WxPython versus Tkinter.

2011-01-26 Thread Corey Richardson
On 01/26/2011 01:18 AM, Octavian Rasnita wrote:
> From: "rantingrick" 
> On Jan 25, 3:41 pm, Corey Richardson  wrote:
> 
>> Do you honestly think he was talking about the accessibility problem?
>> IMO that should move to another thread, because this one is simply
>> about, as the subject suggests, "WxPython versus Tkinter".
> 
> Corey again (like many) you lack a global perspective. Anybody who has
> read along with his thread knows we are covering some pretty big
> issues here. WxPython is just the vehicle. The big picture is simply:
> Tkinter is old and in many ways insufficient for 21st century GUIs. We
> need to decide what should come next. I believe wxPython is our best
> hope. Wx may not be the best it can be, but it is the best we have at
> this time. There is more than "meets the eye" Corey!

I think he was referring to the large amount of trolling and immature
behaviour displayed. It would be a horrible thing to think that
accessibility is _bad_, unless of course it takes away from usability to
sighted users or is tons harder to implement (the technical reasons you
mentioned earlier). I understand that this thread is about the
deficiencies of Tkinter (and many other GUI toolkits) and that Wx is far
better than lots of what we have (but still has its issues). I
personally despise writing GUI's, but I do it when I have to. I'm a fan
of tkinter and wx because they are (in my very little experience) very
easy to use.

The issue I was raising with your post was really context. He wasn't
bashing specifically on accessibility or a toolkit, but more of the
attitudes and overall tone of some of the posts.

Hope that cleared it up for you.

(This would be a good time for python-gui to be opened up IMO, since it
appears lots of discussion is being generated)

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


Re: WxPython versus Tkinter.

2011-01-25 Thread Corey Richardson
On 01/25/2011 03:55 PM, Octavian Rasnita wrote:
> 
>> this thread was a "psy-ops" (psychological
>> operations) trick to turn off wxPython adopters by associating it with
>> juvenile nonsense
> 
> Do you think the need for accessibility is a nonsense?
> Or do you think it is something juvenile?
> 
> 
> Octavian
> 

Do you honestly think he was talking about the accessibility problem?
IMO that should move to another thread, because this one is simply
about, as the subject suggests, "WxPython versus Tkinter".
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: WxPython versus Tkinter.

2011-01-23 Thread Corey Richardson

On 01/23/2011 09:47 PM, rantingrick wrote:

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


I await any challengers...


CODE UPDATE:

  * removed sys.maxint (not sure how it got there?)


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


In the example at 
http://www.wxpython.org/OSCON2004/advanced/wxPython-Advanced-OSCON2004.pdf 
they use sys.maxint, which may be where you got it (wild shot in the dark!).


The following result in a segfault:
---item-1-
list_item = wx.ListItem()
list_item.SetId(idx)
list_item.SetText(name)
list_item.SetWidth(50)
index = self.InsertItem(list_item)
---end

--item-2--
self.InsertStringItem(idx, name)
---end


The following will launch the application:
(drop in replacement for line 151):

index = self.SetStringItem(idx, 0, name)

No idea why, I've never used wxPython before today.
Unfortunately, it doesn't actually show the items in the directory.
Since I'm definitely not a wxPython user, would you mind making the
above work, rantingrick? Not trying to worm out of anything, but this
is way over my head.

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


Re: WxPython versus Tkinter.

2011-01-23 Thread Corey Richardson

On 01/23/2011 09:29 PM, rantingrick wrote:

On Jan 23, 8:07 pm, Corey Richardson  wrote:


because imageIdx is just a dictionary,


No, imageIdx is an integer.


You're right.
imageIdx = self.imageMap[iconname]

I confused imageIdx with self.imageMap. But that still doesn't fix my 
problem, so before I go diving into the wxPython source, anyone have a 
'quick fix'?

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


Re: WxPython versus Tkinter.

2011-01-23 Thread Corey Richardson

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

On Jan 23, 6:30 pm, Corey Richardson  wrote:

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


On Jan 22, 6:07 pm, rantingrickwrote:



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


Have you tried any debugging? Maybe Linux has some specific needs and
NOT wxPython. Stop jumping to conclusions.



Python (and supposedly wxPython) are cross-platform. Code that runs on 
one should run on the other unmodified. This is obviously not the case.


Line 151 fails (determined from a simple binary search using print 
statements):


index = self.InsertImageStringItem(sys.maxint, name, imageIdx)

Maybe wxPython (really wxwidgets, python doesn't throw segfaults...that 
I've ever seen) isn't suited for the stdlib, unless this is a just a 
really silly bug somewhere in your programming (which I doubt it is).
Looks like an issue with the method, because imageIdx is just a 
dictionary, sys.maxint is a (surprise!) integer, and name is a string.

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


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


  1   2   >