SQLObject 0.10.2

2008-05-30 Thread Oleg Broytmann
Hello!

I'm pleased to announce version 0.10.2, a bugfix release of 0.10 branch
of SQLObject.


What is SQLObject
=

SQLObject is an object-relational mapper.  Your database tables are described
as classes, and rows are instances of those classes.  SQLObject is meant to be
easy to use and quick to get started with.

SQLObject supports a number of backends: MySQL, PostgreSQL, SQLite,
Firebird, Sybase, MSSQL and MaxDB (also known as SAPDB).


Where is SQLObject
==

Site:
http://sqlobject.org

Development:
http://sqlobject.org/devel/

Mailing list:
https://lists.sourceforge.net/mailman/listinfo/sqlobject-discuss

Archives:
http://news.gmane.org/gmane.comp.python.sqlobject

Download:
http://cheeseshop.python.org/pypi/SQLObject/0.10.2

News and changes:
http://sqlobject.org/News.html


What's New
==

News since 0.10.1
-

Small Features
~~

* Use VARCHAR(MAX) and VARBINARY(MAX) for MSSQL = 9.0.

* Run post_funcs after RowDestroySignal.

Bug Fixes
~

* Fixed a minor bug in Set column.

* A bug fixed for RowCreatedSignal together with InheritableSQLObject:
  run post_funcs after the entire hierarchy has been created.

* Aggregate functions now honors 'distinct'.

For a more complete list, please see the news:
http://sqlobject.org/News.html

Oleg.
-- 
 Oleg Broytmannhttp://phd.pp.ru/[EMAIL PROTECTED]
   Programmers don't die, they just GOSUB without RETURN.
--
http://mail.python.org/mailman/listinfo/python-announce-list

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


ANN: NumPy 1.1.0

2008-05-30 Thread Jarrod Millman
I'm pleased to announce the release of NumPy 1.1.0.

NumPy is the fundamental package needed for scientific computing with
Python.  It contains:

 * a powerful N-dimensional array object
 * sophisticated (broadcasting) functions
 * basic linear algebra functions
 * basic Fourier transforms
 * sophisticated random number capabilities
 * tools for integrating Fortran code.

Besides it's obvious scientific uses, NumPy can also be used as an
efficient multi-dimensional container of generic data. Arbitrary
data-types can be defined. This allows NumPy to seamlessly and
speedily integrate with a wide-variety of databases.

This is the first minor release since the 1.0 release in
October 2006. There are a few major changes, which introduce
some minor API breakage. In addition this release includes
tremendous improvements in terms of bug-fixing, testing, and
documentation.

For information, please see the release notes:
http://sourceforge.net/project/shownotes.php?release_id=602575group_id=1369

Thank you to everybody who contributed to this release.

Enjoy,

-- 
Jarrod Millman
Computational Infrastructure for Research Labs
10 Giannini Hall, UC Berkeley
phone: 510.643.4014
http://cirl.berkeley.edu/
--
http://mail.python.org/mailman/listinfo/python-announce-list

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


SQLObject 0.9.7

2008-05-30 Thread Oleg Broytmann
Hello!

I'm pleased to announce version 0.9.7, a minor bug fix release of SQLObject.


What is SQLObject
=

SQLObject is an object-relational mapper.  Your database tables are described
as classes, and rows are instances of those classes.  SQLObject is meant to be
easy to use and quick to get started with.

SQLObject supports a number of backends: MySQL, PostgreSQL, SQLite,
Firebird, Sybase, MSSQL and MaxDB (also known as SAPDB).


Where is SQLObject
==

Site:
http://sqlobject.org

Development:
http://sqlobject.org/devel/

Mailing list:
https://lists.sourceforge.net/mailman/listinfo/sqlobject-discuss

Archives:
http://news.gmane.org/gmane.comp.python.sqlobject

Download:
http://cheeseshop.python.org/pypi/SQLObject/0.9.7

News and changes:
http://sqlobject.org/News.html


What's New
==

News since 0.9.6


Small Features
~~

* Use VARCHAR(MAX) and VARBINARY(MAX) for MSSQL = 9.0.

* Run post_funcs after RowDestroySignal.

Bug Fixes
~

* Fixed a minor bug in Set column.

* A bug fixed for RowCreatedSignal together with InheritableSQLObject:
  run post_funcs after the entire hierarchy has been created.

* Aggregate functions now honors 'distinct'.

For a more complete list, please see the news:
http://sqlobject.org/News.html

Oleg.
-- 
 Oleg Broytmannhttp://phd.pp.ru/[EMAIL PROTECTED]
   Programmers don't die, they just GOSUB without RETURN.
--
http://mail.python.org/mailman/listinfo/python-announce-list

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


NYC Python User Group Meeting Announcement....

2008-05-30 Thread John Clark
Greetings!

The next New York City Python Users Group meeting is planned for June 17th, 
6:30pm at Daylife Inc. at 444 Broadway (between Howard St. and Grand St.) on
the 5th Floor. We welcome all those in the NYC area who are interested in 
Python to attend.

More information can be found on the users group wiki page:

http://www.nycpython.org

Hope to see you there!

-John Clark


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

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


Re: Code execution in imported modules

2008-05-30 Thread Casey McGinty
On Thu, May 29, 2008 at 2:43 PM, Eric Wertman [EMAIL PROTECTED] wrote:

 So I'm working on some file parsing and building up a stack of regular
 expressions that I need to use.  I was thinking of dropping them in an
 external module.  I was wondering.. if I put them in a file called
 regex.py like so :

 import re

 re1 = ..
 re2 = ..

 and then do:

 rgx1 = re.compile(re1)
 rgx2 = re.compile(re2)


 and, in my script, parse.py py I do:

 from regex import *

 text = bunch of stuff...

 m = rgx1.search(text)


 Does the re get compiled when I import it, or every time I call it?
 Since I'm calling it often, I'd like to compile it once.

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


Please correct me if I am wrong ...
but I believe this should work, and rgx's will only be compiled on the first
import. You could also place them in a class and get the same effect when
you instantiate the class.

class MyRegEx( object ):
re1 = ..
re2 = ..
rgx1 = re.compile(re1)
rgx2 = re.compile(re2)
--
http://mail.python.org/mailman/listinfo/python-list

Re: Python and Flaming Thunder

2008-05-30 Thread Marc 'BlackJack' Rintsch
On Thu, 29 May 2008 17:57:45 -0400, D'Arcy J.M. Cain wrote:

 I guess I am still new to this group and don't understand its charter.
 I wasn't aware that it was a Flaming Blunder group.  Can someone please
 point me to a newsgroup or mailing list dedicated to the Python
 programming language?

By discussing language design of FT compared to other languages you can
learn about Python.  We all know that Python is brilliant -- here's the
opportunity to think about why it is.  :-)

And it's basically only this very long thread, so it's easy to filter and
ignore in a decent news reader.

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


Re: question

2008-05-30 Thread Marc 'BlackJack' Rintsch
On Thu, 29 May 2008 15:41:29 -0700, Gandalf wrote:

 On May 30, 12:14 am, John Henderson [EMAIL PROTECTED] wrote:
 Gandalf wrote:
  how do i write this code in order for python to understand it
  and print me the x variable

  x=1
  def ():
  x++
  if x  1:
  print wrong
  else :
  print x

  ()

 Example:

 x=1
 def (x):
 x += 1
 if x  1:
 return wrong
 else :
return x

 print (x)

 John
 
 mmm isn't their any global variable for functions?

There is but you shouldn't use global variables as they make program and
data flow harder to understand, the code more difficult to test, and
usually couples functions more tightly then they should.

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


some question with Quixote and Nginx

2008-05-30 Thread smalfish
hi,
  i have some question with this,quixote publish width FastCGI.the two
scripts like this(root.ptl and hello.ptl):

class RootDirectory(Directory):
_q_exports = [, hello]

def _q_index [html] (self):

h4Hello,Blog/h4
lia href=hello/hello/a/li

hello = HelloDirectory()

class HelloDirectory(Directory):
_q_exports = [, hi]

def _q_index [html] (self):

h4hello page/h4
lia href=/back home/a/li


def hi [html] (self):

aaa


now, on the firefox input:
http://localhost/hello/  -- this ok
http://localhost/hello  -- this will forward http://localhost/hello/hello/
, error.

other:
http://localhost/hello/hi  -- this ok
http://localhost/hello/hi/ -- http://localhost/hello/hi//hello/hi/

i think,some problem with Nginx(PATH_INFO is not correct.)

==
nginx.conf:
location / {
 fastcgi_pass 127.0.0.1:8000;
 fastcgi_param SERVER_NAME nginx;
 fastcgi_param PATH_INFO $request_uri;
 fastcgi_param SCRIPT_NAME $fastcgi_script_name;
 fastcgi_param REQUEST_METHOD $request_method;
 fastcgi_param QUERY_STRING $query_string;
 fastcgi_param CONTENT_TYPE $content_type;
 fastcgi_param CONTENT_LENGTH $content_length;
 fastcgi_intercept_errors off;
}

fastcgi:
spawn-fcgi -a 127.0.0.1 -p 8000 -f fastcgi_server.py -u nginx -P /var/
log/nginx/qfcgi.pid


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


Re: question

2008-05-30 Thread inhahe

Gandalf [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 On May 30, 12:14 am, John Henderson [EMAIL PROTECTED] wrote:
 Gandalf wrote:
  how do i write this code in order for python to understand it
  and print me the x variable

  x=1
  def ():
  x++
  if x  1:
  print wrong
  else :
  print x

  ()

 Example:

 x=1
 def (x):
 x += 1
 if x  1:
 return wrong
 else :
return x

 print (x)

 John

 mmm isn't their any global variable for functions?

how about
def ():
  y = x+1
  if y  1:
return wrong
  else:
return y

but if you really have to modify x outside of the scope of the function, 
well, i guess one possibility is to return a tuple, one element being a 
string that may or may not contain the word wrong and another being x, and 
then whatever's calling  can change x in their own scope based on the 
return value. but other than that, the normal way to affect a variable 
beyond the scope of your function is to make a class and affect a class 
variable.  although there is always the 'global' statement also.



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


Re: make a string a list

2008-05-30 Thread iapain
On May 29, 11:30 pm, Nikhil [EMAIL PROTECTED] wrote:
 or a string iterable ? How can I do that. I have lots of '\r\n'
 characters in the string which I think can be easier if it were made
 into a list and I can easily see if the required value (its a numeral)
 is present in it or not after some position or after some characters'
 position.

 Thanks,
 Nikhil

If you just want to check required value then you can even use Sets or
build your own hash table.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python and Flaming Thunder

2008-05-30 Thread Duncan Booth
D'Arcy J.M. Cain [EMAIL PROTECTED] wrote:

 I guess I am still new to this group and don't understand its charter.
 I wasn't aware that it was a Flaming Blunder group.  Can someone please
 point me to a newsgroup or mailing list dedicated to the Python
 programming language?
 
A minor point of netiquette: it's fine to reply by email to a message if 
you want to make a point off group, but if you are following up to the 
newsgroup/mailing list please don't CC the original sender: they will see 
the message in any case on the newsgroup and getting it twice is just 
likely to annoy.

I don't understand your problem: it's just a single thread so killfile or 
skip it.

-- 
Duncan Booth http://kupuguy.blogspot.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python and Flaming Thunder

2008-05-30 Thread Torsten Bronger
Hallöchen!

Duncan Booth writes:

 [...]

 I don't understand your problem: it's just a single thread so
 killfile or skip it.

Although I agree with you that there is no problem, *this* is not a
good justification for this thread.  One should stay on topic in
*every* thread.

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
  Jabber ID: [EMAIL PROTECTED]
   (See http://ime.webhop.org for further contact info.)
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python threads and memory usage

2008-05-30 Thread Mike
On May 30, 9:16 am, Dennis Lee Bieber [EMAIL PROTECTED] wrote:
 On Thu, 29 May 2008 12:01:30 -0700 (PDT), Mike [EMAIL PROTECTED]
 declaimed the following in comp.lang.python:

  I observed, that every thread reserved some memory, and after exit
  thread doesn't freed it. When i leaved my server working for 3 days,
  then it takes 15% of 512MB memory (during that time about 15000
  threads were created and stopped). When server starts it only takes
  about 1% of memory.

         Do you have any outstanding references to the threads? If so, have
 you performed a .join() with the thread? Until you join it, the thread
 state (thread local objects/variables) are probably being held for
 access from outside the thread.
 --
         Wulfraed        Dennis Lee Bieber               KD6MOG
         [EMAIL PROTECTED]             [EMAIL PROTECTED]
                 HTTP://wlfraed.home.netcom.com/
         (Bestiaria Support Staff:               [EMAIL PROTECTED])
                 HTTP://www.bestiaria.com/

I'm joining threads only during my program exit. I'll try to do what
You suggest.

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


Re: should I put old or new style classes in my book?

2008-05-30 Thread Arnaud Delobelle
Alan Isaac [EMAIL PROTECTED] writes:

 This thread raises two questions for me.

 1. I take it from this thread that in Python 3 the following are
 equivalent:

class Test: pass

class Test(object): pass

 Is that correct, and if so, where is it stated explicitly?
 (I know about the all classes are new style classes statement.)

I don't know where it is stated, but how could they *not* be
equivalent?

 2. I take it from this thread that in Python 2.2+ if I put the
 following at the top of a module ::

__metaclass__ = type

 then all the classes defined in that module will be newstyle
 classes.  Is that correct?  Somehow I did not grok that from

 URL:http://docs.python.org/ref/metaclasses.html

 but it seems right.

From the URL you quote:

The appropriate metaclass is determined by the following
precedence rules:

* If dict['__metaclass__'] exists, it is used.

* Otherwise, if there is at least one base class, its metaclass is
  used (this looks for a __class__ attribute first and if not
  found, uses its type).

* Otherwise, if a global variable named __metaclass__ exists, it
  is used.

* Otherwise, the old-style, classic metaclass (types.ClassType) is
  used.

Look at the third point.

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


Re: code of a function

2008-05-30 Thread Pete Forman
alex23 [EMAIL PROTECTED] writes:

  Which is very handy, like most of IPython.

+1 QOTW
-- 
Pete Forman-./\.-  Disclaimer: This post is originated
WesternGeco  -./\.-   by myself and does not represent
[EMAIL PROTECTED]-./\.-   the opinion of Schlumberger or
http://petef.22web.net   -./\.-   WesternGeco.
--
http://mail.python.org/mailman/listinfo/python-list


Re: seg. fault with Py_BuildValue?

2008-05-30 Thread Christian Meesters

 Check if either x or y are NULL.
They aren't. Just did an explicit check.
--
http://mail.python.org/mailman/listinfo/python-list


free computer studies

2008-05-30 Thread sachin . vijayan80
free computer studies
free computer programmes
free computer education
http://foodplantss.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: should I put old or new style classes in my book?

2008-05-30 Thread Matthieu Brucher
2008/5/29 Alan Isaac [EMAIL PROTECTED]:

 This thread raises two questions for me.



 1. I take it from this thread that in Python 3 the

 following are equivalent:



   class Test: pass



   class Test(object): pass



 Is that correct, and if so, where is it stated explicitly?

 (I know about the all classes are new style classes statement.)


All classes are new style classes, and the usual

class MyClass(object) pass

should be replaced by the first

class MyClass: pass

IIRC. I don't know ATM where I read it.

Matthieu
-- 
French PhD student
Website : http://matthieu-brucher.developpez.com/
Blogs : http://matt.eifelle.com and http://blog.developpez.com/?blog=92
LinkedIn : http://www.linkedin.com/in/matthieubrucher
--
http://mail.python.org/mailman/listinfo/python-list

Re: Hungarian Notation

2008-05-30 Thread Lie
On May 27, 12:28 pm, inhahe [EMAIL PROTECTED] wrote:
 Does anybody know of a list for canonical prefixes to use for hungarian
 notation in Python?  Not that I plan to name all my variables with hungarian
 notation, but just for when it's appropriate.

If it was me, I'd use an empty-defined class:

class Fake(object):
pass

data = 'headinfo=trash;headtrash=info'
Header = Fake()
Header.Str = data
Header.Dict = parse(data)

it saves name if it's important (alternatively, you may also use a
dict or a tuple/list to store the string/dict pair).
But using Fake class just like that is difficult to work with if I
need to write to the data (not read only) and synchronizes the data,
in that case, it's easy to extend the Fake Class:

class Fake(object):
def __init__(self, data):
self.data = parse(data)

def toStr(self):
return str(self.data)
def fromStr(self, s):
self.data = parse(s)
Str = property(toStr, fromStr)

def toDict(self):
return self.data
def fromDict(self, s):
self.data = s
Dict = property(toDict, fromDict)

you might go as far as overriding __str__ and __repr__ as appropriate.
--
http://mail.python.org/mailman/listinfo/python-list


Re: should I put old or new style classes in my book?

2008-05-30 Thread Carl Banks
On May 29, 12:07 pm, [EMAIL PROTECTED] wrote:
 The current edition of the book presents old style classes.  I am
 considering
 switching to new style classes on the assumption that this should be
 the default
 choice for new programs.  The drawback is that a lot of the online
 documentation
 still uses old style classes.


New style, all the way.

The drawback you speak of for new-style classes I think is today more
of a drawback for old-style.  The problem is, when a newbie goes
looking for examples, there is a lot of code out there that uses
things like properties, type(instance), @staticmethods, and so on.
Those won't work, and will confuse the hell out of newbies, if you
teach them old-style.  OTOH, the examples out there that are written
for old-style usually still work for new-style classes.

The only significant issue, as far as I'm concerned, is the list of
bases.  Which is why, even if you only cover new-style classes, it's
important to at least mention that there used to exist old-style that
don't list any bases (in Python 2.x).  And then tell the user, We're
not covering it, it's not something you need to worry about, and most
of the time you can and should add (object) and the code will still
work.  And leave it at that--let the interested newbie seek out more
information on their own.


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


How to covert ASCII to integer in Python?

2008-05-30 Thread Skonieczny, Chris
YOU SHOULD REMOVE or CORRECT YOUR POST here: 
http://mail.python.org/pipermail/python-list/2007-February/427841.html  
 
It is not true - eg. try : 
a='P'# P is ASCII , isn't it ? 
b=int(a)
and what you will get ? An error !!!
 
Or probably you yourself should - quote : 
You probably should go through the tutorial ASAP that is located here:

http://docs.python.org/tut/ 

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

Re: Assignment and comparison in one statement

2008-05-30 Thread Lie
On May 24, 5:59 am, Johannes Bauer [EMAIL PROTECTED] wrote:
 Hello group,

 I'm just starting with Python and am extremely unexperienced with it so
 far. Having a strong C/C++ background, I wish to do something like

 if (q = getchar()) {
         printf(%d\n, q);

 }

 or translated to Python:

 if (p = myfunction()):
         print p

 However, this assignment and comparison is not working. What's the
 Python way of doing this kind of thing?

 Thanks a lot,
 Johannes

Python often tries to avoid things it considers bad design in a
language, assignment and comparison is, for example, a bad design
because it is easily mistaken with equality comparison, among other
things. This avoidance of bad design sometimes go as far as making
the way to do something in python completely different than doing
the same thing in other languages, thus it is always a good idea to
state what you intent in doing, rather than stating what you think you
need to do. An example is python's notion for 'for' loop, which can
only loop a list, most people coming from other languages would use
range/xrange here and there, a pythonic code would only rarely use a
range/xrange (usually in situations where the number of repetition is
constant).

Try reasking by stating what you wanted to do, rather than the
abstract question that states what you think you need to do you've
just asked. What functions you wanted to use and for what?
--
http://mail.python.org/mailman/listinfo/python-list


FREE Tutorials on HTML XHTML CSS JavaScript XML XSL ASP SQL ADO VBScript, SAP - ABAP and more...

2008-05-30 Thread Dhanabal
access all computer tutorials for free visit 
http://freecomputertutorialz1.blogspot.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: should I put old or new style classes in my book?

2008-05-30 Thread sturlamolden
On May 29, 6:07 pm, [EMAIL PROTECTED] wrote:

 The current edition of the book presents old style classes.  I am
 considering
 switching to new style classes on the assumption that this should be
 the default
 choice for new programs.  The drawback is that a lot of the online
 documentation
 still uses old style classes.

You should use new-style classes. It is the default in Python 2.6 and
the only option in 3.0. These releases will be out before your book is
on the market.

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


Re: Assignment and comparison in one statement

2008-05-30 Thread alex23
On May 30, 7:39 pm, Lie [EMAIL PROTECTED] wrote:
 An example is python's notion for 'for' loop, which can
 only loop a list[...]

Actually, the for statement steps through any object that provides an
iterator interface. Lists just happen to be one such object type.

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


Re: Python threads and memory usage

2008-05-30 Thread Mike
On May 30, 9:42 am, Mike [EMAIL PROTECTED] wrote:
 On May 30, 9:16 am, Dennis Lee Bieber [EMAIL PROTECTED] wrote:



  On Thu, 29 May 2008 12:01:30 -0700 (PDT), Mike [EMAIL PROTECTED]
  declaimed the following in comp.lang.python:

   I observed, that every thread reserved some memory, and after exit
   thread doesn't freed it. When i leaved my server working for 3 days,
   then it takes 15% of 512MB memory (during that time about 15000
   threads were created and stopped). When server starts it only takes
   about 1% of memory.

          Do you have any outstanding references to the threads? If so, have
  you performed a .join() with the thread? Until you join it, the thread
  state (thread local objects/variables) are probably being held for
  access from outside the thread.
  --
          Wulfraed        Dennis Lee Bieber               KD6MOG
          [EMAIL PROTECTED]             [EMAIL PROTECTED]
                  HTTP://wlfraed.home.netcom.com/
          (Bestiaria Support Staff:               [EMAIL PROTECTED])
                  HTTP://www.bestiaria.com/

 I'm joining threads only during my program exit. I'll try to do what
 You suggest.

 THX

It helped. Now all threads are added to thread list and every some
period of time I'm checking which threads are alive (enumerate), and
joining all which aren't. Now [memory usage is still on 1% :D:D:D

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


Re: Saving tif file from tricky webserver

2008-05-30 Thread Diez B. Roggisch

schweet1 schrieb:

Greetings,

I am attempting to automate accessing and saving a file (a TIF) from
the following URL:

http://patimg1.uspto.gov/.DImg?Docid=US007376435PageNum=1IDKey=E21184B8FAD5

I have tried some methods using urllib, httplib, and
web32com.client(InternetExplorer), but haven't been successful.
Currently I am using (in Python 2.5)

import webbrowser

url = [see above]

webbrowser.open(url, new=0, autoraise=0)

When this is run a windows popup dialog opens asking me to Open, Save,
or Cancel.  However, if I query multiple such URLs, I do not want to
have to respond manually.  Is there a way I can use Python to save the
TIF?


You need to figure out what really becomes the download url, and use 
that. Use e.g. http live headers for firefox to get that information.


If the server needs the form-submitting stuff to actually grant access 
to the TIFF, you might need to use mechanize to talk to the site as if 
you were a browser.


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


Re: ctypes, function pointers and a lot of trouble

2008-05-30 Thread Nick Craig-Wood
Matt [EMAIL PROTECTED] wrote:
  Okay, thanks a lot for your reply Nick, I think you pushed me back on 
  the right way.

Good!

  Now I started with trying to implement the callback functions and am 
  stuck at the following point:
 
  I define my classes/structures/unions:
 
  class cdStream(Structure):
   _fields_ = [(contextH, c_uint),
(open, c_void_p),
[snip]
  then i define my functions (right now I do just nothing) and at the same 
  time I define the datatypes like they're listed in my C sample program:
 
  def pystreamopen (contextH, mode, pErr):
   pass
 
  cstreamopen = CFUNCTYPE(c_uint, c_ushort, c_uint)
[snip]
  and now the problem starts: i want the pointers in the cdStream 
  Structure point at my functions and tried to do it the following way:
 
  data = cdStgMedium()
  data.type = 0
  data.u.pStream.contextH = c_uint(3) #must be some kind of identifier.
  data.u.pStream.open = cstreamopen(pystreamopen)
[snip]
  unfortunately that doesn't work because Python returns a TypeError: 
  incompatible types, CFunctionType instance instead of c_void_p instance
 
  Any ideas/help (please)?

Probably the best thing is if you define the union with the types of
the pointers to your functions instead of c_void_p, eg

  class cdStream(Structure):
   _fields_ = [(contextH, c_uint),
(open, cstreamopen),
(close, cstreamclose), # etc...

This will involve you re-ordering your definitions.

Or alternatively, you could cast the function pointer to a c_void_p
first, eg

  data.u.pStream.open = c_void_p( cstreamopen(pystreamopen) )

which should work but is less typesafe.

-- 
Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick
--
http://mail.python.org/mailman/listinfo/python-list


Re: Finding file details...

2008-05-30 Thread Kalibr
On May 30, 3:03 pm, Kam-Hung Soh [EMAIL PROTECTED] wrote:
 Kalibr wrote:
  On May 30, 1:41 am, Roger Upole [EMAIL PROTECTED] wrote:
  You can use the shell COM objects to access media properties
  as shown by Explorer.

  import win32com.client
  sh=win32com.client.Dispatch('Shell.Application')

  folder= r'M:\Music\Bob Dylan\Highway 61 Revisited'
  ns=sh.NameSpace(folder)

  ## the column index for Artist may vary from folder to folder
  for c in range(0,255):
  colname=ns.GetDetailsOf(None, c)
  if colname=='Artists':  ## This shows up as just Artist on XP
  for i in ns.Items():
  artist=ns.GetDetailsOf(i, c)
  if artist:
  print ns.GetDetailsOf(i, 0), artist
  break

  Roger

  I shall give that a go. (is the module you reference this one?
 http://python.net/crew/mhammond/win32/Downloads.html)

 If you installed ActiveState's Python, the win32com module should be
 installed.

 --
 Kam-Hung Soh a href=http://kamhungsoh.com/blog;Software Salariman/a

I gave your program a go, and it works magnificently.
Now I have to figure out how tro use it on a song by song basis
(I still suck at using classes).
Thanks so much for your help.
--
http://mail.python.org/mailman/listinfo/python-list


Re: should I put old or new style classes in my book?

2008-05-30 Thread Bruno Desthuilliers

[EMAIL PROTECTED] a écrit :

Hi All,

I am working on a revised edition of How To Think Like a Computer
Scientist,
which is going to be called Think Python.  It will be published by
Cambridge
University Press, but there will still be a free version under the GNU
FDL.

You can see the latest version at thinkpython.com; I am revising now,
so
I welcome all comments, suggestions, corrections, etc.

Anyway, I am posting to ask about the current status of new style
classes.
I am planning to present only one style in the book, because the
differences
between them don't matter for anything I am doing in the book.



The current edition of the book presents old style classes.  I am
considering
switching to new style classes on the assumption that this should be
the default
choice for new programs.  The drawback is that a lot of the online
documentation
still uses old style classes.

Thanks for any guidance you can provide.


Same remarks as anyone else that answered so far: definitively use 
new-style classes, and just add a note about the old-style syntax.


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


Re: Hungarian Notation

2008-05-30 Thread Michael Mabin
Variable names should have prefixes or suffixes (as I prefer) that represent
the kind of data they represent rather than the data type itself.
For example account_bal_am, order_qt, line_ct, first_nm.  Where am is
amount, qt is quantity and ct is count.  Coding standards could impose rules
on datatypes that should be used for these kinds:  am (amount) is a currency
field and should be represented by decimal values. qt (quantity) is a long,
nm a string and so on.

On Fri, May 30, 2008 at 3:31 AM, Lie [EMAIL PROTECTED] wrote:

 On May 27, 12:28 pm, inhahe [EMAIL PROTECTED] wrote:
  Does anybody know of a list for canonical prefixes to use for hungarian
  notation in Python?  Not that I plan to name all my variables with
 hungarian
  notation, but just for when it's appropriate.

 If it was me, I'd use an empty-defined class:

 class Fake(object):
pass

 data = 'headinfo=trash;headtrash=info'
 Header = Fake()
 Header.Str = data
 Header.Dict = parse(data)

 it saves name if it's important (alternatively, you may also use a
 dict or a tuple/list to store the string/dict pair).
 But using Fake class just like that is difficult to work with if I
 need to write to the data (not read only) and synchronizes the data,
 in that case, it's easy to extend the Fake Class:

 class Fake(object):
def __init__(self, data):
self.data = parse(data)

def toStr(self):
return str(self.data)
def fromStr(self, s):
self.data = parse(s)
Str = property(toStr, fromStr)

def toDict(self):
return self.data
def fromDict(self, s):
self.data = s
Dict = property(toDict, fromDict)

 you might go as far as overriding __str__ and __repr__ as appropriate.
 --
 http://mail.python.org/mailman/listinfo/python-list




-- 
| _ | * | _ |
| _ | _ | * |
| * | * | * |
--
http://mail.python.org/mailman/listinfo/python-list

Re: should I put old or new style classes in my book?

2008-05-30 Thread Eduardo O. Padoan
On Thu, May 29, 2008 at 3:06 PM, Jason [EMAIL PROTECTED] wrote:
 I've got Python 3.0 alpha 2.  In this version, it looks like you can
 define classes in either the old style or new style.  (I snipped the
 top line a bit in the following example):

Wrong. Py3k Classes are always new-style. They subclass object
implicitly when no superclass is given.

 Python 3.0a2 (r30a2:59405M, Dec  7 2007, 15:23:28
 Type help, copyright, credits or license
 class one(object): pass
 ...
 class two: pass
 ...
 two
 class '__main__.two'
 one
 class '__main__.one'
 type(one)
 type 'type'
 type(two)
 type 'type'


Both classes are new style.


-- 
 Eduardo de Oliveira Padoan
http://www.advogato.org/person/eopadoan/
http://twitter.com/edcrypt
Bookmarks: http://del.icio.us/edcrypt
--
http://mail.python.org/mailman/listinfo/python-list


Python 2.5.2 on Ubuntu Hardy Utf-8-Euro error

2008-05-30 Thread Josep
I'm playing with an application framework (or kinda) that's developed
with python, and it throws this error:


 File 
 /usr/lib/python2.5/site-packages/Dabo-0.8.3-py2.5.egg/dabo/db/dCursorMixin.py,
  line 281, in execute
 sql = unicode(sql, self.Encoding)
 LookupError: unknown encoding: utf_8_euro

At the application (DABO) mailing list, they have pointed that this has
to be a Python issue. As I'm a totally python newbie, I would ask if
somebody has experimented this kind of error, and if there is any known
solution. I've found no clue searching at Google right now.

My Python version is 2.5.2, Ubuntu Hardy .deb package.

Thanks in advance for your help.

-- 

Josep Sànchez
[papapep]
--
http://extralinux.net
--


signature.asc
Description: Això és una part	d'un missatge signada digitalment
--
http://mail.python.org/mailman/listinfo/python-list

how can i stop script from running on login ?

2008-05-30 Thread abhilash pp
Hi all,

One of my friends played some tricky thing, and now I am in great trouble,
please help
Here is the scenario  [windows xp ]:

He wrote one login script and put it on the start program folder under 'All
Users'
The script is like this it will issue a log off command when we login; due
to this I am not able to login to my system even he himself not able to
access the system and solve the problem. The main thing is the script is of
'.pyw' type so I can't able to close the CMD window to stop this script

How can I remove that script? Any help will be appreciated, thanks in
advance

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

Re: How to get all the variables in a python shell

2008-05-30 Thread caca
  Your project interests me. Actually I was thinking about doing the
same. I hadn't worked on it at all, but I though about it and had the
idea about reading the session namespace directly, which I though
would be stored in the __dict__ attribute of something.

  After reading your post, I have been trying a little bit, and I have
found a way to do it with ipython. If you open an ipython console,
press _ then hit TAB, you'll see it stores some useful information,
including all input, all output, and after some searching, a
dictionary matching all variables to its values.

__IPYTHON__.user_ns

  There is a little extra stuff in there that you don't want, but that
can be easily filtered (the extra stuff is either 'In', 'Out', 'help'
or starts with '_'). I've tried it, and you can change the value in
that dict to alter the value of the real variable. Say you have a
variable 'test':

test=5
__IPYTHON__.user_ns['test']=4
print test #prints 5

  If I get it right, python is a dynamic language, and you won't break
things by messing around with its inner stuff like this, but you
better check it.

  Is this what you had in mind?
--
http://mail.python.org/mailman/listinfo/python-list


Generating event from event

2008-05-30 Thread Gandalf
I have script which being triggered by pressing CTRL+Right mouse click
from any place in my O.P , Now I need to generate automatically event
like copy my selected item or double clicking the right mouse cursor
without user interfering.
how can i implement this width python?


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


Re: how can i stop script from running on login ?

2008-05-30 Thread Benjamin Kaplan
On Fri, May 30, 2008 at 8:44 AM, abhilash pp
[EMAIL PROTECTED][EMAIL PROTECTED]
wrote:

 Hi all,

 One of my friends played some tricky thing, and now I am in great trouble,
 please help
 Here is the scenario  [windows xp ]:

 He wrote one login script and put it on the start program folder under 'All
 Users'
 The script is like this it will issue a log off command when we login; due
 to this I am not able to login to my system even he himself not able to
 access the system and solve the problem. The main thing is the script is of
 '.pyw' type so I can't able to close the CMD window to stop this script

 How can I remove that script? Any help will be appreciated, thanks in
 advance

 Abhilash


Try running the machine in safe mode, then delete the script.
--
http://mail.python.org/mailman/listinfo/python-list

help

2008-05-30 Thread ha bo
hi 
i wanna paginate my table (x lines per pages),the size of my table is changing 
according to the user.
i wanna know if paginator.py can help me ,if yes how?
some one can help me 
ps:i use django
thank you 

_
Découvrez Windows Live Spaces et créez votre site Web perso en quelques clics !
http://spaces.live.com/signup.aspx--
http://mail.python.org/mailman/listinfo/python-list

Re: seg. fault with Py_BuildValue?

2008-05-30 Thread Christian Meesters
Ok now, I know where the error is: y actually contained refcounts. This,
of course, is complete nonsense and causes the interpreter to crash at some
point.

Thanks to all of you: You helped at least to track down the problem.

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


SQLObject 0.9.7

2008-05-30 Thread Oleg Broytmann
Hello!

I'm pleased to announce version 0.9.7, a minor bug fix release of SQLObject.


What is SQLObject
=

SQLObject is an object-relational mapper.  Your database tables are described
as classes, and rows are instances of those classes.  SQLObject is meant to be
easy to use and quick to get started with.

SQLObject supports a number of backends: MySQL, PostgreSQL, SQLite,
Firebird, Sybase, MSSQL and MaxDB (also known as SAPDB).


Where is SQLObject
==

Site:
http://sqlobject.org

Development:
http://sqlobject.org/devel/

Mailing list:
https://lists.sourceforge.net/mailman/listinfo/sqlobject-discuss

Archives:
http://news.gmane.org/gmane.comp.python.sqlobject

Download:
http://cheeseshop.python.org/pypi/SQLObject/0.9.7

News and changes:
http://sqlobject.org/News.html


What's New
==

News since 0.9.6


Small Features
~~

* Use VARCHAR(MAX) and VARBINARY(MAX) for MSSQL = 9.0.

* Run post_funcs after RowDestroySignal.

Bug Fixes
~

* Fixed a minor bug in Set column.

* A bug fixed for RowCreatedSignal together with InheritableSQLObject:
  run post_funcs after the entire hierarchy has been created.

* Aggregate functions now honors 'distinct'.

For a more complete list, please see the news:
http://sqlobject.org/News.html

Oleg.
-- 
 Oleg Broytmannhttp://phd.pp.ru/[EMAIL PROTECTED]
   Programmers don't die, they just GOSUB without RETURN.
--
http://mail.python.org/mailman/listinfo/python-list


SQLObject 0.10.2

2008-05-30 Thread Oleg Broytmann
Hello!

I'm pleased to announce version 0.10.2, a bugfix release of 0.10 branch
of SQLObject.


What is SQLObject
=

SQLObject is an object-relational mapper.  Your database tables are described
as classes, and rows are instances of those classes.  SQLObject is meant to be
easy to use and quick to get started with.

SQLObject supports a number of backends: MySQL, PostgreSQL, SQLite,
Firebird, Sybase, MSSQL and MaxDB (also known as SAPDB).


Where is SQLObject
==

Site:
http://sqlobject.org

Development:
http://sqlobject.org/devel/

Mailing list:
https://lists.sourceforge.net/mailman/listinfo/sqlobject-discuss

Archives:
http://news.gmane.org/gmane.comp.python.sqlobject

Download:
http://cheeseshop.python.org/pypi/SQLObject/0.10.2

News and changes:
http://sqlobject.org/News.html


What's New
==

News since 0.10.1
-

Small Features
~~

* Use VARCHAR(MAX) and VARBINARY(MAX) for MSSQL = 9.0.

* Run post_funcs after RowDestroySignal.

Bug Fixes
~

* Fixed a minor bug in Set column.

* A bug fixed for RowCreatedSignal together with InheritableSQLObject:
  run post_funcs after the entire hierarchy has been created.

* Aggregate functions now honors 'distinct'.

For a more complete list, please see the news:
http://sqlobject.org/News.html

Oleg.
-- 
 Oleg Broytmannhttp://phd.pp.ru/[EMAIL PROTECTED]
   Programmers don't die, they just GOSUB without RETURN.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.5.2 on Ubuntu Hardy Utf-8-Euro error

2008-05-30 Thread Sanoski
On May 30, 8:24 am, Josep [EMAIL PROTECTED] wrote:
 I'm playing with an application framework (or kinda) that's developed
 with python, and it throws this error:

  File 
  /usr/lib/python2.5/site-packages/Dabo-0.8.3-py2.5.egg/dabo/db/dCursorMixin.py,
   line 281, in execute
      sql = unicode(sql, self.Encoding)
  LookupError: unknown encoding: utf_8_euro

 At the application (DABO) mailing list, they have pointed that this has
 to be a Python issue. As I'm a totally python newbie, I would ask if
 somebody has experimented this kind of error, and if there is any known
 solution. I've found no clue searching at Google right now.
I've had nothing but problems ever since I upgraded to Hardy. I used
to be a die hard Ubuntu fan until recently. Maybe try a better OS


 My Python version is 2.5.2, Ubuntu Hardy .deb package.

 Thanks in advance for your help.

 --

 Josep Sànchez
 [papapep]
 --http://extralinux.net
 --

  signature.asc
 1KDownload

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


Re: should I put old or new style classes in my book?

2008-05-30 Thread Arnaud Delobelle
Eduardo O. Padoan [EMAIL PROTECTED] writes:

 On Thu, May 29, 2008 at 3:06 PM, Jason [EMAIL PROTECTED] wrote:
 I've got Python 3.0 alpha 2.  In this version, it looks like you can
 define classes in either the old style or new style.  (I snipped the
 top line a bit in the following example):

 Wrong. Py3k Classes are always new-style. They subclass object
 implicitly when no superclass is given.

I think he was talking about syntax, not object types.

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


Re: Generating event from event

2008-05-30 Thread Larry Bates

Gandalf wrote:

I have script which being triggered by pressing CTRL+Right mouse click
from any place in my O.P , Now I need to generate automatically event
like copy my selected item or double clicking the right mouse cursor
without user interfering.
how can i implement this width python?


thanks!

You didn't tell us enough to answer your question.  What GUI are you
using?  Nearly every one of them that I'm aware of allow you to register
handlers for such events.

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


Has a file been opened by another program ?

2008-05-30 Thread dj
Hello All,

First, Is there a python library, method or module that will tell you
if a file has been opened by another program (i.e: Word, PowerPoint,
IE etc.), the methods I have found in the standard library will only
work with the python open method.

Second, I want to take the time to thank each and everyone of you for
your help. If you have not already guessed, I am a python novice ( I
know your surprised), and I am learning a lot and have discovered alot
about python from your answers. So, I just want to say... THANK
YOU !
--
http://mail.python.org/mailman/listinfo/python-list


convert string containing list to list (or tuple) type

2008-05-30 Thread Poppy
I'm reading from a database a column that has a list of codes (comma 
seperated). When I read in the list I have a single value, see code sample 
below values for a, b, and c. These represent possible values in my 
database. I need to loop through each value so I can expand my data from 
this compressed view.

My code below works and creates my desired output but I believe there must 
be a better way this is very messy. My messy function that I'd like to 
replace is lst_codes(codes). Any alternative suggestions?

this is what I begin with
a = ',P,'
b = ',I,G,AQ,ET,K,BF,'
c = ',DZ,'
this is what I want (lists or tuples are fine)
['P']
['I', 'G', 'AQ', 'ET', 'K', 'BF']
['DZ']


def lst_codes(codes):
 turn a string of comma seperated codes into a real list object 
i = 0
lstD = []
while i  len(codes):
a = codes[i]
b = ,
if (i + 1)  len(codes):
b = codes[i + 1]
i = i + 1
else:
b = ,

if b  ,:
lstD.append(a + b)
i = i + 2
else:
lstD.append(a)
i = i + 1
return lstD


a = ',P,'
b = ',I,G,AQ,ET,K,BF,'
c = ',DZ,'

for ea in (a,b,c):
print lst_codes(ea.strip(,))


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


Re: convert string containing list to list (or tuple) type

2008-05-30 Thread Duncan Booth
Poppy [EMAIL PROTECTED] wrote:

 a = ',P,'
 b = ',I,G,AQ,ET,K,BF,'
 c = ',DZ,'
 
 for ea in (a,b,c):
 print lst_codes(ea.strip(,))
 

Why not just use:

 ea.strip(',').split(',')

?

-- 
Duncan Booth http://kupuguy.blogspot.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: convert string containing list to list (or tuple) type

2008-05-30 Thread Poppy
Arrgh. One of those days where I find an answer just after posting. I spend 
hours on the code below only to find I don't know how to use split to it's 
fullest.

 b.strip(,).split(,)
['I', 'G', 'AQ', 'ET', 'K', 'BF']

Poppy [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 I'm reading from a database a column that has a list of codes (comma 
 seperated). When I read in the list I have a single value, see code sample 
 below values for a, b, and c. These represent possible values in my 
 database. I need to loop through each value so I can expand my data from 
 this compressed view.

 My code below works and creates my desired output but I believe there must 
 be a better way this is very messy. My messy function that I'd like to 
 replace is lst_codes(codes). Any alternative suggestions?

 this is what I begin with
 a = ',P,'
 b = ',I,G,AQ,ET,K,BF,'
 c = ',DZ,'
 this is what I want (lists or tuples are fine)
 ['P']
 ['I', 'G', 'AQ', 'ET', 'K', 'BF']
 ['DZ']


 def lst_codes(codes):
 turn a string of comma seperated codes into a real list object 
i = 0
lstD = []
while i  len(codes):
a = codes[i]
b = ,
if (i + 1)  len(codes):
b = codes[i + 1]
i = i + 1
else:
b = ,

if b  ,:
lstD.append(a + b)
i = i + 2
else:
lstD.append(a)
i = i + 1
return lstD


 a = ',P,'
 b = ',I,G,AQ,ET,K,BF,'
 c = ',DZ,'

 for ea in (a,b,c):
print lst_codes(ea.strip(,))

 


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


Re: How to covert ASCII to integer in Python?

2008-05-30 Thread David C. Ullrich
In article [EMAIL PROTECTED],
 Skonieczny, Chris [EMAIL PROTECTED] wrote:

 YOU SHOULD REMOVE or CORRECT YOUR POST here: 
 http://mail.python.org/pipermail/python-list/2007-February/427841.html  

Why? There's nothing wrong there.

 It is not true - eg. try : 
 a='P'# P is ASCII , isn't it ? 
 b=int(a)
 and what you will get ? An error !!!

You really don't see any difference between
convert '1' to an integer and convert 'P' to an integer?

In case there's actually a problem you're trying to solve
here, try ord instead of int.

 Or probably you yourself should - quote : 
 You probably should go through the tutorial ASAP that is located here:
 
 http://docs.python.org/tut/ 
 
 -
 [Image]

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


Re: definition of a highlevel language?

2008-05-30 Thread Henrique Dante de Almeida
On May 26, 6:06 pm, Paul Miller [EMAIL PROTECTED] wrote:
 On Mon, 26 May 2008 15:49:33 -0400, Dan Upton wrote:
  On Mon, May 26, 2008 at 3:22 PM,  [EMAIL PROTECTED] wrote:
  I don't know if it would necessarily look like the CPython VM, except
  for the decode stage (this being said without any knowledge of the
  CPython implementation, but with more than I ever thought I'd know about
  processor architecture/microarchitecture)

 Out of curiosity, do you know how easy it would be to make a Python chip
 using FPGAs?  I have little to no hardware knowledge, but it sounds like
 a fun project in any case.  Even if it's not likely to have blazing
 performance, it'd be cool to load Python bytecode directly into
 memory. :-)

 --
 code.py: a blog about Python.  http://pythonista.wordpress.com
 ** Posted fromhttp://www.teranews.com**

 The python VM is too high level. :-) I think a python CPU would
need to be developed in two layers, one that looks like a typical
processor and another that executes complex instructions
(microcode ?). The low level part takes some weeks (one week or so if
you have the whole architecture figured out) in VHDL. Once I claimed
to have done this in an April Fool's day. It was fun. :-D
--
http://mail.python.org/mailman/listinfo/python-list


Re: UNIX credential passing

2008-05-30 Thread Sebastian 'lunar' Wiesner
[ Kris Kennaway [EMAIL PROTECTED] ]

 I want to make use of UNIX credential passing on a local domain socket
 to verify the identity of a user connecting to a privileged service.
 However it looks like the socket module doesn't implement
 sendmsg/recvmsg wrappers, and I can't find another module that does this
 either.  Is there something I have missed?

http://pyside.blogspot.com/2007/07/unix-socket-credentials-with-python.html

Illustrates, how to use socket credentials without sendmsg/recvmsg and so
without any need for patching.


-- 
Freedom is always the freedom of dissenters.
  (Rosa Luxemburg)
--
http://mail.python.org/mailman/listinfo/python-list


Re: Generating event from event

2008-05-30 Thread Gandalf
On May 30, 3:43 pm, Larry Bates [EMAIL PROTECTED] wrote:
 Gandalf wrote:
  I have script which being triggered by pressing CTRL+Right mouse click
  from any place in my O.P , Now I need to generate automatically event
  like copy my selected item or double clicking the right mouse cursor
  without user interfering.
  how can i implement this width python?

  thanks!

 You didn't tell us enough to answer your question.  What GUI are you
 using?  Nearly every one of them that I'm aware of allow you to register
 handlers for such events.

 -Larry
windows xp
--
http://mail.python.org/mailman/listinfo/python-list


Re: Getting up and running with Python on a Mac

2008-05-30 Thread David C. Ullrich
In article 
[EMAIL PROTECTED],
 [EMAIL PROTECTED] wrote:

 I've just bought an iMac (OS X 10.5.2, will almost immediately jump to
 10.5.3), and am looking to install Python on it, and to use it with
 XCode, Apple's IDE. 

If that's what you really want to do then start XCode, select
New Project and look for the ones with Python in their names.

I was excited to hear that Python was going to be automatically
integrated into XCode in OS 10.5. I tried it once. I should say
I really didn't give it a fair trial - the impression I got from
my unfair trial was I'd have to learn a lot about Cocoa to do
anything useful. 

Searched a little, decided to try wxPython next, and I was
very happy with that. Seems much easier - also as far as I
could see there was nothing but a 'Hello World' example
included in XCode, while wxPython comes with a truly amazing
suite of complete examples (the C++ wxWidgets book recommends
looking at wxPython for the examples!)

Some googling suggests that a number of people
 have had trouble getting Python to run satisfactorily on their Macs.
 This is my first Mac, and I'd appreciate some guidance on what to do
 (and what not to) when installing Python and potential problems to
 keep an eye open for. I want to do a fair bit of scientific /
 numerical computing, so it would seem that SAGE ot the Enthought
 Python distribution would seem to be the most relevant  - I'd
 appreciate your guidance on getting Python to run on a Mac with a
 particular focus on these two distributions.
 
 Thank you in advance
 
 Thomas Philips

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


Re: Help needed in choosing an algorithm for Cryptographic services.

2008-05-30 Thread Peter Pearson
On Thu, 29 May 2008 20:27:35 -0500, Larry Bates wrote:
 abhishek wrote:
 Hi group, recently my employer asked me too implement encryption/
 decryption for secure data transfer over internet. Problem is that the
 client application is written using C# and the webserver where i need
 to store the information is developed using python.
 
 My situation of dilemma is which cryptographic method suits me best
 for this purpose.
 
 Help/Suggestions are urgently required

The proper newsgroup for this question is sci.crypt.

Data security is a complex and difficult problem, and you are likely
to fail in the worst possible way: implementing something that is
weak but that you believe to be strong.  Some advice: (1) Use
off-the-shelf products like PGP or GPG; don't write your own.
(2) Read Bruce Schneier's Applied Cryptography to get a feeling
for the dimensions of the problem. (3) Start by composing a
clear statement of what you need, avoiding vague terms like
security.  If you don't know where you're going, you can't
tell whether you've arrived.

-- 
To email me, substitute nowhere-spamcop, invalid-net.
--
http://mail.python.org/mailman/listinfo/python-list


Re: A video introducing Ulipad, an IDE mainly for Python

2008-05-30 Thread David C. Ullrich
In article [EMAIL PROTECTED],
 Dick Moores [EMAIL PROTECTED] wrote:

 I've been using Ulipad, a free IDE mainly for Python, and written in 
 wxPython, for a couple of years, and think it's terrific. Now another 
 user, Kelie Feng, has made an 8-minute video showing it off. The 
 visual clarity of the video is remarkable. You can download it 
 (Introducing_Ulipad_2008-05-22.avi), and a codec (tscc.exe) that may 
 be necessary for your player, from http://www.rcblue.com/u3/.

I skipped the video and tried Ulipad. Looks very interesting.

The documentation I got is mostly in Chinese. Is there an
English version somewhere?

 Dick Moores

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


Re: How to covert ASCII to integer in Python?

2008-05-30 Thread Philipp Pagel
Skonieczny, Chris [EMAIL PROTECTED] wrote:

 YOU SHOULD REMOVE or CORRECT YOUR POST here: 
 http://mail.python.org/pipermail/python-list/2007-February/427841.html  
  
 It is not true - eg. try : 
 a='P'# P is ASCII , isn't it ? 
 b=int(a)
 and what you will get ? An error !!!

'P' is obviously not an ASCII representation of a number.
What did you expect? The closest number by visual appearance?

cu
Philipp

-- 
Dr. Philipp Pagel
Lehrstuhl f. Genomorientierte Bioinformatik
Technische Universität München
http://mips.gsf.de/staff/pagel
--
http://mail.python.org/mailman/listinfo/python-list


Re: definition of a highlevel language?

2008-05-30 Thread Dan Upton
On Mon, May 26, 2008 at 5:06 PM, Paul Miller [EMAIL PROTECTED] wrote:
 On Mon, 26 May 2008 15:49:33 -0400, Dan Upton wrote:

 On Mon, May 26, 2008 at 3:22 PM,  [EMAIL PROTECTED] wrote:

 I don't know if it would necessarily look like the CPython VM, except
 for the decode stage (this being said without any knowledge of the
 CPython implementation, but with more than I ever thought I'd know about
 processor architecture/microarchitecture)

 Out of curiosity, do you know how easy it would be to make a Python chip
 using FPGAs?  I have little to no hardware knowledge, but it sounds like
 a fun project in any case.  Even if it's not likely to have blazing
 performance, it'd be cool to load Python bytecode directly into
 memory. :-)


I don't really know, but I would guess that it's hard, or at least
time-consuming.  The best example I can give you is JOP: A Java
Optimized Processor which was basically an FPGA-based chip that
executed Java bytecode natively.  If you're curious, you can read
about it at http://www.jopdesign.com/ .  It looks like it was done as
a PhD thesis at the Vienna University of Technology, and unless
Austria has significantly lower PhD requirements... ;)
--
http://mail.python.org/mailman/listinfo/python-list


running on WinPC + comunication via USB

2008-05-30 Thread martin . nkm
Hello, I have two questions.
1/ If I want to use Python and let my WinPC communicate via RS-232
with external embedded computer I know there is a pyserial module,
which I can use it. But what will happen if I want to replace RS-232
by USB? I know I can have virtual COM port, but all the configuration
parameters basically refer to RS-232 parameters - baudrate, bits,
stopbits, parity. In case of USB that's a nonsense I think. Does
anybody know?
2/ Second is a basic question. Do I need also cygwin running on my
Windows PC to get running Python scripts? Or is that Python
interpreter (Win executable) self efficient? Thanks.
--
http://mail.python.org/mailman/listinfo/python-list


Re: How to covert ASCII to integer in Python?

2008-05-30 Thread Mensanator
On May 30, 10:03�am, Philipp Pagel [EMAIL PROTECTED]
wrote:
 Skonieczny, Chris [EMAIL PROTECTED] wrote:
  YOU SHOULD REMOVE or CORRECT YOUR POST here:
 http://mail.python.org/pipermail/python-list/2007-February/427841.html�

  It is not true - eg. try :
  a='P' � � � � � �# P is ASCII , isn't it ?
  b=int(a)
  and what you will get ? An error !!!

 'P' is obviously not an ASCII representation of a number.

It is in base 36.

 a='P'
 b=int(a,36)
 b
25


 What did you expect? The closest number by visual appearance?

 cu
 � � � � Philipp

 --
 Dr. Philipp Pagel
 Lehrstuhl f. Genomorientierte Bioinformatik
 Technische Universit�t M�nchenhttp://mips.gsf.de/staff/pagel

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

Re: Python 2.5.2 on Ubuntu Hardy Utf-8-Euro error

2008-05-30 Thread Peter Otten
Josep wrote:

 I'm playing with an application framework (or kinda) that's developed
 with python, and it throws this error:
 
 
 File
 /usr/lib/python2.5/site-packages/Dabo-0.8.3-py2.5.egg/dabo/db/dCursorMixin.py,
 line 281, in execute
 sql = unicode(sql, self.Encoding)
 LookupError: unknown encoding: utf_8_euro
 
 At the application (DABO) mailing list, they have pointed that this has
 to be a Python issue. As I'm a totally python newbie, I would ask if
 somebody has experimented this kind of error, and if there is any known
 solution. I've found no clue searching at Google right now.
 
 My Python version is 2.5.2, Ubuntu Hardy .deb package.

Python might get confused by an @EURO suffix in the locale:

$ [EMAIL PROTECTED]
$ python -cimport locale; print locale.getdefaultlocale()
('de_DE', 'utf_8_euro')

Try setting the LANG environment variable to something like

$ LANG=de_DE.UTF-8
$ python -cimport locale; print locale.getdefaultlocale()
('de_DE', 'UTF8')

before you run your program (use ca_ES or whatever you need instead of
de_DE).

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


Re: Python and Flaming Thunder

2008-05-30 Thread Grant Edwards
On 2008-05-30, Torsten Bronger [EMAIL PROTECTED] wrote:
 Hall?chen!

 Duncan Booth writes:

 [...]

 I don't understand your problem: it's just a single thread so
 killfile or skip it.

 Although I agree with you that there is no problem, *this* is not a
 good justification for this thread.  One should stay on topic in
 *every* thread.

I've noticed that a lot of things that should be, aren't.

The percentage of off-topic threads in c.l.p is extraordinarily
low by normal Usenet standards.  One oughtn't complain about it
lest one jinx things and reduce c.l.p to the state of the rest
of Usenet. 

I wouldn't even consider the thread all that OT, but maybe
that's just me.

-- 
Grant Edwards   grante Yow! !  Everybody out of
  at   the GENETIC POOL!
   visi.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: help

2008-05-30 Thread J. Cliff Dyer
Take a look at django's built in pagination features:

http://www.djangoproject.com/documentation/generic_views/

http://www.djangoproject.com/documentation/pagination/

Also, take a look at the django specific mailing list.
[EMAIL PROTECTED]

Cheers,
Cliff

On Fri, 2008-05-30 at 12:59 +, ha bo wrote:
 hi 
 i wanna paginate my table (x lines per pages),the size of my table is
 changing according to the user.
 i wanna know if paginator.py can help me ,if yes how?
 some one can help me 
 ps:i use django
 thank you 
 
 
 
 __
 Tous vos amis discutent sur Messenger, et vous ? Téléchargez
 Messenger, c'est gratuit !
 --
 http://mail.python.org/mailman/listinfo/python-list

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

Re: running on WinPC + comunication via USB

2008-05-30 Thread Diez B. Roggisch

[EMAIL PROTECTED] schrieb:

Hello, I have two questions.
1/ If I want to use Python and let my WinPC communicate via RS-232
with external embedded computer I know there is a pyserial module,
which I can use it. But what will happen if I want to replace RS-232
by USB? I know I can have virtual COM port, but all the configuration
parameters basically refer to RS-232 parameters - baudrate, bits,
stopbits, parity. In case of USB that's a nonsense I think. Does
anybody know?


Depending on the setup - no, it's the exact same thing. If e.g. the 
usb-device is a usb2serial converter or otherwise offers it's serveces 
as a serial-like device, it should work.


Additionally, there is libusb + a python-wrapping for that.


2/ Second is a basic question. Do I need also cygwin running on my
Windows PC to get running Python scripts? Or is that Python
interpreter (Win executable) self efficient? Thanks.


No cygwin needed. In fact you need to be careful *not* to mix python and 
cygwin-python. They can happily co-exist - but installing 
3rd-party-packages for one doesn't imply they are available for the other.


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


Re: Generating event from event

2008-05-30 Thread Diez B. Roggisch

Gandalf schrieb:

On May 30, 3:43 pm, Larry Bates [EMAIL PROTECTED] wrote:

Gandalf wrote:

I have script which being triggered by pressing CTRL+Right mouse click
from any place in my O.P , Now I need to generate automatically event
like copy my selected item or double clicking the right mouse cursor
without user interfering.
how can i implement this width python?
thanks!

You didn't tell us enough to answer your question.  What GUI are you
using?  Nearly every one of them that I'm aware of allow you to register
handlers for such events.

-Larry

windows xp


Oh please. You have been around here  asking enough questions to 
finally notice that more information is needed - actually, you have been 
providing this at other times. What GUI-Toolkit are you using, on which OS?


Yes, I now *know* that it is WX - because I searched the archives. But 
that is not the thing here - provide enough information yourself.


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


Re: Python and Flaming Thunder

2008-05-30 Thread Torsten Bronger
Hallöchen!

Grant Edwards writes:

 On 2008-05-30, Torsten Bronger [EMAIL PROTECTED] wrote:

 Duncan Booth writes:

 [...]

 I don't understand your problem: it's just a single thread so
 killfile or skip it.

 Although I agree with you that there is no problem, *this* is not
 a good justification for this thread.  One should stay on topic
 in *every* thread.

 [...]

 I wouldn't even consider the thread all that OT, but maybe that's
 just me.

Me too, and therefore I see no problem.  But one shouldn't break the
rules, relying on all others sticking to them.

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
  Jabber ID: [EMAIL PROTECTED]
   (See http://ime.webhop.org for further contact info.)
--
http://mail.python.org/mailman/listinfo/python-list


Re: how can i stop script from running on login ?

2008-05-30 Thread abhilash pp
thanks Benjamin, i have to try it out

On Fri, May 30, 2008 at 6:31 PM, Benjamin Kaplan [EMAIL PROTECTED]
wrote:



 On Fri, May 30, 2008 at 8:44 AM, abhilash pp [EMAIL PROTECTED][EMAIL 
 PROTECTED]
 wrote:

 Hi all,

 One of my friends played some tricky thing, and now I am in great trouble,
 please help
 Here is the scenario  [windows xp ]:

 He wrote one login script and put it on the start program folder under
 'All Users'
 The script is like this it will issue a log off command when we login; due
 to this I am not able to login to my system even he himself not able to
 access the system and solve the problem. The main thing is the script is of
 '.pyw' type so I can't able to close the CMD window to stop this script

 How can I remove that script? Any help will be appreciated, thanks in
 advance

 Abhilash


 Try running the machine in safe mode, then delete the script.


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

Re: Generating event from event

2008-05-30 Thread Gandalf
Hi Diez, I can't see how it  matter which GUI-Toolkit i uses because I
can combine libraries.
I think all that matter is that i work with windows XP.

if you ever done something like that or you familiar with article
which can show me how to implement what I asked it would help me

Thank you very much
--
http://mail.python.org/mailman/listinfo/python-list


Calling instance methods from a decorator

2008-05-30 Thread Kirk Strauser
I'm trying to write a decorator that would do something like:

def trace(before, after):
def middle(func):
def inner(*args, **kwargs):
func.im_self.debugfunction(before)
result = func(*args, **kwargs)
func.im_self.debugfunction(after)
return result
return inner
   return middle

class Foo(object):
def __init__(self, myname):
self.name = myname

def debugfunction(self, message):
print 'Instance %s says: %s' % (self.name, message)

@trace('calling', 'finished')
def bar(self, arg):
print arg

 Foo('snake').bar(123)
Instance snake says: calling
123
Instance snake says: finished

The gotcha seems to be that there's no way to get to 'self' from within the
inner function, since func will only have the normal attributes:

 print dir(func)
['__call__', '__class__', '__delattr__', '__dict__', '__doc__', '__get__', 
'__getattribute__', '__hash__', '__init__', '__module__', '__name__', 
'__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', 
'func_closure', 'func_code', 'func_defaults', 'func_dict', 'func_doc', 
'func_globals', 'func_name']

There's no nice im_self to bounce off of or anything.  I seem to be going
about this all wrong.  What's a good approach to get the desired effect?
-- 
Kirk Strauser
The Day Companies
--
http://mail.python.org/mailman/listinfo/python-list


Re: Calling instance methods from a decorator

2008-05-30 Thread Diez B. Roggisch

Kirk Strauser schrieb:

I'm trying to write a decorator that would do something like:

def trace(before, after):
def middle(func):
def inner(*args, **kwargs):
func.im_self.debugfunction(before)
result = func(*args, **kwargs)
func.im_self.debugfunction(after)
return result
return inner
   return middle

class Foo(object):
def __init__(self, myname):
self.name = myname

def debugfunction(self, message):
print 'Instance %s says: %s' % (self.name, message)

@trace('calling', 'finished')
def bar(self, arg):
print arg


Foo('snake').bar(123)

Instance snake says: calling
123
Instance snake says: finished

The gotcha seems to be that there's no way to get to 'self' from within the
inner function, since func will only have the normal attributes:


print dir(func)

['__call__', '__class__', '__delattr__', '__dict__', '__doc__', '__get__', 
'__getattribute__', '__hash__', '__init__', '__module__', '__name__', 
'__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', 
'func_closure', 'func_code', 'func_defaults', 'func_dict', 'func_doc', 
'func_globals', 'func_name']

There's no nice im_self to bounce off of or anything.  I seem to be going
about this all wrong.  What's a good approach to get the desired effect?


Of course you can get the self - just use the first paramter, because it 
 *is* self. Self is just a parameter - nothing special.


Alternatively, declare inner like this:

def inner(self, *args, **kwargs):
...
try:
   return func(self, *args, **kwargs)
finally:
   


Note the additional try/finally. It's got nothing todo with your 
original problem - but you should use it to guarantee that your trace 
gets called when leaving the call.


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


Re: A video introducing Ulipad, an IDE mainly for Python

2008-05-30 Thread Dick Moores

At 07:57 AM 5/30/2008, David C. Ullrich wrote:

In article [EMAIL PROTECTED],
 Dick Moores [EMAIL PROTECTED] wrote:

 I've been using Ulipad, a free IDE mainly for Python, and written in
 wxPython, for a couple of years, and think it's terrific. Now another
 user, Kelie Feng, has made an 8-minute video showing it off. The
 visual clarity of the video is remarkable. You can download it
 (Introducing_Ulipad_2008-05-22.avi), and a codec (tscc.exe) that may
 be necessary for your player, from http://www.rcblue.com/u3/.

I skipped the video and tried Ulipad. Looks very interesting.

The documentation I got is mostly in Chinese. Is there an
English version somewhere?


F1 will open UliPad Documentations. Check out the HowTo's and the 
FAQ. And subscribe to the Ulipad list at Google Groups 
(http://groups.google.com/group/ulipad). The main developer, 
Limodou, is in Beijing, but he's very quick in answering questions 
posed to the list.


Dick Moores

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


Re: Python 2.5.2 on Ubuntu Hardy Utf-8-Euro error

2008-05-30 Thread Martin v. Löwis
 File 
 /usr/lib/python2.5/site-packages/Dabo-0.8.3-py2.5.egg/dabo/db/dCursorMixin.py,
  line 281, in execute
 sql = unicode(sql, self.Encoding)
 LookupError: unknown encoding: utf_8_euro
 
 At the application (DABO) mailing list, they have pointed that this has
 to be a Python issue.

It's definitely not a Python issue.

 As I'm a totally python newbie, I would ask if
 somebody has experimented this kind of error, and if there is any known
 solution. I've found no clue searching at Google right now.

The problem is that self.Encoding is incorrect - it should not be
utf_8_euro. Instead, it should be UTF-8 (or perhaps utf_8). DABO
shouldn't use locale.getdefaultlocale()[1], but
locale.getpreferredencoding().

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


PyDev multiple source files?

2008-05-30 Thread RossGK
Newbie questions on PyDev project setup.   Things are going fine -
writing python code in eclipse/pydev and running them with various
imports etc, doing wxpython stuff blah, blah, blah. My .py code is in
a module, in a package, in a project. It runs fine.

Now I want to be able to break my single source file up into multiple
files to segregate functions, divide up with others, etc, but I don't
know how to configure it. I pulled one simple class definition out of
my single source file and created a new .py file with just that in
there. But now I'm stalled...

What is the equivalent of an 'include' statement. I assume there's
something I put into one .py file to say I'm using stuff in another
local .py file.   I tried using import but it doesn't seem to work -
ie code doesn't know about the class in the other file.

Also, how about global vars that are needed across multiple .py files?
Where do I declare them to be understood in all the files that use
that global.

I suspect there is something I do in __init__.py - perhaps the
equivalent of 'include' statements in there with all my globals
stuffed in there too???   I'm lost here, but will continue to play
with it.  Any hints appreciated.  Surely all python developers don't
cram everything into one huge file (I hope).

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


Re: Help needed in choosing an algorithm for Cryptographic services.

2008-05-30 Thread Paul Rubin
abhishek [EMAIL PROTECTED] writes:
 Hi group, recently my employer asked me too implement encryption/
 decryption for secure data transfer over internet. Problem is that the
 client application is written using C# and the webserver where i need
 to store the information is developed using python.

Use one of the SSL wrappers.  Note that if you're using a recent
Debian distro, make sure to take the latest OpenSSL update since they
had an unbelievably bad screwup that destroyed their versions of
OpenSSL's security for a while.  That applies to all Debian based
distros including Ubuntu, but not to non-Debian derivatives such as
Fedora.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Generating event from event

2008-05-30 Thread Mike Driscoll
On May 30, 12:11 pm, Gandalf [EMAIL PROTECTED] wrote:
 Hi Diez, I can't see how it  matter which GUI-Toolkit i uses because I
 can combine libraries.
 I think all that matter is that i work with windows XP.

 if you ever done something like that or you familiar with article
 which can show me how to implement what I asked it would help me

 Thank you very much

It matters because each Python GUI toolkit works differently. Tkinter
does it via Tk/tcl calls, wxPython uses the wx library and pyGTK does
it in yet another way. The basic ideas are the same, but the
implementations are quite different.

In wx, for example, there are mouse events called wx.MouseEvent:

http://www.wxpython.org/docs/api/wx.MouseEvent-class.html

In Tkinter, they do the same thing, but the calls are almost
completely different. See the following for examples:

http://www.pythonware.com/library/tkinter/introduction/events-and-bindings.htm

You probably either want the MouseEvents or to create an
AcceleratorTable.

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


Re: Python 2.5.2 on Ubuntu Hardy Utf-8-Euro error

2008-05-30 Thread Peter Otten
Martin v. Löwis wrote:

 File
 /usr/lib/python2.5/site-packages/Dabo-0.8.3-py2.5.egg/dabo/db/dCursorMixin.py,
 line 281, in execute
 sql = unicode(sql, self.Encoding)
 LookupError: unknown encoding: utf_8_euro
 
 At the application (DABO) mailing list, they have pointed that this has
 to be a Python issue.
 
 It's definitely not a Python issue.
 
 As I'm a totally python newbie, I would ask if
 somebody has experimented this kind of error, and if there is any known
 solution. I've found no clue searching at Google right now.
 
 The problem is that self.Encoding is incorrect - it should not be
 utf_8_euro. Instead, it should be UTF-8 (or perhaps utf_8). DABO
 shouldn't use locale.getdefaultlocale()[1], but
 locale.getpreferredencoding().

I think that is the effect of a bug:

 locale._parse_localename([EMAIL PROTECTED])
('en_US', 'utf_8_euro')

The function first normalizes the @ away and then looks for it. Is that
the expected behaviour?

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

Re: PyDev multiple source files?

2008-05-30 Thread RossGK
On May 30, 2:10 pm, RossGK [EMAIL PROTECTED] wrote:

 Now I want to be able to break my single source file up into multiple
 files to segregate functions, divide up with others, etc, but I don't
 know how to configure it.

Found a reference that helped me out:

http://www.python.org/doc/2.1.3/tut/node8.html

The keys for me are that a) a file named junk.py is called a module (I
thought a module was a set of files within a package - nope just a
source file).

Import is the right thing for an 'include' action - but after you
import you need to hierarchically reference the contents of the
imported module.   So if my junk.py 'module' contains a def things,
then after I have done my import junk  I refer to things as
junk.things

Global seem to have a scope of only their current module. So the
question that comes to mind is how to create a global global.  Can I
stick it into __init_.py or something and have it available for the
whole package?
--
http://mail.python.org/mailman/listinfo/python-list


RE: PyDev multiple source files?

2008-05-30 Thread Sells, Fred
the short answer is

a file is a module; therefore to 'include' access to 'myclass' in file xyz.py 
from another file called 'abc.py'  you would put this in abc.py

import xyz  #note no '.py'
x = xyz.myclass()
or
from xyz import myclass  #if you're lazy use ... import *
x = myclass()

see the basic tutorial on modules and importing

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED]
 Behalf Of RossGK
 Sent: Friday, May 30, 2008 2:10 PM
 To: python-list@python.org
 Subject: PyDev multiple source files?
 
 
 Newbie questions on PyDev project setup.   Things are going fine -
 writing python code in eclipse/pydev and running them with various
 imports etc, doing wxpython stuff blah, blah, blah. My .py code is in
 a module, in a package, in a project. It runs fine.
 
 Now I want to be able to break my single source file up into multiple
 files to segregate functions, divide up with others, etc, but I don't
 know how to configure it. I pulled one simple class definition out of
 my single source file and created a new .py file with just that in
 there. But now I'm stalled...
 
 What is the equivalent of an 'include' statement. I assume there's
 something I put into one .py file to say I'm using stuff in another
 local .py file.   I tried using import but it doesn't seem to work -
 ie code doesn't know about the class in the other file.
 
 Also, how about global vars that are needed across multiple .py files?
 Where do I declare them to be understood in all the files that use
 that global.
 
 I suspect there is something I do in __init__.py - perhaps the
 equivalent of 'include' statements in there with all my globals
 stuffed in there too???   I'm lost here, but will continue to play
 with it.  Any hints appreciated.  Surely all python developers don't
 cram everything into one huge file (I hope).
 
 Ross.
 --
 http://mail.python.org/mailman/listinfo/python-list
 
--
http://mail.python.org/mailman/listinfo/python-list


Re: Calling instance methods from a decorator

2008-05-30 Thread Kirk Strauser
At 2008-05-30T17:40:17Z, Diez B. Roggisch [EMAIL PROTECTED] writes:

 Of course you can get the self - just use the first paramter, because it
 *is* self. Self is just a parameter - nothing special.

If I blame it on being a long week, can I keep my geek card?
-- 
Kirk Strauser
The Day Companies
--
http://mail.python.org/mailman/listinfo/python-list


Spring Python version 0.5.0 is released

2008-05-30 Thread Goldfish
Spring Python (http://springpython.webfactional.com) version 0.5.0 was
released today.

It contains updates to DatabaseTemplate and DatabaseTransactions,
along with more testing underneath MySQL, PostGreSQL, and Sqlite.
Support for Oracle has been added, but only minimally tested so far.

Spring Python has been re-licensed underneath the Apache License 2.0,
making it more business friendly.

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


python, dlls, and multiple instances

2008-05-30 Thread Patrick Stinson
Is it a correct to assume that you can use multiple instances of
python altogether if each is loaded from a separate dll? For instance,
if I write a couple of dll/so libs, and each has python statically
linked in, is it safe to assume that since dlls use their own address
space then each dll would have it's own GIL, and will therefore
coexist safely within the same app? This is correct across all
platforms, yes?

I ask because I will be writing an audio plugin that uses python both
for the gui and the audio thread. The audio thread must not be
blocked, and will also be set up as a restricted execution environment
to prevent the usual dangerous calls to open, socket, etc. The python
running in the application thread may be blocked and may do whatever
it wants.

I think my understanding is correct since our current dll
implementation statically links python, and I know that the host app
(Ableton Live) also uses python for it's scripting engine. This should
be fun, since I've wanted to write a recipe for using python in an
audio plugin GUIs for a while now.

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


Re: make a string a list

2008-05-30 Thread Tobiah

 or a string iterable ? How can I do that. I have lots of '\r\n'
 characters in the string which I think can be easier if it were made
 into a list and I can easily see if the required value (its a numeral)
 is present in it or not after some position or after some characters'
 position.

They already are.  They are quite like lists in many ways:

 s = 'abcdefg'
 for c in s: print c
...
a
b
c
d
e
f
g
 s[3]
'd'
 s = foo\r\n
 s.find(\r)
3
 s.replace(\r, ).replace(\n, )
'foo'
   

** Posted from http://www.teranews.com **
--
http://mail.python.org/mailman/listinfo/python-list


accumulator generators

2008-05-30 Thread Cameron
I was reading this a href=this http://www.paulgraham.com/icad.html;Paul
Graham article/a and he builds an accumuator generator function in
the appendix. His looks like this:

pre
def foo(n):
  s = [n]
  def bar(i):
s[0] += i
return s[0]
  return bar
/pre

Why does that work, but not this:

pre
def foo(n):
  s = n
  def bar(i):
s += i
return s
  return bar
/pre
--
http://mail.python.org/mailman/listinfo/python-list


Re: should I put old or new style classes in my book?

2008-05-30 Thread Aahz
In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] wrote:

Anyway, I am posting to ask about the current status of new style
classes.  I am planning to present only one style in the book, because
the differences between them don't matter for anything I am doing in
the book.

You've got a tough use-case.  When is your book supposed to be done?  To
what extent to you want to make your book work with 3.x?

Overall, I'm generally in favor of presenting both (I'm opposed to
new-style-only), but in your case it sounds like just new-style would be
better.
-- 
Aahz ([EMAIL PROTECTED])   * http://www.pythoncraft.com/

Need a book?  Use your library!
--
http://mail.python.org/mailman/listinfo/python-list


Re: The Importance of Terminology's Quality

2008-05-30 Thread John Thingstad

På Fri, 30 May 2008 02:56:37 +0200, skrev David Combs [EMAIL PROTECTED]:


In article [EMAIL PROTECTED],
Robert Maas, http://tinyurl.com/uh3t  
[EMAIL PROTECTED] wrote:

From: [EMAIL PROTECTED] [EMAIL PROTECTED]
the importance of naming of functions.




Lisp is *so* early a language (1960?), preceeded mainly only by Fortran  
(1957?)?,
and for sure the far-and-away the first as a platform for *so many*  
concepts

of computer-science, eg lexical vs dynamic (special) variables, passing
*unnamed* functions as args (could Algol 60 also do something like that,
via something it maybe termed a thunk), maybe is still the only one
in which program and data have the same representation -- that it'd
seem logical to use it's terminology in all languages.

From C is the very nice distinction between formal and actual args.

And from algol-60, own and local -- own sure beats static!

And so on.


To me, it's too bad that that hacker-supreme (and certified genius)
Larry W. likes to make up his own terminology for Perl.  Sure makes
for a lot of otherwise-unnecessary pages in the various Perl texts,
as well as posts here.

Of course, a whole lot better his terminology than no language at all!


David




Perl is solidly based in the UNIX world on awk, sed, bash and C.
I don't like the style, but many do.

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


Re: accumulator generators

2008-05-30 Thread Diez B. Roggisch

Cameron schrieb:

I was reading this a href=this http://www.paulgraham.com/icad.html;Paul
Graham article/a and he builds an accumuator generator function in
the appendix. His looks like this:

pre
def foo(n):
  s = [n]
  def bar(i):
s[0] += i
return s[0]
  return bar
/pre

Why does that work, but not this:

pre
def foo(n):
  s = n
  def bar(i):
s += i
return s
  return bar
/pre


Because python's static analysis infers s as being a variable local to 
bar in the second case - so you can't modify it in the outer scope.


In the future, you may declare

def bar(i):
nonlocal s
...


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


Re: Showing the method's class in expection's traceback

2008-05-30 Thread Agustin Villena
To this therad, I received 2 kinds of anwsers:
- some that help me in
- and other where some guy thinks that has the right to rule if my
need has some value

Thanksfully, Python is an open platform, and with the help obtained
here, now I can fullfill my needs.
Who is the arrogant?

On 22 mayo, 11:59, Bruno Desthuilliers bruno.
[EMAIL PROTECTED] wrote:
 Agustin Villena a écrit :



  On May 22, 5:19 am, Bruno Desthuilliers bruno.
  [EMAIL PROTECTED] wrote:
  Agustin Villena a écrit :

  And not that useful - why would one care about the function being
  defined in class X or Y when one have the exact file and line ?
  I have 3 reasons:
  1) My developing time is expended running unit tests and browsing
  tracebacks to find which is the real problem. Knowing the offender
  class (instead of the method alone) makes me understand more quickly
  which component of my software is failing.
  This is only true when there is an obvious, one-to-one, unambiguous
  relationship between the physical location of the error (file, line) and
  the class of the object the method has been called on. Which is not
  necessarily the case (inheritance, method decoration and monkeypatching
  comes to mind here...).

  Also, your above statement seems to imply that component==class, which
  is not the case in Python.

  2) There are some ocassions where I only have the traceback (e.g. when
  analyzing an app's log) and no inmediate access to teh source code
  Ok. But the above still apply...

  3) And finally, for completeness: If a function is really a method, if
  the tracebackshowonly its name and not the class that defines it,
  for me its a bug, because the method name has no sense out of its
  class.
  I'm not sure you really grasp what methods are in Python. What you
  define (using the def statement) within a class is function, not a
  method. It only becomes a method when it's looked up on an instance or
  class object, and this 'method' is only a thin wrapper around the
  instance, class and function objects. And FWIW, you don't need to define
  the function within the class to make it a method:

  # bar.py
  def bar(obj):
 print function bar.bar called on obj %s % obj

  # foo.py

  class Foo(object): pass

  # baaz.py
  from foo import Foo
  import bar

  Foo.baaz = bar.bar

  def guux(obj):
 print function baaz.guux called on obj %s % obj

  # main.py
  from baaz import Foo
  f = Foo()
  f.bar()

  f.gnix = baae.guux.__get__(f, type(f))
  f.gnix()

  Not to say that your concerns are pointless, and that things cannot be
  improved somehow, but this is not that trivial, and there may be
  ambuiguities in some not so rare cases.

  Well, the solution given in an early response is good enough for me.

 Not for me.

  I don't see things like you, because I'm accustomed to design my
  software
  though classes and see the code in an object = software's functional
  atom/component way

 I guess you mean 'class = software's functional atom/component' -
 because it's perfectly legal, in Python, to have per-instance methods...

 Now the fact that *you* see it that way doesn't mean Python (and most
 Python users) have to share your views, so labelling the way it works as
 a bug sounds a bit arrogant to me.

  I agree that python's dynamic nature make things complicated here, but
  for me it its just
  an implementation problem derived of the recent OOP support of python

 I beg your pardon ? recent OOP support in Python ? Python had classes
 and objects years before Oak was renamed as Java and made public, you know.

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


Re: accumulator generators

2008-05-30 Thread Kirk Strauser
At 2008-05-30T19:50:43Z, Cameron [EMAIL PROTECTED] writes:

 Why does that work, but not this:

 def foo(n):
   s = n
   def bar(i):
 s += i
 return s
   return bar

Assume that n is an int, making s one also.  Ints are immutable; you can
only copy them.  So your bar is taking s, adding i to it, then assigning the
value back to the local variable named s.
-- 
Kirk Strauser
The Day Companies
--
http://mail.python.org/mailman/listinfo/python-list


Re: php vs python

2008-05-30 Thread Ethan Furman

Jerry Stuckle wrote:


 As I've said before - good programmers can write good code in any
 language.


So... an eloquent speaker of English is also an eloquent speaker of 
Spanish/French/German?


I think your statement would be correct if worded: some programmers can 
write good code in any language.  There's a reason why computer coding 
paradigms are called 'languages' -- because they are, and as such they 
require different ways of thinking.  Just because someone is good at 
playing pianos doesn't mean they are also good at wood carving.  Just 
because someone is good (i.e. writes good code) in C / PHP / Python / 
Perl / Assembly / whatever does not inherently mean that that same 
person will be able to write good code in any other language.  That's 
one reason why there are so many to choose from: different people think 
differently and most are only optimal in certain areas.


Or perhaps your definition of a good programmer means somebody who can 
write good code in any language?  What then is a programmer who can only 
write good code in a handful of languages?  Or maybe only two languages? 
  Or even only one?


My definition of a good programmer is someone who can write good code in 
a computer language.  I would use the word 'versatile' or even 
'multi-lingual' to broaden the scope to more than one language.

--
Ethan

P.S.
My apologies, Jerry, for writing back to you directly -- I haven't yet 
discovered how to post to newsgroups, and I do not know the php mailing 
list address.  I guess by both our definitions I am not a 'good 
newsgroup poster.'  ;-)


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


Re: Python 2.5.2 on Ubuntu Hardy Utf-8-Euro error

2008-05-30 Thread M.-A. Lemburg

On 2008-05-30 17:41, Peter Otten wrote:

Josep wrote:


I'm playing with an application framework (or kinda) that's developed
with python, and it throws this error:



File
/usr/lib/python2.5/site-packages/Dabo-0.8.3-py2.5.egg/dabo/db/dCursorMixin.py,
line 281, in execute
sql = unicode(sql, self.Encoding)
LookupError: unknown encoding: utf_8_euro

At the application (DABO) mailing list, they have pointed that this has
to be a Python issue. As I'm a totally python newbie, I would ask if
somebody has experimented this kind of error, and if there is any known
solution. I've found no clue searching at Google right now.

My Python version is 2.5.2, Ubuntu Hardy .deb package.


Python might get confused by an @EURO suffix in the locale:


Right, that's what's happening.

The locale module uses a locale aliasing table that help map environment
locale settings to C local names.

That table was last updated in 2004 and since then a lot more
locale variable strings have made their way into the Linux
distros.

I guess we need to update the table...


$ [EMAIL PROTECTED]
$ python -cimport locale; print locale.getdefaultlocale()
('de_DE', 'utf_8_euro')

Try setting the LANG environment variable to something like

$ LANG=de_DE.UTF-8
$ python -cimport locale; print locale.getdefaultlocale()
('de_DE', 'UTF8')

before you run your program (use ca_ES or whatever you need instead of
de_DE).

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


--
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, May 30 2008)
 Python/Zope Consulting and Support ...http://www.egenix.com/
 mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
 mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/


 Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! 


   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
   Registered at Amtsgericht Duesseldorf: HRB 46611
--
http://mail.python.org/mailman/listinfo/python-list


Re: should I put old or new style classes in my book?

2008-05-30 Thread Alan G Isaac

Alan Isaac [EMAIL PROTECTED] writes:

I take it from this thread that in Python 3 the following are
equivalent:



   class Test: pass



   class Test(object): pass



Arnaud Delobelle wrote:

I don't know where it is stated, but how could they *not* be
equivalent?


The most obvious way would be that the former became an illegal
syntax.  But in Python 3 alpha, it is accepted, so I assume that it
will continue to be?

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


ThreadPoolingMixIn

2008-05-30 Thread pavel . uvarov
Hi, everybody!

I wrote a useful class ThreadPoolingMixIn which can be used to create
fast thread-based servers. This mix-in works much faster than
ThreadingMixIn because it doesn't create a new thread on each request.

Is it worth including in SocketServer.py?


from __future__ import with_statement
from SocketServer import ThreadingMixIn
import threading
import Queue
class ThreadPoolingMixIn(ThreadingMixIn):
Mix-in class to handle requests in a thread
pool.

The pool grows and thrinks depending on
load.

For instance, a threading UDP server class is created as
follows:

class ThreadPoolingUDPServer(ThreadPoolingMixIn, UDPServer):
pass


__author__ = 'Pavel Uvarov [EMAIL PROTECTED]'

def init_thread_pool(self, min_workers = 5,
 max_workers = 100, min_spare_workers = 5):
Initialize thread pool.
self.q = Queue.Queue()
self.min_workers = min_workers
self.max_workers = max_workers
self.min_spare_workers = min_spare_workers
self.num_workers = 0
self.num_busy_workers = 0
self.workers_mutex = threading.Lock()
self.start_workers(self.min_workers)

def start_workers(self, n):
Start n workers.
for i in xrange(n):
t = threading.Thread(target = self.worker)
t.setDaemon(True)
t.start()

def worker(self):
A function of a working
thread.

It gets a request from queue (blocking if
there
are no requests) and processes
it.

After processing it checks how many spare
workers
are there now and if this value is greater
than
self.min_spare_workers then the worker
exits.
Otherwise it loops
infinitely.


with self.workers_mutex:
self.num_workers += 1
while True:
(request, client_address) = self.q.get()
with self.workers_mutex:
self.num_busy_workers += 1
self.process_request_thread(request, client_address)
self.q.task_done()
with self.workers_mutex:
self.num_busy_workers -= 1
if self.num_workers - self.num_busy_workers  \
self.min_spare_workers:
self.num_workers -= 1
return

def process_request(self, request, client_address):
Puts a request into
queue.

If the queue size is too large, it adds extra
worker.


self.q.put((request, client_address))
with self.workers_mutex:
if self.q.qsize()  3 and self.num_workers 
self.max_workers:
self.start_workers(1)

def join(self):
Wait for all busy threads
self.q.join()
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.5.2 on Ubuntu Hardy Utf-8-Euro error

2008-05-30 Thread M.-A. Lemburg

On 2008-05-30 22:37, M.-A. Lemburg wrote:

On 2008-05-30 17:41, Peter Otten wrote:

Josep wrote:


I'm playing with an application framework (or kinda) that's developed
with python, and it throws this error:



File
/usr/lib/python2.5/site-packages/Dabo-0.8.3-py2.5.egg/dabo/db/dCursorMixin.py, 


line 281, in execute
sql = unicode(sql, self.Encoding)
LookupError: unknown encoding: utf_8_euro

At the application (DABO) mailing list, they have pointed that this has
to be a Python issue. As I'm a totally python newbie, I would ask if
somebody has experimented this kind of error, and if there is any known
solution. I've found no clue searching at Google right now.

My Python version is 2.5.2, Ubuntu Hardy .deb package.


Python might get confused by an @EURO suffix in the locale:


Right, that's what's happening.

The locale module uses a locale aliasing table that help map environment
locale settings to C local names.

That table was last updated in 2004 and since then a lot more
locale variable strings have made their way into the Linux
distros.

I guess we need to update the table...


I've opened ticket http://bugs.python.org/issue3011 for this.


$ [EMAIL PROTECTED]
$ python -cimport locale; print locale.getdefaultlocale()
('de_DE', 'utf_8_euro')

Try setting the LANG environment variable to something like

$ LANG=de_DE.UTF-8
$ python -cimport locale; print locale.getdefaultlocale()
('de_DE', 'UTF8')

before you run your program (use ca_ES or whatever you need instead of
de_DE).

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




--
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, May 30 2008)
 Python/Zope Consulting and Support ...http://www.egenix.com/
 mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
 mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/


 Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! 


   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
   Registered at Amtsgericht Duesseldorf: HRB 46611
--
http://mail.python.org/mailman/listinfo/python-list


SMS sending and receiving from website?

2008-05-30 Thread globalrev
can i send and receive messages from a website using python?

how would that work with costs? would the mobileowner pay both ways?
--
http://mail.python.org/mailman/listinfo/python-list


Importing modules from packages with relative imports

2008-05-30 Thread John Millikin
With the old import system, and a package that looks like this:

foo/
  __init__.py
  main.py
  bar/
__init__.py
baz.py

If I wanted to delay importing baz until it was actually used, I could
leave the __init__.py files empty and simply import bar.baz.
However, with the new relative imports syntax, from . import bar.baz
causes a syntax error. I could use something like from .bar import
baz as bar_baz, but that's long, annoying to write, and requires
changing all the uses of bar.baz.spam to bar_baz.spam through the
file. Is there any way to achieve the bar.baz name with relative
imports?
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.5.2 on Ubuntu Hardy Utf-8-Euro error

2008-05-30 Thread Martin v. Löwis
 The function first normalizes the @ away and then looks for it. Is that
 the expected behaviour?

I believe this functionality is broken by design. Python can't possibly
know correctly what each locale name on each system means, and what
encoding is used in the locale.

Instead, the system's API to find out the encoding should be used,
as exposed in locale.getpreferredencoding().

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


Re: accumulator generators

2008-05-30 Thread Cameron
On May 30, 1:04 pm, Diez B. Roggisch [EMAIL PROTECTED] wrote:
 Cameron schrieb:



  I was reading this a href=thishttp://www.paulgraham.com/icad.html;Paul
  Graham article/a and he builds an accumuator generator function in
  the appendix. His looks like this:

  pre
  def foo(n):
    s = [n]
    def bar(i):
      s[0] += i
      return s[0]
    return bar
  /pre

  Why does that work, but not this:

  pre
  def foo(n):
    s = n
    def bar(i):
      s += i
      return s
    return bar
  /pre

 Because python's static analysis infers s as being a variable local to
 bar in the second case - so you can't modify it in the outer scope.

 In the future, you may declare

 def bar(i):
      nonlocal s
      ...

 Diez

thanks for the response. Just to make sure I understand- Is the reason
it works in the first case because s[0] is undefined at that point (in
bar), and so python looks in the outer scope and finds it there?

Cameron

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


Re: Help needed in choosing an algorithm for Cryptographic services.

2008-05-30 Thread Sebastian 'lunar' Wiesner
[ Peter Pearson [EMAIL PROTECTED] ]

 On Thu, 29 May 2008 20:27:35 -0500, Larry Bates wrote:
 abhishek wrote:
 Hi group, recently my employer asked me too implement encryption/
 decryption for secure data transfer over internet. Problem is that the
 client application is written using C# and the webserver where i need
 to store the information is developed using python.
 
 My situation of dilemma is which cryptographic method suits me best
 for this purpose.
 
 Help/Suggestions are urgently required

 Data security is a complex and difficult problem, and you are likely
 to fail in the worst possible way: implementing something that is
 weak but that you believe to be strong.  Some advice: (1) Use
 off-the-shelf products like PGP or GPG; don't write your own.

full ack.

 (2) Read Bruce Schneier's Applied Cryptography to get a feeling
 for the dimensions of the problem. 

While this book is most certainly worth reading, I doubt, that it is
necessary to gain in-depth knowledge of cryptography to make use of it in
your code.  

If you transfer data over SSL-connection, you should rely on them being
safe, you don't need to understand the details.  You only need to know,
what SSL can protect against, and what it can't protect against.

-- 
Freedom is always the freedom of dissenters.
  (Rosa Luxemburg)
--
http://mail.python.org/mailman/listinfo/python-list


Re: accumulator generators

2008-05-30 Thread Hans Nowak

Cameron wrote:

On May 30, 1:04 pm, Diez B. Roggisch [EMAIL PROTECTED] wrote:

Cameron schrieb:




I was reading this a href=thishttp://www.paulgraham.com/icad.html;Paul
Graham article/a and he builds an accumuator generator function in
the appendix. His looks like this:
pre
def foo(n):
  s = [n]
  def bar(i):
s[0] += i
return s[0]
  return bar
/pre
Why does that work, but not this:
pre
def foo(n):
  s = n
  def bar(i):
s += i
return s
  return bar
/pre

Because python's static analysis infers s as being a variable local to
bar in the second case - so you can't modify it in the outer scope.

In the future, you may declare

def bar(i):
 nonlocal s
 ...

Diez


thanks for the response. Just to make sure I understand- Is the reason
it works in the first case because s[0] is undefined at that point (in
bar), and so python looks in the outer scope and finds it there?


You can refer to variables in enclosing scopes, just not redefine them in that 
same scope.  That's why in the first example, bar can refer to to s (defined in 
foo).  By assigning to s[0], it modifies the list, which is OK; trying to 
redefine the name 's' (like the second example tries to do) would not be OK.


Also see: http://zephyrfalcon.org/labs/python_pitfalls.html (pitfall #6).

--
Hans Nowak (zephyrfalcon at gmail dot com)
http://4.flowsnake.org/
--
http://mail.python.org/mailman/listinfo/python-list


Re: UNIX credential passing

2008-05-30 Thread Kris Kennaway

Sebastian 'lunar' Wiesner wrote:

[ Kris Kennaway [EMAIL PROTECTED] ]


I want to make use of UNIX credential passing on a local domain socket
to verify the identity of a user connecting to a privileged service.
However it looks like the socket module doesn't implement
sendmsg/recvmsg wrappers, and I can't find another module that does this
either.  Is there something I have missed?


http://pyside.blogspot.com/2007/07/unix-socket-credentials-with-python.html

Illustrates, how to use socket credentials without sendmsg/recvmsg and so
without any need for patching.




Thanks to both you and Paul for your suggestions.  For the record, the 
URL above is linux-specific, but it put me on the right track.  Here is 
an equivalent FreeBSD implementation:


def getpeereid(sock):
 Get peer credentials on a UNIX domain socket.

Returns a nested tuple: (uid, (gids)) 

LOCAL_PEERCRED = 0x001
NGROUPS = 16

#struct xucred {
#u_int   cr_version; /* structure layout version */
#uid_t   cr_uid; /* effective user id */
#short   cr_ngroups; /* number of groups */
#gid_t   cr_groups[NGROUPS]; /* groups */
#void*_cr_unused1;   /* compatibility with old ucred */
#};

xucred_fmt = '2ih16iP'
res = tuple(struct.unpack(xucred_fmt, sock.getsockopt(0, 
LOCAL_PEERCRED, struct.calcsize(xucred_fmt


# Check this is the above version of the structure
if res[0] != 0:
raise OSError

return (res[1], res[3:3+res[2]])


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


Re: The Importance of Terminology's Quality

2008-05-30 Thread Lew

John Thingstad wrote:

Perl is solidly based in the UNIX world on awk, sed, bash and C.
I don't like the style, but many do.


Please exclude the Java newsgroups from this discussion.

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


  1   2   >