Re: Why does Python show the whole array?

2009-04-09 Thread Peter Otten
Lawrence D'Oliveiro wrote: > In message , Gilles Ganault > wrote: > >> test = "t...@gmail.com" >> isp = ["gmail.com", "yahoo.com"] >> for item in isp: >> if test.find(item): >> print item >> === output >> gmail.com >> yahoo.com >> === > > This is why conditional constructs should not acc

Can someone explain about the usage of unittest.TestSuite?

2009-04-09 Thread srinivasan srinivas
Hi, I would like to know about the unittest.TestSuite clearly like at what situations i can use this TestSuite? I am not getting the clear difference between this and unittest.TestCase. Thanks, Srini Cricket on your mind? Visit the ultimate cricket website. Enter http://beta.cricket.ya

Re: Simple CGI request and Python reply

2009-04-09 Thread Tim Roberts
Greg Corradini wrote: > >I'm trying to implement something very simple without using a Python >WebFramework and I need some advice. I want to send a comma delimited string >from the client to a server-side Python script. My initial plan was to use a >JavaScript function (see below) called "makereq

numpy.where

2009-04-09 Thread heidi taynton
Hi, I'm fairly new to programming and am having a probably cutting my arrays. I have two different 1d arrays, one of time, and the second energy.I want to cut both arrays of time min<=time<=max . I've created a 2d array with [time,energy] and I believe numpy.where is what I am lookin

Re: Why does Python show the whole array?

2009-04-09 Thread Miles
On Thu, Apr 9, 2009 at 2:59 AM, Peter Otten wrote: > Lawrence D'Oliveiro wrote: >> This is why conditional constructs should not accept any values other than >> True and False. > > So you think > > if test.find(item) == True: ... > > would have been better? Clearly, any comparison with a boolean l

Re: Why does Python show the whole array?

2009-04-09 Thread John Machin
On Apr 9, 4:53 pm, Lawrence D'Oliveiro wrote: > In message , Gilles Ganault > wrote: > > > test = "t...@gmail.com" > > isp = ["gmail.com", "yahoo.com"] > > for item in isp: > > if test.find(item): > > print item > > === output > > gmail.com > > yahoo.com > > === > > This is why conditional

Re: Why does Python show the whole array?

2009-04-09 Thread Niklas Norrthon
On 9 Apr, 09:49, Miles wrote: > On Thu, Apr 9, 2009 at 2:59 AM, Peter Otten wrote: > > Lawrence D'Oliveiro wrote: > >> This is why conditional constructs should not accept any values other than > >> True and False. > > > So you think > > > if test.find(item) == True: ... > > > would have been bett

Re: Floor value in math operators

2009-04-09 Thread John Machin
On Apr 9, 4:18 pm, AggieDan04 wrote: > On Apr 8, 12:08 pm, David Smith wrote: > > > > > Avi wrote: > > > Hi, > > > > This will be a very simple question to ask all the awesome programmers > > > here: > > > > How can I get answer in in decimals for such a math operator: > > > > 3/2 > > > > I get 1

Re: Why does Python show the whole array?

2009-04-09 Thread Steven D'Aprano
On Thu, 09 Apr 2009 18:53:13 +1200, Lawrence D'Oliveiro wrote: > This is why conditional constructs should not accept any values other > than True and False. I once tried this: for i in alist.sort(): and got an error I didn't understand because I failed to read the docs. Clearly for loops shou

Get the ipv6 address from a interface

2009-04-09 Thread Kai Timmer
Hello, i need a function that returns the ipv6 address from a given interface name. For ipv4 i use this one: def get_ip_address(ifname): s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) return socket.inet_ntoa(fcntl.ioctl( s.fileno(), 0x8915, # SIOCGIFADDR struct.pack('25

Re: numpy.where

2009-04-09 Thread Neil Crighton
heidi taynton mac.com> writes: > > Hi, > > I'm fairly new to programming and am having a probably cutting my arrays. I have two different 1d arrays, one > of time, and the second energy.I want to cut both arrays of time min<=time<=max . I've created a 2d array > with [time,energy] an

Re: Returning different types based on input parameters

2009-04-09 Thread Adam Olsen
On Apr 8, 8:09 am, George Sakkis wrote: > On Apr 7, 3:18 pm, Adam Olsen wrote: > > > On Apr 6, 3:02 pm, George Sakkis wrote: > > > > For example, it is common for a function f(x) to expect x to be simply > > > iterable, without caring of its exact type. Is it ok though for f to > > > return a li

Re: numpy.where

2009-04-09 Thread Neil Crighton
Carl Banks gmail.com> writes: > > >>> condition = (min_time <= time) & (time <= max_time) > > >>> new_time = time[condition] > > >>> new_energy = energy[condition] > > Won't work: condition is an array of ones and zeros, but you need to > index the arrays with indices. So, add a call to nonzero

Pathological regular expression

2009-04-09 Thread David Liang
Hi all, I'm having a weird problem with a regular expression (tested in 2.6 and 3.0): Basically, any of these: _re_comments = re.compile(r'^(([^\\]+|\\.|"([^"\\]+|\\.)*")*)#.*$') _re_comments = re.compile(r'^(([^#]+|\\.|"([^"\\]+|\\.)*")*)#.*$') _re_comments = re.compile(r'^(([^"]+|\\.|"([^"\\]+|\

Reading only headers

2009-04-09 Thread S.Selvam
Hi all, I want to read headers from web page and check whether its Content-Type is xml or not.I used the following code ... request = urllib2.Request(url, None, USER_AGENT) opener = urllib2.build_opener() datastream = opener.open(request) if datastream.headers.get('Content-Type','').find('xml

Re: Pathological regular expression

2009-04-09 Thread David Liang
On Apr 9, 2:56 am, David Liang wrote: > Hi all, > I'm having a weird problem with a regular expression (tested in 2.6 > and 3.0): > > Basically, any of these: > _re_comments = re.compile(r'^(([^\\]+|\\.|"([^"\\]+|\\.)*")*)#.*$') > _re_comments = re.compile(r'^(([^#]+|\\.|"([^"\\]+|\\.)*")*)#.*$')

Re: Pathological regular expression

2009-04-09 Thread David Liang
On Apr 9, 2:56 am, David Liang wrote: > Hi all, > I'm having a weird problem with a regular expression (tested in 2.6 > and 3.0): > > Basically, any of these: > _re_comments = re.compile(r'^(([^\\]+|\\.|"([^"\\]+|\\.)*")*)#.*$') > _re_comments = re.compile(r'^(([^#]+|\\.|"([^"\\]+|\\.)*")*)#.*$')

Re: Problem with PIL/Tkinter Program Example

2009-04-09 Thread Peter Otten
W. eWatson wrote: > Something is amiss here. The program produces a canvas in which one can > move an object around. The input file is hard coded (see open). If you > want to try it, you'll need to provide a file. Python error below. Name > space difficulty? > Traceback (most recent call last): >

Re: Retrieving a specific object from a list?

2009-04-09 Thread Jeremiah Dodds
On Thu, Apr 9, 2009 at 12:16 PM, andrew cooke wrote: > but when you need to access instances by more than one value (.bar and > .baz) then typically that's a hard problem, and there's a trade-off > somewhere. you might find writing a special container that contains two > dicts is useful. if so,

Re: numpy.where

2009-04-09 Thread Carl Banks
On Apr 9, 1:33 am, Neil Crighton wrote: > heidi taynton mac.com> writes: > > > > > Hi,   > > > I'm fairly new to programming and am having a probably cutting my arrays.  I > > have two different 1d arrays, one> of time, and the second energy.    I want > to cut both arrays of time > > min<=time<

Re: Retrieving a specific object from a list?

2009-04-09 Thread andrew cooke
andrew cooke wrote: [...] > but when you need to access instances by more than one value (.bar and > .baz) then typically that's a hard problem, and there's a trade-off > somewhere. you might find writing a special container that contains two > dicts is useful. if so, you might want to use weak r

Re: Get the ipv6 address from a interface

2009-04-09 Thread Roy Smith
In article <86176ef7-c2e0-4c5d-b883-d91672e3e...@w40g2000yqd.googlegroups.com>, Kai Timmer wrote: > Hello, > i need a function that returns the ipv6 address from a given interface > name. For ipv4 i use this one: > def get_ip_address(ifname): > s = socket.socket(socket.AF_INET, socket.SOCK_DG

Retrieving a specific object from a list?

2009-04-09 Thread Jeremiah Dodds
I've been looking over some of my code, and I've found something I do that has a bit of a smell to it. I've searched the group and docs, and haven't found much of anything that solves this particular problem, although I may just not be searching correctly. Anyhow, I find that often I'll have a lis

Re: Retrieving a specific object from a list?

2009-04-09 Thread andrew cooke
Jeremiah Dodds wrote: > I've been looking over some of my code, and I've found something I do that > has a bit of a smell to it. I've searched the group and docs, and haven't > found much of anything that solves this particular problem, although I may > just not be searching correctly. > > Anyhow,

Problem with PIL/Tkinter Program Example

2009-04-09 Thread W. eWatson
Something is amiss here. The program produces a canvas in which one can move an object around. The input file is hard coded (see open). If you want to try it, you'll need to provide a file. Python error below. Name space difficulty? #Mouse movement from Tkinter import * import PIL import Im

Re: Floor value in math operators

2009-04-09 Thread David Smith
AggieDan04 wrote: > On Apr 8, 12:08 pm, David Smith wrote: >> Avi wrote: >>> Hi, >>> This will be a very simple question to ask all the awesome programmers >>> here: >>> How can I get answer in in decimals for such a math operator: >>> 3/2 >>> I get 1. I want to get 1.5 >>> Thanks in advance, >>>

Re: Why does Python show the whole array?

2009-04-09 Thread Terry Reedy
Lawrence D'Oliveiro wrote: In message , Gilles Ganault wrote: test = "t...@gmail.com" isp = ["gmail.com", "yahoo.com"] for item in isp: if test.find(item): print item === output gmail.com yahoo.com === This is why conditional constructs should not accept any values other than True a

Re: Why does Python show the whole array?

2009-04-09 Thread Lawrence D'Oliveiro
In message <7e7a386f-d336-4186-822d- c6af0a581...@e38g2000vbe.googlegroups.com>, John Machin wrote: > On Apr 9, 4:53 pm, Lawrence D'Oliveiro central.gen.new_zealand> wrote: > >> This is why conditional constructs should not accept any values other >> than True and False. > > An alternative viewp

Re: group several methods under a attribute

2009-04-09 Thread Aahz
In article , Rhodri James wrote: > >You'll note that this is, all Aaron's protests to the contrary, >splitting your class up into multiple cooperating classes. Ayup. >If you're set on doing it like this, doing it this way avoids polluting >your namespace so much: > >class ClsB(object): > c

Re: numpy.where

2009-04-09 Thread Lou Pecora
In article , Neil Crighton wrote: > > I'm not sure exactly what you're trying to do, but maybe you want a boolean > array to select the right elements? So if time and energy are 1-d numpy arrays > of the same length: > > >>> condition = (min_time <= time) & (time <= max_time) > >>> new_time =

Unicode Decode Error

2009-04-09 Thread reetesh nigam
Hi All, There is some special character in my database. and when try to show on my UI it says return codecs.utf_8_decode(input, errors, True) UnicodeDecodeError: 'utf8' codec can't decode byte 0xc4 in position 10: unexpected end of data Can any one help to solve this problem -- http://mail.p

Re: Can someone explain about the usage of unittest.TestSuite?

2009-04-09 Thread Benjamin Peterson
srinivasan srinivas yahoo.co.in> writes: > > > Hi, > I would like to know about the unittest.TestSuite clearly like at what situations i can use this TestSuite? > I am not getting the clear difference between this and unittest.TestCase. You write your actual tests with TestCase. A TestSuite st

Re: Re: Why does Python show the whole array?

2009-04-09 Thread John Posner
Lawrence D'Oliveiro wrote: > Fine if it only happened once. But it's a commonly-made mistake. At some > point you have to conclude that not all those people are stupid, there > really is something wrong with the design. I think "something wrong with the design" is overstating the case a bit, an

Re: Unicode Decode Error

2009-04-09 Thread MRAB
reetesh nigam wrote: Hi All, There is some special character in my database. and when try to show on my UI it says return codecs.utf_8_decode(input, errors, True) UnicodeDecodeError: 'utf8' codec can't decode byte 0xc4 in position 10: unexpected end of data Can any one help to solve this p

Re: Why does Python show the whole array?

2009-04-09 Thread John Machin
On Apr 10, 12:35 am, John Posner wrote: > Lawrence D'Oliveiro wrote: > >  > Fine if it only happened once. But it's a commonly-made mistake. At some >  > point you have to conclude that not all those people are stupid, there >  > really is something wrong with the design. > > I think "something wr

Re: Why does Python show the whole array?

2009-04-09 Thread Tim Rowe
2009/4/9 Miles : > Clearly, any comparison with a boolean literal should be illegal.  ;) Hey, we could have strict type checking at compile time of /all/ operations, couldn't we? Anybody care to join me over at the Ada list? ;-) -- Tim Rowe -- http://mail.python.org/mailman/listinfo/python-list

Re: Unicode Decode Error

2009-04-09 Thread John Machin
On Apr 10, 12:40 am, MRAB wrote: > reetesh nigam wrote: > > Hi All, > > There is some special character in my database. > > and when try to show on my UI it says > > >     return codecs.utf_8_decode(input, errors, True) > > UnicodeDecodeError: 'utf8' codec can't decode byte 0xc4 in position > > 10

moving to processing from threading, global variables

2009-04-09 Thread rkmr...@gmail.com
hi i am trying to move from threading to processing package. this is the controller i used to spawn new threads, and it used the global variable done to check if it needs to spawn more threads or not. it worked great for me. it checks if there is new data to be processed every 30 seconds, and spawn

communication between objects - help

2009-04-09 Thread R. David Murray
Murali kumar wrote: > hi all.. > > > please see my attached document.. I think you'll get more help if you post in plain text. -- R. David Murray http://www.bitdance.com -- http://mail.python.org/mailman/listinfo/python-list

Why is it that *dbm modules don't provide an iterator? (Language design question)

2009-04-09 Thread Akira Kitada
Hi, I was wondering why *dbm modules in Python do not give us an iterable interface? Take a look at an example below """ # Python 2.6 >>> import gdbm >>> d = gdbm.open("spam.db", "n") >>> d["key1"] = "ham" >>> d["key2"] = "spam" >>> >>> for k in d: ... print k ... Traceback (most recent call

Autocompletion

2009-04-09 Thread Sorin Schwimmer
Hi All, Does anybody knows about a module to assist with text autocompletion for a given dictionary? Thanks, SxN __ Ask a question on any topic and get answers from real people. Go to Yahoo! Answers and share what you know

writing array

2009-04-09 Thread heidi taynton
Hey guys, I'm trying to write a new array from the one i already have but here is the catch: I want an array where n=# of data points used in previous point (rounded down) in every spot, I want to take 1.1**n data points and then take the mean of the data points. (i know there is a n

xml.dom.minidom getElementsByTagName white space issue

2009-04-09 Thread R. David Murray
Leonardo lozanne wrote: > Hi, >   > I'm getting some XML tags with white spaces from a web service and when I try > to get them with the getElements ByTagName I'm not able to do so. I'm getting > an empty list. What I'm doing is: >   > #XML_response is an xml string > xml_msg = xml.dom.minidom.p

Re: Autocompletion

2009-04-09 Thread Tim Chase
Does anybody knows about a module to assist with text autocompletion for a given dictionary? On machines with the GNU readline library available, Python provides the "readline" module which should allow for auto-completion. -tkc -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem with PIL/Tkinter Program Example

2009-04-09 Thread W. eWatson
Peter Otten wrote: W. eWatson wrote: Something is amiss here. The program produces a canvas in which one can move an object around. The input file is hard coded (see open). If you want to try it, you'll need to provide a file. Python error below. Name space difficulty? Traceback (most recent

safe eval of moderately simple math expressions

2009-04-09 Thread Joel Hedlund
Hi all! I'm writing a program that presents a lot of numbers to the user, and I want to let the user apply moderately simple arithmentics to these numbers. One possibility that comes to mind is to use the eval function, but since that sends up all kinds of warning flags in my head, I thought

Re: Why does Python show the whole array?

2009-04-09 Thread Hrvoje Niksic
John Posner writes: > Q: Has anyone on the python-dev list ever proposed a "string"-module > function that does the job of the "in" operator? Maybe this: > > if test.contains(item) # would return a Boolean value That's a string method, not a function in the string module. If you want a fun

Jython on Google AppEngine.

2009-04-09 Thread Alan Kennedy
Hi all, You may be interested to know that you can now run jython 2.2 out of the box on Google AppEngine, thanks to their new java support. A patch is required for jython 2.5, but we will be folding this in before the jython 2.5 RC release over the next few weeks. More details here http://jytho

Recommendations on Pythonic tree data structure design techniques

2009-04-09 Thread python
Any recommendations on Python based tree data structures that I can study? I'm working on an application that will model a basic outline structure (simple tree) and am looking for ideas on Pythonic implementation techniques. By outline I mean a traditional hierarchical document outline (section, ch

Re: safe eval of moderately simple math expressions

2009-04-09 Thread Matt Nordhoff
Joel Hedlund wrote: > Hi all! > > I'm writing a program that presents a lot of numbers to the user, and I > want to let the user apply moderately simple arithmentics to these > numbers. One possibility that comes to mind is to use the eval function, > but since that sends up all kinds of warning f

Re: Re: Why does Python show the whole array?

2009-04-09 Thread John Posner
Hrvoje Niksic wrote: > if test.contains(item) # would return a Boolean value > >> That's a string method, not a function in the string module. Oops, of course. import operator operator.contains('foo', 'o') That's pretty good, and IMHO a bit better than John Machin's suggestion

Re: Re: Why does Python show the whole array?

2009-04-09 Thread Peter Otten
John Posner wrote: > Given how common string maniuplations are, I guess I'm surprised that > Python hasn't yet made "contains()" into both a "string"-module function > *and* a string-object method. Could you explain why you prefer 'contains(belly, beer)' or 'belly.contains(beer)' over 'beer in be

Re: safe eval of moderately simple math expressions

2009-04-09 Thread Aaron Brady
On Apr 9, 10:56 am, Joel Hedlund wrote: > Hi all! > > I'm writing a program that presents a lot of numbers to the user, and I > want to let the user apply moderately simple arithmentics to these > numbers. One possibility that comes to mind is to use the eval function, > but since that sends up al

Re: Retrieving a specific object from a list?

2009-04-09 Thread Terry Reedy
Jeremiah Dodds wrote: I've been looking over some of my code, and I've found something I do that has a bit of a smell to it. I've searched the group and docs, and haven't found much of anything that solves this particular problem, although I may just not be searching correctly. Anyhow, I find

Re: Re: Why does Python show the whole array?

2009-04-09 Thread andrew cooke
Peter Otten wrote: > John Posner wrote: > >> Given how common string maniuplations are, I guess I'm surprised that >> Python hasn't yet made "contains()" into both a "string"-module function >> *and* a string-object method. > > Could you explain why you prefer 'contains(belly, beer)' > or 'belly.co

Re: safe eval of moderately simple math expressions

2009-04-09 Thread Terry Reedy
Joel Hedlund wrote: Hi all! I'm writing a program that presents a lot of numbers to the user, and I want to let the user apply moderately simple arithmentics to these numbers. One possibility that comes to mind is to use the eval function, but since that sends up all kinds of warning flags in

Re: Floor value in math operators

2009-04-09 Thread Avi
On Apr 9, 8:26 am, David Smith wrote: > AggieDan04 wrote: > > On Apr 8, 12:08 pm, David Smith wrote: > >> Avi wrote: > >>> Hi, > >>> This will be a very simple question to ask all the awesome programmers > >>> here: > >>> How can I get answer in in decimals for such a math operator: > >>> 3/2 > >

Scrap Posts

2009-04-09 Thread Avi
Hey Folks, I love this group and all the awesome and python savvy people who post here. However I also see some dumb posts like 'shoes' or something related to sex :( What can we do about crap like this? Can we clean it up? Or atleast flag some for removal. Moderators? -- http://mail.python.org/

Re: Scrap Posts

2009-04-09 Thread andrew cooke
are you on the mailing list (python-list@python.org) or reading via google groups? groups is full of junk, but the list is filtered. the (filtered) list is also available via gmane and similar. (disclaimer - i also use spamassasin so it's possible that is cleaning the mail up, but this discussi

Re: Scrap Posts

2009-04-09 Thread Matt Nordhoff
Avi wrote: > Hey Folks, > > I love this group and all the awesome and python savvy people who post > here. However I also see some dumb posts like 'shoes' or something > related to sex :( > > What can we do about crap like this? Can we clean it up? Or atleast > flag some for removal. > > Moderat

Re: numpy.where

2009-04-09 Thread Carl Banks
On Apr 9, 2:58 am, Neil Crighton wrote: > Carl Banks gmail.com> writes: > > > > >>> condition = (min_time <= time) & (time <= max_time) > > > >>> new_time = time[condition] > > > >>> new_energy = energy[condition] > > > Won't work: condition is an array of ones and zeros, but you need to > > inde

Re: Returning different types based on input parameters

2009-04-09 Thread Aahz
In article , George Sakkis wrote: > >To take it further, what if f wants to return different types, >differing even in a duck-type sense? That's easier to illustrate in a >API-extension scenario. Say that there is an existing function `solve >(x)` that returns `Result` instances. Later someone w

Re: Recommendations on Pythonic tree data structure design techniques

2009-04-09 Thread Daniel Fetchinson
> Any recommendations on Python based tree data structures that I > can study? I'm working on an application that will model a basic > outline structure (simple tree) and am looking for ideas on > Pythonic implementation techniques. By outline I mean a > traditional hierarchical document outline (s

Re: safe eval of moderately simple math expressions

2009-04-09 Thread Paul McGuire
On Apr 9, 10:56 am, Joel Hedlund wrote: > Hi all! > > I'm writing a program that presents a lot of numbers to the user, and I > want to let the user apply moderately simple arithmentics to these > numbers. Joel - Take a look at the examples page on the pyparsing wiki (http:// pyparsing.wikispace

Re: Scrap Posts

2009-04-09 Thread Grant Edwards
On 2009-04-09, Avi wrote: > I love this group and all the awesome and python savvy people > who post here. However I also see some dumb posts like 'shoes' > or something related to sex :( And occasionally both. ;) > What can we do about crap like this? I don't know about "we", but you have a f

Re: Can someone explain about the usage of unittest.TestSuite?

2009-04-09 Thread Krishnakant
On Thu, 2009-04-09 at 12:35 +0530, srinivasan srinivas wrote: > Hi, > I would like to know about the unittest.TestSuite clearly like at what > situations i can use this TestSuite? I am not getting the clear difference > between this and unittest.TestCase. > > Thanks, > Srini > Isn't that pritt

Re: Jython on Google AppEngine.

2009-04-09 Thread Jason Scheirer
On Apr 9, 9:12 am, Alan Kennedy wrote: > Hi all, > > You may be interested to know that you can now run jython 2.2 out of > the box on Google AppEngine, thanks to their new java support. > > A patch is required for jython 2.5, but we will be folding this in > before the jython 2.5 RC release over

Re: safe eval of moderately simple math expressions

2009-04-09 Thread CTO
how about sympy? http://code.google.com/p/sympy/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Re: Re: Why does Python show the whole array?

2009-04-09 Thread John Posner
> Peter Otten wrote: >> Could you explain why you prefer 'contains(belly, beer)' >> or 'belly.contains(beer)' over 'beer in belly'? The last form may be a bit >> harder to find in the documentation, but once a newbie has learned about >> it he'll find it easy to remember. andrew cooke wrote:

Re: Recommendations on Pythonic tree data structure design techniques

2009-04-09 Thread CTO
I'm writing a Python graph library (called Graphine) that's pretty easy to use and does what you want. It is pre-alpha right now, but if you're interested please let me know- I'm very interested in hearing outside opinions. -- http://mail.python.org/mailman/listinfo/python-list

Re: Recommendations on Pythonic tree data structure design techniques

2009-04-09 Thread andrew cooke
pyt...@bdurham.com wrote: > Any recommendations on Python based tree data structures that I > can study? I'm working on an application that will model a basic > outline structure (simple tree) and am looking for ideas on > Pythonic implementation techniques. By outline I mean a > traditional hierar

calculate field in ARCGIS

2009-04-09 Thread Lydia
Hi Python users, I ran into a problem with python coding in ARCGIS. Does anybody have the experience in dealing with this? I need to calculate NEWFIELD based on OLDFIELD under condition: if OLDFIELD == 0 then return string "B" otherwise return "". codeblock = "def codefun(code): if code == 0

regexp strangeness

2009-04-09 Thread Dale Amon
This finds nothing: import re import string card = "abcdef" DEC029 = re.compile("[^&0-9A-Z/ $*,.\-:#@'=\"[<(+\^!);\\\]%_>?]") errs = DEC029.findall(card.strip("\n\r")) print errs This works correctly: import re import string card = "abcdef" DEC029 = re.compile("[^&0-9A-

Re: calculate field in ARCGIS

2009-04-09 Thread Chris Rebert
On Thu, Apr 9, 2009 at 12:42 PM, Lydia wrote: > Hi Python users, > > I ran into a problem with python coding in ARCGIS. Does anybody have the > experience in dealing with this? > > I need to calculate NEWFIELD based on OLDFIELD under condition: if  OLDFIELD > == 0 then return string "B" otherwise

Re: regexp strangeness

2009-04-09 Thread Peter Otten
Dale Amon wrote: > This finds nothing: > > import re > import string > card = "abcdef" > DEC029 = re.compile("[^&0-9A-Z/ $*,.\-:#@'=\"[<(+\^!);\\\]%_>?]") > errs = DEC029.findall(card.strip("\n\r")) > print errs > > This works correctly: > > import re > import string > card

Re: Why is it that *dbm modules don't provide an iterator? (Language design question)

2009-04-09 Thread Joshua Kugler
Akira Kitada wrote: > The loop has to be: > """ k = d.firstkey() while k != None: > ...print k > ...k = d.nextkey(k) > key2 > key1 > """ Why not for key in d.keys(): print key That worked for me. j -- http://mail.python.org/mailman/listinfo/python-list

Re: calculate field in ARCGIS

2009-04-09 Thread Lydia
Thanks for the suggestion. But I guess under Python this doesn't work. I tried putting the code in different ways. But still not worked. codeblock = "def codefun(code): \\ if code == 0: \\ return \"B\" \\ els

How to import a module so that the current globals are available to the module?

2009-04-09 Thread mrstevegross
I'm trying to import a module so that the globals() of the importer module are available to the imported module itself. Consider the following scenario: === mymod.py === def go(): some_special_function(1,2) # 'some_special_function' is a built-in function available in the scope of foo.py (see

Re: cgi file limit size?

2009-04-09 Thread davidj411
i am using these modules: import cgi,time import cgitb; cgitb.enable() iis webmapping now works with -U (key was to remove '-u' from the grouping of "s"'s: C:\Python25\python.exe -u "%s %s" here is the form html code: Server name: File name: i increased the timeout on the IIS server to 2,200

Re: Why is it that *dbm modules don't provide an iterator? (Language design question)

2009-04-09 Thread Akira Kitada
keys() returns a list and my question was not about "how to" but more like "why"... I assumed there were some decisions behind this, rather than it's just not implemented yet. Best, On Friday, April 10, 2009, Joshua Kugler wrote: > Akira Kitada wrote: > >> The loop has to be: >> """ > k = d.f

is this possible (getting info off web page)

2009-04-09 Thread Esmail
Hi, I am trying to keep track of two flight bookings on the kayak.com web site, and would like to automate my query using Python. If I enter the url below myself into the browser, a form gets filled out and the site searches for flights. I would love to be able to have a simple python script whi

Re: Jython on Google AppEngine.

2009-04-09 Thread Tino Wildenhain
Jason Scheirer wrote: On Apr 9, 9:12 am, Alan Kennedy wrote: Hi all, You may be interested to know that you can now run jython 2.2 out of the box on Google AppEngine, thanks to their new java support. ... Finally! A way to run Python on App Engine! ? Is that some kind of weird humor? :-)

Re: Why is it that *dbm modules don't provide an iterator? (Language design question)

2009-04-09 Thread skip
Joshua> Why not Joshua> for key in d.keys(): Joshua> print key Joshua> That worked for me. Time & space. One motivation for using dbm files is to write large (huge, in fact) mappings to disk. Simply reconstituting the entire set of keys may consume a lot of time (they must

Re: regexp strangeness

2009-04-09 Thread MRAB
Peter Otten wrote: Dale Amon wrote: This finds nothing: import re import string card = "abcdef" DEC029 = re.compile("[^&0-9A-Z/ $*,.\-:#@'=\"[<(+\^!);\\\]%_>?]") The regular expression you're actually providing is: >>> print "[^&0-9A-Z/ $*,.\-:#@'=\"[<(+\^!);\\\]%_>?]" [^&0-9A-Z/

RE: is this possible (getting info off web page)

2009-04-09 Thread bruce
Hi Esmail. I've not looked at the site. however, i can give you some general pointers that might help you in solving your issue. first off, try to accomplish your goal, using curl, or one of the other cmdline apps that fetch page data. this allows you to quickly nail down any issues that might oc

Re: calculate field in ARCGIS

2009-04-09 Thread MRAB
Lydia wrote: Thanks for the suggestion. But I guess under Python this doesn't work. I tried putting the code in different ways. But still not worked. codeblock = "def codefun(code): \\ if code == 0: \\ return \"B\" \\

Re: Best way to start

2009-04-09 Thread Ken Dere
Avi wrote: > Hi, > > What is a good way to learn Python? > > Do you recommend going by a book (suggestions welcome) or learning > with tutorials? Both? > > Thanks in advance, > Avi A good book is Learning Python by Lutz (O'Reilly) Then, you need to do some actual programming. The best way is

Re: How to import a module so that the current globals are available to the module?

2009-04-09 Thread Scott David Daniels
mrstevegross wrote: I'm trying to import a module so that the globals() of the importer module are available to the imported module itself One awkward solution is to deliberately initialize mymod.py That will work, but it's a bit ugly. Plus, I have to repeat it for every module with t

Re: completly unrelated to python but i had to post it

2009-04-09 Thread Ben Finney
janus99 writes: > if u've never read it, it'll knock ur socks off, and the comments > are riveting Please save it for another forum in future. -- \ “It is wrong to think that the task of physics is to find out | `\ how nature *is*. Physics concerns what we can *say* about | _o

Re: How to import a module so that the current globals are available to the module?

2009-04-09 Thread Peter Otten
mrstevegross wrote: > I'm trying to import a module so that the globals() of the importer > module are available to the imported module itself. Consider the > following scenario: > > === mymod.py === > def go(): > some_special_function(1,2) > # 'some_special_function' is a built-in function a

Re: calculate field in ARCGIS

2009-04-09 Thread Jason Scheirer
On Apr 9, 12:55 pm, Chris Rebert wrote: > On Thu, Apr 9, 2009 at 12:42 PM, Lydia wrote: > > Hi Python users, > > > I ran into a problem with python coding in ARCGIS. Does anybody have the > > experience in dealing with this? > > > I need to calculate NEWFIELD based on OLDFIELD under condition: if

[ANN] Introduction to Python course, San Francisco, Jun 2009

2009-04-09 Thread wesley chun
Need to get up-to-speed with Python as quickly as possible? Come join me, Wesley Chun, author of Prentice-Hall's bestseller "Core Python Programming," for a comprehensive intro course coming up this June in beautiful Northern California! Please pass on this note to whomever you think may be interes

Re: Get the ipv6 address from a interface

2009-04-09 Thread Martin v. Löwis
> I'm not 100% sure what you're trying to do, but the above is horribly > non-portable. You probably want to be looking at socket.getpeername() and > socket.getsockname(). This only works if you are actually connected. I think he wants to find out the local address without actually connecting.

Re: Get the ipv6 address from a interface

2009-04-09 Thread Martin v. Löwis
> which works great. But i am not enough into python to port that to > ipv6. It has to work under linux only. Any help is appreciated. Not sure how universal this is, but I would read /proc/net/if_inet6. At least, that's what ifconfig does, and it seems to work fine. mar...@mira:~$ cat /proc/net/

Re: Why is it that *dbm modules don't provide an iterator? (Language design question)

2009-04-09 Thread Martin v. Löwis
> I assumed there were some decisions behind this, rather than it's just > not implemented yet. I believe this assumption is wrong - it's really that no code has been contributed to do that. For gdbm, you can also use the firstkey/nextkey methods. Regards, Martin -- http://mail.python.org/mailma

Re: How to import a module so that the current globals are available to the module?

2009-04-09 Thread Carl Banks
On Apr 9, 2:25 pm, mrstevegross wrote: > I'm trying to import a module so that the globals() of the importer > module are available to the imported module itself. [snip] In general, the way I recommend to deal with this issue (aside from reorganizing your code) is to pass the function you want t

Re: Why does Python show the whole array?

2009-04-09 Thread John Machin
On Apr 10, 2:36 am, John Posner wrote: > Hrvoje Niksic wrote: > >  >  if test.contains(item)     # would return a Boolean value >  > > >  >> That's a string method, not a function in the string module. > > Oops, of course. > >   import operator >   operator.contains('foo', 'o') > > That's

Re: Why is it that *dbm modules don't provide an iterator? (Language design question)

2009-04-09 Thread andrew cooke
"Martin v. Löwis" wrote: >> I assumed there were some decisions behind this, rather than it's just >> not implemented yet. > > I believe this assumption is wrong - it's really that no code has been > contributed to do that. But doesn't the issue at http://bugs.python.org/issue662923 imply that the

Open source web crawler with mysql integration

2009-04-09 Thread dhenews
I'm looking for a crawler that can spider my site and toss the results into mysql so, in turn, that database can be indexed by Sphinx Search. Since I don't want to reinvent the wheel, is anyone aware of any open source projects or code snippets that can already handle this? Thanks for any advice.

Re: Open source web crawler with mysql integration

2009-04-09 Thread Daniel Fetchinson
> I'm looking for a crawler that can spider my site and toss the results > into mysql so, in turn, that database can be indexed by Sphinx Search. > > Since I don't want to reinvent the wheel, is anyone aware of any open > source projects or code snippets that can already handle this? Have a look a

  1   2   >