[ANN] TurboGears 1.1rc1 released

2009-09-22 Thread Christopher Arndt
On behalf of the TurboGears Team, I am pleased to announce that
TurboGears 1.1rc1 is available for download at

http://turbogears.org/

and the Python package index

http://pypi.python.org/pypi/TurboGears

TurboGears 1.1rc1 is the first release candidate for the upcoming 1.1
release, which is the evolution of the TurboGears 1 codebase. The 1.1
branch now uses SQLAlchemy as the default database layer and Genshi as
the standard templating engine but is 100 percent compatible with
applications built on TurboGears 1.0.

We encourage you to test this release with your existing TurboGears 1.0
applications and by building new ones. If no major problems are
reported, this release will become 1.1final in about two weeks. Beta
versions of TurboGears 1.1 have been in use in production environments
for over a year now, so we believe this release is rock-stable.


What is TurboGears?
---

TurboGears is a rapid development, front-to-back, open source web
meta-framework. Its aim is to simplify and speed up the development of
modern web applications written in the Python programming language.

TurboGears is designed around the model-view-controller architecture,
much like Struts or Ruby on Rails, and takes the best Python web
components available (hence meta-framework) and combines them into one
easy-to-install, documented whole.


What's new?
---

Apart from the change of defaults to SLQAlchemy and Genshi, TurboGears
1.1 has a new testing framework built on WebTest, a new quickstart
design (backported from TurboGears 2) and many, many bigger and smaller
fixes and improvements over version 1.0 in its internals. For a
comprehensive list of changes see the changelog in our Trac at

http://trac.turbogears.org/wiki/ChangeLog


How to install?
---

The easiest way to install TurboGears 1.1rc1 is via setuptools:

[sudo] easy_install [-f http://turbogears.org/download/] TurboGears

we recommend that you install TurboGears into its own virtual
environment using the virtualenv tool:

[sudo] easy_install virtualenv
virtualenv --no-site-packages /path/to/tgenv
source /path/to/tgenv/bin/activate
easy_install [-f http://turbogears.org/download/] TurboGears


How is it related to TurboGears 2?
--

TurboGears 1.1 is based on the original TurboGears 1.0 codebase and
still uses CherryPy 2.3 as the underlying web application server. It is
100 percent compatible with existing TurboGears 1.0 applications and
porting an application using SQLObject and Kid to use SQLAlchemy and
Genshi is easiliy achieved.

TurboGears 2 has almost the same API as TurboGears 1.x but builds on
Pylons as the underlying web engine. Most new development for TurboGears
now happens in version 2, but the 1.1 branch will be continued to be
supported and maybe even developed further for the foreseeable future.


The Future
--

TurboGears 1.1 final is slated to be released in about two weeks.
Afterwards we plan to issue a maintenance release for the TurboGears 1.0
branch, which would be version 1.0.9.

Further development on the TurboGears 1.1 branch depends on community
feedback, which we plan to collect by conducting an online survey
amongst TurboGears users. You may expect a separate announcement for
this very soon!


Share  enjoy!

-- 
Christopher Arndt sysad...@turbogears.org
TurboGears Systems Administrator
http://www.turbogears.org/

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

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


[ANN]: IronPython 2.6 Release Candidate 1

2009-09-22 Thread Dave Fugate
Hello Python Community,

We're pleased to announce the release of IronPython 2.6 Release Candidate 1 
which can be freely downloaded at 
http://ironpython.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=30315.  
Over the development span of IronPython 2.6, exactly 417 bugs have been fixed.  
Since the release of Beta 2, we've addressed the following:

* Non-hosting related APIs previously found in Microsoft.Scripting.dll 
have been migrated to Microsoft.Dynamic.dll.  The rationale behind this 
decision is that we're aiming for compatible DLR binaries with the next major 
release of IronRuby, namely 1.0.  Microsoft.Dynamic.dll will likely end up 
being a bit different between IronPython 2.6 and IronRuby 1.0, but we intend on 
keeping Microsoft.Scripting.dll and Microsoft.Scripting.Core.dll exactly the 
same.  By doing this you'll be able to utilize the DLR hosting APIs to run both 
IronPython 2.6 and IronRuby 1.0 code from the same .NET application!

* Documentation distributed with the release has been updated

* A plethora of bugs have been fixed over the past two months with 
special emphasis given to CodePlex work items with lots of votes

If no major issues with this release candidate are discovered, we hope to ship 
the final 2.6 release in a little under a month.  Anyone planning on upgrading 
to 2.6 should try out this release candidate and let us know of any issues you 
find ASAP.

Thanks to everyone in the IronPython Community who reported bugs and provided 
valuable feedback:  Zachc, yamakox, vernondcole, VAks, tscottw, 
tonyandrewmeyer, tomwright, TomasMatousek, tkamiya, timers, srivatsn, sopeajw, 
saveenr, sanxiyn, rridge, ronniemaor, quirogaco, pythonfoo, py_sunil, pm100, 
pl6306, paulfelix, orestis, olegt, oldman, NDHUMuscle, mycall, mmaly, 
mmacdonaldssfcu, maplpro, luntain, llaske, lbaker, Lawouach, laurionb, 
laughingboy, kurhan, kuno, kowenswp, klrohe, kevgu, jmesserly, jlunder, 
jdhardy, jbevain, jackeyoo, hhonisch, gz, gjones, fwereade, deadalusai, 
daveremy, darb, CurtHagenlocher, chaghi, cgravill, cartman, bobarnso, billchi, 
atifaziz, ashcor, alvanet, __Helmut__, fuzzyman, fabiofz, Eloff, egonw_, 
dungen, dsblank, dmajnemer, dinov, and dfugate.

We really do appreciate your input which helps to make every release of 
IronPython better than the last.

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

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


Solved - Python: automate input to MySQL query

2009-09-22 Thread Threader Slash
-- Forwarded message --
 From: Philip Semanchuk phi...@semanchuk.com
 To: Python-list (General) python-list@python.org
 Date: Mon, 21 Sep 2009 08:49:27 -0400
 Subject: Re: Python: automate input to MySQL query

 On Sep 21, 2009, at 5:18 AM, Threader Slash wrote:

  Hi Everybody...

 I have a query that works as follows:

 Code:

 db.query(SELECT traveler.travelerFirstName,vaccine.vaccineName from
 (traveler INNER JOIN takenvaccine ON traveler.travelerID =
 takenvaccine.travelerID)
   INNER JOIN vaccine ON takenvaccine.vaccineID=vaccine.vaccineID
   INNER JOIN requiredvaccine ON
 vaccine.vaccineID=requiredvaccine.requiredvaccineID
   INNER JOIN city ON requiredvaccine.cityID = city.cityID
 WHERE traveler.travelerFirstName = 'John')

 The output gives me all vaccines taken by a given employee. To allow the
 user to choose different names when running the system, I am trying to use
 a
 variable, named *person*:

 Code:

 person = John

 db.query(SELECT traveler.travelerFirstName,vaccine.vaccineName from
 (traveler INNER JOIN takenvaccine ON traveler.travelerID =
 takenvaccine.travelerID)
   INNER JOIN vaccine ON takenvaccine.vaccineID=vaccine.vaccineID
   INNER JOIN requiredvaccine ON
 vaccine.vaccineID=requiredvaccine.requiredvaccineID
   INNER JOIN city ON requiredvaccine.cityID = city.cityID
 WHERE traveler.travelerFirstName = 'person')

 Then I run the query inside my python program. The first version without
 variable works fine. But the second, using variable, doesn't give me any
 output. What I am missing here about the python variable sintaxe to make
 the
 MySQL work with variable ... Any suggestion?


 In your second query you've got person hardcoded as a string. You're
 looking for a traveler with the actual first name of person.

 Change this line:

 WHERE traveler.travelerFirstName = 'person')


 to this:

 WHERE traveler.travelerFirstName = %s)


 and pass person as a list of params to db.query(). Something like this
 should work:

 sql = SELECT blah blah blah WHERE traveler.travelerFirstName = %s
 db.query(sql, [person])

 See the Python DB API documentation for specifics. This might look like the
 same thing as string interpolation, but it isn't.

 Good luck
 Philip


Hi Philip,

Thanks for comments and suggestions.

Now it works! Here is the solution:

 Code:


self.db = MySQLdb.connect(hostname,username,passwd,dbname)
self.cursor=self.db.cursor();

name=John
runQuery=SELECT traveler.travelerFirstName,vaccine.vaccineName from
traveler INNER JOIN takenvaccine ON traveler.travelerID =
takenvaccine.travelerID INNER JOIN vaccine ON
takenvaccine.vaccineID=vaccine.vaccineID INNER JOIN requiredvaccine ON
vaccine.vaccineID=requiredvaccine.requiredvaccineID INNER JOIN site ON
requiredvaccine.siteID = site.siteID WHERE traveler.travelerFirstName
= %s

self.cursor.execute(runQuery,(name,))

print tell vaccines taken for a chosen traveler\n

for row in self.cursor.fetchall():
 print row


Note: you need to declare the whole query in the same line to it take effect
in the variable runQuery.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: easy question, how to double a variable

2009-09-22 Thread Processor-Dev1l
On Sep 20, 10:27 pm, daggerdvm dagger...@yahoo.com wrote:
  Write the definition of a function  twice , that receives an  int
 parameter and returns an  int that is twice the value of the
 parameter.

 how can i do this

I will stop this theatre...
as you should know, you want your function to make arithmetic
operation n*2.
Everything you have to do is to define some function with parameter n
and make this function to return n*2.
If you are not jerk, you can make the whole code you need from the
previous sentence :)))
-- 
http://mail.python.org/mailman/listinfo/python-list


[SQL] Pick random rows from SELECT?

2009-09-22 Thread Threader Slash
Here is a simple and quick solution --

Generate a random number
random.shuffle(x[, random])¶Shuffle the sequence x in place. The optional
argument random is a 0-argument function returning a random float in [0.0,
1.0); by default, this is the function random().
http://docs.python.org/library/random.html

Multiple the random value returned by the maxnumber of your table primary
key index.
http://www.tizag.com/mysqlTutorial/mysqlmax.php

Then use the result in your query as

randID = MAX(id) * random()

SELECT objectname FROM products WHERE objectID = randID

Hope this help.
Cheers... Threader


-- Forwarded message --
From: Dennis Lee Bieber wlfr...@ix.netcom.com
To: python-list@python.org
Date: Mon, 21 Sep 2009 21:40:02 -0700
Subject: Re: [SQL] Pick random rows from SELECT?
On Mon, 21 Sep 2009 10:59:38 +0200, Gilles Ganault nos...@nospam.com
declaimed the following in gmane.comp.python.general:

 Since this list is quite big and the site is the bottleneck, I'd like
 to run multiple instances of this script, and figured a solution would
 be to pick rows at random from the dataset, check in my local database
 if this item has already been taken care of, and if not, download
 details from the remote web site.

   You really think making MULTIPLE, overlapping requests to a web site
is going to be more efficient than just suffering the single transfer
time of one large query?

 If someone's done this before, should I perform the randomization in
 the SQL query (SQLite using the APSW wrapper
 http://code.google.com/p/apsw/), or in Python?

   Pardon, I thought you implied the bottleneck is the web-site
database -- I'd worry about any web-site that exposes a file-server
based database to direct user access.

 Here's some simplified code:

 sql = 'SELECT id,label FROM companies WHERE activity=1'
 rows=list(cursor.execute(sql))
 for row in rows:
   id = row[0]
   label = row[1]

   print strftime(%H:%M)
   url = http://www.acme.com/details.php?id=%s; % id
   req = urllib2.Request(url, None, headers)
   response = urllib2.urlopen(req).read()

   name = re_name.search(response)
   if name:
   name = name.group(1)
   sql = 'UPDATE companies SET name=? WHERE id=?'
   cursor.execute(sql, (name,id) )

   Ah... You mean you are retrieving the names from a local database,
and then requesting web-site details based upon that name.

   No matter how you look at it, you appear to want to process the
entire local list of companies... Multiple randomized local queries will
just add to the final run-time as you start to get duplicates -- and
have to reject that one to query for another random name.

   I'd suggest either a pool of threads -- 5-10, each reading company
names from a shared QUEUE, which is populated by the main thread
(remember to commit() so that you don't block on database updates by the
threads). OR... determine how many companies there are, and start
threads feeding them start and length (length being #names /
#threads, round up -- start then being 0*length+1, 1*length+1, etc...)
and use those in thread specific selects using ... limit length
offset start... This way each thread retrieves its own limited set of
companies (make sure to use the same sorting criteria).
--
   Wulfraed Dennis Lee Bieber   KD6MOG
   wlfr...@ix.netcom.com
HTTP://wlfraed.home.netcom.com/http://wlfraed.home.netcom.com/




-- Forwarded message --
From: greg g...@cosc.canterbury.ac.nz
To: python-list@python.org
Date: Tue, 22 Sep 2009 17:07:33 +1200
Subject: Re: Comparison of parsers in python?
Nobody wrote:

 What I want: a tokeniser generator which can take a lex-style grammar (not
 necessarily lex syntax, but a set of token specifications defined by
 REs, BNF, or whatever), generate a DFA, then run the DFA on sequences of
 bytes. It must allow the syntax to be defined at run-time.


You might find my Plex package useful:

http://www.cosc.canterbury.ac.nz/greg.ewing/python/Plex/

It was written some time ago, so it doesn't know about
the new bytes type yet, but it shouldn't be hard to
adapt it for that if you need to.

 What I don't want: anything written by someone who doesn't understand the
 field (i.e. anything which doesn't use a DFA).


Plex uses a DFA.

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


Hi, SOAP lib for Python 3.0

2009-09-22 Thread Ares
Hi,

Does anyone have a reccommendation on the best soap library for
Python 3.0? The libs I found only support python 2.6 or belove.

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


Re: using python 2.5

2009-09-22 Thread Dave Angel

kunal.k wrote:

I have installed python 2.5 for a particular code. Now i have 2.6
already installed. How do i direct this code to use the 2.5 modules??

  
I can think of two different questions you might be asking.  1) How do I 
get the add-on modules installed with 2.6 to also work in 2.5?  or 2) 
How do I get a particular script to use 2.5, while all other scripts 
should use 2.6 ?


Sean answered #1, but I think you meant to ask #2

First question is what OS you've installed these on.  In Windows, the 
python version is selected by file associations, while in Unix/Linux 
systems, it's selected by the shebang line at the beginning of the script.


A generic answer if you just have one script is to make an OS script 
(bat file, or shell script) that invokes the particular python 
interpreter, passing it the script name as an argument).


But if you want to be able to just run the script as though it were a 
compiled executable, tell us what OS you're on, and maybe the base 
locations of your two installations.


DaveA

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


Re: easy question, how to double a variable

2009-09-22 Thread Hendrik van Rooyen
On Monday, 21 September 2009 22:50:31 daggerdvm wrote:

 carl banks.you are a dork

No mister_do_my_homework, he is not.  
He is actually a respected member
of this little community.

You, however, are beginning to look like one.

Why do you not come clean - tell us what you are doing,
show us what you have tried, and maybe, just maybe, 
some kind soul will help you, instead of mocking you.

Although that is now less likely as you have started calling
people derogatory names.

And if you do not at least do what I have suggested, there is about a 
snowball's hope in hell of anybody helping you, as you come across as a 
parasite who wants other people to do his work.

Prove you are not, or go away.

- Hendrik

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


Re: where is ctrl+newline handled in pywin editor?

2009-09-22 Thread Roger Upole
C or L Smith wrote:
I use the pywin environment on Windows for python code editing and 
interactive environment.

 I've been able to find the place in the editor files where the enter key 
 is handled and where the whitespace is stripped from a line and I've been 
 able to get it to not leave any white space when a double return is 
 entered. But what I would like to be able to do is find the place where 
 ctrl+enter is handled so I could have it strip any trailing space from the 
 current line before going back to the left margin. Is anyone acquainted 
 enough with the pywin editor to be able to help with this?

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

The key bindings are in \pythonwin\pywin\default.cfg.  The
current definition is

Ctrl+Enter= ProcessEnter

(same as a normal enter).
ProcessEnterEvent in \pythonwin\pywin\framework\interact.py
checks whether the shift or ctrl keys were used.

   Roger



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


Re: passing object between classes

2009-09-22 Thread Duncan Booth
daved170 daved...@gmail.com wrote:

 Is there any existing python Log object that do so?

There is. See Jean-Michel Pichavant's reply.

 I no, I created my
 own Log object that only open file and write a line to it,

 how can I make it be global?

You could assign it to a global name.

 Should I use it as a static object?

If you wish. It depends on exactly what you want. Usually static
objects are fine for logging unless you want to be able to modify the
logging in particular situations (e.g. when running your unit tests). In 
that case you could just assign it to an attribute of your object much as 
you were failing to do in your original post: there is no reason at all why 
that shouldn't work also. 

 will it work?

There is no reason why not.

 (offcurse in the case of the threads I'll use utex)

With the built-in logging module you don't need to worry about that.

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


Re: Looking for a pure Python chart drawing module

2009-09-22 Thread Nick Craig-Wood
John Nagle na...@animats.com wrote:
  I'm looking for something that can draw simple bar and pie charts
  in Python.  I'm trying to find a Python package, not a wrapper for
  some C library, as this has to run on both Windows and Linux
  and version clashes are a problem.
 
  Here's the list from the Python wiki at
  http://wiki.python.org/moin/NumericAndScientific/Plotting;.
  Almost all the options are really wrappers for some other
  package in C/C++.
[snip]
  So, for pure Python, Pychart is it.  I'll have to try it and see if it still
  works.

I don't think anyone has mentioned reportlab...  It can plot charts I
think, though last time I used it I plotted stuff by hand as I wanted
exact control over the layout.

I'm not sure of the dependencies though so may not be suitable for
your purposes.

http://www.reportlab.org/rl_toolkit.html

-- 
Nick Craig-Wood n...@craig-wood.com -- http://www.craig-wood.com/nick
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: easy question, how to double a variable

2009-09-22 Thread Tim Chase

daggerdvm wrote:

what are you retarded?  this is not a test you moron, i can ask all
the questions i want about it.


You seem to have forgotten to CC the list.   Let me help show the 
world your mad skillz -- at replying, at programming, at 
orthography, at interpersonal communication...


Sure you can ask all the questions you want...and the newsgroup 
can give all the answers it sees fit.  In all likelihood, your 
professor wanted *you* to solve the problem, not have 
comp.lang.python solve the problem for you.  You got at least two 
answers that solve the problem, but were designed to clearly 
indicated to the professor that you didn't author them yourself.


From my experience teaching students to program, that's the sort 
of problem that 4th or 5th graders (who have been paying 
attention in class) should be able to do with no need to ask for 
help.


Given that you made *no* effort (your post had *zero* code to 
show you had even attempted the problem), you got back far more 
than you put in.


-tkc




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


Re: recommendation for webapp testing?

2009-09-22 Thread Ryan Kelly

 I need to do some basic website testing (log into account, add item to
 cart, fill out and submit forms, check out, etc.). What modules would
 be good to use for webapp testing like this?
 
 Windmill is an option, but I haven't tried it myself

I'll second Windmill as an option, have had good experiences with it.
The current version is a little on the slow side, but I believe there's
a big new release just around the corner that contains significant
performance improvements.

   Ryan

-- 
Ryan Kelly
http://www.rfk.id.au  |  This message is digitally signed. Please visit
r...@rfk.id.au|  http://www.rfk.id.au/ramblings/gpg/ for details



signature.asc
Description: This is a digitally signed message part
-- 
http://mail.python.org/mailman/listinfo/python-list


difficulty in understanding rsplit(None,1)[1]

2009-09-22 Thread hrishy
Hi

What does rsplit(None,1)[1] accomplish.

Can somebody please decompose that to me.

regards



  

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


Re: easy question, how to double a variable

2009-09-22 Thread daggerdvm
you brain needs error checking!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: easy question, how to double a variable

2009-09-22 Thread Andreas Waldenburger
On Mon, 21 Sep 2009 13:46:31 -0700 (PDT) daggerdvm
dagger...@yahoo.com wrote:

 u don't want to answerthen why post?...get lost.

You're not doing yourself a favor with this attitude, much less
displaying it. You asked a question that you could have solved with 1
hour's worth of reading at most (much less if you're actually attending
some sort of class for this).

I'm not saying you deserve to be mocked, but it is a fact of life that
you get these responses when it is apparent that you put almost no
effort into this problem.

Here's a tip: post to the group your code that you came up with
yourself and explain what gives you trouble. I assure you, the
responses will be more helpful that way.

/W

-- 
INVALID? DE!

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


problem in encryption

2009-09-22 Thread jayshree
hello ,
The community members,

Using following code  :

fileHandle = open ('jay1key.py','wb')
#fileHandle = open ('jay1key.pem',rb).read()
print fileHandle.write (data) #data variable is contains the key
fileHandle.close()


otp = 'jyshri69'


pub_key = M2Crypto.RSA.load_pub_key('jay1key.py')

encrypted = pub_key.public_encrypt(otp, M2Crypto.RSA.pkcs1_padding)
print encrypted text is =   
print ---
print encrypted

the above code gives me following error :
None
Traceback (most recent call last):
  File RetEnc.py, line 71, in ?
pub_key = M2Crypto.RSA.load_pub_key('jay1key.py')
  File /usr/lib/python2.4/site-packages/M2Crypto/RSA.py, line 344,
in load_pub_key
return load_pub_key_bio(bio)
  File /usr/lib/python2.4/site-packages/M2Crypto/RSA.py, line 360,
in load_pub_key_bio
rsa_error()
  File /usr/lib/python2.4/site-packages/M2Crypto/RSA.py, line 240,
in rsa_error
raise RSAError, m2.err_reason_error_string(m2.err_get_error())
M2Crypto.RSA.RSAError: no start line


not getting how to resolve it ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: problem in encryption

2009-09-22 Thread jayshree
On Sep 22, 1:44 pm, jayshree jayshree06c...@gmail.com wrote:
 hello ,
 The community members,

 Using following code  :

 fileHandle = open ('jay1key.py','wb')
 #fileHandle = open ('jay1key.pem',rb).read()
 print fileHandle.write (data) #data variable is contains the key
 fileHandle.close()

 otp = 'jyshri69'

 pub_key = M2Crypto.RSA.load_pub_key('jay1key.py')

 encrypted = pub_key.public_encrypt(otp, M2Crypto.RSA.pkcs1_padding)
 print encrypted text is =   
 print ---
 print encrypted

 the above code gives me following error :
 None
 Traceback (most recent call last):
   File RetEnc.py, line 71, in ?
     pub_key = M2Crypto.RSA.load_pub_key('jay1key.py')
   File /usr/lib/python2.4/site-packages/M2Crypto/RSA.py, line 344,
 in load_pub_key
     return load_pub_key_bio(bio)
   File /usr/lib/python2.4/site-packages/M2Crypto/RSA.py, line 360,
 in load_pub_key_bio
     rsa_error()
   File /usr/lib/python2.4/site-packages/M2Crypto/RSA.py, line 240,
 in rsa_error
     raise RSAError, m2.err_reason_error_string(m2.err_get_error())
 M2Crypto.RSA.RSAError: no start line

 not getting how to resolve it ?

the key looks like this :
-BEGIN RSA PUBLIC KEY-
mQGiBEpz7VIRBADAt9YpYfYHJeGA6d
+G261FHW1uA0YXltCWa7TL6JnIsuxvh9vImUoyMJd6
1xEW4TuROTxGcMMiDemQq6HfV9tLi7ptVBLf/8nUEFoGhxS
+DPJsy46WmlscKHRIEdIkTYhp
uAIMim0q5HWymEqqAfBLwJTOY9sR+nelh0NKepcCqwCgvenJ2R5UgmAh
+sOhIBrh3OahZEED
/2sRGHi4xRWKePFpttXfb2hry2/jURPae/wYfuI6Xw3k5EO593veGS7Zyjnt+7mVY1N5V/
ey
rfXaS3R6GsByG/eRVzRJGU2DSQvmF+q2NC6v2s4KSzr5CVKpn586SGUSg/
aKvXY3EIrpvAGP
rHum1wt6P9m9kr/4X8SdVhj7Jti6A/0TA8C2KYhOn/
hSYAMTmhisHan3g2Cm6yNzKeTiq6/0
ooG/
ffcY81zC6+Kw236VGy2bLrMLkboXPuecvaRfz14gJA9SGyInIGQcd78BrX8KZDUpF1Ek
KxQqL97YRMQevYV89uQADKT1rDBJPNZ+o9f59WT04tClphk/
quvMMuSVILQaamF5c2ggPGph
eXNocmVlQGdtYWlsLmNvbT6IZgQTEQIAJgUCSnPtUgIbAwUJAAFRgAYLCQgHAwIEFQIIAwQW
AgMBAh4BAheAAAoJEFjpOQ2vjFvzS0wAn3vf1A8npIY/DMIFFw0/
eGf0FNekAKCBJnub9GVu
9OUY0nISQf7uZZVyI7kBDQRKc+1SEAQAm7Pink6S5+kfHeUoJVldb
+VAlHdf7BdvKjVeiKAb
dFUa6vR9az+wn8V5asNy/
npEAYnHG2nVFpR8DTlN0eO35p78qXkuWkkpNocLIB3bFwkOCbff
P3yaCZp27Vq+9182bAR2Ah10T1KShjWTS/
wfRpSVECYUGUMSh4bJTnbDA2MAAwUEAIcRhF9N
OxAsOezkiZBm+tG4BgT0+uWchY7fItJdEqrdrROuCFqWkJLY2uTbhtZ5RMceFAW3s
+IYDHLL
PwM1O+ZojhvAkGwLyC4F
+6RCE62mscvDJQsdwS4L25CaG2Aw97HhY7+bG00TWqGLb9JibKie
X1Lk+W8Sde/4UK3Q8tpbiE8EGBECAA8FAkpz7VICGwwFCQABUYAACgkQWOk5Da+MW/
MAAgCg
tfUKLOsrFjmyFu7biv7ZwVfejaMAn1QXEJw6hpvte60WZrL0CpS60A6Q
-END RSA PUBLIC KEY-
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: difficulty in understanding rsplit(None,1)[1]

2009-09-22 Thread Martin P. Hellwig

hrishy wrote:

Hi

What does rsplit(None,1)[1] accomplish.

Can somebody please decompose that to me.

regards


Sure:

 test = 'This is a test'
 help(test.rsplit)
Help on built-in function rsplit:

rsplit(...)
S.rsplit([sep [,maxsplit]]) - list of strings

Return a list of the words in the string S, using sep as the
delimiter string, starting at the end of the string and working
to the front.  If maxsplit is given, at most maxsplit splits are
done. If sep is not specified or is None, any whitespace string
is a separator.

 step_two = test.rsplit(None, 1)
 step_two
['This is a', 'test']

 step_two[1]
'test'


--
MPH
http://blog.dcuktec.com
'If consumed, best digested with added seasoning to own preference.'
--
http://mail.python.org/mailman/listinfo/python-list


Re: easy question, how to double a variable

2009-09-22 Thread Donn
On Monday 21 September 2009 22:49:50 daggerdvm wrote:
 you brain needs error checking!
try:
 return response()
except Troll,e:
 raise dontFeed(anymore=True)

\d
-- 
home: http://otherwise.relics.co.za/
2D vector animation : https://savannah.nongnu.org/projects/things/
Font manager : https://savannah.nongnu.org/projects/fontypython/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: difficulty in understanding rsplit(None,1)[1]

2009-09-22 Thread hrishy
Hi Martin

Many thanks 
And by the way great way to explain that thing

--- On Tue, 22/9/09, Martin P. Hellwig martin.hell...@dcuktec.org wrote:

 From: Martin P. Hellwig martin.hell...@dcuktec.org
 Subject: Re: difficulty in understanding rsplit(None,1)[1]
 To: python-list@python.org
 Date: Tuesday, 22 September, 2009, 9:52 AM
 hrishy wrote:
  Hi
  
  What does rsplit(None,1)[1] accomplish.
  
  Can somebody please decompose that to me.
  
  regards
  
 Sure:
 
  test = 'This is a test'
  help(test.rsplit)
 Help on built-in function rsplit:
 
 rsplit(...)
     S.rsplit([sep [,maxsplit]]) - list of
 strings
 
     Return a list of the words in the string S,
 using sep as the
     delimiter string, starting at the end of the
 string and working
     to the front.  If maxsplit is given, at
 most maxsplit splits are
     done. If sep is not specified or is None, any
 whitespace string
     is a separator.
 
  step_two = test.rsplit(None, 1)
  step_two
 ['This is a', 'test']
 
  step_two[1]
 'test'
 
 
 -- MPH
 http://blog.dcuktec.com
 'If consumed, best digested with added seasoning to own
 preference.'
 -- http://mail.python.org/mailman/listinfo/python-list
 


  

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


Re: entry widget won't validate

2009-09-22 Thread Peter Otten
Mike wrote:

 On Sep 21, 12:47 pm, Peter Otten __pete...@web.de wrote:
 Mike wrote:
  I'm trying to arrange for an Entry widget to check whether its data
  is all digits and whether the number represented is small enough.
  The validate function seem to be called once at startup and not
  afterwards:
 
 
  The print statement run 3 times at startup.
  Editing an Entry does not cause any printing.
  Any ideas?

 Quotinghttp://www.tcl.tk/man/tcl8.5/TkCmd/entry.htm#M12:

 
 In general, the textVariable and validateCommand can be dangerous to mix.
 Any problems have been overcome so that using the validateCommand will
 not interfere with the traditional behavior of the entry widget. Using
 the textVariable for read-only purposes will never cause problems. The
 danger comes when you try set the textVariable to something that the
 validateCommand would not accept, which causes validate to become none
 (the invalidCommand will not be triggered). The same happens when an
 error occurs evaluating the validateCommand.
 

 You can verify that this is indeed your problem by changing the
 Levels.vc() method to always return True for the moment.
 
 Returning True does seems to cause vc to be called more often.
 I'm still not getting the data I want though.
 The variable always gives me the pre-change string.
 I gather I need to do something with %P.
 google gave me hints that I should use something called register,
 but I'm not at all clear on what I should do with them.
 I don't know how to translate from Tcl to python.

I don't know Tcl either; the following is the first thing that seemed to 
work, after some trial and error:

import Tkinter as tk

def validate(before, after):
print before, --, after
return after.isdigit()

if __name__ == __main__:
root = tk.Tk()
name = root.register(validate)
cmd = 'expr {[%(name)s %(parms)s]}' % dict(name=name, parms=%s %P)
var = tk.StringVar()
entry = tk.Entry(root, textvariable=var,
 validate=all, validatecommand=cmd)
entry.pack()
entry.focus_set()
root.mainloop()

Peter

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


Combining sets/dictionaries

2009-09-22 Thread Alfons Nonell-Canals
Hello,
I have different sets/dictionaries/lists (whatever you want because I
can convert them easily) and I would like to combine them. I don't want
a consensus and something like it. I'd need to combine all elements of
the first one with the all elements of the second one and third,... the
numbers of dictionaries/sets/lists is variable as the number of elements
for each one.

For example, i have the following sets and I would like to obtain all
possible combinations...

['I', 'O', 'N', 'P', 'S', 'C']
['I', 'O', 'N', 'P', 'S', 'C']
['I', 'O', 'N', 'P', 'S', 'C']
['I', 'N', 'P', 'S', 'C']
['I', 'N', 'P', 'S', 'C']
['F', 'I', 'L', 'O', 'N', 'P', 'S', 'R', 'C']
['I', 'O', 'N', 'P', 'S', 'C']
['I', 'O', 'N', 'P', 'S', 'C']
['F', 'I', 'L', 'O', 'N', 'P', 'S', 'R', 'C']

And it should be flexible because as I've said, the number of
dictionaries/lists/sets is not always the same, as the number of elements.

I don't like to ask this kid of questions but... today I'm totally lost
and I need it to close one part of a nice project...

Thanks in advance!

Best regards,
Alfons.





-- 

Alfons Nonell-Canals, PhD
Chemogenomics Lab
Research Group on Biomedical Informatics (GRIB) - IMIM/UPF
Barcelona Biomedical Research Park (PRBB)
C/ Doctor Aiguader, 88 - 08003 Barcelona 
alfons.non...@upf.edu - http://cgl.imim.es
Tel. +34933160528
 
http://alfons.elmeuportal.cat
http://www.selenocisteina.info

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


Re: Combining sets/dictionaries

2009-09-22 Thread Peter Otten
Alfons Nonell-Canals wrote:

 I have different sets/dictionaries/lists (whatever you want because I
 can convert them easily) and I would like to combine them. I don't want
 a consensus and something like it. I'd need to combine all elements of
 the first one with the all elements of the second one and third,... the
 numbers of dictionaries/sets/lists is variable as the number of elements
 for each one.
 
 For example, i have the following sets and I would like to obtain all
 possible combinations...
 
 ['I', 'O', 'N', 'P', 'S', 'C']
 ['I', 'O', 'N', 'P', 'S', 'C']
 ['I', 'O', 'N', 'P', 'S', 'C']
 ['I', 'N', 'P', 'S', 'C']
 ['I', 'N', 'P', 'S', 'C']
 ['F', 'I', 'L', 'O', 'N', 'P', 'S', 'R', 'C']
 ['I', 'O', 'N', 'P', 'S', 'C']
 ['I', 'O', 'N', 'P', 'S', 'C']
 ['F', 'I', 'L', 'O', 'N', 'P', 'S', 'R', 'C']
 
 And it should be flexible because as I've said, the number of
 dictionaries/lists/sets is not always the same, as the number of elements.
 
 I don't like to ask this kid of questions but... today I'm totally lost
 and I need it to close one part of a nice project...

Using one common definition of combinations:

 from pprint import pprint
 pprint(items)
[['I', 'O', 'N', 'P', 'S', 'C'],
 ['I', 'O', 'N', 'P', 'S', 'C'],
 ['I', 'O', 'N', 'P', 'S', 'C'],
 ['I', 'N', 'P', 'S', 'C'],
 ['I', 'N', 'P', 'S', 'C'],
 ['F', 'I', 'L', 'O', 'N', 'P', 'S', 'R', 'C'],
 ['I', 'O', 'N', 'P', 'S', 'C'],
 ['I', 'O', 'N', 'P', 'S', 'C'],
 ['F', 'I', 'L', 'O', 'N', 'P', 'S', 'R', 'C']]
 import itertools
 for c in itertools.combinations(items, 2):
... print c
...
(['I', 'O', 'N', 'P', 'S', 'C'], ['I', 'O', 'N', 'P', 'S', 'C'])
(['I', 'O', 'N', 'P', 'S', 'C'], ['I', 'O', 'N', 'P', 'S', 'C'])
(['I', 'O', 'N', 'P', 'S', 'C'], ['I', 'N', 'P', 'S', 'C'])
(['I', 'O', 'N', 'P', 'S', 'C'], ['I', 'N', 'P', 'S', 'C'])
snip

If you mean something else (likely) please give a more detailed description 
or provide some examples with both input and desired output.

Peter

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


Re: easy question, how to double a variable

2009-09-22 Thread koranthala
On Sep 21, 1:27 am, daggerdvm dagger...@yahoo.com wrote:
  Write the definition of a function  twice , that receives an  int
 parameter and returns an  int that is twice the value of the
 parameter.

 how can i do this

Please note that most mails here are humorous - as should be expected
for a language named after Monty Python.
So, please do not get angry and do take it the way it was intended.

The main problem that everybody sees is that the code you asked is
extremely simple. This causes others to think that you have not
invested any time in getting a solution yourself. Most of us here are
30 years old, and we know from experience that if one does not invest
time and energy in solving issues when we are young, it eventually
leads us to a very unrewarding and unhappy life in the end.

So, even though it looks to you that people are mocking you, it is not
exactly the case. If you do try to get a solution and is unable to do
so, then I am 100% sure that many many people would have provided you
the answer or the way to do so.

Also, since you are young (presumably), it would be good to understand
that if you get it into a flamewar (email or in life), it tends to end
bad for you in the end. Esp, MRAB, Carl Banks, Steven D'Aprano, Tim
Chase etc , whom you flamed, are amongst the most respected people in
this group.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tkinter - Text - bullets

2009-09-22 Thread eb303
On Sep 22, 7:45 am, Thomas Lehmann iris-und-thomas-lehm...@t-
Online.de wrote:
  This is probably why you had all these alignment problems. But it's
  weird, because the script I posted is copied and pasted from a really
  script that I've run, and which doesn't cause any error. What is the
  version of tcl/tk used by your Tkinter module? And what is your Python
  version?

 Using python 2.5 (with Tcl/Tk 8.4):

 Traceback (most recent call last):
   File Text1.py, line 10, in module
 txt.tag_configure('bulleted_list', font=('Times', 18),
 lmargin1='10m', lmargin2='15m', tabs=['15m'])
   File E:\Python25\lib\lib-tk\Tkinter.py, line 3066, in
 tag_configure
 return self._configure(('tag', 'configure', tagName), cnf, kw)
   File E:\Python25\lib\lib-tk\Tkinter.py, line 1188, in _configure
 self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
 _tkinter.TclError: bad screen distance ['15m']

Try tabs='15m' instead. Seems the list is not handled properly.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: socket send O(N**2) complexity

2009-09-22 Thread Antoine Pitrou
exarkun at twistedmatrix.com writes:
 
 To the OP, you can get view-like behavior with the buffer builtin. 

And, on Python 3 (or even the 2.7 in development), you can use the memoryview
builtin for similar effect.

Regards

Antoine.


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


Re: Combining sets/dictionaries

2009-09-22 Thread Adrien
Hi,

Did you try the list.update() builtin function ?

Regards

Peter Otten a écrit :
 Alfons Nonell-Canals wrote:
 
 I have different sets/dictionaries/lists (whatever you want because I
 can convert them easily) and I would like to combine them. I don't want
 a consensus and something like it. I'd need to combine all elements of
 the first one with the all elements of the second one and third,... the
 numbers of dictionaries/sets/lists is variable as the number of elements
 for each one.

 For example, i have the following sets and I would like to obtain all
 possible combinations...

 ['I', 'O', 'N', 'P', 'S', 'C']
 ['I', 'O', 'N', 'P', 'S', 'C']
 ['I', 'O', 'N', 'P', 'S', 'C']
 ['I', 'N', 'P', 'S', 'C']
 ['I', 'N', 'P', 'S', 'C']
 ['F', 'I', 'L', 'O', 'N', 'P', 'S', 'R', 'C']
 ['I', 'O', 'N', 'P', 'S', 'C']
 ['I', 'O', 'N', 'P', 'S', 'C']
 ['F', 'I', 'L', 'O', 'N', 'P', 'S', 'R', 'C']

 And it should be flexible because as I've said, the number of
 dictionaries/lists/sets is not always the same, as the number of elements.

 I don't like to ask this kid of questions but... today I'm totally lost
 and I need it to close one part of a nice project...
 
 Using one common definition of combinations:
 
 from pprint import pprint
 pprint(items)
 [['I', 'O', 'N', 'P', 'S', 'C'],
  ['I', 'O', 'N', 'P', 'S', 'C'],
  ['I', 'O', 'N', 'P', 'S', 'C'],
  ['I', 'N', 'P', 'S', 'C'],
  ['I', 'N', 'P', 'S', 'C'],
  ['F', 'I', 'L', 'O', 'N', 'P', 'S', 'R', 'C'],
  ['I', 'O', 'N', 'P', 'S', 'C'],
  ['I', 'O', 'N', 'P', 'S', 'C'],
  ['F', 'I', 'L', 'O', 'N', 'P', 'S', 'R', 'C']]
 import itertools
 for c in itertools.combinations(items, 2):
 ... print c
 ...
 (['I', 'O', 'N', 'P', 'S', 'C'], ['I', 'O', 'N', 'P', 'S', 'C'])
 (['I', 'O', 'N', 'P', 'S', 'C'], ['I', 'O', 'N', 'P', 'S', 'C'])
 (['I', 'O', 'N', 'P', 'S', 'C'], ['I', 'N', 'P', 'S', 'C'])
 (['I', 'O', 'N', 'P', 'S', 'C'], ['I', 'N', 'P', 'S', 'C'])
 snip
 
 If you mean something else (likely) please give a more detailed description 
 or provide some examples with both input and desired output.
 
 Peter
 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: easy question, how to double a variable

2009-09-22 Thread Mel
Tim Roberts wrote:

 daggerdvm dagger...@yahoo.com wrote:

carl banks.you are a dork
 
 What are you, eleven years old?
 
 Look, you asked us to answer for you what is CLEARLY a homework question.
 It is unethical for you to ask that, and it is unethical for us to answer
 it.

Forget ethical.  We can do his homework for him, we can perhaps pass exams 
for him, maybe graduate for him, and then with our luck, he'll get a job in 
our office and we get to do his work for him.

Mel.


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


Re: Combining sets/dictionaries

2009-09-22 Thread Mel
Alfons Nonell-Canals wrote:

 Hello,
 I have different sets/dictionaries/lists (whatever you want because I
 can convert them easily) and I would like to combine them. I don't want
 a consensus and something like it. I'd need to combine all elements of
 the first one with the all elements of the second one and third,... the
 numbers of dictionaries/sets/lists is variable as the number of elements
 for each one.
 
 For example, i have the following sets and I would like to obtain all
 possible combinations...
 
 ['I', 'O', 'N', 'P', 'S', 'C']
 ['I', 'O', 'N', 'P', 'S', 'C']
 ['I', 'O', 'N', 'P', 'S', 'C']
 ['I', 'N', 'P', 'S', 'C']
 ['I', 'N', 'P', 'S', 'C']
 ['F', 'I', 'L', 'O', 'N', 'P', 'S', 'R', 'C']
 ['I', 'O', 'N', 'P', 'S', 'C']
 ['I', 'O', 'N', 'P', 'S', 'C']
 ['F', 'I', 'L', 'O', 'N', 'P', 'S', 'R', 'C']
 
 And it should be flexible because as I've said, the number of
 dictionaries/lists/sets is not always the same, as the number of elements.
 
 I don't like to ask this kid of questions but... today I'm totally lost
 and I need it to close one part of a nice project...

Maybe a recursive function or generator:

Each item from the first list appended to each of the possible combinations 
from the second through nth lists.

Mel.



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


Re: Not this one the other one, from a dictionary

2009-09-22 Thread Sion Arrowsmith
Vlastimil Brom  vlastimil.b...@gmail.com wrote:
 other_key = (set(data_dict.iterkeys()) - set([not_wanted_key,])).pop()

other_key = set(data_dict.iterkeys()).difference([not_wanted]).pop()
saves you the construction of an unnecessary set instance. At the
cost of a bit more verbosity, you can get rid of a second set:

key_set = set(data_dict.iterkeys())
key_set.difference_update([not_wanted_key])
other_key = key_set.pop()

although the loss of clarity compared to the one liner can't be
worth the miniscule benefit in this case.

-- 
\S

   under construction

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


Re: easy question, how to double a variable

2009-09-22 Thread Ben Finney
Mel mwil...@the-wire.com writes:

 Tim Roberts wrote:
  Look, you asked us to answer for you what is CLEARLY a homework
  question. It is unethical for you to ask that, and it is unethical
  for us to answer it.

 Forget ethical. We can do his homework for him, we can perhaps pass
 exams for him, maybe graduate for him, and then with our luck, he'll
 get a job in our office and we get to do his work for him.

+1 QOTW

-- 
 \   “Special today: no ice cream.” —mountain inn, Switzerland |
  `\   |
_o__)  |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: problem in encryption

2009-09-22 Thread Piet van Oostrum
 jayshree jayshree06c...@gmail.com (j) wrote:

j hello ,
j The community members,

j Using following code  :

j fileHandle = open ('jay1key.py','wb')
j #fileHandle = open ('jay1key.pem',rb).read()
j print fileHandle.write (data) #data variable is contains the key
j fileHandle.close()


j otp = 'jyshri69'


j pub_key = M2Crypto.RSA.load_pub_key('jay1key.py')

[Why do you give your key file a .py extension? .pem would be better.]

Your key in the next posting (when the broken lines are reconstructed)
seems to be in PKCS1 format. That's what -BEGIN RSA PUBLIC KEY-
indicates. However,  M2Crypto.RSA.load_pub_key expects the key in X.509
format, which starts with -BEGIN PUBLIC KEY- and also has a
different format inside, so just changing the header and trailer won't
work. 

Anyway, I doubt that the key is correct as it seems to large for just a
public key. How was that key generated?
-- 
Piet van Oostrum p...@cs.uu.nl
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: p...@vanoostrum.org
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Substitute for KConfig in Qt4

2009-09-22 Thread David Boddie
On Sat Sep 19 12:18:40 CEST 2009, nusch wrote:
 On Sep 19, 3:53 am, David Boddie da... at boddie.org.uk wrote:
  On Thursday 17 September 2009 13:04, nusch wrote:
   I want to remove pyKDE dependencies from my app to make it pure PyQt.
   What will be the best substitute for KConfig?
 
  What exactly do you use KConfig for in your application?
 
  David

 e.g storing dock window positions, fields choosen in QComboBox etc.
 But I Dont want to use normal config files for it

Then you would use QSettings. Although that may use configuration files
behind the scenes, they should at least be stored in a standard place.

http://www.riverbankcomputing.com/static/Docs/PyQt4/html/qsettings.html

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


Re: Combining sets/dictionaries

2009-09-22 Thread Carl Banks
On Sep 22, 3:08 am, Alfons Nonell-Canals alfons.non...@upf.edu
wrote:
 Hello,
 I have different sets/dictionaries/lists (whatever you want because I
 can convert them easily) and I would like to combine them. I don't want
 a consensus and something like it. I'd need to combine all elements of
 the first one with the all elements of the second one and third,... the
 numbers of dictionaries/sets/lists is variable as the number of elements
 for each one.

 For example, i have the following sets and I would like to obtain all
 possible combinations...

 ['I', 'O', 'N', 'P', 'S', 'C']
 ['I', 'O', 'N', 'P', 'S', 'C']
 ['I', 'O', 'N', 'P', 'S', 'C']
 ['I', 'N', 'P', 'S', 'C']
 ['I', 'N', 'P', 'S', 'C']
 ['F', 'I', 'L', 'O', 'N', 'P', 'S', 'R', 'C']
 ['I', 'O', 'N', 'P', 'S', 'C']
 ['I', 'O', 'N', 'P', 'S', 'C']
 ['F', 'I', 'L', 'O', 'N', 'P', 'S', 'R', 'C']

This is the input.  What do you want the output to look like given
this input?

I can't really tell exactly what you mean by all combinations, there
are different ways to combine sequences, and it doesn't sound like you
mean the formal mathematical definition of combination.

My best guess is that you want something like this.

def all_union(seqs):
s = set()
for seq in seqs:
s.update(seq)
return s


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


Re: easy question, how to double a variable

2009-09-22 Thread Mahmoud Abdelkader
http://codingforums.com/showthread.php?s=e26b8b0aabc69745ef24a855b1a0fc83t=177529

It seems that this dude really is looking for how to double a variable...


hi looking for help catching up in a class and overall to get me better than
i am now. I can pay you by the week or per hour.

everything can be done by email i will ask you questions and send you simple
questions like:

how to double a variables value i.e: def double(x):
return (x * 2)

ect. you can post here or send me an email at ***...@aol.com


On Tue, Sep 22, 2009 at 9:01 AM, Mel mwil...@the-wire.com wrote:

 Tim Roberts wrote:

  daggerdvm dagger...@yahoo.com wrote:
 
 carl banks.you are a dork
 
  What are you, eleven years old?
 
  Look, you asked us to answer for you what is CLEARLY a homework question.
  It is unethical for you to ask that, and it is unethical for us to answer
  it.

 Forget ethical.  We can do his homework for him, we can perhaps pass exams
 for him, maybe graduate for him, and then with our luck, he'll get a job in
 our office and we get to do his work for him.

Mel.


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

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


Re: easy question, how to double a variable

2009-09-22 Thread Grant Edwards
On 2009-09-22, Mel mwil...@the-wire.com wrote:
 Tim Roberts wrote:

 daggerdvm dagger...@yahoo.com wrote:

carl banks.you are a dork
 
 What are you, eleven years old?
 
 Look, you asked us to answer for you what is CLEARLY a homework question.
 It is unethical for you to ask that, and it is unethical for us to answer
 it.

 Forget ethical.  We can do his homework for him, we can perhaps pass exams 
 for him, maybe graduate for him, and then with our luck, he'll get a job in 
 our office and we get to do his work for him.

No, no, no.  The plan is to do his homework for him so that
he's incompetent when he graduates and won't be competition for
the rest of us who did do our homework.

-- 
Grant Edwards   grante Yow! ... the HIGHWAY is
  at   made out of LIME JELLO and
   visi.commy HONDA is a barbequeued
   OYSTER!  Yum!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Combining sets/dictionaries

2009-09-22 Thread Alfons Nonell-Canals
Hello,
finally I've solved it using a combinatorics library which allows to
do this kind of things.

Here, here is an example:

   
http://automatthias.wordpress.com/2007/04/28/cartesian-product-of-multiple-sets/


Thanks for your suggestions.


Regards,
Alfons.

Carl Banks wrote:
 On Sep 22, 3:08 am, Alfons Nonell-Canals alfons.non...@upf.edu
 wrote:
   
 Hello,
 I have different sets/dictionaries/lists (whatever you want because I
 can convert them easily) and I would like to combine them. I don't want
 a consensus and something like it. I'd need to combine all elements of
 the first one with the all elements of the second one and third,... the
 numbers of dictionaries/sets/lists is variable as the number of elements
 for each one.

 For example, i have the following sets and I would like to obtain all
 possible combinations...

 ['I', 'O', 'N', 'P', 'S', 'C']
 ['I', 'O', 'N', 'P', 'S', 'C']
 ['I', 'O', 'N', 'P', 'S', 'C']
 ['I', 'N', 'P', 'S', 'C']
 ['I', 'N', 'P', 'S', 'C']
 ['F', 'I', 'L', 'O', 'N', 'P', 'S', 'R', 'C']
 ['I', 'O', 'N', 'P', 'S', 'C']
 ['I', 'O', 'N', 'P', 'S', 'C']
 ['F', 'I', 'L', 'O', 'N', 'P', 'S', 'R', 'C']
 

 This is the input.  What do you want the output to look like given
 this input?

 I can't really tell exactly what you mean by all combinations, there
 are different ways to combine sequences, and it doesn't sound like you
 mean the formal mathematical definition of combination.

 My best guess is that you want something like this.

 def all_union(seqs):
 s = set()
 for seq in seqs:
 s.update(seq)
 return s


 Carl Banks
   

-- 

Alfons Nonell-Canals, PhD
Chemogenomics Lab
Research Group on Biomedical Informatics (GRIB) - IMIM/UPF
Barcelona Biomedical Research Park (PRBB)
C/ Doctor Aiguader, 88 - 08003 Barcelona 
alfons.non...@upf.edu - http://cgl.imim.es
Tel. +34933160528
 
http://alfons.elmeuportal.cat
http://www.selenocisteina.info

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


Re: Finding application data after install - a solution?

2009-09-22 Thread Aahz
In article mailman.232.1253597842.2807.python-l...@python.org,
Wolodja Wentland  wentl...@cl.uni-heidelberg.de wrote:

I want to:

1. Give administrators the freedom to install the data wherever they
   want
2. Adhere to the FHS (installing data within modules breaks it)
3. Be able to find that data again regardless of the installation
  scheme used

1 and 2 are easily solved... It was just not possible to find the data
again. The snippet in the original code solves that.

Given your mention of FHS, it sounds like you are focused on Unix-like
systems, in which case why not rely on the standard mechanisms for config
files?
-- 
Aahz (a...@pythoncraft.com)   * http://www.pythoncraft.com/

I won't accept a model of the universe in which free will, omniscient
gods, and atheism are simultaneously true.  --M
-- 
http://mail.python.org/mailman/listinfo/python-list


Dynamic Form

2009-09-22 Thread Victor Subervi
Hi;
I have a dynamic form in which I do the following:
1) Request two fields (company name, number of entries). That is sent back
to the form.
2) If the two fields are not None, the form requests other data. That, too,
is sent back to the form.
3) That new data is then entered into a MySQL table.
The problem is, that when I go back to refresh the form, the data is
re-entered into the table! How do I prevent that?
TIA,
Victor
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OK to memoize re objects?

2009-09-22 Thread Hyuga
On Sep 21, 11:02 am, Nobody nob...@nowhere.com wrote:
 On Mon, 21 Sep 2009 07:11:36 -0700, Ethan Furman wrote:
  Looking in the code for re in 2.5:
  _MAXCACHE = 100
  On the other hand, I (a
  re novice, to be sure) have only used between two to five in any one
  program... it'll be a while before I hit _MAXCACHE!

 Do you know how many REs import-ed modules are using? The cache isn't
 reserved for __main__.

Based on this, I'd say that the best policy would be that if you only
have a handful of simple REs that are used only on occasion, it's
probably not worth using re.compile--even if they fall out of cache,
it shouldn't take a noticeable amount of time to recompile them.

If, however, these are either complex REs, or REs that are being used
very frequently, say in a loop, might as well save the compiled RE
somewhere just to be sure it doesn't have to be recompiled at any
point.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: easy question, how to double a variable

2009-09-22 Thread Hyuga
On Sep 22, 9:57 am, Grant Edwards inva...@invalid.invalid wrote:
 On 2009-09-22, Mel mwil...@the-wire.com wrote:

  Tim Roberts wrote:

  daggerdvm dagger...@yahoo.com wrote:

 carl banks.you are a dork

  What are you, eleven years old?

  Look, you asked us to answer for you what is CLEARLY a homework question.
  It is unethical for you to ask that, and it is unethical for us to answer
  it.

  Forget ethical.  We can do his homework for him, we can perhaps pass exams
  for him, maybe graduate for him, and then with our luck, he'll get a job in
  our office and we get to do his work for him.

 No, no, no.  The plan is to do his homework for him so that
 he's incompetent when he graduates and won't be competition for
 the rest of us who did do our homework.

Well, while they may not be as much competition come promotion time, I
think Mr. Finney had it right that these people *do* still somehow get
hired, and then the rest of us end up having to do enough work for
multiple people.  Sometimes spending more time redoing other peoples'
shoddy work than it would have taken to do ourselves in the first
place.  Annoying for the programmer, but really bad for business.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Dynamic Form

2009-09-22 Thread Simon Forman
On Tue, Sep 22, 2009 at 10:46 AM, Victor Subervi
victorsube...@gmail.com wrote:
 Hi;
 I have a dynamic form in which I do the following:
 1) Request two fields (company name, number of entries). That is sent back
 to the form.
 2) If the two fields are not None, the form requests other data. That, too,
 is sent back to the form.
 3) That new data is then entered into a MySQL table.
 The problem is, that when I go back to refresh the form, the data is
 re-entered into the table! How do I prevent that?
 TIA,
 Victor


First, this seems like it's not a python question, rather it's seems
to be about some web stuff.

Second, there's not enough information to tell you anything useful.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Dynamic Form--Potential purge cache?

2009-09-22 Thread bouncy...@gmail.com
Personally that sounds like the data needs to be deliberately oveerittren in 
the form. That or the cache has to be cleared by a remote instruction. 
Unfortunately I know how to do neither :[

--Original Message--
From: Simon Forman sajmik...@gmail.com
To: python-list@python.org
Date: Tue, 22 Sep 2009 11:34:25 AM -0400
Subject: Re: Dynamic Form

On Tue, Sep 22, 2009 at 10:46 AM, Victor Subervi
victorsube...@gmail.com wrote:
 Hi;
 I have a dynamic form in which I do the following:
 1) Request two fields (company name, number of entries). That is sent back
 to the form.
 2) If the two fields are not None, the form requests other data. That, too,
 is sent back to the form.
 3) That new data is then entered into a MySQL table.
 The problem is, that when I go back to refresh the form, the data is
 re-entered into the table! How do I prevent that?
 TIA,
 Victor


First, this seems like it's not a python question, rather it's seems
to be about some web stuff.

Second, there's not enough information to tell you anything useful.
-- 
http://mail.python.org/mailman/listinfo/python-list

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


Module inspection by name

2009-09-22 Thread Nadav Chernin
Hi all, a have easy question for python developers.

 

Assume I have list of all objects:

 

obj=dir()

 

Now I want to know which object from obj list is module.

 

I searched some method in module inspection, but there is not any method
that get 'string' as parameters

 

Any reply will be greatfull  

 

Nadav

 

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


Re: Module inspection by name

2009-09-22 Thread Jean-Michel Pichavant

Nadav Chernin wrote:


Hi all, a have easy question for python developers.

Assume I have list of all objects:

obj=dir()

Now I want to know which object from “obj” list is module.

I searched some method in module inspection, but there is not any 
method that get ‘string’ as parameters


Any reply will be greatfull

Nadav



import sys
import os
name = 'os'
sys.modules[name]

will return the module itself with the string name. It should allow you 
to use the method you found using the module itself.


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


Re: Finding application data after install - a solution?

2009-09-22 Thread Wolodja Wentland
On Tue, Sep 22, 2009 at 07:42 -0700, Aahz wrote:
 I want to:
 
 1. Give administrators the freedom to install the data wherever they
want
 2. Adhere to the FHS (installing data within modules breaks it)
 3. Be able to find that data again regardless of the installation
   scheme used
 
 1 and 2 are easily solved... It was just not possible to find the data
 again. The snippet in the original code solves that.
 Given your mention of FHS, it sounds like you are focused on Unix-like
 systems, in which case why not rely on the standard mechanisms for config
 files?

I do not intentionally focus on UNIX type systems, but I have grown up
with *nix and I rather follow one scheme than none at all. But the
proposed way works on Windows as well, although the users might find
previously unseen directories like 'PREFIX/share/foo/doc' and the like
on their system.

How to solve this platform independently? And what standard mechanisms
for config files do you mean? Are there library functions I overlooked?

But the data I am speaking about are not config files. I will explain in
more detail so you can understand the problem.

I have a library that parses markup that has a canonical form and a
localised one. 'Image:' for example is the canonical form and the one
used for English. In German the canonical form *and* a localised one is
used ('Bild:'). This scheme (localised+canonical) holds true for all
(260+) languages this markup is used in.

The library itself works fine with the canonical forms, but loads
language specific markup definitions *if they are available* . I
therefore don't want to install this data along with the library for the
following reasons:

1. The data is not needed if the user just want to work with English
   data

2. The data could change much more frequently than the library that
   works with the data.

   If I couple library and data together I would have to make a new
   release *every time* the data changes, even if the user does not
   care about the other languages.

I therefore opted to provide a seperate (Python) distribution foo-data
which contains the language specific markup definitions and install it
to '$DATA_PREFIX/share/foo/languageinfo' .

As $DATA_PREFIX is only known at build time there was (until now) no
reliable way to find the data if the only information one can get is
$LIB_PREFIX, because these two might be totally unrelated.

I hope that clarifies my point

Wolodja

P.S Which markup format am I speaking about? First one to answer gets a
brand new Internet!


signature.asc
Description: Digital signature
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: entry widget won't validate

2009-09-22 Thread Mike
On Sep 22, 4:29 am, Peter Otten __pete...@web.de wrote:
 Mike wrote:
  On Sep 21, 12:47 pm, Peter Otten __pete...@web.de wrote:
  Mike wrote:
   I'm trying to arrange for an Entry widget to check whether its data
   is all digits and whether the number represented is small enough.
   The validate function seem to be called once at startup and not
   afterwards:

   The print statement run 3 times at startup.
   Editing an Entry does not cause any printing.
   Any ideas?

 I don't know Tcl either; the following is the first thing that seemed to
 work, after some trial and error:

 import Tkinter as tk

 def validate(before, after):
     print before, --, after
     return after.isdigit()

 if __name__ == __main__:
     root = tk.Tk()
     name = root.register(validate)
     cmd = 'expr {[%(name)s %(parms)s]}' % dict(name=name, parms=%s %P)
     var = tk.StringVar()
     entry = tk.Entry(root, textvariable=var,
                      validate=all, validatecommand=cmd)
     entry.pack()
     entry.focus_set()
     root.mainloop()

Thanks.
It worked.
I discovered that None is not an acceptable substitute for False.
If validate returns None, it quits being called.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Dynamic Form

2009-09-22 Thread Victor Subervi
Well it's Web stuff, sure, but it's written in python :) The code follows.
The problem is that I haven't figured out how to tell the program that the
user has entered data and to clear the cache of that data so that it's not
re-entered. How do I do that?
TIA,
Victor

#!/usr/bin/python

import cgitb; cgitb.enable()
import cgi
import sys,os
sys.path.append(os.getcwd())
import MySQLdb
import re

def upload(company, num):
  form = cgi.FieldStorage()
  num = form.getfirst('num', 0)
  company = form.getfirst('company', '')
  flag = form.getfirst('flag', '')
  num = int(num)
  print Content-Type: text/html
  print
  print 
!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Frameset//EN 
http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd;
head xmlns=http://www.w3.org/1999/xhtml;
style type='text/css'
.text {  font-family: Arial, Helvetica, sans-serif; font-size: 16px;
text-decoration: none; text-align: justify}
/style
titleGlobal Solutions Group/title
meta http-equiv=distribution content=Global /
meta http-equiv=robots content=index all, follow all /
meta name=author content=This web site developed by beno. You may reach
him at his web site [beno.vi], or by dialing 340-773-0687 and asking for
room 102. /
body

  if flag == 'yes':
host = 'hose'
db = 'db'
user = 'user'
passwd = 'pass'
database = MySQLdb.connect(host, user, passwd, db)
cursor= database.cursor()
pat = '[.,()\[\]\\+=!#$%^;:\'*]'
company = re.sub(pat, '', company)
sql = 'Category varchar(100), Item varchar(20), Description
varchar(255), UOM varchar(20), Price float(7,2)'
cursor.execute('create table if not exists %s (%s);' % (company, sql))
i = 0
while i  num:
  print i
  cat = 'cat' + str(i)
  cat = form.getfirst(cat, '')
  item = 'item' + str(i)
  item = form.getfirst(item, '')
  descr = 'descr' + str(i)
  descr = form.getfirst(descr, '')
  uom = 'uom' + str(i)
  uom = form.getfirst(uom, '')
  price = 'price' + str(i)
  price = form.getfirst(price, '')
  sql = 'insert into %s (Category, Item, Description, UOM, Price) values
(%s, %s, %s, %s, %s);' % (company, cat, item, descr, uom, price)
  cursor.execute(sql)
  i += 1
cursor.close()
print 'h2Data entered successfully./h2'
company = ''
num = 0
  print 'form method=post action=upload.py\n'
  print Company Name: input type='text' value='%s' size='20'
maxlength='100' name='company' /br /br /\n % (company)
  if num == 0:
  print How many rows of products shall we include? input type='text'
value='' size='10' maxlength='10' name='num' /br /\n
  else:
print input type='hidden' name='flag' value='yes' /\n
print input type='hidden' name='num' value='%s' /\n % (num)
i = 0
while i  num:
  print 'hr /\n'
  print Category: input type='text' value='' size='20' maxlength='100'
name='cat%s' /br /\n % (str(i))
  print Item: input type='text' value='' size='20' maxlength='20'
name='item%s' /br /\n % (str(i))
  print Description: input type='text' value='' size='20'
maxlength='255' name='descr%s' /br /\n % (str(i))
  print UOM: input type='text' value='' size='20' maxlength='20'
name='uom%s' /br /\n % (str(i))
  print Price: input type='text' value='' size='10' maxlength='10'
name='price%s' /br /\n % (str(i))
  i += 1
  print 
hr /
div align='center'
  input type='submit' value=' Send ' /
/div
/form
/body/html


upload(company='', num=0)


On Tue, Sep 22, 2009 at 11:34 AM, Simon Forman sajmik...@gmail.com wrote:

 On Tue, Sep 22, 2009 at 10:46 AM, Victor Subervi
 victorsube...@gmail.com wrote:
  Hi;
  I have a dynamic form in which I do the following:
  1) Request two fields (company name, number of entries). That is sent
 back
  to the form.
  2) If the two fields are not None, the form requests other data. That,
 too,
  is sent back to the form.
  3) That new data is then entered into a MySQL table.
  The problem is, that when I go back to refresh the form, the data is
  re-entered into the table! How do I prevent that?
  TIA,
  Victor
 

 First, this seems like it's not a python question, rather it's seems
 to be about some web stuff.

 Second, there's not enough information to tell you anything useful.
 --
 http://mail.python.org/mailman/listinfo/python-list

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


Set literal confusion

2009-09-22 Thread kaoruAngel
I recently decided to implement a small project in python after being
away from the language for a while, so, in learning the language over
again, I experimented.

---
Python 3.1.1 (r311:74483, Aug 17 2009, 16:45:59) [MSC v.1500 64 bit
(AMD64)] on win32

 5 in set(range(10))
True

 15 in set(range(10))
False

 5 in {range(10)}
False

 15 in {range(10)}
False

 {range(10)}
{range(0, 10)}

 set(range(10))
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
--

After a few days of sitting on what seemed at first to be seemingly
buggy, inconsistent set-creation behaviour, I've finally decided it's
not a bug, but a misunderstanding of mine. However, that does still
leave me with one question: why does Python 3.1.1 allow me to get
caught up in my confusion while Python 3.0 (an EARLIER version) spouts
an error pointing me in the right direction? (see below for Python 3.0
behaviour)


Python 3.0 (r30:67507, Dec  3 2008, 20:14:27) [MSC v.1500 32 bit
(Intel)] on win32

 5 in set(range(10))
True

 15 in set(range(10))
False

 5 in {range(10)}
Traceback (most recent call last):
  File stdin, line 1, in module
TypeError: unhashable type: 'range'

 15 in {range(10)}
Traceback (most recent call last):
  File stdin, line 1, in module
TypeError: unhashable type: 'range'
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: easy question, how to double a variable

2009-09-22 Thread Xavier Ho
On Tue, Sep 22, 2009 at 11:58 PM, Mahmoud Abdelkader
mabdelka...@gmail.comwrote:

 hi looking for help catching up in a class and overall to get me better
 than i am now. I can pay you by the week or per hour.


Wow. I'd feel guilty getting paid doing that. Sounds all too easy.

I hope he is actually learning, not just thinking that money will solve all
his problems.

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


Re: Not this one the other one, from a dictionary

2009-09-22 Thread Jean Daniel
Building on the answers of the others, a simple one liner, no side
effect, not the fastest I guess:

 d={'a': 'bob', 'b': 'stu'}
 set( d.keys() ).difference( [ 'a' ] ).pop()
'b'

Note the square brackets for the parameter of difference(). 'The
string 'a' and the list [ 'a' ] are both iterable but really are
different.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Set literal confusion

2009-09-22 Thread Peter Otten
kaoruAngel wrote:

 I recently decided to implement a small project in python after being
 away from the language for a while, so, in learning the language over
 again, I experimented.
 
 ---
 Python 3.1.1 (r311:74483, Aug 17 2009, 16:45:59) [MSC v.1500 64 bit
 (AMD64)] on win32
 
 5 in set(range(10))
 True
 
 15 in set(range(10))
 False
 
 5 in {range(10)}
 False
 
 15 in {range(10)}
 False
 
 {range(10)}
 {range(0, 10)}
 
 set(range(10))
 {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
 --
 
 After a few days of sitting on what seemed at first to be seemingly
 buggy, inconsistent set-creation behaviour, I've finally decided it's
 not a bug, but a misunderstanding of mine. However, that does still
 leave me with one question: why does Python 3.1.1 allow me to get
 caught up in my confusion while Python 3.0 (an EARLIER version) spouts
 an error pointing me in the right direction? (see below for Python 3.0
 behaviour)

That is probably a bug: http://bugs.python.org/issue4701

 
 Python 3.0 (r30:67507, Dec  3 2008, 20:14:27) [MSC v.1500 32 bit
 (Intel)] on win32
 
 5 in set(range(10))
 True
 
 15 in set(range(10))
 False
 
 5 in {range(10)}
 Traceback (most recent call last):
   File stdin, line 1, in module
 TypeError: unhashable type: 'range'
 
 15 in {range(10)}
 Traceback (most recent call last):
   File stdin, line 1, in module
 TypeError: unhashable type: 'range'

My younger 3.0.1 doesn't show that behaviour:

Python 3.0.1+ (r301:69556, Apr 15 2009, 17:25:52)
[GCC 4.3.3] on linux2
Type help, copyright, credits or license for more information.
 {range(10)}
{range(0, 10)}

Peter

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


Re: Set literal confusion

2009-09-22 Thread Vlastimil Brom
2009/9/22 kaoruAngel kaoruan...@gmail.com:
 I recently decided to implement a small project in python after being
 away from the language for a while, so, in learning the language over
 again, I experimented.

 ---
 Python 3.1.1 (r311:74483, Aug 17 2009, 16:45:59) [MSC v.1500 64 bit
 (AMD64)] on win32

 5 in set(range(10))
 True

 15 in set(range(10))
 False

 5 in {range(10)}
 False

 15 in {range(10)}
 False

 {range(10)}
 {range(0, 10)}

 set(range(10))
 {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
 --
...

You might also try the set comprehension:

Python 3.1 (r31:73574, Jun 26 2009, 20:21:35) [MSC v.1500 32 bit
(Intel)] on win32
Type copyright, credits or license() for more information.
 {i for i in range(10)}
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
 set(range(10))
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}


For these simple cases without conditions, it probably doesn't make
much difference.
The character of the single items is maybe more obvious.

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


Re: Set literal confusion

2009-09-22 Thread Peter Otten
Dennis Lee Bieber wrote:

 range() is what used to be xrange() -- an on-demand generator of
 values. You created a set containing a single generator. Try something
 like:
 
 5 in {list(range(10))}

No. {expr} is always a set with a single element. 

 {range(10)}
{range(0, 10)}

That element cannot be a list, by the way, because lists aren't hashable.

 {list(range(10))}
Traceback (most recent call last):
  File stdin, line 1, in module
TypeError: unhashable type: 'list'

Peter

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


How can I tell if variable is defined

2009-09-22 Thread Brown, Rodrick
How could I do the following check in Python

In Perl I could do something like if ((defined($a)) { ... }

I tried if var is not None:
However this doesn't seem to work as described.

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


Re: How can I tell if variable is defined

2009-09-22 Thread Sean DiZazzo
On Sep 22, 11:03 am, Brown, Rodrick  rodrick.br...@citi.com wrote:
 How could I do the following check in Python

 In Perl I could do something like if ((defined($a)) { ... }

 I tried if var is not None:
 However this doesn't seem to work as described.

 Thanks.

try:
var
except NameError:
handle_it()

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


Re: How can I tell if variable is defined

2009-09-22 Thread Rami Chowdhury
On Tue, 22 Sep 2009 11:03:25 -0700, Brown, Rodrick   
rodrick.br...@citi.com wrote:



How could I do the following check in Python

In Perl I could do something like if ((defined($a)) { ... }

I tried if var is not None:
However this doesn't seem to work as described.

Thanks.


Could you let us know in what context you're checking to see if a variable  
is defined? If you mean has the name been used before, then bear in mind  
Python is a lot stricter about this kind of thing than Perl, and if you've  
never used 'var' before the if-statement, you'll probably get a NameError  
being raised.


If you want to check whether the name 'var' is bound to a meaningful  
object, however (e.g. if it's an optional argument to a function, and you  
know it exists, but don't know if it's bound to meaningful data) then your  
construction should work.



--
Rami Chowdhury
Never attribute to malice that which can be attributed to stupidity --  
Hanlon's Razor

408-597-7068 (US) / 07875-841-046 (UK) / 0189-245544 (BD)
--
http://mail.python.org/mailman/listinfo/python-list


Re: How can I tell if variable is defined

2009-09-22 Thread Grant Edwards
On 2009-09-22, Brown, Rodrick rodrick.br...@citi.com wrote:

 How could I do the following check in Python

 In Perl I could do something like if ((defined($a)) { ... }

try:
yourNameHere
except NameError:
print undefined
else:
print defined

 I tried if var is not None:
 However this doesn't seem to work as described.

As described where?

-- 
Grant Edwards   grante Yow! I feel like a wet
  at   parking meter on Darvon!
   visi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Substitute for KConfig in Qt4

2009-09-22 Thread nusch
On Sep 22, 3:43 pm, David Boddie dbod...@trolltech.com wrote:
 On Sat Sep 19 12:18:40 CEST 2009, nusch wrote:

  On Sep 19, 3:53 am, David Boddie da... at boddie.org.uk wrote:
   On Thursday 17 September 2009 13:04, nusch wrote:
I want to remove pyKDE dependencies from my app to make it pure PyQt.
What will be the best substitute for KConfig?

   What exactly do you use KConfig for in your application?

   David

  e.g storing dock window positions, fields choosen in QComboBox etc.
  But I Dont want to use normal config files for it

 Then you would use QSettings. Although that may use configuration files
 behind the scenes, they should at least be stored in a standard place.

 http://www.riverbankcomputing.com/static/Docs/PyQt4/html/qsettings.html

 David

Thanks. That's what I'm looking for
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Module inspection by name

2009-09-22 Thread Dave Angel

Jean-Michel Pichavant wrote:
div class=moz-text-flowed style=font-family: -moz-fixedNadav 
Chernin wrote:


Hi all, a have easy question for python developers.

Assume I have list of all objects:

obj=dir()

Now I want to know which object from “obj” list is module.

I searched some method in module inspection, but there is not any 
method that get ‘string’ as parameters


Any reply will be greatfull

Nadav



import sys
import os
name = 'os'
sys.modules[name]

will return the module itself with the string name. It should allow 
you to use the method you found using the module itself.


JM

/div

The right way to tell if an object is a module is to do isinstance(). 
But your first problem is that the return value of dir() is a list of 
strings, while you want a list of objects. I'd suggest you use globals() 
instead, which produces a dictionary of name/object pairs. Then iterate 
through the values, checking each type with isinstance().


Show us a sample of your code that doesn't work, and we'll try to show 
you how to fix it.


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


custom data warehouse in python vs. out-of-the-box ETL tool

2009-09-22 Thread snfctech
Does anyone have experience building a data warehouse in python?  Any
thoughts on custom vs using an out-of-the-box product like Talend or
Informatica?

I have an integrated system Dashboard project that I was going to
build using cross-vendor joins on existing DBs, but I keep hearing
that a data warehouse is the way to go.  e.g. I want to create orders
and order_items with relations to members (MS Access DB), products
(flat file) and employees (MySQL).

Thanks in advance for any tips.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How can I tell if variable is defined

2009-09-22 Thread Dave Angel

Brown, Rodrick wrote:

How could I do the following check in Python

In Perl I could do something like if ((defined($a)) { ... }

I tried if var is not None:
However this doesn't seem to work as described.

Thanks.


  

try/except

Or look up the attribute in the appropriate dictionary(ies).


def test():
   newvar = 42
   if newvar in locals():
   print yes

DaveA

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


Re: How can I tell if variable is defined

2009-09-22 Thread Mel
Grant Edwards wrote:

 On 2009-09-22, Brown, Rodrick rodrick.br...@citi.com wrote:
 
 How could I do the following check in Python

 In Perl I could do something like if ((defined($a)) { ... }
 
 try:
 yourNameHere
 except NameError:
 print undefined
 else:
 print defined

This being Python, however, it can be fooled:

Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41) 
[GCC 4.3.3] on linux2
Type help, copyright, credits or license for more information.
 class A():
...   def __repr__ (self):
... global b
... return b
... 
 a = A()
 try:
...   a
... except NameError:
...   print `a` is not defined
... 
`a` is not defined




Mel.

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


Read header and data from a binary file

2009-09-22 Thread Jose Rafael Pacheco
Hello,

I want to read from a binary file called myaudio.dat
Then I've tried the next code:

import struct
name = myaudio.dat
f = open(name,'rb')
f.seek(0)
chain =  4s 4s I 4s I 20s I I i 4s I 67s s 4s I
s = f.read(4*1+4*1+4*1+4*1+4*1+20*1+4*1+4*1+4*1+4*1+4*1+67*1+1+4*1+4*1)
a = struct.unpack(chain, s)
header = {'identifier' : a[0],
  'cid'  : a[1],
  'clength'   : a[2],
  'hident' : a[3],
  'hcid32' : a[4],
  'hdate'  : a[5],
  'sampling' : a[6],
  'length_B'  : a[7],
  'max_cA'   : a[8],
  'max_cA1' : a[9],
  'identNOTE'  : a[10],
  'c2len'  : a[11],}

It produces:

{'length_B': 150001, 'sampling': 5, 'max_cA1': 'NOTE', 'hident': 'HEDR',
'c2len': Normal Sustained Vowel 'A', Voice and Speech Lab., MEEI, Boston,
MA, 'hdate': 'Jul 13 11:57:41 1994', 'identNOTE': 68, 'max_cA': -44076,
'cid': 'DS16', 'hcid32': 32, 'identifier': 'FORM', 'clength': 300126}

So far when I run f.tell()
f.tell()
136L

The audio data length is 300126, now I need a clue to build an array with
the audio data (The Chunk SDA_), would it possible with struct?, any help ?

Thanks

The file format is:


Offset  |  Length |  Type |Contents
0   4character Identifier: FORM
4  4character Chunk identifier: DS16
8  4integer Chunk length
12  - -  Chunk data

Header 2

Offset   Length   Type   Contents
0 4 character Identifier: HEDR or HDR8
4 4 integer Chunk length (32)
8 20 character Date, e.g. May 26 23:57:43 1995
28 4 integer Sampling rate
32 4 integer Data length (bytes)
36 2 unsigned integer Maximum absolute value for channel A:
0x if not defined
38 2 unsigned integer Maximum absolute value for channel A:
0x if not defined

NOTE Chunk

Offset   Length   Type   Contents
0 4 character Identifier: NOTE
4 4 integer Chunk length
8 - character Comment string

SDA_, SD_A or SDAB Chunk
Offset Length Type Contents
0 4 character Identifier: SDA_, SD_B, or SDAB
4 4 integer Chunk length
8 - - Data
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How can I tell if variable is defined

2009-09-22 Thread Peter Otten
Brown, Rodrick  wrote:

 How could I do the following check in Python
 
 In Perl I could do something like if ((defined($a)) { ... }
 
 I tried if var is not None:
 However this doesn't seem to work as described.

But in Python this often is the most idiomatic way to check whether a 
variable was set explicitly. Example:

 def foo(a=None):
... if a is None:
... print using default
... else:
... print using a =, a
...
 foo()
using default
 foo(42)
using a = 42

If you tell us what you are actually trying to do we can probably come up 
with a solution that is better than the literal answer

try:
   a
except NameError:
   a_is_defined = False
else:
   a_is_defined = True

Peter

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


set breakpoint in another module/file

2009-09-22 Thread Daniel
Is there a way with pdb to set a breakpoint in another module directly
using a command similar to set_trace() ? For example, I'd like to do
something like this in my source code:

import pdb
pdb.setbreak(42, /path/to/universe.py, name == 'hitchhiker')

Is there a way to do (something like) that with the pdb that ships
with Python? If not, what would people think of adding an additional
function to the pdb module that would do something like the following
code (see below). My use case for this is that often I'd like to set a
breakpoint in some module that does not belong to the project I'm
working in. I rather not edit the module, which is often in site-
packages. The workaround of course is to use set_trace() to drop into
pdb and then set the breakpoint at the pdb prompt, but that's clumsy.
I've found this to be handy:


def setbreak(line=None, file=None, cond=None, temp=0, frame=None,
throw=False):
set a breakpoint or a given line in file with conditional

arguments:
line - line number on which to break
file - module or filename where the breakpoint should be set
cond - string with conditional expression, which (if given)
must
evaluate to true to break
temp - if true, create a temporary breakpoint

example usage:

setbreak(42, /path/to/universe.py, name == 'hitchhiker')


if frame is None:
frame = sys._getframe().f_back
if file is None:
file = frame.f_code.co_filename
elif not file.startswith(file:) and os.path.sep not in file:
try:
mod = __import__(file[4:], globals(), locals(),
[__file__])
except ImportError, err:
if throw:
raise
sys.__stdout__.write(cannot set breakpoint: %s:%s : %s %
(file, line, err))
return
file = mod.__file__
sys.__stdout__.write(breaking in: %s % file)
if file.endswith(.pyc):
file = file[:-1]
pdb = Pdb(stdout=sys.__stdout__) # use sys.__stdout__ to work with
nose tests
pdb.reset()
pdb.curframe = frame
pdb.botframe = object()
pdb.set_continue()
temp = line
while temp  line + 10:
error = pdb.set_break(file, temp, cond=cond, temporary=temp)
if error:
temp += 1
else:
break
if error:
error = pdb.set_break(file, line, cond=cond, temporary=temp)
if throw:
raise Error(error)
sys.__stdout__.write(\n%s\n % error)
return
sys.__stdout__.write(\n)
pdb.do_break() # print breakpoints
sys.settrace(pdb.trace_dispatch)


I'm sure there is a better way to implement some of this, especially
the part marked with HACK, but it seems to work for me in most
situations.

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


Re: How can I tell if variable is defined

2009-09-22 Thread Peter Otten
Mel wrote:

 Grant Edwards wrote:
 
 On 2009-09-22, Brown, Rodrick rodrick.br...@citi.com wrote:
 
 How could I do the following check in Python

 In Perl I could do something like if ((defined($a)) { ... }
 
 try:
 yourNameHere
 except NameError:
 print undefined
 else:
 print defined
 
 This being Python, however, it can be fooled:
 
 Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41)
 [GCC 4.3.3] on linux2
 Type help, copyright, credits or license for more information.
 class A():
 ...   def __repr__ (self):
 ... global b

Superfluous global statement.

 ... return b
 ...
 a = A()
 try:
 ...   a
 ... except NameError:
 ...   print `a` is not defined
 ...
 `a` is not defined

This is an artifact of the interactive interpreter, like the following way 
to print 42:

 for i in range(3): 42
...
42
42
42

Peter

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


Re: set breakpoint in another module/file

2009-09-22 Thread Stef Mientki

Daniel wrote:

Is there a way with pdb to set a breakpoint in another module directly
using a command similar to set_trace() ? For example, I'd like to do
something like this in my source code:

import pdb
pdb.setbreak(42, /path/to/universe.py, name == 'hitchhiker')

  

I think winpdb ( nothing todo with windows-OS ) can do that and much more.

cheers,
Stef
--
http://mail.python.org/mailman/listinfo/python-list


Re: How can I tell if variable is defined

2009-09-22 Thread Mel
Peter Otten wrote:
 Mel wrote:
 Grant Edwards wrote: 
 On 2009-09-22, Brown, Rodrick rodrick.br...@citi.com wrote:
 
 How could I do the following check in Python

 In Perl I could do something like if ((defined($a)) { ... }
 
[ ... ]
 This is an artifact of the interactive interpreter,

True.  You can avoid the artifact by wrapping the test in a function:

Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41) 
[GCC 4.3.3] on linux2
Type help, copyright, credits or license for more information.
 class A():
...   def __repr__ (self):
... return b
... 
 def is_defined (obj):
...   try:
... obj
...   except NameError:
... return False
...   return True
... 
 a = A()
 if is_defined (a):
...   print `a` is defined
... else:
...   print `a` is not defined
... 
`a` is defined
 if is_defined (b):
...   print `b` is defined
... else:
...   print `b` is not defined
... 
Traceback (most recent call last):
  File stdin, line 1, in module
NameError: name 'b' is not defined
 

At the cost of it not quite working when the function is called with an 
undefined name.  I suppose the print statements could be crafted to make it 
look better.


Mel.



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


DBHandler class for logging?

2009-09-22 Thread kj



I've come across mentions of a mythical class of logging handlers
called DBHandler, but I can't find it anywhere.

Could someone please point me in the right direction?

(FWIW, I'm looking for ways to log messages to PostgreSQL RDBMS.)

TIA!

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


Re: DBHandler class for logging?

2009-09-22 Thread Diez B. Roggisch

kj schrieb:

I've come across mentions of a mythical class of logging handlers
called DBHandler, but I can't find it anywhere.

Could someone please point me in the right direction?

(FWIW, I'm looking for ways to log messages to PostgreSQL RDBMS.)


I'm not aware such a thing is part of the standard logging package. But 
it's trivial to write one, we did so ourselves. Depending on your 
version of python, you need to inject the class into the 
logging.handlers-module to make it loadable by the logfile-format. AFAIK 
since 2.6 that restriction is gone.


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


Re: DBHandler class for logging?

2009-09-22 Thread kj
In 7hsukcf2tqht...@mid.uni-berlin.de Diez B. Roggisch de...@nospam.web.de 
writes:

kj schrieb:
 I've come across mentions of a mythical class of logging handlers
 called DBHandler, but I can't find it anywhere.
 
 Could someone please point me in the right direction?
 
 (FWIW, I'm looking for ways to log messages to PostgreSQL RDBMS.)

I'm not aware such a thing is part of the standard logging package. But 
it's trivial to write one, we did so ourselves. Depending on your 
version of python, you need to inject the class into the 
logging.handlers-module to make it loadable by the logfile-format.

I'm sorry for my ignorance, but what exactly do you mean by
injecting the new class into the logging.handlers-module?  And
what is the logfile-format?

TIA!

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


Searching a large dictionary

2009-09-22 Thread Support Desk
I need help searching a large python dictionary. The dictionary is setup
like so

Key[{'item':value,'item2':value,'item3':value,'item4':value,'item5':value','item6':value,'item7':value,'item8':value,'item9':value}]

Key2[{'item':value,'item2':value,'item3':value,'item4':value,'item5':value','item6':value,'item7':value,'item8':value,'item9':value}]

Key3[{'item':value,'item2':value,'item3':value,'item4':value,'item5':value','item6':value,'item7':value,'item8':value,'item9':value}]



What would be the best way to search for a specific value of item1 and add
all the results to a new dictionary? Thanks
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: custom data warehouse in python vs. out-of-the-box ETL tool

2009-09-22 Thread Sean DiZazzo
On Sep 22, 1:00 pm, snfctech tschm...@sacfoodcoop.com wrote:
 Does anyone have experience building a data warehouse in python?  Any
 thoughts on custom vs using an out-of-the-box product like Talend or
 Informatica?

 I have an integrated system Dashboard project that I was going to
 build using cross-vendor joins on existing DBs, but I keep hearing
 that a data warehouse is the way to go.  e.g. I want to create orders
 and order_items with relations to members (MS Access DB), products
 (flat file) and employees (MySQL).

 Thanks in advance for any tips.

I have done some small/medium sized stuff using SQLAlchemy,
Turbogears, and Flex.  I have never used a commercial product, but I
imagine getting it set up to work with your data is the hardest part
of the job anyway, and the solution you end up with will most likely
limit you to applying their api to your data.  If you build it
yourself, you have complete control, and know exactly where to go when
you have a problem, or to add a feature.

I'm no expert, but I think I would try to find a way to consolidate
the data into one data source.  We handle the giant amount of data we
are collecting by preprocessing it into another DB anyway, so I
imagine you could do both things at the same time.

This could very probably be handled in a different way if you are a
DBA.  I'm just a MySQL hack.  :)

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


Re: Read header and data from a binary file

2009-09-22 Thread Simon Forman
On Tue, Sep 22, 2009 at 4:30 PM, Jose Rafael Pacheco
jose_rafael_pach...@yahoo.es wrote:
 Hello,

 I want to read from a binary file called myaudio.dat
 Then I've tried the next code:

 import struct
 name = myaudio.dat
 f = open(name,'rb')
 f.seek(0)

Don't bother to seek(0) on a file you just opened.

 chain =  4s 4s I 4s I 20s I I i 4s I 67s s 4s I
 s = f.read(4*1+4*1+4*1+4*1+4*1+20*1+4*1+4*1+4*1+4*1+4*1+67*1+1+4*1+4*1)

Instead of calculating the size of the data represented by the format,
instead use the struct.calcsize() function

s = f.read(struct.calcsize(chain))

 a = struct.unpack(chain, s)
 header = {'identifier' : a[0],
           'cid'  : a[1],
           'clength'   : a[2],
   'hident' : a[3],
   'hcid32' : a[4],
   'hdate'  : a[5],
   'sampling' : a[6],
   'length_B'  : a[7],
   'max_cA'   : a[8],
   'max_cA1' : a[9],
   'identNOTE'  : a[10],
   'c2len'  : a[11],}

 It produces:

 {'length_B': 150001, 'sampling': 5, 'max_cA1': 'NOTE', 'hident': 'HEDR',
 'c2len': Normal Sustained Vowel 'A', Voice and Speech Lab., MEEI, Boston,
 MA, 'hdate': 'Jul 13 11:57:41 1994', 'identNOTE': 68, 'max_cA': -44076,
 'cid': 'DS16', 'hcid32': 32, 'identifier': 'FORM', 'clength': 300126}

 So far when I run f.tell()
f.tell()
 136L

 The audio data length is 300126, now I need a clue to build an array with
 the audio data (The Chunk SDA_), would it possible with struct?, any help ?

Read the chunk ID and length and then use the length to read the rest
of the chunk data.



 Thanks

 The file format is:


 Offset  |  Length |  Type |    Contents
 0   4    character     Identifier: FORM
 4      4        character     Chunk identifier: DS16
 8      4        integer         Chunk length
 12      -         -  Chunk data

 Header 2

 Offset       Length       Type       Contents
 0     4     character     Identifier: HEDR or HDR8
 4     4     integer     Chunk length (32)
 8     20     character     Date, e.g. May 26 23:57:43 1995
 28     4     integer     Sampling rate
 32     4     integer     Data length (bytes)
 36     2     unsigned integer     Maximum absolute value for channel A:
 0x if not defined
 38     2     unsigned integer     Maximum absolute value for channel A:
 0x if not defined

 NOTE Chunk

 Offset       Length       Type       Contents
 0     4     character     Identifier: NOTE
 4     4     integer     Chunk length
 8     -     character     Comment string

 SDA_, SD_A or SDAB Chunk
 Offset     Length     Type     Contents
 0     4     character     Identifier: SDA_, SD_B, or SDAB
 4     4     integer     Chunk length
 8     -     -     Data


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


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


Re: Read header and data from a binary file

2009-09-22 Thread MRAB

Jose Rafael Pacheco wrote:

Hello,

I want to read from a binary file called myaudio.dat
Then I've tried the next code:

import struct
name = myaudio.dat
f = open(name,'rb')
f.seek(0)
chain =  4s 4s I 4s I 20s I I i 4s I 67s s 4s I
s = f.read(4*1+4*1+4*1+4*1+4*1+20*1+4*1+4*1+4*1+4*1+4*1+67*1+1+4*1+4*1)

[snip]
FYI, the struct module has a function called 'calcsize', so:

s = f.read(struct.calcsize(chain))
--
http://mail.python.org/mailman/listinfo/python-list


Re: DBHandler class for logging?

2009-09-22 Thread Diez B. Roggisch

kj schrieb:

In 7hsukcf2tqht...@mid.uni-berlin.de Diez B. Roggisch de...@nospam.web.de 
writes:


kj schrieb:

I've come across mentions of a mythical class of logging handlers
called DBHandler, but I can't find it anywhere.

Could someone please point me in the right direction?

(FWIW, I'm looking for ways to log messages to PostgreSQL RDBMS.)


I'm not aware such a thing is part of the standard logging package. But 
it's trivial to write one, we did so ourselves. Depending on your 
version of python, you need to inject the class into the 
logging.handlers-module to make it loadable by the logfile-format.


I'm sorry for my ignorance, but what exactly do you mean by
injecting the new class into the logging.handlers-module?  And
what is the logfile-format?


The logfile format as specified in the documentation fo the 
logging-module. And due to some restrictions in the way how this 
instantiates declared logging-handlers, you need to set your own class 
into logging.handlers:


import logging.handlers as h

class MyHandler(...):
...


h.MyHandler = MyHandler


# now you can load the config.

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


Re: Not this one the other one, from a dictionary

2009-09-22 Thread Vlastimil Brom
Thanks for the elaboration;
in retrospect, given the simple requirement, that there are only two
dict keys, one of which is know and the other to be determined, maybe
just the direct dict methods are appropriate, e.g.

d = {'a': 'bob', 'b': 'stu'}
d_copy = dict(d)
d_copy.pop(a)
'bob'
d_copy.popitem()
('b', 'stu')

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


Re: Searching a large dictionary

2009-09-22 Thread Chris Rebert
On Tue, Sep 22, 2009 at 2:50 PM, Support Desk
support.desk@gmail.com wrote:
 I need help searching a large python dictionary. The dictionary is setup
 like so

 Key[{'item':value,'item2':value,'item3':value,'item4':value,'item5':value','item6':value,'item7':value,'item8':value,'item9':value}]

 Key2[{'item':value,'item2':value,'item3':value,'item4':value,'item5':value','item6':value,'item7':value,'item8':value,'item9':value}]

 Key3[{'item':value,'item2':value,'item3':value,'item4':value,'item5':value','item6':value,'item7':value,'item8':value,'item9':value}]

That is not valid syntax. Do you mean you have a dictionary like this?:

{ Key : 
[{'item':value,'item2':value,'item3':value,'item4':value,'item5':value','item6':value,'item7':value,'item8':value,'item9':value}],
Key2 : 
[{'item':value,'item2':value,'item3':value,'item4':value,'item5':value','item6':value,'item7':value,'item8':value,'item9':value}],
Key3 : 
[{'item':value,'item2':value,'item3':value,'item4':value,'item5':value','item6':value,'item7':value,'item8':value,'item9':value}]
}

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Searching a large dictionary

2009-09-22 Thread Simon Forman
On Tue, Sep 22, 2009 at 5:50 PM, Support Desk
support.desk@gmail.com wrote:
 I need help searching a large python dictionary. The dictionary is setup
 like so

 Key[{'item':value,'item2':value,'item3':value,'item4':value,'item5':value','item6':value,'item7':value,'item8':value,'item9':value}]

 Key2[{'item':value,'item2':value,'item3':value,'item4':value,'item5':value','item6':value,'item7':value,'item8':value,'item9':value}]

 Key3[{'item':value,'item2':value,'item3':value,'item4':value,'item5':value','item6':value,'item7':value,'item8':value,'item9':value}]


These look like you're indexing objects Key, Key2, Key3 by
dictionaries, or possibly these are the result of printing dict-like
objects with custom __repr__() methods.  Could you give more
information about what's actually going on here?

 What would be the best way to search for a specific value of item1 and add
 all the results to a new dictionary? Thanks

Searching a dict is accomplished by simply asking for the key:  d['item1']

I'm going to guess you meant something like this:

list_of_dicts = [Key, Key2, Key3]
new_dict = {}

for i, k in enumerate(list_of_dicts):
value = k['item1']
if value == some_specific_value:
new_dict[i] = value


But it's not really clear from your post exactly what you meant to ask.



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


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


Re: Searching a large dictionary

2009-09-22 Thread Support Desk
Chris,  Yes that is the correct syntax, thanks

On Tue, Sep 22, 2009 at 5:22 PM, Chris Rebert c...@rebertia.com wrote:

 On Tue, Sep 22, 2009 at 2:50 PM, Support Desk
 support.desk@gmail.com wrote:
  I need help searching a large python dictionary. The dictionary is setup
  like so
 
 
 Key[{'item':value,'item2':value,'item3':value,'item4':value,'item5':value','item6':value,'item7':value,'item8':value,'item9':value}]
 
 
 Key2[{'item':value,'item2':value,'item3':value,'item4':value,'item5':value','item6':value,'item7':value,'item8':value,'item9':value}]
 
 
 Key3[{'item':value,'item2':value,'item3':value,'item4':value,'item5':value','item6':value,'item7':value,'item8':value,'item9':value}]

 That is not valid syntax. Do you mean you have a dictionary like this?:

 { Key :
 [{'item':value,'item2':value,'item3':value,'item4':value,'item5':value','item6':value,'item7':value,'item8':value,'item9':value}],
 Key2 :
 [{'item':value,'item2':value,'item3':value,'item4':value,'item5':value','item6':value,'item7':value,'item8':value,'item9':value}],
 Key3 :
 [{'item':value,'item2':value,'item3':value,'item4':value,'item5':value','item6':value,'item7':value,'item8':value,'item9':value}]
 }

 Cheers,
 Chris
 --
 http://blog.rebertia.com

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


Re: Searching a large dictionary

2009-09-22 Thread Simon Forman
On Tue, Sep 22, 2009 at 6:30 PM, Support Desk
support.desk@gmail.com wrote:
 Chris,  Yes that is the correct syntax, thanks


Okay, but correct syntax of what?  Help us help you.


 On Tue, Sep 22, 2009 at 5:22 PM, Chris Rebert c...@rebertia.com wrote:

 On Tue, Sep 22, 2009 at 2:50 PM, Support Desk
 support.desk@gmail.com wrote:
  I need help searching a large python dictionary. The dictionary is setup
  like so
 
 
  Key[{'item':value,'item2':value,'item3':value,'item4':value,'item5':value','item6':value,'item7':value,'item8':value,'item9':value}]
 
 
  Key2[{'item':value,'item2':value,'item3':value,'item4':value,'item5':value','item6':value,'item7':value,'item8':value,'item9':value}]
 
 
  Key3[{'item':value,'item2':value,'item3':value,'item4':value,'item5':value','item6':value,'item7':value,'item8':value,'item9':value}]

 That is not valid syntax. Do you mean you have a dictionary like this?:

 { Key :
 [{'item':value,'item2':value,'item3':value,'item4':value,'item5':value','item6':value,'item7':value,'item8':value,'item9':value}],
 Key2 :
 [{'item':value,'item2':value,'item3':value,'item4':value,'item5':value','item6':value,'item7':value,'item8':value,'item9':value}],
 Key3 :
 [{'item':value,'item2':value,'item3':value,'item4':value,'item5':value','item6':value,'item7':value,'item8':value,'item9':value}]
 }

 Cheers,
 Chris
 --
 http://blog.rebertia.com


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


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


Re: .h files?

2009-09-22 Thread rogerdpack4
 What python distributions are you referring to? The ones I know don't
 make this distinction; there is only a single set of header files that
 you can choose to install.

Ok good to know.
-r
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Searching a large dictionary

2009-09-22 Thread Chris Rebert
 On Tue, Sep 22, 2009 at 5:22 PM, Chris Rebert c...@rebertia.com wrote:
 On Tue, Sep 22, 2009 at 2:50 PM, Support Desk
 support.desk@gmail.com wrote:
  I need help searching a large python dictionary. The dictionary is setup
  like so
 
 
  Key[{'item':value,'item2':value,'item3':value,'item4':value,'item5':value','item6':value,'item7':value,'item8':value,'item9':value}]
 
 
  Key2[{'item':value,'item2':value,'item3':value,'item4':value,'item5':value','item6':value,'item7':value,'item8':value,'item9':value}]
 
 
  Key3[{'item':value,'item2':value,'item3':value,'item4':value,'item5':value','item6':value,'item7':value,'item8':value,'item9':value}]

 That is not valid syntax. Do you mean you have a dictionary like this?:

 { Key :
 [{'item':value,'item2':value,'item3':value,'item4':value,'item5':value','item6':value,'item7':value,'item8':value,'item9':value}],
 Key2 :
 [{'item':value,'item2':value,'item3':value,'item4':value,'item5':value','item6':value,'item7':value,'item8':value,'item9':value}],
 Key3 :
 [{'item':value,'item2':value,'item3':value,'item4':value,'item5':value','item6':value,'item7':value,'item8':value,'item9':value}]
 }
On Tue, Sep 22, 2009 at 3:30 PM, Support Desk
support.desk@gmail.com wrote:
 Chris,  Yes that is the correct syntax, thanks

Ok, so what would the new dictionary you want look like exactly? A
list would seem the natural datatype for the results, but you want a
dict.

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Searching a large dictionary

2009-09-22 Thread Chris Rebert
 -Original Message-
 From: Chris Rebert c...@rebertia.com
 Sent: Tuesday, September 22, 2009 5:35 PM
 To: Support Desk support.desk@gmail.com
 Cc: python-list@python.org
 Subject: Re: Searching a large dictionary
 On Tue, Sep 22, 2009 at 5:22 PM, Chris Rebert c...@rebertia.com wrote:
 On Tue, Sep 22, 2009 at 2:50 PM, Support Desk
 support.desk@gmail.com wrote:
  I need help searching a large python dictionary. The dictionary is setup
  like so
 
 
  Key[{'item':value,'item2':value,'item3':value,'item4':value,'item5':value','item6':value,'item7':value,'item8':value,'item9':value}]
 
 
  Key2[{'item':value,'item2':value,'item3':value,'item4':value,'item5':value','item6':value,'item7':value,'item8':value,'item9':value}]
 
 
  Key3[{'item':value,'item2':value,'item3':value,'item4':value,'item5':value','item6':value,'item7':value,'item8':value,'item9':value}]

 That is not valid syntax. Do you mean you have a dictionary like this?:

 { Key :
 [{'item':value,'item2':value,'item3':value,'item4':value,'item5':value','item6':value,'item7':value,'item8':value,'item9':value}],
 Key2 :
 [{'item':value,'item2':value,'item3':value,'item4':value,'item5':value','item6':value,'item7':value,'item8':value,'item9':value}],
 Key3 :
 [{'item':value,'item2':value,'item3':value,'item4':value,'item5':value','item6':value,'item7':value,'item8':value,'item9':value}]
 }
 On Tue, Sep 22, 2009 at 3:30 PM, Support Desk
 support.desk@gmail.com wrote:
 Chris,  Yes that is the correct syntax, thanks

 Ok, so what would the new dictionary you want look like exactly? A
 list would seem the natural datatype for the results, but you want a
 dict.
On Tue, Sep 22, 2009 at 3:41 PM, Support support.desk@gmail.com wrote:
 Chris, a list would work fine, the results are being rendered to a django 
 template

results = []
for lst in your_dict.values():
d = lst[0]
try:
results.append(d[item1])
except KeyError:
pass
#use results

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Solved - Python: automate input to MySQL query

2009-09-22 Thread Threader Slash
Hi Dennis,
You're right. Putting  allows indentation. Great!

About putting the name of the table: x.travelerID, etc.. I think it keep the
query more documented, specially when you are dealing with 5 tables in a
same query, like this query.

Cheers.. Threader.

-- Forwarded message --
From: Dennis Lee Bieber wlfr...@ix.netcom.com
To: python-list@python.org
Date: Tue, 22 Sep 2009 10:43:52 -0700
Subject: Re: Solved - Python: automate input to MySQL query
On Tue, 22 Sep 2009 15:58:18 +1000, Threader Slash
threadersl...@gmail.com declaimed the following in
gmane.comp.python.general:


 self.db = MySQLdb.connect(hostname,username,passwd,dbname)
 self.cursor=self.db.cursor();

 name=John
 runQuery=SELECT traveler.travelerFirstName,vaccine.vaccineName from
 traveler INNER JOIN takenvaccine ON traveler.travelerID =
 takenvaccine.travelerID INNER JOIN vaccine ON
 takenvaccine.vaccineID=vaccine.vaccineID INNER JOIN requiredvaccine ON
 vaccine.vaccineID=requiredvaccine.requiredvaccineID INNER JOIN site ON
 requiredvaccine.siteID = site.siteID WHERE traveler.travelerFirstName
 = %s

   snip

 Note: you need to declare the whole query in the same line to it take
effect
 in the variable runQuery.

   No, you don't... IF you wrap it in triple-quotes...

runQuery=select t.travelerFirstName, v.vaccineName
   from traveler as t
   inner join takenvaccine as tv
   on t.travelerID = tv.travelerID
   inner join vaccine as v
   on tv.vaccineID = v.vaccineID
   inner join requiredvaccine as rv
   on v.vaccineID = rv.requiredvaccineID
   inner join site as s
   on rv.siteID = s.siteID
   where t.travelerFirstName = %s

Should be perfectly acceptable to Python and the database query
processor.

   I'm not too impressed with the database naming scheme -- if the
TABLE is named x, why prefix all the fields in the table with the same
x
   requiredvaccine.requiredvaccineID
is rather redundant -- same with all the others. The only place where it
might be justified is when it is a foreign key linkage.

   vaccine.ID  ID of the vaccine record

   requiredvaccine.ID  ID of the rv record itself, not of
the
vaccine
   requiredvaccine.vaccineID   foreign key, ID /in/ vaccine
that
this record refers to.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: socket send O(N**2) complexity

2009-09-22 Thread Nobody
On Mon, 21 Sep 2009 16:33:08 -0400, Jack Diederich wrote:

 AIUI, as a python string is imutable, a slice of a string is a
 new string which points (C char *) to the start of the slice data
 and with a length that is the length of the slice, about 8 bytes
 on 32 bit machine.
 
 Not in CPython.  While some special strings are re-used (empty string,
 single letters) if you take a slice of an existing string a new buffer
 is allocated and the slice memcpy'd into it.

Er, why?

I can understand doing this for mutable sequences, but it doesn't seem
to make much sense for strings.


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


Re: difficulty in understanding rsplit(None,1)[1]

2009-09-22 Thread Martin P. Hellwig

John Machin wrote:

On Sep 22, 7:10 pm, hrishy hris...@yahoo.co.uk wrote:

Hi Martin

Many thanks
And by the way great way to explain that thing


great way to find out for yourself faster than waiting for a response
from the internet ;-)


I have been called many things in the past but being labeled 'the 
internet' is an honour way to big for me ;-)


--
MPH
http://blog.dcuktec.com
'If consumed, best digested with added seasoning to own preference.'
--
http://mail.python.org/mailman/listinfo/python-list


Re: socket send O(N**2) complexity

2009-09-22 Thread Jack Diederich
On Tue, Sep 22, 2009 at 7:25 PM, Nobody nob...@nowhere.com wrote:
 On Mon, 21 Sep 2009 16:33:08 -0400, Jack Diederich wrote:

 AIUI, as a python string is imutable, a slice of a string is a
 new string which points (C char *) to the start of the slice data
 and with a length that is the length of the slice, about 8 bytes
 on 32 bit machine.

 Not in CPython.  While some special strings are re-used (empty string,
 single letters) if you take a slice of an existing string a new buffer
 is allocated and the slice memcpy'd into it.

 Er, why?

 I can understand doing this for mutable sequences, but it doesn't seem
 to make much sense for strings.

Because it adds large amounts of complexity.  If you have a string
that points to 8 bytes in a 1Gig string and the giant string goes out
of scope, what do you do?  You can keep it alive, you can copy out 8
bytes; you can do one of those things now or you can wait until later
when some kind of garbage collection happens.   Once you have that
system why not pile ropes on top of it?  and once you have ropes why
not just make strings mutable ...

If you want much longer mailing list threads about the topic search
the python-dev archives.

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


Re: difficulty in understanding rsplit(None,1)[1]

2009-09-22 Thread nopsidy
lol
-nop nop nop
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How can I tell if variable is defined

2009-09-22 Thread Dave Angel



Mel wrote:

snip

This is an artifact of the interactive interpreter,



True.  You can avoid the artifact by wrapping the test in a function:

Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41) 
[GCC 4.3.3] on linux2

Type help, copyright, credits or license for more information.
  

class A():


...   def __repr__ (self):
... return b
... 
  

def is_defined (obj):


...   try:
... obj
...   except NameError:
... return False
...   return True
... 
  

a = A()
if is_defined (a):


...   print `a` is defined
... else:
...   print `a` is not defined
... 
`a` is defined
  

if is_defined (b):


...   print `b` is defined
... else:
...   print `b` is not defined
... 
Traceback (most recent call last):

  File stdin, line 1, in module
NameError: name 'b' is not defined
  

At the cost of it not quite working when the function is called with an 
undefined name.  I suppose the print statements could be crafted to make it 
look better.



Mel.

  
No clue what you're trying to accomplish here.  The exception inside the 
function is_defined() will never fire;  the method always returns True.


You're getting an exception during the attempt to call such a function, 
and so of course there's no point in putting the if test around that either.


This may be the last time I try to read such complexity in an 
interactive transcript.  It took a couple of tries before I got the 
indentation understood.  I thought that is_defined() was intended to be 
a method inside the class.


DaveA

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


Re: Searching a large dictionary

2009-09-22 Thread Dave Angel

Support Desk wrote:

I need help searching a large python dictionary. The dictionary is setup
like so

Key[{'item':value,'item2':value,'item3':value,'item4':value,'item5':value','item6':value,'item7':value,'item8':value,'item9':value}]

Key2[{'item':value,'item2':value,'item3':value,'item4':value,'item5':value','item6':value,'item7':value,'item8':value,'item9':value}]

Key3[{'item':value,'item2':value,'item3':value,'item4':value,'item5':value','item6':value,'item7':value,'item8':value,'item9':value}]



What would be the best way to search for a specific value of item1 and add
all the results to a new dictionary? Thanks

  
With all the messages I've seen so far on this thread, all you've 
managed to do is confuse it further.   I suggest you start over (new 
thread) with a legal program defining a single dictionary (with real 
values for Key, Key2, and value, and without extra quote marks which 
make it fail to compile even if we guess what you're doing with the 
three keys).  I suggest that at least some relevant parts of the data 
should not be all identical, so we can tell what's important.


Use copy  paste from working code.

Then given a real dictionary, describe what you really want to search 
for, and what acceptable results would be.


And also specify the programming language, version, and OS environment.

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


Re: set breakpoint in another module/file

2009-09-22 Thread millerdev

 I think winpdb ( nothing todo with windows-OS ) can do that and much more.

The problem with winpdb (which I played with a long time ago) is that
it's much heavier than the built-in pdb--it's a GUI debugger. It
requires the beast called wx, which I do not use for web (or GUI)
development. I'm don't relish the thought of installing wx just for a
debugger. I'm really just looking for a simple function in the pdb
module that sets a breakpoint (which can subsequently be removed).
Nothing more.

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


Re: custom data warehouse in python vs. out-of-the-box ETL tool

2009-09-22 Thread snfctech
Thanks for your replies, Sean and Martin.

I agree that the ETL tools are complex in themselves, and I may as
well spend that learning curve on a lower-level tool-set that has the
added value of greater flexibility.

Can you suggest a good book or tutorial to help me build a data
warehouse in python?  Bill Inmon's Building the Data Warehouse is 17
years old, and I've been cautioned against Kimball.

Thanks.


On Sep 22, 3:40 pm, Martin P. Hellwig martin.hell...@dcuktec.org
wrote:
 snfctech wrote:
  Does anyone have experience building a data warehouse in python?  Any
  thoughts on custom vs using an out-of-the-box product like Talend or
  Informatica?

  I have an integrated system Dashboard project that I was going to
  build using cross-vendor joins on existing DBs, but I keep hearing
  that a data warehouse is the way to go.  e.g. I want to create orders
  and order_items with relations to members (MS Access DB), products
  (flat file) and employees (MySQL).

  Thanks in advance for any tips.

 My experience is that if you enjoy hacking around databases and are
 proficient in Python, than for small scale solutions it is preferable to
 do it yourself. If you need a large scale solutions with advanced
 requirements, building it yourself is mostly the only way.

 I have build a rather complex datawarehouse system in the past (well
 actually more like a centralised synchronisation hub, having input and
 reporting databases as satellite clients), shoving data from around 500
 databases (typically 5 Gb in size each) spread over the world.

 The only commercial solutions I reviewed was Business Objects Data
 Integrator and Oracle Warehouse Builder.

 These tools where quite flexible and if you already have a license deal
 which includes these tools I would definitely recommend to have more
 than just a look at it.

 If not and you are comfortably with using python to shovel data from A
 to B and transform it at the same time (moving relational data
 automatically into a EAV model and back again, for example) than
 building your own solution will probably save you money and time (as
 opposed to learn how to use that ETL tool).

 This will require you to have at least interest in the following subjects:
 - Authorization, may everybody use all data or should it be limited to a
 subset on the data depending on the data?
 (My solution was one centralised hub which contains all data but is only
 accessible to special 'client' servers strictly maintained by me which
 only sync the data relevant to them).

 - Authenticity, if you have different values for the same thing, which
 one should be considered authoritative and if yes may it be pushed back
 to the un-authoritative?

 -Synchronisation, you really don't want to push/pull all of the database
 content over every x times, so how can you delta it and is there a way
 to do this only when the data changes (push vs pull)?

 -ATOMIC, how long may the data be out of date and is it allowed to
 partially update

 -Using and maintaining multiple databases, hopefully spread over
 multiple systems. I had a server for each production DB, a server that
 mirrored that production DB with some added columns per table for
 external synchronization purposes and a master synchronisation server
 (so in essence all data was copied three times, not very efficient but
 good if you like to play it on the safe side).

 --
 MPHhttp://blog.dcuktec.com
 'If consumed, best digested with added seasoning to own preference.'

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


pygui - showing an image

2009-09-22 Thread kyle schalm
hello, i wonder what the chances are that anyone here uses pygui?
it looks pretty good, but i just started using it (version 2.05) and
can't figure out how to just display a window with an image in it. i
tried:

image = Image('foo.png')
window.place(image) -- error message
window.add(image)   -- nothing shows

then i tried getting a canvas involved but that seemed to make things worse.
any hints are appreciated. thanks,
-kyle
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pygui - showing an image

2009-09-22 Thread David Robinow
On Tue, Sep 22, 2009 at 9:26 PM, kyle schalm kyle.sch...@gmail.com wrote:
 hello, i wonder what the chances are that anyone here uses pygui?
 it looks pretty good, but i just started using it (version 2.05) and
 can't figure out how to just display a window with an image in it. i
 tried:

 image = Image('foo.png')
 window.place(image) -- error message
 window.add(image)   -- nothing shows

 then i tried getting a canvas involved but that seemed to make things worse.
 any hints are appreciated. thanks,
 -kyle
 --
 http://mail.python.org/mailman/listinfo/python-list

There's an example in Tests/21-image.py
See if that helps.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Combining sets/dictionaries

2009-09-22 Thread alex23
Alfons Nonell-Canals alfons.non...@upf.edu wrote:
 finally I've solved it using a combinatorics library which allows to
 do this kind of things.

If you're using a version of Python  2.6 you might find that
itertools.combinations does what you want without requiring the
additional code.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Combining sets/dictionaries

2009-09-22 Thread alex23
On Sep 23, 12:44 pm, alex23 wuwe...@gmail.com wrote:
 Alfons Nonell-Canals alfons.non...@upf.edu wrote:
  finally I've solved it using a combinatorics library which allows to
  do this kind of things.

 If you're using a version of Python  2.6 you might find that
 itertools.combinations does what you want without requiring the
 additional code.

Actually, that's probably _not_ what you want, sorry. I don't like the
recursive solution you've found, though, especially as you can get the
same result with a generator expression:

 set1 = set(['smart', 'dumb']) # the example on the site is easier to follow 
 than your use case, sorry
 set2 = set(['hard-working', 'lazy'])
 list((a,b) for a in set1 for b in set2)
[('smart', 'lazy'), ('smart', 'hard-working'), ('dumb', 'lazy'),
('dumb', 'hard-working')]

 set3 = ['crazy', 'sane', 'boring'] # works with iterators of any size
 list((a,b) for a in set1 for b in set3)
[('smart', 'crazy'), ('smart', 'sane'), ('smart', 'boring'), ('dumb',
'crazy'), ('dumb', 'sane'), ('dumb', 'boring')]

Hope this helps.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: socket send O(N**2) complexity

2009-09-22 Thread Steven D'Aprano
On Wed, 23 Sep 2009 00:25:52 +0100, Nobody wrote:

 On Mon, 21 Sep 2009 16:33:08 -0400, Jack Diederich wrote:
 
 AIUI, as a python string is imutable, a slice of a string is a new
 string which points (C char *) to the start of the slice data and with
 a length that is the length of the slice, about 8 bytes on 32 bit
 machine.
 
 Not in CPython.  While some special strings are re-used (empty string,
 single letters) if you take a slice of an existing string a new buffer
 is allocated and the slice memcpy'd into it.
 
 Er, why?
 
 I can understand doing this for mutable sequences, but it doesn't seem
 to make much sense for strings.

Consider:

huge_string = abcdef*1000*1000*1000
tiny_string = huge_string[42:45]
del huge_string

Under the current behaviour, huge_string will be garbage collected. With 
the proposed string-view, it won't be. It would be surprising and 
disturbing if taking a tiny slice of a huge string prohibited the huge 
string from being garbage collected.


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


  1   2   >