Re: Python supports LSP, does it?

2005-08-10 Thread en.karpachov
On Thu, 11 Aug 2005 01:19:19 +0100
phil hunt wrote:

> According to Wikipedia, the Liskov substitution principle is:
> 
>   Let q(x) be a property provable about objects x of type T. Then 
>   q(y) should be true for objects y of type S where S is a subtype of T
> 
> To me, this is nonsense. Under this definition any subtype must 
> behave the same as its parent type, becausde if it doesn't there 
> will be some q(y) that are different to q(x).
> 
> But if it behaves the same, what's the point of having a subtype?

It does not behave the same, it has the same properties.

In other words, if there is some true assertion about _any_ object of type
x, then it's true about any object of type y, if y is derived from x.

Quick-and-dirty example: any object of type "list" is iterable, and it is true
as well for any object of some type derived from list.

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


Unicode regular expressions -- buggy?

2005-08-10 Thread Christopher Subich
I don't think the python regular expression module correctly handles 
combining marks; it gives inconsistent results between equivalent forms 
of some regular expressions:

 >>> sys.version
'2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)]'
 >>>re.match('\w',unicodedata.normalize('NFD',u'\xf1'),re.UNICODE).group(0)
u'n'
 >>>re.match('\w',unicodedata.normalize('NFC',u'\xf1'),re.UNICODE).group(0)
u'\xf1'

In the above example, u'\xf1' is n-with-tilde (ñ).  NFC happens to be a 
no-op, and NFD decomposes it into u'n\u0303', which splits out the tilde 
as a combining mark.

Is this a limitation-by-design, or a bug?  If the latter, is it already 
known/to-be-fixed?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pre-PEP Proposal: Codetags

2005-08-10 Thread Martin v. Löwis
Micah Elliott wrote:
> I also have this living as a wiki 
> if people would like to add comments there. I might try to capture there
> feedback from this group anyway. First try at a PEP -- thanks for any
> feedback!

I think you somewhat misunderstood the purpose of the PEP process.
This is meant primarily for enhancements to Python (the language
and its library), and it is meant to save the PEP author from
implementing unagreeable functionality - if the PEP is accepted,
the PEP author is typically expected to implement the proposed
functionality (in many cases, having a draft implementation is
prerequisite to accepting it).

Both elements seem to be missing your document: it does not propose
changes to the Python language; instead, it proposes a specific
way of writing comments (ie. something that is not relevant to the
Python interpreter or libraries, only to the Python developer).
Also, there is no indication that you would like to implement
something for the PEP: what tool would you like to change in what
specific way?

If you want this as a PEP so that Python somehow "endorses" code
tags (which appear to be independent from the programming language),
I'm -1: Python has traditionally abstained from pushing unrelated
technologies. Instead, it integrates with the technologies people
find useful; in this spirit, I would rather like to see code tags
become popular on their own merits, and *then* perhaps integrating
support for it into IDLE could be considered.

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


Re: signals (again)

2005-08-10 Thread bill
How does that help?  I interpret "use asynchronous calls" to mean "use
fcntl to set an FN_NOTIFY on the directory in order to be alerted when
something needs to be done."   But the method of doing that which I
outlined above has a critical section in which the incoming signal will
not be noticed.  All of the solutions I can think of for getting around
it involve a lot of acrobatics that I'm fairly certain aren't
necessary, and more to the point I don't think they actually solve the
problem.  There is always a section in which the signal arrives just
before the pause, so it doesn't wake us up out of the pause as it is
intended to.  We can set globals in the signal handler, and then check
them right before the pause, but if they get set after we check, then
we're hosed.  I was hoping that perhaps the following code might be
atomic:

if notify_occurred or signal.pause():

but I'm almost certain that it's not.

The problem is localized, so I don't see how invoking a seperate thread
is useful.  Could you elaborate on how you think that will help?

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


Re: what's the exactly newsgroup url of python-list?

2005-08-10 Thread Erik Max Francis
Ben Finney wrote:

> You may be confused.
> 
> news:comp.lang.python> is a URL to a Usenet newsgroup, as
> evidenced by the 'news:' schema part. If your web browser is
> configured properly to invoke a newsreader (such as Thunderbird) for
> 'news:' URLs, your newsrreader will then attempt to get the
> comp.lang.newsgroup from your default NNTP server.
> 
> python-list is a mailing list.

There's a relation between them which you're not mentioning, which is 
that all posts to the mailing list are gated to the newsgroup and vice 
versa.  They are not completely unrelated entities.

-- 
Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
   Make it come down / Like molasses rain
   -- Sandra St. Victor
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: new python debugger

2005-08-10 Thread nir1408
Thanks for the compliments.

I really believe Winpdb is not just another Python debugger, and that
it will be a real step forward in the quality of Python debuggers once
it matures.

Also, don't worry about the .com url, it is a GPL debugger.

Winpdb is still a BETA despite the version number which is 1.0.1
so I will appreciate feedback on bugs, unexpected behavior, or
suggestions.

Finally, If you think it is great, don't hesitate to share your opinion
with others.

Nir

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


Re: Python-2.4.1 Build error on AIX

2005-08-10 Thread Martin v. Löwis
Srinivasan TK wrote:
> I get the below error when trying to build python on
> AIX.
> 
> Is there a way to ignore _tkinter.

Yes. Just ignore these error messages.

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


Pre-PEP Proposal: Codetags

2005-08-10 Thread Micah Elliott
I also have this living as a wiki 
if people would like to add comments there. I might try to capture there
feedback from this group anyway. First try at a PEP -- thanks for any
feedback!


Please add **NOTE:** comments to the bottom of this wiki document
using `WikiRestructuredText`:trac:.

===
 Codetag PEP (*or* Tao of Codetagging)
===

PEP: XXX
Title: Codetags
Version: $Revision$
Last-Modified: $Date$
Author: Micah Elliott 
Status: Active
Type: Informational
Content-Type: text/x-rst
Created: 27-Jun-2005
Post-History: XXX


Abstract


This informational PEP aims to provide guidelines for consistent use
of Codetags, which would enable the construction of standard utilities
to take advantage of the Codetag information, as well as making Python
code more uniform across projects. Codetag is a also a very
lightweight programming micro-paradigm and becomes useful for project
managment, documentation, change tracking, and project health
monitoring. This is submitted as a PEP because I feel its ideas are
Pythonic, although the concepts are not unique to Python programming.
Herein are the definition of a Codetag, a philosophy rant, a
motivation for standardized conventions, a specification, a toolset
description, and possible objections to the Codetag project/paradigm.


What's a Codetag?
=

Programmers widely use ad-hoc code comment markup conventions to serve
as reminders of sections of code that need closer inspection or
review.  Examples of markup include ``FIXME``, ``TODO``, ``XXX``,
``BUG``, but there many more in wide use in existing software.  Such
markup will be henceforth referred to as a *Codetag*. These Codetags
may show up in application code, unit tests, scripts, general
documentation, or wherever suitable.


Philosophy
==

NOTE: **I'm not certain Philosophy_ belongs in the PEP, but it
somewhat explains the usefulness of Codetags** 

If you subscribe to most of these values, then Codetags will likely be
useful for you.

1. As much information as possible should be contained **inside the
   source code** (application code or unit tests). This along with use
   of Codetags impedes duplication. Most documentation can be
   generated from that source code Eg, by using help2man, man2html,
   docutils, epydoc/pydoc, ctdocgen, etc.

2. Information should be almost **never duplicated** -- it should be
   recorded in a single original format and all other locations should
   be automatically generated from the original, or simply be
   referenced.  This is the *SPOT* rule.

3. Documentation that gets into customers' hands should be
   **auto-generated** from single sources into whatever output formats.
   People want documentation in many forms. It is thus important to
   have a documentation system that can generate all of these.

4. Whatever information is subject to (and suited for) user
   feedback/input should be contained in a **wiki** (or maybe usenet or
   maillists). Eg, FAQ, RFC, PEP.

5. There should not be a dedicated, disjoint **documentation team**
   for any non-huge project.  The developers writing the code know the
   code best, and should be the ones to describe it.

6. **Plain text** (with non-invasive markup) is the best form of writing
   anything. All other formats are to be generated from the plain
   text.

7. **Revision control** should be used for almost everything. And
   modifications should be checkin'd at least daily.


Motivation
==

**Various productivity tools can be built around Codetags.**
See `Toolset Possibilities`_.

**Encourages consistency.**
Historically, a subset of these Codetags has been used informally in
the majority of codes in existence, whether Python or some other
language.  Tags have been used in an inconsistent manner with
different spellings, semantics, format, and placement. Eg, some
programmers might include datestamps and/or user identifiers, limit to
a single line or not, spell the Codetag differently than others, etc.

**Encourages adherence to SPOT/DRY principle.**
Eg, generating a roadmap dynamically from Codetags instead of keeping
TODOs in sync with separate roadmap document.

**Easy to remember.**
All Codetags must be concise, intuitive, and semantically
non-overlapping with others. Format is also simple.

**Use not required/imposed.**
If you don't use Codetags already, there's no obligation to start, and
no risk of affecting code (but see Objections_). A small subset can be
adopted and the Tools_ will still be useful (a few are already
implicitly adopted anyway). Also very easy to identify and remove if a
Codetag is no longer deemed useful. Then it is effectively *completed*
and recorded by revision control simply by checkin'ing.

**Gives a global view of code.**
Use tools to generate documentation and reports.

**A logical location for capturing CRCs/Stories/Requirements.**
The XP community often do

Re: Oreilly CodeZoo

2005-08-10 Thread richard
Jorge Godoy wrote:
> richard wrote:
>> That's a good idea. Unfortunately, changing the sorting of the
>> classifiers will be fun. Could I ask you to submit an RFE "bug" via the
>> link on the pypi page?
> 
> I'll do that tomorrow morning.

Thanks!

 
>> Yep, this is related to your other comment regarding my 6th point. Also,
>> I don't believe packages are included in the browse if they have no
>> classifiers.
> 
> It means that some packages might be "lost" somewhere?  How about an
> "unclassified" classifier? :-)

No, it means that when you're browsing by classifier, the packages that
don't specify any classifiers won't match your browse specifications ;)


>> There's a top-level RSS feed, but not one per-package.
> 
> I was thinking about one per topic / classification, not per package.  It
> would be overkill to subscribe to 600+ feeds.

Hurm. Interesting idea. Could be done with a bit of work.


Richard

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


Re: What is Python?!

2005-08-10 Thread Jeff Schwab
bruno modulix wrote:
> bash is a scripting language,

Bash is a shell.  It is frequently used for scripting, but that is only 
a secondary purpose.

> javascript is a scripting language,

Yes, but it's a particularly specialized one.

> perl is a scripting language,

Blasphemy!  Perl is a dynamic language, entirely suitable for large 
applications.  I've written some pretty big programs entirely in Perl, 
and extended it with C and C++ to make it fit nicely into existing 
application frameworks.

> php is a scripting language,

OK, but it's also awfully specialized.

> Python is *not* a scripting language !-)

It's a scripting language, among other things.  Why do you think 
non-imported source files are not automatically compiled to pyc's?
-- 
http://mail.python.org/mailman/listinfo/python-list


wanna stop by my homemade glory hole?

2005-08-10 Thread Jennifer
my husband is installing an extra bathroom poolside.  there is a perfect size 
hole (unless you have a huge cock) to stick your dick through into the adjoing 
room.  come around the side of my house(perfect if you look like a repair man) 
enter into the unfisnished bathroom and I'll service you from the other side.  
you can leave when your done, no talking or small talk.  i want to do this 
before the hole gets patched up. its been a huge fantasy of mine ever since 
I've seen a glory hole online. you can email me for a time convienient for you. 
im home all-day most days so my schedule is open. do you prefer a certain color 
of lipstick? check out my pic and email here under kallegirl26 
www.no-strings-fun.net/kallegirl26 
ready and waiting, me ;o)


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


Re: Python supports LSP, does it?

2005-08-10 Thread Gregory Bond
phil hunt wrote:

> To me, this is nonsense. Under this definition any subtype must 
> behave the same as its parent type, becausde if it doesn't there 
> will be some q(y) that are different to q(x).

Not necessarily. the set of operations on y could be a superset of 
the set of operations on x.  So you could have q(y) == q(x) (for all q 
applicable to x) but there could be w(y) that has no w(x).  In C++ 
terms, this implies no virtual functions.

Which is not to say that I'm disagreeing with your basic point: 
insisting on q(y) == q(x) for all q will greatly limit your use of 
polymorphism, unless you are 'sensible' (or perhaps what a mathematician 
would call 'loose') about how you define your "q"s!
-- 
http://mail.python.org/mailman/listinfo/python-list


datagram queue length

2005-08-10 Thread Jonathan Ellis
I seem to be running into a limit of 64 queued datagrams.  This isn't a
data buffer size; varying the size of the datagram makes no difference
in the observed queue size.  If more datagrams are sent before some are
read, they are silently dropped.  (By "silently," I mean, "tcpdump
doesn't record these as dropped packets.")  This is a problem because
while my consumer can handle the overall load easily, the requests
often come in large bursts.

This only happens when the sending and receiving processes are on
different machines, btw.

Can anyone tell me where this magic 64 number comes from, so I can
increase it?

Illustration follows.

-Jonathan

# 
# start this, then immediately start the other
# _on another machine_
import socket, time

sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.bind(('', 3001))

time.sleep(5)

while True:
 data, client_addr = sock.recvfrom(8192)
 print data

# 
import socket

for i in range(200):
 sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
 sock.sendto('a' * 100, 0, ('***other machine ip***', 3001))
 sock.close()

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


performance of recursive generator

2005-08-10 Thread aurora
I love generator and I use it a lot. Lately I've been writing some  
recursive generator to traverse tree structures. After taking closer look  
I have some concern on its performance.

Let's take the inorder traversal from  
http://www.python.org/peps/pep-0255.html as an example.

def inorder(t):
 if t:
 for x in inorder(t.left):
 yield x
 yield t.label
 for x in inorder(t.right):
 yield x

Consider a 4 level deep tree that has only a right child:

1
  \
   2
\
 3
  \
   4


Using the recursive generator, the flow would go like this:

maingen1gen2gen3gen4


inorder(1..4)

 yield 1
 inorder(2..4)
 yield 2
 yield 2
 inorder(3..4)
 yield 3
 yield3
 yield 3
 inorder(4)
 yield 4
 yield 4
 yield 4
 yield 4


Note that there are 4 calls to inorder() and 10 yield. Indeed the  
complexity of traversing this kind of tree would be O(n^2)!


Compare that with a similar recursive function using callback instead of  
generator.

def inorder(t, foo):
 if t:
 inorder(t.left, foo):
 foo(t.label)
 inorder(t.right, foo):


The flow would go like this:

mainstack1  stack2  stack3  stack4


inorder(1..4)
 foo(1)
 inorder(2..4)
 foo(2)
 inorder(3..4)
 foo(3)
 inorder(4)
 foo(4)


There will be 4 calls to inorder() and 4 call to foo(), give a reasonable  
O(n) performance.

Is it an inherent issue in the use of recursive generator? Is there any  
compiler optimization possible?
-- 
http://mail.python.org/mailman/listinfo/python-list


Interface type checking

2005-08-10 Thread Paddy
Hi,
I read a blog entry by GVR on interfaces in which he mentioned that you
had to be able to state the type signature of, say, a function.

That got me thinking along the lines of:
  If you have some typical data, then transform it into a string
showing
  its sub-types.
  Could not a regular expression matching this string be used to check
the type signature of the data?

for example:
  >>> data = [[{'a': 1, ('b',):3.0 }, ()]]
  >>> stringrep = typeExpand(data)
  >>> stringrep
  'list:float>,tuple<>>>'
  >>> re.match(r"^list|tuple<.*>)*>>$",stringrep)
  <_sre.SRE_Match object at 0x01611F60>
  >>>

Looking at the example above, I don't think regular expression matching
is right.
Some extra syntax such as:
  typeMatcher.match(r"list|tuple<.*>)*>>", stringrep
Where this matcher is more like a parser and so does '<' '>' nested
bracket matching; changes . to mean 0 or more types (e.g: 'str'; or
'str,str...'); and allows you the shorthand of writing 'list' for
.list<.*>'.

I've done some work below on typeExpand, but I'm not fluent in a parser
module to implement typeMatcher.match quickly.

Enjoy!


#== BEGIN typeMatcher.py ==
'''
Object type Expander
'''

import types
from pprint import pprint as pp

# Map types to a type name
type2name = dict( [ (typ,name[:name.rindex('Type')].lower())
for name,typ in types.__dict__.iteritems()
  if type(typ)==types.TypeType
  and str(typ).find('=0 ]
  +[(type(set()), 'set')] )
#pp(type2name)

def typeExpand(obj):
  ' Expand an objects type'
  ty = type(obj)
  name = type2name.get(ty,'')
  if not name:
# Make up a name. So "" becomes "_type_XX_"
name = str(type(obj))
name = name.replace(' ','_')
name = name.replace('<','_')
name = name.replace('>','_')
name = name.replace("'",'')
  typeExpansionHandler = globals().get( name+'__TypeHandler', None)
  if typeExpansionHandler:
return ''.join([name, '<', typeExpansionHandler(obj), '>'])
  else:
return name

def list__TypeHandler(obj):
  ' How to expand the contents of a list/tuple'
  return ','.join([ typeExpand(ob) for ob in obj])
tuple__TypeHandler = list__TypeHandler

def dict__TypeHandler(obj):
  ' How to expand the contents of a dict'
  return ','.join([ '%s:%s' % (typeExpand(name), typeExpand(value))
for name,value in obj.iteritems()])

def match(matchExprString, typeString): pass

#== END typeMatcher.py ==

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


Re: what's the exactly newsgroup url of python-list?

2005-08-10 Thread Ben Finney
He, Aspk <[EMAIL PROTECTED]> wrote:
> My thunderbir cant connect to comp.lang.python as the python.org page
> saying.

You may be confused.

news:comp.lang.python> is a URL to a Usenet newsgroup, as
evidenced by the 'news:' schema part. If your web browser is
configured properly to invoke a newsreader (such as Thunderbird) for
'news:' URLs, your newsrreader will then attempt to get the
comp.lang.newsgroup from your default NNTP server.

python-list is a mailing list.

-- 
 \"When I was a baby I kept a diary. Recently I was re-reading |
  `\   it, it said 'Day 1: Still tired from the move. Day 2: Everybody |
_o__)   talks to me like I'm an idiot.'"  -- Steven Wright |
Ben Finney 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is Python?!

2005-08-10 Thread Evil Bastard
bruno modulix wrote:
> You can tell buy the most common use. bash is a scripting language,
> javascript is a scripting language, perl is a scripting language, php is
> a scripting language, Python is *not* a scripting language !-)

Perhaps a better definition - the term 'scripting language' is
increasingly being used by CTOs as a justification for saving money by
putting large chunks of their workforces on lower pay scales - an
attitude of 'scripters aren't as skilled as real programmers, so don't
deserve the same pay'.

To me, the term is archic. What 'scripting language' means to me is:
 1. insufficient facilities for general purpose or 'serious' programming
 2. ability to get simple useful programs up and working quickly
 3. absence of a hack/compile/link/test cycle.

What makes 1 and 3 redundant is that linkage mechanisms have diversified
over the years. For instance, java and python's 'import' statements,
java's CLASSPATH and python's 'sys.path'.

I guess a language could be called a 'scripting language' if:
 - the source code can be executed directly, and/or
 - source need not be converted to a separate file in a
   non-human-readable format before it can be executed, and/or
 - a change to the source file automatically causes a change in
   runtime behaviour

By these, Python is most definitely a scripting language, and joins Perl
and PHP. Whereas changes to java source files don't change runtime
behaviour.

OTOH, Python is also a compiled language, since it can be 'fixed' into a
n executable binary format.

-- 
Cheers
EB

--

One who is not a conservative by age 20 has no brain.
One who is not a liberal by age 40 has no heart.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PEP 328, absolute/relative import

2005-08-10 Thread Ben Finney
Aahz <[EMAIL PROTECTED]> wrote:
> Ben Finney  <[EMAIL PROTECTED]> wrote:
> >So, under PEP 328 rules, the original poster's current-directory
> >module could only be imported (a) if the current directory was in
> >sys.path, or (b) if the code specified a relative import. The
> >accidental shadowing of the stdlib module could not happen.
> 
> Normally the current directory *is* on sys.path, and the first
> thing, too:

Ah. I'd forgotten that, my bad.

So, modules in the current directory will continue to be imported as
before, because they *are* absolute imports by PEP328 definitions.

-- 
 \"If it ain't bust don't fix it is a very sound principle and |
  `\  remains so despite the fact that I have slavishly ignored it |
_o__)  all my life."  -- Douglas Adams |
Ben Finney 
-- 
http://mail.python.org/mailman/listinfo/python-list


looking to GIVE my first oral favor

2005-08-10 Thread Casee
im new to this, i guess you can say im still curious about having extra marital 
lovers.  i've only had 1 encounter with a married man and I loved it so much.  
its such a strong burning desire now.  when I look at men, i'm always wondering 
how they look nude, or their cock size. basically, i want to find a man to have 
his way with me and really show me the ropes of being a lover to another man on 
the side. exchange face and cock pics with me here under luvnlady3050 
http://www.no-strings-fun.net/kallegirl26 
kisses, me



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


Re: regex help

2005-08-10 Thread Christopher Subich
jeff sacksteder wrote:
> Regex questions seem to be rather resistant to googling.
> 
> My regex currently looks like - 'FOO:.*\n\n'
> 
> The chunk of text I am attempting to locate is a line beginning with
> "FOO:", followed by an unknown number of lines, terminating with a
> blank line. Clearly the ".*" phrase does not match the single newlines
> occuring inside the block.

Include the re.DOTALL flag when you compile the regular expression.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Short term project

2005-08-10 Thread Peter Olsen
I'd like to hear more.

Michael Seeley wrote:

> To: [EMAIL PROTECTED]
> From: "Michael Seeley" <[EMAIL PROTECTED]>
> Subject: Short term project
> Date: Mon, 01 Aug 2005 20:18:47 GMT
> 
> I have a client in Fort Worth, TX that needs a Python programmer for a 
> short
> project.  This could be a telecommuting position.  Please email me at
> [EMAIL PROTECTED] if interested.
> 
> --
> http://mail.python.org/mailman/listinfo/python-announce-list
> 
>Support the Python Software Foundation:
>http://www.python.org/psf/donations.html
-- 
http://mail.python.org/mailman/listinfo/python-list


what's the exactly newsgroup url of python-list?

2005-08-10 Thread He, Aspk
My thunderbir cant connect to comp.lang.python as the python.org page
saying.

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


Re: PEP 328, absolute/relative import (was: Re: Bizarre error from help())

2005-08-10 Thread Aahz
In article <[EMAIL PROTECTED]>,
Ben Finney  <[EMAIL PROTECTED]> wrote:
>
>So, under PEP 328 rules, the original poster's current-directory
>module could only be imported (a) if the current directory was in
>sys.path, or (b) if the code specified a relative import. The
>accidental shadowing of the stdlib module could not happen.

Normally the current directory *is* on sys.path, and the first thing,
too:

>>> sys.path
['', '/usr/local/lib/python24.zip', '/usr/local/lib/python2.4', 
'/usr/local/lib/python2.4/plat-netbsd2', '/usr/local/lib/python2.4/lib-tk', 
'/usr/local/lib/python2.4/lib-dynload', 
'/usr/local/lib/python2.4/site-packages']
-- 
Aahz ([EMAIL PROTECTED])   <*> http://www.pythoncraft.com/

The way to build large Python applications is to componentize and
loosely-couple the hell out of everything.
-- 
http://mail.python.org/mailman/listinfo/python-list


regex help

2005-08-10 Thread jeff sacksteder
Regex questions seem to be rather resistant to googling.

My regex currently looks like - 'FOO:.*\n\n'

The chunk of text I am attempting to locate is a line beginning with
"FOO:", followed by an unknown number of lines, terminating with a
blank line. Clearly the ".*" phrase does not match the single newlines
occuring inside the block.

Suggestions are warmly welcomed.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: "Compile time" checking?

2005-08-10 Thread Bengt Richter
On Wed, 10 Aug 2005 20:39:03 +0100, [EMAIL PROTECTED] (phil hunt) wrote:
[...]
>
>I've not personally had problems with the wrong number of argumnets 
>to a function call -- they get caught at run-time and are easy 
>enough to fix -- but I do sometimes get errors because a varialbe is 
>the wrong time, e.g. a string when it should be an int.
>
>One problem I once encountered was wit this and I waasn't picking it 
>up because my debugging code looked like this:
>
>   if debug: print "v=%s" % (v,)
>
>Which of course prints the same output whether v is '2' or 2.
>
>For this reason I tend to debug print statements like this now:
>
>   if debug: print "v=%s" % (v,)

I usually prefer %r over %s for debug prints

if debug: print "v=%r" % (v,)

since it represents (repr's ;-) the v thing better

 >>> print 'v=%r' % 2
 v=2
 >>> print 'v=%r' % '2'
 v='2'

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


Tiny Python interpreter

2005-08-10 Thread Lucas Correia Villa Real
Hello,

I'm working with an ARM cpu which has only 64MB of flash memory available for 
storing applications. This system is running with an X server, some office 
applications and now I need to have a small Python interpreter, too (Python 
2.2 is fine).

I've googled a bit for the subject, but the only relevant links were outdated, 
and I haven't found any active project so far. Does anyone know of 
implementations which are still being maintained and which makes Python 
available for embedded systems?

Thanks in advance for any suggestions, and please CC: me on replies, as I'm 
not subscribed to this list.

-- 
Lucas
powered by /dev/dsp
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Creating Palm OS programs with python?

2005-08-10 Thread Casey Hawthorne
Apparently there is a PVM (Python Virtual Machine) for the Palm OS,
but it is several versions back!

Jython, might be better, but it is also a few versions back!

[EMAIL PROTECTED] wrote:

>QUick question:
>
>Is it possible to create a palm os program to use on a PDA with
>python?
>
>
>THanks
--
Regards,
Casey
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What are modules really for?

2005-08-10 Thread Mike Meyer
Peter Hansen <[EMAIL PROTECTED]> writes:

> Dan wrote:
>> You might think of modules in Python as like packages in Java. However,
>> putting classes in the same module doesn't give them any additional
>> powers to interact with each other. (At least, not that I know of.)
>
> Use of "global" to rebind shared module-scope names...

You can rebind module-scope names from outside the module. It's an
ugly practice, and I wouldn't recommend it, but it *is* possible.

But you're on the right track. If two consenting classes want to share
_named module variables, it's best that they be in the same module.

 http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python supports LSP, does it?

2005-08-10 Thread phil hunt
On Tue, 09 Aug 2005 18:36:56 -0500, Andy Leszczynski 
 wrote:
>wikipedia 
>(http://en.wikipedia.org/wiki/Python_programming_language#Object-oriented_programming)
> 
>says:
>"""
>Python's support for object oriented programming paradigm is vast. It 
>supports polymorphism [...] fully in the Liskov substitution 
>principle-sense for all objects.
>"""
>
>Just wondering if it is true statement. Is not LSP more a quality of the 
>desing of class hierachy rather then language itslef? Comments?

According to Wikipedia, the Liskov substitution principle is:

  Let q(x) be a property provable about objects x of type T. Then 
  q(y) should be true for objects y of type S where S is a subtype of T

To me, this is nonsense. Under this definition any subtype must 
behave the same as its parent type, becausde if it doesn't there 
will be some q(y) that are different to q(x).

But if it behaves the same, what's the point of having a subtype?

Am I missing something?

-- 
Email: zen19725 at zen dot co dot uk


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


Re: Is there a way of executing a command in a string?

2005-08-10 Thread Mike Meyer
Jeff Schwab <[EMAIL PROTECTED]> writes:

> Jerry He wrote:
>> Hi,   suppose I have the following string
>> cmdstr = "b = lambda s: s*s"
>>   Is there a way to execute this string other than
>> copying it onto a file and then importing it?
>
>  >>> exec "b = lambda s: s*s"
>  >>> b

Jeff forgot to warn you that exec is a *dangerous* function. Don't use
it on data that you aren't 100% sure of the origin of. Better yet,
avoid it if at all possible.

If you'll tell us why you think you need to do this, possibly we can
help you avoid using exec.

   http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: "Compile time" checking?

2005-08-10 Thread Grant Edwards
On 2005-08-11, Qopit <[EMAIL PROTECTED]> wrote:
>
>> if debug: print "v=%s" % (v,)
>
> Not that important, but I assume the first one was supposed to be:
>
>   if debug: print "v=", s
>
> right?

http://docs.python.org/tut/node9.html#SECTION00910

-- 
Grant Edwards   grante Yow!  .. Now KEN and BARBIE
  at   are PERMANENTLY ADDICTED to
   visi.comMIND-ALTERING DRUGS...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Recommendations for CVS systems

2005-08-10 Thread Mike Meyer
[EMAIL PROTECTED] (Aahz) writes:

> In article <[EMAIL PROTECTED]>,
> Erik Max Francis  <[EMAIL PROTECTED]> wrote:
>>
>>It also is free for personal use (up to 2 clients, 2 users) and open 
>>soruce projects can get free licenses.  Or at least it was so the last I 
>>checked.
>
> For anything mission-critical, I wouldn't want to rely on a free license.
> At least if it's Open Source and someone plays with the license, someone
> else will fork (c.f. XFree86).  Alternatively, I am sometimes willing to
> pay for good closed-source software.

To my mind, Perforce qualifes for that last sentence. It's solid
software, with excellent support, from people who really understand
both software development and the open source software movement.

 http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python supports LSP, does it?

2005-08-10 Thread Mike Meyer
bruno modulix <[EMAIL PROTECTED]> writes:
> Clearly, somethingElse is a subtype of baseClass, when derivedClass is
> not. Don't confuse suclassing with subtyping. issinstance() let you
> check for subclassing, not for subtyping. The only language-level
> mechanism I know of that more or less inforce LSP is Eiffel's contracts.

Eiffel's DbC has been picked up by other languages. D and SPARK come
to mind.

In a broader sense, a couple of Python frameworks support interfaces,
which basically guarantee subtyping at the same level as Liskov's CLU
language does.

   http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to write a line in a text file

2005-08-10 Thread James Dennett
Calvin Spealman wrote:
> On 7/31/05, James Dennett <[EMAIL PROTECTED]> wrote:
> 
>>Peter Hansen wrote:
>>
>>
>>>Steven D'Aprano wrote:
>>>
>>>Given that ZODB and PySQLite are simply Python extension modules, which
>>>get bundled by your builder tool and are therefore installed
>>>transparently along with your app by your installer, this is a total
>>>non-issue at least with those packages.
>>>
>>>After all, it's not 1970 any more. ;-)
>>
>>Indeed; since 1970 we learned to prefer straightforward
>>file formats where possible, reserving use of databases
>>for structured data where the extra costs are justified.
>>
>>Sometime maybe databases will get better to the point
>>that we don't need to distinguish so much between them
>>and filesystems, but we're not there yet.  Managing raw
>>files, carefully, still has a place.
>>
>>-- James
> 
> 
> Filesystems are a horrible way to organize information, and even worse
> at structuring it. The mentality that there are any benefits of
> low-overhead the outweigh the benefits of minimal database layers,
> such as ZODB, BSD DB, and SQLite, is a large part of the reason we are
> still stuck with such a mess. Those "extra costs" are so minimal, that
> you wouldn't even notice them, if you hadn't convinced yourself of
> their presense before performing or researching any realy benchmarks.
> A simple RDBMS can be much easier to work with than any flat file
> format, will likely be far faster in processing the data, and has the
> benefit of years of coding making the code that actually reads and
> writes your data as fast and stable as possible.

Read again, and you'll note that I didn't say the costs were
performance related (though in some, just some, situations the
performance cost of using an RDBMS is a reason to avoid it,
and in other cases an RDBMS will be faster than naive file
access).

The reasons for using other formats are things such as better
interoperability, which extends to better future proofing,
easier installations (in some situations -- note again that
there are no hard and fast rules), and the fact that power
users can edit the files by hand (more easily than they can
tweak information in databases in many, but not all, cases).
It can also (again, in some cases) be easier to port filesystem
based storage between systems than to move database access code.

Oh, and please don't assume that I make my decisions without
measuring performance.  If you store enough millions, or
billions, of items, then performance is worth measuring.  I've
found situations where using various database engines made sense,
I've found situations where flat files made more sense, and I've
seen cases where either was used where the other might have been
a better choice.

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


Weekly Python Patch/Bug Summary

2005-08-10 Thread Kurt B. Kaiser
Patch / Bug Summary
___

Patches :  352 open ( -2) /  2896 closed ( +8) /  3248 total ( +6)
Bugs:  913 open ( +4) /  5162 closed (+10) /  6075 total (+14)
RFE :  191 open ( +0) /   178 closed ( +0) /   369 total ( +0)

New / Reopened Patches
__

compiler package: "global a; a=5"  (2005-08-04)
   http://python.org/sf/1251748  opened by  Armin Rigo

Simplying Tkinter's event loop  (2005-08-05)
   http://python.org/sf/1252236  opened by  Michiel de Hoon

modulefinder misses modules  (2005-08-05)
   http://python.org/sf/1252550  opened by  Thomas Heller

poplib list() docstring fix  (2005-08-05)
CLOSED http://python.org/sf/1252706  opened by  Steve Greenland

QuickTime API needs corrected object types  (2005-08-09)
   http://python.org/sf/1254695  opened by  Christopher K Davis

GCC detection for runtime_library_dirs when ccache is used  (2005-08-09)
   http://python.org/sf/1254718  opened by  Seo Sanghyeon

Patches Closed
__

Faster commonprefix in macpath, ntpath, etc.  (2005-01-20)
   http://python.org/sf/1105730  closed by  birkenfeld

poplib list() docstring fix  (2005-08-05)
   http://python.org/sf/1252706  closed by  birkenfeld

absolute paths cause problems for MSVC  (2003-10-21)
   http://python.org/sf/827386  closed by  loewis

Fix LINKCC (Bug #1189330)  (2005-07-15)
   http://python.org/sf/1239112  closed by  loewis

file.encoding support for file.write and file.writelines  (2005-06-04)
   http://python.org/sf/1214889  closed by  birkenfeld

st_gen and st_birthtime support for FreeBSD  (2005-04-11)
   http://python.org/sf/1180695  closed by  loewis

Add unicode for sys.argv, os.environ, os.system  (2005-07-02)
   http://python.org/sf/1231336  closed by  loewis

Refactoring Python/import.c  (2004-12-30)
   http://python.org/sf/1093253  closed by  theller

New / Reopened Bugs
___

cgitb gives wrong lineno inside try:..finally:  (2005-08-03)
   http://python.org/sf/1251026  opened by  Rob W.W. Hooft

Decoding with unicode_internal segfaults on UCS-4 builds  (2005-08-03)
   http://python.org/sf/1251300  opened by  nhaldimann

smtplib and email.py  (2005-08-03)
   http://python.org/sf/1251528  opened by  Cosmin Nicolaescu

Python 2.4.1 crashes when importing the attached script  (2005-08-04)
   http://python.org/sf/1251631  opened by  Viktor Ferenczi

Fail codecs.lookup() on 'mbcs' and 'tactis'  (2005-08-04)
   http://python.org/sf/1251921  reopened by  lemburg

Fail codecs.lookup() on 'mbcs' and 'tactis'  (2005-08-04)
   http://python.org/sf/1251921  opened by  liturgist

Issue with telnetlib read_until not timing out  (2005-08-04)
   http://python.org/sf/1252001  opened by  padded

IOError after normal write  (2005-08-04)
   http://python.org/sf/1252149  opened by  Patrick Gerken

os.system on win32 can't handle pathnames with spaces  (2005-08-05)
CLOSED http://python.org/sf/1252733  opened by  Ori Avtalion

non-admin install may fail (win xp pro)  (2005-07-05)
CLOSED http://python.org/sf/1232947  reopened by  loewis

raw_input() displays wrong unicode prompt  (2005-01-10)
   http://python.org/sf/1099364  reopened by  prikryl

Python interpreter unnecessarily linked against c++ runtime  (2005-08-08)
   http://python.org/sf/1254125  opened by  Zak Kipling

parser fails on long non-ascii lines if coding declared  (2005-08-08)
CLOSED http://python.org/sf/1254248  opened by  Oleg Noga

Docs for list.extend() are incorrect  (2005-08-08)
CLOSED http://python.org/sf/1254362  opened by  Kent Johnson

"appropriately decorated" is undefined in MultiFile.push doc  (2005-08-09)
   http://python.org/sf/1255218  opened by  Alan

float('-inf')  (2005-08-10)
   http://python.org/sf/1255395  opened by  Steven Bird

bug in use of __getattribute__ ?  (2005-08-10)
CLOSED http://python.org/sf/1256010  opened by  sylvain ferriol

Bugs Closed
___

numarray in debian python 2.4.1  (2005-08-02)
   http://python.org/sf/1249903  closed by  birkenfeld

incorrect description of range function  (2005-08-02)
   http://python.org/sf/1250306  closed by  birkenfeld

isinstance() fails depending on how modules imported  (2005-08-01)
   http://python.org/sf/1249615  closed by  hgibson50

set of pdb breakpoint fails  (2005-07-30)
   http://python.org/sf/1248127  closed by  birkenfeld

Fail codecs.lookup() on 'mbcs' and 'tactis'  (2005-08-04)
   http://python.org/sf/1251921  closed by  loewis

os.system on win32 can't handle pathnames with spaces  (2005-08-05)
   http://python.org/sf/1252733  closed by  salty-horse

distutils: MetroWerks support can go  (2005-07-17)
   http://python.org/sf/1239948  closed by  jackjansen

non-admin install may fail (win xp pro)  (2005-07-05)
   http://python.org/sf/1232947  closed by  loewis

segfault in os module  (2005-06-24)
   http://python.org/sf/1226969  closed by  loewis

LINKCC incorrect

Re: What is Python?!

2005-08-10 Thread Roy Smith
In article <[EMAIL PROTECTED]>,
 "Jason Drew" <[EMAIL PROTECTED]> wrote:

> Roy Smith wrote: "there's a system called Jython, which lets you
> compile Java source to Python byte code."
> 
> Don't you have that the wrong way 'round?

Duh, of course I do!  Thanks for the correction.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: "Compile time" checking?

2005-08-10 Thread Qopit

> if debug: print "v=%s" % (v,)

Not that important, but I assume the first one was supposed to be:

  if debug: print "v=", s

right?

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


Re: PEP 328, absolute/relative import (was: Re: Bizarre error from help())

2005-08-10 Thread Roy Smith
Ben Finney <[EMAIL PROTECTED]> wrote:
> Once PEP 328 is fully implemented, all bare 'import foo' statements
> specify absolute imports (i.e. from sys.path only). To perform a
> relative import (e.g. from current directory) will require different
> syntax.

It seems like this will break lots of existing code.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: signals (again)

2005-08-10 Thread Paul Rubin
"bill" <[EMAIL PROTECTED]> writes:
> What's the pythonic thing to do here?  How can I
> guarantee timely response to the creation of a file in the directory
> referenced by fd?

Use asynchronous calls and/or a separate thread.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PEP 328, absolute/relative import

2005-08-10 Thread Christopher Subich
Ben Finney wrote:
> Once PEP 328 is fully implemented, all bare 'import foo' statements
> specify absolute imports (i.e. from sys.path only). To perform a
> relative import (e.g. from current directory) will require different
> syntax.

I'm not completely familiar with either, but how will that influence the 
__import__ function?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: wxPython and threads again

2005-08-10 Thread Christopher Subich
David E. Konerding DSD staff wrote:
> The easiest approach, though, is to use the threadedselectreactor in Twisted 
> (you need
> to check the HEAD branch out with subversion, because that reactor isn't 
> included in any releases).
> With threadedselectreactor, it's easy to incorporate both the GUI event loop 
> and the twisted reactor.
> Twisted already includes lots of code for doing asynchronous callback-style 
> IO for
> IO bound processes like downloading.  Further, you don't even think in an 
> explicitly threaded way-
> createing a whole thread just to manage a download process which is motly IO 
> and a little bookkeeping is
> silly.  Twisted's approach just makes a lot more sense and simplifies the 
> code too.

Or, don't use threadedselectreactor, but instead just use normal 
threading and reactor.callFromThread.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: FTP over SSL (explicit encryption)

2005-08-10 Thread Andrew MacIntyre
David Isaac wrote:
> I am looking for a pure Python secure ftp solution.
> Does it exist?

I recall coming across an extension package (pretty sure it wasn't pure
Python anyway, certainly not for the SSL bits) with SFTP - I think the
name was Paramiko or something like that.

-
Andrew I MacIntyre "These thoughts are mine alone..."
E-mail: [EMAIL PROTECTED]  (pref) | Snail: PO Box 370
[EMAIL PROTECTED] (alt) |Belconnen ACT 2616
Web:http://www.andymac.org/   |Australia
-- 
http://mail.python.org/mailman/listinfo/python-list


PEP 328, absolute/relative import (was: Re: Bizarre error from help())

2005-08-10 Thread Ben Finney
Peter Hansen <[EMAIL PROTECTED]> wrote:
> Ben Finney wrote:
> > Roy Smith <[EMAIL PROTECTED]> wrote:
> >>[current-directory module shadowing a system module]
> > 
> > All hail the coming of PEP 328:
> > http://www.python.org/peps/pep-0328.html>
> 
> Which, unless I misunderstand, would do nothing to change the
> behaviour of the OP's situation unless the mistakingly named
> "string.py" module was actually inside a package.  If it was just in
> the current directory at the time, I don't think the PEP328 would
> have affected the situation.

Once PEP 328 is fully implemented, all bare 'import foo' statements
specify absolute imports (i.e. from sys.path only). To perform a
relative import (e.g. from current directory) will require different
syntax.

"[...] relative imports will use leading dots. A single leading
dot indicates a relative import, starting with the current
package. Two or more leading dots give a relative import to the
parent(s) of the current package [...]"

http://www.python.org/peps/pep-0328.html#guido-s-decision>

So, under PEP 328 rules, the original poster's current-directory
module could only be imported (a) if the current directory was in
sys.path, or (b) if the code specified a relative import. The
accidental shadowing of the stdlib module could not happen.

-- 
 \ "You know what would make a good story? Something about a clown |
  `\who makes people happy, but inside he's real sad. Also, he has |
_o__)severe diarrhea."  -- Jack Handey |
Ben Finney 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: "Compile time" checking?

2005-08-10 Thread phil hunt
On 10 Aug 2005 12:01:01 -0700, Qopit <[EMAIL PROTECTED]> wrote:
>> Why not just find out, by trying to compile it? :-)
>
>This will likely certify me as a python newbie, but... how do you mean?
> How do you compile a .py file?

At the command prompt:

$ python yourfile.py

This compiles it, then runs it.

>If you mean to .pyc by doing an import on it,

Indeed so.

> that may work fine for
>the simple example I typed up earlier, but that is easy to bypass by
>slapping the offending line in a function.  The sample below also
>passes PyChecker with not even a warning:
>
>#
>def tester(a,b,c):
>  print "bogus test function",a,b,c
>
>def try1():
>  tester(1,2,3)
>def try2():
>  tester(1,2)#still no error here
>#
>
>Do you mean something different?

I've never used PyChecker myself, so can't comment on it.

I've not personally had problems with the wrong number of argumnets 
to a function call -- they get caught at run-time and are easy 
enough to fix -- but I do sometimes get errors because a varialbe is 
the wrong time, e.g. a string when it should be an int.

One problem I once encountered was wit this and I waasn't picking it 
up because my debugging code looked like this:

   if debug: print "v=%s" % (v,)

Which of course prints the same output whether v is '2' or 2.

For this reason I tend to debug print statements like this now:

   if debug: print "v=%s" % (v,)


-- 
Email: zen19725 at zen dot co dot uk


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


Creating Palm OS programs with python?

2005-08-10 Thread djanvk
QUick question:

Is it possible to create a palm os program to use on a PDA with
python?


THanks

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


Re: wxPython and threads again

2005-08-10 Thread Bryan Olson
Peter Hansen wrote:
 > David E. Konerding DSD staff wrote:
 >> Further, calling wx from a thread other than the one running the
 >> event loop is deep voodoo and should typically be avoided.
 >
 > "Typically"?  Let's just say "always" and maybe use the phrase "certain
 > to corrupt wx and crash the app" instead of "deep voodoo". :-)  At least
 > that way the OP won't waste time experimenting...

Come to think of it, wouldn't it be a good idea for a GUI
toolkit to to do something like:

 import thread

 # ...

 def WhateverToolKitInitFunction(*args):
 global _thread_of_record
 _thread_of_record = thread.get_ident()
 # ...


 def check_thread():
 if thread.get_ident() != _thread_of_record:
 raise RuntimeError('Attempt to update GUI from foreign 
thread.')


And then begin each non-thread-safe function like:


 def SomeUpdateFunction(*args):
 check_thread()
 # ...


[...]
 > Even simpler for some purposes is wx.CallAfter(),

Ah, Nice. Same method under the hood, but hides the complexity.


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


Re: Recommendations for CVS systems

2005-08-10 Thread François Pinard
[Aahz]

> For anything mission-critical, I wouldn't want to rely on a free license.

For anything mission-critical, I wouldn't want to rely on closed sources...

Could the best be open source and non-free license? :-)

-- 
François Pinard   http://pinard.progiciels-bpi.ca
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: interpreter frame

2005-08-10 Thread Bengt Richter
On 10 Aug 2005 15:08:21 -0700, "Leo" <[EMAIL PROTECTED]> wrote:

>Good try, but that doesn't seem to work either. Maybe I should have
>emphasized that what I really want is the line of code, as opposed to
>the entire frame. Here is the output of sys._getframe() on my system:
>
>Python 2.3.4 (#1, Feb  2 2005, 12:11:53)
>[GCC 3.4.2 20041017 (Red Hat 3.4.2-6.fc3)] on linux2
>Type "help", "copyright", "credits" or "license" for more information.
 import sys
 sys._getframe()
>
 from inspect import *
 getframeinfo(sys._getframe())
>('', 1, '?', None, None)
>
>Is it different in 2.4? Maybe there is something else in sys.* that I
>am having trouble finding?
>
Isn't there some requirement of having a source file in order to get
the line of code, which an interactive session does not satisfy?
(Maybe a strategically located StringIO instance encapsulating the latest
interactive chunk as "source file" could solve it?)

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


Re: Recommendations for CVS systems

2005-08-10 Thread Terry Reedy

"Aahz" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> In article <[EMAIL PROTECTED]>,
> Terry Reedy <[EMAIL PROTECTED]> wrote:
>>For what it is worth, the Python developers are discussing moving the
>>Python codebase to subversion, though other options were discussed.  The
>>result so far is PE 347  Migrating the Python CVS to Subversion.
>
> While you're technically correct, at this point it's closer to "planning
> the move to Subversion".

No, I was exactly correct as to what I stated.  The difference between 
'discussing' and 'planning' is pretty small and the fact that some might be 
'planning' does not negate 'discussing'.  In fact, alternatives were still 
being discussed as of earlier today, with Guido sharing his experience with 
Perforce.

Terry J. Reedy



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


signals (again)

2005-08-10 Thread bill
I see this (or similar) question occasionally looking back through the
archive, but haven't yet seen a definitive answer, so I'm going to ask
it again.

Consider the following:

while True:
do_something_to_files_in_directory(fd)
fcntl(fd, F_NOTFIY, DN_CREATE)
signal.pause()


How do you deal with the signal that occurs after the fcntl and before
the pause?  The solution to sleep instead of pause is aesthetically
ugly and doesn't really help.  I've thought about examining the stack
trace in the signal handler for SIGIO and responding appropriately, but
that's pretty ugly too.  I saw some mention of implementing a try:
construct that would delay receipt of the signal for one atomic python
instruction, and that seemed like a good idea, but I didn't see much
follow up on that.  What's the pythonic thing to do here?  How can I
guarantee timely response to the creation of a file in the directory
referenced by fd?

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


Re: interpreter frame

2005-08-10 Thread Leo
Good try, but that doesn't seem to work either. Maybe I should have
emphasized that what I really want is the line of code, as opposed to
the entire frame. Here is the output of sys._getframe() on my system:

Python 2.3.4 (#1, Feb  2 2005, 12:11:53)
[GCC 3.4.2 20041017 (Red Hat 3.4.2-6.fc3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys._getframe()

>>> from inspect import *
>>> getframeinfo(sys._getframe())
('', 1, '?', None, None)

Is it different in 2.4? Maybe there is something else in sys.* that I
am having trouble finding?

TIA,
Leo.

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


Re: wxPython and threads again

2005-08-10 Thread perchef
thanks for all these advices.
I think a custom event will be the way to go.
for the moment I use something _really_ ugly : a mix between GUI,
threads and recursive fonctions.

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


Python-based system wins 2005 Australian Eureka Science Prize

2005-08-10 Thread Tim Churches
See
http://www.amonline.net.au/eureka/communications_technology/2005_winner.htm

A Google search on "scamseek python" reveals the nexus with Python - see
for example
http://www.cs.usyd.edu.au/~lkmrl/Scamseek-Project-data-mining-conf-v0.pdf

Congratulations to Prof Jon Patrick and team on their win, and for
choosing Python!

Tim C


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


Re: "Compile time" checking?

2005-08-10 Thread Qopit
> if __name__ == '__main__':

Yep - that does it... should have thought of that.  Thanks.

This works fine for pychecker with no hangage:
#---
if __name__ == "__main__":
  while 1:
x = raw_input("meh:")
#---

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


Re: "Compile time" checking?

2005-08-10 Thread Qopit
>  def tester(a, b, c):
>  global tester
>  print "bogus test function", a, b, c
>  def tester(a, b):
>  print "other test function", a, b
>
>  tester(1, 2, 3) # This runs fine.
>  tester(1, 2)# This too.

Interesting example.  In that case, pychecker does spit out a warning
since it has trouble deciphering the redefinition.  I have no problem
whatsoever with a compiler/code-checker getting confused in such an
oddball situation.  As you say, it is difficult for an automated
process to follow such flows.  A warning is fine here (as I got with
the "proper" pychecker on my initial example - it did easily catch what
I thought should have been, and was, obvious).

With your example, I was curious how pychecker would deal with it if
you altered the flow a bit so that all calls would/should make sense in
what seems to me to be logical locals order, and tried this:

#---
def tester(a, b, c):
global tester
print "bogus test function", a, b, c
def tester(a, b):
  print "other test function", a, b
tester(1, 2) #no pychecker complaint since local
tester(1, 2, 3) # pychecker complains here (?)
#---

I'm a bit confused why pychecker complained where it did - I don't get
how it got the 2 arg version at that point, but I actually don't really
care that much due to the weirdness level of this code.  A compiler (or
code-checker) warning on this code is perfectly acceptable to me.  I'm
a big fan of Python's ability to easily rebind everything in sight, but
this particular usage seems like a strange abuse I wouldn't expect a
code-checker to be able to figure out.  I'll just avoid writing
confusing code like that... it's not only confusing to a program, but
to a human as well!  Dynamically massacring a function definition (as
opposed to just rebinding a new implementation) like that seems odd to
me.

> Compile it by running it and write unit tests.

... sure, that works,  I'm just used to the integrated tools I've had
available to me for the last 15 years to help me write more robust code
wy faster than having to unit test a zillion blocks of code when
you change a single definition somewhere.

PyChecker seems like it may fit the bill right now... just need to try
it some more and figure out how to get around that weird raw_input
thing.  The basis for my first post was a jerk what-the-heck reaction
to the fact that it seemed that pychecker didn't get the simple arg
count mismatch error, but jk showed that that was wrong and I just have
to sort out something with SPE.

Cheers,
Russ

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


Re: providing arguments to base.__init__

2005-08-10 Thread Daniel Schüle
Rob Conner schrieb:
> seems like you are not running the correct wavePlayer. make sure you
> don't have 2 wavePlayer vars.
> 

I am not sure I understand right
wavePlayer.py is a module I wrote myself and placed
to site-packages so there is no other wavePlayer module
I put a class wavePlayer into it and after

import wavePlayer
p = wavePlayer.wavePlayer()

I got this error

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


Re: Python supports LSP, does it?

2005-08-10 Thread Andy Leszczynski
Mike Meyer wrote:
[...]
> The wikipedia was really abusing the phrase LSP. I've corrected the
> wikipedia.
>  http://mail.python.org/mailman/listinfo/python-list


Re: providing arguments to base.__init__

2005-08-10 Thread Rob Conner
seems like you are not running the correct wavePlayer. make sure you
don't have 2 wavePlayer vars.

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


Re: providing arguments to base.__init__

2005-08-10 Thread [EMAIL PROTECTED]
I only have an answer to the last one: you do not call the
'destructors'  of the base classes, so they are not executed.

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


Re: Point and click GUI builder for Python

2005-08-10 Thread McBooCzech
Don't forget Eric3 + PyQt + Qt designer? I think they are great tools.

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


Re: FTP over SSL (explicit encryption)

2005-08-10 Thread David Isaac

"Eric Nieuwland" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Do you want SFTP or FTP/S?

The latter.

> I'm having a look at FTP/S right now. That's a little
> more complicated, but it seems doable.
> If I succeed, I guess I'll donate the stuff as an extension to ftplib.

Great!
Please post a link as soon as it is usable!

Thanks,
Alan Isaac


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


Re: "Compile time" checking?

2005-08-10 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Qopit wrote:

> Now I'm running into another snag when checking some other code I have.
>  Pychecker gets hung up on raw_input... it actually executes code
> rather than just checking it, it seems.  For example, the snippet below
> hangs pychecker::
> 
> #---
> while 1:
>   x = raw_input("meh:")
> #---
> 
> Curious.

AFAIK `pylint` tries to avoid running the code.

A common idiom to protect code from being executed, if the module is just
imported opposed to executed as main module, is to write::

  def foo():
  # some code

  if __name__ == '__main__':
  foo()

`__name__` is set to the module name if the module will be imported but to
'__main__' if the module is directly executed.

Ciao,
Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: "Ordered" dicts

2005-08-10 Thread Delaney, Timothy (Tim)
Martin Miller wrote:

> To avoid continued reinvention of this wheel, I'd also vote to have
> this functionality be at least included in a standard module, if not
> built-in.

This has been discussed on python-dev (I proposed it actually). The
final consensus was that no such implementation would be included at
this time, as it's a pretty simple thing to implement, and there are
already several implementations in the Cookbook.

My arguments included the fact that there were several implementations
in the Cookbook as an indication it should be included in the standard
library ...

Thread starts here:
http://mail.python.org/pipermail/python-dev/2005-March/051915.html

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


Re: What is Python?!

2005-08-10 Thread Jason Drew
Roy Smith wrote: "there's a system called Jython, which lets you
compile Java source to Python byte code."

Don't you have that the wrong way 'round? From the Jython website:
"Jython is an implementation of the high-level, dynamic,
object-oriented language Python written in 100% Pure Java, and
seamlessly integrated with the Java platform. It thus allows you to run
Python on any Java platform."

In the case of Jython you could perhaps say that Python bytecode is
"exactly like Java". However, in the case of regular Python, it's
closer to say that Python bytecode is much the same _idea_ as Java
bytecode.

Jason

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


providing arguments to base.__init__

2005-08-10 Thread Daniel Schüle
Hello Ng,

I was playing around with pymedia module
and I succeeded when I used complementation
instead of inheritance .. but then I was
forced to wrap simple methods of sound.Output
like pause/unpause/stop. It works, but
seems to me unnecessary .. and I would like
to grasp why the code below doesn't work

***
import threading, wave, sys,
import pymedia.audio.sound as sound, tkFileDialog

class wavePlayer(threading.Thread, sound.Output):
  def __init__(self, filename = None):
   if filename == None:
filename = tkFileDialog.askopenfilename()
   try:
self.wav = wave.open(filename)
   except:
print "something went wrong"
sys.exit(1)
   freq, nchannels, format = self.wav.getframerate(),
self.wav.getnchannels(), sound.AFMT_S16_LE
   sound.Output.__init__(self, freq, nchannels, format)
   threading.Thread.__init__(self)
***


 >>>p = wavePlayer.wavePlayer()
Traceback (most recent call last):
   File "", line 1, in ?
TypeError: Output() takes at least 3 arguments (0 given)


can somebody explain why this happens?
I tried to construct more simple example
but there it works fine, here is it

 >>> class base1:
... def __init__(self):
... self.x = []
... print "base1"
... def __del__(self):
... print "~base1"
...
 >>> class base2:
... def __init__(self, a, b):
... self.x = a * b
... print "base2"
... def __del__(self):
... print "~base2"
...
 >>> class derived(base1, base2):
... def __init__(self):
... print "derived"
... base1.__init__(self)
... base2.__init__(self, 5, 7)
... def __del__(self):
... print "~derived"
...
 >>> d = derived()
derived
base1
base2
 >>> dir(d)
['__del__', '__doc__', '__init__', '__module__', 'x']
 >>> d.x
35
 >>>
 >>> del d
~derived
 >>>
 >>>

base2.__init__ is called in the same way
sound.Output.__init__ is called
both get multiple arguments

one more curiosity, why doesn't del d, call destructors
of base classes?

Thanks for you answears

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


Re: "Compile time" checking?

2005-08-10 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Qopit wrote:

> Hi there,
> 
> I'm pretty new to Python and am trying to figure out how to get "will
> this code compile?"-like code checking.  To me this is a pretty basic
> language/environment requirement, especially when working with large
> projects.  It is *much* better to catch errors at "compile-time" rather
> than at run-time.

Might sound harsh, but then python ist the wrong language for you.

> One thing I've "found" is the PyChecker module (conveniently embedded
> in SPE), but it doesn't seem to do that great of a job.  For example,
> the following simple program checks out perfectly as far as PyChecker
> is concerned:
> 
> #
> def tester(a,b,c):
>   print "bogus test function",a,b,c
> tester(1,2,3)  #this runs fine
> tester(1,2)#this obviously causes a run-time TypeError exception
> #
> 
> It seems to me that this should be an obvious catch for PyChecker.

It's just obviuos because you know that the first call to `tester()`
doesn't change the name binding for `tester` to a callable object that
also accepts just two parameters.  You, as a human, can see easily the
error here, but a program has to follow all possible control flows to be
sure about that.  And that's most of the time very complex and sometimes
impossible.  It's not enough to look just at the signature of the function.

Simple (?) test::

  def tester(a, b, c):
  global tester
  print "bogus test function", a, b, c
  def tester(a, b):
  print "other test function", a, b

  tester(1, 2, 3) # This runs fine.
  tester(1, 2)# This too.

> Any other comments appreciated (aside from things like "just right good
> code that doesn't have bugs like that" :) ).

Compile it by running it and write unit tests.

Ciao,
Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help with Regular Expressions

2005-08-10 Thread Paul McGuire
The pyparsing distribution includes epydoc-generated class
documentation, and a few example programs.  Dave Kuhlman has a nice
HOWTO at
http://www.rexx.com/~dkuhlman/python_201/python_201.html#SECTION00760

Drop me a note if you are looking for some specific tips or techniques.
 (I'm working on an article on using pyparsing as an adventure game
command processor.)

-- Paul

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


Re: help in algorithm

2005-08-10 Thread gene tani
this sounds like LSI / singular value decomposition (?)

http://javelina.cet.middlebury.edu/lsa/out/lsa_explanation.htm

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


Re: "Compile time" checking?

2005-08-10 Thread Qopit
How embarassing... thanks, jk.  I grabbed a copy of pychecker v0.8.14
directly (not the one in SPE) and it catches it exactly as you showed.
Now I wonder why the SPE one doesn't catch it (and why it is sooo
comparatively slow)!

Now I'm running into another snag when checking some other code I have.
 Pychecker gets hung up on raw_input... it actually executes code
rather than just checking it, it seems.  For example, the snippet below
hangs pychecker::

#---
while 1:
  x = raw_input("meh:")
#---

Curious.

I'm going to look into some of the code checking capabilities (if
present) of Komodo and Wing.  Anyone familiar enough with their ability
to comment?

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


Re: Why does __init__ not get called?

2005-08-10 Thread Rob Conner
I'm out of my league too. I don't know enough about __new__ and
__init__.
I just went another route and did a wrapper for datetime, and didn't
extend it.
Thanks for the effort.

By chance... does anyone know, if I wrote a class, and just wanted to
override __new__ just for the fun of it. What would __new__ look like
so that it behaves exactly the same as it does any other time.

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


Re: interpreter frame

2005-08-10 Thread Peter Hansen
Leo wrote:
> Why is it not possible to get the frame from the interpreter using the
> inspect library? 

Because sys._getframe() does the job instead?

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


Re: wxPython and threads again

2005-08-10 Thread Peter Hansen
David E. Konerding DSD staff wrote:
> Further, calling wx from a thread other than the one running the event 
 > loop is deep voodoo and should typically be avoided.

"Typically"?  Let's just say "always" and maybe use the phrase "certain 
to corrupt wx and crash the app" instead of "deep voodoo". :-)  At least 
that way the OP won't waste time experimenting...

> You need another way to pass completion information between the downloader
> thread and the main thread; the simplest way is to define a custom wx
> Event, and wxPostEvent from the downloader thread when it completes (
> and when the gauge should be updated).  wxPostEvent is safe to call from 
> non-eventloop threads.
> The main thread's wx event loop just spins, properly updating all other
> parts of the GUI, and receiving events from the downloader thread.

Even simpler for some purposes is wx.CallAfter(), which provides the 
asynchronous performance of wxPostEvent with the "beautifully general" 
approach of passing callables through a Queue which Bryan Olson 
described in his post.  (That is, you don't need to do polling with a 
non-blocking get() on the Queue this way.)

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


Re: Recommendations for CVS systems

2005-08-10 Thread Erik Max Francis
Aahz wrote:

> For anything mission-critical, I wouldn't want to rely on a free license.

If it's mission critical, in the worst case scenario you can just pay 
for a modest license.  And, as I said, it's free for use for personal 
use -- no license is required, it just works.  They can't force 
upgrades, so even if they changed that policy in the future, they can't 
take that away from you.

-- 
Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
   A father is a thousand schoolmasters.
   -- Louis Nizer
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: "Ordered" dicts

2005-08-10 Thread gene tani
More ways to do it, from the FAQ

http://www.python.org/doc/faq/programming.html#how-can-i-get-a-dictionary-to-display-its-keys-in-a-consistent-order

Also look at the recipe, page 222 of Cookbook2, that allows you to rank
key values by their associated values, and demonstrate the power of
mixins.

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


Re: What is Python?!

2005-08-10 Thread bruno modulix
Roy Smith wrote:
> Robert Wierschke <[EMAIL PROTECTED]> wrote:
> 
>>  a scripting language or a "normal" language like C++ etc.
> 
> 
> It is difficult to define exactly what a "scripting language" is and isn't, 

You can tell buy the most common use. bash is a scripting language,
javascript is a scripting language, perl is a scripting language, php is
a scripting language, Python is *not* a scripting language !-)

> but I think most people would classify it as a scripting language.

It can be used for scripting too, yes.


-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '[EMAIL PROTECTED]'.split('@')])"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Catching stderr output from graphical apps

2005-08-10 Thread Bryan Olson
gry@ll.mit.edu wrote:
 > Python 2.3.3, Tkinter.__version__'$Revision: 1.177 $'
 >
 > Hmm, the error window pops up with appropriate title, but contains no
 > text.
 > I stuck an unbuffered write to a log file in ErrorPipe.write and got
 > only one line: Traceback (most recent call last):$
 >
 > Any idea what's wrong?

Darn. Are you on Windoze/Mac/Unix/, and what version?

If you can spare the time, could you please try:


 import errorwindow
 import sys

 sys.stderr.write("Hello\nWorld.\n")

 x = 7 + nosuchvariable


and tell me what happens?

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


Python-2.4.1 Build error on AIX

2005-08-10 Thread Srinivasan TK
All,
I get the below error when trying to build python on
AIX.

Is there a way to ignore _tkinter.

Please help

Sri

I do the following in my command line.

export CC=gcc 

ld: 0706-006 Cannot find or open library file: -l
tk8.3
ld:open(): A file or directory in the path
name does not exist.
ld: 0706-006 Cannot find or open library file: -l
tcl8.3
ld:open(): A file or directory in the path
name does not exist.
*** WARNING: renaming "_tkinter" since importing it
failed: No such file or directory
error: No such file or directory
make: *** [sharedmods] Error 1






Start your day with Yahoo! - make it your home page 
http://www.yahoo.com/r/hs 
 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: "Compile time" checking?

2005-08-10 Thread Qopit
> Why not just find out, by trying to compile it? :-)

This will likely certify me as a python newbie, but... how do you mean?
 How do you compile a .py file?

If you mean to .pyc by doing an import on it, that may work fine for
the simple example I typed up earlier, but that is easy to bypass by
slapping the offending line in a function.  The sample below also
passes PyChecker with not even a warning:

#
def tester(a,b,c):
  print "bogus test function",a,b,c

def try1():
  tester(1,2,3)
def try2():
  tester(1,2)#still no error here
#

Do you mean something different?

Also - thanks for the pylint comment... haven't tried it yet.  It would
be nice to have the capability in an IDE like SPE, though.

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


Re: Putting function references in a Queue

2005-08-10 Thread Richard Townsend
On Tue, 09 Aug 2005 23:46:22 GMT, Bryan Olson wrote:

> I think that's a good thing to do. The tricky part is getting an
> event loop to wait on both the queue and other kinds of events.
> Periodic polling works, but kind of sucks.
> 
> What's the 'done' argument? A lock maybe?

'done' is just a boolean for the child thread to indicate it has finished.
The main thread keeps a dictionary of references to the child threads so
the app can send then 'abort' messages via their input Queues. When a child
thread sets 'done' to True, the main thread deletes its reference from the
dictionary.

Periodic polling triggered by a timer in the X-app main loop was the only
way I could think of checking for feedback from the child threads, not very
neat though...

Thanks to everyone for their input!

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


Re: Help with Regular Expressions

2005-08-10 Thread Christopher Subich
Paul McGuire wrote:
> If your re demands get more complicated, you could take a look at
> pyparsing.  The code is a bit more verbose, but many find it easier to
> compose their expressions using pyparsing's classes, such as Literal,
> OneOrMore, Optional, etc., plus a number of built-in helper functions
> and expressions, including delimitedList, quotedString, and
> cStyleComment.  Pyparsing is intended for writing recursive-descent
> parsers, but can also be used (and is best learned) with simple
> applications such as this one.

As a slightly unrelated pyparsing question, is there a good set of API 
documentation around for pyparsing?

I've looked into it for my mud client, but for now have gone with 
DParser because I need (desire) custom token generation sometimes. 
Pyparsing looks easier to internationalize, though.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: wxPython and threads again

2005-08-10 Thread Bryan Olson
David E. Konerding DSD staff wrote:
[...]
 > You need another way to pass completion information between the 
downloader
 > thread and the main thread; the simplest way is to define a custom wx
 > Event, and wxPostEvent from the downloader thread when it completes (
 > and when the gauge should be updated).  wxPostEvent is safe to call 
from non-eventloop threads.
 > The main thread's wx event loop just spins, properly updating all other
 > parts of the GUI, and receiving events from the downloader thread.
 >
 > ANother approach is to have a thread-safe Queue and have the main 
thread/event loop
 > poll the queue with queue.get_nowait() periodically (typically 0.1-1 
sec).
 > The downloader thread shares the queue object and puts data 
structures (typically
 > class instances, strings, or ints) that indicate status updates.

The way-cool things to transmit, in either the queue or the
event data, are tuples of:

 (func, args, kwargs)

The so-called-'main' thread gets these, and blindly calls
func(*args, **kwargs). Since only the main thread can safely
update the GUI, other threads pass GUI-updating functions to be
called by the main thread.

The technique is beautifully general. The worker thread does
it's long, blocking operations independently, and when it needs
to update the GUI it sends the main thread a quick, non-blocking
function.

In wxPython, custom events can carry arbitrary data, so the easy
thing to do is just pass the (func, args, kwargs) across with
wxPostEvent (or so I've read; I'm not a wxPython user).

TkInter has no equivalent to wxPostEvent. Contrary to popular
belief, TkInter's event_generate is not thread-safe. The usual
TkInter solution is a queue, which the main thread periodically
polls via the 'after' function.


 > The easiest approach, though, is to use the threadedselectreactor in 
Twisted (you need
 > to check the HEAD branch out with subversion, because that reactor 
isn't included in any releases).
 > With threadedselectreactor, it's easy to incorporate both the GUI 
event loop and the twisted reactor.
 > Twisted already includes lots of code for doing asynchronous 
callback-style IO for
 > IO bound processes like downloading.  Further, you don't even think 
in an explicitly threaded way-
 > createing a whole thread just to manage a download process which is 
motly IO and a little bookkeeping is
 > silly.  Twisted's approach just makes a lot more sense and simplifies 
the code too.

I couldn't disagree more about that being easier and simplifying
the code. "Creating a whole thread" is trivial.


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


Re: FTP over SSL (explicit encryption)

2005-08-10 Thread Eric Nieuwland
David Isaac wrote:
> I am looking for a pure Python secure ftp solution.
> Does it exist?
Do you want SFTP or FTP/S?

> I would have thought that the existence of OpenSSL
> would imply "yes" but I cannot find anything.
>
> ftplib does not seem to provide any secure services.
Indeed. If you want SFTP, just make a copy of ftplib and modify so it 
will use an SSL socket instead of a normal socket. After that, only 
some minor point may remain.

> [...]I know about M2Crypto
> http://sandbox.rulemaker.net/ngps/m2/
> but that requires installing SWIG and OpenSSL.
> (If someone tells me they have found this trivial
> under Windows, I am willing to try ... )
I guess SFTP should work on Windows as well.

> I would have thought that this was a common need with
> a standard Python solution, so I suspect I'm overlooking
> something obvious.
AFAIK you're not. I'm having a look at FTP/S right now. That's a little 
more complicated, but it seems doable.
If I succeed, I guess I'll donate the stuff as an extension to ftplib.

--eric

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


Re: Syntax error after upgrading to Python 2.4

2005-08-10 Thread Walter Dörwald
[EMAIL PROTECTED] wrote:

> Hi,
> 
> After upgrading to 2.4 (from 2.3), I'm getting a weird syntax error:
> 
> 
import themes
> 
> Traceback (most recent call last):
>   File "", line 1, in ?
>   File "themes.py", line 564
> font = self.font.makeBlackAndWhite(),
>   additive = self.additive,
>  ^
> SyntaxError: invalid syntax
> 
> The relevant code is:
> 
> def makeBlackAndWhite( self ):
> 
> return CharStyle( names = self.names,
>   basedOn = self.basedOn.makeBlackAndWhite(),
>   font = self.font.makeBlackAndWhite(),
>   additive = self.additive,
>   prefixText = self.prefixText )
> 
> This is a method in the CharStyle class which returns a new modified
> instance of CharStyle.
> 
> I'm using Windows XP and Python 2.4.1
> 
> Any ideas? O:-)

This is probably related to http://www.python.org/sf/1163244. Do you 
have a PEP 263 encoding declaration in your file? Can you try 
Lib/codecs.py from current CVS?

Bye,
Walter Dörwald
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: "Compile time" checking?

2005-08-10 Thread en.karpachov
On 10 Aug 2005 08:53:15 -0700
Qopit wrote:

> def tester(a,b,c):
>   print "bogus test function",a,b,c
> tester(1,2,3)  #this runs fine
> tester(1,2)#this obviously causes a run-time TypeError exception

/tmp% cat >a.py
def tester(a,b,c):
  print "bogus test function",a,b,c
tester(1,2,3)  #this runs fine
tester(1,2)#this obviously causes a run-time TypeError exception
/tmp% pychecker a.py
Processing a...
bogus test function 1 2 3
  Caught exception importing module a:
File "/usr/lib/site-python/pychecker/checker.py", line 587, in 
setupMainCode()
  module = imp.load_module(self.moduleName, file, filename, smt)
File "a.py", line 4
  tester(1,2)#this obviously causes a run-time TypeError exception
  TypeError: tester() takes exactly 3 arguments (2 given)

Warnings...

a:1: NOT PROCESSED UNABLE TO IMPORT
/tmp% pychecker -V
0.8.14

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


Re: Catching stderr output from graphical apps

2005-08-10 Thread gry
Python 2.3.3, Tkinter.__version__'$Revision: 1.177 $'

Hmm, the error window pops up with appropriate title, but contains no
text.
I stuck an unbuffered write to a log file in ErrorPipe.write and got
only one line: Traceback (most recent call last):$

Any idea what's wrong?

-- George

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


Re: Does any one recognize this binary data storage format

2005-08-10 Thread Christopher Subich
Calvin Spealman wrote:
> 
> Original Poster should send this off to thedailywtf.com

I absolutely agree.  This is a terrible programming practice.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What are modules really for?

2005-08-10 Thread en.karpachov
On Wed, 10 Aug 2005 09:36:13 +0100
N.Davis wrote:

> As for multiple inheritance, yes I've always been aware of it being 
> available in C++, but I learned C++ at a company which banned multiple 
> inheritance in their coding standards, with comments about "The GOTO of 
> the 1990s".

Looks like something religious. It seems they was completely ignorant about
what the multiple inheritance is and what is it for.

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


Re: Help with Regular Expressions

2005-08-10 Thread Cappy2112
Be careful with that book though, it's RE examples are Perl-centric and
not exactly the same implementation that Python uses. However, it's a
good place to start

This will also be useful
http://www.amk.ca/python/howto/regex/

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


Re: What are modules really for?

2005-08-10 Thread bruno modulix
Tito wrote:
>> [1]  'aName' => public, '_aName' => protected, '__aName' => private
> 
> 
> I didn't know this one, as I am quite new to Python. Is it really
> general use?

Yes, it's the convention.

Well, to be more exact, this is:

name => interface (intended for public use)
_name => implementation (not intented for public use)
__name => mangled (should not be hidden or overriden) [1]
__name__ => magic (has special meaning for the Python interpreter) [2]

BTW, from module import * tends to only import 'public' symbols, so you
can use _name to prevent _name being imported by accident.

[1] The purpose here is not to enforce privacy, but to protect the
symbolf from being accidentaly overriden or hidden.
given:
class Foo(object):
  def __init__(self, name):
self.__name = name
f = Foo('foo')

You'll have to use :
f._Foo__name

to access foo.__name from outside the class (this hold for derived
classes too).


[2] __name__ attributes (variables and functions) usually have special
behaviours attached to them. For exemple,
- obj.__init__(self, ...) is called on object initialisation
- seq.__len__() is called by len(seq),
- obj.__str__() is called by str(obj)
- obj.__add__ is the '+' operator  called by obj1 + obj2 ->
obj1.__add__(self, obj2),
- obj.__getattr__(self, name) is called when you lookup an inexistant
attribute of obj, etc...

You'll find all this (and much more) in the doc.

HTH
-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '[EMAIL PROTECTED]'.split('@')])"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: MainThread blocks all others

2005-08-10 Thread Nodir Gulyamov
Hello Dennis and Bryan!
You were absolutely right. I should show you real code instead of brain 
fucking. I am very sorry.
Please find below real code. Sorry for amount of sources.
Main aspect of program is all process should be in one determined sequence 
containing 3 stages. They are defined as stage1(), stage2() and stage3() in 
appMainFrame()
Execution started when Start button presses (handler def OnStart() in 
appMainFrame() ). At the same time CardsObserver calls 
appMainFrame.addCards() to increment counter and in each stages wait this 
counter.
All other code from library.

Kind regards,
/Gelios

###Main application:

#exception class
class NotASIMCardException:
def __init__( self, message ):
self.message = message
def __str__(self):
return repr( self.message )


class SmartCardOperations:

def getATR( self, readerDescr ):
atr=""
self.attachedReaders = readers()
for reader in self.attachedReaders:
if readerDescr == str( reader ):
connection=reader.createConnection()
try:
connection.connect()
atr=toHexString( connection.getATR() )
connection.disconnect()
except NoCardException:
atr="no card inserted"
return atr

def decodeICCID( self, iccidBytes ):
resIccid = []

#swap bytes
i = 0
while i < len(iccidBytes):
strTmp = str( hex( iccidBytes[i] ) )
if len(strTmp) == 3:
strTmp = strTmp[0] + strTmp[1] + "0" + strTmp[2]
resIccid += [strTmp[3] + strTmp[2]]
i += 1

#remove last 2 bytes
resIccid = resIccid[:-2]
#remove first last digit
strTmp = str( resIccid[i-3] )
if len(strTmp) == 1:
strTmp += "0"
resIccid[i-3] = strTmp[0]

return resIccid

def getICCID(self, readerDescr):
self.attachedReaders = readers()
for reader in self.attachedReaders:
if readerDescr == str( reader ):
session = smartcard.Session( reader )
try:
data, sw1, sw2 = session.sendCommandAPDU( SELECT + 
DF_ROOT )
data, sw1, sw2 = session.sendCommandAPDU( SELECT + 
EF_ICCID )
data, sw1, sw2 = session.sendCommandAPDU( READ_BINARY + 
[0x0A])
if sw1 == 0x90 or sw1 == 0x91:
msg = "Ok"
else:
msg = "ICCID read error. Error code: " + 
str(hex(sw1)) + str(hex(sw2))
session.close()
except NoCardException:
msg = "ICCID read error. Error code: " + str(hex(sw1)) + 
str(hex(sw2))

return msg, self.decodeICCID(data), data

def getADM0( self, readerDescr, iccid ):
self.attachedReaders = readers()
for reader in self.attachedReaders:
if readerDescr == str( reader ):
session = smartcard.Session( reader )
try:
data, sw1, sw2 = session.sendCommandAPDU( SAM_SEND_ICCID 
+ iccid )
resBytesStr = str(sw1) + ' ' + str(sw2)
if resBytesStr != "61 08":
msg = "?? ?? ? SAM ??"
return msg, None
data, sw1, sw2 = session. sendCommandAPDU( 
SAM_GET_ADM0 )
except NoCardException:
msg = "ADM0 getting error. Error code: " + str(hex(sw1)) 
+ str(hex(sw2))
msg = "Ok"
return msg, data

def chgEfLnd( self, iccid, adm0 ):
self.attachedReaders = readers()
for reader in self.attachedReaders:
if readerDescr == str( reader ):
session = smartcard.Session( reader )
try:
data, sw1, sw2 = session.sendCommandAPDU( 
VERIFY_KEY_SIMERA3 + adm0 )
resBytesStr = str(sw1) + ' ' + str(sw2)
if resBytesStr == "98 04" or resBytesStr == "98 40":
msg = "?? ??? ? ?"
return msg
data, sw1, sw2 = session.sendCommandAPDU( SELECT + 
DF_ROOT )
data, sw1, sw2 = session.sendCommandAPDU( SELECT + 
DF_GSM )
data, sw1, sw2 = session.sendCommandAPDU( DELETE_FILE )
if sw1 != 0x90 or sw1 != 0x91:
msg = "?? ??? ? ?"
return msg
data, sw1, sw2 = session.sendCommandAPDU( SELECT + 
DF_GSM )
data, sw1, sw2 = session.sendCommandAPDU(
smartcard.util.toBytes(CREATE_FILE_APDU)
if sw1 != 0x90 or sw1 != 0x91:
msg = "?? ??? ? ?"
   

Re: wxPython and threads again

2005-08-10 Thread David E. Konerding DSD staff
In article <[EMAIL PROTECTED]>, perchef wrote:
> Hi,
> 
> I have several files to download and a GUI to update. I know this is a
> frequently asked question but i can't find an appropriate solution.
> My Downloader extends threading.Thread and update a wx.Gauge in GUI
> during the process.
> 
> for src in urls:
>downloader = Downloader( src, destination, GUI )
>downloader.start()
> 
> #work with the downloaded files...
> 
> If i don't use a downloader.join() in this for loop, I launch several
> threads at the same time and so my wx.Gauge is bouncing up and down.
> If i do add the downloader.join() my GUI is no more updated ( in fact,
> nothing appears, it's frozen )
> How can I wait the end of the thread and also be able to update the GUI

Well, the constraints are this: the main thread is running the wx main loop,
and thus, cannot block by calling join on the downloader thread.  Further, 
calling
wx from a thread other than the one running the event loop is deep voodoo and 
should typically
be avoided.

You need another way to pass completion information between the downloader
thread and the main thread; the simplest way is to define a custom wx
Event, and wxPostEvent from the downloader thread when it completes (
and when the gauge should be updated).  wxPostEvent is safe to call from 
non-eventloop threads.
The main thread's wx event loop just spins, properly updating all other
parts of the GUI, and receiving events from the downloader thread.

ANother approach is to have a thread-safe Queue and have the main thread/event 
loop
poll the queue with queue.get_nowait() periodically (typically 0.1-1 sec).
The downloader thread shares the queue object and puts data structures 
(typically
class instances, strings, or ints) that indicate status updates.

The easiest approach, though, is to use the threadedselectreactor in Twisted 
(you need
to check the HEAD branch out with subversion, because that reactor isn't 
included in any releases).
With threadedselectreactor, it's easy to incorporate both the GUI event loop 
and the twisted reactor.
Twisted already includes lots of code for doing asynchronous callback-style IO 
for
IO bound processes like downloading.  Further, you don't even think in an 
explicitly threaded way-
createing a whole thread just to manage a download process which is motly IO 
and a little bookkeeping is
silly.  Twisted's approach just makes a lot more sense and simplifies the code 
too.

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


Re: Module Extension C/CPI Question

2005-08-10 Thread Martin v. Löwis
Jeremy Moles wrote:
> typedef struct Foo {
>   int x;
>   int y;
>   int z;
>   char xyz[100];
> } Foo;
> 
> Is there an "accepted" way of propagating this upstream? I was thinking
> one of these two:

It really depends on the struct. Would a C programmer automatically
be able to list all members, in their natural order? If they are
'x','y','z', I would say 'yes': it's obviously a point in a cartesian
coordinate system. If the members are readily known, and if you
would not use one without the others, a tuple is the right structure.

If, on the other hand, different applications would access different
fields, and if there are many fields so nobody could memorize them,
you would be better off with named access. A dictionary would work,
but people would prefer attribute names.

A typical example is the result of os.stat(), which is a type
named stat_result these days. It used to be a tuple, but that was
very inconvenient. For backwards compatibility, it had to remain
tuple-like, so we now have the StructSeq mechanism. This might
be the easiest way to get a struct-like value back to Python.

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


Re: Does any one recognize this binary data storage format

2005-08-10 Thread Calvin Spealman
On 8/10/05, Grant Edwards <[EMAIL PROTECTED]> wrote:
> On 2005-08-10, John Machin <[EMAIL PROTECTED]> wrote:
> 
> Perhaps the one bit is an exponent -- some kind of floating point
> based format?  That matches the doubling of all digits.
> >>>
> >>>That would just be sick.  I can't imagine anybody on an 8-bit
> >>>CPU using FP for a phone number.
> 
> >>  >>> double_binary_lehex_to_double('00806a6e4941')
> >>  333.0
> >>  >>> double_binary_lehex_to_double('00806a6e5941')
> >>  666.0
> >>  >>> double_binary_lehex_to_double('108777F9Fc41')
> >>  77.0
> >>
> >> ;-)
> >
> > Well done, Scott & Bengt!!
> > I've just verified that this works with all 12 corrected examples posted
> > by the OP.
> >
> > Grant, MS-DOS implies 16 bits at least;
> 
> You're right.  For some reason I was thinking you had said CP/M.
> 
> > and yes there was an FPU (the 8087).
> 
> I never met an MS-DOS box that had an 8087 (though I did write
> firmware for an 8086+8087 fire-control computer once upon a
> time).
> 
> > And yes there are a lot of sick people who store things as
> > numbers (whether integer or FP) when the only arithmetic
> > operations that can be applied to them stuff them up mightily
> > (like losing leading zeroes off post-codes, having NEGATIVE
> > tax file numbers, etc) and it's still happening on the best
> > OSes and 64-bit CPUS. Welcome to the real world :-)
> 
> I've been in the real world for a long time, and the dumb
> things people (including myself) do still surprise me.
> 
> --
> Grant Edwards   grante Yow!  Hello, GORRY-O!! I'm
>   at   a GENIUS from HARVARD!!
>visi.com
> --
> http://mail.python.org/mailman/listinfo/python-list
> 

Original Poster should send this off to thedailywtf.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: "Compile time" checking?

2005-08-10 Thread phil hunt
On 10 Aug 2005 08:53:15 -0700, Qopit <[EMAIL PROTECTED]> wrote:
>Hi there,
>
>I'm pretty new to Python and am trying to figure out how to get "will
>this code compile?"-like code checking.

Why not just find out, by trying to compile it? :-)


-- 
Email: zen19725 at zen dot co dot uk


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


Re: how to write a line in a text file

2005-08-10 Thread Jeff Schwab
Calvin Spealman wrote:
> On 7/31/05, James Dennett <[EMAIL PROTECTED]> wrote:
> 
>>Peter Hansen wrote:
>>
>>
>>>Steven D'Aprano wrote:
>>>
>>>Given that ZODB and PySQLite are simply Python extension modules, which
>>>get bundled by your builder tool and are therefore installed
>>>transparently along with your app by your installer, this is a total
>>>non-issue at least with those packages.
>>>
>>>After all, it's not 1970 any more. ;-)
>>
>>Indeed; since 1970 we learned to prefer straightforward
>>file formats where possible, reserving use of databases
>>for structured data where the extra costs are justified.
>>
>>Sometime maybe databases will get better to the point
>>that we don't need to distinguish so much between them
>>and filesystems, but we're not there yet.  Managing raw
>>files, carefully, still has a place.
>>
>>-- James
> 
> 
> Filesystems are a horrible way to organize information, and even worse
> at structuring it. The mentality that there are any benefits of
> low-overhead the outweigh the benefits of minimal database layers,
> such as ZODB, BSD DB, and SQLite, is a large part of the reason we are
> still stuck with such a mess. Those "extra costs" are so minimal, that
> you wouldn't even notice them, if you hadn't convinced yourself of
> their presense before performing or researching any realy benchmarks.
> A simple RDBMS can be much easier to work with than any flat file
> format, will likely be far faster in processing the data, and has the
> benefit of years of coding making the code that actually reads and
> writes your data as fast and stable as possible.


You don't use files?  You're telling me that instead of copying & 
modifying my friend's bashrc, I should be querying a bunch of tables 
with SQL?  Bull.  Ordinary files, preferably in line-separated or tagged 
formats, are going to be a lot easier for most of us to work for a long 
time to come.  This is especially true now that we have lots of good 
libraries for working with XML-based formats.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: "Compile time" checking?

2005-08-10 Thread Benjamin Niemann
Qopit wrote:

> [snip]
>
> My questions are:
> - Am I missing something with my tester example?
> - Are there other code-checking options other than PyChecker?

Try pylint

-- 
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Recommendations for CVS systems

2005-08-10 Thread skip

>> For a python newsgroup, you are required to consider mercurial.  It's
>> not ready for production use yet, but is making rapid progress, ...

aahz> Why do you say "required" when the next sentence you say it's not
aahz> ready for production?

I believe "consider" != "adopt".  Different people's needs are different, so
the notion of how "production-ready" it has to be will vary.

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


Re: PyOpenGL

2005-08-10 Thread Mike C. Fletcher
[EMAIL PROTECTED] wrote:

>Hey I'm a programmer looking to port some of my opengl ...although
>limited into a python app I've made... I'd like to know where to find
>any python/opengl source or a tutorial etc.. whatever I'd like to get a
>series of points that represent a 3d slope presented to the user.
>
>Thanks
>Matt
>  
>
That'd a fairly simple demo; you'll find a "big brother" of it in the 
"dots" demo with PyOpenGL (which is a particle system composed of dots 
(points)).

OpenGLContext has a number of demos for displaying pointsets (dots), 
including the basic pointset test that just creates a set of 20 points 
or so.

If what you mean is that you want to create a *mesh* from a point-set, 
then you need to add some more information, particularly you need a way 
to figure out the topological connections between points.  If it's a 
regular x,y grid, you can readily construct the polygons, if not, you 
get into something a little more fuzzy.

Good luck,
Mike

-- 

  Mike C. Fletcher
  Designer, VR Plumber, Coder
  http://www.vrplumber.com
  http://blog.vrplumber.com

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


Memory leak in PyImport_ReloadModule - URGENT

2005-08-10 Thread ben . held
Having recently upgraded to Python 2.4, I am having a large memory
leak with the following code built with VC++ 6.0:

PyObject *pName, *pModule;

Py_Initialize();
pName = PyString_FromString(argv[1]);

pModule = PyImport_Import(pName);
Py_DECREF(pName);

PyObject* pModule2 = PyImport_ReloadModule(pModule);
Py_DECREF(pModule2);
Py_DECREF(pModule);
Py_Finalize();
return 0;

I get leaks of over 500 kb.  I have another program which is much more
complex, in which every call to PyImport_ReloadModule is leaking 200+
kb, even though I am calling Py_DECREF correctly.

Help!

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


Re: What are modules really for?

2005-08-10 Thread Tito
> [1]  'aName' => public, '_aName' => protected, '__aName' => private

I didn't know this one, as I am quite new to Python. Is it really 
general use?

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


  1   2   3   >