ANN: Schevo 3.0-beta1 released

2005-11-03 Thread Matthew Scott
==
 Schevo 3.0-beta1
==

--
 Release Announcement
--

Also available at
http://schevo.org/latest/release/announcements/3.0-beta1.html



What's new in version 3.0-beta1?


* Initial release of Schevo 3.0 series.


Get Schevo!
===

See the `Schevo website`_ for more information, or go ahead and `get
started with Schevo`_.

.. _Schevo website:
   http://schevo.org/

.. _get started with Schevo:
   http://schevo.org/latest/guides/getting-started.html


What is Schevo?
===

Schevo is a next-generation DBMS that focuses on the following:

- **Database Integrity**: Schevo is designed from the ground up to
  protect your data.  All changes to a Schevo database must be done
  using transactions, and Schevo ensures that those transactions
  always leave the database in a consistent state.

- **Rapid Development**: Schevo includes features to make it easy and
  fun to create even the most complex of databases.  Not only is the
  schema syntax easy to write and understand, you can also quickly
  place initial values in your schema that are required by your
  database, and use the same syntax to create sets of sample data to
  use during development.

- **User Interface Generation**: Schevo provides user interface
  toolkits that take advantage of the richness of the database schema.
  You can use the full-featured Schevo Navigator to interact with your
  database without writing a single line of code outside of your
  database schema.  A PyQt-based toolkit is already available, and
  TurboGears and NuFox toolkits are in the works.

- **Rich Schema Definition**: The schema for a Schevo database is
  written in concise, easy-to-read Python code.  Not only does the
  schema describe how information in the database is structured, but
  also defines all transactions and rules that ensure database
  integrity.

- **Assisted Schema Evolution**: Once a Schevo database is deployed
  and is used to store valuable data, you will inevitably make further
  changes to the structure of the database.  Schevo assists you in
  this task and makes it easy to restructure a database and facilitate
  the migration of data from one schema version to the next.


Why use Schevo?
===

The main problem that Schevo was designed to address is that
Relational databases, which use Structured Query Language (SQL), do
not match well with object-oriented programming languages, such as
Java, Python and Ruby.  This situation has been labeled the
object-relational impedance mismatch problem, and it is a
significant barrier to the rapid development and evolution of database
applications.

Because of this mismatch, database applications tend to have three
distinct layers of code: SQL within the database, object-oriented code
within the application, and an object-relational mapping (ORM) layer
to mediate between the SQL and the object language.  These extra
layers add additional complexity and inflexibility to what are already
complex and inflexible databases.  Schevo eliminates these extra
layers.

Schevo solves the object-relational impedance mismatch problem by
combining relational features with the object-oriented programming
language Python.  A database schema defined in Schevo results in a
database that enforces the same integrity constraints supported by the
Relational model, with the added benefit of Python objects.

The benefit of this is that application developers can create their
entire application using the full power of the Python language without
having to introduce another language (SQL) that has its own language
constructs, its own datatypes, and a limited set of behavior.
Instead, a Schevo database stores Schevo objects which use native
Python datatypes and include any behavior defined for those objects.
In addition, Schevo objects contain a great deal of metadata that is
available for introspection to support the development of rich user
interfaces with a minimal amount of code.

In fact, Schevo includes a GUI Navigator that can display a fully
interactive interface into any Schevo database.  The Navigator is
constructed on-the-fly based solely on the metadata available within
the Schevo database file.  The Navigator allows you to display,
create, update, and delete any object within the database, within the
rules and constraints defined for that database.


--
Matthew R. Scott
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


when and how do you use Self?

2005-11-03 Thread Tieche Bruce A MSgt USMTM/AFD
I am new to python,

 

Could someone explain (in English) how and when to use self?

 

I have been reading, and haven't found a good example/explanation

 

 

Bruce Tieche ([EMAIL PROTECTED])

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


Re: Getting a function name from string

2005-11-03 Thread Bengt Richter
On Wed, 02 Nov 2005 19:01:46 -0500, Mike Meyer [EMAIL PROTECTED] wrote:

Paul McGuire [EMAIL PROTECTED] writes:
 David Rasmussen [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
 If I have a string that contains the name of a function, can I call it?
 As in:

 def someFunction():
 print Hello

 s = someFunction
 s() # I know this is wrong, but you get the idea...

 /David

 Lookup the function in the vars() dictionary.

 def fn(x):
 ...   return x*x
 ...
 vars()['fn']
 function fn at 0x009D67B0
 vars()['fn'](100)
 1

vars() sans arguments is just locals, meaning it won't find functions
in the global name space if you use it inside a function:

 def fn(x):
...  print x
... 
 def fn2():
...  vars()['fn']('Hello')
... 
 fn2()
Traceback (most recent call last):
  File stdin, line 1, in ?
  File stdin, line 2, in fn2
KeyError: 'fn'
 

Using globals() in this case will work, but then won't find functions
defined in the local name space.

For a lot of uses, it'd be better to build the dictionary by hand
rather than relying on one of the tools that turns a namespace into a
dictionary.
IMO it would be nice if name lookup were as cleanly
controllable and defined as attribute/method lookup.
Is it a topic for py3k?

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


Re: Microsoft Hatred FAQ

2005-11-03 Thread W.H.Offenbach
John W. Kennedy wrote:
 IBM was genuinely innovative, and did their best to provide value for
 money. Microsoft hasn't been able to produce anything but me-too
 products since the 80's. (Multiplan, Word for DOS, the QBASIC engine,
 early sponsorship of mouses, and the gutsy decision to morph MS-DOS 
 1.0,
 a CP/M quasi-clone, into DOS 2.0, a Unix quasi-clone, are about all I
 can give them credit for.)

You're suggesting MS stands for 'Mimick or Steal', right?

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


Re: when and how do you use Self?

2005-11-03 Thread Fredrik Lundh
Tieche Bruce A MSgt USMTM/AFD [EMAIL PROTECTED] wrote:

 Could someone explain (in English) how and when to use self?

 I have been reading, and haven't found a good example/explanation

consider a class C:

 class C:
... def method(self):
... print self
...
 C
class __main__.C at 0x0091D7E0

you can create unique instances of this class by calling the class itself:

 a = C()
 a
__main__.C instance at 0x00925FD0

 b = C()
 b
__main__.C instance at 0x00927030

here, a and b are two separate objects, that both refer to the same
class object, but are otherwise distinct (the cryptic codes are object
identities).

now, if you call a method on one of those objects, Python will use the
method code from the class, but the method will get a reference to the
instance as its first argument (self).

when you call the method via the a object, the method gets a reference
to the a object as the first argument:

 a.method()
__main__.C instance at 0x00925FD0

when you call the method via the b object, the method gets a reference
to the b object as the first argument:

 b.method()
__main__.C instance at 0x00927030

the instance object is usually used to store instance-specific variables
(usually known as attributes or members).  an example:

 class Counter:
... def __init__(self):
... self.value = 0
... def increment(self):
... self.value = self.value + 1
... return self.value
...
 a = Counter()
 b = Counter()
 a.increment()
1
 a.increment()
2
 a.increment()
3
 b.increment()
1

(the __init__ method is automatically called for each new instance)

you can also access the instance attributes from the outside:

 print a.value
3
 print b.value
1

for more on this, see:

http://docs.python.org/tut/node11.html#SECTION001130

/F



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


Re: when and how do you use Self?

2005-11-03 Thread bruno at modulix
Tieche Bruce A MSgt USMTM/AFD wrote:
 I am new to python,
 
  
 
 Could someone explain (in English) how and when to use self?
 
Don't use self. Use other.
-- 
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: how to write a blog system with Python

2005-11-03 Thread bruno at modulix
ice wrote:
 I am a fresh here , and I have no idea of it.
 Do you have any comments?
 
Learn Python
Learn web programming
Write the specs for your blog system
Design the solution
Implement it

-- 
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: Python and MySQL

2005-11-03 Thread Aquarius
I am also have _mysql.c that has to be compiled. I downloaded 1.2.0
from here
http://sourceforge.net/project/showfiles.php?group_id=22307package_id=15775
(the .tar.gz). Do you mean, that if I drop the import _mysql and from
_mysql import ... lines everything will work OK? I private install
would be great for me, if it works :D

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


OT - Re: Microsoft Hatred FAQ

2005-11-03 Thread Tim Daneliuk
David Blomstrom wrote:

 Everytime someone compares MS's behavior with some
 less controversial criminal behavior, you act like
 they
 accused MS of holding people up at gunpoint.
 
 Screwing literally millions of consumers and taxpayers
 and holding entire schools hostage is far worse than
 holding up an individual at gunpoint. The name
 Microsoft is virtually synonymous with crime, even if
 many people are too stupid to recognize it as crime -
 or the courts are too corrupt or inefficient to
 convict Bill Gates for many of his crimes.

A) I don't much care if people wander off topic from time to time -
that's what filters are for.  But as a matter of general courtesy
is it too much to ask that the subject line be so marked?

B) Rhetoric is not Reality.  Crime has a very specific definition.
It always has one or more of Fraud, Force, or Threat.  No such
case against Microsoft has ever been levied.  Just because *you*
don't like market outcomes doesn't make it a crime.
Here is some *thoughtful* counterpoint (instead of the ignorant
foaming that has characterized this thread):

http://www.cato.org//pubs/pas/pa352.pdf
http://reason.com/0111/fe.dk.antitrusts.shtml
http://www.cato.org//pubs/pas/pa-405es.html

C) Hate Microsoft all you want.  But those of us old enough to have
actually done this for than 10 minutes recall the days where every single
hardware vendor was also a unique software and systems vendor.
Absent a Microsoft/Intel-style de facto standard, you'd never have
seen the ascent of Linux or Open Source as it exists today.  Drivers
are painful to write, so oddball or vendor-specific systems don't
get them very rapidly.  Microsoft/Intel commoditized the space whether
you like it or not.  They (perhaps unintentionally) created the
computer equivalent of standard connectors as found in audio systems.

D) Your ranting is puerile.  If you are going to waste bandwidth on
 OT matters, at least make it intelligent and/or interesting.

E) I prefer Unix and its variants.  However, I (and you) are direct
beneficiaries of Microsoft's success.

F) There are *more* choices than ever today for both systems and applications
software.  Stop foaming, and go do something useful with them ...



No Cheers,
-- 

Tim Daneliuk [EMAIL PROTECTED]
PGP Key: http://www.tundraware.com/PGP/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to write a blog system with Python

2005-11-03 Thread Sybren Stuvel
ice enlightened us with:
 I am a fresh here , and I have no idea of it.  Do you have any
 comments?

Look up turbogears and watch the 20 minute Wiki video tutorial.

Sybren
-- 
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself? 
 Frank Zappa
-- 
http://mail.python.org/mailman/listinfo/python-list


Class Variable Access and Assignment

2005-11-03 Thread Graham
This has to do with class variables and instances variables.

Given the following:

code

class _class:
var = 0
#rest of the class

instance_b = _class()

_class.var=5

print instance_b.var # - 5
print _class.var # - 5

/code

Initially this seems to make sense, note the difference between to last
two lines, one is refering to the class variable 'var' via the class
while the other  refers to it via an instance.

However if one attempts the following:

code

instance_b.var = 1000 # - _class.var = 5
_class.var =  # - _class.var = 

/code

An obvious error occurs. When attempting to assign the class variable
via the instance it instead creates a new entry in that instance's
__dict__ and gives it the value. While this is allowed because of
pythons ability to dynamically add attributes to a instance however it
seems incorrect to have different behavior for different operations.

There are two possible fixes, either by prohibiting instance variables
with the same name as class variables, which would allow any reference
to an instance of the class assign/read the value of the variable. Or
to only allow class variables to be accessed via the class name itself.

Many thanks to elpargo and coke. elpargo assisted in fleshing out the
best way to present this.

perhaps this was intended, i was just wondering if anyone else had
noticed it, and if so what form would you consider to be 'proper'
either referring to class variables via the class itself or via
instances of that class. Any response would be greatly appreciated.


Graham

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


Class Variable Access and Assignment

2005-11-03 Thread Graham
This has to do with class variables and instances variables.

Given the following:

code

class _class:
var = 0
#rest of the class

instance_b = _class()

_class.var=5

print instance_b.var # - 5
print _class.var # - 5

/code

Initially this seems to make sense, note the difference between to last
two lines, one is refering to the class variable 'var' via the class
while the other  refers to it via an instance.

However if one attempts the following:

code

instance_b.var = 1000 # - _class.var = 5
_class.var =  # - _class.var = 

/code

An obvious error occurs. When attempting to assign the class variable
via the instance it instead creates a new entry in that instance's
__dict__ and gives it the value. While this is allowed because of
pythons ability to dynamically add attributes to a instance however it
seems incorrect to have different behavior for different operations.

There are two possible fixes, either by prohibiting instance variables
with the same name as class variables, which would allow any reference
to an instance of the class assign/read the value of the variable. Or
to only allow class variables to be accessed via the class name itself.

Many thanks to elpargo and coke. elpargo assisted in fleshing out the
best way to present this.

perhaps this was intended, i was just wondering if anyone else had
noticed it, and if so what form would you consider to be 'proper'
either referring to class variables via the class itself or via
instances of that class. Any response would be greatly appreciated.


Graham

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


typo in the documentation or am I stupid?

2005-11-03 Thread Tommy . Ryding
In the embedding Python manual at Python.org an example is presented
that uses the function:
PyDict_GetAttrString. Is it possible that this is a typo?

I have searched the source code and I can't find it, I have also used
google and I only get 4 hits.

In for example Programming Python another function with similar name is
described: PyObject_GetAttrString. Could that be the one that fit into
the example?

Hopefully someone knows the answer to my question ;)

//Tommy

Link to the spot at Python.org:
http://docs.python.org/ext/pure-embedding.html

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


Re: Class Variable Access and Assignment

2005-11-03 Thread Eric Nieuwland
Graham wrote:
 code

 class _class:
 var = 0
 #rest of the class

 instance_b = _class()

 _class.var=5

 print instance_b.var # - 5
 print _class.var # - 5

 /code
 [...]
 code

 instance_b.var = 1000 # - _class.var = 5
 _class.var =  # - _class.var = 

 /code

 An obvious error occurs.

Nope. 'var' is NOT a class variable! It is a pre-filled instance 
variable.
You need some explicit programming to get class variables.

--eric

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


Unicode string and metakit database

2005-11-03 Thread Tony
I write a database application with Metakit. My script is like the
following:
...
vw = db.getas(t1[no:I,ch:S,code1:S,code2:S])
...
*vw.append(no=i,ch=x,code1=y[0],code2=y[1])
...
But errors occured on * and it displayed TypeError: not a Python
string.
x, y[0], y[1] are unicode strings. Doesn't Metakit support unicode or
else?

Thanks a lot!

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


Re: Class Variable Access and Assignment

2005-11-03 Thread Steven D'Aprano
On Thu, 03 Nov 2005 01:43:32 -0800, Graham wrote:

[snip]

 print instance_b.var # - 5
 print _class.var # - 5
 
 /code
 
 Initially this seems to make sense, note the difference between to last
 two lines, one is refering to the class variable 'var' via the class
 while the other refers to it via an instance.

That's not correct. The line instance_b.var is referring to an instance
attribute. According to the usual Object Oriented model of inheritance, if
the instance does not have an attribute, the class is searched next.

So instance_b.var and _class.var are asking for two different things. The
first says, Search the instance for attribute var, then the class. The
second says Search the class.

BTW, a leading underscore is the convention for a private(ish) variable.
The convention for naming a variable after a reserved word is a trailing
underscore class_. In this case, there is also the convention that classes
should start with a capital, so you have Class and instance. (instance, of
course, is not a reserved word.)


 However if one attempts the following:
 
 code
 
 instance_b.var = 1000 # - _class.var = 5
 _class.var =  # - _class.var = 
 
 /code
 
 An obvious error occurs. 

I see no error. No exception is raised when I try it: I get the expected
results. Assigning to an instance assigns to the instance, assigning to
the class assigns to the class. That's normal OO behaviour.


 When attempting to assign the class variable
 via the instance it instead creates a new entry in that instance's
 __dict__ and gives it the value. 

You might *want* to assign to the class attribute, but that's not what you
are doing. You are assigning to the instance.

Admittedly, it might not be the behaviour you expect, but it is the
standard behaviour in (as far as I know) all OO languages.

If you want to assign to the class attribute, you either assign to the
class directly, or use instance_b.__class__.var.


 While this is allowed because of
 pythons ability to dynamically add attributes to a instance however it
 seems incorrect to have different behavior for different operations.

Surely you can't mean that? Why would you want different operations to
have the same behaviour?


 There are two possible fixes, either by prohibiting instance variables
 with the same name as class variables, which would allow any reference
 to an instance of the class assign/read the value of the variable. Or
 to only allow class variables to be accessed via the class name itself.

There is also a third fix: understand Python's OO model, especially
inheritance, so that normal behaviour no longer surprises you.


-- 
Steven.

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


Re: Class Variable Access and Assignment

2005-11-03 Thread Jorge Godoy
Graham [EMAIL PROTECTED] writes:

 perhaps this was intended, i was just wondering if anyone else had
 noticed it, and if so what form would you consider to be 'proper'
 either referring to class variables via the class itself or via
 instances of that class. Any response would be greatly appreciated.

It was discussed before here and there's something about that at the docs:
http://docs.python.org/tut/node11.html


-- 
Jorge Godoy  [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


strtok equvialent ?

2005-11-03 Thread [EMAIL PROTECTED]
Hi,

are there a strtok equivalent in python ? str.split() only takes single
seperator.

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


Re: typo in the documentation or am I stupid?

2005-11-03 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote_

 In the embedding Python manual at Python.org an example is presented
 that uses the function:
 PyDict_GetAttrString. Is it possible that this is a typo?

according to this checkin message (fix stupid typo), the answer is yes:

http://mail.python.org/pipermail/python-checkins/2005-October/047291.html

on the other hand, since the target is a module object, PyObject_GetAttrString
might be a better choice (no time to dig into this right now).

/F 



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


Re: strtok equvialent ?

2005-11-03 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote:

 are there a strtok equivalent in python ? str.split() only takes single
 seperator.

use a regular expression split with a character group:

 s = breakfast=spam+egg-bacon
 import re
 re.split([-+=], s)
['breakfast', 'spam', 'egg', 'bacon']

to deal with an arbitrary set of delimiting characters without having to
bother with RE syntax, use re.escape:

 re.split([ + re.escape(-+=) + ], s)
['breakfast', 'spam', 'egg', 'bacon']

/F 



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


Anomaly in creating class methods

2005-11-03 Thread venk
Hi,
 given below is my interaction with the interpreter In one case, i
have created the class method using the famous idiom... and in the
other, i have tried to create it outside the class definition... why
isn't the latter working ? (of course, the presence of decorators is a
different issue)
 class D:
... def f(cls):
... print cls
...
 D.f=classmethod(D.f)
 D.f
bound method classobj.f of class __main__.D at 0xb7c99f5c
 D.f()
Traceback (most recent call last):
  File stdin, line 1, in ?
TypeError: unbound method f() must be called with D instance as first
argument (got classobj instance instead)
 class D:
... def f(cls):
... print cls
... f=classmethod(f)
...
 D.f
bound method classobj.f of class __main__.D at 0xb7c9947c
 D.f()
__main__.D

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


Re: strtok equvialent ?

2005-11-03 Thread [EMAIL PROTECTED]
thanks.

Fredrik Lundh wrote:
 [EMAIL PROTECTED] wrote:

  are there a strtok equivalent in python ? str.split() only takes single
  seperator.

 use a regular expression split with a character group:

  s = breakfast=spam+egg-bacon
  import re
  re.split([-+=], s)
 ['breakfast', 'spam', 'egg', 'bacon']

 to deal with an arbitrary set of delimiting characters without having to
 bother with RE syntax, use re.escape:

  re.split([ + re.escape(-+=) + ], s)
 ['breakfast', 'spam', 'egg', 'bacon']
 
 /F

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


shared library search path

2005-11-03 Thread Stefan Arentz

Hi. I've wrapped a C++ class with Boost.Python and that works great. But, I
am now packaging my application so that it can be distributed. The structure
is basically this:

 .../bin/foo.py
 .../lib/foo.so
 .../lib/bar.py

In foo.py I do the following:

 sys.path.append(os.path.dirname(sys.path[0]) + '/lib')

and this allows foo.py to import bar. Great.

But, the foo.so cannot be imported. The import only succeeds if I place
foo.so next to foo.py in the bin directory.

I searched through the 2.4.2 documentation on python.org but I can't find
a proper explanation on how the shared library loader works.

Does anyone understand what it going on here?

 S.

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


problem with async_chat

2005-11-03 Thread rix
Hi there,
I am writing an application that requires a client-server interaction.
Looking up on the internet and working on it I came up with something
like this:
a class ADFSServer that takes inbound connections and dispatches them
to ADFSReceiver.
The connection is always initialized by ADFSSender.
here is the code:

import asynchat
import asyncore
import socket
import string

class ADFSServer (asyncore.dispatcher):

def __init__ (self, port):
asyncore.dispatcher.__init__ (self)
self.create_socket (socket.AF_INET, socket.SOCK_STREAM)
self.set_reuse_addr()
here = ('', port)
self.bind (here)
self.listen (1)

def handle_accept (self):
print (Server is accepting connection)
ADFSReceiver (self, self.accept())

class ADFSReceiver (asynchat.async_chat):

channel_counter = 0

def __init__ (self, server, (conn, addr)):
asynchat.async_chat.__init__ (self, conn)
self.set_terminator ('\n')
self.server = server
self.id = self.channel_counter
self.channel_counter = self.channel_counter + 1
self.buffer = ''
print (Receiver created)

def collect_incoming_data (self, data):
self.buffer.append(data)
print (collecting data)

def found_terminator (self):
data = self.buffer
self.buffer = ''
print '[Received Message]\n %s' % (self.id, repr(data))
self.close()
return data

def handle_close (self):
print 'Closing receiver'
self.close()

class ADFSSender (asynchat.async_chat):

def __init__ (self, data, address):
print creating sender
asynchat.async_chat.__init__ (self)
#self.set_terminator (\n)
self.create_socket (socket.AF_INET, socket.SOCK_STREAM)
self.connect (address)
self.push(data)
self.push (\n)

if __name__ == '__main__':
work1 = ADFSServer (1234)
asyncore.loop()


I start the server on a shell, and from another shell I launch the
ADFSSender.
The problem is that if I use the push() function the code doesn't work.
If I use the send() it works.
As I am using the async_chat class, I would like to use the push()
method, so I was wondering what was the problem with my code...

thanks,
rix

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


NTFS reparse points

2005-11-03 Thread Stanislaw Findeisen
I want to create a reparse point on NTFS (any).

Here 
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/reparse_points.asp)
 
I read: reparse points are used to implement NTFS file system links. 
Here 
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/hard_links_and_junctions.asp)
 
I read: Soft links are implemented through reparse points.

However I can't see FILE_ATTRIBUTE_REPARSE_POINT turned on in any file / 
directory shortcuts I create. In fact the only attribute set in 
shortcuts created using Windows Explorer is FILE_ATTRIBUTE_ARCHIVE. (I 
am using GetFileAttributes() to examine this.)

The questions are:

(1) Why is that so?
(2) Does anybody have any idea (sample code?) on how to create a reparse 
point (the simpler, the better) using Python?

I am using Windows 2000 Professional, Python 2.4 and Mark Hammond's 
Python for Windows Extensions build 204.

Thank you.

+---+
| When replying, please replace my_initials in the|
| From: address field with my initials - that is, SF. |
+---+

-- 
 http://www.nglogic.com
 Enter through the narrow gate! (Mt 7:13-14)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python's website does a great disservice to the language

2005-11-03 Thread Steve Holden
Alex Martelli wrote:
 The Eternal Squire [EMAIL PROTECTED] wrote:
...
 
2)  Consider what he really wants for a supervisor of software
engineers.   Ideally such a person should be a software engineer with
at least 3 times the experience of the most junior member.  Such a
 
 
 I like the general idea but not your formula.  If the most junior team
 member was 1 month out of school, would it really be OK for the
 supervisor to be somebody who graduated 3 months ago?-)
 
It worked for Microsoft ...

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


How to read all files in a directory

2005-11-03 Thread hungbichvo
Dear All,

My python application is small. It reads data from a file.
My code is:
   fileName = '900128.DAT'
   dataFile = open(fileName, 'r').readlines()
I have to run 100 input files .DAT. Each time I run application, I have 
to change code fileName to a new one. For example, fileName 
= 'NewFile.DAT'.
I do not know how I can process all file with extension .DAT in a 
specific directory once only.

Any suggestion will be appreciated,

Thank you.



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


Re: Class Variable Access and Assignment

2005-11-03 Thread Antoon Pardon
Op 2005-11-03, Steven D'Aprano schreef [EMAIL PROTECTED]:

 There are two possible fixes, either by prohibiting instance variables
 with the same name as class variables, which would allow any reference
 to an instance of the class assign/read the value of the variable. Or
 to only allow class variables to be accessed via the class name itself.

 There is also a third fix: understand Python's OO model, especially
 inheritance, so that normal behaviour no longer surprises you.

No matter wat the OO model is, I don't think the following code
exhibits sane behaviour:

class A:
  a = 1

b = A()
b.a += 2
print b.a
print A.a

Which results in

3
1

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


Re: How to read all files in a directory

2005-11-03 Thread Stefan Arentz
hungbichvo [EMAIL PROTECTED] writes:

 Dear All,
 
 My python application is small. It reads data from a file.
 My code is:
fileName = '900128.DAT'
dataFile = open(fileName, 'r').readlines()
 I have to run 100 input files .DAT. Each time I run application, I have 
 to change code fileName to a new one. For example, fileName 
 = 'NewFile.DAT'.
 I do not know how I can process all file with extension .DAT in a 
 specific directory once only.
 
 Any suggestion will be appreciated,
 
 Thank you.

http://www.python.org/doc/2.4.2/lib/module-glob.html

% python
Python 2.4.2 (#2, Sep 30 2005, 21:19:01)
[GCC 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu8)] on linux2
Type help, copyright, credits or license for more information.
 import glob
 print glob.glob('*.rb')
['hello.rb', 'test.rb', 'ping.rb', 'echo.rb']

Sorry for the ruby code in the example :-)

 S.

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


Re: Class Variable Access and Assignment

2005-11-03 Thread Stefan Arentz
Antoon Pardon [EMAIL PROTECTED] writes:

 Op 2005-11-03, Steven D'Aprano schreef [EMAIL PROTECTED]:
 
  There are two possible fixes, either by prohibiting instance variables
  with the same name as class variables, which would allow any reference
  to an instance of the class assign/read the value of the variable. Or
  to only allow class variables to be accessed via the class name itself.
 
  There is also a third fix: understand Python's OO model, especially
  inheritance, so that normal behaviour no longer surprises you.
 
 No matter wat the OO model is, I don't think the following code
 exhibits sane behaviour:
 
 class A:
   a = 1
 
 b = A()
 b.a += 2
 print b.a
 print A.a
 
 Which results in
 
 3
 1

I find it confusing at first, but I do understand what happens :-)

But really, what should be done different here?

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


Getting Python Accepted in my Organisation

2005-11-03 Thread Stuart Turner
Hi Everyone,

I'm working hard trying to get Python 'accepted' in the organisation I work
for.  I'm making some good in-roads.  One chap sent me the text below on
his views of Python.  I wondered if anyone from the group could give me
some advice on how to respond / if they had been in a similar position.

Any help appreciated,

Thanks in advance,

- Stuart


 Python is a scripting language like Perl, awk, tcl, Java etc...  it is
not quite a fully developed OO language, but does support some OO that Perl
doesn't.  To be clear, these scripting languages have their place in our
environment, but they are not full replacements for C#, Java, C, etc... 
because they do not come with the full range of libraries e.g GDI
libraries.  Python has to be compared to Perl, Awk in order to evaluate it. 
Perl, until recently, did not support threading.  Why would it? it is a
scripting language and can run async shell commands.  I would be interested
to learn if Python supports a robust threading model (not just a pointer
reference to an object), as this is a significant drawback when using a
scripting language.  CGI only works because the container can thread with
Perl.  Python is object orientated, but I do not know what implementation? 
Essentially any language with a pointer can claim to be OO, although Python
does market itself on OO capabilities.  Do you know what implementation
they have used?
  
    Lets discuss, as I am not a great fan of Perl and if Python is more
structured then it is possibly worth promoting.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Getting Python Accepted in my Organisation

2005-11-03 Thread Stefan Arentz
Stuart Turner [EMAIL PROTECTED] writes:

 Hi Everyone,
 
 I'm working hard trying to get Python 'accepted' in the organisation I work
 for.  I'm making some good in-roads.  One chap sent me the text below on
 his views of Python.  I wondered if anyone from the group could give me
 some advice on how to respond / if they had been in a similar position.

What do you want to use Python for? What do you use now?

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


Re: Getting Python Accepted in my Organisation

2005-11-03 Thread Stuart Turner
I'm already using it for a ton of things - I want to try and get broader
acceptance in the organisation for it to be made and 'officially supported
product'.


Stefan Arentz wrote:

 Stuart Turner [EMAIL PROTECTED] writes:
 
 Hi Everyone,
 
 I'm working hard trying to get Python 'accepted' in the organisation I
 work
 for.  I'm making some good in-roads.  One chap sent me the text below on
 his views of Python.  I wondered if anyone from the group could give me
 some advice on how to respond / if they had been in a similar position.
 
 What do you want to use Python for? What do you use now?
 
  S.

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


Re: Class Variable Access and Assignment

2005-11-03 Thread Steve Holden
Antoon Pardon wrote:
 Op 2005-11-03, Steven D'Aprano schreef [EMAIL PROTECTED]:
 
 
There are two possible fixes, either by prohibiting instance variables
with the same name as class variables, which would allow any reference
to an instance of the class assign/read the value of the variable. Or
to only allow class variables to be accessed via the class name itself.

There is also a third fix: understand Python's OO model, especially
inheritance, so that normal behaviour no longer surprises you.
 
 
 No matter wat the OO model is, I don't think the following code
 exhibits sane behaviour:
 
 class A:
   a = 1
 
 b = A()
 b.a += 2
 print b.a
 print A.a
 
 Which results in
 
 3
 1
 
I don't suppose you'd care to enlighten us on what you'd regard as the 
superior outcome?

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


Re: Getting Python Accepted in my Organisation

2005-11-03 Thread Stefan Arentz
Stuart Turner [EMAIL PROTECTED] writes:

 I'm already using it for a ton of things - I want to try and get broader
 acceptance in the organisation for it to be made and 'officially supported
 product'.

IMO that is what you need to communicate: 'already using it for a ton of
things' and probably adding 'being more productive than with tool XYZ'

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


Re: OT - Re: Microsoft Hatred FAQ

2005-11-03 Thread Steven D'Aprano
On Thu, 03 Nov 2005 04:34:20 -0500, Tim Daneliuk wrote:


 A) I don't much care if people wander off topic from time to time -
 that's what filters are for.  But as a matter of general courtesy
 is it too much to ask that the subject line be so marked?

Fair enough.

 B) Rhetoric is not Reality.  Crime has a very specific definition.
 It always has one or more of Fraud, Force, or Threat.

Nonsense.

Jaywalking is a crime. So is littering. So is merely belonging to certain
organisations, such as the German Nazi party or any number of allegedly
terrorist groups. Walking around naked in public is a crime, and in many
places in the world, including the USA, you then become a registered sex
offender for the rest of your life. (So much for doing time and wiping
the slate clean.)

Possession of many substances is a crime in the USA, and not just drugs
of addiction. There is no Fraud, Force or Threat involved in growing
cannabis in your backyard, or selling pornography to teenagers, or driving
without a licence.

Possession of banned books is a crime in many countries, and yes even in
the 21st century there are many, many banned books. If legislation being
urged on the US Senate by the MPAA is passed, manufacturing, selling and
possibly even possession of analog to digital devices will become a crime
-- not just a civil offense, or a misdemeanor, but a felony.

Even *accidents* can be crimes, if the circumstances are right (or perhaps
I should say wrong). The act of manslaughter is still a crime, even if it
does not include Fraud, Force or Threat. Failing to do you job can land
you in jail, if people die because of your negligence.


 No such
 case against Microsoft has ever been levied.

That is, if you ignore all the dozens of times Microsoft has either
settled out of court or been found guilty of crimes by juries.


 Just because *you*
 don't like market outcomes doesn't make it a crime.

In civilizations that believe in freedom for human beings, freedom is not
unlimited. There are actions which remain forbidden, even though that
limits individual freedom. Bill Gates is not permitted to lock you up
against your will: his freedom to restrict others' freedoms is severely
curtailed.

In civilizations that believe in free markets, freedom is also not
unlimited. There are actions which are forbidden, because those actions
restrict the freedom of others. Microsoft has been found guilty of
deliberately committing those illegal acts, in Japan, Europe and even the
USA. Just as Bill Gates can't legally hire henchmen to drag you away and
lock you up in his basement, so he can't legally use economic punishment
against anyone who would buy your goods or services, and for the same
reason: his actions will infringe your freedoms.

Those who believe in free markets understand that unrestricted freedom
leads to the biggest bully limiting the freedoms of others. But then there
are those that defend the right of bullies to limit the freedom of others.


 C) Hate Microsoft all you want.  But those of us old enough to have
 actually done this for than 10 minutes recall the days where every single
 hardware vendor was also a unique software and systems vendor.
 Absent a Microsoft/Intel-style de facto standard, you'd never have
 seen the ascent of Linux or Open Source as it exists today.

Nonsense again.

Real standards, like TCP/IP which is the backbone of the Internet, aren't
controlled by any one company. Anyone can create a TCP stack. Nobody but
Microsoft can create a competing version of Windows. TCP/IP became a
standard long before Microsoft even acknowledged it's existence. So did
ASCII, the IBM BIOS, and serial ports, to name just a few. Does the term
ISO standard mean anything to you?

Intel-compatible hardware is a true de facto standard, because there are
actual competitors to Intel who product compatible but different hardware.
AMD CPUs are different from Intel, but you can run the same copy of
Windows on either and get the same results. The same can't be said of the
Windows standard -- there is Microsoft Windows, and there is nothing
else. While OS X or Linux or Solaris might do much the same sort of things
as Windows, they aren't Windows-compatible in the same way that AMD and
Intel CPUs are compatible. At best they can interoperate with Windows, or
share data with Windows.

You do your argument no favours by trying to confabulate the Microsoft
monopoly in software with Intel's lack of monopoly. Intel has to compete
in a free market, and hardware costs have fallen hugely: my first PC cost
me AUD$4000 in 1986. Today I can get a machine a thousand times more
powerful for $800. The first time I bought Microsoft Word and Excel, I
paid around $100 each for them. MS Office retails at over $800 today, and
you get very little extra functionality that didn't exist in 1986, lots
more meaningless bells and whistles, and no printed documentation.

In the same time that hardware has fallen in 

Re: OT - Re: Microsoft Hatred FAQ

2005-11-03 Thread Jerzy Karczmarczuk
Steven D'Aprano wrote:

 Jaywalking is a crime. So is littering. So is merely belonging to certain
 organisations, such as the German Nazi party or any number of allegedly
 terrorist groups. Walking around naked in public is a crime, and in many
 places in the world, including the USA, you then become a registered sex
 offender for the rest of your life. (So much for doing time and wiping
 the slate clean.)
 
 Possession of many substances is a crime in the USA, and not just drugs
 of addiction. There is no Fraud, Force or Threat involved in growing
 cannabis in your backyard, or selling pornography to teenagers, or driving
 without a licence.
 
 Possession of banned books is a crime in many countries,  [enough ...]

Now, tell me: is the polluting of a newsgroup with off-topic postings,
a crime, and if yes then what?


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


Re: Class Variable Access and Assignment

2005-11-03 Thread Antoon Pardon
Op 2005-11-03, Stefan Arentz schreef [EMAIL PROTECTED]:
 Antoon Pardon [EMAIL PROTECTED] writes:

 Op 2005-11-03, Steven D'Aprano schreef [EMAIL PROTECTED]:
 
  There are two possible fixes, either by prohibiting instance variables
  with the same name as class variables, which would allow any reference
  to an instance of the class assign/read the value of the variable. Or
  to only allow class variables to be accessed via the class name itself.
 
  There is also a third fix: understand Python's OO model, especially
  inheritance, so that normal behaviour no longer surprises you.
 
 No matter wat the OO model is, I don't think the following code
 exhibits sane behaviour:
 
 class A:
   a = 1
 
 b = A()
 b.a += 2
 print b.a
 print A.a
 
 Which results in
 
 3
 1

 I find it confusing at first, but I do understand what happens :-)

I understand what happens too, that doesn't make it sane behaviour.

 But really, what should be done different here?

I don't care what should be different. But a line with only one
referent to an object in it, shouldn't be referring to two different
objects.

In the line: b.a += 2, the b.a should be refering to the class variable
or the object variable but not both. So either it could raise an
attribute error or add two to the class variable.

Sure one could object to those sematics too, but IMO they are preferable
to what we have now.

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


Re: Class Variable Access and Assignment

2005-11-03 Thread Paul Rubin
Steve Holden [EMAIL PROTECTED] writes:
  class A:
a = 1
  b = A()
  b.a += 2
  print b.a
  print A.a
  Which results in
  3
  1
 
 I don't suppose you'd care to enlighten us on what you'd regard as the
 superior outcome?

class A:
  a = []
b = A()
b.append(3)
print b.a
print a.a

Compare and contrast.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Class Variable Access and Assignment

2005-11-03 Thread Steven D'Aprano
On Thu, 03 Nov 2005 11:55:06 +, Antoon Pardon wrote:

 No matter wat the OO model is, I don't think the following code
 exhibits sane behaviour:
 
 class A:
   a = 1
 
 b = A()
 b.a += 2
 print b.a
 print A.a
 
 Which results in
 
 3
 1

Seems perfectly sane to me. 

What would you expect to get if you wrote b.a = b.a + 2? Why do you expect
b.a += 2 to give a different result?

Since ints are immutable objects, you shouldn't expect the value of b.a
to be modified in place, and so there is an assignment to b.a, not A.a.

On the other hand, if this happened:

py class A:
... a = []
... 
py b = A()
py b.a.append(None)
py print b.a, A.a
[None], []

*then* you should be surprised.

(Note that this is not what happens: you get [None], [None] as expected.
The difference is that append modifies the mutable list in place.)



-- 
Steven.

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


wxGlade will not run on my machine

2005-11-03 Thread LenS
I have installed wxGlade on a MS XP machine.  It executed on completion
of the install.  However,  when I try to double click on the wxGlade
icon to start nothing happens.  I searched the NG and found that this
had been report before but no solution was posted.  I am running the
following versions;

Python 2.4.1
wxPython 2.6.1.0

Would like to give wxGlade a try.

Len Sumnler

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


Re: Class Variable Access and Assignment

2005-11-03 Thread Stefan Arentz
Antoon Pardon [EMAIL PROTECTED] writes:

...

  No matter wat the OO model is, I don't think the following code
  exhibits sane behaviour:
  
  class A:
a = 1
  
  b = A()
  b.a += 2
  print b.a
  print A.a
  
  Which results in
  
  3
  1
 
  I find it confusing at first, but I do understand what happens :-)
 
 I understand what happens too, that doesn't make it sane behaviour.
 
  But really, what should be done different here?
 
 I don't care what should be different. But a line with only one
 referent to an object in it, shouldn't be referring to two different
 objects.

It doesn't.

 In the line: b.a += 2, the b.a should be refering to the class variable
 or the object variable but not both. So either it could raise an
 attribute error or add two to the class variable.

It does exactly what you say. It adds 2 to the a *instance variable* of
the object instance in 'b'. It doesn't touch the *class variable* A.a
which is still 1.

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


Release of PyPy 0.8.0

2005-11-03 Thread Carl Friedrich Bolz
pypy-0.8.0: Translatable compiler/parser and some more speed
==

The PyPy development team has been busy working and we've now packaged
our latest improvements, completed work and new experiments as
version 0.8.0, our third public release.

The highlights of this third release of PyPy are:

- Translatable parser and AST compiler. PyPy now integrates its own
   compiler based on Python own 'compiler' package but with a number
   of fixes and code simplifications in order to get it translated
   with the rest of PyPy.  This makes using the translated pypy
   interactively much more pleasant, as compilation is considerably
   faster than in 0.7.0.

- Some Speed enhancements. Translated PyPy is now about 10 times
   faster than 0.7 but still 10-20 times slower than
   CPython on pystones and other benchmarks.  At the same time,
   language compliancy has been slightly increased compared to 0.7
   which had already reached major CPython compliancy goals.

- Some experimental features are now translateable.  Since 0.6.0, PyPy
   shipped with an experimental Object Space (the part of PyPy
   implementing Python object operations and manipulation) implementing
   lazily computed objects, the Thunk object space. With 0.8.0 this
   object space can also be translated preserving its feature
   additions.

What is PyPy (about)?


PyPy is a MIT-licensed research-oriented reimplementation of
Python written in Python itself, flexible and easy to
experiment with.  It translates itself to lower level
languages.  Our goals are to target a large variety of
platforms, small and large, by providing a compilation toolsuite
that can produce custom Python versions.  Platform, Memory and
Threading models are to become aspects of the translation
process - as opposed to encoding low level details into a
language implementation itself.  Eventually, dynamic
optimization techniques - implemented as another translation
aspect - should become robust against language changes.

Note that PyPy is mainly a research and development project
and does not by itself focus on getting a production-ready
Python implementation although we do hope and expect it to
become a viable contender in that area sometime next year.

PyPy is partially funded as a research project under the
European Union's IST programme.

Where to start?
-

Getting started: 
http://codespeak.net/pypy/dist/pypy/doc/getting-started.html

PyPy Documentation: http://codespeak.net/pypy/dist/pypy/doc/

PyPy Homepage:  http://codespeak.net/pypy/

The interpreter and object model implementations shipped with
the 0.8 version can run on their own and implement the core
language features of Python as of CPython 2.4.  However, we still
do not recommend using PyPy for anything else than for education,
playing or research purposes.

Ongoing work and near term goals
-

At the last sprint in Paris we started exploring the new directions of
our work, in terms of extending and optimising PyPy further. We
started to scratch the surface of Just-In-Time compiler related work,
which we still expect will be the major source of our future speed
improvements and some successful amount of work has been done on the
support needed for stackless-like features.

This release also includes the snapshots in preliminary or embryonic
form of the following interesting but yet not completed sub projects:

- The OOtyper, a RTyper variation for higher-level backends
   (Squeak, ...)
- A JavaScript backend
- A limited (PPC) assembler backend (this related to the JIT)
- some bits for a socket module

PyPy has been developed during approximately 16 coding sprints across
Europe and the US.  It continues to be a very dynamically and
incrementally evolving project with many of these one-week workshops
to follow.

PyPy has been a community effort from the start and it would
not have got that far without the coding and feedback support
from numerous people.   Please feel free to give feedback and
raise questions.

 contact points: http://codespeak.net/pypy/dist/pypy/doc/contact.html


have fun,

 the pypy team, (Armin Rigo, Samuele Pedroni,
 Holger Krekel, Christian Tismer,
 Carl Friedrich Bolz, Michael Hudson,
 and many others: 
http://codespeak.net/pypy/dist/pypy/doc/contributor.html)

PyPy development and activities happen as an open source project
and with the support of a consortium partially funded by a two
year European Union IST research grant. The full partners of that
consortium are:

 Heinrich-Heine University (Germany), AB Strakt (Sweden)
 merlinux GmbH (Germany), tismerysoft GmbH (Germany)
 Logilab Paris (France), DFKI GmbH (Germany)
 ChangeMaker (Sweden), Impara (Germany)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to write a blog system with Python

2005-11-03 Thread ice
Thanks for all your comments.
What I wanted is a chance to practise my programming talents with
Python.

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


Re: Class Variable Access and Assignment

2005-11-03 Thread Steve Holden
Paul Rubin wrote:
 Steve Holden [EMAIL PROTECTED] writes:
 
class A:
  a = 1
b = A()
b.a += 2
print b.a
print A.a
Which results in
3
1


I don't suppose you'd care to enlighten us on what you'd regard as the
superior outcome?
 
 
 class A:
   a = []
 b = A()
 b.append(3)
 print b.a
 print a.a
 
 Compare and contrast.

append() guarantees to modify a mutable object in place. Augmented 
assignment operations don't,but are normally equivalent to

   name = name operator value

In the former case exactly such semantics are implemented. I still don;t 
see anyone suggesting a better outcome for the augmented assignment.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


Re: Class Variable Access and Assignment

2005-11-03 Thread Antoon Pardon
Op 2005-11-03, Stefan Arentz schreef [EMAIL PROTECTED]:
 Antoon Pardon [EMAIL PROTECTED] writes:

 ...

  No matter wat the OO model is, I don't think the following code
  exhibits sane behaviour:
  
  class A:
a = 1
  
  b = A()
  b.a += 2
  print b.a
  print A.a
  
  Which results in
  
  3
  1
 
  I find it confusing at first, but I do understand what happens :-)
 
 I understand what happens too, that doesn't make it sane behaviour.
 
  But really, what should be done different here?
 
 I don't care what should be different. But a line with only one
 referent to an object in it, shouldn't be referring to two different
 objects.

 It doesn't.

Yes it does. If the b.a refers to the instance variable, then an
AttributeError should be raised, because the instance variable doesn't
exist yet, so you can't add two to it.

If the b.a refers to the class variable then two should be added to it.

Neither happens instead we get some hybrid in which an instance varible
is created that gets the value of class variable incrented by two.

 In the line: b.a += 2, the b.a should be refering to the class variable
 or the object variable but not both. So either it could raise an
 attribute error or add two to the class variable.

 It does exactly what you say. It adds 2 to the a *instance variable* of
 the object instance in 'b'.

There is no instance variable at that point. How can it add 2, to
something that doesn't exist at the moment.

 It doesn't touch the *class variable* A.a which is still 1.

But it accesses the class variable.

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


Re: Filepath string manipulation help

2005-11-03 Thread mjakowlew
Thanks guys. The os.path method works, but this is for a script for a
website upload program on a zope webserver. For some reason even admin
access won't let me run the script through the server.

The main issue with my script is that Firefox has no problem with the
program the way it is, but IE somehow uses a different filename format.

ex:/

In IE
filepath='c:\documents\web\zope\file.ext'

In Firefox
filepath='file.ext'

So when IE goes to upload the file, it gets an error for illegal
characters because of the \'s and : Is there another way to do this
(extract just the filename) using something else other than the os
that won't be blocked by the webserver

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


Re: [OT] Gmane/Tunderbird users: is g.c.p.general too big?

2005-11-03 Thread Steve Holden
Robert Kern wrote:
 Steve Holden wrote:
 
Sorry about this almost off-topic post, but I am guessing there must be 
other readers of this group who use Thunderbird (in my case 1.0.2) to 
access it as gmane.comp.general.python.

I'm currently showing 344,548 articles in the group due to the gmane 
policy of permanent retention, and lately it seems to have started 
taking forever to switch from mailboxes to the newsgroup. Furthermore, 
the Thunderbird process's memory usage climbs from ~30MB reading mail to 
over 200MB reading the newsgroup.

Has anyone else noticed this, or is it specific to my setup? Does anyone 
have a solution?
 
 
 You can specify a policy for keeping old messages for each server
 account. Go to your Account Settings for GMane and look in Offline 
 Disk Space. You can choose to keep all messages, the newest N messages,
 or messages from the past N days.
 
Thanks, that's done it. A few days ago Thunderbird had a giddy fit and 
suddenly decided that every article on the server was unread. I don't 
know what happened, but after resetting the Thunderbird policy for the 
group (and waiting three minutes for it to comb through everything) all 
is well again.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


Re: Class Variable Access and Assignment

2005-11-03 Thread Antoon Pardon
Op 2005-11-03, Steven D'Aprano schreef [EMAIL PROTECTED]:
 On Thu, 03 Nov 2005 11:55:06 +, Antoon Pardon wrote:

 No matter wat the OO model is, I don't think the following code
 exhibits sane behaviour:
 
 class A:
   a = 1
 
 b = A()
 b.a += 2
 print b.a
 print A.a
 
 Which results in
 
 3
 1

 Seems perfectly sane to me. 

 What would you expect to get if you wrote b.a = b.a + 2?

I would expect a result consistent with the fact that both times
b.a would refer to the same object.

 Why do you expect
 b.a += 2 to give a different result?

I didn't know I did.

 Since ints are immutable objects, you shouldn't expect the value of b.a
 to be modified in place, and so there is an assignment to b.a, not A.a.

You are now talking implementation details. I don't care about whatever
explanation you give in terms of implementation details. I don't think
it is sane that in a language multiple occurence of something like b.a
in the same line can refer to different objects

I think it even less sane, if the same occurce of b.a refers to two
different objects, like in b.a += 2

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


Re: XML DOM: XML/XHTML inside a text node

2005-11-03 Thread Paul Boddie
Roman Suzi wrote:

 On Thu, 2 Nov 2005 [EMAIL PROTECTED] wrote:
  Is there a better way?

 What about parsing the input into XML first? Is there any point in including
 unescaped code into XML document unless it is XML itself?

Indeed. My approach would be to parse the user's input using the
parseString function, to get the root element of this newly parsed
document, and then to import that element into the existing document
using importNode. The imported document information could then be
inserted into the existing document at a suitable place. For example:

user_doc = xml.dom.minidom.parseString(user_input)
# NOTE: Check for element or use XPath here...
user_doc_root = user_doc.childNodes[0]
imported_root = existing_doc.importNode(user_doc_root, 1)
existing_doc_location.appendChild(imported_root)

Paul

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


Re: Getting Python Accepted in my Organisation

2005-11-03 Thread Kay Schluehr

Stefan Arentz wrote:
 Stuart Turner [EMAIL PROTECTED] writes:

  I'm already using it for a ton of things - I want to try and get broader
  acceptance in the organisation for it to be made and 'officially supported
  product'.

 IMO that is what you need to communicate: 'already using it for a ton of
 things' and probably adding 'being more productive than with tool XYZ'

  S.

It didn't work well in my case. I still use Python for tons of things
but it didn't change the attitudes of my co-workers towards learning a
new language. It just changed my status as a programmer inside of the
department. And remember: Python is still cutting edge as a language
but sub-standard when it comes to tool support i.e. you do not have to
introduce just a language but a different culture of programming as it
is common sense now. 

Kay

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


Re: Python for .NET and IronPython

2005-11-03 Thread Luis M. Gonzalez
I just want to clarify that the above mentioned web site
(www.ironpython.com) is no longer maintained.
If you want to get updated information on IronPython, you should visit
this site:
www.gotdotnet.com/Workspaces/Workspace.
aspx?id=ad7acff7-ab1e-4bcb-99c0-57ac5a3a9742

Or the mailing list here:
http://lists.ironpython.com/pipermail/users-ironpython.com/

By the way, the current version is 0.9.3 and it's advancing at a pretty
fast pace towards version 1.0.

Luis

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


Re: Getting Python Accepted in my Organisation

2005-11-03 Thread Steve Holden
Stuart Turner wrote:
 Hi Everyone,
 
 I'm working hard trying to get Python 'accepted' in the organisation I work
 for.  I'm making some good in-roads.  One chap sent me the text below on
 his views of Python.  I wondered if anyone from the group could give me
 some advice on how to respond / if they had been in a similar position.
 
 Any help appreciated,
 
 Thanks in advance,
 
 - Stuart
 
 
  Python is a scripting language like Perl, awk, tcl, Java etc...  it is
 not quite a fully developed OO language, but does support some OO that Perl
 doesn't.  To be clear, these scripting languages have their place in our
 environment, but they are not full replacements for C#, Java, C, etc... 
 because they do not come with the full range of libraries e.g GDI
 libraries.  Python has to be compared to Perl, Awk in order to evaluate it. 
 Perl, until recently, did not support threading.  Why would it? it is a
 scripting language and can run async shell commands.  I would be interested
 to learn if Python supports a robust threading model (not just a pointer
 reference to an object), as this is a significant drawback when using a
 scripting language.  CGI only works because the container can thread with
 Perl.  Python is object orientated, but I do not know what implementation? 
 Essentially any language with a pointer can claim to be OO, although Python
 does market itself on OO capabilities.  Do you know what implementation
 they have used?
   
 Lets discuss, as I am not a great fan of Perl and if Python is more
 structured then it is possibly worth promoting.

First of all, let's dismiss the notion that Python is a scripting 
language. It can be used for scripting tasks, and has been successfully 
so used in many environments, but it's a fully-developed programming 
language with a well-defined and cleanly-implemented OO model. Many 
people call Python a scripting language because it is interpreted, but 
the parallel with Java is better that that with Perl, since Python 
compiles programs into bytecodes for a virtual machine.

An advantage of Python is that while it is fully object-oriented it is 
also well-suited to procedural programming and, unlike Java, you are not 
forced to try and fit all tasks into an object-oriented model.

Python does indeed support a robust threading model, and has recently 
improved threading support still further by adding explicit features to 
support per-thread state in a cleaner way. It has been used to implement 
many high-volume asynchronous network server tasks, among which Zope is 
perhaps the best known.

The author of your comments asks what implementation of OO 
capabilities Python uses. This is a very broad question, but basically 
Python uses a multiple-inheritance model (though nobody is forced to use 
multiple superclasses) and has a very clean object orientation.

For background I have been studying and working with object oriented 
languages for over thirty years, and find Python the most natural and 
cleanest way to express many object oriented programming solutions.

Finally I feel that the Python community is much more welcoming than 
that of most programming languages, which is important if you are 
looking for support as your familiarity with the language grows.

Good luck with your Python advocacy.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

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


Re: Class Variable Access and Assignment

2005-11-03 Thread Antoon Pardon
Op 2005-11-03, Steve Holden schreef [EMAIL PROTECTED]:
 Antoon Pardon wrote:
 Op 2005-11-03, Steven D'Aprano schreef [EMAIL PROTECTED]:
 
 
There are two possible fixes, either by prohibiting instance variables
with the same name as class variables, which would allow any reference
to an instance of the class assign/read the value of the variable. Or
to only allow class variables to be accessed via the class name itself.

There is also a third fix: understand Python's OO model, especially
inheritance, so that normal behaviour no longer surprises you.
 
 
 No matter wat the OO model is, I don't think the following code
 exhibits sane behaviour:
 
 class A:
   a = 1
 
 b = A()
 b.a += 2
 print b.a
 print A.a
 
 Which results in
 
 3
 1
 
 I don't suppose you'd care to enlighten us on what you'd regard as the 
 superior outcome?

No. I don't think a superior outcome is necessary to see that this is
not sane behaviour. I don't care that much on how it gets fixed.

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


__slots__ and class attributes

2005-11-03 Thread Ewald R. de Wit
I'm running into a something unexpected  for a new-style class
that has both a class attribute and __slots__ defined. If the
name of the class attribute also exists in __slots__, Python
throws an AttributeError. Is this by design (if so, why)?

class A( object ):
__slots__ = ( 'value', )
value = 1

def __init__( self, value = None ):
self.value = value or A.value

a = A()
print a.value


Traceback (most recent call last):
  File t1.py, line 8, in ?
a = A()
  File t1.py, line 6, in __init__
self.value = value or A.value
AttributeError: 'A' object attribute 'value' is read-only


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


Re: Class Variable Access and Assignment

2005-11-03 Thread Sybren Stuvel
Antoon Pardon enlightened us with:
 I would expect a result consistent with the fact that both times b.a
 would refer to the same object.

b.a is just a name, not a pointer to a spot in memory. Getting the
value associated with that name is something different from assigning
a new value to that name.

Sybren
-- 
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself? 
 Frank Zappa
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Getting Python Accepted in my Organisation

2005-11-03 Thread [EMAIL PROTECTED]
How about, Google use python extensively ? This I believe is a very
strong argument for any concern about python.

However, policy in organisations can be very funny and many of them may
be set long time ago which even though may no longer be relavent are
still policy.

I would suggest focus on why the policy(like why distinguish between
script vs compiled language, as the rationale behind it can be
performance) and address it accordingly rather than taking literal
arguments.

Stuart Turner wrote:
 Hi Everyone,

 I'm working hard trying to get Python 'accepted' in the organisation I work
 for.  I'm making some good in-roads.  One chap sent me the text below on
 his views of Python.  I wondered if anyone from the group could give me
 some advice on how to respond / if they had been in a similar position.

 Any help appreciated,

 Thanks in advance,

 - Stuart


  Python is a scripting language like Perl, awk, tcl, Java etc...  it is
 not quite a fully developed OO language, but does support some OO that Perl
 doesn't.  To be clear, these scripting languages have their place in our
 environment, but they are not full replacements for C#, Java, C, etc...
 because they do not come with the full range of libraries e.g GDI
 libraries.  Python has to be compared to Perl, Awk in order to evaluate it.
 Perl, until recently, did not support threading.  Why would it? it is a
 scripting language and can run async shell commands.  I would be interested
 to learn if Python supports a robust threading model (not just a pointer
 reference to an object), as this is a significant drawback when using a
 scripting language.  CGI only works because the container can thread with
 Perl.  Python is object orientated, but I do not know what implementation?
 Essentially any language with a pointer can claim to be OO, although Python
 does market itself on OO capabilities.  Do you know what implementation
 they have used?

 Lets discuss, as I am not a great fan of Perl and if Python is more
 structured then it is possibly worth promoting.

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


Re: Class Variable Access and Assignment

2005-11-03 Thread venk
You see,
 The seen behavior is due to the result of python's name
binding,scoping scheme.
Let me give you an example,
 class A:
 i=0
 def t(self):
 print self.i
 self.i=4
then
a=A()
a.i is 0
a.t()
then,
A.i is 0
a.i is 4

In the function, it first searches for i in its local scope, on not
finding it, accesses the class object's i.
then the next line, is an assignment, which binds (creates a new
variable) in the instance's scope. you can use the buit-in id function
to verify it.

the same thing happens in the case of b.a = b.a + 2  search for b.a
not found, read the value from the enclosing scope (of the class
object) then assign b.a to the local scope, with the value 3.

But, I think your question about the sanity of the behaviour should be
analysed sincerely

if,
k=0
def f():
   print k
   k=k+1
raises UnboundLocalError, then how is it accepted in the former case?
hmmm

maybe, my arguments are hapazard but, i'll get to know when i'm
flamed ;)

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


Re: Python for .NET and IronPython

2005-11-03 Thread Gerard Flanagan

John Salerno wrote:
 Hi all. I'm currently learning C#, and I'm also interested in learning
 Python

In a similar position to yourself - learning both languages - I can
definitely recommend Python ( though C# 's curly brackets might annoy
you more than they did before!!)

 so it seems like a decent
 idea to want to integrate the two

FWIW, what I've been doing lately is calling Python scripts from
Windows.Forms apps, capturing their 'StdOut'.  There's an article on
http://www.thecodeproject.com which explains how you can do this
asynchronously, but the following (C#) code is what I'm using ( imagine
a Windows Form with a TextBox to enter the script name, another to
enter any arguments for the script, and 'Run', 'Cancel' and 'Browse'
CommandButtons).


(assumes the script requires no user interaction)

private void BrowseForScript_Click(object sender, System.EventArgs e)
{
if ( this.openFileDialog.ShowDialog() == DialogResult.OK )
{
this.txtIO.Clear();
this.txtIO.Focus();
this.txtIO.AppendText( openFileDialog.FileName);
}
}

private void Run_Click(object sender, System.EventArgs e)
{
System.Diagnostics.ProcessStartInfo startInfo;
System.Diagnostics.Process process;
string directory;
string pyArgs;
string script;

script = this.txtIO.Text.Trim();

if ( script == null || script.Length == 0 )
{
return;
}

try
{
directory = Path.GetDirectoryName( script );
script = Path.GetFileName( script );
}
catch (ArgumentException)
{
MessageBox.Show(The script file path contains invalid 
characters.,
Invalid Script Path,
MessageBoxButtons.OK,
MessageBoxIcon.Error);
return;
}

if ( script.Length == 0 )
{
MessageBox.Show(No script file has been specified.,
Invalid Script Path,
MessageBoxButtons.OK,
MessageBoxIcon.Error);
return;
}

if ( directory == null || directory.Length == 0 )
{
directory = DEFAULT_SCRIPT_DIRECTORY;
}

pyArgs = this.txtArgs.Text.Trim();

startInfo = new ProcessStartInfo(python);
startInfo.WorkingDirectory = directory;
startInfo.Arguments = script +   + pyArgs;
startInfo.UseShellExecute = false;
startInfo.CreateNoWindow = true;
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardError = true;

process = new Process();
process.StartInfo = startInfo;
process.Start();

string s;
while ((s = process.StandardOutput.ReadLine()) != null)
{
this.__application.Write( s + \n );
}

while ((s = process.StandardError.ReadLine()) != null)
{
this.__application.Write( s + \n );
}
}


Gerard

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


Re: Class Variable Access and Assignment

2005-11-03 Thread Antoon Pardon
Op 2005-11-03, venk schreef [EMAIL PROTECTED]:
 You see,
  The seen behavior is due to the result of python's name
 binding,scoping scheme.

I know what causes the behaviour. But I still think it is
not sane behaviour.


 ...

 the same thing happens in the case of b.a = b.a + 2  search for b.a
 not found, read the value from the enclosing scope (of the class
 object) then assign b.a to the local scope, with the value 3.

This is an explanation depending on a specific implementation.

Now can you give me a language design argument that supports the 
idea that in b.a = b.a + 2 b.a refers to two different objects.

And even if you could do that, can you give such an argument that
in b.a += 2 that one occurence of b.a should refer to two different
objects.

Suppose I have code like this:

  for i in xrange(1,11):
b.a = b.a + i

Now the b.a on the right hand side refers to A.a the first time through
the loop but not the next times. I don't think it is sane that which
object is refered to depends on how many times you already went through
the loop.

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


installing PygreSQL and psychopg2 modules (a newbie question)

2005-11-03 Thread Zlatko Matić




Hello.
I was trying to install PygreSQL and psychopg2 in 
order to use python as front-end for PostgreSQL, on WIndows XP. 
When I tried to install by calling setup.py from 
command prompt ("setup.py install"), in both cases I had the same 
error:

"error: Python was built with version 7.1 of Visual 
Studio, and extensions need to be built with the same version of the compiler, 
but it isn't installed."

It looks like 
this:"C:\Downloads\Python\psychopg\psycopg2-2.0b5\psycopg2-2.0b5setup.py 
installrunning installrunning buildrunning build_pyrunning 
build_extbuilding 'psycopg2._psycopg' extensionerror: Python was built 
with version 7.1 of Visual Studio, and extensions need to be built with 
the same version of the compiler, but it isn't 
installed.C:\Downloads\Python\psychopg\psycopg2-2.0b5\psycopg2-2.0b5pausePress 
any key to continue . . ."
What does it mean ? What am I supposed to 
do?

Thanks,

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

Re: Class Variable Access and Assignment

2005-11-03 Thread Antoon Pardon
Op 2005-11-03, Sybren Stuvel schreef [EMAIL PROTECTED]:
 Antoon Pardon enlightened us with:
 I would expect a result consistent with the fact that both times b.a
 would refer to the same object.

 b.a is just a name, not a pointer to a spot in memory. Getting the
 value associated with that name is something different from assigning
 a new value to that name.

If that was all to it, one would expect the following to work to:

 a = 1
 def f():
...   a += 2
...
 f()

Traceback (most recent call last):
File stdin, line 1, in ?
File stdin, line 2, in f
UnboundLocalError: local variable 'a' referenced before assignment

But I'll word it differently:

I would expect a result consistent with the fact that both times
b.a would be resolved in the same name space.

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


Re: OT - Re: Microsoft Hatred FAQ

2005-11-03 Thread venk
Hi,
 Though out of the streamline, I find your post to be one of the most
reasonable and well-formed arguments I have read in a long time. Keep
it up. Great work.

Steven D'Aprano wrote:
Real standards, like TCP/IP which is the backbone of the Internet,
aren't
controlled by any one company. Anyone can create a TCP stack. Nobody
but
Microsoft can create a competing version of Windows. TCP/IP became a
standard long before Microsoft even acknowledged it's existence. So did
ASCII, the IBM BIOS, and serial ports, to name just a few. Does the
term
ISO standard mean anything to you?

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


Re: Class Variable Access and Assignment

2005-11-03 Thread Stefan Arentz
Antoon Pardon [EMAIL PROTECTED] writes:

 Op 2005-11-03, venk schreef [EMAIL PROTECTED]:
  You see,
   The seen behavior is due to the result of python's name
  binding,scoping scheme.
 
 I know what causes the behaviour. But I still think it is
 not sane behaviour.
 
 
  ...
 
  the same thing happens in the case of b.a = b.a + 2  search for b.a
  not found, read the value from the enclosing scope (of the class
  object) then assign b.a to the local scope, with the value 3.
 
 This is an explanation depending on a specific implementation.
 
 Now can you give me a language design argument that supports the 
 idea that in b.a = b.a + 2 b.a refers to two different objects.
 
 And even if you could do that, can you give such an argument that
 in b.a += 2 that one occurence of b.a should refer to two different
 objects.

Your problem is a namespace conflict together with a certain
stubborness about lookup order :-)

It is really simple. When you say b.a then the instance variable 'a'
is looked up first. If it does not exist then a class variable lookup
is done.

Remember, Python is a dynamic language.

It is all according to how things have been in Python for a long time.

The real issue here is that you should propery name class variables so
that there can't be any confusion about class or instance scope. I use
all uppercase identifiers for class variables for example.

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


Re: Most efficient way of storing 1024*1024 bits

2005-11-03 Thread Alex Stapleton

On 3 Nov 2005, at 05:03, Alex Martelli wrote:

 Brandon K [EMAIL PROTECTED] wrote [inverting his topposting!]:


 Six megabytes is pretty much nothing on a modern computer.



 BTW, it'd be 6 megabits or 750kb ;)


 ...but Mike was proposing using one digit per bit, hence, 6 megabytes.
 That makes it easy to search for bitpatterns with re or  
 string.find; if
 the bits were packed 8 to a byte, such searches would be very hard.


They would just require some out-of-the-box thinking using character  
arrays and stuff I think. It's definately still doable with regex's  
if you really want to.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Class Variable Access and Assignment

2005-11-03 Thread venk
hey,
 did  u read my reply fully? i too feel that this matter of raising
unbound local error in one case and not raising it in the other must be
analysed...

quoting from the documentation
If a name binding operation occurs anywhere within a code block, all
uses of the name within the block are treated as references to the
current block. This can lead to errors when a name is used within a
block before it is bound. This rule is subtle. Python lacks
declarations and allows name binding operations to occur anywhere
within a code block. The local variables of a code block can be
determined by scanning the entire text of the block for name binding
operations.

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


Re: Getting Python Accepted in my Organisation

2005-11-03 Thread Roy Smith
Stuart Turner [EMAIL PROTECTED] wrote:
  Python is a scripting language like Perl, awk, tcl, Java etc...

It is difficult to say whether Python is a scripting language or not until 
you define what you mean by scripting language.  People throw the term 
scripting language around with wild abandon these days.  As far as I can 
tell, what they usually mean is something like, It's not C++, or perhaps 
somewhat more generally, It doesn't fit the compile-link-load-execute 
model I learned in college 20 years ago.

 it is not quite a fully developed OO language

Ask the guy in what way he thinks it's not quite fully developed.  My guess 
is he doesn't really know, or perhaps will latch onto something like it 
doesn't have private data.  That is true, but only partially so.  And for 
people who are hung up on that, you can point out that it's also only 
partially true about C++.

Some people have been working with C++ and Java for so long they have 
started to think that OO means The way C++ and Java do things, which 
pretty much means static typing and complex access control models.  It 
doesn't have to be that way.

 To be clear, these scripting languages have their place in our
 environment, but they are not full replacements for C#, Java, C, etc...

With this I am in complete agreement.  A good craftsman keeps a wide 
selection of tools at his or her disposal.  Each is useful for some tasks, 
can be pressed into service for many more, and is utterly wrong for others.

 because they do not come with the full range of libraries e.g GDI
 libraries.

No language has libraries for everything you might ever possibly want to 
do.  Python has a wide range of libraries for many common tasks, but my no 
means all.  Still, if it comes down to language X has a good library for 
what we need and language Y doesn't, that will often be (and rightly so) 
the decision maker as to which language to use.

 Python has to be compared to Perl, Awk in order to evaluate it.

Comparing Python to Perl makes a lot of sense, but comparing it to Awk is 
absurd.   What Awk provides is decent flow control (including an implicit 
read-match-execute outer loop), excellent pattern matching, automatic 
memory management, implicit string-numeric conversion, and associative 
arrays.  Packaging all this up in a handy to use form was a great advance, 
and the features it provides are well suited for a large class of data 
reduction and text processing tasks.

But, Awk has no OO features, is not extensible, has poor error handling, 
and provides no system access.  It doesn't even have subroutines.  It is, 
with some minor exceptions, a read one input stream, process it in a 
single pass, write one output stream text processing scripting (there's 
that word again) language.

If you want to compare Python to other roughly similar languages, I would 
include Perl, Java, Tcl, and Ruby.  If this guy thinks comparing Python to 
Awk makes sense, he either has no clue what Awk is, or no clue what Python 
is.  BTW, comparing Java, Tcl, or Ruby to Awk would be equally absurd.

 Essentially any language with a pointer can claim to be OO,

And Perl is the proof of that statement!
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Class Variable Access and Assignment

2005-11-03 Thread Eric Nieuwland
Stefan Arentz wrote:
 It is really simple. When you say b.a then the instance variable 'a'
 is looked up first. If it does not exist then a class variable lookup
 is done.

This mixing of class and instance variable might be the cause of 
confusion...

I think of it as follows:
1 When the class statement ends a class object is created which is 
filled by all the statements inside the class statement
This means all variables and functions (methods) are created according 
to the description.
NOTE This happens just once.
2 When an instance of the class is created, what effectively happens is 
that a shallow copy of the class object is made.
Simple values and object references are copied.

This explains:
- why methods and complex objects (e.g. lists) are shared among 
instances of a class and the class itself
- simple values are not shared

--eric

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


sizers in boa constructors

2005-11-03 Thread Ashok
hi,
I am trying to build a small gui program in python using boa
constructor. i have a few problems. i would be grateful if anyone can
help me in this regard.
1. i have four static text controls positioned one below the other.
what i want to do is when i change the content of the upper static text
control, the lower ones should reposition themselves, with a constant
seperation, say 25px from the upper ones. I am not able to do this.
when i change the label of upper static text, the text overlaps on the
lower ones.

2. i am not able to implement sizers in general using boa. if anyone
can suggest some resources where i can get information, i would be
grateful

thanks

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


Re: Python and MySQL

2005-11-03 Thread Sion Arrowsmith
Aquarius [EMAIL PROTECTED] wrote:
I want to know if there is a way to interface a MySQL database without
Python-MySQL or without installing anything that has C files that need
to be compiled. The reason for this, is that I want to develop a
certain web application, but my hosting provider ([EMAIL PROTECTED]@#%) isn't 
very
eager to supply Python-MySQL (or any modules to python). Is there an
alternative approach I could use to pass around this ridiculos lack of
functionality?

If you've got MySQL installed, you probably have a command-line
mysql client, and you could use subprocess or popen to run that.
That's a little desperate though, and the error handling will suck.
(I've seen this trick used with other databases.)

-- 
\S -- [EMAIL PROTECTED] -- http://www.chaos.org.uk/~sion/
  ___  |  Frankly I have no feelings towards penguins one way or the other
  \X/  |-- Arthur C. Clarke
   her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Getting Python Accepted in my Organisation

2005-11-03 Thread Eric Nieuwland
Stuart Turner wrote:
  Python is a scripting language like Perl, awk, tcl, Java etc...  it 
 is
 not quite a fully developed OO language, but does support some OO that 
 Perl
 doesn't.  To be clear, these scripting languages have their place in 
 our
 environment, but they are not full replacements for C#, Java, C, 
 etc... 
 because they do not come with the full range of libraries e.g GDI
 libraries.  Python has to be compared to Perl, Awk in order to 
 evaluate it. 
 Perl, until recently, did not support threading.  Why would it? it is a
 scripting language and can run async shell commands.  I would be 
 interested
 to learn if Python supports a robust threading model (not just a 
 pointer
 reference to an object), as this is a significant drawback when using a
 scripting language.  CGI only works because the container can thread 
 with
 Perl.  Python is object orientated, but I do not know what 
 implementation? 
 Essentially any language with a pointer can claim to be OO, although 
 Python
 does market itself on OO capabilities.  Do you know what implementation
 they have used?

So, Java both is and is not a scripting language?
My favourite article says it all in its title: 
http://www.python.org/pycon/dc2004/papers/6/

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


Re: Class Variable Access and Assignment

2005-11-03 Thread Antoon Pardon
Op 2005-11-03, Stefan Arentz schreef [EMAIL PROTECTED]:
 Antoon Pardon [EMAIL PROTECTED] writes:

 Op 2005-11-03, venk schreef [EMAIL PROTECTED]:
  You see,
   The seen behavior is due to the result of python's name
  binding,scoping scheme.
 
 I know what causes the behaviour. But I still think it is
 not sane behaviour.
 
 
  ...
 
  the same thing happens in the case of b.a = b.a + 2  search for b.a
  not found, read the value from the enclosing scope (of the class
  object) then assign b.a to the local scope, with the value 3.
 
 This is an explanation depending on a specific implementation.
 
 Now can you give me a language design argument that supports the 
 idea that in b.a = b.a + 2 b.a refers to two different objects.
 
 And even if you could do that, can you give such an argument that
 in b.a += 2 that one occurence of b.a should refer to two different
 objects.

 Your problem is a namespace conflict together with a certain
 stubborness about lookup order :-)

 It is really simple. When you say b.a then the instance variable 'a'
 is looked up first. If it does not exist then a class variable lookup
 is done.

Fine, we have the code:

  b.a += 2

We found the class variable, because there is no instance variable,
then why is the class variable not incremented by two now?

 Remember, Python is a dynamic language.

So? Python being a dynamic language doesn't prevent the following to fail:

 a=1
 def f():
...   a += 2
... 
 f()
Traceback (most recent call last):
  File stdin, line 1, in ?
  File stdin, line 2, in f
UnboundLocalError: local variable 'a' referenced before assignment

 It is all according to how things have been in Python for a long time.

Unsane behaviour for a long time is still unsane behaviour.

 The real issue here is that you should propery name class variables so
 that there can't be any confusion about class or instance scope. I use
 all uppercase identifiers for class variables for example.

The fact that this can be regarded as unwise coding, doesn't imply
it is sane behaviour of python. Variable shadowing happens. I don't
consider it sane behaviour if the same reference in a line gets
resolved in different name spaces

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


Re: shared library search path

2005-11-03 Thread Neal Becker
Stefan Arentz wrote:

 
 Hi. I've wrapped a C++ class with Boost.Python and that works great. But,
 I am now packaging my application so that it can be distributed. The
 structure is basically this:
 
  .../bin/foo.py
  .../lib/foo.so
  .../lib/bar.py
 
 In foo.py I do the following:
 
  sys.path.append(os.path.dirname(sys.path[0]) + '/lib')
 
 and this allows foo.py to import bar. Great.
 
 But, the foo.so cannot be imported. The import only succeeds if I place
 foo.so next to foo.py in the bin directory.
 
 I searched through the 2.4.2 documentation on python.org but I can't find
 a proper explanation on how the shared library loader works.
 
 Does anyone understand what it going on here?
 
  S.
 

No, but here is the code I use:
import sys
sys.path.append ('../wrap')


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


Re: Class Variable Access and Assignment

2005-11-03 Thread venk
Again (blink) quoting from the docs 
For targets which are attribute references, the initial value is
retrieved with a getattr() and the result is assigned with a setattr().
Notice that the two methods do not necessarily refer to the same
variable. When getattr() refers to a class variable, setattr() still
writes to an instance variable. For example:

class A:
x = 3# class variable
a = A()
a.x += 1 # writes a.x as 4 leaving A.x as 3


I felt a wee bit clear after going thru the doc... attribute
referencing is not the same as searching the variable in the enclosing
scopes But, i still feel the inconsistency...

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


Re: Forcing the position of scroll bars on a wxTextCtrl

2005-11-03 Thread Magnus Lycka
Clans Of Intrigue wrote:
 Thanks, that did the trick perfectly :)
 
 also got rid of the self._log member so the class is now just:
 
 class LogControl:
  Simple helper to redirect stdout to a panel in the GUI 
 def __init__( self, textCtrl ):
 self._ctrl = textCtrl
 self.write( Application Started... )
 
 def write( self, Message ):
 # Add message to log and force scroll bars to end of window
 self._ctrl.SetValue( self._ctrl.GetValue() + Message )
 self._ctrl.ShowPosition(self._ctrl.GetLastPosition())

But if you have 100kB text in the control, and add another 1kB log
message, it certainly seems suboptimal to use:
self._ctrl.SetValue( self._ctrl.GetValue() + Message )
Here, you first copy all the text in the control to a Python
string, build a new string with old+new text, and replace the old
text with the context of this bigger string. You should simply use
self._ctrl.AppendText( Message ). I'm not sure exactly what happens
under he hood, but I suspect that's more efficient, besides being
prettier in the source...

Thou shalt study thy libraries and strive not to reinvent them
without cause, that thy code may be short and readable and thy
days pleasant and productive.

E.g. http://www.wxpython.org/docs/api/wx.TextCtrl-class.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: computer programming

2005-11-03 Thread Magnus Lycka
Brandon K wrote:
 what is .tk?  Turkmenistan?  or is it just some arbitrary suffix.

Nope that's tm. Tokelau has tk. I'm sure you can learn more from
Wikipedia etc. See e.g. http://en.wikipedia.org/wiki/ISO_3166-1

 
 www.javaholics.tk
 
 
 
 
 == Posted via Newsgroups.com - Usenet Access to over 100,000 
 Newsgroups ==
 Get Anonymous, Uncensored, Access to West and East Coast Server Farms! 
 == Highest Retention and Completion Rates! HTTP://WWW.NEWSGROUPS.COM 
 ==
 
 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: installing PygreSQL and psychopg2 modules (a newbie question)

2005-11-03 Thread Tom Brown
On Wednesday 02 November 2005 14:10, Zlatko Matić wrote:
 Hello.
 I was trying to install PygreSQL and psychopg2 in order to use python
 as front-end for PostgreSQL, on WIndows XP. When I tried to install
 by calling setup.py from command prompt (setup.py install), in both
 cases I had the same error:

 error: Python was built with version 7.1 of Visual Studio, and
 extensions need to be built with the same version of the compiler,
 but it isn't installed.

 It looks like this:
 C:\Downloads\Python\psychopg\psycopg2-2.0b5\psycopg2-2.0b5setup.py
 install running install
 running build
 running build_py
 running build_ext
 building 'psycopg2._psycopg' extension
 error: Python was built with version 7.1 of Visual Studio, and
 extensions need t
 o be built with the same version of the compiler, but it isn't
 installed.

 C:\Downloads\Python\psychopg\psycopg2-2.0b5\psycopg2-2.0b5pause
 Press any key to continue . . .

 What does it mean ? What am I supposed to do?

 Thanks,

 Zlatko

Use the windows installer for psycopg2. You can download it here:
http://stickpeople.com/projects/python/win-psycopg/psycopg2-2.0b5.win32-py2.4.exe

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

Re: Class Variable Access and Assignment

2005-11-03 Thread Stefan Arentz
Antoon Pardon [EMAIL PROTECTED] writes:

...

 Fine, we have the code:
 
   b.a += 2
 
 We found the class variable, because there is no instance variable,
 then why is the class variable not incremented by two now?

Because it really is executed as:

 b.a = b.a + 2

  1. get 't'b.a and store it in a temporary 't' (found the instance)
  2. add 2 to 't'
  3. store 't' in 'b.a'

The last operation stores it into an instance variable.

 
  Remember, Python is a dynamic language.
 
 So? Python being a dynamic language doesn't prevent the following to fail:
 
  a=1
  def f():
 ...   a += 2
 ... 
  f()
 Traceback (most recent call last):
   File stdin, line 1, in ?
   File stdin, line 2, in f
 UnboundLocalError: local variable 'a' referenced before assignment

See the 'global' keyword.

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


Re: Class Variable Access and Assignment

2005-11-03 Thread Stefan Arentz
Stefan Arentz [EMAIL PROTECTED] writes:

 Antoon Pardon [EMAIL PROTECTED] writes:
 
 ...
 
  Fine, we have the code:
  
b.a += 2
  
  We found the class variable, because there is no instance variable,
  then why is the class variable not incremented by two now?
 
 Because it really is executed as:
 
  b.a = b.a + 2
 
   1. get 't'b.a and store it in a temporary 't' (found the instance)

Oops.

   1. get b.a and store it in a temporary 't' (found the class variable 'a')

S.

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


Re: Class Variable Access and Assignment

2005-11-03 Thread Antoon Pardon
Op 2005-11-03, venk schreef [EMAIL PROTECTED]:
 hey,
  did  u read my reply fully? i too feel that this matter of raising
 unbound local error in one case and not raising it in the other must be
 analysed...

Yes, it seems I didn't respond to your satisfaction, but since you
don't provide details I can't clarify.

 quoting from the documentation
 If a name binding operation occurs anywhere within a code block, all
 uses of the name within the block are treated as references to the
 current block. This can lead to errors when a name is used within a
 block before it is bound. This rule is subtle. Python lacks
 declarations and allows name binding operations to occur anywhere
 within a code block. The local variables of a code block can be
 determined by scanning the entire text of the block for name binding
 operations.

Well I wonder. Would the following code be considered a name binding
operation:

  b.a = 5

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


Re: installing PygreSQL and psychopg2 modules (a newbie question)

2005-11-03 Thread Robert Boyd
On 11/2/05, Zlatko Matić [EMAIL PROTECTED] wrote:









I was trying to install PygreSQL and psychopg2 in 
order to use python as front-end for PostgreSQL, on WIndows XP. 
When I tried to install by calling setup.py from 
command prompt (setup.py install), in both cases I had the same 
error:

error: Python was built with version 7.1 of Visual 
Studio, and extensions need to be built with the same version of the compiler, 
but it isn't installed.
What does it mean ? What am I supposed to 
do?
It means you are trying to install from source (I assume you downloaded
tarballs of pygresql and psycopg), and it needs a compiler to build the
source. Your Python was installed as a Windows binary, right? (you did
point-and-click install of Python?) It appears you do not have Visual
Studio installed on your system. I have no idea if these database
libraries will build with VS, I've never tried on Windows. Another
thing, you need all the postgres libraries and headers to build these
packages, and I don't know if postgres win32 includes these.
Rob
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Class Variable Access and Assignment

2005-11-03 Thread Steven D'Aprano
On Thu, 03 Nov 2005 04:30:09 -0800, Paul Rubin wrote:

 Steve Holden [EMAIL PROTECTED] writes:
  class A:
a = 1
  b = A()
  b.a += 2
  print b.a
  print A.a
  Which results in
  3
  1
 
 I don't suppose you'd care to enlighten us on what you'd regard as the
 superior outcome?
 
 class A:
   a = []
 b = A()
 b.append(3)
 print b.a
 print a.a
 
 Compare and contrast.


I take it then that you believe that ints like 1 should be mutable like
lists? Because that is what the suggested behaviour implies.

Ah, what a grand thing that would be! We could say:

0 += 1
1 += 2
7 -= 1

and then have 0 + 1 == 7. Think of the obfuscated code we could write!



-- 
Steven.

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


Learning multiple languages (question for general discussion)

2005-11-03 Thread John Salerno
After my last post, I thought of another question as a result of the 
following:

--
Mike Meyer wrote:
  John Salerno [EMAIL PROTECTED] writes:
  [Wants to learn C# and Python simultaneously.]
 
 So my question is, is this feasible?
 
 
  Should be. It might be faster to do them sequentually.
--

I thought it might be interesting to get some opinions on when you know 
when you're done learning a language. I've been learning C# for a few 
months (albeit not intensively) and I feel I have a good grasp of the 
language in general. Of course, I haven't messed much with databases, or 
at all with ASP.NET...so far just WinForms. But as far as the syntax of 
the language, I understand that, as well as a lot of how the .NET 
Framework works.

I know this is a very subjective situation, but when would you say that 
it's 'safe' to move on to another language? How do you define a language 
as being learned? For me, I'm just doing this for fun, but I imagine 
in the computer programming world, you constantly need to learn new 
things, so I wouldn't assume that you completely learn a language before 
moving on to another.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Class Variable Access and Assignment

2005-11-03 Thread Antoon Pardon
Op 2005-11-03, venk schreef [EMAIL PROTECTED]:
 Again (blink) quoting from the docs 
 For targets which are attribute references, the initial value is
 retrieved with a getattr() and the result is assigned with a setattr().
 Notice that the two methods do not necessarily refer to the same
 variable. When getattr() refers to a class variable, setattr() still
 writes to an instance variable. For example:

 class A:
 x = 3# class variable
 a = A()
 a.x += 1 # writes a.x as 4 leaving A.x as 3
 

 I felt a wee bit clear after going thru the doc... attribute
 referencing is not the same as searching the variable in the enclosing
 scopes But, i still feel the inconsistency...

The documentation is IMO no help in arguing whether the behaviour is
sane or not. Unsane documented behaviour is still unsane.

So yes the documentation explains why such a result can happen,
but that doesn't change the fact that in this case we have
only one a.x on that line and the processing behind the scenes
refers to an x in two different name spaces.

I think that is unsane behaviour and giving an explanation on
why this particular behaviour arises from the current implemenation
doesn't change that.

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


Re: weakrefs to functions for observer pattern

2005-11-03 Thread Michael Schneider
Alex Martelli wrote:
 Michael Schneider [EMAIL PROTECTED] wrote:
 
 
I would like to use weak refs in an observer pattern implementation.
The problme that I have seems to be that weakrefs can't manage functions.
 
 
 They can manage just fine functions written in *Python*, just not
 builtin functions*, i.e., ones written in *C*.  Just wrap any builtin
 function you need to register as observer into a tiny Python-coded
 wrapper and live happily ever after.
...
 
Not all objects can be weakly referenced; those objects which can 
include class instances, functions written in Python (but not in C), 
 
 
 
 Alex
Alex,

Thank you, I mis-read the docs.

The mistake I  made was having was using a weak reference as a key in 
the dictionary.

Weak references will be very useful for me.

I really enjoy python.  So many good things have been added to the 
language without taking the fun away :-)

Mike

-- 
The greatest performance improvement occurs on the transition of from 
the non-working state to the working state.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to associate files with application

2005-11-03 Thread Ashok
Thanks Lasse, that was really helpful

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


Re: Learning multiple languages (question for general discussion)

2005-11-03 Thread Thomas Guettler
Am Thu, 03 Nov 2005 14:47:52 + schrieb John Salerno:

 After my last post, I thought of another question as a result of the 
 following:
 
 --
 Mike Meyer wrote:
   John Salerno [EMAIL PROTECTED] writes:
   [Wants to learn C# and Python simultaneously.]
  
  So my question is, is this feasible?
  
  
   Should be. It might be faster to do them sequentually.
 --

Unfortunately there is not C# section in Pleac:

 http://pleac.sourceforge.net/

You can learn both languages by reading the python solutions in pleac,
an try to translate them to C#. Please submit the code to the
project.

HTH,
 Thomas

-- 
Thomas Güttler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de
Spam Catcher: [EMAIL PROTECTED]

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


Re: Class Variable Access and Assignment

2005-11-03 Thread Steven D'Aprano
On Thu, 03 Nov 2005 12:50:51 +, Antoon Pardon wrote:

 I don't care what should be different. But a line with only one
 referent to an object in it, shouldn't be referring to two different
 objects.

 It doesn't.
 
 Yes it does. If the b.a refers to the instance variable, then an
 AttributeError should be raised, because the instance variable doesn't
 exist yet, so you can't add two to it.

Then you don't approve of inheritance? That's fine, it is your choice, but
as far as I know, all OO languages include inheritance. I can't imagine
why you would want this to happen:

py class BetterList(list):
... def wobble(self):
... Wobble a list.
... pass
... 
py L = BetterList((1, 2, 3))
py L.sort()
Traceback (most recent call last):
  File stdin, line 1, in ?
AttributeError: 'BetterList' object has no attribute 'sort'

(It just goes to show that Explicit is better than Implicit is not
*always* true.)



 If the b.a refers to the class variable then two should be added to it.
 
 Neither happens instead we get some hybrid in which an instance varible
 is created that gets the value of class variable incrented by two.

Which is precisely the expected behaviour. First you fetch the instance
attribute, which by the rules of inheritance falls back to the value
of the class attribute if it doesn't yet exist (which, in this specific
case, it does not). Then you add two to it, and store the result in the
instance attribute. You can't increment the object 1 because it is
immutable.



 In the line: b.a += 2, the b.a should be refering to the class
 variable or the object variable but not both. So either it could raise
 an attribute error or add two to the class variable.

 It does exactly what you say. It adds 2 to the a *instance variable* of
 the object instance in 'b'.
 
 There is no instance variable at that point. How can it add 2, to
 something that doesn't exist at the moment.

By the standard rules of inheritance.


-- 
Steven.

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


Re: another beginner sort of question

2005-11-03 Thread John Salerno
Thanks!

Mike Meyer wrote:
 John Salerno [EMAIL PROTECTED] writes:
 [Wants to learn C# and Python simultaneously.]
 
So my question is, is this feasible?
 
 
 Should be. It might be faster to do them sequentually.
 
 
Or does learning Python require (or entail) learning all the details
behind it?
 
 
 Not really. There are some traps you can fall into that are obvious if
 you know how the underlying implementation works, but even for those,
 you just need the general idea, not the details.
 
 
Also, do I need to know anything about C or C++?
 
 
 No. In fact, the less you know about them, the less you'll have to
 unlearn to use Python effectively.
 
 
Python seems to connected to those languages that I'm afraid
learning Python by itself might not be practical, but hopefully
that's unfounded.
 
 
 CPython (the implementation most people mean when they say Python)
 is written in C, and has well-defined APIs for putting an interpreter
 into a C program, or making functionality from a C library available
 to a CPython program. Other implementations have similar hooks for
 different languages. Unless you want to get into the internals of an
 implementation, to embed Python in an application, or to write a
 Python extension (usually because you're wrapping an existing
 library), you won't need to worry about any of these.
 
 One thing. While Python is called a scripting language, it doesn't
 have facilities for dealing with shell scripting that other scripting
 languages have. As such, it's harder to do shell scripting type
 things in Python than in those languages. On the other hand, it's
 easier than doing them in C, for the same reason that doing pretty
 much anything in Python is easier than doing it in C. On the gripping
 hand, if you do things pythonically instead of like you'd do them in a
 shell script, you may find that Python is easier than the shell
 script.
 
 mike
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Class Variable Access and Assignment

2005-11-03 Thread Steven D'Aprano
On Thu, 03 Nov 2005 12:53:37 +, Antoon Pardon wrote:

 I don't suppose you'd care to enlighten us on what you'd regard as the 
 superior outcome?
 
 No. I don't think a superior outcome is necessary to see that this is
 not sane behaviour. I don't care that much on how it gets fixed.

It isn't broken, there is nothing to fix. The code does precisely what the
inheritance model promises to do.


-- 
Steven.

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


Re: PEP submission broken?

2005-11-03 Thread Magnus Lycka
Steve Holden wrote:
 Volunteers don't always behave as perfect bureaucrats :-)

Neither do typical bureaucrats!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to print random strings

2005-11-03 Thread Magnus Lycka
[EMAIL PROTECTED] wrote:
 So how would I go about have 5 strings, and running a program that will
 randomly pick one of those to print?

  import random
  text = Perhaps reading the manual is a good idea?.split()
  random.choice(text)
'is'
  random.choice(text)
'reading'
  random.choice(text)
'a'
  random.choice(text)
'the'
  random.choice(text)
'Perhaps'

See http://docs.python.org/lib/module-random.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Class Variable Access and Assignment

2005-11-03 Thread Magnus Lycka
Antoon Pardon wrote:
 Op 2005-11-03, Steven D'Aprano schreef [EMAIL PROTECTED]:
 
 
There are two possible fixes, either by prohibiting instance variables
with the same name as class variables, which would allow any reference
to an instance of the class assign/read the value of the variable. Or
to only allow class variables to be accessed via the class name itself.

There is also a third fix: understand Python's OO model, especially
inheritance, so that normal behaviour no longer surprises you.
 
 
 No matter wat the OO model is, I don't think the following code
 exhibits sane behaviour:
 
 class A:
   a = 1
 
 b = A()
 b.a += 2
 print b.a
 print A.a
 
 Which results in
 
 3
 1

On the other hand:

  class C:
... a = [1]
...
  b=C()
  b.a += [2]
  b.a
[1, 2]
  C.a
[1, 2]

I can understand that Guido was a bit reluctant to introduce
+= etc into Python, and it's important to understand that they
typically behave differently for immutable and mutable objects.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Class Variable Access and Assignment

2005-11-03 Thread Magnus Lycka
Antoon Pardon wrote:
 There is no instance variable at that point. How can it add 2, to
 something that doesn't exist at the moment.

Because 'a += 1' is only a shorthand for 'a = a + 1' if a is an
immutable object? Anyway, the behaviour is well documented.

http://docs.python.org/ref/augassign.html says:

An augmented assignment expression like x += 1 can be rewritten as x = x 
+ 1 to achieve a similar, but not exactly equal effect. In the augmented 
version, x is only evaluated once. Also, when possible, the actual 
operation is performed in-place, meaning that rather than creating a new 
object and assigning that to the target, the old object is modified instead.

...

For targets which are attribute references, the initial value is 
retrieved with a getattr() and the result is assigned with a setattr(). 
Notice that the two methods do not necessarily refer to the same 
variable. When getattr() refers to a class variable, setattr() still 
writes to an instance variable. For example:

class A:
 x = 3# class variable
a = A()
a.x += 1 # writes a.x as 4 leaving A.x as 3
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Most efficient way of storing 1024*1024 bits

2005-11-03 Thread Alex Martelli
Alex Stapleton [EMAIL PROTECTED] wrote:
   ...
  Six megabytes is pretty much nothing on a modern computer.
 
  BTW, it'd be 6 megabits or 750kb ;)
 
  ...but Mike was proposing using one digit per bit, hence, 6 megabytes.
  That makes it easy to search for bitpatterns with re or  
  string.find; if
  the bits were packed 8 to a byte, such searches would be very hard.
 
 They would just require some out-of-the-box thinking using character
 arrays and stuff I think. It's definately still doable with regex's  
 if you really want to.

Doable, yes, of course -- that's pretty obvious, and I'm not sure
what's out of the box about it -- but orders of magnitude harder.  For
example, to look for a fixed sequence of X bits, you'd have to search
for any of 8 sequences of slightly more than X/8 characters (where the
first and last are normally charsets) built by the possible shifts of
the bitsequence by 0, 1, ... 7 bits.  I also suspect that performance
would badly suffer (dealing with 750 KB of data, plus all the auxiliary
stuff for Python and re, isn't going to fit in cache anyway).  All in
all, doesn't feel worth pursuing, particularly when the OP mentioned
time mattering more than space right from the word go.


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


Re: Learning multiple languages (question for general discussion)

2005-11-03 Thread infidel
Python has spoiled me.  I used to periodically try out new languages
just for fun, but since learning Python, it's become a lot less
interesting.  I find myself preferring to just try new ideas or
techniques in Python rather than searching for new languages to dabble
in.  The last few I've downloaded were, in no particular order:  Perl,
Ruby, Lisp, Io, and Scheme.  I usually get as far as installing the
necessary interpreters/compilers and opening up a tutorial or two
before I lose interest.

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


Re: Getting Python Accepted in my Organisation

2005-11-03 Thread Tommy . Ryding
I have done the same thing in my organisation.

Show them concrete examples of when they can benefit from Python to
Convince them.
My colleagues and bosses has been conviced and therefore my current
work task is to integrate the interpreter in a VxWorks environment so
everyone at the company can use it within our context.

If you are good at convincing you can be lucky and get some fun work
tasks. :)

Good luck!

//T

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


How can I package a python script and modules into a single script?

2005-11-03 Thread Noah
I would like to package my main script and all the
modules it imports into a single script that will
run just as the collection would. It should not
need to package standard Python lib modules -- just
my local modules. This is not the same question
that would be answered with py2exe or py2app. I
don't need to package the script into a binary
along with Python. I expect Python to be installed.
I also don't want to use distutils to install the
script. The script will always run on Unix.

I thought that there might be some way to run a
script package from a tar file. One way would be to
have the package script  untar itself into a temp
directory; run the main script; then  delete the
temporary package directory when done. That sounds
clunky and prone to leave around trash if someone
does a 'kill -9'. However, this might be an
acceptable compromise. I'm sure that I've seen a
tool around like this, but I can't find it anymore.
I checked the usual places (google and sf.net).

I also considered simply cutting and pasting all
the modules I need into one single, giant script,
but that's less appealing than the tarball idea
(unless it could be done automatically).

Yours,
Noah

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


Re: Python and MySQL

2005-11-03 Thread Thomas Bartkus
Steve Holden [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Thomas Bartkus wrote:
  Steve Holden [EMAIL PROTECTED] wrote in message
  news:[EMAIL PROTECTED]
 
 I have a _mysql.c as a part of my distrbution of MySQLdb. Don't you?
 
 
 
  You made me give that library a good hard stare.
 
  And no - everything is enunciated in clear Python (.py) code with
  corresponding (.pyc) and (.pyo).  It appears we have Python source for
  everything.
 
 FWIW:
 
 
 print MySQLdb.version_info
 
  (1, 2, 0, 'final', 1)
 
 OK. I saw that my own version was (1, 0, 0, 'final', 1), so I assumed
 Andy's updated the package somewhat. However, downloading the source of
 1.2 I see that _mysql.c still appears, and that the package's
 __init__.py still includes the line

 include _mysql

 My C:\Python24\Lib\site-packages directory does contain a _mylsql.pyd
 file. Would you like to check that we are talking about the same module?

Okay - I neglected to look at the [site-packages] directory itself.  Here I
do find [_mysql.pyd] full of binary code.  A MySQLdb related file that
doesn't seem to have a corresponding file with Python source code. Mea
culpa! This is on  MS Windows [C:\Python23].

But heck!  Now I'm looking at the /usr/lib/python2.3/site-packages on a
Mandrake Linux box.  No [_mysql.] pyd here! Fewer files overall and while
there are other file extensions, everything seems to have a corresponding
[.py].

print MySQLdb.version_info
(0, 9, 2, 'final', 1)

Thomas Bartkus



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


Re: Learning multiple languages (question for general discussion)

2005-11-03 Thread John Salerno
LOL. As weird as it sounds, that's what I *don't* want to happen with 
C#! I've spent a lot of time with it, and I love it, but I don't want 
Python to take over!  :)



infidel wrote:
 Python has spoiled me.  I used to periodically try out new languages
 just for fun, but since learning Python, it's become a lot less
 interesting.  I find myself preferring to just try new ideas or
 techniques in Python rather than searching for new languages to dabble
 in.  The last few I've downloaded were, in no particular order:  Perl,
 Ruby, Lisp, Io, and Scheme.  I usually get as far as installing the
 necessary interpreters/compilers and opening up a tutorial or two
 before I lose interest.
 
-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   3   >