[ANN] pyx12-1.4.0 released

2007-05-11 Thread John Holland
pyx12-1.4.0 is available at http://pyx12.sourceforge.net/

What is Pyx12?
==
Pyx12 is a HIPAA X12 document validator and converter. X12 files are a
form of electronic data interchange.  The HIPAA transaction standard
requires certain types of healthcare data to be transmitted in this
form.

Pyx12 parses an ANSI X12N (Healthcare) data file and validates it
against a representation of the Implementation Guidelines for a HIPAA
transaction. By default, it creates a 997 response. It can also create
an HTML representation of the X12 document or can translate to and
from several XML representations of the data file.


What's New:
===
This is primarily a feature release:

Run-time Map Customization:
The validation specifications for each X12 transaction are contained
in XML files (map files). For a particular transaction, the map file
describes the loops, segments, and elements; their relationships,
their requirement conditions; and their data types. As XML files,
their contents can be altered using XSL transformations. The parsing
and validation of an X12 document can be altered by giving one or more
XSLT files as command line arguments. The XSLT files are applied to
the correct map for the X12 document in turn. Using this feature, the
validation of the document can be made more or less restrictive.

The XSL transform should be written so that it only affects the
intended map file. Applying the XSLT to any other map should result in
no change. Also, the resulting XML map must validate against the XML
Schema file 'map.xsd'.

Regular Expression Element Value Validation:
XSL transforms can also be used to apply a regular expression to a map
element node. This allows further element value validation. See
example XSLT files in %PYTHONDIR%\test\files and the XML Schema file
'map.xsd' for more details. For syntax, see python regular expression
syntax.

Windows installation using the python generated EXE file has been
fixed.  Map location lookups have been fixed.  See
http://pyx12.sourceforge.net/install.html for more information.

The original maps (pre A1) have been removed from the package.

XML Schemas for the maps and for dataele.xml have been created.
Non-conforming maps have been fixed.

License
===

pyx12 is released under the BSD license.

===
John Holland
Kalamazoo Community Mental Health and Substance Abuse Services
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

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


ANN: Front Range Pythoneers Meeting, Wed, May 16, 6-8 PM, in Boulder, Colorado - Weather Research with Python

2007-05-11 Thread frpythoneers
== Meeting: Wednesday, May 16, 2007 ==

 * Time: 6-8 PM

 * Location: bivio Software, Inc., 28th and Iris, Boulder, CO. Above
   Hair Elite in Suite S. There is abundant parking.

This coming Wednesday, May 16, we have two researchers from the
National Center for Atmospheric Research (NCAR) in Boulder presenting
how they use Python as part of their weather research:

 * Joe VanAndel will present Linux and Python at 20,000 Meters Above
   the Sea, a NCAR/CNES dropsonde project that investigated the
   hurricane formation zone off the west coast of Africa. After
   introducing the driftsonde project, he will discuss how Linux was
   used in the on-board gondola computer and explain how using the
   Python programming language facilitated reprogramming the gondola
   in the middle of a flight.

 * Mary Haley will present Python Frameworks for Geoscience
   Visualization and Analysis. PyNGL and PyNIO are Python interfaces
   to a widely popular software package called the NCAR Command
   Language (NCL) for the access, analysis, and high-quality
   quantitative visualization of geoscientific data. Mary will briefly
   discuss NCL's history, and then segue into why Python was chosen
   for developing the next generation framework tools for file
   input/output, analysis and visualization. She will show an
   animation from a new high resolution Community Climate System Model
   (CCSM) run computed on a T341 grid (1024 points in longitude by 512
   points in latitude) that was created using NCAR's new Python
   interfaces to NCL and other post production utilities.


Some upcoming events you might be interested in:

 * Front Range Code Camp. Saturday, May 19. This would be an good
   setting to have a Python code jam.

 * Pythoneers Meeting, June 18. Steve Bethard from CU will present on
   Python and Natural Language Processing.

 * SciPy 2007 Conference, Aug 16-17. Held on the CalTech campus in
   Pasadena, CA, Aug 16-17. The deadline for abstracts is June 29.

We will have food  drink available as usual.  This includes our usual
free beer!

Hope to see you there Wednesday!
More details: http://wiki.python.org/moin/FrontRangePythoneers

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

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


Jython 2.2 Beta2 is available

2007-05-11 Thread Charlie Groves
I'm happy to announce that Jython 2.2-beta2 is available for download:
http://sourceforge.net/project/showfiles.php?group_id=12867package_id=12218release_id=507592
See http://jython.org/Project/installation.html for installation instructions.

This is the second and final beta release towards the 2.2 version of
Jython.  It includes fixes for more than 30 bugs found since the first
beta and the completion of Jython's support for new-style classes.

Enjoy!

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

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


Re: how to refer to partial list, slice is too slow?

2007-05-11 Thread 人言落日是天涯,望极天涯不见家
I make a sample here for the more clearly explanation

s =  . - this is a large string data - ...

def parser1(data)
 # do some parser
 ...
 # pass the remainder to next parser
 parser2(data[100:])

def parser2(data)
 # do some parser
 ...
 # pass the remainder to next parser
 parser3(data[100:])

def parser3(data)
 # do some parser
 ...
 # pass the remainder to next parser
 parser4(data[100:])

...


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

Re: how to refer to partial list, slice is too slow?

2007-05-11 Thread Martin v. Lo
人言落日是天涯,望极天涯不见家 schrieb:
 I'm a python newbie. It seems the slice operation will do copy.
 for example:
 a = [1,2,3,4,5,6,7,8,9,0]
 b = a[7:]
 b
 [8, 9, 0]
 a.remove(9)
 a
 [1, 2, 3, 4, 5, 6, 7, 8, 0]
 b
 [8, 9, 0]
 
 if the list have large members, the slice operations will consume many
 times.
 for instance, I have a long string named it as S, the size is more
 than 100K
 I want to parser it one part-to-part. first, I process the first 100
 byte, and pass the remainder to the next parser function. I pass the
 S[100:] as an argument of the next parser function. but this operation
 will cause a large bytes copy. Is there any way to just make a
 reference to the remainder string not copy?

You can use itertools.islice:

py a = [1,2,3,4,5,6,7,8,9,0]
py b = itertools.islice(a, 7)
py b
itertools.islice object at 0xb7d9c34c
py b.next()
1
py b.next()
2
py b.next()
3
py b.next()
4
py b.next()
5
py b.next()
6
py b.next()
7
py b.next()
Traceback (most recent call last):
  File stdin, line 1, in ?
StopIteration

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

Re: SQLObject 0.9.0

2007-05-11 Thread Martin v. Löwis
 For reasons others will know, there are different branches to the
 SQLObject project. I think, analogously, python still has an active 2.4
 branch, if that helps make sense of maintaining branches based on
 versions. I'm not sure why the announcements aren't bundled into one
 because just about everyone who sees this for the first time asks the
 same question.

For the community being addressed (namely, users of SQLObject), this
form provides a useful service:
- they know that three branches are actively being maintained (0.7,
  0.8, and 0.9). I would expect that in particular users of the 0.7
  branch are glad to see that 0.7 is still alive even though 0.9 was
  just started. This is indeed more than is common, so releasing 0.7.7
  simultaneously sends a clear message of affirmation (I explicitly
  looked for a notice that this would be the last 0.7 release, and
  found none)
- for each branch, there is a list of changes for the branch, and
  I can easily see what changed in the version I'm interested in.
  Googling for old release announcements (e.g. SQLObject 0.7.5) brings
  up the announcement on hit 2, so I can also easily find announcemnts
  if I missed one.

Those not using SQLObject, or even see this for the first time, this
form gives the project higher attention than other projects - so it
may attract users. It may also shy away users if they think this
obsessive form of sending three usenet articles in a single hour
is spam, but I guess the author is willing to take that risk.

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


Re: which is more pythonic/faster append or +=[]

2007-05-11 Thread Alex Martelli
Peter Otten [EMAIL PROTECTED] wrote:

 Note the -s before the initialization statement that Alex meant to add but
 didn't. If that is missing 

Yep, sorry for erroneously skipping the -s!


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


Re: How to find C source

2007-05-11 Thread Martin v. Löwis
Gabriel Genellina schrieb:
 En Thu, 10 May 2007 21:47:39 -0300, [EMAIL PROTECTED] escribió:
 
 How do I get to the source for parser.suite()?
 
 Are you looking for function parser_suite in parsermodule.c?

To give some URL for convenience:

http://svn.python.org/projects/python/trunk/Modules/parsermodule.c

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


Simple Tkinter Progress Bar

2007-05-11 Thread Gurpreet Singh
Hi 
 
I am a newbie in Python

I am creating a simple Tkinter based application. 
I have written Tkinter GUI source code and the
programme logic in the same .py file.

I am searching for a way to implement a simple
Progress bar for my application.

Are there any simple ways of doin it. 




   
Yahoo!
 oneSearch: Finally, mobile search 
that gives answers, not web links. 
http://mobile.yahoo.com/mobileweb/onesearch?refer=1ONXIC
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to find C source

2007-05-11 Thread castironpi
On May 10, 8:36 pm, Gabriel Genellina [EMAIL PROTECTED]
wrote:
 En Thu, 10 May 2007 21:47:39 -0300, [EMAIL PROTECTED] escribió:

  How do I get to the source for parser.suite()?

 Are you looking for function parser_suite in parsermodule.c?

 --
 Gabriel Genellina

Looks like -it-.  Thank you for your time.

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


module error for elementtree

2007-05-11 Thread saif . shakeel
#!/usr/bin/env python


from elementtree import ElementTree as Element
tree = et.parse(testxml.xml)


for t in tree.getiterator(SERVICEPARAMETER):
if t.get(Semantics) == localId:
t.set(Semantics, dataPackageID)


tree.write(output.xml)


Hi,
 For the above code to work elementtree is
imported in first line ,but when running it says :
ImportError: No module named elementtree.ElementTree
Does thie module exists as default or a patch is needed?
Thanks

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


Re: High resolution sleep (Linux)

2007-05-11 Thread Laurent Pointal
John a écrit :
 Anyways, what I need is high resolution sleep, not high resolution
 timing. Installing a real time OS seems like overkill.

IDEA Maybe try creating threading.Event and waiting for it with a timeout.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: module error for elementtree

2007-05-11 Thread half . italian
On May 11, 12:05 am, [EMAIL PROTECTED] wrote:
 #!/usr/bin/env python

 from elementtree import ElementTree as Element
 tree = et.parse(testxml.xml)

 for t in tree.getiterator(SERVICEPARAMETER):
 if t.get(Semantics) == localId:
 t.set(Semantics, dataPackageID)

 tree.write(output.xml)

 Hi,
  For the above code to work elementtree is
 imported in first line ,but when running it says :
 ImportError: No module named elementtree.ElementTree
 Does thie module exists as default or a patch is needed?
 Thanks

http://groups.google.com/group/comp.lang.python/browse_frm/thread/e095cc79d1efb99/a4523a6e9b7061af?rnum=1#a4523a6e9b7061af

Read carefully.

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


Re: Change serial timeout per read

2007-05-11 Thread Hendrik van Rooyen

 [EMAIL PROTECTED] wrote:



 What I actually want to do is to respond immediately if the expected
 string comes in, but not raise a timeout unless it takes longer than
 the maximum time. So if the device I'm communicating with usually
 responds in a second, but _can_ take up to 20 seconds, I don't want to
 do a sleep(20) then read the port since this will slow everything down
 a lot in an average world. I want to keep checking for the expected
 string, and act upon it as soon as I've got it, only raising a timeout
 if I haven't got it after 20 seconds. I guess to do this using non-
 blocking calls I have to do something like:
 timesofar = 0
 returnstring = port.read(1)
 while len(returnstring)expectedlength:
 if timesofar = timeout:
 raise SerialException('Timeout')
 time.sleep(checkportinterval)
 timesofar += checkpointinterval
 returnstring += port.read(1)
 
 This seems rather messy. What I've tried this morning is to produce a
 modified version of uspp with a second optional timeout parameter in
 its read() function. If this is present, the timeout given is sent to
 the port using SetCommTimeouts(). If it's not present, the timeouts
 specified when the port was opened are sent. At first sight, with
 minimal testing on Windows, this seems to be working, and will leave
 my application code a lot cleaner than the non-blocking plus sleep
 approach. Of course I don't know whether my method will work on Linux,
 and there may be problems I haven't found yet.

If it works it works - no problem with that - fight the 
dragons as you meet them, one at a time.

I normally put something like this in a read function 
(from memory, not tested):

error = 0
k = ''
try:
  k = port.read(1)
except IoError:
  error = 1
return error,k

For this to work, you have to first unblock the port using fcntl:

def unblock(f):
  given file f sets unblock flag to true

  fcntl.fcntl(f.fileno(),f.F_SETFL, os.O_NONBLOCK)

Then you put a call to the read in a loop, and use time.time()
to do your time out, resetting a start_time variable at the start,
and every time you get a char, and using short sleeps 
(millisec or so) after unsuccessful calls to make it less of a 
busy loop.

The side benefit of this is that once you have received a char,
you can change gears and use a shorter time out to detect the
end of message, in a protocol and state agnostic way. - when 
the device has stopped sending chars for a little while it has 
finished saying what it wants to say. - so its easy to write a 
get_a_reply routine with variable time out, moving the action 
from the char to the message level:

start_time=time.time()
s = ''
while time.time()-start_time  time_out:
  error,k = get_a_char(port)
  if error:
time.sleep(0.001)
continue
  s += k   # keep the first char
  start_time = time.time()
  while time.time() - start_time  0.005:   # inter char time out
status,k = get_a_char(port)
if error:
  time.sleep(0.001)
  continue
s +=k
start_time = time.time()
  break
return s   # return empty string or what was received

Something similar works for me on Suse Linux - not sure if 
fcntl works on windows.

And no it isn't pretty. - but then very little of what I write is...

- Hendrik

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


Re: High resolution sleep (Linux)

2007-05-11 Thread Nick Craig-Wood
Bart [EMAIL PROTECTED] wrote:
  What about C module with usleep,nanosleep?

Unlikely to help!  It is an linux OS limit that the minimum sleep time
is 1/HZ.

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


Re: how to refer to partial list, slice is too slow?

2007-05-11 Thread Marc 'BlackJack' Rintsch
In [EMAIL PROTECTED],
人言落日是天涯,望极天涯不见家 wrote:

 I make a sample here for the more clearly explanation
 
 s =  . - this is a large string data - ...
 
 def parser1(data)
  # do some parser
  ...
  # pass the remainder to next parser
  parser2(data[100:])
 
 def parser2(data)
  # do some parser
  ...
  # pass the remainder to next parser
  parser3(data[100:])
 
 def parser3(data)
  # do some parser
  ...
  # pass the remainder to next parser
  parser4(data[100:])
 
 ...

Do you need the remainder within the parser functions?  If not you could
split the data into chunks of 100 bytes and pass an iterator from function
to function.  Untested:

def iter_chunks(data, chunksize):
offset = chunksize
while True:
result = data[offset:offset + chunksize]
if not result:
break
yield result


def parser1(data):
chunk = data.next()
# ...
parser2(data)


def parser2(data):
chunk = data.next()
# ...
parser3(data)

# ...

def main():
# Read or create data.
# ...
parser1(iter_chunks(data, 100))

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

Re: Newbie question about string(passing by ref)

2007-05-11 Thread Duncan Booth
lazy [EMAIL PROTECTED] wrote:

 I want to pass a string by reference. I understand that strings are
 immutable, but Im not
 going to change the string in the function, just to aviod the overhead
 of copying(when pass-by-value) because the
 strings are long and this function will be called over and over
 again.

You'll find it is pretty hard to get Python to copy a string even if you 
wanted it to. About the only way is to break it apart and then construct a 
new string with the same value from it.

 s = some long string
 id(s)
12944352
 copyofs = s[:]
 id(copyofs)
12944352
 copyofs = s[:-1]+s[-1:]
 id(copyofs)
12944992
 def fn(foo):
print id(foo)
return foo

 fn(s)
12944352
'some long string'
 id(fn(s))
12944352
12944352

And sometimes two strings created separately magically become the same 
string (not that should you assume this will happen, just that it might, 
and the behaviour will vary according to a lot of factors):

 s1 = abc
 id(s1)
12956256
 s2 = abc
 id(s2)
12956256
 s1 = pqr stu
 id(s1)
12956288
 s2 = pqr stu
 id(s2)
12956192
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple Tkinter Progress Bar

2007-05-11 Thread Stefan Sonnenberg-Carstens
On Fr, 11.05.2007, 08:42, Gurpreet Singh wrote:
 Hi

 I am a newbie in Python

 I am creating a simple Tkinter based application.
 I have written Tkinter GUI source code and the
 programme logic in the same .py file.

 I am searching for a way to implement a simple
 Progress bar for my application.

 Are there any simple ways of doin it.





 Yahoo!
 oneSearch: Finally, mobile search
 that gives answers, not web links.
 http://mobile.yahoo.com/mobileweb/onesearch?refer=1ONXIC
 --
 http://mail.python.org/mailman/listinfo/python-list


Please see this:

http://tkinter.unpythonic.net/wiki/ProgressBar

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


checking if hour is between two hours

2007-05-11 Thread Flyzone
Hi all, i'm again working on my script of parsing logfiles :)
I putted a new function to disable the rule of error between a certain
hours, cause i want to use it as a monitoring script that run every 5
minutes and to disable error in hours of maintenance.
But i have some problems to check it.
In the rule-file i have HHMM(start) and HHMM(stop) - 0 0 to
disable hours check (i can't check the timestamp in logfile cause not
all the logfiles that i need to check have a timestamp in it).
In the script i wrote:

Actualtime=datetime.datetime.today().strftime(%H%M)
if (startend):
 if (Actualtimestart):
  end=int(Hcheck)+1
 else:
  if (int(Actualtime)int(end)):
 start=Actualtime
if ((int(Actualtime)int(start)) or (int(Actualtime)int(end)) or
((start==0) and (end==0)) ):
   rule=error
   ...blablabla
else:
   rule=skip
   blablabla
Why i don't use the complete date with YYMMDDHHMM?
Think about a rule that need to be disabled from hours 20:00 to
04:00.
If i use also yymmdd, in the rule file i need to write a 2000 and
0400+1, the +1 to tell the script that the end
is in the day after, to add a day. But it will work just till the
, hour in witch the day will change.

The script work, but is not so cleani just would like some
advice to make it more clean, if possible.

Like always, thanks in advance for the helps :)

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


Re: 4 byte integer

2007-05-11 Thread Michael Bentley

On May 11, 2007, at 4:25 AM, Paul D Ainsworth wrote:

 Greetings everyone. I'm a relative newcomer to python and I have a  
 technical
 problem.

 I want to split a 32 bit / 4 byte unsigned integer into 4 separate  
 byte
 variables according to the following logic: -

 bit numbers 0..7 byte 1
 bit numbers 8..15 byte 2
 bit numbers 16..23 byte 3
 bit numbers 24..31 byte 4

 Each of these byte variables to contain integer data from 0 to 255  
 (or 0 to
 FF in hex mode)

 I had thought that struct.unpack with an input message format of  
 'I' would
 be the way to do it, but its reporting an error that it doesn't  
 want to
 accept an integer.

 Please can anyone advise?

Have a look at http://aspn.activestate.com/ASPN/Cookbook/Python/ 
Recipe/113799
-- 
http://mail.python.org/mailman/listinfo/python-list


Jessica Reveals all Again

2007-05-11 Thread wise . of . clean791
http://jessicasboobs.blogspot.com/ - Download snazzy jessica images (I
bet you will find her naked)

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


Re: Erlang style processes for Python

2007-05-11 Thread Michael
Jacob Lee wrote:

 Funny enough, I'm working on a project right now that is designed for
 exactly that: PARLEY, http://osl.cs.uiuc.edu/parley .

Have you seen Kamaelia? Some people have noted that Kamaelia seems to have a
number of similarities to Erlang's model, which seems to come from a common
background knowledge. (Kamaelia's model is based on a blending of what I
know from a very basic recasting of CSP, Occam, unix pipelines and async
hardware verification).

Home:
   http://kamaelia.sourceforge.net/Home

Intros:
   http://kamaelia.sourceforge.net/Introduction
   http://kamaelia.sourceforge.net/t/TN-LinuxFormat-Kamaelia.pdf
   http://www.bbc.co.uk/rd/pubs/whp/whp113.shtml
 * http://kamaelia.sourceforge.net/t/TN-LightTechnicalIntroToKamaelia.pdf
   http://kamaelia.sourceforge.net/Docs/NotationForVisualisingAxon

The one *'d is perhaps the best at the moment.

Detail:
   http://kamaelia.sourceforge.net/Cookbook
   http://kamaelia.sourceforge.net/Components


Michael.

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


Re: searching algorithm

2007-05-11 Thread Michael Bentley

On May 10, 2007, at 12:26 PM, Gigs_ wrote:

 Hi all!

 I have text file (english-croatian dictionary) with words in it in  
 alphabetical
 order.
 This file contains 17 words in this format:
 english word: croatian word

 I want to make instant search for my gui
 Instant search, i mean that my program search words and show words  
 to user as
 user type letters.
 yes, it needs to be fast

 Can someone give me some points (approaches) how to make this
 Should i make indexes and go with file.seek

 or should breake dictionary in peaces and put words that start with  
 a in one and
 with b in another...
 ?

 So if i have this words
 ...

 if user type: abs program should list all words above in english  
 and in croatian
 if user type: absorb than program should list last 3 words in  
 english and in
 croatian





 any help would be appreciate!
 my apologies for bad english

Here's an idea:  use a rats' nest of dictionaries and do all the  
lookup work up front when you build the rats' nest.  Maybe something  
like this:

#! /usr/bin/env python
import pprint

dictionary = absinth:pelin
absinthe:pelin
absolute:apsolutan
absolute:apsolutni kod
absolute:apsolutno
absolute:#269;ist
absolute:nesumnjiv
absolute:potpun
absolute:savrsen
absolute coordinates:apsolutne koordinate
absolute frequency:apsolutna u#269;estalost
absolute gap:apsolutni jaz
absolute line spacing:apsolutni me#273;urazmak linija
absolute majority:apsolutna ve#263;ina
absolute pointing device:apsolutni pokaziva#269;ki ure#273;aj
absolute quantity:apsolutni udio
absolute value:apsolutna vrijednost
absolute zero:apsolutna nula
absolutely:apsolutno
absolutely:bezuvjetno
absolutely:nezavisno
absolutely:potpuno
absolutely:samostalno
absolutely:sasvim
absolution:odrjesenje
absolution:oprostaj
absolutism:apsolutizam
absolve:odrijesiti
absolve:osloboditi
absorb:absorbirati
absorb:apsorbirati
absorb:crpsti

lookup = {'words':{}, 'letters':{}}

for translation in dictionary.split('\n'):
 english, croatian = translation.split(':')
 if english in lookup['words']:
 lookup['words'][english].append(croatian)
 else:
 lookup['words'][english] = [croatian]

 for position, letter in enumerate(english):
 if position == 0:
 youAreHere = lookup['letters']

 if letter not in youAreHere:
 youAreHere[letter] = {'words':[]}
 youAreHere[letter]['words'].append(lookup['words'][english])
 youAreHere = youAreHere[letter]

def tryit(partial):
 youAreHere = lookup['letters']
 for letter in partial:
 youAreHere = youAreHere[letter]
 return youAreHere['words']

if __name__ == '__main__':
 pprint.pprint(tryit('abso'))


Hope this helps,
Michael
---
The Rules of Optimization are simple.
Rule 1: Don't do it.
Rule 2 (for experts only): Don't do it yet.
-- Michael A. Jackson , Principles of
Program Design, 1975.


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


4 byte integer

2007-05-11 Thread Paul D Ainsworth
Greetings everyone. I'm a relative newcomer to python and I have a technical 
problem.

I want to split a 32 bit / 4 byte unsigned integer into 4 separate byte 
variables according to the following logic: -

bit numbers 0..7 byte 1
bit numbers 8..15 byte 2
bit numbers 16..23 byte 3
bit numbers 24..31 byte 4

Each of these byte variables to contain integer data from 0 to 255 (or 0 to 
FF in hex mode)

I had thought that struct.unpack with an input message format of 'I' would 
be the way to do it, but its reporting an error that it doesn't want to 
accept an integer.

Please can anyone advise?



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


Re: searching algorithm

2007-05-11 Thread Michael Bentley

 Call me dense, but how does one do this in Python - which doesn't have
 pointers? Dictionaries with dictionaries within dictionaries... (with
 each letter as the key and the its children as values) is going to be
 extremely space inefficient, right?

Isn't *everything* in python essentially a pointer?  Dictionaries  
with dictionaries within dictionaries...  My gut feeling (which means  
I have not measured it, so I don't actually know) is that it would  
not be space inefficient.  Perhaps someone who knows more about this  
will speak up?

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


Re: newb: Python Module and Class Scope

2007-05-11 Thread Dave Baum
In article [EMAIL PROTECTED],
 johnny [EMAIL PROTECTED] wrote:

 Can a class inside a module, access a method, outside of class, but
 inside of the module?
 
 Eg.  Can instance of class a access main, if so how?  What is the
 scope of def main() interms of class A?
 
 myModule:
 
 class A:
main()
 
 def main():
 

Yes, class A can access main.  The name main will be defined at the 
top level of the module, and is considered a global for that module.  
Code within that module can access it simply as main.  Code in other 
modules would have to import the module in order to use symbols within 
it.  For example...

### myModule.py 

class A:
  def m():
main()

def main():
  pass


### other.py ###

import myModule

def main():
  pass

class B:
  def o():
main() # calls main() in this module
myModule.main() # calls main in myModule



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


Re: 4 byte integer

2007-05-11 Thread Paul D Ainsworth

 Have a look at http://aspn.activestate.com/ASPN/Cookbook/Python/ 
 Recipe/113799

Brilliant - thank you :) 


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


Re: newb: Python Module and Class Scope

2007-05-11 Thread Duncan Booth
Dave Baum [EMAIL PROTECTED] wrote:

 In article [EMAIL PROTECTED],
  johnny [EMAIL PROTECTED] wrote:
 
 scope of def main() interms of class A?
 
 myModule:
 
 class A:
main()
 
 def main():
 
 
 Yes, class A can access main.  The name main will be defined at the 
 top level of the module, and is considered a global for that module.

No, the name main will be defined when the execution of the 'def main()' 
statement is complete. It is not defined until that point.

In the example given the class statement is executed before the def 
statement is executed so at that point main is still undefined.
-- 
http://mail.python.org/mailman/listinfo/python-list


Custom Software Development

2007-05-11 Thread VB
iTechArt Group - Custom Software Development and Offshore outsourcing
Company

http://www.itechart.com/

Offshore custom software development company iTechArt - Web site and
Content Management Solutions development, CMS consulting: Ektron,
Drupal and DotNetNuke

iTechArt Group provides high quality custom software development
services and offshore software development. On December 2006, iTechArt
Group became an authorized Microsoft Certified Partner. This means
that our company has been recognized by Microsoft for our vast
expertise and authorized to custom software development; provide IT
service consulting and custom business solutions.

Custom Software Development and Offshore outsourcing Company iTechArt
has worked together since 2003 to design build and deliver .NET Web
Content Management software solutions that help clients meet their
strategic objectives. We are agile oriented development partner able
to consistently deliver solid results.

iTechArt software development team assemblies specialists in the
development of custom software applications and offshore software
outsourcing services.

Working concepts of our company are based on proven approaches and
international standards used for custom software development such as
Capability Maturity Model Integration for Software Engineering (CMMI-
SW). In the same breath we have our own standpoint on software
development process management which is fully effective and
comprehensible for our clients.


iTechArt offers software development in the next main directions:

1. Custom Software Development (Offshore outsourcing for worldwide
based software development companies.)

2. Software Development for Digital Signage (Media content development
and remote displays / information kiosks Web-based software
application management.)

3. Web Site Development  (E-commerce solutions, CMS/DotNetNuke/Ektron/
Drupal,  Web 2.0/PHP/MySQL/AJAX, Flash/Action script/Flex and many
more.)

4. Offshore Development Center (Dedicated development team of software
developers. Our offshore development centers operate as an extension
to clients' existing software engineering business.)

Contact iTechArt (  http://www.itechart.com/  )about custom software
development, end-to-end software solutions, outsourcing software
development, custom DotNetNuke module development, DotNetNuke
consulting, dotnetnuke hosting, first class Java and .Net developers,
software application design, software testing, Quality Assurance,
functionality testing and defect analysis, performance and stress
testing, usability testing, Microsoft Media Services and Adobe Media
Flash Server solutions, digital signage solutions and custom
development, Ektron CMS400.NET developers, CMS, .NET Web Content
Management software solutions

Web:
http://www.itechart.com/
http://www.itechart.com/Pages/ProductsServices/HowWeWork.aspx
http://www.itechart.com/Pages/ProductsServices/BusinessModels.aspx
http://www.itechart.com/Pages/ProductsServices/CustomSoftwareDevelopment.aspx
http://www.itechart.com/Pages/ProductsServices/DotNetNukeModuleDevelopment.aspx

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


Re: module error for elementtree

2007-05-11 Thread Stefan Behnel
[EMAIL PROTECTED] wrote:
 On May 11, 12:22 pm, [EMAIL PROTECTED] wrote:
 On May 11, 12:05 am, [EMAIL PROTECTED] wrote:





 #!/usr/bin/env python
 from elementtree import ElementTree as Element
 tree = et.parse(testxml.xml)
 for t in tree.getiterator(SERVICEPARAMETER):
 if t.get(Semantics) == localId:
 t.set(Semantics, dataPackageID)
 tree.write(output.xml)
 Hi,
  For the above code to work elementtree is
 imported in first line ,but when running it says :
 ImportError: No module named elementtree.ElementTree
 Does thie module exists as default or a patch is needed?
 Thanks
 http://groups.google.com/group/comp.lang.python/browse_frm/thread/e09...

 Read carefully.- Hide quoted text -

 - Show quoted text -
 
 The commands are given in that link are more so for a linux system .I
 am developing in windows.how should i go about to make it work

As said: read carefully.

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


Re: module error for elementtree

2007-05-11 Thread saif . shakeel
On May 11, 12:22 pm, [EMAIL PROTECTED] wrote:
 On May 11, 12:05 am, [EMAIL PROTECTED] wrote:





  #!/usr/bin/env python

  from elementtree import ElementTree as Element
  tree = et.parse(testxml.xml)

  for t in tree.getiterator(SERVICEPARAMETER):
  if t.get(Semantics) == localId:
  t.set(Semantics, dataPackageID)

  tree.write(output.xml)

  Hi,
   For the above code to work elementtree is
  imported in first line ,but when running it says :
  ImportError: No module named elementtree.ElementTree
  Does thie module exists as default or a patch is needed?
  Thanks

 http://groups.google.com/group/comp.lang.python/browse_frm/thread/e09...

 Read carefully.- Hide quoted text -

 - Show quoted text -

The commands are given in that link are more so for a linux system .I
am developing in windows.how should i go about to make it work

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


vim e autoindentazione commenti

2007-05-11 Thread Alan Franzoni
Ciao a tutti,
alla fine dopo le mille dispute emacs vs vim mi sono messo a provarli
entrambi... e mi pare ora di essere diventato un vimmaro (pur se molto
'custom' in quanto lo sto rendendo un bel po' + simile a cream).

Una domanda stupida. Forse è più da comp.editors.
Come faccio a far sì che vim prosegua automaticamente i commenti su più
righe? Ho settato la lunghezza massima della riga a 79 caratteri, fin qui
tutto ok, ma quando vado a capo, anche se la riga inizia con #, vim non lo
aggiunge in automatico all'inizio.


Al contrario con altri tipi di file (es. Java) questa aggiunta è automatica
e la trovo molto, molto comoda.

Dovrei andae a intaccare il file di indentazione? o quello di sintassi?


-- 
Alan Franzoni [EMAIL PROTECTED]
-
Togli .xyz dalla mia email per contattarmi.
Remove .xyz from my address in order to contact me.
-
GPG Key Fingerprint (Key ID = FE068F3E):
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to tell whetehr Python script called as CGI or from command line?

2007-05-11 Thread rowan
 import os
 if QUERY_STRING in os.environ:
  # CGI script

 might work.

Thanks Steve for this suggestion. I did something similar:
import os
req = os.getenv('REQUEST_URI')
if (not req is None) and len(req)  0:
web = True

which seemed to work for me.

Rowan

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


Re: Jython 2.2 Beta2 is available

2007-05-11 Thread Aahz
In article [EMAIL PROTECTED],
Charlie Groves python-list@python.org wrote:

I'm happy to announce that Jython 2.2-beta2 is available for download:
http://sourceforge.net/project/showfiles.php?group_id=12867package_id=12218release_id=507592
See http://jython.org/Project/installation.html for installation instructions.

This is the second and final beta release towards the 2.2 version of
Jython.  It includes fixes for more than 30 bugs found since the first
beta and the completion of Jython's support for new-style classes.

COngrats!  Whoo-hoo!  Excellent news!
-- 
Aahz ([EMAIL PROTECTED])   * http://www.pythoncraft.com/

Look, it's your affair if you want to play with five people, but don't
go calling it doubles.  --John Cleese anticipates Usenet
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Python and Decimal integers from DB

2007-05-11 Thread Sampson, David
Here is the solution, for the record.
 
 

import pyodbc
conn = pyodbc.connect(DSN=NAPL;UID=NAPL_VIEW;PWD=NAPVIEW)
curs = conn.cursor()
 
roll_num = 'A27255'
Cols = 'TO_CHAR(X_NO) as X_NO'
Table = 'photos'
Select = 'Select ' + Cols + ' from ' + Table + ' where roll_number = '
+' + roll_num + ' 
 
curs.execute(Select)
print select sucess
rows= curs.fetchall()
print fetch success
for row in rows:
print row.X_NO
 
print done


X_NO was entered in the DB as a number using the comma as a non-standard
separator. Python did not like it in the decimal.py module so we brought
it in as a character string using varchar2.
 
Python liked this solution and returned my results. Now I can give the
chars to a var and change it to numbers for some vector math
 
Hope this helps people in the future




From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf
Of Sampson, David
Sent: May 10, 2007 12:58
To: python-list@python.org
Subject: Python and Decimal integers from DB



Hey folks 

Freshie looking for help 

This is what I am trying to do. 

Use PYODBC to hit an oracle DB that has a ODBC connection.\ 
\The code bellow works when I replace '*' with a specific collumn name
that does not have commas in the number. 

It also works for alphanumberic values. 

It fails when I try '*' or any collumn that has a comman in the number.
The numbers are Latitude longitude readings. 

I get back Select Success but not fetch success so I feel as thopugh
something is missing on the fetchall() function

So how do I get the numbers to be recognized by python? 

I did lots of searches on python, ODBC, PYODBC, Decimal us and commas as
decimals and various combinations. Lots of mailing lists a few tutorials
and lots of misses.

I came across: 

Import decimal 
Decimal.Decimal() 

This works a bit. It took a coma separated number string and kept the
first part. But that works only when I put in a raw value, it doesn't
work on the Fetchall function.

HELP PLEASE... 


Cheers 


===PYHTON CODE 

import pyodbc 
conn = pyodbc.connect(DSN=NAPL;UID=NAPL_VIEW;PWD=NAPVIEW) 
curs = conn.cursor() 

roll_num = 'A27255' 
Cols = '*' 
Table = 'photos' 
Select = 'Select ' + Cols + ' from ' + Table + ' where roll_number = '
+' + roll_num + ' 

curs.execute(Select) 
print select sucess 
rows= curs.fetchall() 
print fetch success 
for row in rows: 
print row.PHOTO_NUMBER 

print done 
 



=Standard Output  
Traceback (most recent call last): 
  File
C:\Python25\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py
, line 310, in RunScript 
exec codeObject in __main__.__dict__ 
  File U:\My Documents\py_projects\georef\NAPL_DB.py, line 12, in
module 
rows= curs.fetchall() 
  File C:\Python25\lib\decimal.py, line 614, in __new__ 
self._sign, self._int, self._exp =
context._raise_error(ConversionSyntax) 
  File C:\Python25\lib\decimal.py, line 2325, in _raise_error 
raise error, explanation 
InvalidOperation 

 

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

Re: searching algorithm

2007-05-11 Thread Neil Cerutti
On 2007-05-11, ciju [EMAIL PROTECTED] wrote:
 By the way, both data structures could be implemented as tuple
 in python, for I suppose, if only lookup is needed tuple gives
 better performance than list.

I used a list instead of a tuple where I thought a list would be
convenient while building the data structure. But you could
convert everything to tuples in the end, it's true.

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


software testing articles

2007-05-11 Thread [EMAIL PROTECTED]
Have you ever been interested in software testing? Giving you an in
depth analysis/knowledge on software testing!!

http://www.top-itarticles.com/softtest/main.asp

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


Re: module error for elementtree

2007-05-11 Thread Jerry Hill
On 11 May 2007 00:05:19 -0700, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:
  For the above code to work elementtree is
 imported in first line ,but when running it says :
 ImportError: No module named elementtree.ElementTree
 Does thie module exists as default or a patch is needed?

That depends on which version of Python you are running.  Starting
with 2.5, ElementTree was moved into the standard library, as part of
the xml package.  If you're using an older version of python, I think
you'll need to download and install the elementtree package from
http://effbot.org/zone/element-index.htm

Assuming you're using python 2.5, you probably want something like this:

from xml.etree.ElementTree import ElementTree as et

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


Re: vim e autoindentazione commenti

2007-05-11 Thread Neil Cerutti
On 2007-05-11, Alan Franzoni
[EMAIL PROTECTED] wrote:
 Al contrario con altri tipi di file (es. Java) questa aggiunta
 è automatica e la trovo molto, molto comoda.

 Dovrei andae a intaccare il file di indentazione? o quello di
 sintassi?

Colto prego nel manuale Vim: 

:help format-comments

(Spiacente per la mia scrittura difettosa. Sto utilizzando il
traduttore di altavista.)

-- 
Neil Cerutti
You've got to take the sour with the bitter. --Samuel Goldwyn
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: setting extra data to a wx.textctrl

2007-05-11 Thread kyosohma
On May 10, 10:51 pm, Pom [EMAIL PROTECTED] wrote:
 Hello group!

 I have an application which uses a lot of mysql data fields, all the
 same data type (floats).

 I created a panel which executes a SELECT * FROM tablename and makes
 as much fields as needed, using de cursor.description as wx.statictext
 and the cursors field contents copied into wx.textctrls.

 At creation time, I loop over all the fields in the record and create a
 tuple which contains ((textctrl1, fieldname1), (textctrl2, fieldname2),
 ...)  so I can keep track of which textctrl holds which piece of fielddata.

 The problem I'm having is:

 to know the fieldname in an text_event, I use event.GetEventObject(),
 then perform an iteration over the tuple and when I find a match I use
 the field name to update the mysqltable.
 When having a few fields, this is ok.  But I have over 100 fields in 1
 record and it really slows things down.

 Now my question is: should I use a python dictionary (with an object as
 first lookup field) ?

 On windows, I've seen a Tag property in a textbox which was meant to
 be used for this kind of stuff.  Maybe it's better to override the
 wx.textctrl so I can add an extra string value?

 Anyone having the best solution for this ?

 thx!

Both of your ideas seem sound to me. You could also look into using
statically assigned IDs that increment by one. Then you could just
increment or decrement by one and look up the field by ID. Of course,
that might get ugly and there are some IDs that are supposedly
reserved. But it's an idea.

Also, I've heard that Dabo (http://dabodev.com/) is good for database
work. You might look at that. To get the quickest and most on target
answers to wxPython questions, I recommend the wxPython users-group
mailing list: http://www.wxpython.org/maillist.php

Mike

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


Re: append

2007-05-11 Thread vdicarlo
  the reference material. I want to know about list
 operations such as
  append.

I've been struggling myself to assemble and learn just the right
combination of quick references. Here is some of what I've found.

For a quick search for the syntax and a simple example of a particular
method or function, the single most efficient source for me has been
the keyword search page for the Python Library Reference, Language
Reference, and Python/C API manuals that you can find from a link on
the official documentation page at http://www.python.org/doc/ or
directly at

http://starship.python.net/crew/theller/pyhelp.cgi

Full text searches (not limited to keywords like the resource above)
of the Python Library Reference can also be done at
http://www.zvon.org/other/python/PHP/search.php

Other handy references are:

Dive into Python at
http://diveintopython.org/toc/index.html

The Python 2.5 Quick Reference at
http://rgruet.free.fr/PQR25/PQR2.5.html

Last, but far from least, the one resource that I most wish I had
known about when I started with Python is the screencast tutorial site
at www.showmedo.com. There are two excellent free screencasts on
Python resources at http://tinyurl.com/2qkuht and lots of other Python
tutorials, most free and some for a modest fee. In particular, the 9th
installment of the paid series called Python Newbies on XP at
http://tinyurl.com/3ayhwt is about how to use the help functions built
into Python Idle.

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


Dyla'07: 3rd Workshop on Dynamic Languages and Applications

2007-05-11 Thread Alexandre Bergel
Dear colleague,

Please, note that after the workshop, best papers will be selected,  
and a second deadline will then be set regarding  preparation of the  
Electronic Communications of the EASST. Note that we submission  
deadline has been extended.

The important dates:
- May 27: deadline for the workshop submissions. Submissions should  
follow LNCS format (www.springer.com/lncs) and should be sorter than  
10 pages. **extended deadline**
- June 12-13: Author notification of their submission
- June 15, 2007: ECOOP'07 Early Registration
- July 31: Workshop
- August 5: Selection of best papers for Electronic Communications  
of the EASST
- September 10: deadline for revised and extended version of  
submission for the communications.

Regards,
Dyla organisers


*
Call for Papers
Dyla 2007: 3rd Workshop on Dynamic Languages and Applications
July 31, 2007, Berlin (Collocated with ECOOP 2007)

http://dyla2007.unibe.ch
*

Objective
=

The goal of this workshop is to act as a forum where we can discuss  
new advances in the conception, implementation and application of  
object-oriented languages that radically diverge from the statically  
typed class-based reflectionless doctrine. The goal of the workshop  
is to discuss new as well as older forgotten languages and features  
in this  context. Topics of interest include, but are certainly not  
limited to:

   - agents, actors, active objects, distribution, concurrency and  
mobility
   - delegation, prototypes, mixins
   - first-class closures, continuations, environments
   - reflection and meta-programming
   - (dynamic) aspects for dynamic languages
   - higher-order objects  messages
   - ...  other exotic dynamic features which you would categorize as OO
   - multi-paradigm  static/dynamic-marriages
   - (concurrent/distributed/mobile/aspect) virtual machines
   - optimisation of dynamic languages
   - automated reasoning about dynamic languages
   - regular syntactic schemes (cf. S-expressions, Smalltalk, Self)
   - Smalltalk, Python, Ruby, Scheme, Lisp, Self, ABCL, Prolog, ...
   - ... any topic relevant in applying and/or supporting dynamic  
languages.

We solicit high-quality submissions on research results
and/or experience. Submitted papers must be unpublished
and not submitted for publication elsewhere. Submissions
should not exceed 10 pages, LNCS format (www.springer.com/lncs).


Submission
==

Prospective attendees are requested to submit a position paper or an  
essay (max 10 pages, references included) on a topic relevant to the  
workshop to Alexandre Bergel ([EMAIL PROTECTED]).  
Submissions are demanded to be in .pdf format and should arrive  
before May 13, 2007.

A selection of the best papers will be made, which will require an  
extension for an inclusion in a special issue in Electronic  
Communications of the EASST  (eceasst.cs.tu-berlin.de). For this  
purpose, a new deadline will be set after the workshop.

Moreover, Springer publishes a Workshop-Reader (as in the case of  
previous ECOOPs) which appears after the Conference and which  
contains Workshop-Reports (written by the organizers) and not the  
position papers submitted by the participants.


Important dates
===

May 27, 2007: deadline for the workshop submissions. Submissions  
should follow LNCS format (www.springer.com/lncs) and should be  
sorter than 10 pages. **extended deadline**

June 12-13, 2007: Author notification of their submission

June 15, 2007: ECOOP'07 Early Registration

July 31, 2007: Workshop

August 05, 2007: Selection of best papers for Electronic  
Communications of the EASST

September 10, 2007: deadline for revised and extended version of  
submission for the communications.


Organisers
==

Alexandre Bergel
Wolfgang De Meuter
Stéphane Ducasse
Oscar Nierstrasz
Roel Wuyts


Program committee
=

Alexandre Bergel  (Hasso-Plattner-Institut, University of  
Potsdam, Germany)
Johan Brichau (Université catholique de Louvain, Belgium)
Pascal Costanza   (Vrije Universiteit Brussel, Belgium)
Wolfgang De Meuter  (Vrije Universiteit Brussel, Belgium)
Stéphane Ducasse (University of Savoie, France)
Erik Ernst (University of Aarhus, Denmark)
Robert Hirschfeld   (Hasso-Plattner-Institut, University of  
Potsdam, Germany)
Oscar Nierstrasz(University of Bern, Switzerland)
Matthew Flatt   (University of Utah, USA)
Dave Thomas(Bedarra Research Labs, Canada)
Laurence Tratt(King's College London, UK)
Roel Wuyts(IMEC  Université Libre de Bruxelles,  
Belgium)

-- 
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.software-artist.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.



-- 

Re: searching algorithm

2007-05-11 Thread Alex Martelli
Michael Bentley [EMAIL PROTECTED] wrote:

 
  Call me dense, but how does one do this in Python - which doesn't have
  pointers? Dictionaries with dictionaries within dictionaries... (with
  each letter as the key and the its children as values) is going to be
  extremely space inefficient, right?
 
 Isn't *everything* in python essentially a pointer?  Dictionaries  
 with dictionaries within dictionaries...  My gut feeling (which means
 I have not measured it, so I don't actually know) is that it would  
 not be space inefficient.  Perhaps someone who knows more about this
 will speak up?

Dicts are hash tables, and therefore, for performance, always keep some
extra space (so that the table won't be too full).


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


Re: Towards faster Python implementations - theory

2007-05-11 Thread sturlamolden
On May 10, 4:02 pm, Tim Golden [EMAIL PROTECTED] wrote:

 But the relevant bit of your last paragraph is at the start:
 We should

Sorry, bad choice of words.

 see it faster. That's great. But unless people
 puts their money where their mouths are, I don't

I know, I know. But that doesn't stop me from envying what the Lisp
community has achieved.

Python still sucks if we are using it for scientific simulations,
testing CPU-bound algorithms, etc. Sure it is only 150-200 times
slower than C for these tasks, but that can amount to the difference
between one day and half a year of CPU time. But as strange as it may
seem, it can still be advantageous to use Python. E.g. it may be less
expensive to run the simulation in parallel on 200 CPUs than writing
the code in C instead of Python.






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


Re: Newbie look at Python and OO

2007-05-11 Thread Grant Edwards
On 2007-05-10, Gabriel Genellina [EMAIL PROTECTED] wrote:
 En Thu, 10 May 2007 18:21:42 -0300, [EMAIL PROTECTED] escribió:

 These conversations are funny to me.  I use Python every day and I
 have never actually thought about the implications of binding objects
 to names, or two names pointing to the same object.  Problems of this
 sort just never come up in actual programming for me.  It just works.

 Python was my virgin language, so maybe that just makes it natural to
 me, but it seems like people coming from other languages get hung up
 on testing out the differences and theories rather than just
 programming in it.  Alas, maybe I have yet to get deep enough to run
 into these kinds of problems.

 Certainly, learning Python as a first language has some
 advantages. But I think you'd feel a bit shocked if you had to
 program in C++ someday; these rather innocent lines might not
 do what you think:
[...]
 Simple things have so complex and ugly rules that... ugh, enough for now.

http://www.ariel.com.au/jokes/An_Interview_with_Bjarne_Stroustrup.html

Maybe BS thought he was joking, but IMO, it's true.

  Stroustrup: Remember the length of the average-sized 'C'
   project? About 6 months. Not nearly long enough for a guy
   with a wife and kids to earn enough to have a decent
   standard of living. Take the same project, design it in C++
   and what do you get? I'll tell you. One to two years.

-- 
Grant Edwards   grante Yow! I know how to do
  at   SPECIAL EFFECTS!!
   visi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: software testing articles

2007-05-11 Thread Andrew Koenig
[EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]

 Have you ever been interested in software testing? Giving you an in
 depth analysis/knowledge on software testing!!

Looking around the site at random, I saw no in depth analysis/knowledge of 
anything.


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


Re: Towards faster Python implementations - theory

2007-05-11 Thread sturlamolden
On May 10, 7:18 pm, Terry Reedy [EMAIL PROTECTED] wrote:

 Unfortunately, native machine code depends on the machine, or at least the
 machine being emulated by the hardware.  Fortunately or not, the dominance
 of the x386 model makes this less of a problem.

CMUCL and SBCL depends on the dominance of the x86 architecture.

GCL uses the GCC backend, which supports a wide range of
architectures.

Building a compiler backend is not needed for a Python JIT, one can
accept the GPL license and use GCC as a backend.

Or one could translate between Python and Lisp on the fly, and use a
compiled Lisp (CMUCL, SBCL, Franz, GCL) as runtime backend.

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


Re: change of random state when pyc created??

2007-05-11 Thread Alan Isaac
This is an attempt to synthesize Bill and Carsten's proposals.

http://docs.python.org/lib/typesmapping.html: for footnote (3)

Keys and values are listed in an arbitrary order.  This order is
indeterminate and generally depends on factors outside the scope of
the
containing program.  However, if items(), keys(), values(),
iteritems(), iterkeys(), and itervalues() are called with no
intervening modifications to the dictionary, the lists will directly
correspond.

http://docs.python.org/lib/types-set.html: append a new sentence to 2nd par.

Iteration over a set returns elements in an indeterminate order,
which
generally depends on factors outside the scope of the containing
program.

Alan Isaac


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


Better way to isolate string

2007-05-11 Thread HMS Surprise
Greetings.

Given the string s below and using only  python built-in capabilities,
I am trying to isolate the substring G132153. This string may have any
number of digits but the pieces around it will not change. I have
accomplished this with split but there must be a more elegant and
compact way to do this.


 s ='a href=../active/Group_Detail.php?GroupID=G132153SvcType=1AType=V 
 class=dvLinkG132153/a'
 t = s.split('')
 u = t[-1].split('')
 v = u[0]
 v
'G132153'


Thanks,

jvh

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


Re: Newbie look at Python and OO

2007-05-11 Thread Duncan Booth
Grant Edwards [EMAIL PROTECTED] wrote:

 http://www.ariel.com.au/jokes/An_Interview_with_Bjarne_Stroustrup.html
 
 Maybe BS thought he was joking, but IMO, it's true.
 
   Stroustrup: Remember the length of the average-sized 'C'
project? About 6 months. Not nearly long enough for a guy
with a wife and kids to earn enough to have a decent
standard of living. Take the same project, design it in C++
and what do you get? I'll tell you. One to two years.
 

I doubt very much that BS was involved at any point in writing it. You 
forgot to quote the bit at the end:

[Note - for the humor-impaired, not a true story]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Better way to isolate string

2007-05-11 Thread Tim Golden
HMS Surprise wrote:
 I suppose a one liner would look better, but I am alway leery of these
 things 'breaking'.
 
 t = s.split('')[-1].split('')[0]
 s ='a href=../active/Group_Detail.php?
 GroupID=G132153SvcType=1AType=V class=dvLinkG132153/a'

Only if you're competing in an obscurity competition ;)

If you're really confined to built-ins (ie you can't import
a single module) then just go with your original solution.
Why not?

If you can import modules, then you want to look
at the urlparser and cgi modules, I suspect.

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


PyGTK : a NEW simple way to code an app

2007-05-11 Thread manatlan
I was a fan of SimpleGladeApp/tepache way to build a pygtk app.
I've build a new efficient/dynamic way to build a pygtk app ...

Here is an example :
=
class Fen(GladeApp):

Window win
.title=Hello
@delete_event
VBox
HBox
Label jo
.label=kokotte
entry myEntry
.text=kuku
gtkBuTTon b2
.label=33
@clicked
Label jo
.label=koko
Button b
.label=3
@clicked

def init(self,m):
self.jo.set_text(m)
pass
def on_b_clicked(self,*a):
self.quit(3)
def on_b2_clicked(self,*a):
self.quit(33)
def on_win_delete_event(self,*args):
self.quit(4)

f=Fen(koko2)
print f.loop()
=

How it works :

in fact, the __doc__ is converted as a glade file
the tree of object is indented (like python way)
you can see some common pygtk widget ...
line starting with a dot is an property of the parent object.
line starting with a @ is a declaration of a event of the parent
object.
widgets are not case sensitive, and can start with Gtk. If a second
word is provided it will be used as an id, otherwise an unique id
will be build according the type of widget.
the window is created with glade, widgets are provided as attributs of
the instance, and signals are autoconnected on method
on_[widgetId]_[event](self,*args) (if a signal is missing in your
class, it warns you at run time) 

It will not replace the use of glade-3 for complex widget ... but I
think it's an easy way to code very easily/quickly a simple pygtk
window/form.
I think it could be really useful/handly for beginners too.

for people which are involved in pygtk/python/gui ... i'd like to hear
your comments/ideas ...

Rq:
i don't provide the code now, but it will be released in next version
of GladeApp ( http://manatlan.infogami.com/GladeApp )
it works already, but i need to make packing properties available
too ...

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


Re: vim e autoindentazione commenti

2007-05-11 Thread Alan Franzoni
Il Fri, 11 May 2007 13:15:01 GMT, Neil Cerutti ha scritto:

:help format-comments
 
 (Spiacente per la mia scrittura difettosa. Sto utilizzando il
 traduttore di altavista.)

Really sorry ^_^ I thought I was posting in it.comp.lang.python 

Thank you BTW!


-- 
Alan Franzoni [EMAIL PROTECTED]
-
Togli .xyz dalla mia email per contattarmi.
Remove .xyz from my address in order to contact me.
-
GPG Key Fingerprint (Key ID = FE068F3E):
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie look at Python and OO

2007-05-11 Thread Grant Edwards
On 2007-05-11, Duncan Booth [EMAIL PROTECTED] wrote:
 Grant Edwards [EMAIL PROTECTED] wrote:

 http://www.ariel.com.au/jokes/An_Interview_with_Bjarne_Stroustrup.html
 
 Maybe BS thought he was joking, but IMO, it's true.
 
   Stroustrup: Remember the length of the average-sized 'C'
project? About 6 months. Not nearly long enough for a guy
with a wife and kids to earn enough to have a decent
standard of living. Take the same project, design it in C++
and what do you get? I'll tell you. One to two years.
 

 I doubt very much that BS was involved at any point in writing it. You 
 forgot to quote the bit at the end:

 [Note - for the humor-impaired, not a true story]

My bad.  I completely missed that -- I thought it was a real
interview where BS was joking.

-- 
Grant Edwards   grante Yow! I just remembered
  at   something about a TOAD!
   visi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple Python REGEX Question

2007-05-11 Thread Gary Herron
johnny wrote:
 I need to get the content inside the bracket.

 eg. some characters before bracket (3.12345).

 I need to get whatever inside the (), in this case 3.12345.

 How do you do this with python regular expression?
   

 import re
 x = re.search([0-9.]+, (3.12345))
 print x.group(0)
3.12345

There's a lot more to the re module, of course.  I'd suggest reading the
manual, but this should get you started.


Gary Herron

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


Re: Towards faster Python implementations - theory

2007-05-11 Thread John Nagle
Tim Golden wrote:
 sturlamolden wrote:
 
 On May 8, 5:53 pm, John Nagle [EMAIL PROTECTED] wrote:

 The point here is that we don't need language changes or 
 declarations
 to make Python much faster.  All we need are a few restrictions that
 insure that, when you're doing something unusual, the compiler can
 tell. 
 
 I doubt if anyone disputes the gist of what you're
 saying[*], viz that Python could be made faster by using
 technique (a), (b) or (c) which have been successful elsewhere. At least 
 that it's worth investgating.
 
 But the relevant bit of your last paragraph is at the start:
 We should Unless someone or someones has the time,
 inclination, money, backing, wherewithal etc. to implement
 this or any other measure of speeding-up, it's all
 pie-in-the-sky. Useful, maybe, as discussion of what
 options are viable, but a project of this magnitude
 doesn't just happen in some developer's lunchbreak.

 Focusing may help.  Between Jython, PyPy, and Shed Skin,
enough effort has been put in to produce something better than
CPython, but none of those efforts resulted in something more
useable than CPython.

 There's a commercial grade Python from ActiveState, but
that's CPython in a cardboard box, I think.

 Another problem is that if the language is defined as
whatever gets put in CPython, that discourages other
implementations.  The language needs to be standards-based.

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


Re: Better way to isolate string

2007-05-11 Thread HMS Surprise
I suppose a one liner would look better, but I am alway leery of these
things 'breaking'.

t = s.split('')[-1].split('')[0]
s ='a href=../active/Group_Detail.php?
GroupID=G132153SvcType=1AType=V class=dvLinkG132153/a'

jh

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


Simple Python REGEX Question

2007-05-11 Thread johnny
I need to get the content inside the bracket.

eg. some characters before bracket (3.12345).

I need to get whatever inside the (), in this case 3.12345.

How do you do this with python regular expression?

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


Re: path stuff

2007-05-11 Thread fscked
On May 10, 6:08 pm, Gabriel Genellina [EMAIL PROTECTED]
wrote:
 En Thu, 10 May 2007 19:04:30 -0300, fscked [EMAIL PROTECTED]  
 escribió:





  ok, I lied, it is still doing the archived folders. Here is the code:

  import os, sys
  from path import path

  myfile = open(boxids.txt, r, 0)
  for line in myfile:
  d = 'D:\\Dir\\' + path(line.strip())
  for f in d.walkfiles('*Config*.xml'):
  for dirpath, dirnames, filenames in os.walk(d):
  if Archived in dirnames:
  dirnames.remove(Archived) #skip this directory
  print f
  print 'Done'

  when it does the print f it still shows me the dirs i don't want to
  see.

 You are walking the directory structure *twice*, using two different  
 methods at the same time. Also, there is no standard `path` module, and  
 several implementations around, so it would be a good idea to tell us  
 which one you use.
 If you want to omit a directory, and include just filenames matching a  
 pattern:

 import os, sys, os.path, fnmatch

 def findinterestingfiles(root_dir):
for dirpath, dirnames, filenames in os.walk(root_dir):
  if Archived in dirnames:
dirnames.remove(Archived)
  for filename in fnmatch.filter(filenames, '*Config*.xml'):
fullfn = os.path.join(dirpath, filename)
print fullfn

 myfile = open(boxids.txt, r)
 for line in myfile:
dirname = os.path.join('D:\\Dir\\', line.strip())
findinterestingfiles(dirname):
 myfile.close()

 --
 Gabriel Genellina- Hide quoted text -

 - Show quoted text -

Should this code work? I get a syntax error and cannot figure out why.

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


Re: Better way to isolate string

2007-05-11 Thread HMS Surprise
On May 11, 10:45 am, Tim Golden [EMAIL PROTECTED] wrote:
 HMS Surprise wrote:
  I suppose a one liner would look better, but I am alway leery of these
  things 'breaking'.

  t = s.split('')[-1].split('')[0]
  s ='a href=../active/Group_Detail.php?
  GroupID=G132153SvcType=1AType=V class=dvLinkG132153/a'

 Only if you're competing in an obscurity competition ;)

 If you're really confined to built-ins (ie you can't import
 a single module) then just go with your original solution.
 Why not?

 If you can import modules, then you want to look
 at the urlparser and cgi modules, I suspect.

 TJG

Thanks for replying Tim. Good point.

jh

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


Re: Towards faster Python implementations - theory

2007-05-11 Thread Paul Boddie
On 11 May, 18:04, John Nagle [EMAIL PROTECTED] wrote:

  Another problem is that if the language is defined as
 whatever gets put in CPython, that discourages other
 implementations.  The language needs to be standards-based.

Indeed. This was suggested by one of the speakers at last year's
EuroPython with reference to the various proposals to remove map,
reduce, lambda and so on from the language. The opinion was that if
Python implementations change and leave the users either on
unsupported releases or with the work of migrating their code
continuously and/or to features that they don't find as intuitive or
appropriate, some people would rather migrate their code to a language
which is standardised and which can remain agreeable for the
foreseeable future.

Paul

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


Re: software testing articles

2007-05-11 Thread Terry Reedy

[EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
| Have you ever been interested in software testing? Giving you an in
| depth analysis/knowledge on software testing!!

Random non-Python IT topics are spam.  Please desist.
[Link to page with 75% ads deleted]



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


Re: File modes

2007-05-11 Thread HMS Surprise
On May 10, 7:11 pm, Jon Pentland [EMAIL PROTECTED] wrote:
 I don't really see the use for being able to do that. Have you tried


Well, I think I found a reason and it probably happens quite a bit.

I open the file and read it into a list. I pop some elements from the
list for processing and then write the shortened list back to disk to
be available for other functions to access later, where later varies
from seconds to days. There is no need to keep the file open till
after the processing so I wish to write/flush/close right away.

jvh

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


File writing success

2007-05-11 Thread HMS Surprise
If file writing has no return value (http://docs.python.org/lib/bltin-
file-objects.html), how do you know if the write was successful?
Should one assume that if the open was successful then write are also?

Thanks,

jvh

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


A newbie question about FileDialog in wxPython

2007-05-11 Thread OhKyu Yoon
Hi!
I am opening files using the wx.FileDialog in wxPython.
I want to modify the FileDialog such that some information about a 
highlighted file is displayed before I decide to open the file.
This is what I tried:

class ModifiedFileDialog(wx.FileDialog):
def __init__(self,parent,message,wildcard,style):
wx.FileDialog(self,parent,message,,,wildcard,style)
width,height = self.GetSizeTuple()
self.SetSizeWH(width,height+100)
# and so on...

I get an error when I try to change the size or make other changes.
Could someone tell me how to make this work or direct me to some reference?
Thank you. 


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


Re: Towards faster Python implementations - theory

2007-05-11 Thread Terry Reedy

sturlamolden [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
| On May 10, 4:02 pm, Tim Golden [EMAIL PROTECTED] wrote:
| I know, I know. But that doesn't stop me from envying what the Lisp
| community has achieved.

But do not let your envy stop you from noticing and appreciating what the 
Python commnunity has achieved.

| Python still sucks if we are using it for scientific simulations,

Not if you use extensions compiled from C or Fortran.  Doing so is not 
cheating, any more than using the C-coded methods of the builtin types. 
Leveraging existing code and compilers was part of Python's design.

With the Numeric extensions, produced by people at the US nuke labs. 
scientific simulations were, I think, Python's first killer ap.

| Sure it is only 150-200 times slower than C for these tasks,

As a general statement, nonsense.  A LinPack inversion of a 10k x 10k 
matrix takes the same time whether called from Python or a C program.  The 
miniscule extra overhead of Python is more than made up for by the ability 
to call LinPack and other functions interactively.

The extended buffer protocol, championed by Travis Oliphant and slated for 
3.0, will make cooperation between extensions much easier.

Terry Jan Reedy



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


Re: File writing success

2007-05-11 Thread Jason
On May 11, 12:21 pm, HMS Surprise [EMAIL PROTECTED] wrote:
 If file writing has no return value (http://docs.python.org/lib/bltin-
 file-objects.html), how do you know if the write was successful?
 Should one assume that if the open was successful then write are also?

 Thanks,

 jvh

In Python, errors are not usually indicated by a return code.
Instead, an exception should be raised for error conditions.  The
Python file semantics follows this.  If the function returns instead
of raising an exception, you may assume that the write completed
successfully.  Please note that the file objects may use buffers, so a
call to the flush method may be needed to ensure that everything is on
disk.

K:\tempdir
 Volume in drive K is LEXAR MEDIA
 Volume Serial Number is -

 Directory of K:\temp

05/11/2007  01:14 PMDIR  .
05/11/2007  01:14 PMDIR  ..
   0 File(s)  0 bytes
   2 Dir(s)  75,071,488 bytes free

K:\temppython
Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit
(Intel)] on win
32
Type help, copyright, credits or license for more information.
 out = file(test.txt, wb)
 out.write( Hi! * 8000 )
Traceback (most recent call last):
  File stdin, line 1, in module
IOError: [Errno 28] No space left on device


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


Re: File writing success

2007-05-11 Thread Jon Ribbens
On 2007-05-11, HMS Surprise [EMAIL PROTECTED] wrote:
 If file writing has no return value (http://docs.python.org/lib/bltin-
 file-objects.html), how do you know if the write was successful?

Because no exception was thrown?

Although bear in mind that some errors might not become apparent until
you close or flush the file.
-- 
http://mail.python.org/mailman/listinfo/python-list


Interesting list Validity (True/False)

2007-05-11 Thread nufuhsus
Hello all,

First let me appologise if this has been answered but I could not find
an acurate answer to this interesting problem.

If the following is true:
C:\Python25\rg.pypython
Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32
bit (Intel)] on
win32
Type help, copyright, credits or license for more
information.
 [] == []
True
 ['-o'] == []
False
 ['-o'] == False
False


Then why do I get the following results:
C:\Python25\rg.pyhelp.py -o
print arg ['-o']
type(arg): type 'list'
arg is True? False
help.py version 1.0 Copyright RDEG (c) 2007
['-o'] is an unrecognized option.
Progam Exit (0)

python
import sys

_ver_ = 1.00

if '-h' in sys.argv or '--help' in sys.argv:
print
print help.py Version, _ver_, Copyright RDEG (c) 2007
print '''

Options : -h, --help -- display this message
Progam Exit (0)'''
sys.exit(0)
else:
arg = sys.argv[1:]
print 'print arg', arg
print 'type(arg):', type(arg)
print 'arg is True?', arg == True
print help.py version, _ver_, Copyright RDEG (c) 2007
print , arg, is an unrecognized option.
print Progam Exit (0)
sys.exit(0)
/python

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


stealth screen scraping with python?

2007-05-11 Thread different . engine
Folks:

I am screen scraping a large volume of data from Yahoo Finance each
evening, and parsing with Beautiful Soup.

I was wondering if anyone could give me some pointers on how to make
it less obvious to Yahoo that this is what I am doing, as I fear that
they probably monitor for this type of activity, and will soon ban my
IP.

-DE

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


Re: stealth screen scraping with python?

2007-05-11 Thread Dotan Cohen
On 11 May 2007 12:32:55 -0700, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:
 Folks:

 I am screen scraping a large volume of data from Yahoo Finance each
 evening, and parsing with Beautiful Soup.

 I was wondering if anyone could give me some pointers on how to make
 it less obvious to Yahoo that this is what I am doing, as I fear that
 they probably monitor for this type of activity, and will soon ban my
 IP.

 -DE


So long as you are sending a regular http request, as from a browser,
then they will have no way of knowing. Just keep your queries down to
no more than once every 3-5 seconds and you should be fine. Rotate
your IP, too, if you can.

Dotan Cohen

http://lyricslist.com/lyrics/artist_albums/110/carmen_eric.html
http://what-is-what.com/what_is/eula.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: File writing success

2007-05-11 Thread Facundo Batista
HMS Surprise wrote:

 If file writing has no return value (http://docs.python.org/lib/bltin-
 file-objects.html), how do you know if the write was successful?

If not, you'll get an error raised.

Regards,

-- 
.   Facundo
.
Blog: http://www.taniquetil.com.ar/plog/
PyAr: http://www.python.org/ar/


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


Re: stealth screen scraping with python?

2007-05-11 Thread kyosohma
On May 11, 2:32 pm, [EMAIL PROTECTED] wrote:
 Folks:

 I am screen scraping a large volume of data from Yahoo Finance each
 evening, and parsing with Beautiful Soup.

 I was wondering if anyone could give me some pointers on how to make
 it less obvious to Yahoo that this is what I am doing, as I fear that
 they probably monitor for this type of activity, and will soon ban my
 IP.

 -DE

Depends on what you're doing exactly. I've done something like this
and it only hits the page once:

URL = 'http://quote.yahoo.com/d/quotes.csv?s=%sf=sl1c1p2'
TICKS = ('AMZN', 'AMD', 'EBAY', 'GOOG', 'MSFT', 'YHOO')
u = urlopen(URL % ','.join(TICKS))
for data in u:
tick, price, chg, per = data.split(',')
# do something with data

If you're grabbing all the data in one fell swoop (which is what you
should aim for), then it's harder for Yahoo! to know what you're doing
exactly. And I can't see why they'd care as that is all a browser does
anyway. It's when you hit the site a bunch of times in a short period
of time that sets off the alarms.

Mike

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


Re: Interesting list Validity (True/False)

2007-05-11 Thread Grant Edwards
On 2007-05-11, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

 Then why do I get the following results:
 C:\Python25\rg.pyhelp.py -o
 print arg ['-o']
 type(arg): type 'list'
 arg is True? False
 help.py version 1.0 Copyright RDEG (c) 2007
 ['-o'] is an unrecognized option.
 Progam Exit (0)

You got those results because that's what your program does.

Were you intending it to do something else?  If so, you're
going to have to explain what you wanted, because we can't read
your mind.

-- 
Grant Edwards   grante Yow! Hey, wait
  at   a minute!!  I want a
   visi.comdivorce!! ... you're not
   Clint Eastwood!!
-- 
http://mail.python.org/mailman/listinfo/python-list


test

2007-05-11 Thread Joe Eagar
sorry just a test.

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


Re: Interesting list Validity (True/False)

2007-05-11 Thread [EMAIL PROTECTED]
On May 11, 2:28 pm, [EMAIL PROTECTED] wrote:
 Hello all,

 First let me appologise if this has been answered but I could not find
 an acurate answer to this interesting problem.

 If the following is true:
 C:\Python25\rg.pypython
 Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32
 bit (Intel)] on
 win32
 Type help, copyright, credits or license for more
 information.
  [] == []
 True
  ['-o'] == []
 False
  ['-o'] == False
 False
 

 Then why do I get the following results:
 C:\Python25\rg.pyhelp.py -o
 print arg ['-o']
 type(arg): type 'list'
 arg is True? False
 help.py version 1.0 Copyright RDEG (c) 2007
 ['-o'] is an unrecognized option.
 Progam Exit (0)

 python
 import sys

 _ver_ = 1.00

 if '-h' in sys.argv or '--help' in sys.argv:
 print
 print help.py Version, _ver_, Copyright RDEG (c) 2007
 print '''

 Options : -h, --help -- display this message
 Progam Exit (0)'''
 sys.exit(0)
 else:
 arg = sys.argv[1:]
 print 'print arg', arg
 print 'type(arg):', type(arg)
 print 'arg is True?', arg == True
 print help.py version, _ver_, Copyright RDEG (c) 2007
 print , arg, is an unrecognized option.
 print Progam Exit (0)
 sys.exit(0)
 /python


Does this clear things up?


import sys


_ver_ = 1.00


if '-h' in sys.argv or '--help' in sys.argv:
print
print help.py Version, _ver_, Copyright RDEG (c) 2007
print '''


Options : -h, --help -- display this message
Progam Exit (0)'''
sys.exit(0)
else:
arg = sys.argv[1:]
print 'print arg', arg
print 'type(arg):', type(arg)
print 'arg is True?', arg == True

print
if arg:
print 'was True'
else:
print 'was False'
print

print help.py version, _ver_, Copyright RDEG (c) 2007
print , arg, is an unrecognized option.
print Progam Exit (0)
sys.exit(0)

##C:\python25\userpython arghhh!.py -o
##print arg ['-o']
##type(arg): type 'list'
##arg is True? False
##
##was True
##
##help.py version 1.0 Copyright RDEG (c) 2007
## ['-o'] is an unrecognized option.
##Progam Exit (0)

##C:\python25\userpython arghhh!.py
##print arg []
##type(arg): type 'list'
##arg is True? False
##
##was False
##
##help.py version 1.0 Copyright RDEG (c) 2007
## [] is an unrecognized option.
##Progam Exit (0)

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


Re: test

2007-05-11 Thread Sherm Pendley
Joe Eagar [EMAIL PROTECTED] writes:

 sorry just a test.

Sorry, you failed. You missed alt.test by a mile.

sherm--

-- 
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting list Validity (True/False)

2007-05-11 Thread Grant Edwards
On Fri, May 11, 2007 at 01:20:44PM -0700, [EMAIL PROTECTED]
wrote:
 On May 11, 3:55 pm, Grant Edwards [EMAIL PROTECTED] wrote:
  You got those results because that's what your program does.
 
  Were you intending it to do something else?  If so, you're
  going to have to explain what you wanted, because we can't

 According to my output, it seems that arg is False even when I
 give an option of '-o' which according to the book should be
 True. No?

'-o' is not equal to True.  However, that does not mean it
evaluates to false when tested by an if or while statement.

 If arg == ['-o'] then shouldn't arg == True return True and
 skip the if?

No.  See the folloing link regarding the truth value of an
object:

http://docs.python.org/lib/truth.html

There are many objects other than True that evaluate to true
in the context of an if/while statement.  Just because an
objecty has a true truth-value doesn't mean that it is equal
to the True object.

-- 
Grant Edwards   grante Yow! Why don't you ever
  at   enter any CONTESTS,
   visi.comMarvin??  Don't you know
   your own ZIPCODE?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting list Validity (True/False)

2007-05-11 Thread nufuhsus
 On May 11, 2:28 pm, [EMAIL PROTECTED] wrote:





  Hello all,

  First let me appologise if this has been answered but I could not find
  an acurate answer to this interesting problem.

  If the following is true:
  C:\Python25\rg.pypython
  Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32
  bit (Intel)] on
  win32
  Type help, copyright, credits or license for more
  information.
   [] == []
  True
   ['-o'] == []
  False
   ['-o'] == False
  False

  Then why do I get the following results:
  C:\Python25\rg.pyhelp.py -o
  print arg ['-o']
  type(arg): type 'list'
  arg is True? False
  help.py version 1.0 Copyright RDEG (c) 2007
  ['-o'] is an unrecognized option.
  Progam Exit (0)

  python
  import sys

  _ver_ = 1.00

  if '-h' in sys.argv or '--help' in sys.argv:
  print
  print help.py Version, _ver_, Copyright RDEG (c) 2007
  print '''

  Options : -h, --help -- display this message
  Progam Exit (0)'''
  sys.exit(0)
  else:
  arg = sys.argv[1:]
  print 'print arg', arg
  print 'type(arg):', type(arg)
  print 'arg is True?', arg == True
  print help.py version, _ver_, Copyright RDEG (c) 2007
  print , arg, is an unrecognized option.
  print Progam Exit (0)
  sys.exit(0)
  /python



I hope this helps (I have tried to post this twice already but it
seems to be going somewhere else) you help me.

What I would like to happen is:
else:
arg = sys.argv[1:]
print 'print arg', arg
print 'type(arg):', type(arg)
print 'arg is True?', arg == True
if arg != True:
print No Option Provided
print help.py version, _ver_, Copyright RDEG (c) 2007
print , arg, is an unrecognized option.
print Progam Exit (0)
sys.exit(0)

But as you can see by my output ['-o'] seems to be False as well as []
so the if happens regardless.

According to the Book, ['-o'] should return True which should fail
the if, no?

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


Path python versions and Macosx

2007-05-11 Thread andrea
Hi everyone,
I use python on macosx with textmate as editor (great program).

I also use macport to install unix programs from the command line and
I find it great too.
Well I would like to have all my modules in the path when I'm using
textmate AND when I use the commandline (ipython), but because
textmate and the command line use different python versions they also
search in different places..

I found somewhere to write .pythonrc.py like this

#!/usr/bin/env python
import sys
PATH='/opt/local/lib/python2.4/site-packages/'
sys.path.append(PATH)
del sys

But it doesn't work either, I also tried to append this
PATH=/Library/Frameworks/Python.framework/Versions/Current/bin:/opt/
local/lib/python2.4/site-packages:${PATH}
to .bash_profile but nothing.

Where should I set this variables??

Thanks a lot

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


name capitalization of built-in types, True, and False

2007-05-11 Thread cbtube03
I see that naming conventions are such that classes usually get named
CamelCase. So why are the built-in types named all lowercase (like
list, dict, set, bool, etc.)?

And names for instances of classes are usually written in lowercase,
like foo in ``foo = CamelCase()``. So why are True and False
(instances of bool) capitalized? Shouldn't they be true and false?
Same goes for None.

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


Time

2007-05-11 Thread HMS Surprise
I need to convert the string below into epoch seconds so that I can
perform substractions and additions.  I assume I will need to break it
up into a time_t struct and use mktime. Two questions if you will
please:

Is there a way to use multiple separator characters for split similar
to awk's [|] style?

Could you point to an example of a python time_t struct?

05/11/2007 15:30

Thanks,

jvh

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


Re: Time

2007-05-11 Thread HMS Surprise


 Could you point to an example of a python time_t struct?


Or maybe that should be a tm struct???

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


Re: Simulating simple electric circuits

2007-05-11 Thread Bjoern Schliessmann
Dave Baum wrote:
 
 Sounds reasonable.  Depending on the size of your network, I might
 not worry too much about precomputing and saving information.  

Thanks. Yes, I'm actually testing it presently without any
optimizations and it runs very well.

 If your circuit has loops in it (where the output of a later relay
 circles back to an earlier relay's coil), then it is possible for
 the circuit to oscillate, so you might have to be careful about
 this.  

That's no substancial problem, with real relay circuits this happens
sometimes too :) (even in the systems I'm modelling)

After all, I'm quite pleased now with how well the last approach I
mentioned works. I've been able to model a medium complex switching
sequence today, and it worked flawlessly.

(The only problem I have now arises when I make relays react
delayed, using Twisted's reactor.callLater. Sometimes, a relay gets
current and loses it shortly after, but the event loop in rare
cases executes the status change functions the other way round (no
current, then current). I've been trying to fix that by
detection if a timer already runs. Anyhow, the inconsistencies only
vanish if I let the relays react delayless again. I'm going to have
to look into this further ...)


Regards,


Björn

P.S.: If anyone happens to be interested in details, just ask, I'll
post some code.

-- 
BOFH excuse #319:

Your computer hasn't been returning all the bits it gets from the
Internet.

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


Re: Interesting list Validity (True/False)

2007-05-11 Thread Carsten Haese
On Fri, 2007-05-11 at 12:28 -0700, [EMAIL PROTECTED] wrote:
 Hello all,
 
 First let me appologise if this has been answered but I could not find
 an acurate answer to this interesting problem.
 
 If the following is true:
 C:\Python25\rg.pypython
 Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32
 bit (Intel)] on
 win32
 Type help, copyright, credits or license for more
 information.
  [] == []
 True
  ['-o'] == []
 False
  ['-o'] == False
 False
 

Your confusion stems from the fact that for a given object, the answer
to the following three questions can be vastly different:
a) Is the object identical to True?
b) Is the object equal to True?
c) Is the object considered to be True in an if statement?

Observe:

 def check_trueness(obj):
...if obj is True: print repr(obj), is identical to True.
...else: print repr(obj), is not identical to True.
...if obj == True: print repr(obj), is equal to True.
...else: print repr(obj), is not equal to True.
...if obj: print repr(obj), is considered to be True by if.
...else: print repr(obj), is not considered to be True by if.
...
 check_trueness(True)
True is identical to True.
True is equal to True.
True is considered to be True by if.
 check_trueness(1)
1 is not identical to True.
1 is equal to True.
1 is considered to be True by if.
 check_trueness([1])
[1] is not identical to True.
[1] is not equal to True.
[1] is considered to be True by if.
 check_trueness([])
[] is not identical to True.
[] is not equal to True.
[] is not considered to be True by if.

Testing whether an object is equal to True is a much stronger test than
whether it is considered to be True in an 'if' statement, and the test
for identity is stronger still. Testing whether an object is equal to
True or identical to True is useless in most Python programs.

So, rather than doing this:

if thing==True:
   # blah

Just do this:

if thing:
   # blah

Hope this helps,

-- 
Carsten Haese
http://informixdb.sourceforge.net


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


Problems with grid() layout under tkinter

2007-05-11 Thread Thomas Jansson
Dear all

I am trying to make a small wrapper program for textbased program and
it is going well but I have one problem. Namely that I simply do not
understand how this grid thing work. I have assigned every widget a
specific placement in a grid but when I am running the program it
looks very strange. I hope you can help me.

A example of the program
http://tjansson.dyndns.dk/apache2-default/strange-grid.jpg
and the code
http://tjansson.dyndns.dk/tjansson/gui.py

Kind regards
Thomas Jansson

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


Re: Interesting list Validity (True/False)

2007-05-11 Thread nufuhsus
On May 11, 4:32 pm, Grant Edwards [EMAIL PROTECTED] wrote:
 On Fri, May 11, 2007 at 01:20:44PM -0700, [EMAIL PROTECTED]
 wrote:

  On May 11, 3:55 pm, Grant Edwards [EMAIL PROTECTED] wrote:
   You got those results because that's what your program does.

   Were you intending it to do something else?  If so, you're
   going to have to explain what you wanted, because we can't
  According to my output, it seems that arg is False even when I
  give an option of '-o' which according to the book should be
  True. No?

 '-o' is not equal to True.  However, that does not mean it
 evaluates to false when tested by an if or while statement.

  If arg == ['-o'] then shouldn't arg == True return True and
  skip the if?

 No.  See the folloing link regarding the truth value of an
 object:

 http://docs.python.org/lib/truth.html

 There are many objects other than True that evaluate to true
 in the context of an if/while statement.  Just because an
 objecty has a true truth-value doesn't mean that it is equal
 to the True object.

 --
 Grant Edwards   grante Yow! Why don't you ever
   at   enter any CONTESTS,
visi.comMarvin??  Don't you know
your own ZIPCODE?

OK. Then how would you differenciate between a call with an option
versus one without (e.g. help.py -o (where arg == ['-o']) Vs. help.py
(where arg == []))?

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


Re: Interesting list Validity (True/False)

2007-05-11 Thread Carsten Haese
On Fri, 2007-05-11 at 14:07 -0700, [EMAIL PROTECTED] wrote:
 OK. Then how would you differenciate between a call with an option
 versus one without (e.g. help.py -o (where arg == ['-o']) Vs. help.py
 (where arg == []))?

if arg:
  print With options
else:
  print Without options

-- 
Carsten Haese
http://informixdb.sourceforge.net


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


Re: Interesting list Validity (True/False)

2007-05-11 Thread nufuhsus
On May 11, 5:07 pm, Carsten Haese [EMAIL PROTECTED] wrote:
 On Fri, 2007-05-11 at 12:28 -0700, [EMAIL PROTECTED] wrote:
  Hello all,

  First let me appologise if this has been answered but I could not find
  an acurate answer to this interesting problem.

  If the following is true:
  C:\Python25\rg.pypython
  Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32
  bit (Intel)] on
  win32
  Type help, copyright, credits or license for more
  information.
   [] == []
  True
   ['-o'] == []
  False
   ['-o'] == False
  False

 Your confusion stems from the fact that for a given object, the answer
 to the following three questions can be vastly different:
 a) Is the object identical to True?
 b) Is the object equal to True?
 c) Is the object considered to be True in an if statement?

 Observe:

  def check_trueness(obj):

 ...if obj is True: print repr(obj), is identical to True.
 ...else: print repr(obj), is not identical to True.
 ...if obj == True: print repr(obj), is equal to True.
 ...else: print repr(obj), is not equal to True.
 ...if obj: print repr(obj), is considered to be True by if.
 ...else: print repr(obj), is not considered to be True by if.
 ... check_trueness(True)

 True is identical to True.
 True is equal to True.
 True is considered to be True by if. check_trueness(1)

 1 is not identical to True.
 1 is equal to True.
 1 is considered to be True by if. check_trueness([1])

 [1] is not identical to True.
 [1] is not equal to True.
 [1] is considered to be True by if. check_trueness([])

 [] is not identical to True.
 [] is not equal to True.
 [] is not considered to be True by if.

 Testing whether an object is equal to True is a much stronger test than
 whether it is considered to be True in an 'if' statement, and the test
 for identity is stronger still. Testing whether an object is equal to
 True or identical to True is useless in most Python programs.

 So, rather than doing this:

 if thing==True:
# blah

 Just do this:

 if thing:
# blah

 Hope this helps,

 --
 Carsten Haesehttp://informixdb.sourceforge.net- Hide quoted text -

 - Show quoted text -

Thanks Carsten ( all), I will give the if thing: # blah trick. I
guess I am starting to seem my own confusion. As Grant mentioned, I
was comparing ['-o'] to True which of course is False :o)

However, how would you test for the falsness of the object arg?

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


Re: Interesting list Validity (True/False)

2007-05-11 Thread Carsten Haese
On Fri, 2007-05-11 at 14:12 -0700, [EMAIL PROTECTED] wrote:
 However, how would you test for the falsness of the object arg?

if not arg:
   # stuff

-- 
Carsten Haese
http://informixdb.sourceforge.net


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


Re: Interesting list Validity (True/False)

2007-05-11 Thread nufuhsus
On May 11, 5:12 pm, [EMAIL PROTECTED] wrote:
 On May 11, 5:07 pm, Carsten Haese [EMAIL PROTECTED] wrote:





  On Fri, 2007-05-11 at 12:28 -0700, [EMAIL PROTECTED] wrote:
   Hello all,

   First let me appologise if this has been answered but I could not find
   an acurate answer to this interesting problem.

   If the following is true:
   C:\Python25\rg.pypython
   Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32
   bit (Intel)] on
   win32
   Type help, copyright, credits or license for more
   information.
[] == []
   True
['-o'] == []
   False
['-o'] == False
   False

  Your confusion stems from the fact that for a given object, the answer
  to the following three questions can be vastly different:
  a) Is the object identical to True?
  b) Is the object equal to True?
  c) Is the object considered to be True in an if statement?

  Observe:

   def check_trueness(obj):

  ...if obj is True: print repr(obj), is identical to True.
  ...else: print repr(obj), is not identical to True.
  ...if obj == True: print repr(obj), is equal to True.
  ...else: print repr(obj), is not equal to True.
  ...if obj: print repr(obj), is considered to be True by if.
  ...else: print repr(obj), is not considered to be True by if.
  ... check_trueness(True)

  True is identical to True.
  True is equal to True.
  True is considered to be True by if. check_trueness(1)

  1 is not identical to True.
  1 is equal to True.
  1 is considered to be True by if. check_trueness([1])

  [1] is not identical to True.
  [1] is not equal to True.
  [1] is considered to be True by if. check_trueness([])

  [] is not identical to True.
  [] is not equal to True.
  [] is not considered to be True by if.

  Testing whether an object is equal to True is a much stronger test than
  whether it is considered to be True in an 'if' statement, and the test
  for identity is stronger still. Testing whether an object is equal to
  True or identical to True is useless in most Python programs.

  So, rather than doing this:

  if thing==True:
 # blah

  Just do this:

  if thing:
 # blah

  Hope this helps,

  --
  Carsten Haesehttp://informixdb.sourceforge.net-Hide quoted text -

  - Show quoted text -

 Thanks Carsten ( all), I will give the if thing: # blah trick. I
 guess I am starting to seem my own confusion. As Grant mentioned, I
 was comparing ['-o'] to True which of course is False :o)

 However, how would you test for the falsness of the object arg?- Hide quoted 
 text -

 - Show quoted text -

Would that be arg is not True: # blah.?

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


Re: Interesting list Validity (True/False)

2007-05-11 Thread nufuhsus
On May 11, 5:19 pm, Carsten Haese [EMAIL PROTECTED] wrote:
 On Fri, 2007-05-11 at 14:12 -0700, [EMAIL PROTECTED] wrote:
  However, how would you test for the falsness of the object arg?

 if not arg:
# stuff

 --
 Carsten Haesehttp://informixdb.sourceforge.net

I think that is the ticket Carsten! Thanks for all the good
information all y'all.

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


Re: setting extra data to a wx.textctrl

2007-05-11 Thread Pom
[EMAIL PROTECTED] wrote:
 On May 10, 10:51 pm, Pom [EMAIL PROTECTED] wrote:
 Hello group!

 I have an application which uses a lot of mysql data fields, all the
 same data type (floats).

 I created a panel which executes a SELECT * FROM tablename and makes
 as much fields as needed, using de cursor.description as wx.statictext
 and the cursors field contents copied into wx.textctrls.

 At creation time, I loop over all the fields in the record and create a
 tuple which contains ((textctrl1, fieldname1), (textctrl2, fieldname2),
 ...)  so I can keep track of which textctrl holds which piece of fielddata.

 The problem I'm having is:

 to know the fieldname in an text_event, I use event.GetEventObject(),
 then perform an iteration over the tuple and when I find a match I use
 the field name to update the mysqltable.
 When having a few fields, this is ok.  But I have over 100 fields in 1
 record and it really slows things down.

 Now my question is: should I use a python dictionary (with an object as
 first lookup field) ?

 On windows, I've seen a Tag property in a textbox which was meant to
 be used for this kind of stuff.  Maybe it's better to override the
 wx.textctrl so I can add an extra string value?

 Anyone having the best solution for this ?

 thx!
 
 Both of your ideas seem sound to me. You could also look into using
 statically assigned IDs that increment by one. Then you could just
 increment or decrement by one and look up the field by ID. Of course,
 that might get ugly and there are some IDs that are supposedly
 reserved. But it's an idea.
 
 Also, I've heard that Dabo (http://dabodev.com/) is good for database
 work. You might look at that. To get the quickest and most on target
 answers to wxPython questions, I recommend the wxPython users-group
 mailing list: http://www.wxpython.org/maillist.php
 
 Mike
 


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


Re: Interesting list Validity (True/False)

2007-05-11 Thread Rob Williscroft
 wrote in news:[EMAIL PROTECTED] in 
comp.lang.python:

  [] == []
 True
  ['-o'] == []
 False
  ['-o'] == False
 False
 

To test wether something is true use if.
To test wether something is false use if not.

The python values True and False are for when you need to 
*store* a boolean value (for later testing).

I you want to to see if an arbitry expression would test as true
or false at the interactive prompt use bool():

 bool([])
False
 bool(['-o'])
True
 

There is *never* any need to write things like:

expression == True

or:
expression == False

Once you stop doing this things will become much simpler.

Rob.
-- 
http://www.victim-prime.dsl.pipex.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interesting list Validity (True/False)

2007-05-11 Thread [EMAIL PROTECTED]
On May 11, 3:36 pm, [EMAIL PROTECTED] wrote:
  On May 11, 2:28 pm, [EMAIL PROTECTED] wrote:







   Hello all,

   First let me appologise if this has been answered but I could not find
   an acurate answer to this interesting problem.

   If the following is true:
   C:\Python25\rg.pypython
   Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32
   bit (Intel)] on
   win32
   Type help, copyright, credits or license for more
   information.
[] == []
   True
['-o'] == []
   False
['-o'] == False
   False

   Then why do I get the following results:
   C:\Python25\rg.pyhelp.py -o
   print arg ['-o']
   type(arg): type 'list'
   arg is True? False
   help.py version 1.0 Copyright RDEG (c) 2007
   ['-o'] is an unrecognized option.
   Progam Exit (0)

   python
   import sys

   _ver_ = 1.00

   if '-h' in sys.argv or '--help' in sys.argv:
   print
   print help.py Version, _ver_, Copyright RDEG (c) 2007
   print '''

   Options : -h, --help -- display this message
   Progam Exit (0)'''
   sys.exit(0)
   else:
   arg = sys.argv[1:]
   print 'print arg', arg
   print 'type(arg):', type(arg)
   print 'arg is True?', arg == True
   print help.py version, _ver_, Copyright RDEG (c) 2007
   print , arg, is an unrecognized option.
   print Progam Exit (0)
   sys.exit(0)
   /python

 I hope this helps (I have tried to post this twice already but it
 seems to be going somewhere else) you help me.

 What I would like to happen is:
 else:
 arg = sys.argv[1:]
 print 'print arg', arg
 print 'type(arg):', type(arg)
 print 'arg is True?', arg == True
 if arg != True:
 print No Option Provided
 print help.py version, _ver_, Copyright RDEG (c) 2007
 print , arg, is an unrecognized option.
 print Progam Exit (0)
 sys.exit(0)

 But as you can see by my output ['-o'] seems to be False as well as []
 so the if happens regardless.

 According to the Book, ['-o'] should return True which should fail
 the if, no?

You're mistaking the porperties of an object for the object itself.

if arg:

tests the property (of being empty).

if arg==True:

tests the type property (whether a list is a boolean).

Change the code I gave above to be:

print
if arg:
print 'The argument given was:',arg
else:
print 'No argument given'
print

then you'll get

##C:\python25\userpython arghhh!.py -o
##print arg ['-o']
##type(arg): type 'list'
##arg is True? False
##
##The argument given was: ['-o']
##
##help.py version 1.0 Copyright RDEG (c) 2007
## ['-o'] is an unrecognized option.
##Progam Exit (0)
##
##C:\python25\userpython arghhh!.py
##print arg []
##type(arg): type 'list'
##arg is True? False
##
##No argument given
##
##help.py version 1.0 Copyright RDEG (c) 2007
## [] is an unrecognized option.
##Progam Exit (0)

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


Re: Interesting list Validity (True/False)

2007-05-11 Thread nufuhsus
Just an update of my output after Carsten and company's advice:

out
C:\Python25\rg.pyhelp.py -h

help.py Version 1.0 Copyright RDEG (c) 2007


Options : -h, --help -- display this message
Progam Exit (0)

C:\Python25\rg.pyhelp.py -i
print arg ['-i']
type(arg): type 'list'
arg is True? False
help.py version 1.0 Copyright RDEG (c) 2007
 ['-i'] is an unrecognized option.
Progam Exit (0)

C:\Python25\rg.pyhelp.py -i
help.py version 1.0 Copyright RDEG (c) 2007
 ['-i'] is an unrecognized option.
Progam Exit (0)

C:\Python25\rg.pyhelp.py
No Option provided
help.py version 1.0 Copyright RDEG (c) 2007
 No Option is an unrecognized option.
Progam Exit (0)
/out

Thanks again.


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


Re: Time

2007-05-11 Thread HMS Surprise
Sorry, reading a little closer I see that the time tuple is apparently
an ordinary list.

jvh

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


OMG BRITNEYS AT IT AGAIN AGAIN!!!!!!

2007-05-11 Thread wise . of . clean789
http://britneyboobs.blogspot.com/2007/05/britney-spears-slips-up-again-exposes.html
- Exclusive pics of Britney Spears..

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


Re: OMG BRITNEYS AT IT AGAIN AGAIN!!!!!!

2007-05-11 Thread notbob
On 2007-05-11, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 http://britneyboobs.blogspot.com/2007/05/britney-spears-slips-up-again-exposes.html
 - Exclusive pics of Britney Spears..

Britneyboobs what?... you take pride in being one?

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


Recursion limit problems

2007-05-11 Thread elventear
Hello everyone,

I am runing into recursion limit problems. I have found that the
culprit was related to the __hash__ function that I had assigned to
the objects that were added to a set.

Basically my __hash__ function is the following:

def __hash__(self):
out_int = 0
for property,value in self:
out_int ^= hash( property )^hash( value )

return out_int

And the iterator for this object is:

def __iter__(self):
for property,value in self.__dict__.iteritems():
yield property,value

After commenting the __hash__ function and using the default provided
by Python (I suppose it is based on the position in memory of the
object), the recursion limit problems went away. (This problem was
happening even after increasing the recursion limit to the maximum of
my platform, MacOSX).

I am not that versed in Python, so I don't know exactly I could do to
overcome this problem, any ideas are deeply appreciated.

Thanks!

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


  1   2   >