Re: How to Teach Python "Variables"

2007-11-28 Thread Paul Rudin
none <""atavory\"@(none)"> writes:


>   IIRC, I once saw an explanation how Python doesn't have
> "variables" in the sense that, say, C does, and instead has bindings
> from names to objects. Does anyone have a link?

"Variable" is an abstract concept, and it's a slightly different
concept for every programming language. So you're correct to say that
they're not like C variables. But putting it that way is no more valid
than saying that C doesn't have variables like Python's.

If you're teaching it from first principles then I wouldn't start by
saying what they're not, if people don't know what C variables are
then it doesn't help to say "these Python variables are not like C
variables". If they do know about variables in other languages, it
might help to say "forget your preconceptions about what a variable
is".

As you say, in Python variables are essentially names in some kind of
lookup table for objects... this is a perfectly reasonable way to try
and explain the idea (and is essentially the way it's
implemented). Then you have to get into scoping, and the odd gotcha
(e.g. contrast assigning to a global variable in local scope with
referencing one - with and without a "global" statement).

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


Unexpected behavior when initializing class

2007-11-28 Thread [EMAIL PROTECTED]
Hello everybody,

I've banged my ahead around for a while trying to figure out why
multiple instances of a class share the same instance variable.  I've
stripped down my code to the following, which reproduces my problem.

class Test(object):
def __init__(self, v=[]):
self.values = v

def addValue(self, v):
self.values += [v]
return

a = Test()
a.addValue(1)
print a.values   # Should print [1]
b = Test()
print b.values   # Should print empty list
b.addValue(2)
print a.values   # Should print [1]

The output I get is:

[1]
[1]
[1, 2]

The output I am expecting is:

[1]
[]
[1]

Another strange thing is that if I initialize with a different value,
the new instance will not share the 'values' attribute with the other
two:

c = Test([9])
print c.values# Prints [9] as it should
print a.values# Still prints [1, 2]

There is something I clearly don't understand here.  Can anybody
explain?  Thanks!

Python 2.4.4 (#1, Oct 23 2006, 13:58:18)
[GCC 4.1.1 20061011 (Red Hat 4.1.1-30)] on linux2

Alfred J. Fazio,
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Unexpected behavior when initializing class

2007-11-28 Thread Paul Rudin
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes:

> Hello everybody,
>
> I've banged my ahead around for a while trying to figure out why
> multiple instances of a class share the same instance variable.  I've
> stripped down my code to the following, which reproduces my problem.
>
> class Test(object):
> def __init__(self, v=[]):
> self.values = v

You have to understand that the default value for v - an empty list -
is made at compile time - and it's the *same* list every time it's
used i.e. if you don't pass in a value for v when you make new
instances of your class.

A common paradigm to get round this - assuming you want a different
empty list each time - is something like:

def __init__(self, v = None):
self.values = v if v else []

(or maybe test explicitly for None, but you get the idea.)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Unexpected behavior when initializing class

2007-11-28 Thread Gary Herron
[EMAIL PROTECTED] wrote:
> Hello everybody,
>
> I've banged my ahead around for a while trying to figure out why
> multiple instances of a class share the same instance variable.  I've
> stripped down my code to the following, which reproduces my problem.
>   

This is a *feature* of Python that bytes *ever* newbie at least once. ;-)

See
http://www.python.org/doc/faq/general/#why-are-default-values-shared-between-objects

> class Test(object):
> def __init__(self, v=[]):
> self.values = v
>
> def addValue(self, v):
> self.values += [v]
> return
>
> a = Test()
> a.addValue(1)
> print a.values   # Should print [1]
> b = Test()
> print b.values   # Should print empty list
> b.addValue(2)
> print a.values   # Should print [1]
>
> The output I get is:
>
> [1]
> [1]
> [1, 2]
>
> The output I am expecting is:
>
> [1]
> []
> [1]
>
> Another strange thing is that if I initialize with a different value,
> the new instance will not share the 'values' attribute with the other
> two:
>
> c = Test([9])
> print c.values# Prints [9] as it should
> print a.values# Still prints [1, 2]
>
> There is something I clearly don't understand here.  Can anybody
> explain?  Thanks!
>
> Python 2.4.4 (#1, Oct 23 2006, 13:58:18)
> [GCC 4.1.1 20061011 (Red Hat 4.1.1-30)] on linux2
>
> Alfred J. Fazio,
> [EMAIL PROTECTED]
>   

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


Re: Unexpected behavior when initializing class

2007-11-28 Thread [EMAIL PROTECTED]
On Nov 28, 3:31 am, Paul Rudin <[EMAIL PROTECTED]> wrote:
> You have to understand that the default value for v - an empty list -
> is made at compile time - and it's the *same* list every time it's
> used i.e. if you don't pass in a value for v when you make new
> instances of your class.

*smack*!!  That's me smacking myself on the forehead.  I now remember
reading a long time ago that this was an FAQ!  Thanks for the reply,
Paul.  :)

Alfred J. Fazio,
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: looking for ocbc example

2007-11-28 Thread Tim Golden
Carl K wrote:
> jay graves wrote:
>> On Sep 21, 2:43 am, Tim Golden <[EMAIL PROTECTED]> wrote:
>>> Carl K wrote:
 It seems there are 2 odbc modules - pyOdbc and mxOdbc - anyone know the 
 difference?
>>> In short, pyodbc is open source; mxOdbc requires a commercial license.
>>> pyodbc is a newcomer, but appears to work for everything I've thrown
>>> at it (which is not much). mxOdbc has been around longer, and is sure
>>> to be a more mature product. It may offer more features & functionality.
>> There is also a brand new module 'ceODBC'.
>> http://ceodbc.sourceforge.net/
>>
>> I haven't used it yet but I want to give it a try.
> 
> I tried it, and it worked better than pyodbc.  (better is not exactly right. 
> there was some weird bug in the ctree odbc driver, and the author of ceODBC 
> gave 
> me a workaround.)

All right, I'm a little perplexed as to whether "better" here
refers to the admirable response of the ceOBDC author or to
some other factors which demonstrate ceODBC's superiority.

I've not really got the opportunity to pit them against each
other so to speak, but I'd love to hear from someone who had.

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


Re: Unexpected behavior when initializing class

2007-11-28 Thread John Machin
On Nov 28, 7:19 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> Hello everybody,
>
> I've banged my ahead around for a while trying to figure out why
> multiple instances of a class share the same instance variable.  I've
> stripped down my code to the following, which reproduces my problem.
>
> class Test(object):
> def __init__(self, v=[]):
> self.values = v
>
> def addValue(self, v):
> self.values += [v]
> return
>
> a = Test()
> a.addValue(1)
> print a.values   # Should print [1]
> b = Test()
> print b.values   # Should print empty list
> b.addValue(2)
> print a.values   # Should print [1]
>
> The output I get is:
>
> [1]
> [1]
> [1, 2]
>
> The output I am expecting is:
>
> [1]
> []
> [1]
>
> Another strange thing is that if I initialize with a different value,
> the new instance will not share the 'values' attribute with the other
> two:
>
> c = Test([9])
> print c.values# Prints [9] as it should
> print a.values# Still prints [1, 2]
>
> There is something I clearly don't understand here.  Can anybody
> explain?  Thanks!

http://www.python.org/doc/faq/general/#why-are-default-values-shared-between-objects

http://docs.python.org/tut/node6.html#SECTION00671


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


Re: Unexpected behavior when initializing class

2007-11-28 Thread Duncan Booth
Paul Rudin <[EMAIL PROTECTED]> wrote:

> You have to understand that the default value for v - an empty list -
> is made at compile time

Not at compile time: the default value is created at runtime when the def 
statement is executed.

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


How to debug Python program with GUI (Tkinter)?

2007-11-28 Thread Davy
Hi all,

How to debug Python program with GUI, especially Tkinter? My debug
environment is PythonWin.

For example, when I single step in the program, the step will go to
mainloop() and always loop there. How can I know where the program is
processed?

Any suggestions are welcome!
Best regards,
Davy
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: read/write to java socket in python

2007-11-28 Thread Dave Baum
Your server program is using readLine(), which will block until a 
newline is received.  The server code does not write a newline, so it is 
waiting at recv() for data from the server, and the server is still 
waiting for a newline.  If you change the client to do the following, it 
should work:

s.send("Hi Java Server\n");


Dave


In article 
<[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] wrote:

> Hi all,
> 
> I have a problem with reading from a Java server after I have written
> to it - it just hangs. It works fine if I just write to the server and
> not try to write. I have read the HOWTO on sockets - and it states
> that there is a problem (something about flushing), but not what the
> solutions is. Nor do google. Can somebody please help?
> 
> A few lines down you can see the example code that sums up the
> problem. Just change the name of the Python HOST-variable.
> 
> Thanks
> Mads
> 
> 
> This is the client in Python:
> #! /usr/bin/env python
> 
> import sys
> from socket import *
> 
> PORT = 3122
> HOST = 'app-5'
> SUCCESS = 'Success'
> FAILURE = 'Failure'
> 
> s = socket(AF_INET, SOCK_STREAM)
> s.connect((HOST, PORT))
> s.send("Hi Java Server");
> print "Have written, waiting to recieve.."
> print s.recv(1014)
> s.close()
> 
> And this the server in Java:
> import java.io.*;
> import java.net.*;
> 
> public class Server{
> public static void main(String args[]){
> 
> int port = 3122;
> int backLog = 50;
> 
> ServerSocket ss = null;
> try{
> 
> InetAddress localhost =
> InetAddress.getLocalHost();
> ss = new ServerSocket(port, backLog,
> localhost);
> while(true){
> final Socket client = ss.accept();
> new Thread(){
> public void run(){
> try{
> 
> 
> InputStream is =
> client.getInputStream();
> BufferedReader buf =
> new BufferedReader(new InputStreamReader(is));
> print(buf.readLine());
> 
> PrintWriter out = new
> PrintWriter(client.getOutputStream());
> out.write("Hi Python
> Client.");
> out.flush();
> client.close();
> }catch(Exception e)
> {print(e);}
> }
> }.start();
> }
> }catch(Exception e){print(e);}
> }
> 
> private static void print(Object o){System.out.println(o);}
> }
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OPLC purchase period extended

2007-11-28 Thread Richie Hindle

[Aahz]
> I'm sure that some people would be willing to serve as middleware...

I would *love* to have one of these for my kids, if anyone here would be
prepared to forward one to the UK for me.  I can pay you the postage by
PalPal, Amazon voucher, whatever suits.

The XO reminds me of the computers I grew up with in the early 80s - the
Sinclair ZX Spectrum and the BBC Micro.  They're miles apart technically,
but similar in the way they're designed for children.  The lack of that
kind of computer is something that's vaguely worried me for my kids - a
Windows PC, or even Linux or Mac, carries so much baggage that trying to
learn basic programming on it would have a much steeper learning curve
than a more basic, child-targeted machine.  Something that's designed for
children and has Python as its main programming language is a dream come
true!

It's also something that can safely be left lying around the house, and
become a part of everyday family life, in a way that a desktop machine or
a standard laptop can't.  When the story I'm reading to my 4-year-old
mentions Elvis and she asks who he is, rather than traipsing down two
flights of stairs to the study and cranking up the PC, being able to grab
the XO - which was partly hers - to answer her question would be just
fantastic.

And what better way to encourage friends and family to donate to the OLPC
cause than to demonstrate the real thing to them?  The G1G1 scheme is a
great idea, and it's a real shame they've had to limit its availability to
North America.

-- 
Richie Hindle
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to debug Python program with GUI (Tkinter)?

2007-11-28 Thread Diez B. Roggisch
Davy wrote:

> Hi all,
> 
> How to debug Python program with GUI, especially Tkinter? My debug
> environment is PythonWin.
> 
> For example, when I single step in the program, the step will go to
> mainloop() and always loop there. How can I know where the program is
> processed?

You can't - the mainloop is written in C. You need to set breakpoints in the
command-handlers of your interest.

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


Is Ruby 1.9 going to be faster than CPython?

2007-11-28 Thread Nicola Larosa (tekNico)
Holy Shmoly, Ruby 1.9 smokes Python away!
http://antoniocangiano.com/2007/11/28/holy-shmoly-ruby-19-smokes-python-away/

The post is less flaming than the title, fortunately. :-)

--
Nicola Larosa - http://www.tekNico.net/

If you have multiple CPUs and you want to use them all, fork off as
many
processes as you have CPUs. [...] If you really want "true" multi-
threading
for Python, use Jython or IronPython; the JVM and the CLR do support
multi-CPU threads. Of course, be prepared for deadlocks, live-locks,
race
conditions, and all the other nuisances that come with multi-threaded
code.
 -- Guido van Rossum, July 2007
-- 
http://mail.python.org/mailman/listinfo/python-list


tcp traceroute

2007-11-28 Thread Thomas Guettler
Hi,

I want to write a small tcp traceroute script. I works, but how
can I get the IP of the hop that send 'no route to host'?

Result:
python tmp/tcptraceroute.py a.b.c.d 80
ttl=01: (113, 'No route to host')
ttl=02: (113, 'No route to host')
ttl=03: (113, 'No route to host')
ttl=04: timed out
ttl=05: timed out
ttl=06: timed out
ttl=07: timed out
ttl=08: timed out
ttl=09: OK


#!/usr/bin/env python
# tcptraceroute.py
# This script is in the public domain

import os
import sys
import struct
import socket

def usage():
print '''Usage: %s host port
Tries to connect to host at TCP port with increasing TTL (Time to live).
''' % os.path.basename(sys.argv[0])

def main():
if not len(sys.argv)==3:
usage()
sys.exit(1)
ttl=1
host, port = sys.argv[1:]
port=int(port)
for ttl in range(1, 30):
s=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setsockopt(socket.IPPROTO_IP, socket.IP_TTL, struct.pack('I', ttl))
s.settimeout(2)
try:
s.connect((host, port))
except (socket.error, socket.timeout), err:
print 'ttl=%02d: %s' % (ttl, err)
s.close()
continue
except KeyboardInterrupt:
print 'ttl=%02d (KeyboardInterrupt)' % ttl
break
print 'ttl=%02d: OK' % (ttl)
break

if __name__=='__main__':
main()
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: securing a python execution environment...

2007-11-28 Thread miller . paul . w
Here's some proof of concept code I wrote a while back for this very
purpose.  What I do is use compiler.parse to take a code string and
turn it into an abstract syntax tree.  Then, using a custom visitor
object that raises an exception if it comes across something it
doesn't like, I use compiler.ast.walk to walk the tree and check for
Bad Stuff (tm) such as:

  * Importing a module not on the whitelist of safe modules.
  * Accessing a name that begins with "__" (double underscore).
  * Using the exec statement.
  * Expecting the Spanish Inquisition.

Hehe, ok, just kidding about that last one. :-)

If Bad Stuff(tm) is not detected, then I just compile it with the
built-in compile function and return the resulting code object.

Here it is:

---CUT HERE---

import compiler

# 'this' is the only module I was absolutely sure was safe. :P

allowed_imports = ['this', ]

class __Visitor (compiler.visitor.ExampleASTVisitor):

def visitImport (self, node):

# I have no idea why, but the 'names' attribute of an Import
or a From
# node always seem to be of the form ('name', None). (Hence
the
# 'name[0]' in the following list comprehension rather than
simply
# 'name'.  Someone(tm) should definitely work on the
documentation for
# the compiler module.

bad_names = [name[0] for name in node.names
 if name[0] not in allowed_imports ]
if any (bad_names):
if len (bad_names) > 1:
raise ImportError, "The modules %s could not be
imported." % \
   ", ".join (bad_names)
else:
raise ImportError, "The module %s could not be
imported." % \
bad_names[0]

def visitFrom(self, node):
modname = node.modname
if modname not in allowed_imports:
names = [name[0] for name in node.names]
if len (names) > 1:
names = ", ".join (stuff)
raise ImportError, "Could not import %s from module %s." %
\
  (names, modname)

def visitName (self, node):
if node.name.startswith ('__'):
raise AttributeError, 'Cannot access attribute %s.\n' %
node.name

def visitExec(self, node):
raise SyntaxError, "Use of the exec statement is not allowed."

# Save the builtin compile function for later.

__compile = compile

def compile (source, filename, mode, *args):
v = __Visitor()
ast = compiler.parse (source, mode=mode)
compiler.visitor.walk (ast, v)

# If we got here without an exception, then we ought to be OK.
# To be truly nice, we might want to fix up the traceback in case
we
# deliberately raised the exception, so it's easy to tell the
difference
# between intentional and unintentional exceptions.

return __compile (source, filename, mode, *args)

---CUT HERE---

As neat as this code is, in the end, I discarded the idea of running
"untrusted" Python code this way.  It's just too easy to screw up and
miss something (c.f. the many SQL injection vulnerabilities we've seen
over the years).  And, once an "untrusted" individual has the ability
to run Python code on your box, you're basically screwed, anyway.  For
example, if I wanted to eat a lot of CPU and exhaust memory on
someone's machine, I could just have Python calculate Ackerman's
function or the factorial of some giant number.

Once you've sorted out every such possible problem by developing a
comprehensive threat model and defending against every attack you can
come up with, you'll either have

  A) Missed something, or
  B) Written a Python interpreter in Python.

Obviously, A is bad, and B is most likely too slow to be usable,
unless you base your efforts on pypy. :-)

Nonetheless, the compiler module is a fun toy to have around.  You can
use it for lots of cool stuff, and I heartily recommend playing around
with it.  I just wish it had better documentation. :-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Different kinds of Import Errors

2007-11-28 Thread Peter Otten
Thomas Guettler wrote:

> If you look at this code, you see there are two kind of ImportErrors:
> 
> 1. app_name has no attribute or file managment.py: That's OK.
> 2. managment.py exists, but raises an ImportError: That's not OK: reraise
> 
> # Import the 'management' module within each installed app, to 
> register
> # dispatcher events.
> for app_name in settings.INSTALLED_APPS:
> try:
> __import__(app_name + '.management', {}, {}, [''])
> except ImportError, exc:
> if exc.args[0]!='No module named management':
> raise
> 
> 
> I am searching a better solution, since in a future version of python
> the string 'No module namend management' might be changed.
> 
> Any better solution?

An alternative way to determine the expected message:

try:
import sys.pink_elephant
except ImportError, e:
expected_message = e.message.replace("pink_elephant", "management")
else:
raise Exception("your python has swallowed a pink elephant")

I'm probably not serious.

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


Trainings/Projects on Bioinformatics, Molecular Biology, MicroBiology, Drug Designing and SAS Programming at Global Institute of Biotechnology

2007-11-28 Thread Global Institute of Biotechnology
GLOBAL INSTITUTE OF BIOTECHNOLOGY
( A unit of SVS Education Society, Regn No 1640 of 2005, Govt.A.P.)
3-6-276/2, Sai Triveni Chambers, Above Mahesh Bank, Hyderabad, A.P.

ABOUT OURSELVES

Global Institute of Biotechnology in its short span of existence for a
period of Three years has emerged as a premier Institute in the field
of Training and Research in Bioinformatics,Biotechnology and Other
Life Sciences.The Institute is equipped with the state of the art
laboratories in the above fields and is manned by suitably qualified
and experienced faculty.

In order to prepare the students to meet the needs of modern
Biotech,Pharma,and other Life Science Industries, the Institute has
recently added training and project work in SAS ( Statistics Analysis
Systems ) which has become a gold standard for analysis and management
of data in Clinical and Biological Research.

Similarly students of the Biotechnology course, wherein the emphasis
is on the wet lab experimentation, have been undergoing internship in
various biotech companies

The Institute proudly invites applications for Short/Long Term
Training Programmes and Research Projects as detailed below:

BIOINFORMATICS

During the past many years, the Genome of several organisms' including
manhave been completely or Partially sequenced. However these billions
of DNA bases do not tell us much about, what all these genes do what
is their exact role in the process of Development, growth, ageing and
disease. We know that ultimately proteins are coded by genes and
control life Processes. However elucidations of the functions of
proteins are not yet clear. This is where functional genomics,
proteomics and Bioinformatics is an amalgamation of the data in
biological sciences and tools of computing in information technology.
Bioinformatics uses computational power to catalogue, organize and
structure these complex databases and pieces them into meaningful
biological entities, to provide easy access to data on many
developments in the fields of Medical, Pharmaceutical, Agricultural,
Animal and Microbial  Biotechnologies.

Computational tools have become increasingly important in processes
leading to new inventions in Biotechnology. Computer Aided Drug Design
(CADD) is a central part of the rational approach for Drug Discovery.
CADD is an inter disciplinary  field, which includes computational
inputs from Chemistry, Biology, Pharmacology, Biotechnology,
Information Technology. Etc. This is an emerging field, with wide
range of applications. Various aspects of this field include Quantum
Chemistry, Molecular Mechanics, Molecular Docking, Quantitative
Structure Activity Relationship (3D QSAR), Conformational Analysis,
etc. A major component of CADD is Molecular Modeling and Screening of
the Substrate ligand interactions in silico.

Our endeavour is to crate a lively environment for the advancement of
Bioinformatics and to generate an innovative workforce in this
exciting and expanding field.

COURSE CONTENTS

Module:1  BIOLOGICAL DATABASES AND  SEQUENCE ANALYSIS
  (Duration: 1 month)

BIOLOGICAL DATABASES

*   Introduction to Bioinformatics
*   Molecular Databases
*   Primary Databanks, GENEBANK, EMBL, DDBJ
*   Secondary Databases, SWISSPORT, PIR, TrEMBL
*   PFAM. INTERPRO
*   Motif Database, PROSITE
*   Structural Database (PDB)
*   Classification Database(SCOP, CATH)
*   Eukaryotic Promoter Database

. SEQUENCE ANALYSIS

*   Database similarity search
*   Pair wise alignment
*   Dot Matrix Comparison
*   Needleman-Wunsch Algarithm
*   Smith Waterman Algarithm
*   Local Sequence Alignment
*   Global Sequence Alignment
*   Multiple Sequence Alignment
*   Pattern, Motifs and Profiles
*   Primer Designing

Module:2GENOMICS AND PROTEOMICS

( Duration: 1 Month )

GENOMICS

*   Sequence Alignments and its Applications
*   Genome Modelling
*   Gene Sequence analysis
*   Primer Designing
*   SNP Detection and Haplo typing
*   Chromosome Mapping and Linkage Analysis
*   Computational  Assembly of a Genome


PROTEOMICS

*   Protein Sequence Analysis
*   Approaches for Protein  Structure Predection
*   Phylogenetic  analysis of  Protein Families
*   Homology and comparative modeling of protein
*   Active site identification


Module:3DRUG DESIGNING AND DRUG DISCOVERY

  ( Duration: 1 Month )

DRUG DESIGNING

*   Building small molecules
*   Properties of Drug molecules
*   Ligand protein interactions
*   Binding Energy calculations
*   Energy minimization methods
*   Molecular Dynamics and simulation studies
*   Ligand based drug designingFragment based drug designing

DRUG DISCOVERY

*   Selection and Identification of Target Concepts in molecular
recognition
*   Ligand Docking algorithms
*   Kinetics and Thermodynamics of protein drug binding
*   Drug delivery

PROJECT WORK IN
Sequence Anal

Trainings/Projects on Bioinformatics, Molecular Biology, MicroBiology, Drug Designing and SAS Programming at Global Institute of Biotechnology

2007-11-28 Thread Global Institute of Biotechnology
GLOBAL INSTITUTE OF BIOTECHNOLOGY
( A unit of SVS Education Society, Regn No 1640 of 2005, Govt.A.P.)
3-6-276/2, Sai Triveni Chambers, Above Mahesh Bank, Hyderabad, A.P.

ABOUT OURSELVES

Global Institute of Biotechnology in its short span of existence for a
period of Three years has emerged as a premier Institute in the field
of Training and Research in Bioinformatics,Biotechnology and Other
Life Sciences.The Institute is equipped with the state of the art
laboratories in the above fields and is manned by suitably qualified
and experienced faculty.

In order to prepare the students to meet the needs of modern
Biotech,Pharma,and other Life Science Industries, the Institute has
recently added training and project work in SAS ( Statistics Analysis
Systems ) which has become a gold standard for analysis and management
of data in Clinical and Biological Research.

Similarly students of the Biotechnology course, wherein the emphasis
is on the wet lab experimentation, have been undergoing internship in
various biotech companies

The Institute proudly invites applications for Short/Long Term
Training Programmes and Research Projects as detailed below:

BIOINFORMATICS

During the past many years, the Genome of several organisms' including
manhave been completely or Partially sequenced. However these billions
of DNA bases do not tell us much about, what all these genes do what
is their exact role in the process of Development, growth, ageing and
disease. We know that ultimately proteins are coded by genes and
control life Processes. However elucidations of the functions of
proteins are not yet clear. This is where functional genomics,
proteomics and Bioinformatics is an amalgamation of the data in
biological sciences and tools of computing in information technology.
Bioinformatics uses computational power to catalogue, organize and
structure these complex databases and pieces them into meaningful
biological entities, to provide easy access to data on many
developments in the fields of Medical, Pharmaceutical, Agricultural,
Animal and Microbial  Biotechnologies.

Computational tools have become increasingly important in processes
leading to new inventions in Biotechnology. Computer Aided Drug Design
(CADD) is a central part of the rational approach for Drug Discovery.
CADD is an inter disciplinary  field, which includes computational
inputs from Chemistry, Biology, Pharmacology, Biotechnology,
Information Technology. Etc. This is an emerging field, with wide
range of applications. Various aspects of this field include Quantum
Chemistry, Molecular Mechanics, Molecular Docking, Quantitative
Structure Activity Relationship (3D QSAR), Conformational Analysis,
etc. A major component of CADD is Molecular Modeling and Screening of
the Substrate ligand interactions in silico.

Our endeavour is to crate a lively environment for the advancement of
Bioinformatics and to generate an innovative workforce in this
exciting and expanding field.

COURSE CONTENTS

Module:1  BIOLOGICAL DATABASES AND  SEQUENCE ANALYSIS
  (Duration: 1 month)

BIOLOGICAL DATABASES

*   Introduction to Bioinformatics
*   Molecular Databases
*   Primary Databanks, GENEBANK, EMBL, DDBJ
*   Secondary Databases, SWISSPORT, PIR, TrEMBL
*   PFAM. INTERPRO
*   Motif Database, PROSITE
*   Structural Database (PDB)
*   Classification Database(SCOP, CATH)
*   Eukaryotic Promoter Database

. SEQUENCE ANALYSIS

*   Database similarity search
*   Pair wise alignment
*   Dot Matrix Comparison
*   Needleman-Wunsch Algarithm
*   Smith Waterman Algarithm
*   Local Sequence Alignment
*   Global Sequence Alignment
*   Multiple Sequence Alignment
*   Pattern, Motifs and Profiles
*   Primer Designing

Module:2GENOMICS AND PROTEOMICS

( Duration: 1 Month )

GENOMICS

*   Sequence Alignments and its Applications
*   Genome Modelling
*   Gene Sequence analysis
*   Primer Designing
*   SNP Detection and Haplo typing
*   Chromosome Mapping and Linkage Analysis
*   Computational  Assembly of a Genome


PROTEOMICS

*   Protein Sequence Analysis
*   Approaches for Protein  Structure Predection
*   Phylogenetic  analysis of  Protein Families
*   Homology and comparative modeling of protein
*   Active site identification


Module:3DRUG DESIGNING AND DRUG DISCOVERY

  ( Duration: 1 Month )

DRUG DESIGNING

*   Building small molecules
*   Properties of Drug molecules
*   Ligand protein interactions
*   Binding Energy calculations
*   Energy minimization methods
*   Molecular Dynamics and simulation studies
*   Ligand based drug designingFragment based drug designing

DRUG DISCOVERY

*   Selection and Identification of Target Concepts in molecular
recognition
*   Ligand Docking algorithms
*   Kinetics and Thermodynamics of protein drug binding
*   Drug delivery

PROJECT WORK IN
Sequence Anal

Re: string conversion latin2 to ascii

2007-11-28 Thread Jakub Wilk
* Martin Landa <[EMAIL PROTECTED]>, 2007-11-27:
> I have unicode string (or better say latin2 encoding) containing
> non-ascii characters, e.g.
>
> s = "Ukázka_možnosti_využití_programu_OpenJUMP_v_SOA"
>
> I would like to convert this string to plain ascii (using some lookup
> table for latin2)
>
> to get
>
> -> Ukazka_moznosti_vyuziti_programu_OpenJUMP_v_SOA

You may try python-elinks
:


>>> import elinks
>>> print 
>>> "Ukázka_mo\236nosti_vyu\236ití_programu_OpenJUMP_v_SOA".decode('Windows-1250').encode('ASCII',
>>>  'elinks')
Ukazka_moznosti_vyuziti_programu_OpenJUMP_v_SOA


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


**EARN $10000 PER MONTH**CHECK PROOF**

2007-11-28 Thread ramya1898
**EARN $1 PER MONTH**CHECK PROOF**
**BPM SOFTWARE**
**INTERNET SOFTWARE**
**SOFTWARE DEVELOPMENT**
**PROCESS MODELLING SOFTWARE**
http://regantame.blogspot.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: the annoying, verbose self

2007-11-28 Thread Bruno Desthuilliers
Steven D'Aprano a écrit :
> On Tue, 27 Nov 2007 10:11:48 +0100, Bruno Desthuilliers wrote:
> 
>> Fine. Now since Python let you define your own callable types and your
>> own descriptors, you can as well have an attribute that behave just like
>> a method without being an instance of any of the method types - so the
>> above test defeats duck typing. And since you can have callable
>> attributes that are definitively not methods, you can't rely on the fact
>> that an attribute is callable neither.
> 
> I did say the usual way was to call it and see what happens :)

It's certainly *not* "the usual way" to test if some object is callable 
- it's only ok if you really intented to call it, and even then it might 
be better to test before calling so you distinguish exceptions raised 
from within the called code from exceptions due the the call itself.

> (In Python3, I understand that is what callable() will do.

IIRC, there's no callable() function at all in Python 3.

> 
> I also didn't mention classmethods, staticmethods or functions assigned 
> to attributes. As Ton van Vliet is a beginner, I didn't think he needed 
> to be flooded with too many complications all at once.

Understanding the object model of a (mostly) OO langage is not what I'd 
call "too many complications". But I may be a bit biased !-)

> It's quite 
> possible to program in Python for years and never come across a callable 
> attribute that isn't an ordinary method.

You loose !-)

callable(object.__class__)
=> True
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Troubleshooting garbage collection issues

2007-11-28 Thread [EMAIL PROTECTED]
Thanks for the thoughts - much appreciated!  The threaded super-goat
was indeed the offender.  A very aggressive QA tester got us enough of
a pattern to identify the offending module: pyOpenSSL.  After looking
at it closely, we found there are problems with its thread handling.
In particular, the GIL is not properly locked when manipulating
reference counts and also, in once case, when creating a new python
object.  Once we cleaned that up we were unable to reproduce the
problem.

We'll post the fixes back to the pyOpenSSL folks shortly.

Thanks again!

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


Re: How to Teach Python "Variables"

2007-11-28 Thread Aaron Watters
On Nov 27, 5:31 pm, MonkeeSage <[EMAIL PROTECTED]> wrote:

> Of course. But then it really depends on the teaching methodology,
> doesn't it? There is no reason (well, barring the restraints of the
> curriculum vitea), that one should learn topics so complex as to
> require "off-putting" the *real* meaning until later, when one could
> just as easily learn the basic concepts first. I guess it's a matter
> of preference; whether you build from the top down (ala Berkley) or
> the other way 'round.

As you hint, this is the tip of the iceberg
of some very complex philosophical issues.
For practical instruction I think there is
overwhelming evidence you can't "begin at the beginning".
In mathematics you really can't teach starting
with the axioms of set theory and build up from
there -- you'd never get to long division before
the students will have given up long ago.
Similarly, in computer science you can't just
go off to the beach to get some sand to start
building a computer.  (Although when I was
at Bell Labs the joke was that that was the
Bell Labs attitude.)

In practice you always have to start in the
middle and tell the students not to worry
about stuff that would add an overwhelming
amount of detail.  For example, most beginning
students will have a vague idea what
the filesystem is, even though they will
have to deal with it a lot -- and you don't
want to get mired down for the first few weeks
trying to talk about the filesystem.  Instead
you say "follow these steps and all will
become clear later."  It's not a matter of
preference -- it's a matter of necessity.

  -- Aaron Watters
===
http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=lazy+future+generation
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to Teach Python "Variables"

2007-11-28 Thread hdante
On Nov 28, 1:09 am, Steven D'Aprano
<[EMAIL PROTECTED]> wrote:
> On Tue, 27 Nov 2007 10:21:36 -0800, hdante wrote:
> > Python variables are pointers and that's it.
>
> How do I increment a Python variable so that it points to the next
> address, like I can do with pointers in C, Pascal, and other languages?
>
> --
> Steven.

 You can't. Python variables still are pointers. Hint:

 int * const x = &y;

 How do I increment x ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: string conversion latin2 to ascii

2007-11-28 Thread kyosohma
On Nov 27, 5:08 pm, John Machin <[EMAIL PROTECTED]> wrote:
> On Nov 28, 8:45 am, [EMAIL PROTECTED] wrote:
>
>
>
>
>
>
>
> > On Nov 27, 3:35 pm, Martin Landa <[EMAIL PROTECTED]> wrote:
>
> > > Hi all,
>
> > > sorry for a newbie question. I have unicode string (or better say
> > > latin2 encoding) containing non-ascii characters, e.g.
>
> > > s = "Ukázka_možnosti_využití_programu_OpenJUMP_v_SOA"
>
> > > I would like to convert this string to plain ascii (using some lookup
> > > table for latin2)
>
> > > to get
>
> > > -> Ukazka_moznosti_vyuziti_programu_OpenJUMP_v_SOA
>
> > > Thanks for any hits! Regards, Martin Landa
>
> > With a little googling, I found this:
>
> >http://www.peterbe.com/plog/unicode-to-ascii
>
> and if the OP has the patience to read *ALL* the comments on that blog
> entry, he will find that comment[-2] points to
>
> http://effbot.python-hosting.com/file/stuff/sandbox/text/unaccent.py
>
> and comment[-1] (from the blog owner) is "Brilliant! Thank you."
>
> The bottom line is that there is no universal easy solution; you need
> to handcraft a translation table suited to your particular purpose
> (e.g. do you want u-with-umlaut to become u or ue?). The
> unicodedata.normalize function is useful for off-line preparation of a
> set of candidate mappings for that table; it should not be applied
> either on-line or blindly.
>
> Cheers,
> John

Sorry...I didn't know about translation tables or I would have
mentioned that instead. My bad.

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


Re: Unexpected behavior when initializing class

2007-11-28 Thread Mel
Paul Rudin wrote:
> "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes:

> A common paradigm to get round this - assuming you want a different
> empty list each time - is something like:
> 
> def __init__(self, v = None):
> self.values = v if v else []
> 
> (or maybe test explicitly for None, but you get the idea.)

Do test explicitly for None.  Otherwise, if you do

a = []
x = ThatClass (a)


it will so happen that x.values will be an empty list, but it won't be 
the same list as a.

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


Re: Running unmodified CGI scripts persistently under mod_wsgi.

2007-11-28 Thread Thomas Guettler
Istvan Albert schrieb:
> It will be awesome if mod_wsgi can run CGI without invoking python on
> each access.

For SCGI there is something like this: cgi2scgi: it is small executable written 
in C,
which connects to a running SCGI server.

Executing this small binary on every request is no big overhead.

Nevertheless I never used it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Tip of the day generator.

2007-11-28 Thread Joseph king
Hey i was wondering if any one would know if there was a way to have
python randomly read form a file or would you ahve to know the byte
postion and somehow randomize splicing the file so the sentence you
want show's up.

i.e have a file with a lot of tips and useless facts and then have
python randomly read one sentence when the code is run and print at
any time you would want it to.
-- 
http://mail.python.org/mailman/listinfo/python-list


WindowsError: [Error 5] Access is denied With _winreg.enum

2007-11-28 Thread black_13
I have included a small script the reproduces the error I am having in
larger script.
The line 'hkey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,name)'
seems
to be causing the error but im not sure why.
- script 

import _winreg
import string

def reproduce_error():

for index in
xrange(_winreg.QueryInfoKey(_winreg.HKEY_LOCAL_MACHINE)[0]):
   #get names
   name =
_winreg.EnumKey(_winreg.HKEY_LOCAL_MACHINE,index)
   hkey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,name)
   print name

hkey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,'SOFTWARE')
print hkey
hkey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,'SAM')
print hkey

if __name__ == '__main__':
reproduce_error()
--- end script
-
HARDWARE
SAM
Traceback (most recent call last):
  File "winreg_error.py", line 19, in 
reproduce_error()
  File "winreg_error.py", line 10, in reproduce_error
hkey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,name)
WindowsError: [Error 5] Access is denied
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to Teach Python "Variables"

2007-11-28 Thread hdante
On Nov 28, 1:42 pm, Neil Cerutti <[EMAIL PROTECTED]> wrote:
> On 2007-11-28, hdante <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Nov 28, 1:09 am, Steven D'Aprano
> ><[EMAIL PROTECTED]> wrote:
> >> On Tue, 27 Nov 2007 10:21:36 -0800, hdante wrote:
> >> > Python variables are pointers and that's it.
>
> >> How do I increment a Python variable so that it points to the
> >> next address, like I can do with pointers in C, Pascal, and
> >> other languages?
>
> >> --
> >> Steven.
>
> >  You can't. Python variables still are pointers. Hint:
>
> >  int * const x = &y;
>
> >  How do I increment x ?
>
> Not only that, you can't point x at any other object at all.
> That's not a Python variable either.
>
> --
> Neil Cerutti

 That's right. Languages may have arbitrary sets of operations defined
for their variables. There's nothing wrong with that.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to Teach Python "Variables"

2007-11-28 Thread Neil Cerutti
On 2007-11-28, hdante <[EMAIL PROTECTED]> wrote:
> On Nov 28, 1:09 am, Steven D'Aprano
><[EMAIL PROTECTED]> wrote:
>> On Tue, 27 Nov 2007 10:21:36 -0800, hdante wrote:
>> > Python variables are pointers and that's it.
>>
>> How do I increment a Python variable so that it points to the
>> next address, like I can do with pointers in C, Pascal, and
>> other languages?
>>
>> --
>> Steven.
>
>  You can't. Python variables still are pointers. Hint:
>
>  int * const x = &y;
>
>  How do I increment x ?

Not only that, you can't point x at any other object at all.
That's not a Python variable either.

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


Re: How to Teach Python "Variables"

2007-11-28 Thread Neil Cerutti
On 2007-11-28, hdante <[EMAIL PROTECTED]> wrote:
> On Nov 28, 1:42 pm, Neil Cerutti <[EMAIL PROTECTED]> wrote:
>> On 2007-11-28, hdante <[EMAIL PROTECTED]> wrote:
>>
>>
>>
>> > On Nov 28, 1:09 am, Steven D'Aprano
>> ><[EMAIL PROTECTED]> wrote:
>> >> On Tue, 27 Nov 2007 10:21:36 -0800, hdante wrote:
>> >> > Python variables are pointers and that's it.
>>
>> >> How do I increment a Python variable so that it points to the
>> >> next address, like I can do with pointers in C, Pascal, and
>> >> other languages?
>>
>> >> --
>> >> Steven.
>>
>> >  You can't. Python variables still are pointers. Hint:
>>
>> >  int * const x = &y;
>>
>> >  How do I increment x ?
>>
>> Not only that, you can't point x at any other object at all.
>> That's not a Python variable either.
>
> That's right. Languages may have arbitrary sets of operations
> defined for their variables. There's nothing wrong with that.

No, arbitrary operations would be useless.

-- 
Neil Cerutti
Scouts are saving aluminum cans, bottles, and other items to be recycled.
Proceeds will be used to cripple children. --Church Bulletin Blooper
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tip of the day generator.

2007-11-28 Thread Diez B. Roggisch
Joseph king wrote:

> Hey i was wondering if any one would know if there was a way to have
> python randomly read form a file or would you ahve to know the byte
> postion and somehow randomize splicing the file so the sentence you
> want show's up.
> 
> i.e have a file with a lot of tips and useless facts and then have
> python randomly read one sentence when the code is run and print at
> any time you would want it to.

import random
print random.choice(open("quotes").readlines())

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


Re: How to Teach Python "Variables"

2007-11-28 Thread Chris Mellon
On Nov 28, 2007 9:51 AM, hdante <[EMAIL PROTECTED]> wrote:
> On Nov 28, 1:42 pm, Neil Cerutti <[EMAIL PROTECTED]> wrote:
> > On 2007-11-28, hdante <[EMAIL PROTECTED]> wrote:
> >
> >
> >
> > > On Nov 28, 1:09 am, Steven D'Aprano
> > ><[EMAIL PROTECTED]> wrote:
> > >> On Tue, 27 Nov 2007 10:21:36 -0800, hdante wrote:
> > >> > Python variables are pointers and that's it.
> >
> > >> How do I increment a Python variable so that it points to the
> > >> next address, like I can do with pointers in C, Pascal, and
> > >> other languages?
> >
> > >> --
> > >> Steven.
> >
> > >  You can't. Python variables still are pointers. Hint:
> >
> > >  int * const x = &y;
> >
> > >  How do I increment x ?
> >
> > Not only that, you can't point x at any other object at all.
> > That's not a Python variable either.
> >
> > --
> > Neil Cerutti
>
>  That's right. Languages may have arbitrary sets of operations defined
> for their variables. There's nothing wrong with that.
>

Right. Python variables are pointers, except for all the ways that
they are different. By the same criteria, they are also puppies. Give
it a rest.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tip of the day generator.

2007-11-28 Thread Neil Cerutti
On 2007-11-28, Joseph king <[EMAIL PROTECTED]> wrote:
> Hey i was wondering if any one would know if there was a way to
> have python randomly read form a file or would you ahve to know
> the byte postion and somehow randomize splicing the file so the
> sentence you want show's up.
>
> i.e have a file with a lot of tips and useless facts and then
> have python randomly read one sentence when the code is run and
> print at any time you would want it to.

I use a Python application sort of like that to install the
random quotes in my sig. It reads a text file containing one
quote per line, selects a random one, and updates my signature
file with a quote half the time.

Originally it ran as a daemon and updated my sig every 60
seconds, but it was a pain to remember to stop and start it. Now
I just have the program run automatically whenever I edit a post.

Incidentally, you don't want to the the C++ program that this
replaced.

import textwrap
import random
import os

print "Sigswap v0.4"

homedir = os.getenv("HOME")
homedir = '/'.join(homedir.split('\\'))
sigpath = homedir + '/my.sig'

quotepath = homedir + '/quotes.txt'
qfile = file(quotepath)
quotelist = []
for quote in qfile:
quotelist.append(quote)
qfile.close()
sigfile = file(sigpath, "w")
sigfile.write("-- \n")
sigfile.write("Neil Cerutti\n")
random.seed()
if random.choice([True, False]):
quote = random.choice(quotelist)
for line in textwrap.wrap(quote, 78):
sigfile.write(line)
sigfile.write('\n')
sigfile.close()

-- 
Neil Cerutti
Cyrus McCormick invented the McCormick Raper, which did the work of a hundred
men. --History Exam Blooper
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: WindowsError: [Error 5] Access is denied With _winreg.enum

2007-11-28 Thread Jerry Hill
On Nov 28, 2007 11:04 AM, black_13 <[EMAIL PROTECTED]> wrote:
> I have included a small script the reproduces the error I am having in
> larger script.  The line 'hkey = 
> _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,name)'
> seems to be causing the error but im not sure why.
...
> WindowsError: [Error 5] Access is denied

Your user does not have permission to open the registry key you
requested.  On my local machine, HKEY_LOCAL_MACHINE/SECURITY is only
accessible by the SYSTEM account.  Even Administrative users do not
have Read rights to that key by default.

If you want to skip keys you don't have permission to access, you
could do something like this:

import _winreg

for index in xrange(_winreg.QueryInfoKey(_winreg.HKEY_LOCAL_MACHINE)[0]):
try:
name = _winreg.EnumKey(_winreg.HKEY_LOCAL_MACHINE,index)
hkey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,name)
except WindowsError:
print "Could not access registry key", name
else:
print name, hkey

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


Re: How to Teach Python "Variables"

2007-11-28 Thread hdante
On Nov 28, 2:06 pm, Neil Cerutti <[EMAIL PROTECTED]> wrote:
>
> > That's right. Languages may have arbitrary sets of operations
> > defined for their variables. There's nothing wrong with that.
>
> No, arbitrary operations would be useless.
>

 1) You may convince a big company to add you newly developed
arbitrary operation to their compiler.
 2) You may give support to developers who have problems with the
arbitrary operation.
 3) You'll be able to better quantify the failure rate of your
applications.
 4) You'll be able to create an emotional bond between the users and
your software.

> --
> Neil Cerutti
> Scouts are saving aluminum cans, bottles, and other items to be recycled.
> Proceeds will be used to cripple children. --Church Bulletin Blooper

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


Re: Tip of the day generator.

2007-11-28 Thread Jason
On Nov 28, 9:00 am, "Joseph king" <[EMAIL PROTECTED]> wrote:
> Hey i was wondering if any one would know if there was a way to have
> python randomly read form a file or would you ahve to know the byte
> postion and somehow randomize splicing the file so the sentence you
> want show's up.
>
> i.e have a file with a lot of tips and useless facts and then have
> python randomly read one sentence when the code is run and print at
> any time you would want it to.

Python can handle it just fine.  You probably want to create a text
file with a standard delimiter between quotes, perhaps a text line
with three to five equal signs ('===').  Open the file object [1],
read in all the data [2], split the data into a list by the delimiter
[3], then choose a random string from the list [4].  For example:

>>> import random
>>> quotes = open('quotes.txt').read()
>>> quoteList = quotes.split('===\n')
>>> print random.choice( quoteList )
This is a single sentence that repels vikings.

>>> print random.choice( quoteList )
This is a single sentence that repels vikings.

>>> print random.choice( quoteList )
This is a crazy, multi-line quote!  It's
so very, very crazy!
   -Personal Attribution


>>>

Obviously, you might need to deal with leading and trailing whitespace
[5].

If you are restricted to a series of paragraphs in the text file,
you'll need to split the string at the sentence separating
punctuation.  There's a lot of ways that punctuation can work in
English, so splitting on periods, exclamation points, and question
marks may not work if you have elipses (...) in the document.  You'll
probably need to split using a regular expression [6].

If you are reading a formatted file of some sort (such as XML, HTML,
badly-formatted HTML, Word documents, PDFs, etc), you'll need to
figure out how to read the document in Python.  While Python has XML
support and some HTML support [7], you'll probably want Beautiful Soup
[8] to read badly formatted HTML.  Word documents are much trickier,
and it's usually easiest to use Microsoft Word to save to a plain text
format.

Hope this helps you out!

  --Jason

[1] http://docs.python.org/lib/built-in-funcs.html
[2] http://docs.python.org/lib/bltin-file-objects.html
[3] http://docs.python.org/lib/string-methods.html
[4] http://docs.python.org/lib/module-random.html
[5] http://docs.python.org/lib/string-methods.html
[6] http://docs.python.org/lib/node46.html
[7] http://docs.python.org/lib/markup.html
[8] http://www.crummy.com/software/BeautifulSoup/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: WindowsError: [Error 5] Access is denied With _winreg.enum

2007-11-28 Thread kyosohma
On Nov 28, 10:04 am, black_13 <[EMAIL PROTECTED]> wrote:
> I have included a small script the reproduces the error I am having in
> larger script.
> The line 'hkey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,name)'
> seems
> to be causing the error but im not sure why.
> - script 
>
> import _winreg
> import string
>
> def reproduce_error():
>
> for index in
> xrange(_winreg.QueryInfoKey(_winreg.HKEY_LOCAL_MACHINE)[0]):
>#get names
>name =
> _winreg.EnumKey(_winreg.HKEY_LOCAL_MACHINE,index)
>hkey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,name)
>print name
>
> hkey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,'SOFTWARE')
> print hkey
> hkey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,'SAM')
> print hkey
>
> if __name__ == '__main__':
> reproduce_error()
> --- end script
> -
> HARDWARE
> SAM
> Traceback (most recent call last):
>   File "winreg_error.py", line 19, in 
> reproduce_error()
>   File "winreg_error.py", line 10, in reproduce_error
> hkey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,name)
> WindowsError: [Error 5] Access is denied

If you move the "print name" line up one line, you'll notice that it's
choking on the Security key. Go to Start --> Run  and type regedit. Go
to that key and right-click it and check its permissions.

On my PC the only user that has complete control is the SYSTEM. So
you'll probably just want to put an exception block in your function
that records the keys that you can't open and continues to run.

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


Re: Tip of the day generator.

2007-11-28 Thread Neil Cerutti
On 2007-11-28, Neil Cerutti <[EMAIL PROTECTED]> wrote:
> import textwrap
> import random
> import os
>
> print "Sigswap v0.4"
> [...]

Yikes!

That program was in dire need of Pythonification. It must have
been written early in my Pythonology.

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


Creating the windows MSI of python

2007-11-28 Thread Floris Bruynooghe
Hello

I've managed to build python2.4 and python2.5 in windows with MSVC++
7.1 fine following the instructions in the PCbuild directory.  However
now I am wondering how to create the MSI from this[1], but can't find
any instructions.  All I'm looking for is the equivalent of "make
install" (or "make install DESTDIR=/alternative/root").

I could just look at what files and registry settings etc the
installer creates and collect all the files manually from the build
directory, and then poor them into an MSI.  But that seems a bit
dangerous for missing something and it will become a maintenance
headache on upgrades too.  Isn't there some script shipped with python
that allows you to build a completely compatible distribution?

It would be great if someone knows how Python builds it's MSI.

Thanks
Floris


[1] Ok, not really.  What I really want is a merge module or .msm, but
never mind that part.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to Teach Python "Variables"

2007-11-28 Thread hdante
On Nov 28, 2:12 pm, "Chris Mellon" <[EMAIL PROTECTED]> wrote:
>
> Right. Python variables are pointers, except for all the ways that
> they are different. By the same criteria, they are also puppies. Give
> it a rest.

 I'm sorry if your notion of pointer is incorrect. A pointer (or, more
formally, a reference) is an object that points to some value. A
python variable isn't different than that in any way.

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


Re: Unexpected behavior when initializing class

2007-11-28 Thread Arnaud Delobelle
On Nov 28, 3:04 pm, Mel <[EMAIL PROTECTED]> wrote:
> Paul Rudin wrote:
> > "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes:
> > A common paradigm to get round this - assuming you want a different
> > empty list each time - is something like:
>
> > def __init__(self, v = None):
> > self.values = v if v else []
>
> > (or maybe test explicitly for None, but you get the idea.)
>
> Do test explicitly for None.  Otherwise, if you do
>
> a = []
> x = ThatClass (a)
>
> it will so happen that x.values will be an empty list, but it won't be
> the same list as a.
>
> Mel.

Yes.  Another much safer possibility is to make a copy of the initial
v:

def __init__(self, values=[]):
self.values = list(values)

As a nice side effect, the object can be initialised with any
iterable.

--
Arnaud

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


Re: How to Teach Python "Variables"

2007-11-28 Thread Chris Mellon
On Nov 28, 2007 10:57 AM, hdante <[EMAIL PROTECTED]> wrote:
> On Nov 28, 2:12 pm, "Chris Mellon" <[EMAIL PROTECTED]> wrote:
> >
> > Right. Python variables are pointers, except for all the ways that
> > they are different. By the same criteria, they are also puppies. Give
> > it a rest.
>
>  I'm sorry if your notion of pointer is incorrect. A pointer (or, more
> formally, a reference) is an object that points to some value. A
> python variable isn't different than that in any way.
>

A python name isn't an object. The difference between names and
objects is at the core of this entire conversation. In fact, you are
exactly the sort of person this discussion was targeted at, because
you don't understand the difference.

You can play semantic games if you want and just declare that
everything is the same at some fundamental level. It's a little like
taking your ball and going home, because insisting on names that don't
indicate the differences between things is useless at best and harmful
at worst.

Whether you like it or not, the term "pointer" has a specific common
meanings. They do not mean "any means by which you may reference a
value". "variable" is certainly less clear and is used much more
loosely, but in the specific context of comparison to C, python
name/object bindings are not the same as C variables.

Pointers are values. They also point at other values, and those values
may be other pointers, ad infinitum. Understanding this is core to
understanding and using pointers.

Python names are *not* values, and all they do is tag a specific
object in a specific namespace. You can't have a name that refers to
another name, names can only refer to objects. Understanding this is
core to understanding and using the Python object model, *especially*
if some nitwit has been telling you that they're the same as pointers.
-- 
http://mail.python.org/mailman/listinfo/python-list


string parsing / regexp question

2007-11-28 Thread Ryan Krauss
I need to parse the following string:

$$\pmatrix{{\it x_2}\cr 0\cr 1\cr }=\pmatrix{\left({{{\it m_2}\,s^2
 }\over{k}}+1\right)\,{\it x_1}-{{F}\over{k}}\cr -{{{\it m_2}\,s^2\,F
 }\over{k}}-F+\left({\it m_2}\,s^2\,\left({{{\it m_2}\,s^2}\over{k}}+1
 \right)+{\it m_2}\,s^2\right)\,{\it x_1}\cr 1\cr }$$

The first thing I need to do is extract the arguments to \pmatrix{ }
on both the left and right hand sides of the equal sign, so that the
first argument is extracted as

{\it x_2}\cr 0\cr 1\cr

and the second is

\left({{{\it m_2}\,s^2
 }\over{k}}+1\right)\,{\it x_1}-{{F}\over{k}}\cr -{{{\it m_2}\,s^2\,F
 }\over{k}}-F+\left({\it m_2}\,s^2\,\left({{{\it m_2}\,s^2}\over{k}}+1
 \right)+{\it m_2}\,s^2\right)\,{\it x_1}\cr 1\cr

The trick is that there are extra curly braces inside the \pmatrix{ }
strings and I don't know how to write a regexp that would count the
number of open and close curly braces and make sure they match, so
that it can find the correct ending curly brace.

Any suggestions?

I would  prefer a regexp solution, but am open to other approaches.

Thanks,

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


Re: Creating the windows MSI of python

2007-11-28 Thread Christian Heimes
Floris Bruynooghe wrote:
> It would be great if someone knows how Python builds it's MSI.

The Tools/ directory contains a script in Tools/msi/msi.py. Martin von
Löwis is using the script to generate the official MSI bundles. You need
to run it from a development shell. Good luck!

Christian

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


Re: string parsing / regexp question

2007-11-28 Thread Tim Chase
> The trick is that there are extra curly braces inside the \pmatrix{ }
> strings and I don't know how to write a regexp that would count the
> number of open and close curly braces and make sure they match, so
> that it can find the correct ending curly brace.

This criterion is pretty much a deal-breaker for using regexps, 
as you can't really nest things to arbitrary depths using regexps.

You really do need a parser of sorts, and pyparsing[1] is one of 
the more popular parsers, and fairly easy to use.

-tim

[1] http://pyparsing.wikispaces.com/




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


Re: How to Teach Python "Variables"

2007-11-28 Thread J. Clifford Dyer

On Wed, Nov 28, 2007 at 11:23:42AM -0600, Chris Mellon wrote regarding Re: How 
to Teach Python "Variables":
> 
> On Nov 28, 2007 10:57 AM, hdante <[EMAIL PROTECTED]> wrote:
> > On Nov 28, 2:12 pm, "Chris Mellon" <[EMAIL PROTECTED]> wrote:
> > >
> > > Right. Python variables are pointers, except for all the ways that
> > > they are different. By the same criteria, they are also puppies. Give
> > > it a rest.
> >
> >  I'm sorry if your notion of pointer is incorrect. A pointer (or, more
> > formally, a reference) is an object that points to some value. A
> > python variable isn't different than that in any way.
> >
> 
> A python name isn't an object. The difference between names and
> objects is at the core of this entire conversation. In fact, you are
> exactly the sort of person this discussion was targeted at, because
> you don't understand the difference.
> 
> You can play semantic games if you want and just declare that
> everything is the same at some fundamental level. It's a little like
> taking your ball and going home, because insisting on names that don't
> indicate the differences between things is useless at best and harmful
> at worst.
> 
> Whether you like it or not, the term "pointer" has a specific common
> meanings. They do not mean "any means by which you may reference a
> value". "variable" is certainly less clear and is used much more
> loosely, but in the specific context of comparison to C, python
> name/object bindings are not the same as C variables.
> 
> Pointers are values. They also point at other values, and those values
> may be other pointers, ad infinitum. Understanding this is core to
> understanding and using pointers.
> 
> Python names are *not* values, and all they do is tag a specific
> object in a specific namespace. You can't have a name that refers to
> another name, names can only refer to objects. Understanding this is
> core to understanding and using the Python object model, *especially*
> if some nitwit has been telling you that they're the same as pointers.
> -- 
> http://mail.python.org/mailman/listinfo/python-list

OK, now we're down to mock sympathy, insulting analogies and name-calling.  Can 
we just let this thread die.  It was an interesting discussion for a while, but 
it's moved into that ugly putrefaction stage now.  Nothing new is being said, 
and the old stuff is being said more rudely than before.

This thread is bleedin' demised.

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


Python Nmap script linux version

2007-11-28 Thread Daniel Folkes
I made this script for fun.  you need to have Nmap installed on your
linux computer and it will find all the computers on the network and
then run Nmap on it.

Hope you enjoy!

import os
fn = 'i.result'
ip = '192.168.1.1-255'
ip1 = ip[:3]
ips = []
os.system("nmap -sP 192.168.1.1-255 > "+fn)
f = open(fn)
try:
   for line in f:
   if ip1 in line:
   ips.append(line[5:-19])

finally:
   f.close()

os.system("clear")
for i in ips:
   print '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-='
   os.system("nmap "+i)
   print '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-='
   raw_input('press to continue...')


Tell me what you think
-- 
http://mail.python.org/mailman/listinfo/python-list


Try/Except/Yield/Finally...I'm Lost :-}

2007-11-28 Thread Victor Subervi
Hi;
I am trying to find words in a document that are identical to any word in a
vocabulary list, to replace that word with special markup. Let's say the
word is "dharma". I don't want to replace the first few letters of, say
"dharmawuhirfuhi". Also, to make matters more difficult, if the word
"adharma" is found in the document, I need to replace that with special
markup, too. (In Sanskrit, "a" preceding a word negates the word.) But I
don't want to replace "adharma" and then go off and replace the "dharma" in
"adharma", thus having nested markup. Now, I tried separating out all the
words in the line (I go through the doc line by line), but then, of course,
I lost all the punctuation! So now I have this code:

for word in vocab:
aword = "a" + word
try:
line = re.sub(aword, pu_four + aword +
pu_five + aword + pu_six, line)
except:
pass
try:
line = re.sub(word, pu_one + word + pu_two +
word + pu_three, line)
except:
pass

which, of course, ends up breaking all the above! Can someone send me a
shovel to dig my way out of this mess?
TIA,
Victor
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Code Management

2007-11-28 Thread misc
On Nov 20, 4:09 pm, Jens <[EMAIL PROTECTED]> wrote:
>
> 1) Should I put my unittests in a subdirectory? Does the subdirectory
> have to be a package?

As others have suggested, this is a good way to organise your tests.
To avoid problems with the import path, look at nosetests [1]. This
allows you to run::

  nosetests
main_package_name.subpackage1.test.test1:TestSomeClass.test_func

to run the test_func function in the TestSomeClass test case.

Or alternatively::

  nosetests main_package_name.subpackage1

to run all tests contained in the main_package_name.subpackage1
module.

This allows you to remove all of your 'if __name__ ==
"__main__":unittest.main()' code, as well as gets rid of the problem
with relative imports (which others solved using .pth files).

The only downside for me is that running nosetests takes at least half
a second (eg: import nose), compared to making the tests runnable
which can be _very_ quick. For test driven development it's nice to
have tests really really quick.

One gotcha; if you're converting from a 'if __name__ ==
"__main__":...' system; nosetests by default ignores files that are
executable (so you'll need to chmod -x main_package_name/subpackage1/
test/test1.py).


[1] nose: a discovery-based unittest extension - (http://
somethingaboutorange.com/mrl/projects/nose/).

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


Re: Books on Python

2007-11-28 Thread shadowsithe
On Nov 27, 10:05 pm, "barcaroller" <[EMAIL PROTECTED]> wrote:
> Can someone kindly recommend some good books on the following:
>
> Python for beginners
> Python for advanced users
>
> Is there a bible like Larry Wall's Programming Perl or Bjarne Stroustrup's
> The C++ Programming Language?

Python in a Nutshell is a very good reference.
-- 
http://mail.python.org/mailman/listinfo/python-list


Trying to build cjson on Widnows, getting errors

2007-11-28 Thread Jack
Since I don't have VS2003, I'm trying to build cjson with MingW and Cygwin 
but I'm getting lots of errors like these:

build\temp.win32-2.5\Release\cjson.o(.text+0x8e):cjson.c: undefined 
reference to
 `_imp___Py_NoneStruct'
build\temp.win32-2.5\Release\cjson.o(.text+0x95):cjson.c: undefined 
reference to
 `_imp___Py_NoneStruct'
build\temp.win32-2.5\Release\cjson.o(.text+0x122):cjson.c: undefined 
reference t
o `_imp___Py_TrueStruct'
build\temp.win32-2.5\Release\cjson.o(.text+0x129):cjson.c: undefined 
reference t
o `_imp___Py_TrueStruct'
build\temp.win32-2.5\Release\cjson.o(.text+0x15d):cjson.c: undefined 
reference t
o `_imp___Py_ZeroStruct'

Any idea what I'm missing? Thanks. 


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


Re: Books on Python

2007-11-28 Thread Jeff McNeil
I've purchased a couple of books on Python and I keep going back to Python
in a Nutshell.  It's about the only printed text I keep on my desk all the
time.  It has a nice introduction to the language and includes the
specification, too.
If you're familiar with programming,
http://diveintopython.org/ is
good (and it's free online if you don't want to spend the $ on the dead-tree
version).  I'm not sure how up to date it is, though.

Also, don't overlook the online tutorials. They're quite good.

On 11/28/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> On Nov 27, 10:05 pm, "barcaroller" <[EMAIL PROTECTED]> wrote:
> > Can someone kindly recommend some good books on the following:
> >
> > Python for beginners
> > Python for advanced users
> >
> > Is there a bible like Larry Wall's Programming Perl or Bjarne
> Stroustrup's
> > The C++ Programming Language?
>
> Python in a Nutshell is a very good reference.
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: string parsing / regexp question

2007-11-28 Thread Paul McGuire
On Nov 28, 11:32 am, "Ryan Krauss" <[EMAIL PROTECTED]> wrote:
> I need to parse the following string:
>
> $$\pmatrix{{\it x_2}\cr 0\cr 1\cr }=\pmatrix{\left({{{\it m_2}\,s^2
>  }\over{k}}+1\right)\,{\it x_1}-{{F}\over{k}}\cr -{{{\it m_2}\,s^2\,F
>  }\over{k}}-F+\left({\it m_2}\,s^2\,\left({{{\it m_2}\,s^2}\over{k}}+1
>  \right)+{\it m_2}\,s^2\right)\,{\it x_1}\cr 1\cr }$$
>
> The first thing I need to do is extract the arguments to \pmatrix{ }
> on both the left and right hand sides of the equal sign, so that the
> first argument is extracted as
>
> {\it x_2}\cr 0\cr 1\cr
>
> and the second is
>
> \left({{{\it m_2}\,s^2
>  }\over{k}}+1\right)\,{\it x_1}-{{F}\over{k}}\cr -{{{\it m_2}\,s^2\,F
>  }\over{k}}-F+\left({\it m_2}\,s^2\,\left({{{\it m_2}\,s^2}\over{k}}+1
>  \right)+{\it m_2}\,s^2\right)\,{\it x_1}\cr 1\cr
>
> The trick is that there are extra curly braces inside the \pmatrix{ }
> strings and I don't know how to write a regexp that would count the
> number of open and close curly braces and make sure they match, so
> that it can find the correct ending curly brace.
>

As Tim Grove points out, writing a grammar for this expression is
really pretty simple, especially using the latest version of
pyparsing, which includes a new helper method, nestedExpr.  Here is
the whole program to parse your example:

from pyparsing import *

data = r"""$$\pmatrix{{\it x_2}\cr 0\cr 1\cr }=
\pmatrix{\left({{{\it m_2}\,s^2
 }\over{k}}+1\right)\,{\it x_1}-{{F}\over{k}}\cr -{{{\it
m_2}\,s^2\,F
 }\over{k}}-F+\left({\it m_2}\,s^2\,\left({{{\it
m_2}\,s^2}\over{k}}+1
 \right)+{\it m_2}\,s^2\right)\,{\it x_1}\cr 1\cr }$$"""

PMATRIX = Literal(r"\pmatrix")
nestedBraces = nestedExpr("{","}")
grammar = "$$" + PMATRIX + nestedBraces + "=" + \
 PMATRIX + nestedBraces + \
 "$$"
res = grammar.parseString(data)
print res

This prints the following:

['$$', '\\pmatrix', [['\\it', 'x_2'], '\\cr', '0\\cr', '1\\cr'], '=',
'\\pmatrix', ['\\left(', [[['\\it', 'm_2'], '\\,s^2'], '\\over',
['k']], '+1\\right)\\,', ['\\it', 'x_1'], '-', [['F'], '\\over',
['k']], '\\cr', '-', [[['\\it', 'm_2'], '\\,s^2\\,F'], '\\over',
['k']], '-F+\\left(', ['\\it', 'm_2'], '\\,s^2\\,\\left(', [[['\\it',
'm_2'], '\\,s^2'], '\\over', ['k']], '+1', '\\right)+', ['\\it',
'm_2'], '\\,s^2\\right)\\,', ['\\it', 'x_1'], '\\cr', '1\\cr'], '$$']

Okay, maybe this looks a bit messy.  But believe it or not, the
returned results give you access to each grammar element as:

['$$', '\\pmatrix', [nested arg list], '=', '\\pmatrix',
[nestedArgList], '$$']

Not only has the parser handled the {} nesting levels, but it has
structured the returned tokens according to that nesting.  (The '{}'s
are gone now, since their delimiting function has been replaced by the
nesting hierarchy in the results.)

You could use tuple assignment to get at the individual fields:
dummy,dummy,lhs_args,dummy,dummy,rhs_args,dummy = res

Or you could access the fields in res using list indexing:
lhs_args, rhs_args = res[2],res[5]

But both of these methods will break if you decide to extend the
grammar with additional or optional fields.

A safer approach is to give the grammar elements results names, as in
this slightly modified version of grammar:

grammar = "$$" + PMATRIX + nestedBraces("lhs_args") + "=" + \
 PMATRIX + nestedBraces("rhs_args") + \
 "$$"

Now you can access the parsed fields as if the results were a dict
with keys "lhs_args" and "rhs_args", or as an object with attributes
named "lhs_args" and "rhs_args":

res = grammar.parseString(data)
print res["lhs_args"]
print res["rhs_args"]
print res.lhs_args
print res.rhs_args

Note that the default behavior of nestedExpr is to give back a nested
list of the elements according to how the original text was nested
within braces.

If you just want the original text, add a parse action to nestedBraces
to do this for you (keepOriginalText is another pyparsing builtin).
The parse action is executed at parse time so that there is no post-
processing needed after the parsed results are returned:

nestedBraces.setParseAction(keepOriginalText)
grammar = "$$" + PMATRIX + nestedBraces("lhs_args") + "=" + \
 PMATRIX + nestedBraces("rhs_args") + \
 "$$"

res = grammar.parseString(data)
print res
print res.lhs_args
print res.rhs_args

Now this program returns the original text for the nested brace
expressions:

['$$', '\\pmatrix', '{{\\it x_2}\\cr 0\\cr 1\\cr }', '=', '\\pmatrix',
'{\\left({{{\\it m_2}\\,s^2 \n }\\over{k}}+1\\right)\\,{\\it x_1}-{{F}\
\over{k}}\\cr -{{{\\it m_2}\\,s^2\\,F \n }\\over{k}}-F+\\left({\\it
m_2}\\,s^2\\,\\left({{{\\it m_2}\\,s^2}\\over{k}}+1 \n \\right)+{\\it
m_2}\\,s^2\\right)\\,{\\it x_1}\\cr 1\\cr }', '$$']
['{{\\it x_2}\\cr 0\\cr 1\\cr }']
['{\\left({{{\\it m_2}\\,s^2 \n }\\over{k}}+1\\right)\\,{\\it x_1}-{{F}
\\over{k

Control mouse position and clicking

2007-11-28 Thread Glich
hi, how can I, control mouse position and clicking from python?

I want to interact with a flash application inside firefox. thanks.

ps: I am not using windows.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: wxPython problem

2007-11-28 Thread SMALLp
[EMAIL PROTECTED] wrote:
> On Nov 28, 1:06 pm, SMALLp <[EMAIL PROTECTED]> wrote:
>> Hy. I'm new in linux (Ubuntu 7.10) as well as in python. I installed
>> IDLE, and i installed package python-wxgtkX. I start IDLE and when i
>> want co compile my aplication all windows close. Also when i vrite
>> smoethin lik thile in IDLE:
>>
>> import wx
>> app = wx.App()
>> wx.Frmae(none, -1)
>>
>> same thing, Please help! Thanks!
> 
> I'm not sure, but I don't think you downloaded the package correctly.
> Go here for complete instructions:
> 
> http://wxpython.org/download.php
> 
> I think you need to replace the "X" in "python-wxgtkX" with the
> release number. Something like "python-wxgtk2.8" or some such.
> 
> Then try to import wx and see if that works.
> 
> If none of that works, post to the wxPython user's group which can be
> found at the link above.
> 
> Mike
Ups. i installed python-wxgtk2.8 package!
-- 
http://mail.python.org/mailman/listinfo/python-list


wxPython problem

2007-11-28 Thread SMALLp
Hy. I'm new in linux (Ubuntu 7.10) as well as in python. I installed 
IDLE, and i installed package python-wxgtkX. I start IDLE and when i 
want co compile my aplication all windows close. Also when i vrite 
smoethin lik thile in IDLE:

import wx
app = wx.App()
wx.Frmae(none, -1)

same thing, Please help! Thanks!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: wxPython problem

2007-11-28 Thread kyosohma
On Nov 28, 1:06 pm, SMALLp <[EMAIL PROTECTED]> wrote:
> Hy. I'm new in linux (Ubuntu 7.10) as well as in python. I installed
> IDLE, and i installed package python-wxgtkX. I start IDLE and when i
> want co compile my aplication all windows close. Also when i vrite
> smoethin lik thile in IDLE:
>
> import wx
> app = wx.App()
> wx.Frmae(none, -1)
>
> same thing, Please help! Thanks!

I'm not sure, but I don't think you downloaded the package correctly.
Go here for complete instructions:

http://wxpython.org/download.php

I think you need to replace the "X" in "python-wxgtkX" with the
release number. Something like "python-wxgtk2.8" or some such.

Then try to import wx and see if that works.

If none of that works, post to the wxPython user's group which can be
found at the link above.

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


Re: Control mouse position and clicking

2007-11-28 Thread Paul McGuire
On Nov 28, 1:29 pm, Glich <[EMAIL PROTECTED]> wrote:
> hi, how can I, control mouse position and clicking from python?
>
> I want to interact with a flash application inside firefox. thanks.
>
> ps: I am not using windows.

Ooof, I was about to suggest using pywinauto, because I was able to
interact with a flash app with that module, until I saw your p.s.

So even though you are not using windows and can't use this technique
directly, I am just posting to give you some encouragement that, at
least theoretically, such a thing can be done.

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


Re: Control mouse position and clicking

2007-11-28 Thread Laszlo Nagy
Paul McGuire wrote:
> On Nov 28, 1:29 pm, Glich <[EMAIL PROTECTED]> wrote:
>   
>> hi, how can I, control mouse position and clicking from python?
>>
>> I want to interact with a flash application inside firefox. thanks.
>>
>> ps: I am not using windows.
>> 
>
> Ooof, I was about to suggest using pywinauto, because I was able to
> interact with a flash app with that module, until I saw your p.s.
>
> So even though you are not using windows and can't use this technique
> directly, I am just posting to give you some encouragement that, at
> least theoretically, such a thing can be done.
>   
It is for sure - VNC server does that.

It might be a (very bad) solution to install a VNC server on one 
computer, and controll it from Windows using a VNC client. (It works but 
it was a joke, of course...)

   Laszlo

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


Re: win32serviceutil won't start

2007-11-28 Thread Nikola Skoric
Dana Mon, 26 Nov 2007 08:50:23 -0800 (PST), 
[EMAIL PROTECTED] <[EMAIL PROTECTED]> kaze:
> Sorry I didn't reply sooner. If you're creating a service based on a
> Python file, check out the following links in addition to the book
> Wolfgang mentioned:
>
> http://agiletesting.blogspot.com/2005/09/running-python-script-as-windows.html
> http://www.thescripts.com/forum/thread595660.html
> http://essiene.blogspot.com/2005/04/python-windows-services.html
>
> That should get you started. Hope it helps!

Huh. Thank you guys a lot. I took a glance (albeit a rather long one)
and decided that my users will have to install cygwin if they want to
use my script. Service handling is just a bit to complicated (after
creating UNIX daemon with 2 consecutive forks), and I'm not going to
be paid for this :-D

-- 
"Now the storm has passed over me
I'm left to drift on a dead calm sea
And watch her forever through the cracks in the beams
Nailed across the doorways of the bedrooms of my dreams"
-- 
http://mail.python.org/mailman/listinfo/python-list


Bit Operations

2007-11-28 Thread Gianmaria Iaculo - NVENTA
Hi there,
I'm so new to python (coming from .net so excuse me for the stupid question) 
and i'm tring to do a very simple thing,with bytes.

My problem is this:

i've a byte that naturally is composed from 2 nibbles hi&low, and two 
chars.. like A nd B. What i wonna do is to write A to the High nibble and B 
to the the lower nibble.
Or an other example can be i've 2 numbers.. like 7 and 8 and whant to do the 
same as for chars.

I'm really confused on how t do it, maybe cause python is type-less (dynamic 
typed)


Any Help?

Cheers,
Gianmaria
ITALY


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


Re: string parsing / regexp question

2007-11-28 Thread Paul McGuire
On Nov 28, 1:23 pm, Paul McGuire <[EMAIL PROTECTED]> wrote:
> As Tim Grove points out, ...

s/Grove/Chase/

Sorry, Tim!

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


Re: Bit Operations

2007-11-28 Thread Chris Mellon
On Nov 28, 2007 2:07 PM, Gianmaria Iaculo - NVENTA
<[EMAIL PROTECTED]> wrote:
> Hi there,
> I'm so new to python (coming from .net so excuse me for the stupid question)
> and i'm tring to do a very simple thing,with bytes.
>
> My problem is this:
>
> i've a byte that naturally is composed from 2 nibbles hi&low, and two
> chars.. like A nd B. What i wonna do is to write A to the High nibble and B
> to the the lower nibble.

A string in python is a sequence of bytes, so what you're describing
here is the string "AB".

> Or an other example can be i've 2 numbers.. like 7 and 8 and whant to do the
> same as for chars.
>

"\x07\x08"

> I'm really confused on how t do it, maybe cause python is type-less (dynamic
> typed)
>

You can use the struct module to convert back and forth between byte
sequences and numerical values. For example, to get an integer with
the value of the nibble you mentioned before:

struct.unpack("h", "AB") -> (16961,)

Exactly what you'll want to use and what format you want will depend
on why you're doing this.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bit Operations

2007-11-28 Thread Tim Chase
> I'm really confused on how t do it, maybe cause python is
> type-less (dynamic typed)

Being duck-typed doesn't really have anything to do with it. 
Python supports logical shifting and combining

> i've a byte that naturally is composed from 2 nibbles hi&low,
> and two chars.. like A nd B. What i wonna do is to write A to
> the High nibble and B to the the lower nibble. Or an other
> example can be i've 2 numbers.. like 7 and 8 and whant to do
> the same as for chars.

 >>> a = int('1001', 2)
 >>> b = int('0110', 2)
 >>> a
9
 >>> b
6
 >>> 0xff & (((0xff & a) << 4) | (0xff & b))
150

or, if you're sloppy,

 >>> (a << 4) | b
150

And for verification:

 >>> int('10010110', 2)
150

Thus, that can be wrapped up as a function

 >>> nibbles2byte = lambda a,b: \
   0xff & (((0xff & a) << 4) | (0xff & b))
 >>> nibbles2byte(a,b)
150


-tkc




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


Re: win32serviceutil won't start

2007-11-28 Thread kyosohma
On Nov 28, 1:59 pm, Nikola Skoric <[EMAIL PROTECTED]> wrote:
> Dana Mon, 26 Nov 2007 08:50:23 -0800 (PST),
> [EMAIL PROTECTED] <[EMAIL PROTECTED]> kaze:
>
> > Sorry I didn't reply sooner. If you're creating a service based on a
> > Python file, check out the following links in addition to the book
> > Wolfgang mentioned:
>
> >http://agiletesting.blogspot.com/2005/09/running-python-script-as-win...
> >http://www.thescripts.com/forum/thread595660.html
> >http://essiene.blogspot.com/2005/04/python-windows-services.html
>
> > That should get you started. Hope it helps!
>
> Huh. Thank you guys a lot. I took a glance (albeit a rather long one)
> and decided that my users will have to install cygwin if they want to
> use my script. Service handling is just a bit to complicated (after
> creating UNIX daemon with 2 consecutive forks), and I'm not going to
> be paid for this :-D
>
> --
> "Now the storm has passed over me
> I'm left to drift on a dead calm sea
> And watch her forever through the cracks in the beams
> Nailed across the doorways of the bedrooms of my dreams"

Yeah...a lot of things on Windows is just too complicated for its own
good. Every now and again you'll stumble across something that's
pretty elegant though.

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


Re: Bit Operations

2007-11-28 Thread Chris Mellon
On Nov 28, 2007 2:27 PM, Chris Mellon <[EMAIL PROTECTED]> wrote:
> On Nov 28, 2007 2:07 PM, Gianmaria Iaculo - NVENTA
> <[EMAIL PROTECTED]> wrote:
> > Hi there,
> > I'm so new to python (coming from .net so excuse me for the stupid question)
> > and i'm tring to do a very simple thing,with bytes.
> >
> > My problem is this:
> >
> > i've a byte that naturally is composed from 2 nibbles hi&low, and two
> > chars.. like A nd B. What i wonna do is to write A to the High nibble and B
> > to the the lower nibble.
>
> A string in python is a sequence of bytes, so what you're describing
> here is the string "AB".
>

Ah, I didn't realize until after I'd sent this that you were trying to
merge them into the same byte. This doesn't make a whole lot of sense
- ord("A") is outside the range you can represent in half a byte - but
Python does support the full range of bitwise operations, so you can
do whatever kind of shifting and setting that you'd have done in .NET.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: string parsing / regexp question

2007-11-28 Thread Tim Chase
Paul McGuire wrote:
> On Nov 28, 1:23 pm, Paul McGuire <[EMAIL PROTECTED]> wrote:
>> As Tim Grove points out, ...
> 
> s/Grove/Chase/
> 
> Sorry, Tim!

No problem...it's not like there aren't enough Tim's on the list 
as it is. :)

-tkc




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


Re: Bit Operations

2007-11-28 Thread John Machin
On Nov 29, 7:07 am, "Gianmaria Iaculo - NVENTA"
<[EMAIL PROTECTED]> wrote:
> Hi there,
> I'm so new to python (coming from .net so excuse me for the stupid question)
> and i'm tring to do a very simple thing,with bytes.
>
> My problem is this:
>
> i've a byte that naturally is composed from 2 nibbles hi&low, and two
> chars.. like A nd B. What i wonna do is to write A to the High nibble and B
> to the the lower nibble.

But a nibble is 4 bits and a char in general is 8 bits. Please explain
"write A to the high nibble". Let's assume that you mean that 0 <= A
<= 15 

The building blocks that you need are the ord() and chr() builtin
functions, and the << (shift-left) operator. The hex() function is
useful for seeing what is happening.

>>> a = '\x07'
>>> b = '\x08'
>>> c = 7
>>> d = 8
>>> ord(a)
7
>>> chr(c)
'\x07'
>>> hex(c)
'0x7'
>>> hex(c << 4)
'0x70'
>>> hex((ord(a) << 4) + ord(b))
'0x78'
>>> hex((c << 4) + d)
'0x78'
>>>

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


Re: Bit Operations

2007-11-28 Thread Grant Edwards
On 2007-11-28, Chris Mellon <[EMAIL PROTECTED]> wrote:
> On Nov 28, 2007 2:07 PM, Gianmaria Iaculo - NVENTA
><[EMAIL PROTECTED]> wrote:
>> Hi there,
>> I'm so new to python (coming from .net so excuse me for the stupid question)
>> and i'm tring to do a very simple thing,with bytes.
>>
>> My problem is this:
>>
>> i've a byte that naturally is composed from 2 nibbles hi&low, and two
>> chars.. like A nd B. What i wonna do is to write A to the High nibble and B
>> to the the lower nibble.
>
> A string in python is a sequence of bytes, so what you're describing
> here is the string "AB".

No, he's describing something that consists of 2 nibbles (1
byte).  The string "AB" is two bytes.

>> Or an other example can be i've 2 numbers.. like 7 and 8 and whant to do the
>> same as for chars.
>>
>
> "\x07\x08"

Again, he wants a single byte and that's two bytes.

>> I'm really confused on how t do it, maybe cause python is
>> type-less (dynamic typed)
>
> You can use the struct module to convert back and forth between byte
> sequences and numerical values. For example, to get an integer with
> the value of the nibble you mentioned before:
>
> struct.unpack("h", "AB") -> (16961,)

No, he wants to do this:

 (0x0A<<4) | 0x0B

 (7<<4) | 8

> Exactly what you'll want to use and what format you want will depend
> on why you're doing this.


-- 
Grant Edwards   grante Yow! My vaseline is
  at   RUNNING...
   visi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bit Operations

2007-11-28 Thread J. Clifford Dyer
On Wed, Nov 28, 2007 at 09:07:56PM +0100, Gianmaria Iaculo - NVENTA wrote 
regarding Bit Operations:
> 
> Hi there,
> I'm so new to python (coming from .net so excuse me for the stupid question) 
> and i'm tring to do a very simple thing,with bytes.
> 
> My problem is this:
> 
> i've a byte that naturally is composed from 2 nibbles hi&low, and two 
> chars.. like A nd B. What i wonna do is to write A to the High nibble and B 
> to the the lower nibble.
> Or an other example can be i've 2 numbers.. like 7 and 8 and whant to do the 
> same as for chars.
> 
> I'm really confused on how t do it, maybe cause python is type-less (dynamic 
> typed)
> 
Do you possibly mean that your letters are hexadecimal digits?  If so, you can 
follow the advice given to you by others for numbers, treating your letters as 
numbers:

A=10
B=11
...
F=15

py>>> hex(15)
'0xf'
>>> int('f', 16)
15
>>> int('0xf', 16)
15

Cheers,
Cliff

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


Optimized Python bytecode

2007-11-28 Thread Looney, James B
I'm using SCons to build all kinds of things, and part of our build
process involves creating a "release" version of our software.  In the
case of Python, that means compiling the .py into a .pyc or .pyo.
Because I'm placing the compiled script into a different location from
the .py, I have to figure out myself whether to name the file a .pyc or
a .pyo.

So, how do I programatically (within Python) figure out if someone used
the -O or -OO flags, without having access to the argv list?  How about
programatically (still within Python) setting those flags?

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

Re: Bit Operations

2007-11-28 Thread Dan Upton
>  >>> 0xff & (((0xff & a) << 4) | (0xff & b))
> 150
>
> or, if you're sloppy,
>
>  >>> (a << 4) | b
> 150

Slightly OT, maybe - why exactly is the second alternative 'sloppy?'
I believe you, because I had a problem once (in Java) with bytes not
having the value I expected unless I did the and-magic, but I wasn't
clear on why.  Is it an issue with the word otherwise possibly not
being zeroed out?

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


Re: Creating the windows MSI of python

2007-11-28 Thread Floris Bruynooghe
On Nov 28, 5:26 pm, Christian Heimes <[EMAIL PROTECTED]> wrote:
> Floris Bruynooghe wrote:
> > It would be great if someone knows how Python builds it's MSI.
>
> The Tools/ directory contains a script in Tools/msi/msi.py. Martin von
> Löwis is using the script to generate the official MSI bundles. You need
> to run it from a development shell. Good luck!

Thanks!

Floris

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


Re: Bit Operations

2007-11-28 Thread Gianmaria Iaculo - NVENTA
Txs all,
i wont to respond to who asked why i needed it:

I'm using python on GSM modules and the informations i have to move goes 
along GPRS/UMTS connections so it's beatiful for me to transfer more 
informations with less space...
imagine i have to send this simple data

41.232323,12.345678

i can send it as it's or use the nibble trick and on the receiving station 
'unlift" the data and rebuild the original information...

isn'it???

cheers + TXS,
Gianmaria

ps: now i'm gonna read all your answers in details... txs again


Firma Gianmaria Iaculo
"Gianmaria Iaculo - NVENTA" <[EMAIL PROTECTED]> ha scritto nel messaggio 
news:[EMAIL PROTECTED]
> Hi there,
> I'm so new to python (coming from .net so excuse me for the stupid 
> question) and i'm tring to do a very simple thing,with bytes.
>
> My problem is this:
>
> i've a byte that naturally is composed from 2 nibbles hi&low, and two 
> chars.. like A nd B. What i wonna do is to write A to the High nibble and 
> B to the the lower nibble.
> Or an other example can be i've 2 numbers.. like 7 and 8 and whant to do 
> the same as for chars.
>
> I'm really confused on how t do it, maybe cause python is type-less 
> (dynamic typed)
>
>
> Any Help?
>
> Cheers,
> Gianmaria
> ITALY
>
> 

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


Tuning question

2007-11-28 Thread Wally Lepore
Hi Graham

Is this email still good?

Its been awhile since we spoke last on the tuning list. Are you still on
Yahoo messenger?
Also, what is your email address please. You told me to email you when I had
questions that seemed too basic for the tuning list. Thanks Graham.  My
email is [EMAIL PROTECTED]

Stay well
Walter (Wally) Lepore


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


Re: Bit Operations

2007-11-28 Thread J. Clifford Dyer
On Wed, Nov 28, 2007 at 10:05:40PM +0100, Gianmaria Iaculo - NVENTA wrote 
regarding Re: Bit Operations:
> 
> Txs all,
> i wont to respond to who asked why i needed it:
> 
> I'm using python on GSM modules and the informations i have to move goes 
> along GPRS/UMTS connections so it's beatiful for me to transfer more 
> informations with less space...
> imagine i have to send this simple data
> 
> 41.232323,12.345678
> 
> i can send it as it's or use the nibble trick and on the receiving station 
> 'unlift" the data and rebuild the original information...
> 
> isn'it???
> 

Um, no.  It isn't.  How exactly are you going to pack floating point numbers 
into a half a byte?

Or are you sending it as strings?  Also a waste of space, and unnecessarily 
complex.


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


Python Network Graph Library

2007-11-28 Thread [EMAIL PROTECTED]
Hi Folks,

I am looking for a network Graph Library with Python bindings (Iron or
C!).

Just need a simple relationship visualisation - seen a few via google
but many seem to be unmaintained.

Any suggestions?

Thanks,
Davy Mitchell

--
Davy Mitchell
Blog - http://daftspaniel.blogspot.com
Twitter - http://twitter.com/daftspaniel
Skype - daftspaniel
needgod.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bit Operations

2007-11-28 Thread Chris Mellon
On Nov 28, 2007 3:18 PM, J. Clifford Dyer <[EMAIL PROTECTED]> wrote:
> On Wed, Nov 28, 2007 at 10:05:40PM +0100, Gianmaria Iaculo - NVENTA wrote 
> regarding Re: Bit Operations:
> >
> > Txs all,
> > i wont to respond to who asked why i needed it:
> >
> > I'm using python on GSM modules and the informations i have to move goes
> > along GPRS/UMTS connections so it's beatiful for me to transfer more
> > informations with less space...
> > imagine i have to send this simple data
> >
> > 41.232323,12.345678
> >
> > i can send it as it's or use the nibble trick and on the receiving station
> > 'unlift" the data and rebuild the original information...
> >
> > isn'it???
> >
>
> Um, no.  It isn't.  How exactly are you going to pack floating point numbers 
> into a half a byte?
>
> Or are you sending it as strings?  Also a waste of space, and unnecessarily 
> complex.
>

Assuming these are coordinates, not floats, using strings makes sense
but the zlib module is probably a much better choice than a
hand-written compression scheme.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Control mouse position and clicking

2007-11-28 Thread Bjoern Schliessmann
Glich wrote:
> hi, how can I, control mouse position and clicking from python?
> 
> I want to interact with a flash application inside firefox.
> thanks.
> 
> ps: I am not using windows.

On Mac, IIRC, you can't.

Regards,


Björn

-- 
BOFH excuse #394:

Jupiter is aligned with Mars.

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


exporting from twiki

2007-11-28 Thread Gerry
I have a twiki, with documentation on 200 "things".  I'd like to
export the 200 pages, with their embedded graphs, to some static
version (word, pdf, ...) that I can give to a non-connected, reference
user community to "read" - i.e., no =navigation required beyond back
and forth to a table of contents.

I've found a plug-in that exports to PDF, but (while much better than
nothing) leaves a lot to be desired.  PDF editing seems to be pretty
minimal, and I'm not sure I can order the pages as I'd like
(alphabetically by their titles, say).  If I delete a few pages, I'm
not sure I can re-generate the table of contents, and renumber the
pages (in Acrobat).

Do any of you have any tips or code on automating exports from a
twiki?

Thanks,

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


Re: Bit Operations

2007-11-28 Thread Gianmaria Iaculo - NVENTA
U are really nice guys... i'm really apreciating (sorry 4 my bad english)

Chriss is right this are coordinates and i'm treating as strings 
naturally
I dont really have floating points on my module.. it run a 1.5 python 
version from Telit.
So i dont have zLib too... just have 1.5 Mb of Ram and 3Mb of Rom... not 
realy confortable..isn't it?

I'm tring some experiments on the command line... i've tried this:

My longitude is 42.237897

so as a first step... i created a X and done this job as your examples:

a = 4
b = 2

x = (a<<4)|b
x is 66

so i can do:

aDecoded = x >> 4

and i have the 4 again...( a value) but i've some problems while i decode 
the b

Where i go wrong?


Gianmaria




Firma Gianmaria Iaculo
"Chris Mellon" <[EMAIL PROTECTED]> ha scritto nel messaggio 
news:[EMAIL PROTECTED]
> On Nov 28, 2007 3:18 PM, J. Clifford Dyer <[EMAIL PROTECTED]> wrote:
>> On Wed, Nov 28, 2007 at 10:05:40PM +0100, Gianmaria Iaculo - NVENTA wrote 
>> regarding Re: Bit Operations:
>> >
>> > Txs all,
>> > i wont to respond to who asked why i needed it:
>> >
>> > I'm using python on GSM modules and the informations i have to move 
>> > goes
>> > along GPRS/UMTS connections so it's beatiful for me to transfer more
>> > informations with less space...
>> > imagine i have to send this simple data
>> >
>> > 41.232323,12.345678
>> >
>> > i can send it as it's or use the nibble trick and on the receiving 
>> > station
>> > 'unlift" the data and rebuild the original information...
>> >
>> > isn'it???
>> >
>>
>> Um, no.  It isn't.  How exactly are you going to pack floating point 
>> numbers into a half a byte?
>>
>> Or are you sending it as strings?  Also a waste of space, and 
>> unnecessarily complex.
>>
>
> Assuming these are coordinates, not floats, using strings makes sense
> but the zlib module is probably a much better choice than a
> hand-written compression scheme. 

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


Re: Bit Operations

2007-11-28 Thread Tim Chase
>>  >>> 0xff & (((0xff & a) << 4) | (0xff & b))
>> 150
>>
>> or, if you're sloppy,
>>
>>  >>> (a << 4) | b
>> 150
> 
> Slightly OT, maybe - why exactly is the second alternative 'sloppy?'
> I believe you, because I had a problem once (in Java) with bytes not
> having the value I expected unless I did the and-magic, but I wasn't
> clear on why.  Is it an issue with the word otherwise possibly not
> being zeroed out?

Whoops...extra "f"s slipped into my nibble-mask

"Sloppy" lets through things like

 >>> a = int('1', 2) # overflows a nibble
 >>> b = int('1', 2)
 >>> (a<<4) | b
511
 >>> 0xff & (((0xf & a) << 4) | (0xf & b))
255

It clamps each nibble to a true nibble, and the output to a true 
byte.  If you validate your nibbles, you could be lazy yet 
accurate with

 >>> result = ((0xf & a) << 4) | (0xf & b)
 >>> result
255

To get the nibbles back out of the resulting byte, one can simply

 >>> a = 0xf & (result >> 4)
 >>> b = result & 0xf

-tkc




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


Re: Bit Operations

2007-11-28 Thread John Machin
On Nov 29, 8:35 am, "Gianmaria Iaculo - NVENTA"
<[EMAIL PROTECTED]> wrote:
> U are really nice guys... i'm really apreciating (sorry 4 my bad english)
>
> Chriss is right this are coordinates and i'm treating as strings
> naturally
> I dont really have floating points on my module.. it run a 1.5 python
> version from Telit.
> So i dont have zLib too... just have 1.5 Mb of Ram and 3Mb of Rom... not
> realy confortable..isn't it?
>
> I'm tring some experiments on the command line... i've tried this:
>
> My longitude is 42.237897
>
> so as a first step... i created a X and done this job as your examples:
>
> a = 4
> b = 2
>
> x = (a<<4)|b
> x is 66
>
> so i can do:
>
> aDecoded = x >> 4
>
> and i have the 4 again...( a value) but i've some problems while i decode
> the b
>
> Where i go wrong?

>>> 66 & 0xf
2
>>>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Books on Python

2007-11-28 Thread Lou Pecora
In article 
<[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] wrote:

> On Nov 27, 10:05 pm, "barcaroller" <[EMAIL PROTECTED]> wrote:
> > Can someone kindly recommend some good books on the following:
> >
> > Python for beginners
> > Python for advanced users
> >
> > Is there a bible like Larry Wall's Programming Perl or Bjarne Stroustrup's
> > The C++ Programming Language?
> 
> Python in a Nutshell is a very good reference.

I second that.  I also found Learning Python (Lutz & Ascher, O'Reilly 
pub.) to be helpful when I first started, but Nutshell is what I keep 
going back to.  Very good book.

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


Re: Bit Operations

2007-11-28 Thread John Machin
On Nov 29, 8:05 am, "Gianmaria Iaculo - NVENTA"
<[EMAIL PROTECTED]> wrote:
> Txs all,
> i wont to respond to who asked why i needed it:
>
> I'm using python on GSM modules and the informations i have to move goes
> along GPRS/UMTS connections so it's beatiful for me to transfer more
> informations with less space...
> imagine i have to send this simple data
>
> 41.232323,12.345678
>
> i can send it as it's or use the nibble trick and on the receiving station
> 'unlift" the data and rebuild the original information...
>
> isn'it???

Sorry, but it's not apparent what you propose to do. If each number
has 8 decimal digits of precision (as in your example), you could
possibly get by with a 32-bit floating point number. If it's always 6
decimal places and 0 <= number < 1000, you could pack (number *
100) into a 32-bit integer. For the above two options, check out
the struct module. OTOH, maybe it's "packed decimal" that you mean --
try Googling that phrase and see if it matches your intentions. If it
does, and you are concerned with speed, a 100-element dictionary
mapping each byte-pair to a packed byte might be a good idea instead
of the bit bashing:
convert = {
   '78': '\x78',
   ...
}
See http://mail.python.org/pipermail/python-list/2000-October/056329.html

HTH,
John

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


Re: Bit Operations

2007-11-28 Thread Gianmaria Iaculo - NVENTA
John can you make an example of this solution? You maen that a more compact 
way is possible???


Firma Gianmaria Iaculo
"John Machin" <[EMAIL PROTECTED]> ha scritto nel messaggio 
news:[EMAIL PROTECTED]
> On Nov 29, 8:05 am, "Gianmaria Iaculo - NVENTA"
> <[EMAIL PROTECTED]> wrote:
>> Txs all,
>> i wont to respond to who asked why i needed it:
>>
>> I'm using python on GSM modules and the informations i have to move goes
>> along GPRS/UMTS connections so it's beatiful for me to transfer more
>> informations with less space...
>> imagine i have to send this simple data
>>
>> 41.232323,12.345678
>>
>> i can send it as it's or use the nibble trick and on the receiving 
>> station
>> 'unlift" the data and rebuild the original information...
>>
>> isn'it???
>
> Sorry, but it's not apparent what you propose to do. If each number
> has 8 decimal digits of precision (as in your example), you could
> possibly get by with a 32-bit floating point number. If it's always 6
> decimal places and 0 <= number < 1000, you could pack (number *
> 100) into a 32-bit integer. For the above two options, check out
> the struct module. OTOH, maybe it's "packed decimal" that you mean --
> try Googling that phrase and see if it matches your intentions. If it
> does, and you are concerned with speed, a 100-element dictionary
> mapping each byte-pair to a packed byte might be a good idea instead
> of the bit bashing:
> convert = {
>   '78': '\x78',
>   ...
> }
> See http://mail.python.org/pipermail/python-list/2000-October/056329.html
>
> HTH,
> John
> 

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


Re: Books on Python

2007-11-28 Thread kyosohma
On Nov 27, 9:05 pm, "barcaroller" <[EMAIL PROTECTED]> wrote:
> Can someone kindly recommend some good books on the following:
>
> Python for beginners
> Python for advanced users
>
> Is there a bible like Larry Wall's Programming Perl or Bjarne Stroustrup's
> The C++ Programming Language?

For good techniques and advanced knowledge, it's hard to beat Lutz's
tome: "Programming Python 3rd Ed." or Chun's "Core Python
Programming". Both are huge. Lutz's is a little bit more approachable
and had more extensive code examples, but I learned a lot about
Python's insides from Chun.

The cookbooks are handy too, but if you troll ActiveState already, you
may not need those.

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


Re: Bit Operations

2007-11-28 Thread John Machin
On Nov 29, 9:20 am, "Gianmaria Iaculo - NVENTA"
<[EMAIL PROTECTED]> wrote:
> John can you make an example of this solution?

Which possible solution? (a) 32-bit floating point (b) 32-bit integer
(c) packed decimal

> You maen that a more compact
> way is possible???

More compact than what? If your coordinates are all 8-digit decimal
numbers, then each of the above possible solutions will take 32 bits
per number. Which you could use depends on the (unstated) range and
precision of your coordinates. Also, you'll maybe notice that my
comment about using a dictionary for possible solution (c) was a
possible SPEED enhancement, not a compression enhancement.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Network Graph Library

2007-11-28 Thread jay graves
On Nov 28, 3:15 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> Hi Folks,
>
> I am looking for a network Graph Library with Python bindings (Iron or
> C!).
>
> Just need a simple relationship visualisation - seen a few via google
> but many seem to be unmaintained.
>

I've used GraphViz before but never any of the Python bindings.  It's
always been easy enough to just generate the .dot file that Graphviz
expects.
http://www.graphviz.org/

I've also book marked NetworkX but I've never used it.
https://networkx.lanl.gov/wiki

I'm sure there are others.

HTH.
Jay Graves
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: wxPython problem

2007-11-28 Thread SMALLp
SMALLp wrote:
> [EMAIL PROTECTED] wrote:
>> On Nov 28, 1:06 pm, SMALLp <[EMAIL PROTECTED]> wrote:
>>> Hy. I'm new in linux (Ubuntu 7.10) as well as in python. I installed
>>> IDLE, and i installed package python-wxgtkX. I start IDLE and when i
>>> want co compile my aplication all windows close. Also when i vrite
>>> smoethin lik thile in IDLE:
>>>
>>> import wx
>>> app = wx.App()
>>> wx.Frmae(none, -1)
>>>
>>> same thing, Please help! Thanks!
>>
>> I'm not sure, but I don't think you downloaded the package correctly.
>> Go here for complete instructions:
>>
>> http://wxpython.org/download.php
>>
>> I think you need to replace the "X" in "python-wxgtkX" with the
>> release number. Something like "python-wxgtk2.8" or some such.
>>
>> Then try to import wx and see if that works.
>>
>> If none of that works, post to the wxPython user's group which can be
>> found at the link above.
>>
>> Mike
> Ups. i installed python-wxgtk2.8 package!

I'm still having the problem! i installed new version of wxPyton, and 
now I'v noticed that when i'm writing in IDLE
app = wx.App()
frame = wx.Frame(None, -1, 'My frame') it crashes when writing last 
bracket. It works
with PyShell so if no one can halp sugest goot alternative to IDLE.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Control mouse position and clicking

2007-11-28 Thread Tony
On Nov 28, 9:33 pm, Bjoern Schliessmann  wrote:
snip
>
> On Mac, IIRC, you can't.
>
> Regards,

well, you can do it from Java, (the Robot class, as I recall), so you
should be able to do it in Jython, which is a Python implementation,
so

Tony

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


Re: Control mouse position and clicking

2007-11-28 Thread Tony
On Nov 28, 9:33 pm, Bjoern Schliessmann  wrote:
snip
>
> On Mac, IIRC, you can't.
>
> Regards,

well, you can do it from Java, (the Robot class, as I recall), so you
should be able to do it in Jython, which is a Python implementation,
so

Tony

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


Re: Running unmodified CGI scripts persistently under mod_wsgi.

2007-11-28 Thread Graham Dumpleton
On Nov 29, 2:36 am, Thomas Guettler <[EMAIL PROTECTED]> wrote:
> Istvan Albert schrieb:
>
> > It will be awesome ifmod_wsgican run CGI without invoking python on
> > each access.
>
> For SCGI there is something like this: cgi2scgi: it is small executable 
> written in C,
> which connects to a running SCGI server.
>
> Executing this small binary on every request is no big overhead.
>
> Nevertheless I never used it.

That isn't the same as what is being talked about here with unmodified
CGI scripts running under mod_wsgi. That program you are talking about
is more in line with what Ian was talking about, but would still
require the CGI script to be converted to work with SCGI directly or
WSGI and then use a SCGI/WSGI adapter.

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


Re: How to Teach Python "Variables"

2007-11-28 Thread Ben Finney

"Chris Mellon" <[EMAIL PROTECTED]> writes:

> Whether you like it or not, the term "pointer" has a specific common
> meanings. They do not mean "any means by which you may reference a
> value". "variable" is certainly less clear and is used much more
> loosely, but in the specific context of comparison to C, python
> name/object bindings are not the same as C variables.

Yes.

Further, "in the specific context of comparison to C" was all this
thread was *ever* about at the beginning:

none <""atavory\"@(none)"> writes:

>   Hello,
> 
>   IIRC, I once saw an explanation how Python doesn't have
> "variables" in the sense that, say, C does, and instead has bindings
> from names to objects. Does anyone have a link?

So please, let's stop trying to brinng up "pointer" and "variable"
with some pure language-independent meaning that is the only one we
should consider. The *specific context* here is the existing
preconceptions programmers bring from other languages like C.

-- 
 \   "Anytime I see something screech across a room and latch onto |
  `\someone's neck, and the guy screams and tries to get it off, I |
_o__)  have to laugh, because what is that thing?"  -- Jack Handey |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: string parsing / regexp question

2007-11-28 Thread Ryan Krauss
Interesting.  Thanks Paul and Tim.  This looks very promising.

Ryan

On Nov 28, 2007 1:23 PM, Paul McGuire <[EMAIL PROTECTED]> wrote:
> On Nov 28, 11:32 am, "Ryan Krauss" <[EMAIL PROTECTED]> wrote:
> > I need to parse the following string:
> >
> > $$\pmatrix{{\it x_2}\cr 0\cr 1\cr }=\pmatrix{\left({{{\it m_2}\,s^2
> >  }\over{k}}+1\right)\,{\it x_1}-{{F}\over{k}}\cr -{{{\it m_2}\,s^2\,F
> >  }\over{k}}-F+\left({\it m_2}\,s^2\,\left({{{\it m_2}\,s^2}\over{k}}+1
> >  \right)+{\it m_2}\,s^2\right)\,{\it x_1}\cr 1\cr }$$
> >
> > The first thing I need to do is extract the arguments to \pmatrix{ }
> > on both the left and right hand sides of the equal sign, so that the
> > first argument is extracted as
> >
> > {\it x_2}\cr 0\cr 1\cr
> >
> > and the second is
> >
> > \left({{{\it m_2}\,s^2
> >  }\over{k}}+1\right)\,{\it x_1}-{{F}\over{k}}\cr -{{{\it m_2}\,s^2\,F
> >  }\over{k}}-F+\left({\it m_2}\,s^2\,\left({{{\it m_2}\,s^2}\over{k}}+1
> >  \right)+{\it m_2}\,s^2\right)\,{\it x_1}\cr 1\cr
> >
> > The trick is that there are extra curly braces inside the \pmatrix{ }
> > strings and I don't know how to write a regexp that would count the
> > number of open and close curly braces and make sure they match, so
> > that it can find the correct ending curly brace.
> >
>
> As Tim Grove points out, writing a grammar for this expression is
> really pretty simple, especially using the latest version of
> pyparsing, which includes a new helper method, nestedExpr.  Here is
> the whole program to parse your example:
>
> from pyparsing import *
>
> data = r"""$$\pmatrix{{\it x_2}\cr 0\cr 1\cr }=
> \pmatrix{\left({{{\it m_2}\,s^2
>  }\over{k}}+1\right)\,{\it x_1}-{{F}\over{k}}\cr -{{{\it
> m_2}\,s^2\,F
>  }\over{k}}-F+\left({\it m_2}\,s^2\,\left({{{\it
> m_2}\,s^2}\over{k}}+1
>  \right)+{\it m_2}\,s^2\right)\,{\it x_1}\cr 1\cr }$$"""
>
> PMATRIX = Literal(r"\pmatrix")
> nestedBraces = nestedExpr("{","}")
> grammar = "$$" + PMATRIX + nestedBraces + "=" + \
>  PMATRIX + nestedBraces + \
>  "$$"
> res = grammar.parseString(data)
> print res
>
> This prints the following:
>
> ['$$', '\\pmatrix', [['\\it', 'x_2'], '\\cr', '0\\cr', '1\\cr'], '=',
> '\\pmatrix', ['\\left(', [[['\\it', 'm_2'], '\\,s^2'], '\\over',
> ['k']], '+1\\right)\\,', ['\\it', 'x_1'], '-', [['F'], '\\over',
> ['k']], '\\cr', '-', [[['\\it', 'm_2'], '\\,s^2\\,F'], '\\over',
> ['k']], '-F+\\left(', ['\\it', 'm_2'], '\\,s^2\\,\\left(', [[['\\it',
> 'm_2'], '\\,s^2'], '\\over', ['k']], '+1', '\\right)+', ['\\it',
> 'm_2'], '\\,s^2\\right)\\,', ['\\it', 'x_1'], '\\cr', '1\\cr'], '$$']
>
> Okay, maybe this looks a bit messy.  But believe it or not, the
> returned results give you access to each grammar element as:
>
> ['$$', '\\pmatrix', [nested arg list], '=', '\\pmatrix',
> [nestedArgList], '$$']
>
> Not only has the parser handled the {} nesting levels, but it has
> structured the returned tokens according to that nesting.  (The '{}'s
> are gone now, since their delimiting function has been replaced by the
> nesting hierarchy in the results.)
>
> You could use tuple assignment to get at the individual fields:
> dummy,dummy,lhs_args,dummy,dummy,rhs_args,dummy = res
>
> Or you could access the fields in res using list indexing:
> lhs_args, rhs_args = res[2],res[5]
>
> But both of these methods will break if you decide to extend the
> grammar with additional or optional fields.
>
> A safer approach is to give the grammar elements results names, as in
> this slightly modified version of grammar:
>
> grammar = "$$" + PMATRIX + nestedBraces("lhs_args") + "=" + \
>  PMATRIX + nestedBraces("rhs_args") + \
>  "$$"
>
> Now you can access the parsed fields as if the results were a dict
> with keys "lhs_args" and "rhs_args", or as an object with attributes
> named "lhs_args" and "rhs_args":
>
> res = grammar.parseString(data)
> print res["lhs_args"]
> print res["rhs_args"]
> print res.lhs_args
> print res.rhs_args
>
> Note that the default behavior of nestedExpr is to give back a nested
> list of the elements according to how the original text was nested
> within braces.
>
> If you just want the original text, add a parse action to nestedBraces
> to do this for you (keepOriginalText is another pyparsing builtin).
> The parse action is executed at parse time so that there is no post-
> processing needed after the parsed results are returned:
>
> nestedBraces.setParseAction(keepOriginalText)
> grammar = "$$" + PMATRIX + nestedBraces("lhs_args") + "=" + \
>  PMATRIX + nestedBraces("rhs_args") + \
>  "$$"
>
> res = grammar.parseString(data)
> print res
> print res.lhs_args
> print res.rhs_args
>
> Now this program returns the original text for the nested brace
> expressions:
>
> ['$$', '\\pmatrix', '{{\\it x_2}\\cr 0\\cr 1\\cr }', '=', '\\pmatrix',
> '{\\left({{{\\it m_2}

Re: string parsing / regexp question

2007-11-28 Thread Ryan Krauss
On Nov 28, 2007 1:23 PM, Paul McGuire <[EMAIL PROTECTED]> wrote:
> On Nov 28, 11:32 am, "Ryan Krauss" <[EMAIL PROTECTED]> wrote:
> > I need to parse the following string:
> >
> > $$\pmatrix{{\it x_2}\cr 0\cr 1\cr }=\pmatrix{\left({{{\it m_2}\,s^2
> >  }\over{k}}+1\right)\,{\it x_1}-{{F}\over{k}}\cr -{{{\it m_2}\,s^2\,F
> >  }\over{k}}-F+\left({\it m_2}\,s^2\,\left({{{\it m_2}\,s^2}\over{k}}+1
> >  \right)+{\it m_2}\,s^2\right)\,{\it x_1}\cr 1\cr }$$
> >
> > The first thing I need to do is extract the arguments to \pmatrix{ }
> > on both the left and right hand sides of the equal sign, so that the
> > first argument is extracted as
> >
> > {\it x_2}\cr 0\cr 1\cr
> >
> > and the second is
> >
> > \left({{{\it m_2}\,s^2
> >  }\over{k}}+1\right)\,{\it x_1}-{{F}\over{k}}\cr -{{{\it m_2}\,s^2\,F
> >  }\over{k}}-F+\left({\it m_2}\,s^2\,\left({{{\it m_2}\,s^2}\over{k}}+1
> >  \right)+{\it m_2}\,s^2\right)\,{\it x_1}\cr 1\cr
> >
> > The trick is that there are extra curly braces inside the \pmatrix{ }
> > strings and I don't know how to write a regexp that would count the
> > number of open and close curly braces and make sure they match, so
> > that it can find the correct ending curly brace.
> >
>
> As Tim Grove points out, writing a grammar for this expression is
> really pretty simple, especially using the latest version of
> pyparsing, which includes a new helper method, nestedExpr.  Here is
> the whole program to parse your example:
>
> from pyparsing import *
>
> data = r"""$$\pmatrix{{\it x_2}\cr 0\cr 1\cr }=
> \pmatrix{\left({{{\it m_2}\,s^2
>  }\over{k}}+1\right)\,{\it x_1}-{{F}\over{k}}\cr -{{{\it
> m_2}\,s^2\,F
>  }\over{k}}-F+\left({\it m_2}\,s^2\,\left({{{\it
> m_2}\,s^2}\over{k}}+1
>  \right)+{\it m_2}\,s^2\right)\,{\it x_1}\cr 1\cr }$$"""
>
> PMATRIX = Literal(r"\pmatrix")
> nestedBraces = nestedExpr("{","}")
> grammar = "$$" + PMATRIX + nestedBraces + "=" + \
>  PMATRIX + nestedBraces + \
>  "$$"
> res = grammar.parseString(data)
> print res
>
> This prints the following:
>
> ['$$', '\\pmatrix', [['\\it', 'x_2'], '\\cr', '0\\cr', '1\\cr'], '=',
> '\\pmatrix', ['\\left(', [[['\\it', 'm_2'], '\\,s^2'], '\\over',
> ['k']], '+1\\right)\\,', ['\\it', 'x_1'], '-', [['F'], '\\over',
> ['k']], '\\cr', '-', [[['\\it', 'm_2'], '\\,s^2\\,F'], '\\over',
> ['k']], '-F+\\left(', ['\\it', 'm_2'], '\\,s^2\\,\\left(', [[['\\it',
> 'm_2'], '\\,s^2'], '\\over', ['k']], '+1', '\\right)+', ['\\it',
> 'm_2'], '\\,s^2\\right)\\,', ['\\it', 'x_1'], '\\cr', '1\\cr'], '$$']
>
> Okay, maybe this looks a bit messy.  But believe it or not, the
> returned results give you access to each grammar element as:
>
> ['$$', '\\pmatrix', [nested arg list], '=', '\\pmatrix',
> [nestedArgList], '$$']
>
> Not only has the parser handled the {} nesting levels, but it has
> structured the returned tokens according to that nesting.  (The '{}'s
> are gone now, since their delimiting function has been replaced by the
> nesting hierarchy in the results.)
>
> You could use tuple assignment to get at the individual fields:
> dummy,dummy,lhs_args,dummy,dummy,rhs_args,dummy = res
>
> Or you could access the fields in res using list indexing:
> lhs_args, rhs_args = res[2],res[5]
>
> But both of these methods will break if you decide to extend the
> grammar with additional or optional fields.
>
> A safer approach is to give the grammar elements results names, as in
> this slightly modified version of grammar:
>
> grammar = "$$" + PMATRIX + nestedBraces("lhs_args") + "=" + \
>  PMATRIX + nestedBraces("rhs_args") + \
>  "$$"
>
> Now you can access the parsed fields as if the results were a dict
> with keys "lhs_args" and "rhs_args", or as an object with attributes
> named "lhs_args" and "rhs_args":
>
> res = grammar.parseString(data)
> print res["lhs_args"]
> print res["rhs_args"]
> print res.lhs_args
> print res.rhs_args
>
> Note that the default behavior of nestedExpr is to give back a nested
> list of the elements according to how the original text was nested
> within braces.
>
> If you just want the original text, add a parse action to nestedBraces
> to do this for you (keepOriginalText is another pyparsing builtin).
> The parse action is executed at parse time so that there is no post-
> processing needed after the parsed results are returned:
>
> nestedBraces.setParseAction(keepOriginalText)
> grammar = "$$" + PMATRIX + nestedBraces("lhs_args") + "=" + \
>  PMATRIX + nestedBraces("rhs_args") + \
>  "$$"
>
> res = grammar.parseString(data)
> print res
> print res.lhs_args
> print res.rhs_args
>
> Now this program returns the original text for the nested brace
> expressions:
>
> ['$$', '\\pmatrix', '{{\\it x_2}\\cr 0\\cr 1\\cr }', '=', '\\pmatrix',
> '{\\left({{{\\it m_2}\\,s^2 \n }\\over{k}}+1\\right)\\,{\\it x_1}-{{F}\
> \over{k}}\\cr -{{

Re: image rendering in python

2007-11-28 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote:

> http://cdnll.i.imagechef.com/ic/templimg2/Shaved%20Head.jpg
> Do u know how to make such images using PIL

using PIL, you can prepare a background image (the head), an overlay 
layer (properly shaded flesh tones) and a mask (e.g. using ImageDraw and 
a suitable font), and then use the "paste" method to paste the overlay 
onto the background.

you can use the "transform" method to tweak the mask (e.g. to bend the 
text).



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


Re: Python Network Graph Library

2007-11-28 Thread Anand Patil
On Nov 28, 2007 2:38 PM, jay graves <[EMAIL PROTECTED]> wrote:

> On Nov 28, 3:15 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> wrote:
> > Hi Folks,
> >
> > I am looking for a network Graph Library with Python bindings (Iron or
> > C!).
> >
> > Just need a simple relationship visualisation - seen a few via google
> > but many seem to be unmaintained.
> >
>
> I've used GraphViz before but never any of the Python bindings.  It's
> always been easy enough to just generate the .dot file that Graphviz
> expects.
> http://www.graphviz.org/
>
> I've also book marked NetworkX but I've never used it.
> https://networkx.lanl.gov/wiki
>
> I'm sure there are others.
>
> HTH.
> Jay Graves
> --
> http://mail.python.org/mailman/listinfo/python-list
>


Try PyDot, http://dkbza.org/pydot.html . I've had good luck with it.

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

  1   2   >