setuptools_bzr 1.2

2008-06-05 Thread Barry Warsaw

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

I'm happy to announce the setuptools_bzr 1.2 plugin for Python's  
setuptools.  This allows setuptools to find your Python package files  
kept under the Bazaar revision control system.  setuptools_bzr 1.2  
should be compatible with Bazaar 1.5.


This version fixes bug #237652 which prevented it from working  
correctly with loomified branches.  It also adds an environment  
variable to force use of the command line bzr(1) even if bzrlib can be  
found.


setuptools_bzr 1.2 is available in egg and source tarball format on  
the Python Package Index (a.k.a. Cheeseshop):


http://pypi.python.org/pypi/setuptools_bzr/1.2

To use the plugin, just modify your setup() function in setup.py like  
so:


setup(...
  setup_requires = [
  'setuptools_bzr',
  ],
  ...)

The project home page is on Launchpad:

https://launchpad.net/setuptoolsbzr

Enjoy,
- -Barry

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (Darwin)

iQCVAwUBSEglFHEjvBPtnXfVAQKjKQP+KG8zfnIVvMXsqUEnpbgmZt1Cd6v1RJOv
TXXB3Zef5XZerniEFIVZOcA00xQ3PHdpxJLghh3MWUv8wRSIyIgtlRNx+wbKXBWv
fxCvVScWAnW+Zycg4hIM1kUWsYzB4JyGzU9PXRT5oZh5SM1EDYMSQPMrcErukRIg
0rIXw2Ht6KA=
=kAS7
-END PGP SIGNATURE-
--
http://mail.python.org/mailman/listinfo/python-announce-list

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


ANN: Resolver One 1.1 released

2008-06-05 Thread Giles Thomas
We are proud to announce the release of Resolver One, version 1.1 -
the largest IronPython application in the world, we think, at 38,000
lines of production code backed up by 130,000 lines of unit and
functional tests.

Resolver One is a Rapid Application Development tool for analysing and
presenting business data using a familiar spreadsheet interface,
combined with a powerful IronPython-based scripting capability that
allows you to insert your own code directly into the recalculation
loop.  There's a one-minute screencast about it here:

http://www.resolversystems.com/screencasts/resolver-one-in-one

For version 1.1 , we’ve made quite a lot of changes, hopefully making
the program more responsive and pleasant to use - as well as adding
cool new features.  Some of the highlights:

* Significant improvements to performance and memory usage.
* Cutting and pasting is now more spreadsheet-like.
* User-defined formatter functions on a per-cell basis.
* Ability to unpack Python iterables into ranges of cells.
* Auto-indent in the code editor.
* Better coverage of standard spreadsheet functions.
* Comments in cells.
* For the financial edition, we've added Thomson Dataworks
Enterprise connectivity and a number of great enhancements to
Bloomberg access.

We’ve put together a three-minute screencast outlining all these
changes:

http://www.resolversystems.com/screencasts/release-1.1/

It's free for non-commercial use (and quite cheap for commercial
use :-), so if you would like to take a look, you can download it from
our website (free registration required):

http://www.resolversystems.com/get-it/

Best regards,

Giles

--
Giles Thomas
MD  CTO, Resolver Systems Ltd.
[EMAIL PROTECTED]
+44 (0) 20 7253 6372

Try out Resolver One! http://www.resolversystems.com/get-it/
(Free registration required)

17a Clerkenwell Road, London EC1M 5RD, UK
VAT No.: GB 893 5643 79 Registered in England and Wales as company
number 5467329.
Registered address: 843 Finchley Road, London NW11 8NA, UK
--
http://mail.python.org/mailman/listinfo/python-announce-list

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


Looking for some good python learning resources on the web

2008-06-05 Thread [EMAIL PROTECTED]
What are the best sites to read to learn python?
--
http://mail.python.org/mailman/listinfo/python-list


os.path.walk -- Can You Limit Directories Returned?

2008-06-05 Thread Jeff Nyman
Greetings all.

I did some searching on this but I can't seem to find a specific
solution. I have code like this:

=
def walker1(arg, dirname, names):
DC_List.append((dirname,''))

os.path.walk('vcdcflx006\\Flex\\Sites', walker1, 0)
=

The Sites\ directory is set up like this:

Sites\
   Baltimore
   Birmingham
   

And so forth. Each of the city directories has directories under it as
well. The problem is that my code grabs every single directory that is
under the various city directories when what I really want it to do is
just grab the directories that are under Sites\ and that's it. I don't
want it to recurse down into the sub-directories of the cities.

Is there a way to do this? Or is os.path.walk not by best choice here?

Any help and/or advice would be appreciated.

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


Re: os.path.walk -- Can You Limit Directories Returned?

2008-06-05 Thread Diez B. Roggisch

Jeff Nyman schrieb:

Greetings all.

I did some searching on this but I can't seem to find a specific
solution. I have code like this:

=
def walker1(arg, dirname, names):
DC_List.append((dirname,''))

os.path.walk('vcdcflx006\\Flex\\Sites', walker1, 0)
=

The Sites\ directory is set up like this:

Sites\
   Baltimore
   Birmingham
   

And so forth. Each of the city directories has directories under it as
well. The problem is that my code grabs every single directory that is
under the various city directories when what I really want it to do is
just grab the directories that are under Sites\ and that's it. I don't
want it to recurse down into the sub-directories of the cities.

Is there a way to do this? Or is os.path.walk not by best choice here?

Any help and/or advice would be appreciated.


look into the modules glob and os.

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


Problem with TimedRotatingFileHandler

2008-06-05 Thread Dominique.Holzwarth
Hi everyone

I'm trying to use python's logging mechanism to write exception data into a log 
file with the TimedRotatingFileHandler but the rotating of the file is not 
working...
Here's a bit of sample code of what I'm doing (just the interessting part of it 
;-)):

import logging
import logging.handlers as handlers
class MyError(Exception):

fileName = os.path.join(os.path.dirname(__file__), 'Error.log')

def __init__(self):
fileHandler = handlers.TimedRotatingFileHandler(MyError.fileName, 
when='m', interval=1, backupCount=1)
formatter = logging.Formatter('\n%(name)-12s: %(asctime)s 
%(levelname)-8s %(message)s')
fileHandler.setFormatter(formatter)
logging.getLogger('').addHandler(fileHandler)
## Reference to the logger object
self.logger = logging.getLogger('FileLogger')
self.logger.setLevel(logging.INFO)

class MyInheritedError(MyError):
def __init__(self):
MyError.__init__(self)
self.logger.error(some stupid text :-))

The error classes do write into the log file, however there's no rotating. No 
new file is created (and old ones renamed) nor are there any old log entries 
deleted/replaced...
Does anyone have any idea what I could be missing? Might it be a problem due to 
the fact that these classes inherit from Exception?

Would be really cool if some1 could help me :)


*
This e-mail and any files attached are strictly confidential, may be legally
privileged and are intended solely for the addressee. If you are not the
intended recipient please notify the sender immediately by return email and
then delete the e-mail and any attachments immediately.

The views and or opinions expressed in this e-mail are not necessarily the
views of De La Rue plc or any of its subsidiaries and the De La Rue Group
of companies, their directors, officers and employees make no representation
about and accept no liability for its accuracy or completeness.

You should ensure that you have adequate virus protection as the De La Rue
Group of companies do not accept liability for any viruses.

De La Rue plc Registered No.3834125, De La Rue Holdings plc Registered
No 58025 and De La Rue International Limited Registered No 720284 are all
registered in England with their registered office at:
De La Rue House, Jays Close, Viables, Hampshire RG22 4BS
*
--
http://mail.python.org/mailman/listinfo/python-list

Re: Image Processing (batch)

2008-06-05 Thread Tim Roberts
Thomas Guettler [EMAIL PROTECTED] wrote:

I tried PIL for image batch processing. But somehow I don't like it
  - Font-Selection: You need to give the name of the font file.
  - Drawing on an image needs a different object that pasting and saving.
  - The handbook is from Dec. 2006.

I have repeatedly seen the attitude in your last point, and I simply do not
understand it.  What on Earth is wrong with having a product that actually
becomes stable?

We all complain about Microsoft's feature bloat, rolling out unnecessary
new releases of their products year after year with features that no one
really needs.  But when an open source product FAILS to produce a new
release every six weeks, we start seeing posts questioning whether the
product is still viable or has become abandonware.

Once a product does the job it was designed to do, IT'S DONE.

Personally, I think PIL is a great solution for batch processing, but the
beauty of the open source world is that the ARE alternatives.
-- 
Tim Roberts, [EMAIL PROTECTED]
Providenza  Boekelheide, Inc.
--
http://mail.python.org/mailman/listinfo/python-list


Re: readline() seek() ???

2008-06-05 Thread Tim Roberts
DataSmash [EMAIL PROTECTED] wrote:

I have a text file that contains thousands of lines and each line is
256 characters long.

This is my task:
For each line in the file, move to the 25th character, if the
character is a T,
move to the 35th character of the line and read 5 characters from
there.
Capture these 5 characters and write them to a new text file, each 5
characters separated by a comma.

I appreciate your help!

Did you even TRY this?  Your task reads like pseudocode that translates
virtually line-for-line to Python code.

  fout = open('outputfile.txt','w')
  for line in open('inputfile.txt'):
  if line[24] == 'T':
  fout.write( line[34:39] + ',' )
-- 
Tim Roberts, [EMAIL PROTECTED]
Providenza  Boekelheide, Inc.
--
http://mail.python.org/mailman/listinfo/python-list


Re: line continuation for lines ending in and or or

2008-06-05 Thread Tim Roberts
Dan Bishop [EMAIL PROTECTED] wrote:
On Jun 4, 10:09 pm, Russ P. [EMAIL PROTECTED] wrote:
 I've always appreciated Python's lack of requirement for a semi-colon
 at the end of each line. I also appreciate its rules for automatic
 line continuation. If a statement ends with a +, for example, Python
 recognizes that the statement obviously must continue.

 I've noticed, however, that the same rule does not apply when a line
 ends with and, or, or not. Yes, it's a minor point, but
 shouldn't the same rule apply?

 Seems like it would be easy to add.
...
Implicit line continuation only happens if you have an unmatched '('.

 x = (2 +
... 2
... )
 x
4

... or an unmatched [ or an unmatched {.
-- 
Tim Roberts, [EMAIL PROTECTED]
Providenza  Boekelheide, Inc.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Problem with PEXPECT in Python

2008-06-05 Thread A.T.Hofkamp
On 2008-06-04, Mallikarjun Melagiri [EMAIL PROTECTED] wrote:
 Hi Noah,

   I am new to python. I'm trying to use pexpect.

  Following is my problem definition:

  I should have a script on my machine A, which
 should 'ssh' to machine B and from there it shud copy a file to machine
 C thru 'scp'.

 Please help me.

We don't do your work, unless you pay us.


Instead, start solving the problem.
Think about it, start experimenting/programming, for example first a ssh
connection to B (or even a ssh connection to A would already do as first
step).

When you get stuck, post
 - the code
 - if Python produces an error, the PRECISE and COMPLETE error message,
 - a description of why you think it is a problem
 - a description of what you expect/want.

On such specific problems you will receive good and useful answers.


Sincerely,
Albert
--
http://mail.python.org/mailman/listinfo/python-list


ero magazines

2008-06-05 Thread yura
http://ero-mag.net
--
http://mail.python.org/mailman/listinfo/python-list


Re: os.path.walk -- Can You Limit Directories Returned?

2008-06-05 Thread Gary Herron

Jeff Nyman wrote:

Greetings all.

I did some searching on this but I can't seem to find a specific
solution. I have code like this:

=
def walker1(arg, dirname, names):
DC_List.append((dirname,''))

os.path.walk('vcdcflx006\\Flex\\Sites', walker1, 0)
=

The Sites\ directory is set up like this:

Sites\
   Baltimore
   Birmingham
   

And so forth. Each of the city directories has directories under it as
well. The problem is that my code grabs every single directory that is
under the various city directories when what I really want it to do is
just grab the directories that are under Sites\ and that's it. I don't
want it to recurse down into the sub-directories of the cities.

Is there a way to do this? Or is os.path.walk not by best choice here?
  


Yes.   But first, use the more modern iterator os.walk instead of the 
older function calling os.path.walk.  Then in either case (or at least 
for the os.walk -- I'm a little rusty on the older os.path.walk) you can 
modify in-place the subdirectory listing that was passed to you, thereby 
controlling which subdirectories the walk follows. 


Here's some examples:

for path, dirs, files in os.walk(root):
   if 'etc' in dirs:
   dirs.remove('etc')# Skip any directory named 'etc'
   if path == 'whatever':
   del dirs[:]# Clearing dirs means recurse into NO 
subdirectory of path

   ... process the files of directory path...


Gary Herron


Any help and/or advice would be appreciated.

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


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


Re: os.path.walk -- Can You Limit Directories Returned?

2008-06-05 Thread alex23
On Jun 5, 4:54 pm, Jeff Nyman [EMAIL PROTECTED] wrote:
 The problem is that my code grabs every single directory that is
 under the various city directories when what I really want it to do is
 just grab the directories that are under Sites\ and that's it. I don't
 want it to recurse down into the sub-directories of the cities.

 Is there a way to do this? Or is os.path.walk not by best choice here?

No, os.path.walk will always recurse through all of the sub, that's
its purpose. os.walk produces a generator, which you can then manually
step through if you wish:

_, DC_List, _ = os.walk('vcdcflx006\\Flex\\Sites\\*\\').next()

But I'd recommend checking out the glob module:

from glob import glob
DC_List = glob('vcdcflx006\\Flex\\Sites\\*\\')
--
http://mail.python.org/mailman/listinfo/python-list


Re: Looking for some good python learning resources on the web

2008-06-05 Thread Stefan Behnel
[EMAIL PROTECTED] wrote:
 What are the best sites to read to learn python?

http://wiki.python.org/moin/BeginnersGuide

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


Re: Question regarding re module

2008-06-05 Thread Diez B. Roggisch
Tomohiro Kusumi schrieb:
 Hi,
 
 I have a question regarding re module.
 # By the way I'm not in this list, so I'm sorry but please CC me.
 
 I tried following code in Python shell using a regular expression.
 Why doesn't the result of dir(reg) have 'pattern', 'flags', and
 'groupindex' although they exist as members of _sre.SRE_Pattern
 instance ?
 
 It sort of irritates me, because whenever I write Python code
 using a module which I'm not used to using, I often try Python
 shell with TAB complete to find out the member of module/instance.

It could be that the result overloads the __getattr__-method to delegate
calls to some object. Thus it's not part of the outer instance.

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


Interesting Math Problem

2008-06-05 Thread BEES INC
I've been awfully busy programming lately. My Django-based side
project is coming along well and I hope to have it ready for use in a
few weeks. Please don't ask more about it, that's really all I can say
for now. Anyways, I came across an interesting little math problem
today and was hoping some skilled programmers out there could come up
with a more elegant solution than mine.
Problem: Star Ratings

People can rate cheeseburgers on my website with a star rating of 0-5
stars (whole stars only), 5 being mighty tasty and 0 being disgusting.
I would like to show the average of everyone's ratings of a particular
cheeseburger to the nearest half star. I have already calculated the
average rating as a float (star_sum) and the total number of people
that rated the particular cheeseburger (num_raters). The result should
be stored as a float in a variable named stars.
My Solution (in Python):

# round to one decimal place and
# separate into whole and fractional parts
parts = str(round(star_sum/num_raters, 1)).split('.')
whole = int(parts[0])
frac = int(parts[1])
if frac  3:
___frac = 0
elif frac  7:
___frac = 0
___whole += 1
else:
___frac = 5
# recombine for a star rating rounded to the half
stars = float(str(whole)+'.'+str(frac))

Mmmm… In-N-Out Burgers… Please reply if you've got a better solution.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Why does python not have a mechanism for data hiding?

2008-06-05 Thread Antoon Pardon
On 2008-06-04, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote:
 On Wed, 04 Jun 2008 09:34:58 +, Antoon Pardon wrote:

 On 2008-06-04, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote:
 
 it makes sense to me to also test if they work as documented.
 
 If they affect the behaviour of some public component, that's where
 the documentation should be.

 As I said they are public themselves for someone.
 
 Isn't that contradictory: Public for someone I always
 thought public meant accessible to virtually anyone.
 Not to only someone.

 For the programmer who writes or uses the private API it isn't really
 private, he must document it or know how it works.

How does that make it not private. Private has never meant accessible
to noone. And sure he must document it and know how it works. But that
documentation can remain private, limited to the developers of the
product. It doesn't have to be publicly documented.

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


Squeak-like environment for Python?

2008-06-05 Thread Jumping Arne
I've been playing with Squeak a bit and I really like the persistent storage 
model, I also liked HyperCard and Frontier (well, the persistent storage 
model at least).

I wonder if there is some similar environment but based on python, I would 
like to use this environment not as a development environment but as a 
platform for storing data etc - much like HyperCard.

I found a few postings about such an environment:

http://mail.python.org/pipermail/edu-sig/2006-April/006226.html

but it looks like nothing happened.

pythoncard doesn't seem to have the persistent storage model


Have I missed something obvious?

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


Re: Interesting Math Problem

2008-06-05 Thread Ken Starks

BEES INC wrote:

I've been awfully busy programming lately. My Django-based side
project is coming along well and I hope to have it ready for use in a
few weeks. Please don't ask more about it, that's really all I can say
for now. Anyways, I came across an interesting little math problem
today and was hoping some skilled programmers out there could come up
with a more elegant solution than mine.
Problem: Star Ratings

People can rate cheeseburgers on my website with a star rating of 0-5
stars (whole stars only), 5 being mighty tasty and 0 being disgusting.
I would like to show the average of everyone's ratings of a particular
cheeseburger to the nearest half star. I have already calculated the
average rating as a float (star_sum) and the total number of people
that rated the particular cheeseburger (num_raters). The result should
be stored as a float in a variable named stars.
My Solution (in Python):

# round to one decimal place and
# separate into whole and fractional parts
parts = str(round(star_sum/num_raters, 1)).split('.')
whole = int(parts[0])
frac = int(parts[1])
if frac  3:
___frac = 0
elif frac  7:
___frac = 0
___whole += 1
else:
___frac = 5
# recombine for a star rating rounded to the half
stars = float(str(whole)+'.'+str(frac))

Mmmm… In-N-Out Burgers… Please reply if you've got a better solution.


for raw in [0.05 * n for n in range (41)]:
   rounded = round(2.0*raw)/2.0
   print %0.2f -- %0.2f % (raw,rounded)
--
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting Math Problem

2008-06-05 Thread Iain King
On Jun 4, 9:03 am, BEES INC [EMAIL PROTECTED] wrote:
 I've been awfully busy programming lately. My Django-based side
 project is coming along well and I hope to have it ready for use in a
 few weeks. Please don't ask more about it, that's really all I can say
 for now. Anyways, I came across an interesting little math problem
 today and was hoping some skilled programmers out there could come up
 with a more elegant solution than mine.
 Problem: Star Ratings

 People can rate cheeseburgers on my website with a star rating of 0-5
 stars (whole stars only), 5 being mighty tasty and 0 being disgusting.
 I would like to show the average of everyone's ratings of a particular
 cheeseburger to the nearest half star. I have already calculated the
 average rating as a float (star_sum) and the total number of people
 that rated the particular cheeseburger (num_raters). The result should
 be stored as a float in a variable named stars.
 My Solution (in Python):

 # round to one decimal place and
 # separate into whole and fractional parts
 parts = str(round(star_sum/num_raters, 1)).split('.')
 whole = int(parts[0])
 frac = int(parts[1])
 if frac  3:
 ___frac = 0
 elif frac  7:
 ___frac = 0
 ___whole += 1
 else:
 ___frac = 5
 # recombine for a star rating rounded to the half
 stars = float(str(whole)+'.'+str(frac))

 Mmmm… In-N-Out Burgers… Please reply if you've got a better solution.

It'd be easier just to do the whole thing with ints.  Represents your
stars by counting half-stars (i.e. 0 = no stars, 1 = half a star, 2 =
1 star, etc).  Then you just need to divide by 2 at the end.

stars = round(star_sum/num_raters, 0) / 2.0

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


Re: readline() seek() ???

2008-06-05 Thread Carl Banks
On Jun 4, 5:30 pm, DataSmash [EMAIL PROTECTED] wrote:
 Hi group,
 I have a text file that contains thousands of lines and each line is
 256 characters long.

 This is my task:
 For each line in the file, move to the 25th character, if the
 character is a T,
 move to the 35th character of the line and read 5 characters from
 there.
 Capture these 5 characters and write them to a new text file, each 5
 characters separated by a comma.

Your professor possibly reads comp.lang.python, and if so, is likely
to know how to track you down with your IP address.


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


Re: Interesting Math Problem

2008-06-05 Thread Chuckk Hubbard
On Thu, Jun 5, 2008 at 11:52 AM, Chuckk Hubbard
[EMAIL PROTECTED] wrote:
 On Wed, Jun 4, 2008 at 11:03 AM, BEES INC [EMAIL PROTECTED] wrote:

 My Solution (in Python):

 # round to one decimal place and
 # separate into whole and fractional parts
 parts = str(round(star_sum/num_raters, 1)).split('.')
 whole = int(parts[0])
 frac = int(parts[1])
 if frac  3:
 ___frac = 0
 elif frac  7:
 ___frac = 0
 ___whole += 1
 else:
 ___frac = 5
 # recombine for a star rating rounded to the half
 stars = float(str(whole)+'.'+str(frac))

 def roundstars(invalue):
inv *= 2
inv += .5
return float(int(inv))/2

 seems to work for me.

My mistake:

a = (star_sum/num_raters) * 2
a += .5
stars = float(int(a))/2

-Chuckk


-- 
http://www.badmuthahubbard.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: multiprocessing module (PEP 371)

2008-06-05 Thread pataphor
In article 877a5774-d3cc-49d3-bb64-5cab8505a419
@m3g2000hsc.googlegroups.com, [EMAIL PROTECTED] says...

 I don't see pyprocessing as a drop-in replacement for the threading
 module. Multi-threading and multi-processing code tend to be
 different, unless something like mutable objects in shared memory is
 used as well (cf. Python Shared Objects). If this limitation can
 educate Python programmers to use queues instead of locks and mutable
 objects, even multi-threaded Python programs may actually benefit.
 Some API differences between threading and multiprocessing do not
 matter. Programmers should not consider processes as a drop-in
 replacement for threads.

This is probably not very central to the main intention of your post, 
but I see a terminology problem coming up here. It is possible for 
python objects to share a reference to some other object. This has 
nothing to do with threads or processes, although it can be used as a 
*mechanism* for threads and processes to share data. Another mechanism 
would be some copying and synchronization scheme, which is what posh 
seems to do. Or maybe not, I haven't used posh yet, I just read some 
docs (and I already hate the if process.fork(): idiom, what are they 
trying to do, reintroduce c-style assignment and swiching?).

By the way I haven't done much thread and process programming, but the 
things I *have* done often combine threads and processes, like starting 
a console oriented program in a background process, redirecting the IO 
and communicate with it using an event loop in a thread. I gets more 
complicated when a gui thread is also involved, for example when 
retrofitting a gui interface to an existing terminal based chess or go 
playing program.

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


Re: How to make py2.5 distutil to use VC2005?

2008-06-05 Thread 甜瓜
 The problem is not compiler, but runtime. For example, if python is
 built with runtime foo, and yours with runtime bar, and you use in bar
 a file handle, you're screwed:

 http://msdn.microsoft.com/en-us/library/ms235460(VS.80).aspx

 That's why you cannot build a python extension with VS 2005 for python
 2003, in a reliable way.

Thank you for providing this document. Indeed, passing internal
pointers of one CRT lib to another is dangerous. But in most cases,
the python extension only focus on computational-intensive jobs
rather than API-intensive jobs. Therefore it is safe to let VS2003-built
python to call VS2005-built extensions with some attentions.

When you use distutil to trigger compilation, a special *python script*
will check whether the default compiler is VS2003. If there is no
VS2003, this script will pop-up the error for incompatible compilers.
I really really wonder how to *force* distutil to use my specified compile.
eg: (pseudo)
python setup.py build -c VC2005
or
python setup.py build --compiler=C:\VC8\cc --linker=C:\VC8\ld

   Regards,

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


comp.lang.python

2008-06-05 Thread dev
www.freeservice6.blogspot.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: Squeak-like environment for Python?

2008-06-05 Thread Diez B. Roggisch
Jumping Arne wrote:

 I've been playing with Squeak a bit and I really like the persistent
 storage model, I also liked HyperCard and Frontier (well, the persistent
 storage model at least).
 
 I wonder if there is some similar environment but based on python, I would
 like to use this environment not as a development environment but as a
 platform for storing data etc - much like HyperCard.
 
 I found a few postings about such an environment:
 
 http://mail.python.org/pipermail/edu-sig/2006-April/006226.html
 
 but it looks like nothing happened.
 
 pythoncard doesn't seem to have the persistent storage model

What about ZODB? You can use that to store (more or less) arbitrary objects.
Maybe that can be a foundation, if you throw in 

http://nodebox.net/code/index.php/Home

it might be similar to squeak (I only dimly remember what squeak as a whole
is though - smalltalk  easy multimedia I remember)

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


Re: Image Processing (batch)

2008-06-05 Thread Ulrich Eckhardt
Tim Roberts wrote:
 Thomas Guettler [EMAIL PROTECTED] wrote:

I tried PIL for image batch processing. But somehow I don't like it
  - Font-Selection: You need to give the name of the font file.
  - Drawing on an image needs a different object that pasting and saving.
  - The handbook is from Dec. 2006.
 
 I have repeatedly seen the attitude in your last point, and I simply do
 not understand it.  What on Earth is wrong with having a product that
 actually becomes stable?

Nothing, and it is correct pointing that out. OTOH, there are billions of
open source projects out there that started with an idea but never entered
that finished state where they are useful, so-called abandonware. If the
documentation is old, it is either stable or abandoned. Only a closer look
can tell which of both, but statistically it is more likely that it is
abandoned, sad as it is.

Peace!

Uli

-- 
Sator Laser GmbH
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932

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

Re: Exit from os.chroot()

2008-06-05 Thread Thomas Bellman
Tobiah [EMAIL PROTECTED] writes:

 It is better to make copies of the needed binaries and libraries,
 and *only* them.

 Or symbolic links, of course.  Also, wouldn't links prevent
 the process from puffing actual binaries in /usr/bin?

Well, if you create symlinks from the chroot jail that try to
point to things outside the chroot, you are at least guaranteed
that you won't give the chroot:ed process to much information.
Unfortunately, you won't be giving it the tools it needs to do
its designed job, either, since symlinks can't escape a chroot.


-- 
Thomas Bellman,   Lysator Computer Club,   Linköping University,  Sweden
I don't think [that word] means what you!  bellman @ lysator.liu.se
 think it means.   -- The Princess Bride!  Make Love -- Nicht Wahr!
--
http://mail.python.org/mailman/listinfo/python-list

Python and Harry Potter?

2008-06-05 Thread Helmut Jarausch

Hi,
just to let you know ...

Today I've got an email from Amazon recommending me
Harry Potter and the Deathly Hallows

and they told me why they recommended this book,
because I've bought
Core PYTHON Programming

Didn't know, Harry Potter is a Python fan.


--
Helmut Jarausch

Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany
--
http://mail.python.org/mailman/listinfo/python-list


can you help me

2008-06-05 Thread merzouki tarek
nbsp;
hello 
please, I have this error,nbsp;error C1083nbsp;Cannot open 
include file BaseTsd.h, invalide argument, I installed the platformSDKnbsp;, 
but the 
same error , can you help me 

__
Do You Yahoo!?
En finir avec le spam? Yahoo! Mail vous offre la meilleure protection possible 
contre les messages non sollicités 
http://mail.yahoo.fr Yahoo! Mail --
http://mail.python.org/mailman/listinfo/python-list

Re: multiprocessing module (PEP 371)

2008-06-05 Thread sturlamolden
On Jun 5, 11:02 am, pataphor [EMAIL PROTECTED] wrote:

 This is probably not very central to the main intention of your post,
 but I see a terminology problem coming up here. It is possible for
 python objects to share a reference to some other object. This has
 nothing to do with threads or processes, although it can be used as a
 *mechanism* for threads and processes to share data.

It is complicated in the case of processes, because the object must be
kept in shared memory. The complicating factor is that the base
address of the memory mapping, which is not guaranteed to be the same
in the virtual address space of different processes.



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


Re: The Importance of Terminology's Quality

2008-06-05 Thread Jon Harrop
Robert Maas, http://tinyurl.com/uh3t wrote:
 From: [EMAIL PROTECTED] (David Combs)
 Lisp is *so* early a language (1960?), preceeded mainly only by
 Fortran (1957?)?, and for sure the far-and-away the first as a
 platform for *so many* concepts of computer-science, eg lexical vs
 dynamic (special) variables, passing *unnamed* functions as
 args ... maybe is still the only one in which program and data
 have the same representation -- that it'd seem logical to use it's
 terminology in all languages.
 
 Yeah, but why did you cross-post to so many newsgroups? Are you
 trying to run a flame war between advocates of the various
 languages?

What would be the point? We all know that Java, Perl, Python and Lisp suck.
They don't even have pattern matching over algebraic sum types if you can
imagine that. How rudimentary...

-- 
Dr Jon D Harrop, Flying Frog Consultancy
http://www.ffconsultancy.com/products/?u
--
http://mail.python.org/mailman/listinfo/python-list


Re: Squeak-like environment for Python?

2008-06-05 Thread Bruno Desthuilliers

Diez B. Roggisch a écrit :

Jumping Arne wrote:


I've been playing with Squeak a bit and I really like the persistent
storage model, I also liked HyperCard and Frontier (well, the persistent
storage model at least).

I wonder if there is some similar environment but based on python, I would
like to use this environment not as a development environment but as a
platform for storing data etc - much like HyperCard.

I found a few postings about such an environment:

http://mail.python.org/pipermail/edu-sig/2006-April/006226.html

but it looks like nothing happened.

pythoncard doesn't seem to have the persistent storage model


What about ZODB? You can use that to store (more or less) arbitrary objects.
Maybe that can be a foundation, if you throw in 


http://nodebox.net/code/index.php/Home

it might be similar to squeak (I only dimly remember what squeak as a whole
is though - smalltalk  easy multimedia I remember)


Mainly, Squeak is a (relatively) recent, free implementation of Smalltalk.

disclaimer=please someone correct me if I'm wrong
The persistent storage model - the 'image' storing the whole system 
(code, libs, data, whatever) - is part of the Smalltalk system since 
it's first conception IIRC  (even if some Smalltalk implementations - 
like GNU Smalltalk - are more traditionnaly file-based and have no 
automatic persistence).

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


Re: Python and Harry Potter?

2008-06-05 Thread Marc 'BlackJack' Rintsch
On Thu, 05 Jun 2008 11:58:14 +0200, Helmut Jarausch wrote:

 Today I've got an email from Amazon recommending me
 Harry Potter and the Deathly Hallows
 
 and they told me why they recommended this book,
 because I've bought
 Core PYTHON Programming
 
 Didn't know, Harry Potter is a Python fan.

I would've expected something with more magic, like Perl.  :-)

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


Re: Why does python not have a mechanism for data hiding?

2008-06-05 Thread Marc 'BlackJack' Rintsch
On Thu, 05 Jun 2008 08:21:41 +, Antoon Pardon wrote:

 On 2008-06-04, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote:
 On Wed, 04 Jun 2008 09:34:58 +, Antoon Pardon wrote:

 On 2008-06-04, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote:
 
 it makes sense to me to also test if they work as documented.
 
 If they affect the behaviour of some public component, that's where
 the documentation should be.

 As I said they are public themselves for someone.
 
 Isn't that contradictory: Public for someone I always
 thought public meant accessible to virtually anyone.
 Not to only someone.

 For the programmer who writes or uses the private API it isn't really
 private, he must document it or know how it works.
 
 How does that make it not private. Private has never meant accessible
 to noone. And sure he must document it and know how it works. But that
 documentation can remain private, limited to the developers of the
 product. It doesn't have to be publicly documented.

If the audience is the programmer(s) who implement the private API it
is not private but public.  Even the public API is somewhat private to
a user of a program that uses that API.  The public is not virtually
anyone here.  Depends at which level you look in the system.

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


Re: Squeak-like environment for Python?

2008-06-05 Thread Michael Mabin
Check out the Brainwave platform, which uses a new neural database model.
 It allows you to create databases to store any kind of Python object as a
neuron and allows objects to be connected via link to create complex
structures that don't require conventional tables and columns.
It is a development platform that has a bundled webserver based on CherryPy,
with a built-in application generator and deployer.

http://www.brainwavelive.com

On Thu, Jun 5, 2008 at 6:08 AM, Bruno Desthuilliers
[EMAIL PROTECTED] wrote:

 Diez B. Roggisch a écrit :

  Jumping Arne wrote:

  I've been playing with Squeak a bit and I really like the persistent
 storage model, I also liked HyperCard and Frontier (well, the persistent
 storage model at least).

 I wonder if there is some similar environment but based on python, I
 would
 like to use this environment not as a development environment but as a
 platform for storing data etc - much like HyperCard.

 I found a few postings about such an environment:

 http://mail.python.org/pipermail/edu-sig/2006-April/006226.html

 but it looks like nothing happened.

 pythoncard doesn't seem to have the persistent storage model


 What about ZODB? You can use that to store (more or less) arbitrary
 objects.
 Maybe that can be a foundation, if you throw in
 http://nodebox.net/code/index.php/Home

 it might be similar to squeak (I only dimly remember what squeak as a
 whole
 is though - smalltalk  easy multimedia I remember)


 Mainly, Squeak is a (relatively) recent, free implementation of Smalltalk.

 disclaimer=please someone correct me if I'm wrong
 The persistent storage model - the 'image' storing the whole system
 (code, libs, data, whatever) - is part of the Smalltalk system since it's
 first conception IIRC  (even if some Smalltalk implementations - like GNU
 Smalltalk - are more traditionnaly file-based and have no automatic
 persistence).
 /disclaimer

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




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

Re: Why does python not have a mechanism for data hiding?

2008-06-05 Thread Antoon Pardon
On 2008-06-05, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote:
 On Thu, 05 Jun 2008 08:21:41 +, Antoon Pardon wrote:

 On 2008-06-04, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote:
 On Wed, 04 Jun 2008 09:34:58 +, Antoon Pardon wrote:

 On 2008-06-04, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote:
 
 it makes sense to me to also test if they work as documented.
 
 If they affect the behaviour of some public component, that's where
 the documentation should be.

 As I said they are public themselves for someone.
 
 Isn't that contradictory: Public for someone I always
 thought public meant accessible to virtually anyone.
 Not to only someone.

 For the programmer who writes or uses the private API it isn't really
 private, he must document it or know how it works.
 
 How does that make it not private. Private has never meant accessible
 to noone. And sure he must document it and know how it works. But that
 documentation can remain private, limited to the developers of the
 product. It doesn't have to be publicly documented.

 If the audience is the programmer(s) who implement the private API it
 is not private but public.  Even the public API is somewhat private to
 a user of a program that uses that API.  The public is not virtually
 anyone here.  Depends at which level you look in the system.

I think there is a general consensus about on what level to look when we
are talking about private and public attributes. You can of course
start talking at a whole different level and as such use these words
with a meaning different than normally understood. But that will just
make it harder for you to get your ideas accross.

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


Re: Update

2008-06-05 Thread monika
http://windowsxpprotips.blogspot.com/ windows xp pro tips
http://thebesthealthtips.blogspot.com/the best health tips
http://unwealthyhabits.blogspot.com/ unwealthy habits
http://beautytipsfornewu.blogspot.com/  beauty tips for new u
http://datingattractivewomen.blogspot.com/how to attract a women 4
date
http://gta4-grandtheftauto.blogspot.com/ gta4 grand theft Auto
http://tastyhealthrecipes4u.blogspot.com/ Tasty Healthy Recipes
For Healthy Body and mind
http://aboutreligionphilosophy.blogspot.com/About religion and
philosophy
http://storiesbedtime4u.blogspot.com/Naughty Bed Time Stories
http://bollywoodhollywoodnews.blogspot.com/   Bollywood Hollywood News
And Gossip
--
http://mail.python.org/mailman/listinfo/python-list


Re: Why does python not have a mechanism for data hiding?

2008-06-05 Thread Bruno Desthuilliers

Antoon Pardon a écrit :

On 2008-06-04, NickC [EMAIL PROTECTED] wrote:

On Jun 4, 4:09 am, Russ P. [EMAIL PROTECTED] wrote:

What is it about leading underscores that bothers me? To me, they are
like a small pebble in your shoe while you are on a hike. Yes, you can
live with it, and it does no harm, but you still want to get rid of it.

With leading underscores, you can see *at the point of dereference*
that the code is accessing private data.


@NickC : InMyArms(tm) !


But the leading underscore doesn't tell you whether it is your own
private date, which you can use a you see fit, or those of someone
else, which you have to be very carefull with.


That's why we have __name_mangling too. Consider '_' as 'protected' and 
'__' as private.

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


Re: Python and Harry Potter?

2008-06-05 Thread Casey
Python fan??? Harry speaks Python fluently.  We should all be so
lucky!

I'm told Harry is looking forward to Py3K and getting rid of all the
old (hog)warts 
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python and Harry Potter?

2008-06-05 Thread Michael Mabin
Harry Potter is a Parselmouth.  He can speak to snakes.
Of course, Amazon would get this right!

Sheesh!

On Thu, Jun 5, 2008 at 6:10 AM, Marc 'BlackJack' Rintsch [EMAIL PROTECTED]
wrote:

 On Thu, 05 Jun 2008 11:58:14 +0200, Helmut Jarausch wrote:

  Today I've got an email from Amazon recommending me
  Harry Potter and the Deathly Hallows
 
  and they told me why they recommended this book,
  because I've bought
  Core PYTHON Programming
 
  Didn't know, Harry Potter is a Python fan.

 I would've expected something with more magic, like Perl.  :-)

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




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

Re: Why does python not have a mechanism for data hiding?

2008-06-05 Thread Bruno Desthuilliers

Russ P. a écrit :

(snip)
(answering to Carl Bank) I thought you were saying that encapsulation or so-called 
data
hiding is worthless.


As far as I'm concerned, I view encapsulation as very desirable, and 
data-hidding as totally worthless when applied to Python's object model.



Here's what I think Python should have. I think it should have a
keyword, something like priv, to identify data or functions as
private. As I said earlier, private for class data or functions
(methods) could be implemented like protected in C++. That means
that derived classes would have access to it, but clients of the class
would not. If the client really needs or wants access, he could be
given a sort of back door access similar to the current Python rule
regarding double leading underscores. Thus, the client would have
access, but he would know very well that he is using something that
the original designer did not intend for him to use.




It's just a suggestion. I'm not a language expert, and I realize that
I could be missing something important.


Given your very recent discovery of what 'dynamic' *really* means in 
Python (like, for exemple, dynamically adding / replacing attributes - 
including methods - on a per-class or per-instance basis), possibly, yes.



I also realize, by the way, that Python allows a client of a class to
define a new class member from completely outside the class
definition. Obviously, that cannot be declared private.


Why so ?


But if the
same identifier is already declared private within the class, than the
new definition should not be allowed (because it would defeat the
whole idea of private class members).


Why so ?

Metaprogramming (including monkeypatching) is part of the pythoneer's 
toolbox, and while it's not something to use without pretty good 
reasons, it has many times proven to be a real life saver. In languages 
not allowing it, the solutions to the class of problems easily solved by 
monkeypatching happens to be at best a kludge, at worst plain 
unsolvable, at least without too much effort to be even worth it. Your 
above proposition would arbitrarily make possible and useful things 
either uselessly complicated or near impossible.

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


Re: line continuation for lines ending in and or or

2008-06-05 Thread Larry Bates

Dennis Lee Bieber wrote:

On Wed, 4 Jun 2008 21:50:19 -0700 (PDT), Russ P.
[EMAIL PROTECTED] declaimed the following in comp.lang.python:


Darnit! You're right. I've been reading up on Scala lately, and I
guess I got confused. Well, it wouldn't be a bad idea for Python to do
what I thought it did, *plus* what I said it ought to do.


Is it that much of a difficulty to start multiline expresssions with
a (...

That already covers all the conditions you want... Or just using a
line ending of \
(which I find less appealing than the (... )


I suppose this is a matter of taste.  I find using parenthesis to trigger line 
continuations undesirable.  Lines ending in backslash are explicit and easy to 
mentally parse.


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


Re: Question regarding re module

2008-06-05 Thread Tomohiro Kusumi
Diez,

Thanks, you're right.
Delegated attributes are not in the dir() result.

 getattr(reg, pattern)
'[0-9]+'
 getattr(reg, flags)
0
 getattr(reg, groupindex)
{}

Tomohiro Kusumi

  Tomohiro Kusumi schrieb:
 Hi,

 I have a question regarding re module.
 # By the way I'm not in this list, so I'm sorry but please CC me.

 I tried following code in Python shell using a regular expression.
 Why doesn't the result of dir(reg) have 'pattern', 'flags', and
 'groupindex' although they exist as members of _sre.SRE_Pattern
 instance ?

 It sort of irritates me, because whenever I write Python code
 using a module which I'm not used to using, I often try Python
 shell with TAB complete to find out the member of module/instance.

 It could be that the result overloads the __getattr__-method to delegate
 calls to some object. Thus it's not part of the outer instance.
 
 Diez 



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


Re: os.path.walk -- Can You Limit Directories Returned?

2008-06-05 Thread Jeff Nyman
Thank you to everyone for your help.

Much appreciated. I now have a better understanding of how glob can be
used and I have a much better understanding of using the more
effective os.walk.


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


Creating A Tuple From A List, Adding To Tuple As You Do

2008-06-05 Thread Jeff Nyman
Greetings all.

The subject line of this thread is probably one of the worst ever. I
was trying to encapsulate what I am doing. Based on my new-found
knowledge from another thread, I'm able to get a list of directories
and they come to me in the form of a list. Here is an example:

from glob import glob
DC_List = glob('vcdcflx006\\Flex\\Sites\\*\\')
DC_List = ['Baltimore', 'Birmingham', 'Cincinnati', 'Cleveland',
LosAngeles']

(Each element in the DC_List is actually a full directory path, but I
shortened that in the interest of clarity.)

The problem is that I need to pass this list to a list control in a
wxWidgets application. In order to do that, I need to pass in a list
like this:

[ ('Baltimore', ''), ('Birmingham', ''), ('Cincinnati', ''),
('Cleveland', ''), ('LosAngeles', '') ]

In other words, each element in the list is a tuple that has an empty
second string. The problem I'm having is in converting my list above
to be of this type. I can't do append because that (logically) puts
everything at the end. I did try this:


for count in range(0, len(DC_List)):
DC_List.insert(count, '')


Here I was thinking I could insert a '' into the right place after
each entry in the list. That doesn't quite work. Does anyone have an
idea of a good approach here? (I did search on tuples and lists and
while I found a lot of information about both, I couldn't find a
solution that did what I'm discussing above.)

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


Re: readline() seek() ???

2008-06-05 Thread DataSmash
On Jun 5, 3:50 am, Carl Banks [EMAIL PROTECTED] wrote:
 On Jun 4, 5:30 pm, DataSmash [EMAIL PROTECTED] wrote:

  Hi group,
  I have a text file that contains thousands of lines and each line is
  256 characters long.

  This is my task:
  For each line in the file, move to the 25th character, if the
  character is a T,
  move to the 35th character of the line and read 5 characters from
  there.
  Capture these 5 characters and write them to a new text file, each 5
  characters separated by a comma.

 Your professor possibly reads comp.lang.python, and if so, is likely
 to know how to track you down with your IP address.

 Carl Banks


Marc, Thanks.

Tim, Thanks for the code.  It's a easy task IF you know what to look
for.  I didn't.

Carl, I'm not a student.  Was just looking for some ideas.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Creating A Tuple From A List, Adding To Tuple As You Do

2008-06-05 Thread Karsten Heymann
Jeff Nyman [EMAIL PROTECTED] writes:
 from glob import glob
 DC_List = glob('vcdcflx006\\Flex\\Sites\\*\\')
 DC_List = ['Baltimore', 'Birmingham', 'Cincinnati', 'Cleveland',
 LosAngeles']

 The problem is that I need to pass this list to a list control in a
 wxWidgets application. In order to do that, I need to pass in a list
 like this:

 [ ('Baltimore', ''), ('Birmingham', ''), ('Cincinnati', ''),
 ('Cleveland', ''), ('LosAngeles', '') ]

That's not hard:

[ (x,'') for x in DC_List ]

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


Re: Creating A Tuple From A List, Adding To Tuple As You Do

2008-06-05 Thread Paul McGuire
On Jun 5, 7:41 am, Jeff Nyman [EMAIL PROTECTED] wrote:
 DC_List = ['Baltimore', 'Birmingham', 'Cincinnati', 'Cleveland',
 LosAngeles']

 (Each element in the DC_List is actually a full directory path, but I
 shortened that in the interest of clarity.)

 The problem is that I need to pass this list to a list control in a
 wxWidgets application. In order to do that, I need to pass in a list
 like this:

 [ ('Baltimore', ''), ('Birmingham', ''), ('Cincinnati', ''),
 ('Cleveland', ''), ('LosAngeles', '') ]


tupleized_city_list = [ (city,'') for city in DC_list ]

-- Paul


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


Re: Creating A Tuple From A List, Adding To Tuple As You Do

2008-06-05 Thread Fuzzyman
On Jun 5, 1:41 pm, Jeff Nyman [EMAIL PROTECTED] wrote:
 Greetings all.

 The subject line of this thread is probably one of the worst ever. I
 was trying to encapsulate what I am doing. Based on my new-found
 knowledge from another thread, I'm able to get a list of directories
 and they come to me in the form of a list. Here is an example:

 from glob import glob
 DC_List = glob('vcdcflx006\\Flex\\Sites\\*\\')
 DC_List = ['Baltimore', 'Birmingham', 'Cincinnati', 'Cleveland',
 LosAngeles']




NEW_LIST = [(entry, '') for entry in DC_List]

Does this get you what you want?

Michael Foord
http://www.ironpythoninaction.com

 (Each element in the DC_List is actually a full directory path, but I
 shortened that in the interest of clarity.)

 The problem is that I need to pass this list to a list control in a
 wxWidgets application. In order to do that, I need to pass in a list
 like this:

 [ ('Baltimore', ''), ('Birmingham', ''), ('Cincinnati', ''),
 ('Cleveland', ''), ('LosAngeles', '') ]

 In other words, each element in the list is a tuple that has an empty
 second string. The problem I'm having is in converting my list above
 to be of this type. I can't do append because that (logically) puts
 everything at the end. I did try this:

 for count in range(0, len(DC_List)):
 DC_List.insert(count, '')

 Here I was thinking I could insert a '' into the right place after
 each entry in the list. That doesn't quite work. Does anyone have an
 idea of a good approach here? (I did search on tuples and lists and
 while I found a lot of information about both, I couldn't find a
 solution that did what I'm discussing above.)

 - Jeff

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


Re: Question regarding re module

2008-06-05 Thread Paul McGuire
On Jun 5, 7:11 am, Tomohiro Kusumi [EMAIL PROTECTED]
wrote:

  It could be that the result overloads the __getattr__-method to delegate
  calls to some object. Thus it's not part of the outer instance.


Didn't I read that Py3 will support a __dir__ method so that classes
*could* report such pseudo-attributes in response to dir?

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


Re: re

2008-06-05 Thread David C. Ullrich
On Wed, 04 Jun 2008 20:07:41 +0200, Diez B. Roggisch
[EMAIL PROTECTED] wrote:

 Whitespace is actually \s. But [\s]disc[whatever]
 doesn't do the job - then it won't match (disc),
 which counts as disc appearing as a full word.

Ok, then this works:

Yes it does.

My real question was why doesn't a construction like

  (A|B)C

work as expected. The code below shows that it does.
That puzzled me because I couldn't see any real
difference between your solution here and things
I'd tried that didn't work. But those things also
work in the code below - when I saw this just
now I was even more confused...

Oh. Turns out the actual reason for the confusion wasn't
regex syntax, it was the fact that findall doesn't
return what I thought it did - looking at the result
of findall() it seemed as thought the re was matching
empty strings and whitespace... Looking more
carefully at what findall is supposed to do everything
makes sense.

Sorry to be dense. Remind me to read more than the
first sentence next time:

findall (pattern, string)
Return a list of all non-overlapping matches of pattern in string.
If one or more groups are present in the pattern, return a list of
groups;...

import re

test = 
disc
(disc)
foo disc bar
discuss
.split(\n)

for t in test:
 if re.search(r(^|[^\w])(disc)($|[^\w]), t):
 print success:, t


 Also I think you have ^ and $ backwards, and there's
 a ^ I don't understand. I _think_ that a correct version

Yep, sorry for the confusion.

Diez

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


Re: Creating A Tuple From A List, Adding To Tuple As You Do

2008-06-05 Thread Jeff Nyman
Thanks to everyone who responded!

Yes, those solutions all work and do what I need. I'm also getting
much more familiar with how flexible Python is in terms of its
language. I think that's been the hardest challenge for me. I'm
usually finding I try to overdo it when coming up with solutions.

Once again, many thanks.

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


Re: Books for learning how to write big programs

2008-06-05 Thread s0suk3
On May 22, 12:49 pm, Kurt Smith [EMAIL PROTECTED] wrote:
 On Thu, May 22, 2008 at 10:55 AM, duli [EMAIL PROTECTED] wrote:
  Hi:
  I would like recommendations forbooks(in any language, not
  necessarily C++, C, python) which have walkthroughs for developing
  a big software project ? So starting from inception, problem
  definition, design, coding and final delivery on a single theme
  or application.

 The bigger the project, the more likely it is that you'll have
 documentation on how to use it (for a language or library, how to use
 the features in your program) but to take the time to write up a
 dead-tree book on the project's inception, problem definition,
 design, coding and final delivery is not likely well spent.  Anyone
 who has the expertise to write such a book would probably be spending
 his time working on the next phase of the project itself.

 Someone will probably respond with an amazon link to a book that does
 exactly what you're asking, in which case, I will stand corrected.
 But I'll be surprised.



  Most of the code I have written andbooksthat I have read deal with
  toy programs and I am looking for something a bit more
  comprehensive.  For example, maybe a complete compiler written in C++
  for some language, or a complete web server or implementing
  .net libraries in some language (just a few examples of the scale of
  things I am interested in learning).

 It seems to me the reason toy programs are so prevalent is because
 they illustrate a (few) well defined ideas in a short amount of code.
 A big project, necessarily, brings together all kinds of stuff, much
 of which may not interest the author at all, and so doesn't motivate
 him to write a book about it.

 Compilers, web servers  .NET libraries are *widely* varying areas.
 You may have interest in them all, but to significantly contribute to
 any requires a fair amount of expertise and specialization.

 The best route I've found to learn how to organize  program large
 scale applications is this: find a cutting edge program that interests
 you and that is open source.  Download its source, and read the code.
 Diagram it.  Map it out.  Read the comments.  Join the mailing list
 (probably the developer's list), lurk for a while, and ask questions
 about why they organized things the way they did.  Get the overall big
 picture and learn from it.  Better yet, find out what pitfalls they
 found and avoided (or fell into).  Compare their approach 
 organization with another competing project.  This is the wonder of
 open source software -- you have access to everything, and can learn
 from all the expertise the developers put into their opus.

 You can learn the basics frombooks, but nothing beats analyzing a
 species in the wild.

I think I have lately understood what you mean, thanks to Programming
Python 3rd Ed by Lutz. It doesn't teach Python itself -- the book aims
to teach Python programming at an application level, but I'm starting
to wonder whether that knowledge can be obtained from any book. The
book goes through over 1500 pages (!) giving small- and medium-sized
example programs and describing their details. Roughly after a couple
of hundred pages I started to feel like all that was trivial (isn't
looking at code and figuring their details what we do in our every-day
programmer lifes?), and then started to feel like it was really
useless. Maybe large-scale programming can only be self-thought in
every day life, am I right?.
--
http://mail.python.org/mailman/listinfo/python-list


Re: The Importance of Terminology's Quality

2008-06-05 Thread jon . harrop . ms . sharp
On 5 Giu, 12:37, Jon Harrop [EMAIL PROTECTED] wrote:
 [...]

P.S. Please don't look at my profile (at google groups), thanks!

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


nike shoes jordans prada dunk

2008-06-05 Thread [EMAIL PROTECTED]
China supply
Nike_Air_Max_87,Nike_Air_Max_95,Nike_Air_Max_360,Nike_Air_Max_Ltd,Nike_Air_Max_TN,Nike_Air_Max_Rift,Nike_Shoes_R3,Nike_Shoes_R4,Nike_Shoes_R5,Nike_Shoes_R6,Nike_Shoes_NZ,Nike_Shoes_OZ,Nike_Shoes_TL,Nike_Shoes_Monster,Nike_Sho¬es_Energia,Nike_Shoes_Turob,Air_Force_1s
etc.More please sign in My website!
China supply LV Dunk shoes,UGG Boots,Lacoste Puma trainers,DG Prada
Hogan Dsquared2 etc.-please sign in VIEW PROFILE---


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


Re: Tuples part 2

2008-06-05 Thread [EMAIL PROTECTED]
On Jun 5, 1:37 am, [EMAIL PROTECTED] wrote:
 [EMAIL PROTECTED]:

 Do you mean something like this? (notice the many formatting
 differences, use a formatting similar to this one in your code)

 coords = []

 for i in xrange(1, 5):
 for j in xrange(1, 5):
 for k in xrange(1, 2):
 coords.append( (i, j, k) )

 coords *= 10
 print coords

 Bye,
 bearophile

Hi,

the result i would like is similar to a set of n tuples: tuple_1,
tuple_2,...,tuple_n. I use h in order to enumerate the tuples and
i,j,k would be the coordinates. Maybe something like:

tuple_1=((a,b,c),..,(n,n,n))
.
.
.
tuple_n=((d,e,f),..,(n,n,n))

I hope u can help me with that.

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


Re: Why does python not have a mechanism for data hiding?

2008-06-05 Thread Fuzzyman
On Jun 3, 6:54 pm, sturlamolden [EMAIL PROTECTED] wrote:
 On May 24, 3:41 pm, Sh4wn [EMAIL PROTECTED] wrote:

  first, python is one of my fav languages, and i'll definitely keep
  developing with it. But, there's 1 one thing what I -really- miss:
  data hiding. I know member vars are private when you prefix them with
  2 underscores, but I hate prefixing my vars, I'd rather add a keyword
  before it.

 Python has no data hiding because C++ has (void *).

 Python underscores does some name mangling, but does not attempt any
 data hiding.

 Python and C has about the same approach to data hiding. It is well
 tried, and works equally well in both languages:

# this is mine, keep your filthy paws off!!!

 Irresponsible programmers should not be allowed near a computer
 anyway. If you use data hiding to protect your code from yourself,
 what you really need is some time off to reconsider your career.

So, you are stating that no API programmer using Python *ever* has a
valid or genuine reason for wanting (even if he can't have it) genuine
'hiding' of internal state or members from consumers of his (or
her...) API?

Michael Foord
http://www.ironpythoninaction.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python and Harry Potter?

2008-06-05 Thread Hans Nowak

Helmut Jarausch wrote:

Hi,
just to let you know ...

Today I've got an email from Amazon recommending me
Harry Potter and the Deathly Hallows

and they told me why they recommended this book,
because I've bought
Core PYTHON Programming

Didn't know, Harry Potter is a Python fan.


If you scan the alt.fan.harry-potter archives carefully, you will find at least 
one well-known Python core developer. :-)


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


Re: Python and Flaming Thunder

2008-06-05 Thread John Salerno
Dave Parker [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Kind of like how this year's program won't work on next year's
 Python?  Except Flaming Thunder is faster. ;)

To be fair (and accurate), Python 3.0 has been in development for a long 
time without being marketed for production use. Furthermore, there is no 
reason to think 3.0 will take over next year. It's already been stated 
that it may be years before it does, and meanwhile 2.x will continue to be 
developed.

Also, and this is purely my novice opinion, it seems like the 
incompatibilites are mainly going to come from program written in older 
versions of Python. The big, noticeable changes in 3.0 hardly seem to affect 
anything you'll write in recent versions of Python (and that 2to3 won't fix 
otherwise). 


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


[no subject]

2008-06-05 Thread garywood
Hi there. So I have a challenge in the Python book I am using (python
programming for the absolute beginner) that tells me to improve an ask_number()
function, so that it can be called with a step value, and I havn't
been able to find out yet what's meant by a step value, but i'll keep
looking of course. I'd just be grateful if someone could illimunate
this for me.
def ask_number(question, low, high):Ask for a number within a range.  
  response = Nonewhile response not in range(low, high):response = 
int(raw_input(question))return response
Thanks in advance.
--
http://mail.python.org/mailman/listinfo/python-list

Re: Tuples part 2

2008-06-05 Thread George Sakkis
On Jun 5, 9:26 am, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:
 On Jun 5, 1:37 am, [EMAIL PROTECTED] wrote:



  [EMAIL PROTECTED]:

  Do you mean something like this? (notice the many formatting
  differences, use a formatting similar to this one in your code)

  coords = []

  for i in xrange(1, 5):
  for j in xrange(1, 5):
  for k in xrange(1, 2):
  coords.append( (i, j, k) )

  coords *= 10
  print coords

  Bye,
  bearophile

 Hi,

 the result i would like is similar to a set of n tuples: tuple_1,
 tuple_2,...,tuple_n. I use h in order to enumerate the tuples and
 i,j,k would be the coordinates.

From the pseudocode you wrote at first, tuple_1, tuple_2, ..., tuple_n
would be all equal. Is this intentional, and if so, what's the
purpose ?

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


Re: Python and Flaming Thunder

2008-06-05 Thread John Salerno
Dave Parker [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
On May 20, 7:05 pm, Collin [EMAIL PROTECTED] wrote:

---
For example, consider the two statements:

 x = 8
 x = 10

The reaction from most math teachers (and kids) was one of those is
wrong because x can't equal 2 different things at the same time.
---

Aw, come on. I'm a novice programmer but even after reading the most basic 
of introductions to a programming language I can tell that x is being 
assigned one value, then another.

It doesn't seem fair to take statements like the above out of the context of 
a program and then ask teachers and students about it. This statement:

2 + 2 = 4

means something in the context of an elementary math class, but is clearly 
not an assignment statement in Python. But I've never encountered anyone who 
was confused by this distinction, as long as you know where this line 
belongs. 


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


Re: Python and Harry Potter?

2008-06-05 Thread Bjoern Schliessmann
Casey wrote:

 Python fan??? Harry speaks Python fluently.  We should all be so
 lucky!

 I'm told Harry is looking forward to Py3K and getting rid of all
 the old (hog)warts 

Well, how about another Python renaming flame thread then? Let's
call Python 3.0 Parselmouth instead ...

Regards,


Björn

-- 
BOFH excuse #83:

Support staff hung over, send aspirin and come back LATER.

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


Re: Creating A Tuple From A List, Adding To Tuple As You Do

2008-06-05 Thread John Salerno
Jeff Nyman [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]

 Does anyone have an
 idea of a good approach here?

I think it's pretty cool that all three responses to your question suggested 
the exact same solution. But I guess that in itself is a feature of Python. 
:) 


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


Re: Python and Flaming Thunder

2008-06-05 Thread Dan Upton
On Thu, Jun 5, 2008 at 9:43 AM, John Salerno [EMAIL PROTECTED] wrote:
 Dave Parker [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
 On May 20, 7:05 pm, Collin [EMAIL PROTECTED] wrote:

 ---
 For example, consider the two statements:

 x = 8
 x = 10

 The reaction from most math teachers (and kids) was one of those is
 wrong because x can't equal 2 different things at the same time.
 ---

 Aw, come on. I'm a novice programmer but even after reading the most basic
 of introductions to a programming language I can tell that x is being
 assigned one value, then another.

 It doesn't seem fair to take statements like the above out of the context of
 a program and then ask teachers and students about it. This statement:

 2 + 2 = 4

 means something in the context of an elementary math class, but is clearly
 not an assignment statement in Python. But I've never encountered anyone who
 was confused by this distinction, as long as you know where this line
 belongs.

Yeah, that's sort of like I mentioned earlier in the thread about
there being a time dependence between the two.  Not only that, but I
just realized that Dave has trotted out several times the notion of
representing (and solving) a quadratic equation in FT.  Well, let's
see... (x-9)**2 - 1 = (too lazy to do the expansion to write in ax**2
+ bx + c format) = 0... solve solve solve... wait, x = 8 and x = 10!
But how can that be, Dave?  You and your elementary kids just told me
I can't have two values for x...

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


Re: Interesting Math Problem

2008-06-05 Thread Gary Herron

BEES INC wrote:

I've been awfully busy programming lately. My Django-based side
project is coming along well and I hope to have it ready for use in a
few weeks. Please don't ask more about it, that's really all I can say
for now. Anyways, I came across an interesting little math problem
today and was hoping some skilled programmers out there could come up
with a more elegant solution than mine.
Problem: Star Ratings

People can rate cheeseburgers on my website with a star rating of 0-5
stars (whole stars only), 5 being mighty tasty and 0 being disgusting.
I would like to show the average of everyone's ratings of a particular
cheeseburger to the nearest half star. I have already calculated the
average rating as a float (star_sum) and the total number of people
that rated the particular cheeseburger (num_raters). The result should
be stored as a float in a variable named stars.
  


Much simpler this way.  This produces the number of whole start and the 
number of half stars:


v = ... calculate the average ...
whole = int(v+0.25)
half = int(2*(v+0.25-whole))


Gary Herron




My Solution (in Python):

# round to one decimal place and
# separate into whole and fractional parts
parts = str(round(star_sum/num_raters, 1)).split('.')
whole = int(parts[0])
frac = int(parts[1])
if frac  3:
___frac = 0
elif frac  7:
___frac = 0
___whole += 1
else:
___frac = 5
# recombine for a star rating rounded to the half
stars = float(str(whole)+'.'+str(frac))

Mmmm… In-N-Out Burgers… Please reply if you've got a better solution.
--
http://mail.python.org/mailman/listinfo/python-list
  


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


Re: Interesting Math Problem

2008-06-05 Thread Chuckk Hubbard
On Wed, Jun 4, 2008 at 11:03 AM, BEES INC [EMAIL PROTECTED] wrote:

 My Solution (in Python):

 # round to one decimal place and
 # separate into whole and fractional parts
 parts = str(round(star_sum/num_raters, 1)).split('.')
 whole = int(parts[0])
 frac = int(parts[1])
 if frac  3:
 ___frac = 0
 elif frac  7:
 ___frac = 0
 ___whole += 1
 else:
 ___frac = 5
 # recombine for a star rating rounded to the half
 stars = float(str(whole)+'.'+str(frac))

def roundstars(invalue):
inv *= 2
inv += .5
return float(int(inv))/2

seems to work for me.

 Mmmm… In-N-Out Burgers… Please reply if you've got a better solution.

I've never had the pleasure, but I've heard they're a wonderful experience.

-Chuckk

-- 
http://www.badmuthahubbard.com
--
http://mail.python.org/mailman/listinfo/python-list

Re:

2008-06-05 Thread Quentin Gallet-Gilles
I don't want to spoil the fun, so I'll just say that range is the key
here.

Quentin

On Thu, Jun 5, 2008 at 3:43 PM, garywood [EMAIL PROTECTED] wrote:

  Hi there. So I have a challenge in the Python book I am using (python
 programming for the absolute beginner) that tells me to improve an 
 ask_number()
 function, so that it can be called with a step value, and I havn't
 been able to find out yet what's meant by a step value, but i'll keep
 looking of course. I'd just be grateful if someone could illimunate
 this for me.


 def ask_number(question, low, high):
 Ask for a number within a range.
 response = None
 while response not in range(low, high):
 response = int(raw_input(question))
 return response

 Thanks in advance.


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

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

Re: Tuples part 2

2008-06-05 Thread Ivan Illarionov
On 5 июн, 01:57, [EMAIL PROTECTED] [EMAIL PROTECTED]
wrote:
 Hi Everyone,

 i have another question. What if i wanted to make n tuples, each with
 a list of coordinates. For example :

 coords = list()
 for h in xrange(1,11,1):
for i in xrange(1, 5, 1) :
   for j in xrange(1, 5, 1) :
  for k in xrange(1,2,1) :
 coords.append((i,j,k))
 lista+str(h)= tuple coords
 print tuple(coords)

 so that i will have tuple1, tuple2,..., tupleN, etc. I am trying to do
 it the way i show you above but it is not working properly. I wish you
 could help me with that. Thanks again,

 from itertools import repeat, izip
 coords = tuple((i,j,k) for i in xrange(1,5) for j in xrange(1,5) for k in 
 xrange(1,2))
 locals().update((tuple%s % i, coord) for i, coord  in izip(xrange(1,11), 
 repeat(coords)))
 tuple1
((1, 1, 1), (1, 2, 1), (1, 3, 1), (1, 4, 1), (2, 1, 1), (2, 2, 1), (2,
3, 1), (2
, 4, 1), (3, 1, 1), (3, 2, 1), (3, 3, 1), (3, 4, 1), (4, 1, 1), (4, 2,
1), (4, 3
, 1), (4, 4, 1))

Does this help?

But I don't understand why you need this?

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

Re: Creating A Tuple From A List, Adding To Tuple As You Do

2008-06-05 Thread Karsten Heymann
Hi Jeff,

Jeff Nyman [EMAIL PROTECTED] writes:
 I did try this:

 for count in range(0, len(DC_List)):
 DC_List.insert(count, '')

On additional note: You can be quite sure you'll never have to iterate
over the length of a list (or tuple) in python. Just iterate over the
list itself:

for DC in DC_List:
  # do something with DC.

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


Re: Python and Harry Potter?

2008-06-05 Thread Eduardo O. Padoan
On Thu, Jun 5, 2008 at 10:29 AM, Hans Nowak
[EMAIL PROTECTED] wrote:
 Helmut Jarausch wrote:

 Hi,
 just to let you know ...

 Today I've got an email from Amazon recommending me
 Harry Potter and the Deathly Hallows

 and they told me why they recommended this book,
 because I've bought
 Core PYTHON Programming

 Didn't know, Harry Potter is a Python fan.

 If you scan the alt.fan.harry-potter archives carefully, you will find at
 least one well-known Python core developer. :-)


Maybe Guido himself:
The Harry Potter Theory of Programming Language Design
http://www.artima.com/weblogs/viewpost.jsp?thread=123234




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




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


Proof that \ is a better line joiner than parenthetical sets

2008-06-05 Thread John Salerno
Goofy post of the day...

According to the Zen of Python, explicit is better than implicit, and the 
section in the Reference Manual describing the \ line joiner is called 
Explicit line joining and the section describing parentheticals is called 
Implicit line joining.

So there! ;) 


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


Re: Why does python not have a mechanism for data hiding?

2008-06-05 Thread sturlamolden
On Jun 5, 3:26 pm, Fuzzyman [EMAIL PROTECTED] wrote:

 So, you are stating that no API programmer using Python *ever* has a
 valid or genuine reason for wanting (even if he can't have it) genuine
 'hiding' of internal state or members from consumers of his (or
 her...) API?

 Michael Foordhttp://www.ironpythoninaction.com/

If you are an API programmer, the __all__ attribute of a package or
module provides all the internal data hiding you need.


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


Re: Creating A Tuple From A List, Adding To Tuple As You Do

2008-06-05 Thread Iain King
On Jun 5, 1:41 pm, Jeff Nyman [EMAIL PROTECTED] wrote:
 Greetings all.

 The subject line of this thread is probably one of the worst ever. I
 was trying to encapsulate what I am doing. Based on my new-found
 knowledge from another thread, I'm able to get a list of directories
 and they come to me in the form of a list. Here is an example:

 from glob import glob
 DC_List = glob('vcdcflx006\\Flex\\Sites\\*\\')
 DC_List = ['Baltimore', 'Birmingham', 'Cincinnati', 'Cleveland',
 LosAngeles']

 (Each element in the DC_List is actually a full directory path, but I
 shortened that in the interest of clarity.)

 The problem is that I need to pass this list to a list control in a
 wxWidgets application. In order to do that, I need to pass in a list
 like this:

 [ ('Baltimore', ''), ('Birmingham', ''), ('Cincinnati', ''),
 ('Cleveland', ''), ('LosAngeles', '') ]

 In other words, each element in the list is a tuple that has an empty
 second string. The problem I'm having is in converting my list above
 to be of this type. I can't do append because that (logically) puts
 everything at the end. I did try this:

 for count in range(0, len(DC_List)):
 DC_List.insert(count, '')

 Here I was thinking I could insert a '' into the right place after
 each entry in the list. That doesn't quite work. Does anyone have an
 idea of a good approach here? (I did search on tuples and lists and
 while I found a lot of information about both, I couldn't find a
 solution that did what I'm discussing above.)

 - Jeff

I know a ton of people have already replied with list comprehensions,
but I figured I'd chime in with one that also strips out the path of
your folders for you (since I'm not sure how you are managing that
just now)

cities = [(os.path.basename(x), '') for x in glob('vcdcflx006\\Flex
\\Sites\\*\\')]

I tend to use / instead of \\ as a folder seperator, it should work
for you (I think):
cities = [(os.path.basename(x), '') for x in glob('//vcdcflx006/Flex/
Sites/*')]

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


Re: Tuples part 2

2008-06-05 Thread [EMAIL PROTECTED]
On Jun 5, 3:49 pm, Ivan Illarionov [EMAIL PROTECTED] wrote:
 On 5 ÉÀÎ, 01:57, [EMAIL PROTECTED] [EMAIL PROTECTED]
 wrote:



  Hi Everyone,

  i have another question. What if i wanted to make n tuples, each with
  a list of coordinates. For example :

  coords = list()
  for h in xrange(1,11,1):
 for i in xrange(1, 5, 1) :
for j in xrange(1, 5, 1) :
   for k in xrange(1,2,1) :
  coords.append((i,j,k))
  lista+str(h)= tuple coords
  print tuple(coords)

  so that i will have tuple1, tuple2,..., tupleN, etc. I am trying to do
  it the way i show you above but it is not working properly. I wish you
  could help me with that. Thanks again,
  from itertools import repeat, izip
  coords = tuple((i,j,k) for i in xrange(1,5) for j in xrange(1,5) for k in 
  xrange(1,2))
  locals().update((tuple%s % i, coord) for i, coord  in 
  izip(xrange(1,11), repeat(coords)))
  tuple1

 ((1, 1, 1), (1, 2, 1), (1, 3, 1), (1, 4, 1), (2, 1, 1), (2, 2, 1), (2,
 3, 1), (2
 , 4, 1), (3, 1, 1), (3, 2, 1), (3, 3, 1), (3, 4, 1), (4, 1, 1), (4, 2,
 1), (4, 3
 , 1), (4, 4, 1))

 Does this help?

 But I don't understand why you need this?

 Ivan

Hi,

What i need is, for example:

tuple 1=((1, 1, 1), (1, 2, 1), (1, 3, 1), (1, 4, 1))

tuple 2=((2, 1, 1), (2, 2, 1), (2, 3, 1), (2, 4, 1))

tuple 3=((3, 1, 1), (3, 2, 1), (3, 3, 1), (3, 4, 1))

and so on. Please help me and sorry for not taking the time to post my
questions properly.

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


Re: Tuples part 2

2008-06-05 Thread Ivan Illarionov
On 5 июн, 18:19, [EMAIL PROTECTED] [EMAIL PROTECTED]
wrote:
 On Jun 5, 3:49 pm, Ivan Illarionov [EMAIL PROTECTED] wrote:



  On 5 ÉÀÎ, 01:57, [EMAIL PROTECTED] [EMAIL PROTECTED]
  wrote:

   Hi Everyone,

   i have another question. What if i wanted to make n tuples, each with
   a list of coordinates. For example :

   coords = list()
   for h in xrange(1,11,1):
  for i in xrange(1, 5, 1) :
 for j in xrange(1, 5, 1) :
for k in xrange(1,2,1) :
   coords.append((i,j,k))
   lista+str(h)= tuple coords
   print tuple(coords)

   so that i will have tuple1, tuple2,..., tupleN, etc. I am trying to do
   it the way i show you above but it is not working properly. I wish you
   could help me with that. Thanks again,
   from itertools import repeat, izip
   coords = tuple((i,j,k) for i in xrange(1,5) for j in xrange(1,5) for k 
   in xrange(1,2))
   locals().update((tuple%s % i, coord) for i, coord  in 
   izip(xrange(1,11), repeat(coords)))
   tuple1

  ((1, 1, 1), (1, 2, 1), (1, 3, 1), (1, 4, 1), (2, 1, 1), (2, 2, 1), (2,
  3, 1), (2
  , 4, 1), (3, 1, 1), (3, 2, 1), (3, 3, 1), (3, 4, 1), (4, 1, 1), (4, 2,
  1), (4, 3
  , 1), (4, 4, 1))

  Does this help?

  But I don't understand why you need this?

  Ivan

 Hi,

 What i need is, for example:

 tuple 1=((1, 1, 1), (1, 2, 1), (1, 3, 1), (1, 4, 1))

 tuple 2=((2, 1, 1), (2, 2, 1), (2, 3, 1), (2, 4, 1))

 tuple 3=((3, 1, 1), (3, 2, 1), (3, 3, 1), (3, 4, 1))

 and so on. Please help me and sorry for not taking the time to post my
 questions properly.

 Victor




 coords = [(i, tuple((i,j,k) for j in range(1,5) for k in range(1,2))) for i 
 in range(1,5)]
 locals().update((tuple_%s % i, coord) for i, coord in coords)
 tuple_1
((1, 1, 1), (1, 2, 1), (1, 3, 1), (1, 4, 1))
 tuple_2
((2, 1, 1), (2, 2, 1), (2, 3, 1), (2, 4, 1))
 tuple_3
((3, 1, 1), (3, 2, 1), (3, 3, 1), (3, 4, 1))


Is this what you want?

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

Re: Tuples part 2

2008-06-05 Thread Ivan Illarionov
On 5 июн, 18:19, [EMAIL PROTECTED] [EMAIL PROTECTED]
wrote:
 On Jun 5, 3:49 pm, Ivan Illarionov [EMAIL PROTECTED] wrote:



  On 5 ÉÀÎ, 01:57, [EMAIL PROTECTED] [EMAIL PROTECTED]
  wrote:

   Hi Everyone,

   i have another question. What if i wanted to make n tuples, each with
   a list of coordinates. For example :

   coords = list()
   for h in xrange(1,11,1):
  for i in xrange(1, 5, 1) :
 for j in xrange(1, 5, 1) :
for k in xrange(1,2,1) :
   coords.append((i,j,k))
   lista+str(h)= tuple coords
   print tuple(coords)

   so that i will have tuple1, tuple2,..., tupleN, etc. I am trying to do
   it the way i show you above but it is not working properly. I wish you
   could help me with that. Thanks again,
   from itertools import repeat, izip
   coords = tuple((i,j,k) for i in xrange(1,5) for j in xrange(1,5) for k 
   in xrange(1,2))
   locals().update((tuple%s % i, coord) for i, coord  in 
   izip(xrange(1,11), repeat(coords)))
   tuple1

  ((1, 1, 1), (1, 2, 1), (1, 3, 1), (1, 4, 1), (2, 1, 1), (2, 2, 1), (2,
  3, 1), (2
  , 4, 1), (3, 1, 1), (3, 2, 1), (3, 3, 1), (3, 4, 1), (4, 1, 1), (4, 2,
  1), (4, 3
  , 1), (4, 4, 1))

  Does this help?

  But I don't understand why you need this?

  Ivan

 Hi,

 What i need is, for example:

 tuple 1=((1, 1, 1), (1, 2, 1), (1, 3, 1), (1, 4, 1))

 tuple 2=((2, 1, 1), (2, 2, 1), (2, 3, 1), (2, 4, 1))

 tuple 3=((3, 1, 1), (3, 2, 1), (3, 3, 1), (3, 4, 1))

 and so on. Please help me and sorry for not taking the time to post my
 questions properly.

 Victor

Or even so:

locals().update((tuple_%s % i, tuple((i,j,k) for j in range(1,5) for
k in range(1,2))) for i in range(1,5))


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

Re: Tuples part 2

2008-06-05 Thread Ivan Illarionov
On 5 июн, 18:56, Ivan Illarionov [EMAIL PROTECTED] wrote:
 On 5 июн, 18:19, [EMAIL PROTECTED] [EMAIL PROTECTED]
 wrote:



  On Jun 5, 3:49 pm, Ivan Illarionov [EMAIL PROTECTED] wrote:

   On 5 ÉÀÎ, 01:57, [EMAIL PROTECTED] [EMAIL PROTECTED]
   wrote:

Hi Everyone,

i have another question. What if i wanted to make n tuples, each with
a list of coordinates. For example :

coords = list()
for h in xrange(1,11,1):
   for i in xrange(1, 5, 1) :
  for j in xrange(1, 5, 1) :
 for k in xrange(1,2,1) :
coords.append((i,j,k))
lista+str(h)= tuple coords
print tuple(coords)

so that i will have tuple1, tuple2,..., tupleN, etc. I am trying to do
it the way i show you above but it is not working properly. I wish you
could help me with that. Thanks again,
from itertools import repeat, izip
coords = tuple((i,j,k) for i in xrange(1,5) for j in xrange(1,5) for 
k in xrange(1,2))
locals().update((tuple%s % i, coord) for i, coord  in 
izip(xrange(1,11), repeat(coords)))
tuple1

   ((1, 1, 1), (1, 2, 1), (1, 3, 1), (1, 4, 1), (2, 1, 1), (2, 2, 1), (2,
   3, 1), (2
   , 4, 1), (3, 1, 1), (3, 2, 1), (3, 3, 1), (3, 4, 1), (4, 1, 1), (4, 2,
   1), (4, 3
   , 1), (4, 4, 1))

   Does this help?

   But I don't understand why you need this?

   Ivan

  Hi,

  What i need is, for example:

  tuple 1=((1, 1, 1), (1, 2, 1), (1, 3, 1), (1, 4, 1))

  tuple 2=((2, 1, 1), (2, 2, 1), (2, 3, 1), (2, 4, 1))

  tuple 3=((3, 1, 1), (3, 2, 1), (3, 3, 1), (3, 4, 1))

  and so on. Please help me and sorry for not taking the time to post my
  questions properly.

  Victor

 Or even so:

 locals().update((tuple_%s % i, tuple((i,j,k) for j in range(1,5) for
 k in range(1,2))) for i in range(1,5))

 Ivan

Tried to make it readable:

def iter_coords(i):
for j in xrange(1,5):
for k in xrange(1,2):
yield i, j, k

def iter_vars():
for i in xrange(1, 5):
yield tuple_%s % i, tuple(iter_coords(i))

locals().update(dict(iter_vars()))

 tuple_1
((1, 1, 1), (1, 2, 1), (1, 3, 1), (1, 4, 1))
 tuple_2
((2, 1, 1), (2, 2, 1), (2, 3, 1), (2, 4, 1))
 tuple_3
((3, 1, 1), (3, 2, 1), (3, 3, 1), (3, 4, 1))
 tuple_4
((4, 1, 1), (4, 2, 1), (4, 3, 1), (4, 4, 1))

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

Re: Tuples part 2

2008-06-05 Thread George Sakkis
On Jun 5, 11:21 am, Ivan Illarionov [EMAIL PROTECTED] wrote:
 On 5 июн, 18:56, Ivan Illarionov [EMAIL PROTECTED] wrote:



  On 5 июн, 18:19, [EMAIL PROTECTED] [EMAIL PROTECTED]
  wrote:

   On Jun 5, 3:49 pm, Ivan Illarionov [EMAIL PROTECTED] wrote:

On 5 ÉÀÎ, 01:57, [EMAIL PROTECTED] [EMAIL PROTECTED]
wrote:

 Hi Everyone,

 i have another question. What if i wanted to make n tuples, each with
 a list of coordinates. For example :

 coords = list()
 for h in xrange(1,11,1):
for i in xrange(1, 5, 1) :
   for j in xrange(1, 5, 1) :
  for k in xrange(1,2,1) :
 coords.append((i,j,k))
 lista+str(h)= tuple coords
 print tuple(coords)

 so that i will have tuple1, tuple2,..., tupleN, etc. I am trying to do
 it the way i show you above but it is not working properly. I wish you
 could help me with that. Thanks again,
 from itertools import repeat, izip
 coords = tuple((i,j,k) for i in xrange(1,5) for j in xrange(1,5) 
 for k in xrange(1,2))
 locals().update((tuple%s % i, coord) for i, coord  in 
 izip(xrange(1,11), repeat(coords)))
 tuple1

((1, 1, 1), (1, 2, 1), (1, 3, 1), (1, 4, 1), (2, 1, 1), (2, 2, 1), (2,
3, 1), (2
, 4, 1), (3, 1, 1), (3, 2, 1), (3, 3, 1), (3, 4, 1), (4, 1, 1), (4, 2,
1), (4, 3
, 1), (4, 4, 1))

Does this help?

But I don't understand why you need this?

Ivan

   Hi,

   What i need is, for example:

   tuple 1=((1, 1, 1), (1, 2, 1), (1, 3, 1), (1, 4, 1))

   tuple 2=((2, 1, 1), (2, 2, 1), (2, 3, 1), (2, 4, 1))

   tuple 3=((3, 1, 1), (3, 2, 1), (3, 3, 1), (3, 4, 1))

   and so on. Please help me and sorry for not taking the time to post my
   questions properly.

   Victor

  Or even so:

  locals().update((tuple_%s % i, tuple((i,j,k) for j in range(1,5) for
  k in range(1,2))) for i in range(1,5))

  Ivan

 Tried to make it readable:

 def iter_coords(i):
 for j in xrange(1,5):
 for k in xrange(1,2):
 yield i, j, k

 def iter_vars():
 for i in xrange(1, 5):
 yield tuple_%s % i, tuple(iter_coords(i))

 locals().update(dict(iter_vars()))

locals().update() works by accident here because it's in global scope;
it doesn't work within a function.

Use a proper data structure, like a dict or a list, and access each
tuple list as 'tuples[n]' instead of 'tuple_n'.

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

mod_python installer fails

2008-06-05 Thread RossGK
I've been running python 2.5 for a while on WinXP, working fine.  I
code and compile in PyDev/Eclipse.

I wanted to start playing with Django, but when I go to install
mod_python for Apache 2.2 I get the error:
 python version 2.5 required, which was not found in the registry

from the installer:
 mod_python-3.3.1.win32-py2.5-Apache2.2.exe

I've confirmed that I'm running python25, apache2.2.

I thought maybe I could point to my python, but the next screen that
comes up with blank locating fields takes the cursor but does not
allow any text input.  Does anyone know the solution to this one?

Thanks

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


Re: Import removing first module component

2008-06-05 Thread koblas
On Jun 4, 2:48 pm, David C. Ullrich [EMAIL PROTECTED] wrote:
 In article
 [EMAIL PROTECTED],

  koblas [EMAIL PROTECTED] wrote:
  Have the following line:
          import notewave.runner.LMTP

  Yeilding the following error:
          ImportError: No module named runner.LMTP

  For the life of me I don't understand why the first component
  notewave is being stripped off, when the import is happening.

 Does notewave contain a _module_ named runner.LMTP ?
 Probably not, since the error message says there's no
 such module.

  Thanks,

 --
 David C. Ullrich

The following exist:
   .../notewave/runner/LMTP.py
inside of LMTP.py there is:
   class LMTPRunner(Runner) :

Another person pointed out that I should check on the __init__.py and
make sure lmtp is defined in the __all__ block.  I didn't have an
__init__.py at that level of the tree, which must have been causing
problems, but clearly I don't understand the full inheritance of
__init__.py and sub-directories.
--
http://mail.python.org/mailman/listinfo/python-list


ClassName.attribute vs self.__class__.attribute

2008-06-05 Thread Gabriel Rossetti

Hello everyone,

I had read somewhere that it is preferred to use 
self.__class__.attribute over ClassName.attribute to access class (aka 
static) attributes. I had done this and it seamed to work, until I 
subclassed a class using this technique and from there on things started 
screwing up. I finally tracked it down to self.__class__.attribute! What 
was happening is that the child classes each over-rode the class 
attribute at their level, and the parent's was never set, so while I was 
thinking that I had indeed a class attribute set in the parent, it was 
the child's that was set, and every child had it's own instance! Since 
it was a locking mechanism, lots of fun to debug... So, I suggest never 
using self.__class__.attribute, unless you don't mind it's children 
overriding it, but if you want a truly top-level class attribute, use 
ClassName.attribute everywhere!


I wish books and tutorials mentioned this explicitly

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


Re: Tuples part 2

2008-06-05 Thread Ivan Illarionov
On 5 июн, 19:38, George Sakkis [EMAIL PROTECTED] wrote:
 On Jun 5, 11:21 am, Ivan Illarionov [EMAIL PROTECTED] wrote:



  On 5 июн, 18:56, Ivan Illarionov [EMAIL PROTECTED] wrote:

   On 5 июн, 18:19, [EMAIL PROTECTED] [EMAIL PROTECTED]
   wrote:

On Jun 5, 3:49 pm, Ivan Illarionov [EMAIL PROTECTED] wrote:

 On 5 ÉÀÎ, 01:57, [EMAIL PROTECTED] [EMAIL PROTECTED]
 wrote:

  Hi Everyone,

  i have another question. What if i wanted to make n tuples, each 
  with
  a list of coordinates. For example :

  coords = list()
  for h in xrange(1,11,1):
 for i in xrange(1, 5, 1) :
for j in xrange(1, 5, 1) :
   for k in xrange(1,2,1) :
  coords.append((i,j,k))
  lista+str(h)= tuple coords
  print tuple(coords)

  so that i will have tuple1, tuple2,..., tupleN, etc. I am trying to 
  do
  it the way i show you above but it is not working properly. I wish 
  you
  could help me with that. Thanks again,
  from itertools import repeat, izip
  coords = tuple((i,j,k) for i in xrange(1,5) for j in xrange(1,5) 
  for k in xrange(1,2))
  locals().update((tuple%s % i, coord) for i, coord  in 
  izip(xrange(1,11), repeat(coords)))
  tuple1

 ((1, 1, 1), (1, 2, 1), (1, 3, 1), (1, 4, 1), (2, 1, 1), (2, 2, 1), (2,
 3, 1), (2
 , 4, 1), (3, 1, 1), (3, 2, 1), (3, 3, 1), (3, 4, 1), (4, 1, 1), (4, 2,
 1), (4, 3
 , 1), (4, 4, 1))

 Does this help?

 But I don't understand why you need this?

 Ivan

Hi,

What i need is, for example:

tuple 1=((1, 1, 1), (1, 2, 1), (1, 3, 1), (1, 4, 1))

tuple 2=((2, 1, 1), (2, 2, 1), (2, 3, 1), (2, 4, 1))

tuple 3=((3, 1, 1), (3, 2, 1), (3, 3, 1), (3, 4, 1))

and so on. Please help me and sorry for not taking the time to post my
questions properly.

Victor

   Or even so:

   locals().update((tuple_%s % i, tuple((i,j,k) for j in range(1,5) for
   k in range(1,2))) for i in range(1,5))

   Ivan

  Tried to make it readable:

  def iter_coords(i):
  for j in xrange(1,5):
  for k in xrange(1,2):
  yield i, j, k

  def iter_vars():
  for i in xrange(1, 5):
  yield tuple_%s % i, tuple(iter_coords(i))

  locals().update(dict(iter_vars()))

 locals().update() works by accident here because it's in global scope;
 it doesn't work within a function.

 Use a proper data structure, like a dict or a list, and access each
 tuple list as 'tuples[n]' instead of 'tuple_n'.

 George

OP wanted variables and I showed him how to do this. I agree that a
list or a dict would be better.

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

Nested dictionary displays?

2008-06-05 Thread Robert Dailey
Hi,

I'm using Python 3.0 (the latest as of now) and I have a very large
dictionary that I'm attempting to do some processing on. The dictionary
basically has strings in it, as well as other dictionaries which themselves
also have strings. Using a display, I'm trying to (with as little code
possible) make every single string in the entire dictionary tree lower case
by calling lower() on the string. However, python is not accepting my
syntax. How do I create nested displays? Thanks. The code is below. Note,
also, that the path key/value pair should be skipped. I need to lowercase
the 'path' key, but the value is not a tuple, and that value should be
skipped. The nested display/comprehension logic is at the very bottom.

stage_map = {
#--
system:   {   path :C:\mypath
,   debug :   ( boost_system-mt-gyd.dll, )
,   release : ( boost_system-mt.dll, )
}
#--
,filesystem:  {   path :C:\mypath
,   debug :   ( boost_filesystem-mt-gyd.dll,
)
,   release : ( boost_filesystem-mt.dll, )
}
#--
,librocket :  {   path :C:\mypath
,   debug :   ( EMPCore_d.dll
, EMPCorePython_d.dll
, RocketCore_d.dll
, RocketDebugger_d.dll
, RocketControls_d.dll
)
,   release : ( EMPCore.dll
, EMPCorePython.dll
, RocketCore.dll
, RocketDebugger.dll
, RocketControls.dll
)
}
#--
}

# This does not compile...
stage_map = [i.lower() : [ii.lower() : [iii.lower() for iii in jj if
jj.lower() != path] for ii, jj in j] for i, j in stage_map]
--
http://mail.python.org/mailman/listinfo/python-list

Loading Python programs on the net.

2008-06-05 Thread Noorhan Abbas
Hello,
I have developed a program in Python.  I need to put this program on the web. 
Could somebody advice me on the different tools that I can use to do this job. 
My python program basically displays a tree ctrl that allows users to choose 
from it and displays text as an output.  I need to develop a web page that 
displays this tree ctrl and accesses the text files to produce the output.
Thank you very much,
Nora.


  __
Sent from Yahoo! Mail.
A Smarter Email http://uk.docs.yahoo.com/nowyoucan.html--
http://mail.python.org/mailman/listinfo/python-list

Import text file

2008-06-05 Thread Franck Y
Hello,

I have a text file where there is

xxx=value
yyy=value
zzz=value
etc...

I would like use the from myfile import 

Since it has not the extension py how can i read it ?
I know the way to do it with the open file but i think this one is
easier...
Thansk

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


Re: Import removing first module component

2008-06-05 Thread alex23
On Jun 6, 1:44 am, koblas [EMAIL PROTECTED] wrote:
 Another person pointed out that I should check on the __init__.py and
 make sure lmtp is defined in the __all__ block.  I didn't have an
 __init__.py at that level of the tree, which must have been causing
 problems, but clearly I don't understand the full inheritance of
 __init__.py and sub-directories.

Heya,

If you're not sure about packages, it's covered in the python docs
here:

http://docs.python.org/tut/node8.html#SECTION00840

An __all__ variable doesn't have to be defined, the __init__.py can be
empty, as it's the presence of that file that informs python that the
folder is a package. The example in the docs should help you here.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Import text file

2008-06-05 Thread alex23
On Jun 6, 2:28 am, Franck Y [EMAIL PROTECTED] wrote:
 I have a text file where there is

 xxx=value
 yyy=value
 zzz=value
 etc...

 I would like use the from myfile import 

 Since it has not the extension py how can i read it ?
 I know the way to do it with the open file but i think this one is
 easier...

I don't think you'll be able to use import unless you change the file
extension to .py

If you're in control of the text file and are confident it will only
contain name=value pairs, try:

execfile('your_file.txt')


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


Re: Interesting Math Problem

2008-06-05 Thread MRAB
On Jun 4, 9:03 am, BEES INC [EMAIL PROTECTED] wrote:
 I've been awfully busy programming lately. My Django-based side
 project is coming along well and I hope to have it ready for use in a
 few weeks. Please don't ask more about it, that's really all I can say
 for now. Anyways, I came across an interesting little math problem
 today and was hoping some skilled programmers out there could come up
 with a more elegant solution than mine.
 Problem: Star Ratings

 People can rate cheeseburgers on my website with a star rating of 0-5
 stars (whole stars only), 5 being mighty tasty and 0 being disgusting.
 I would like to show the average of everyone's ratings of a particular
 cheeseburger to the nearest half star. I have already calculated the
 average rating as a float (star_sum) and the total number of people
 that rated the particular cheeseburger (num_raters).
[snip]
I hope you really meant that 'star_sum' was the _sum_ and not the
_average_, otherwise the result would definitely be wrong! :-)
--
http://mail.python.org/mailman/listinfo/python-list


Re: gcc error in Mac OS X

2008-06-05 Thread Zhaojie Boulder
Hi Tommy,
When I typed which gcc,nothing happened,I checked the /usr/bin path myself
and gcc was not there. In fact, the Xcode folder is at the same level with
the usr folder. Is there a way you can install Xcode in the right place? I
did not find such a option during the installation process of Xcode.

Thanks,

Jie

2008/6/4 Tommy Grav [EMAIL PROTECTED]:

 What happens when you run

 which gcc

 Cheers
  Tommy


 On Jun 4, 2008, at 6:50 PM, Zhaojie Boulder wrote:

  Hello,

 I am new to Mac and used python in linux before. What I am trying to do is
 to install Ipython and PyCogent in Mac OS X.

 For PyCogent, after entering the package path, I typed python setup.py
 install. The results are as follows:

 Didn't find Pyrex - will compile from .c files
 running install
 running build
 running build_py
 running build_ext
 building 'cogent.align._compare' extension
 gcc -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd
 -fno-common -dynamic -DNDEBUG -g -Os -Wall -Wstrict-prototypes -DMACOSX
 -I/usr/include/ffi -DENABLE_DTRACE -arch i386 -arch ppc -pipe
 -I/Users/zhaojie/Downloads/PyCogent-1.0.1/include
 -I/System/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5
 -c cogent/align/_compare.c -o
 build/temp.macosx-10.5-i386-2.5/cogent/align/_compare.o -w
 unable to execute gcc: No such file or directory
 error: command 'gcc' failed with exit status 1

 After google, I installed Xcode,but it did not help. Also, the Xcode
 folder is not within applications folder, but a separate one parallel with
 applications. Dragging Xcode folder into the applications folder did not
 make a difference, either.

 Hope someone familiar with Mac can help me out.

 Thank you,

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



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

Re: Proof that \ is a better line joiner than parenthetical sets

2008-06-05 Thread Joshua Kugler
John Salerno wrote:
 According to the Zen of Python, explicit is better than implicit, and
 the section in the Reference Manual describing the \ line joiner is called
 Explicit line joining and the section describing parentheticals is
 called Implicit line joining.
 
 So there! ;)

However, according to the Zen of Python, the line before 

Explicit is better than implicit.

says:

Beautiful is better than ugly.

And I think putting parenthesis around a multi-line statement is much
prettier.

So there! :)

j


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


Re: Tuples part 2

2008-06-05 Thread George Sakkis
On Jun 5, 11:48 am, Ivan Illarionov [EMAIL PROTECTED] wrote:
 On 5 июн, 19:38, George Sakkis [EMAIL PROTECTED] wrote:



  On Jun 5, 11:21 am, Ivan Illarionov [EMAIL PROTECTED] wrote:

   On 5 июн, 18:56, Ivan Illarionov [EMAIL PROTECTED] wrote:

On 5 июн, 18:19, [EMAIL PROTECTED] [EMAIL PROTECTED]
wrote:

 On Jun 5, 3:49 pm, Ivan Illarionov [EMAIL PROTECTED] wrote:

  On 5 ÉÀÎ, 01:57, [EMAIL PROTECTED] [EMAIL PROTECTED]
  wrote:

   Hi Everyone,

   i have another question. What if i wanted to make n tuples, each 
   with
   a list of coordinates. For example :

   coords = list()
   for h in xrange(1,11,1):
  for i in xrange(1, 5, 1) :
 for j in xrange(1, 5, 1) :
for k in xrange(1,2,1) :
   coords.append((i,j,k))
   lista+str(h)= tuple coords
   print tuple(coords)

   so that i will have tuple1, tuple2,..., tupleN, etc. I am trying 
   to do
   it the way i show you above but it is not working properly. I 
   wish you
   could help me with that. Thanks again,
   from itertools import repeat, izip
   coords = tuple((i,j,k) for i in xrange(1,5) for j in 
   xrange(1,5) for k in xrange(1,2))
   locals().update((tuple%s % i, coord) for i, coord  in 
   izip(xrange(1,11), repeat(coords)))
   tuple1

  ((1, 1, 1), (1, 2, 1), (1, 3, 1), (1, 4, 1), (2, 1, 1), (2, 2, 1), 
  (2,
  3, 1), (2
  , 4, 1), (3, 1, 1), (3, 2, 1), (3, 3, 1), (3, 4, 1), (4, 1, 1), (4, 
  2,
  1), (4, 3
  , 1), (4, 4, 1))

  Does this help?

  But I don't understand why you need this?

  Ivan

 Hi,

 What i need is, for example:

 tuple 1=((1, 1, 1), (1, 2, 1), (1, 3, 1), (1, 4, 1))

 tuple 2=((2, 1, 1), (2, 2, 1), (2, 3, 1), (2, 4, 1))

 tuple 3=((3, 1, 1), (3, 2, 1), (3, 3, 1), (3, 4, 1))

 and so on. Please help me and sorry for not taking the time to post my
 questions properly.

 Victor

Or even so:

locals().update((tuple_%s % i, tuple((i,j,k) for j in range(1,5) for
k in range(1,2))) for i in range(1,5))

Ivan

   Tried to make it readable:

   def iter_coords(i):
   for j in xrange(1,5):
   for k in xrange(1,2):
   yield i, j, k

   def iter_vars():
   for i in xrange(1, 5):
   yield tuple_%s % i, tuple(iter_coords(i))

   locals().update(dict(iter_vars()))

  locals().update() works by accident here because it's in global scope;
  it doesn't work within a function.

  Use a proper data structure, like a dict or a list, and access each
  tuple list as 'tuples[n]' instead of 'tuple_n'.

  George

 OP wanted variables and I showed him how to do this. I agree that a
 list or a dict would be better.

 Ivan

Generating variable names at runtime doesn't work for locals and it is
a bad solution for globals in 99.9% of the cases. It is usually more
helpful to point someone who can't even express his problem clearly to
the right direction, rather than taking his pseudocode literally and
coming up with a semi-working translation.

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

Re: Pylons and memory use?

2008-06-05 Thread Joshua Kugler
John Salerno wrote:
 Hi everyone. I was thinking about signing up with a web host that
 supports Pylons (among many other things) and one of the differences
 between the various plans is application memory for long-running
 processes. The plan I'd like to sign up for has 80MB. Does anyone know
 if this is enough for basic Pylons applications?
 
 Just in general, how exactly can I calculate how much memory a Pylons
 application (or any other type of application, for that matter) will
 require? Is there some general range I might be able to rely on? Does
 80MB seem like enough for just playing around and hobbyist work?

It would depend on what they define as long running processes.  If the
Python setup is correct, I would assume that it would be running under
mod_python or FastCGI or some such, and would not be considered a long
running process as such.  I would assume the long running process would be
something other than the web app you want running in the back ground. Maybe
a queue processor, or something along those lines.

You may wish to ask for clarification.  Sorry I can't help regarding memory
usage, you may wish to ask in the Pylons IRC channel or on their mailing
list.

j

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


Re: gcc error in Mac OS X

2008-06-05 Thread Zhaojie Boulder
Hi Tommy,

When I typed which gcc,nothing happened,I checked the /usr/bin path myself
and gcc was not there. In fact, the Xcode folder is at the same level with
the usr folder. Is there a way you can install Xcode in the right place? I
did not find such a option during the installation process of Xcode.
Thanks

Jie

2008/6/4 Tommy Grav [EMAIL PROTECTED]:

 What happens when you run

 which gcc

 Cheers
  Tommy


 On Jun 4, 2008, at 6:50 PM, Zhaojie Boulder wrote:

  Hello,

 I am new to Mac and used python in linux before. What I am trying to do is
 to install Ipython and PyCogent in Mac OS X.

 For PyCogent, after entering the package path, I typed python setup.py
 install. The results are as follows:

 Didn't find Pyrex - will compile from .c files
 running install
 running build
 running build_py
 running build_ext
 building 'cogent.align._compare' extension
 gcc -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd
 -fno-common -dynamic -DNDEBUG -g -Os -Wall -Wstrict-prototypes -DMACOSX
 -I/usr/include/ffi -DENABLE_DTRACE -arch i386 -arch ppc -pipe
 -I/Users/zhaojie/Downloads/PyCogent-1.0.1/include
 -I/System/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5
 -c cogent/align/_compare.c -o
 build/temp.macosx-10.5-i386-2.5/cogent/align/_compare.o -w
 unable to execute gcc: No such file or directory
 error: command 'gcc' failed with exit status 1

 After google, I installed Xcode,but it did not help. Also, the Xcode
 folder is not within applications folder, but a separate one parallel with
 applications. Dragging Xcode folder into the applications folder did not
 make a difference, either.

 Hope someone familiar with Mac can help me out.

 Thank you,

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



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

Re: Why does python not have a mechanism for data hiding?

2008-06-05 Thread Russ P.
On Jun 5, 4:47 am, Bruno Desthuilliers bruno.
[EMAIL PROTECTED] wrote:
 Antoon Pardon a écrit :

  On 2008-06-04, NickC [EMAIL PROTECTED] wrote:
  On Jun 4, 4:09 am, Russ P. [EMAIL PROTECTED] wrote:
  What is it about leading underscores that bothers me? To me, they are
  like a small pebble in your shoe while you are on a hike. Yes, you can
  live with it, and it does no harm, but you still want to get rid of it.
  With leading underscores, you can see *at the point of dereference*
  that the code is accessing private data.

 @NickC : InMyArms(tm) !

  But the leading underscore doesn't tell you whether it is your own
  private date, which you can use a you see fit, or those of someone
  else, which you have to be very carefull with.

 That's why we have __name_mangling too. Consider '_' as 'protected' and
 '__' as private.

Only in some vague, fuzzy sense.

My understanding is that the single underscore in a class definition
is a convention only and has no actual effect whatsoever. In C++ (and
Java?), on the other hand, the protected keyword *really* prevents
the client from accessing the data or method, but it allows access to
derived classes. The private keyword goes further and prevents
access even by derived classes. The double leading underscore in
Python does no such thing.

By the way, people often claim that friend classes in C++ violate
encapsulation. That is a common misunderstanding. They do not violate
encapsulation because a class must declare its own friends. In other
words, the determination of who gets acces to the private data in a
class is determined within the class itself. Declaring another class a
friend gives it access to your data but does not give you access to
its data. (At least that's my recollection, though I haven't used C++
for several years.)
--
http://mail.python.org/mailman/listinfo/python-list


Re: Help need with subprocess communicate

2008-06-05 Thread Daniel Klein
On Tue, 3 Jun 2008 23:48:38 -0700 (PDT), [EMAIL PROTECTED] wrote:

On Jun 3, 11:23 pm, Dennis Lee Bieber [EMAIL PROTECTED] wrote:
 On Tue, 3 Jun 2008 18:04:40 -0700 (PDT), [EMAIL PROTECTED] declaimed the
 following in comp.lang.python:



  Hi Daniel,
  Thanks for your reply..
  I've done exactly as you suggested...but I'm still having problem with
  the read...it just gets stuck in
  the read ( I think because its a blocking read...)

 And it is likely blocking because the subprocess is doing buffered
 output -- ie, nothing is available to be read because the output has not
 been flushed.

 This is a problem with most programs when run as a subprocess -- it
 is common for stdout, when routed to a pipe or file, to behave as a
 buffered stream that only flushes when some x-bytes have been written;
 unlike stdout to a console which gets flushed on each new-line.
 --
 WulfraedDennis Lee Bieber   KD6MOG
 [EMAIL PROTECTED]  [EMAIL PROTECTED]
 HTTP://wlfraed.home.netcom.com/
 (Bestiaria Support Staff:   [EMAIL PROTECTED])
 HTTP://www.bestiaria.com/


Is there way to configure the stdout buffer size so that it flushes
earlier..
Is there a way to make above mentioned piece code working?

I'm not so sure it is a buffer problem. To test this out I first created a
'p2.py' script...

from subprocess import *
import os
p=Popen('ConsoleApplication1.exe',stdin=PIPE,stdout=PIPE,universal_newlines=True)
print p.stdout.readline()[:-1] # strip \n from end of line
p.stdin.write('hi' + os.linesep)
print p.stdout.readline()[:-1]
p.stdin.write('bye' + os.linesep)
print p.stdout.readline()[:-1]
p.stdin.close()
p.stdout.close()

I then created the following VB console application (this is the 'process'
that is being 'Popen'd and is in my %PATH%)...

Module Module1
Dim x As String
Sub Main()
Console.WriteLine(Process started...)
x = Console.ReadLine()
Console.WriteLine(x)
x = Console.ReadLine()
Console.WriteLine(x)
End Sub
End Module

Here is the output when I run it...

C:\home\pythonpython p2.py
Process started...
hi
bye

Note that I didn't have to 'flush()' anything.

I got the same thing working with a C program. I don't know why it won't
work with a similar python script...

import sys
sys.stdout.write('process started...\n')
r = sys.stdin.readline()
sys.stdout.write(r + '\n')
s = sys.stdin.readline()
sys.stdout.write(s + '\n')

I called this 'p3.py'. When I plug this into the 'p2.py' script I get
nothing, it just hangs. So maybe there is something else I am missing.

I normally don't do things this way cos there are os size limits to what you
can send/recv, so I use my own protocol (similar to netstrings)  for
communication.

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


Re: ANN: Resolver One 1.1 released

2008-06-05 Thread Laura Creighton
Hey, Congratulations!

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


Re: Why does python not have a mechanism for data hiding?

2008-06-05 Thread George Sakkis
On Jun 5, 2:07 pm, Russ P. [EMAIL PROTECTED] wrote:

 The private keyword goes further and prevents
 access even by derived classes. The double leading underscore in
 Python does no such thing.

Who develops these derived classes ? A competitor ? A malicious
hacker ? A spammer ? Who are you trying to hide your precious classes
from that the double leading underscore is not good enough
protection ? Even with a 'private' keyword, what stops them from doing
s/private/public/g ? Seriously, the underscores are ugly argument
has some merit but language enforced data hiding is overrated, if not
downright silly.
--
http://mail.python.org/mailman/listinfo/python-list


Please unregister this mail-address out of mailing-list.

2008-06-05 Thread Hank @ITGroup

Dear Python Staff,
I am writing this letter to unsubscribe this mail-address from python 
mail-list. One problem is that this python community is so active that I 
always lost myself to find my business emails. So, I want to quit this 
mail-address from you, and want to set up a specific mail-box to receive 
all python mails.
Since could find a way to unsubscribe the mails, I need to write this 
letter to you. Please help.


BTW, python is indeed great, thank you all for any supports.

Hank.

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


  1   2   3   >